9 if ( ! isset( $gravityview ) || empty( $gravityview->template ) ) {
10 gravityview()->log->error(
'{file} template loaded without context', array(
'file' => __FILE__ ) );
24 switch ( $gravityview->field->field->inputType ) {
45 echo apply_filters(
'gravityview_field_tick',
'<span class="dashicons dashicons-yes"></span>', $gravityview->entry,
$field->as_configuration(), $gravityview );
50 echo RGFormsModel::get_choice_text(
$field->field, $gravityview->value,
$field->ID );
55 if ( class_exists(
'GFSurvey' ) && is_callable( array(
'GFSurvey',
'get_instance') ) ) {
56 wp_register_style(
'gsurvey_css', GFSurvey::get_instance()->get_base_url() .
'/css/gsurvey.css' );
57 wp_print_styles(
'gsurvey_css' );
71 $raw_value = is_array( $gravityview->value ) ? $gravityview->value : array(
$field->ID =>
':' . $gravityview->value );
73 $output_values = array();
74 foreach( $raw_value as $row => $row_values ) {
75 list( $_likert_row, $row_value ) = array_pad( explode(
':', $row_values ), 2,
'' );
87 $output_values[] = RGFormsModel::get_choice_text(
$field->field, $row_value, $row );
93 $single_input_field = clone
$field->field;
94 $single_input_field->id =
$field->ID;
95 $single_input_field->gsurveyLikertEnableMultipleRows =
false;
96 $output_values[] = $single_input_field->get_field_input( array(
'id' =>
$field->form_id ), $row_value );
108 $glue = apply_filters(
'gravityview/template/field/survey/glue',
'; ', $gravityview );
110 echo implode(
$glue, $output_values );
116 $choice_text = RGFormsModel::get_choice_text(
$field->field, $gravityview->value,
$input_id );
118 if( ! in_array(
$choice_display, array(
'stars',
'dashicons',
'emoji' ),
true ) ) {
123 $choices =
$field->field->choices;
124 $choice_values = wp_list_pluck( $choices,
'value', $gravityview->value );
125 $starred_index = array_search( $gravityview->value, $choice_values );
126 $star_a11y_label = sprintf( __(
'%s (%d out of %d stars)',
'gk-gravityview'), $choice_text, ( $starred_index + 1 ),
sizeof( $choice_values ) );
135 do_action(
'gravityview/template/field/survey/rating/before',
$field, $gravityview );
137 echo
'<span class="gv-field-survey-screen-reader-text">' . esc_html( $star_a11y_label ) .
'</span>';
138 foreach ( $choices as $current_index => $choice_value ) {
141 $empty = ( $current_index > $starred_index );
142 $css_class =
'gv-field-survey-star-' . ( $empty ?
'empty' :
'filled' );
144 echo sprintf(
'<span class="%s" title="%s"></span>', esc_attr( $css_class ), esc_attr( $choice_value[
'text'] ) );
gravityview_get_input_id_from_id( $field_id='')
Very commonly needed: get the # of the input based on a full field ID.
static get_choice_score( $field, $value, $input_id=0)
Returns the score for a choice at $value.
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
gravityview()
The main GravityView wrapper function.