@@ -10,14 +10,14 @@ discard block |
||
| 10 | 10 | $search_field = $gravityview_view->search_field; |
| 11 | 11 | |
| 12 | 12 | // Make sure that there are choices to display |
| 13 | -if( empty( $search_field['choices'] ) ) { |
|
| 13 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
| 14 | 14 | gravityview()->log->debug( 'search-field-select.php - No choices for field' ); |
| 15 | 15 | return; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if( is_array( $search_field['value'] ) ) { |
|
| 18 | +if ( is_array( $search_field[ 'value' ] ) ) { |
|
| 19 | 19 | gravityview()->log->debug( 'search-field-select.php - Array values passed; using first value.' ); |
| 20 | - $search_field['value'] = reset( $search_field['value'] ); |
|
| 20 | + $search_field[ 'value' ] = reset( $search_field[ 'value' ] ); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -26,19 +26,19 @@ discard block |
||
| 26 | 26 | * @param string $default_option Default: `—` (—) |
| 27 | 27 | * @param string $field_type Field type: "select" or "multiselect" |
| 28 | 28 | */ |
| 29 | -$default_option = apply_filters('gravityview/extension/search/select_default', '—', 'select' ); |
|
| 29 | +$default_option = apply_filters( 'gravityview/extension/search/select_default', '—', 'select' ); |
|
| 30 | 30 | |
| 31 | 31 | ?> |
| 32 | 32 | <div class="gv-search-box gv-search-field-select"> |
| 33 | - <?php if( ! gv_empty( $search_field['label'], false, false ) ) { ?> |
|
| 34 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label> |
|
| 33 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { ?> |
|
| 34 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
| 35 | 35 | <?php } ?> |
| 36 | 36 | <p> |
| 37 | - <select name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"> |
|
| 38 | - <option value="" <?php gv_selected( '', $search_field['value'], true ); ?>><?php echo esc_html( $default_option ); ?></option> |
|
| 37 | + <select name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"> |
|
| 38 | + <option value="" <?php gv_selected( '', $search_field[ 'value' ], true ); ?>><?php echo esc_html( $default_option ); ?></option> |
|
| 39 | 39 | <?php |
| 40 | - foreach( $search_field['choices'] as $choice ) : ?> |
|
| 41 | - <option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( esc_attr( $choice['value'] ), esc_attr( $search_field['value'] ), true ); ?>><?php echo esc_html( $choice['text'] ); ?></option> |
|
| 40 | + foreach ( $search_field[ 'choices' ] as $choice ) : ?> |
|
| 41 | + <option value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" <?php gv_selected( esc_attr( $choice[ 'value' ] ), esc_attr( $search_field[ 'value' ] ), true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option> |
|
| 42 | 42 | <?php endforeach; ?> |
| 43 | 43 | </select> |
| 44 | 44 | </p> |
@@ -15,34 +15,34 @@ |
||
| 15 | 15 | $field_info_items = array(); |
| 16 | 16 | |
| 17 | 17 | // Fields with IDs, not like Source URL or Entry ID |
| 18 | - if( is_numeric( $this->id ) ) { |
|
| 18 | + if ( is_numeric( $this->id ) ) { |
|
| 19 | 19 | |
| 20 | - $field_type_title = GFCommon::get_field_type_title( $this->item['input_type'] ); |
|
| 20 | + $field_type_title = GFCommon::get_field_type_title( $this->item[ 'input_type' ] ); |
|
| 21 | 21 | |
| 22 | - $field_info_items[] = array( |
|
| 23 | - 'value' => sprintf( __('Type: %s', 'gravityview'), $field_type_title ) |
|
| 22 | + $field_info_items[ ] = array( |
|
| 23 | + 'value' => sprintf( __( 'Type: %s', 'gravityview' ), $field_type_title ) |
|
| 24 | 24 | ); |
| 25 | 25 | |
| 26 | - $field_info_items[] = array( |
|
| 27 | - 'value' => sprintf( __('Field ID: %s', 'gravityview'), $this->id ), |
|
| 26 | + $field_info_items[ ] = array( |
|
| 27 | + 'value' => sprintf( __( 'Field ID: %s', 'gravityview' ), $this->id ), |
|
| 28 | 28 | ); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if( !empty( $this->item['desc'] ) ) { |
|
| 32 | - $field_info_items[] = array( |
|
| 33 | - 'value' => $this->item['desc'] |
|
| 31 | + if ( ! empty( $this->item[ 'desc' ] ) ) { |
|
| 32 | + $field_info_items[ ] = array( |
|
| 33 | + 'value' => $this->item[ 'desc' ] |
|
| 34 | 34 | ); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if( !empty( $this->item['adminLabel'] ) ) { |
|
| 38 | - $field_info_items[] = array( |
|
| 39 | - 'value' => sprintf( __('Admin Label: %s', 'gravityview' ), $this->item['adminLabel'] ), |
|
| 37 | + if ( ! empty( $this->item[ 'adminLabel' ] ) ) { |
|
| 38 | + $field_info_items[ ] = array( |
|
| 39 | + 'value' => sprintf( __( 'Admin Label: %s', 'gravityview' ), $this->item[ 'adminLabel' ] ), |
|
| 40 | 40 | 'class' => 'gv-sublabel' |
| 41 | 41 | ); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - $field_info_items[] = array( |
|
| 45 | - 'value' => sprintf( __('Form ID: %s', 'gravityview' ), $this->form_id ), |
|
| 44 | + $field_info_items[ ] = array( |
|
| 45 | + 'value' => sprintf( __( 'Form ID: %s', 'gravityview' ), $this->form_id ), |
|
| 46 | 46 | 'hide_in_picker' => true, |
| 47 | 47 | ); |
| 48 | 48 | |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | protected $form_id; |
| 46 | 46 | |
| 47 | - function __construct( $title = '', $item_id, $item = array(), $settings = array(), $form_id = null) { |
|
| 47 | + function __construct( $title = '', $item_id, $item = array(), $settings = array(), $form_id = null ) { |
|
| 48 | 48 | |
| 49 | 49 | // Backward compat |
| 50 | - if ( ! empty( $item['type'] ) ) { |
|
| 51 | - $item['input_type'] = $item['type']; |
|
| 52 | - unset( $item['type'] ); |
|
| 50 | + if ( ! empty( $item[ 'type' ] ) ) { |
|
| 51 | + $item[ 'input_type' ] = $item[ 'type' ]; |
|
| 52 | + unset( $item[ 'type' ] ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Prevent items from not having index set |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $this->id = $item_id; |
| 72 | 72 | $this->form_id = $form_id; |
| 73 | 73 | $this->settings = $settings; |
| 74 | - $this->label_type = $item['label_type']; |
|
| 74 | + $this->label_type = $item[ 'label_type' ]; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | foreach ( $field_info_items as $item ) { |
| 117 | 117 | |
| 118 | - if( \GV\Utils::get( $item, 'hide_in_picker', false ) ) { |
|
| 118 | + if ( \GV\Utils::get( $item, 'hide_in_picker', false ) ) { |
|
| 119 | 119 | continue; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $class = isset( $item['class'] ) ? sanitize_html_class( $item['class'] ) . ' description' : 'description'; |
|
| 122 | + $class = isset( $item[ 'class' ] ) ? sanitize_html_class( $item[ 'class' ] ) . ' description' : 'description'; |
|
| 123 | 123 | // Add the title in case the value's long, in which case, it'll be truncated by CSS. |
| 124 | 124 | $output .= '<span class="' . $class . '">'; |
| 125 | - $output .= esc_html( $item['value'] ); |
|
| 125 | + $output .= esc_html( $item[ 'value' ] ); |
|
| 126 | 126 | $output .= '</span>'; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -150,29 +150,29 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | // $settings_html will just be hidden inputs if empty. Otherwise, it'll have an <ul>. Ugly hack, I know. |
| 152 | 152 | // TODO: Un-hack this |
| 153 | - $hide_settings_link = ( empty( $this->item['settings_html'] ) || strpos( $this->item['settings_html'], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : ''; |
|
| 153 | + $hide_settings_link = ( empty( $this->item[ 'settings_html' ] ) || strpos( $this->item[ 'settings_html' ], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : ''; |
|
| 154 | 154 | $settings_link = sprintf( '<a href="#settings" class="dashicons-admin-generic dashicons %s" title="%s"></a>', $hide_settings_link, esc_attr( $settings_title ) ); |
| 155 | 155 | |
| 156 | 156 | // Should we show the icon that the field is being used as a link to single entry? |
| 157 | - $hide_show_as_link_class = empty( $this->settings['show_as_link'] ) ? 'hide-if-js' : ''; |
|
| 157 | + $hide_show_as_link_class = empty( $this->settings[ 'show_as_link' ] ) ? 'hide-if-js' : ''; |
|
| 158 | 158 | $show_as_link = '<span class="dashicons dashicons-admin-links ' . $hide_show_as_link_class . '" title="' . esc_attr( $single_link_title ) . '"></span>'; |
| 159 | 159 | |
| 160 | 160 | // When a field label is empty, use the Field ID |
| 161 | 161 | $label = empty( $this->title ) ? sprintf( _x( 'Field #%s (No Label)', 'Label in field picker for empty label', 'gravityview' ), $this->id ) : $this->title; |
| 162 | 162 | |
| 163 | 163 | // If there's a custom label, and show label is checked, use that as the field heading |
| 164 | - if ( ! empty( $this->settings['custom_label'] ) && ! empty( $this->settings['show_label'] ) ) { |
|
| 165 | - $label = $this->settings['custom_label']; |
|
| 166 | - } else if ( ! empty( $this->item['customLabel'] ) ) { |
|
| 167 | - $label = $this->item['customLabel']; |
|
| 164 | + if ( ! empty( $this->settings[ 'custom_label' ] ) && ! empty( $this->settings[ 'show_label' ] ) ) { |
|
| 165 | + $label = $this->settings[ 'custom_label' ]; |
|
| 166 | + } else if ( ! empty( $this->item[ 'customLabel' ] ) ) { |
|
| 167 | + $label = $this->item[ 'customLabel' ]; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $output = '<h5 class="selectable gfield field-id-' . esc_attr( $this->id ) . '">'; |
| 171 | 171 | |
| 172 | 172 | $label = esc_attr( $label ); |
| 173 | 173 | |
| 174 | - if ( ! empty( $this->item['parent'] ) ) { |
|
| 175 | - $label .= ' <small>(' . esc_attr( $this->item['parent']['label'] ) . ')</small>'; |
|
| 174 | + if ( ! empty( $this->item[ 'parent' ] ) ) { |
|
| 175 | + $label .= ' <small>(' . esc_attr( $this->item[ 'parent' ][ 'label' ] ) . ')</small>'; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // Name of field / widget |
@@ -188,10 +188,10 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | $output .= '</h5>'; |
| 190 | 190 | |
| 191 | - $container_class = ! empty( $this->item['parent'] ) ? ' gv-child-field' : ''; |
|
| 192 | - $data_form_id = ! empty( $this->form_id ) ? 'data-formid="' . esc_attr( $this->form_id ) . '"' : ''; |
|
| 191 | + $container_class = ! empty( $this->item[ 'parent' ] ) ? ' gv-child-field' : ''; |
|
| 192 | + $data_form_id = ! empty( $this->form_id ) ? 'data-formid="' . esc_attr( $this->form_id ) . '"' : ''; |
|
| 193 | 193 | |
| 194 | - $output = '<div data-fieldid="' . esc_attr( $this->id ) . '" ' . $data_form_id . ' data-inputtype="' . esc_attr( $this->item['input_type'] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item['settings_html'] . '</div>'; |
|
| 194 | + $output = '<div data-fieldid="' . esc_attr( $this->id ) . '" ' . $data_form_id . ' data-inputtype="' . esc_attr( $this->item[ 'input_type' ] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item[ 'settings_html' ] . '</div>'; |
|
| 195 | 195 | |
| 196 | 196 | return $output; |
| 197 | 197 | } |
@@ -58,16 +58,16 @@ |
||
| 58 | 58 | if ( $view->joins ) { |
| 59 | 59 | $form_ids = array(); |
| 60 | 60 | foreach ( $view->joins as $join ) { |
| 61 | - $form_ids[] = $join->join->ID; |
|
| 62 | - $form_ids[] = $join->join_on->ID; |
|
| 61 | + $form_ids[ ] = $join->join->ID; |
|
| 62 | + $form_ids[ ] = $join->join_on->ID; |
|
| 63 | 63 | } |
| 64 | 64 | foreach ( $entry->entries as $e ) { |
| 65 | - if ( ! in_array( $e['form_id'], $form_ids ) ) { |
|
| 65 | + if ( ! in_array( $e[ 'form_id' ], $form_ids ) ) { |
|
| 66 | 66 | gravityview()->log->error( 'The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', array( 'entry_id' => $e->ID, 'view_id' => $view->ID ) ); |
| 67 | 67 | return null; |
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | - } else if ( $view->form && $view->form->ID != $entry['form_id'] ) { |
|
| 70 | + } else if ( $view->form && $view->form->ID != $entry[ 'form_id' ] ) { |
|
| 71 | 71 | gravityview()->log->error( 'The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', array( 'entry_id' => $entry->ID, 'view_id' => $view->ID ) ); |
| 72 | 72 | return null; |
| 73 | 73 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | if ( ! $entry instanceof Entry ) { |
| 45 | 45 | continue; |
| 46 | 46 | } |
| 47 | - $_entry->entries[ $entry['form_id'] ] = &$entry; |
|
| 47 | + $_entry->entries[ $entry[ 'form_id' ] ] = &$entry; |
|
| 48 | 48 | } |
| 49 | 49 | return $_entry; |
| 50 | 50 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | foreach ( $this->entries as $entry ) { |
| 67 | 67 | $entry = $entry->as_entry(); |
| 68 | - $_entry['_multi'][ $entry['form_id'] ] = $entry; |
|
| 68 | + $_entry[ '_multi' ][ $entry[ 'form_id' ] ] = $entry; |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | public function get_permalink( \GV\View $view = null, \GV\Request $request = null, $track_directory = true ) { |
| 88 | 88 | $slugs = array(); |
| 89 | 89 | add_filter( 'gravityview/entry/slug', $callback = function( $slug ) use ( &$slugs ) { |
| 90 | - $slugs[] = $slug; |
|
| 90 | + $slugs[ ] = $slug; |
|
| 91 | 91 | return implode( ',', $slugs ); |
| 92 | 92 | }, 10, 1 ); |
| 93 | 93 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | public function __destruct() { |
| 95 | - remove_filter( $this->filter_prefix . '_get_template_part', $this->_add_id_specific_templates_callback );; |
|
| 95 | + remove_filter( $this->filter_prefix . '_get_template_part', $this->_add_id_specific_templates_callback ); ; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -175,55 +175,55 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | if ( $is_view && $post ) { |
| 177 | 177 | if ( $field_type ) { |
| 178 | - $specifics []= sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $field_type, $slug_name ); |
|
| 179 | - $inputType && $specifics []= sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $inputType, $slug_name ); |
|
| 180 | - $specifics []= sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $field_type ); |
|
| 181 | - $inputType && $specifics []= sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $inputType ); |
|
| 182 | - $specifics []= sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $field_type, $slug_name ); |
|
| 183 | - $inputType && $specifics []= sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $inputType, $slug_name ); |
|
| 184 | - $specifics []= sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $field_type ); |
|
| 185 | - $inputType && $specifics []= sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $inputType ); |
|
| 178 | + $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $field_type, $slug_name ); |
|
| 179 | + $inputType && $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $inputType, $slug_name ); |
|
| 180 | + $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $field_type ); |
|
| 181 | + $inputType && $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $inputType ); |
|
| 182 | + $specifics [ ] = sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $field_type, $slug_name ); |
|
| 183 | + $inputType && $specifics [ ] = sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $inputType, $slug_name ); |
|
| 184 | + $specifics [ ] = sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $field_type ); |
|
| 185 | + $inputType && $specifics [ ] = sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $inputType ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - $specifics []= sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $slug_name ); |
|
| 189 | - $specifics []= sprintf( '%spost-%d-view-%d-field.php', $slug_dir, $post->ID, $view_id ); |
|
| 190 | - $specifics []= sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $slug_name ); |
|
| 191 | - $specifics []= sprintf( '%spost-%d-field.php', $slug_dir, $post->ID ); |
|
| 188 | + $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $slug_name ); |
|
| 189 | + $specifics [ ] = sprintf( '%spost-%d-view-%d-field.php', $slug_dir, $post->ID, $view_id ); |
|
| 190 | + $specifics [ ] = sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $slug_name ); |
|
| 191 | + $specifics [ ] = sprintf( '%spost-%d-field.php', $slug_dir, $post->ID ); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** Field-specific */ |
| 195 | 195 | if ( $field_id && $form_id ) { |
| 196 | 196 | |
| 197 | 197 | if ( $field_id ) { |
| 198 | - $specifics []= sprintf( '%sform-%d-field-%d-%s.php', $slug_dir, $form_id, $field_id, $slug_name ); |
|
| 199 | - $specifics []= sprintf( '%sform-%d-field-%d.php', $slug_dir, $form_id, $field_id ); |
|
| 198 | + $specifics [ ] = sprintf( '%sform-%d-field-%d-%s.php', $slug_dir, $form_id, $field_id, $slug_name ); |
|
| 199 | + $specifics [ ] = sprintf( '%sform-%d-field-%d.php', $slug_dir, $form_id, $field_id ); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | if ( $field_type ) { |
| 203 | - $specifics []= sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $field_type, $slug_name ); |
|
| 204 | - $inputType && $specifics []= sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $inputType, $slug_name ); |
|
| 205 | - $specifics []= sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $field_type ); |
|
| 206 | - $inputType && $specifics []= sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $inputType ); |
|
| 207 | - |
|
| 208 | - $specifics []= sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $field_type, $slug_name ); |
|
| 209 | - $inputType && $specifics []= sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $inputType, $slug_name ); |
|
| 210 | - $specifics []= sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $field_type ); |
|
| 211 | - $inputType && $specifics []= sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $inputType ); |
|
| 212 | - |
|
| 213 | - $specifics []= sprintf( '%sfield-%s-%s.php', $slug_dir, $field_type, $slug_name ); |
|
| 214 | - $inputType && $specifics []= sprintf( '%sfield-%s-%s.php', $slug_dir, $inputType, $slug_name ); |
|
| 215 | - $specifics []= sprintf( '%sfield-%s.php', $slug_dir, $field_type ); |
|
| 216 | - $inputType && $specifics []= sprintf( '%sfield-%s.php', $slug_dir, $inputType ); |
|
| 203 | + $specifics [ ] = sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $field_type, $slug_name ); |
|
| 204 | + $inputType && $specifics [ ] = sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $inputType, $slug_name ); |
|
| 205 | + $specifics [ ] = sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $field_type ); |
|
| 206 | + $inputType && $specifics [ ] = sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $inputType ); |
|
| 207 | + |
|
| 208 | + $specifics [ ] = sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $field_type, $slug_name ); |
|
| 209 | + $inputType && $specifics [ ] = sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $inputType, $slug_name ); |
|
| 210 | + $specifics [ ] = sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $field_type ); |
|
| 211 | + $inputType && $specifics [ ] = sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $inputType ); |
|
| 212 | + |
|
| 213 | + $specifics [ ] = sprintf( '%sfield-%s-%s.php', $slug_dir, $field_type, $slug_name ); |
|
| 214 | + $inputType && $specifics [ ] = sprintf( '%sfield-%s-%s.php', $slug_dir, $inputType, $slug_name ); |
|
| 215 | + $specifics [ ] = sprintf( '%sfield-%s.php', $slug_dir, $field_type ); |
|
| 216 | + $inputType && $specifics [ ] = sprintf( '%sfield-%s.php', $slug_dir, $inputType ); |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | if ( $form_id ) { |
| 221 | 221 | /** Generic field templates */ |
| 222 | - $specifics []= sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $slug_name ); |
|
| 223 | - $specifics []= sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $slug_name ); |
|
| 222 | + $specifics [ ] = sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $slug_name ); |
|
| 223 | + $specifics [ ] = sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $slug_name ); |
|
| 224 | 224 | |
| 225 | - $specifics []= sprintf( '%sview-%d-field.php', $slug_dir, $view_id ); |
|
| 226 | - $specifics []= sprintf( '%sform-%d-field.php', $slug_dir, $form_id ); |
|
| 225 | + $specifics [ ] = sprintf( '%sview-%d-field.php', $slug_dir, $view_id ); |
|
| 226 | + $specifics [ ] = sprintf( '%sform-%d-field.php', $slug_dir, $form_id ); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -231,12 +231,12 @@ discard block |
||
| 231 | 231 | * Ignore some types that conflict. |
| 232 | 232 | */ |
| 233 | 233 | if ( ! in_array( $field_type, array( 'notes' ) ) ) { |
| 234 | - $specifics []= sprintf( '%s.php', $field_type ); |
|
| 235 | - $specifics []= sprintf( 'fields/%s.php', $field_type ); |
|
| 234 | + $specifics [ ] = sprintf( '%s.php', $field_type ); |
|
| 235 | + $specifics [ ] = sprintf( 'fields/%s.php', $field_type ); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - $specifics []= sprintf( '%sfield-%s.php', $slug_dir, $slug_name ); |
|
| 239 | - $specifics []= sprintf( '%sfield.php', $slug_dir ); |
|
| 238 | + $specifics [ ] = sprintf( '%sfield-%s.php', $slug_dir, $slug_name ); |
|
| 239 | + $specifics [ ] = sprintf( '%sfield.php', $slug_dir ); |
|
| 240 | 240 | |
| 241 | 241 | return array_merge( $specifics, $templates ); |
| 242 | 242 | }; |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | /** Prevent any PHP warnings that may be generated. */ |
| 268 | 268 | ob_start(); |
| 269 | 269 | |
| 270 | - $display_value = \GFCommon::get_lead_field_display( $this->field->field, $value, $entry['currency'], false, 'html' ); |
|
| 270 | + $display_value = \GFCommon::get_lead_field_display( $this->field->field, $value, $entry[ 'currency' ], false, 'html' ); |
|
| 271 | 271 | |
| 272 | 272 | if ( $errors = ob_get_clean() ) { |
| 273 | 273 | gravityview()->log->error( 'Errors when calling GFCommon::get_lead_field_display()', array( 'data' => $errors ) ); |
@@ -24,6 +24,6 @@ |
||
| 24 | 24 | $plugin_theme_hooks_files = glob( $include_path . 'class-gravityview-{plugin,theme}-hooks-*.php', $glob_flags ); |
| 25 | 25 | |
| 26 | 26 | // Load all plugin and theme files automatically |
| 27 | -foreach ( (array) $plugin_theme_hooks_files as $gv_hooks_filename ) { |
|
| 27 | +foreach ( (array)$plugin_theme_hooks_files as $gv_hooks_filename ) { |
|
| 28 | 28 | include $gv_hooks_filename; |
| 29 | 29 | } |
| 30 | 30 | \ No newline at end of file |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | $form = false; |
| 127 | 127 | |
| 128 | - if( $entry ) { |
|
| 129 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
| 128 | + if ( $entry ) { |
|
| 129 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | return $form; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - return (bool) $has_transaction_data; |
|
| 205 | + return (bool)$has_transaction_data; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
| 242 | 242 | |
| 243 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
| 243 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
| 244 | 244 | |
| 245 | 245 | return $result; |
| 246 | 246 | } |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
| 259 | 259 | */ |
| 260 | - public static function get_forms( $active = true, $trash = false ) { |
|
| 260 | + public static function get_forms( $active = true, $trash = false ) { |
|
| 261 | 261 | $forms = array(); |
| 262 | 262 | if ( class_exists( 'GFAPI' ) ) { |
| 263 | - if( 'any' === $active ) { |
|
| 263 | + if ( 'any' === $active ) { |
|
| 264 | 264 | $active_forms = GFAPI::get_forms( true, $trash ); |
| 265 | 265 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
| 266 | 266 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | $has_post_fields = false; |
| 292 | 292 | |
| 293 | 293 | if ( $form ) { |
| 294 | - foreach ( $form['fields'] as $field ) { |
|
| 295 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
| 296 | - $fields["{$field['id']}"] = array( |
|
| 294 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 295 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
| 296 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
| 297 | 297 | 'label' => \GV\Utils::get( $field, 'label' ), |
| 298 | 298 | 'parent' => null, |
| 299 | 299 | 'type' => \GV\Utils::get( $field, 'type' ), |
@@ -302,10 +302,10 @@ discard block |
||
| 302 | 302 | ); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
| 306 | - foreach ( $field['inputs'] as $input ) { |
|
| 305 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
| 306 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
| 307 | 307 | |
| 308 | - if( ! empty( $input['isHidden'] ) ) { |
|
| 308 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
| 309 | 309 | continue; |
| 310 | 310 | } |
| 311 | 311 | |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | * @hack |
| 314 | 314 | * In case of email/email confirmation, the input for email has the same id as the parent field |
| 315 | 315 | */ |
| 316 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
| 316 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
| 317 | 317 | continue; |
| 318 | 318 | } |
| 319 | - $fields["{$input['id']}"] = array( |
|
| 319 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
| 320 | 320 | 'label' => \GV\Utils::get( $input, 'label' ), |
| 321 | 321 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
| 322 | 322 | 'parent' => $field, |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | |
| 331 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 331 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
| 332 | 332 | $has_product_fields = true; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @since 1.7 |
| 343 | 343 | */ |
| 344 | 344 | if ( $has_post_fields ) { |
| 345 | - $fields['post_id'] = array( |
|
| 345 | + $fields[ 'post_id' ] = array( |
|
| 346 | 346 | 'label' => __( 'Post ID', 'gravityview' ), |
| 347 | 347 | 'type' => 'post_id', |
| 348 | 348 | ); |
@@ -355,11 +355,11 @@ discard block |
||
| 355 | 355 | foreach ( $payment_fields as $payment_field ) { |
| 356 | 356 | |
| 357 | 357 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
| 358 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 358 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 359 | 359 | continue; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $fields["{$payment_field->name}"] = array( |
|
| 362 | + $fields[ "{$payment_field->name}" ] = array( |
|
| 363 | 363 | 'label' => $payment_field->label, |
| 364 | 364 | 'desc' => $payment_field->description, |
| 365 | 365 | 'type' => $payment_field->name, |
@@ -391,9 +391,9 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | $fields = array(); |
| 393 | 393 | |
| 394 | - foreach ( $extra_fields as $key => $field ){ |
|
| 395 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
| 396 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
| 394 | + foreach ( $extra_fields as $key => $field ) { |
|
| 395 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
| 396 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | |
@@ -433,33 +433,33 @@ discard block |
||
| 433 | 433 | 'search_criteria' => null, |
| 434 | 434 | 'sorting' => null, |
| 435 | 435 | 'paging' => null, |
| 436 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
| 436 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
| 437 | 437 | 'context_view_id' => null, |
| 438 | 438 | ); |
| 439 | 439 | |
| 440 | 440 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
| 441 | 441 | |
| 442 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
| 443 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
| 442 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 443 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
| 444 | 444 | |
| 445 | 445 | if ( ! is_array( $filter ) ) { |
| 446 | 446 | continue; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | // By default, we want searches to be wildcard for each field. |
| 450 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 450 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
| 451 | 451 | |
| 452 | 452 | /** |
| 453 | 453 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
| 454 | 454 | * @param string $operator Existing search operator |
| 455 | 455 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 456 | 456 | */ |
| 457 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
| 457 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | // don't send just the [mode] without any field filter. |
| 461 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
| 462 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
| 461 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 462 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | } |
@@ -470,33 +470,33 @@ discard block |
||
| 470 | 470 | * Prepare date formats to be in Gravity Forms DB format; |
| 471 | 471 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
| 472 | 472 | */ |
| 473 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
| 473 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
| 474 | 474 | |
| 475 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
| 475 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
| 476 | 476 | |
| 477 | 477 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
| 478 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
| 478 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 479 | 479 | |
| 480 | 480 | if ( $date ) { |
| 481 | 481 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
| 482 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 482 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 483 | 483 | } else { |
| 484 | - gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria['search_criteria'][ $key ] ) ); |
|
| 484 | + gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria[ 'search_criteria' ][ $key ] ) ); |
|
| 485 | 485 | |
| 486 | 486 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
| 487 | - unset( $criteria['search_criteria'][ $key ] ); |
|
| 487 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - if ( empty( $criteria['context_view_id'] ) ) { |
|
| 492 | + if ( empty( $criteria[ 'context_view_id' ] ) ) { |
|
| 493 | 493 | // Calculate the context view id and send it to the advanced filter |
| 494 | 494 | if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
| 495 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 495 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 496 | 496 | } else if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
| 497 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 497 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 498 | 498 | } else if ( 'delete' === GFForms::get( 'action' ) ) { |
| 499 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
| 499 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * @param array $form_ids Forms to search |
| 507 | 507 | * @param int $view_id ID of the view being used to search |
| 508 | 508 | */ |
| 509 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
| 509 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
| 510 | 510 | |
| 511 | 511 | return (array)$criteria; |
| 512 | 512 | } |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | /** Reduce # of database calls */ |
| 542 | 542 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
| 543 | 543 | |
| 544 | - if ( ! empty( $criteria['cache'] ) ) { |
|
| 544 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
| 545 | 545 | |
| 546 | 546 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
| 547 | 547 | |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | |
| 550 | 550 | // Still update the total count when using cached results |
| 551 | 551 | if ( ! is_null( $total ) ) { |
| 552 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
| 552 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | $return = $entries; |
@@ -571,9 +571,9 @@ discard block |
||
| 571 | 571 | $entries = apply_filters_ref_array( 'gravityview_before_get_entries', array( null, $criteria, $passed_criteria, &$total ) ); |
| 572 | 572 | |
| 573 | 573 | // No entries returned from gravityview_before_get_entries |
| 574 | - if( is_null( $entries ) ) { |
|
| 574 | + if ( is_null( $entries ) ) { |
|
| 575 | 575 | |
| 576 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
| 576 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
| 577 | 577 | |
| 578 | 578 | if ( is_wp_error( $entries ) ) { |
| 579 | 579 | gravityview()->log->error( '{error}', array( 'error' => $entries->get_error_message(), 'data' => $entries ) ); |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
| 587 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
| 588 | 588 | |
| 589 | 589 | // Cache results |
| 590 | 590 | $Cache->set( $entries, 'entries' ); |
@@ -693,12 +693,12 @@ discard block |
||
| 693 | 693 | */ |
| 694 | 694 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
| 695 | 695 | |
| 696 | - if( $check_entry_display ) { |
|
| 696 | + if ( $check_entry_display ) { |
|
| 697 | 697 | // Is the entry allowed |
| 698 | 698 | $entry = self::check_entry_display( $entry ); |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - if( is_wp_error( $entry ) ) { |
|
| 701 | + if ( is_wp_error( $entry ) ) { |
|
| 702 | 702 | gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) ); |
| 703 | 703 | return false; |
| 704 | 704 | } |
@@ -732,12 +732,12 @@ discard block |
||
| 732 | 732 | |
| 733 | 733 | $value = false; |
| 734 | 734 | |
| 735 | - if( 'context' === $val1 ) { |
|
| 735 | + if ( 'context' === $val1 ) { |
|
| 736 | 736 | |
| 737 | 737 | $matching_contexts = array( $val2 ); |
| 738 | 738 | |
| 739 | 739 | // We allow for non-standard contexts. |
| 740 | - switch( $val2 ) { |
|
| 740 | + switch ( $val2 ) { |
|
| 741 | 741 | // Check for either single or edit |
| 742 | 742 | case 'singular': |
| 743 | 743 | $matching_contexts = array( 'single', 'edit' ); |
@@ -780,18 +780,18 @@ discard block |
||
| 780 | 780 | $json_val_1 = json_decode( $val1, true ); |
| 781 | 781 | $json_val_2 = json_decode( $val2, true ); |
| 782 | 782 | |
| 783 | - if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
| 783 | + if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
| 784 | 784 | |
| 785 | 785 | $json_in = false; |
| 786 | - $json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 ); |
|
| 787 | - $json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 ); |
|
| 786 | + $json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 ); |
|
| 787 | + $json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 ); |
|
| 788 | 788 | |
| 789 | 789 | // For JSON, we want to compare as "in" or "not in" rather than "contains" |
| 790 | 790 | foreach ( $json_val_1 as $item_1 ) { |
| 791 | 791 | foreach ( $json_val_2 as $item_2 ) { |
| 792 | 792 | $json_in = self::matches_operation( $item_1, $item_2, 'is' ); |
| 793 | 793 | |
| 794 | - if( $json_in ) { |
|
| 794 | + if ( $json_in ) { |
|
| 795 | 795 | break 2; |
| 796 | 796 | } |
| 797 | 797 | } |
@@ -843,10 +843,10 @@ discard block |
||
| 843 | 843 | public static function check_entry_display( $entry, $view = null ) { |
| 844 | 844 | |
| 845 | 845 | if ( ! $entry || is_wp_error( $entry ) ) { |
| 846 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
| 846 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - if ( empty( $entry['form_id'] ) ) { |
|
| 849 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
| 850 | 850 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
| 851 | 851 | } |
| 852 | 852 | |
@@ -856,13 +856,13 @@ discard block |
||
| 856 | 856 | * Check whether the entry is in the entries subset by running a modified query. |
| 857 | 857 | */ |
| 858 | 858 | add_action( 'gravityview/view/query', $entry_subset_callback = function( &$query, $view, $request ) use ( $entry ) { |
| 859 | - $_tmp_query = new \GF_Query( $view->form->ID, array( |
|
| 859 | + $_tmp_query = new \GF_Query( $view->form->ID, array( |
|
| 860 | 860 | 'field_filters' => array( |
| 861 | 861 | 'mode' => 'all', |
| 862 | 862 | array( |
| 863 | 863 | 'key' => 'id', |
| 864 | 864 | 'operation' => 'is', |
| 865 | - 'value' => $entry['id'] |
|
| 865 | + 'value' => $entry[ 'id' ] |
|
| 866 | 866 | ) |
| 867 | 867 | ) |
| 868 | 868 | ) ); |
@@ -872,14 +872,14 @@ discard block |
||
| 872 | 872 | /** @var \GF_Query $query */ |
| 873 | 873 | $query_parts = $query->_introspect(); |
| 874 | 874 | |
| 875 | - $query->where( \GF_Query_Condition::_and( $_tmp_query_parts['where'], $query_parts['where'] ) ); |
|
| 875 | + $query->where( \GF_Query_Condition::_and( $_tmp_query_parts[ 'where' ], $query_parts[ 'where' ] ) ); |
|
| 876 | 876 | |
| 877 | 877 | }, 10, 3 ); |
| 878 | 878 | |
| 879 | 879 | // Prevent page offset from being applied to the single entry query; it's used to return to the referring page number |
| 880 | 880 | add_filter( 'gravityview_search_criteria', $remove_pagenum = function( $criteria ) { |
| 881 | 881 | |
| 882 | - $criteria['paging'] = array( |
|
| 882 | + $criteria[ 'paging' ] = array( |
|
| 883 | 883 | 'offset' => 0, |
| 884 | 884 | 'page_size' => 25 |
| 885 | 885 | ); |
@@ -898,20 +898,20 @@ discard block |
||
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | // This entry is on a View with joins |
| 901 | - if( $entries[0]->is_multi() ) { |
|
| 901 | + if ( $entries[ 0 ]->is_multi() ) { |
|
| 902 | 902 | |
| 903 | 903 | $multi_entry_ids = array(); |
| 904 | 904 | |
| 905 | - foreach ( $entries[0]->entries as $multi_entry ) { |
|
| 906 | - $multi_entry_ids[] = (int) $multi_entry->ID; |
|
| 905 | + foreach ( $entries[ 0 ]->entries as $multi_entry ) { |
|
| 906 | + $multi_entry_ids[ ] = (int)$multi_entry->ID; |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | - if( ! in_array( (int) $entry['id'], $multi_entry_ids, true ) ) { |
|
| 909 | + if ( ! in_array( (int)$entry[ 'id' ], $multi_entry_ids, true ) ) { |
|
| 910 | 910 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
| 911 | 911 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | - } elseif ( (int) $entries[0]->ID !== (int) $entry['id'] ) { |
|
| 914 | + } elseif ( (int)$entries[ 0 ]->ID !== (int)$entry[ 'id' ] ) { |
|
| 915 | 915 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
| 916 | 916 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
| 917 | 917 | } |
@@ -924,59 +924,59 @@ discard block |
||
| 924 | 924 | 'context_view_id' => $view ? $view->ID : null, |
| 925 | 925 | ) ); |
| 926 | 926 | |
| 927 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
| 927 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
| 928 | 928 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No search criteria found:', array( 'data' => $criteria ) ); |
| 929 | 929 | return $entry; |
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | // Make sure the current View is connected to the same form as the Entry |
| 933 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
| 934 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
| 933 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
| 934 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
| 935 | 935 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
| 936 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
| 937 | - return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
| 936 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
| 937 | + return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
| 938 | 938 | } |
| 939 | 939 | } |
| 940 | 940 | |
| 941 | - $search_criteria = $criteria['search_criteria']; |
|
| 941 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
| 942 | 942 | |
| 943 | 943 | // check entry status |
| 944 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
| 945 | - return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
| 944 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
| 945 | + return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | // check entry date |
| 949 | 949 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
| 950 | 950 | |
| 951 | 951 | // field_filters |
| 952 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
| 952 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
| 953 | 953 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No field filters criteria found:', array( 'data' => $search_criteria ) ); |
| 954 | 954 | return $entry; |
| 955 | 955 | } |
| 956 | 956 | |
| 957 | - $filters = $search_criteria['field_filters']; |
|
| 957 | + $filters = $search_criteria[ 'field_filters' ]; |
|
| 958 | 958 | |
| 959 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
| 959 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
| 960 | 960 | |
| 961 | - $mode = $mode ? : 'all'; // If mode is an empty string, assume it's 'all' |
|
| 961 | + $mode = $mode ?: 'all'; // If mode is an empty string, assume it's 'all' |
|
| 962 | 962 | |
| 963 | 963 | // Prevent the mode from being processed below |
| 964 | - unset( $filters['mode'] ); |
|
| 964 | + unset( $filters[ 'mode' ] ); |
|
| 965 | 965 | |
| 966 | - $form = self::get_form( $entry['form_id'] ); |
|
| 966 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
| 967 | 967 | |
| 968 | 968 | foreach ( $filters as $filter ) { |
| 969 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
| 969 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
| 970 | 970 | |
| 971 | - if ( ! isset( $filter['key'] ) ) { |
|
| 971 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
| 972 | 972 | gravityview()->log->debug( '[apply_filters_to_entry] Filter key not set, any field mode', array( 'filter' => $filter ) ); |
| 973 | 973 | /** |
| 974 | 974 | * This is a cross-field search. Let's start digging'. |
| 975 | 975 | */ |
| 976 | 976 | foreach ( \GV\Utils::get( $form, 'fields', array() ) as $field ) { |
| 977 | 977 | $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
| 978 | - if ( $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ) ) { |
|
| 979 | - if ( 'any' === $mode) { |
|
| 978 | + if ( $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ) ) { |
|
| 979 | + if ( 'any' === $mode ) { |
|
| 980 | 980 | return $entry; // All good here |
| 981 | 981 | } // mode === 'all' |
| 982 | 982 | continue 2; // Next filter |
@@ -985,13 +985,13 @@ discard block |
||
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | if ( 'all' === $mode ) { |
| 988 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a subcriterium for any field in ALL mode', $filter ); |
|
| 988 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a subcriterium for any field in ALL mode', $filter ); |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | continue; |
| 992 | 992 | } |
| 993 | 993 | |
| 994 | - $k = $filter['key']; |
|
| 994 | + $k = $filter[ 'key' ]; |
|
| 995 | 995 | |
| 996 | 996 | $field = self::get_field( $form, $k ); |
| 997 | 997 | |
@@ -999,12 +999,12 @@ discard block |
||
| 999 | 999 | $field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null; |
| 1000 | 1000 | $field = $k; |
| 1001 | 1001 | } else { |
| 1002 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 1002 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 1003 | 1003 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
| 1004 | 1004 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? \GV\Utils::get( $field_value, $k ) : $field_value; |
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | - $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
| 1007 | + $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
| 1008 | 1008 | |
| 1009 | 1009 | // Any match is all we need to know |
| 1010 | 1010 | if ( $is_value_match && 'any' === $mode ) { |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | |
| 1014 | 1014 | // Any failed match is a total fail |
| 1015 | 1015 | if ( ! $is_value_match && 'all' === $mode ) { |
| 1016 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
| 1016 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
| 1017 | 1017 | } |
| 1018 | 1018 | } |
| 1019 | 1019 | |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved: all conditions were met' ); |
| 1024 | 1024 | return $entry; |
| 1025 | 1025 | } else { |
| 1026 | - return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 1026 | + return new WP_Error( 'failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | 1029 | } |
@@ -1064,18 +1064,18 @@ discard block |
||
| 1064 | 1064 | * Gravity Forms code to adjust date to locally-configured Time Zone |
| 1065 | 1065 | * @see GFCommon::format_date() for original code |
| 1066 | 1066 | */ |
| 1067 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 1067 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 1068 | 1068 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
| 1069 | 1069 | |
| 1070 | - $format = \GV\Utils::get( $atts, 'format' ); |
|
| 1071 | - $is_human = ! empty( $atts['human'] ); |
|
| 1072 | - $is_diff = ! empty( $atts['diff'] ); |
|
| 1073 | - $is_raw = ! empty( $atts['raw'] ); |
|
| 1074 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
| 1075 | - $include_time = ! empty( $atts['time'] ); |
|
| 1070 | + $format = \GV\Utils::get( $atts, 'format' ); |
|
| 1071 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
| 1072 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
| 1073 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
| 1074 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
| 1075 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
| 1076 | 1076 | |
| 1077 | 1077 | // If we're using time diff, we want to have a different default format |
| 1078 | - if( empty( $format ) ) { |
|
| 1078 | + if ( empty( $format ) ) { |
|
| 1079 | 1079 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
| 1080 | 1080 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
| 1081 | 1081 | } |
@@ -1083,7 +1083,7 @@ discard block |
||
| 1083 | 1083 | // If raw was specified, don't modify the stored value |
| 1084 | 1084 | if ( $is_raw ) { |
| 1085 | 1085 | $formatted_date = $date_string; |
| 1086 | - } elseif( $is_timestamp ) { |
|
| 1086 | + } elseif ( $is_timestamp ) { |
|
| 1087 | 1087 | $formatted_date = $date_local_timestamp; |
| 1088 | 1088 | } elseif ( $is_diff ) { |
| 1089 | 1089 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | |
| 1118 | 1118 | $label = \GV\Utils::get( $field, 'label' ); |
| 1119 | 1119 | |
| 1120 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 1120 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 1121 | 1121 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
| 1122 | 1122 | } |
| 1123 | 1123 | |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | $form = GFAPI::get_form( $form ); |
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 1148 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
| 1149 | 1149 | return GFFormsModel::get_field( $form, $field_id ); |
| 1150 | 1150 | } else { |
| 1151 | 1151 | return null; |
@@ -1192,19 +1192,19 @@ discard block |
||
| 1192 | 1192 | $shortcodes = array(); |
| 1193 | 1193 | |
| 1194 | 1194 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 1195 | - if ( empty( $matches ) ){ |
|
| 1195 | + if ( empty( $matches ) ) { |
|
| 1196 | 1196 | return false; |
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | foreach ( $matches as $shortcode ) { |
| 1200 | - if ( $tag === $shortcode[2] ) { |
|
| 1200 | + if ( $tag === $shortcode[ 2 ] ) { |
|
| 1201 | 1201 | |
| 1202 | 1202 | // Changed this to $shortcode instead of true so we get the parsed atts. |
| 1203 | - $shortcodes[] = $shortcode; |
|
| 1203 | + $shortcodes[ ] = $shortcode; |
|
| 1204 | 1204 | |
| 1205 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
| 1206 | - foreach( $results as $result ) { |
|
| 1207 | - $shortcodes[] = $result; |
|
| 1205 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
| 1206 | + foreach ( $results as $result ) { |
|
| 1207 | + $shortcodes[ ] = $result; |
|
| 1208 | 1208 | } |
| 1209 | 1209 | } |
| 1210 | 1210 | } |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | 'post_type' => 'gravityview', |
| 1237 | 1237 | 'posts_per_page' => 100, |
| 1238 | 1238 | 'meta_key' => '_gravityview_form_id', |
| 1239 | - 'meta_value' => (int) $form_id, |
|
| 1239 | + 'meta_value' => (int)$form_id, |
|
| 1240 | 1240 | ); |
| 1241 | 1241 | $args = wp_parse_args( $args, $defaults ); |
| 1242 | 1242 | $views = get_posts( $args ); |
@@ -1248,21 +1248,21 @@ discard block |
||
| 1248 | 1248 | |
| 1249 | 1249 | $data = unserialize( $view->meta_value ); |
| 1250 | 1250 | |
| 1251 | - if( ! $data || ! is_array( $data ) ) { |
|
| 1251 | + if ( ! $data || ! is_array( $data ) ) { |
|
| 1252 | 1252 | continue; |
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | foreach ( $data as $datum ) { |
| 1256 | - if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) { |
|
| 1257 | - $joined_forms[] = $view->post_id; |
|
| 1256 | + if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) { |
|
| 1257 | + $joined_forms[ ] = $view->post_id; |
|
| 1258 | 1258 | } |
| 1259 | 1259 | } |
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | if ( $joined_forms ) { |
| 1263 | - $joined_args = array( |
|
| 1263 | + $joined_args = array( |
|
| 1264 | 1264 | 'post_type' => 'gravityview', |
| 1265 | - 'posts_per_page' => $args['posts_per_page'], |
|
| 1265 | + 'posts_per_page' => $args[ 'posts_per_page' ], |
|
| 1266 | 1266 | 'post__in' => $joined_forms, |
| 1267 | 1267 | ); |
| 1268 | 1268 | $views = array_merge( $views, get_posts( $joined_args ) ); |
@@ -1418,7 +1418,7 @@ discard block |
||
| 1418 | 1418 | |
| 1419 | 1419 | $directory_widgets = wp_parse_args( $view_widgets, $defaults ); |
| 1420 | 1420 | |
| 1421 | - if( $json_decode ) { |
|
| 1421 | + if ( $json_decode ) { |
|
| 1422 | 1422 | $directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' ); |
| 1423 | 1423 | } |
| 1424 | 1424 | |
@@ -1434,7 +1434,7 @@ discard block |
||
| 1434 | 1434 | * @return string html |
| 1435 | 1435 | */ |
| 1436 | 1436 | public static function get_sortable_fields( $formid, $current = '' ) { |
| 1437 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
| 1437 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
| 1438 | 1438 | |
| 1439 | 1439 | if ( empty( $formid ) ) { |
| 1440 | 1440 | return $output; |
@@ -1447,11 +1447,11 @@ discard block |
||
| 1447 | 1447 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
| 1448 | 1448 | |
| 1449 | 1449 | foreach ( $fields as $id => $field ) { |
| 1450 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1450 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1451 | 1451 | continue; |
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
| 1454 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
| 1455 | 1455 | } |
| 1456 | 1456 | } |
| 1457 | 1457 | |
@@ -1486,9 +1486,9 @@ discard block |
||
| 1486 | 1486 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1487 | 1487 | |
| 1488 | 1488 | // TODO: Convert to using array_filter |
| 1489 | - foreach( $fields as $id => $field ) { |
|
| 1489 | + foreach ( $fields as $id => $field ) { |
|
| 1490 | 1490 | |
| 1491 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1491 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1492 | 1492 | unset( $fields[ $id ] ); |
| 1493 | 1493 | } |
| 1494 | 1494 | } |
@@ -1529,14 +1529,14 @@ discard block |
||
| 1529 | 1529 | * @param int|array $field field key or field array |
| 1530 | 1530 | * @return boolean |
| 1531 | 1531 | */ |
| 1532 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1532 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1533 | 1533 | |
| 1534 | 1534 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
| 1535 | 1535 | $form = self::get_form( $form ); |
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | 1538 | // If entry meta, it's a string. Otherwise, numeric |
| 1539 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1539 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1540 | 1540 | $type = $field; |
| 1541 | 1541 | } else { |
| 1542 | 1542 | $type = self::get_field_type( $form, $field ); |
@@ -1550,9 +1550,9 @@ discard block |
||
| 1550 | 1550 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
| 1551 | 1551 | |
| 1552 | 1552 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
| 1553 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1554 | - if( true === $gv_field->is_numeric ) { |
|
| 1555 | - $numeric_types[] = $gv_field->is_numeric; |
|
| 1553 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1554 | + if ( true === $gv_field->is_numeric ) { |
|
| 1555 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
| 1556 | 1556 | } |
| 1557 | 1557 | } |
| 1558 | 1558 | |
@@ -1702,18 +1702,18 @@ discard block |
||
| 1702 | 1702 | $final_atts = array_filter( $final_atts ); |
| 1703 | 1703 | |
| 1704 | 1704 | // If the href wasn't passed as an attribute, use the value passed to the function |
| 1705 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
| 1706 | - $final_atts['href'] = $href; |
|
| 1705 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
| 1706 | + $final_atts[ 'href' ] = $href; |
|
| 1707 | 1707 | } |
| 1708 | 1708 | |
| 1709 | - $final_atts['href'] = esc_url_raw( $href ); |
|
| 1709 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
| 1710 | 1710 | |
| 1711 | 1711 | /** |
| 1712 | 1712 | * Fix potential security issue with target=_blank |
| 1713 | 1713 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
| 1714 | 1714 | */ |
| 1715 | - if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
| 1716 | - $final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1715 | + if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
| 1716 | + $final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1717 | 1717 | } |
| 1718 | 1718 | |
| 1719 | 1719 | // Sort the attributes alphabetically, to help testing |
@@ -1725,7 +1725,7 @@ discard block |
||
| 1725 | 1725 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | - if( '' !== $output ) { |
|
| 1728 | + if ( '' !== $output ) { |
|
| 1729 | 1729 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
| 1730 | 1730 | } |
| 1731 | 1731 | |
@@ -1752,7 +1752,7 @@ discard block |
||
| 1752 | 1752 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
| 1753 | 1753 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
| 1754 | 1754 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
| 1755 | - $merged[] = $value; |
|
| 1755 | + $merged[ ] = $value; |
|
| 1756 | 1756 | } else { |
| 1757 | 1757 | $merged[ $key ] = $value; |
| 1758 | 1758 | } |
@@ -1785,7 +1785,7 @@ discard block |
||
| 1785 | 1785 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
| 1786 | 1786 | * @param array $settings Settings array, with `number` key defining the # of users to display |
| 1787 | 1787 | */ |
| 1788 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1788 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1789 | 1789 | |
| 1790 | 1790 | return get_users( $get_users_settings ); |
| 1791 | 1791 | } |
@@ -1805,11 +1805,11 @@ discard block |
||
| 1805 | 1805 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
| 1806 | 1806 | |
| 1807 | 1807 | // If $cap is defined, only show notice if user has capability |
| 1808 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1808 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1809 | 1809 | return ''; |
| 1810 | 1810 | } |
| 1811 | 1811 | |
| 1812 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1812 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
| 1813 | 1813 | } |
| 1814 | 1814 | |
| 1815 | 1815 | /** |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | function __construct() { |
| 23 | 23 | |
| 24 | 24 | $this->widget_id = 'poll'; |
| 25 | - $this->widget_description = __('Displays the results of Poll Fields that exist in the form.', 'gravityview' ); |
|
| 26 | - $this->widget_subtitle = sprintf( _x('Note: this will display poll results for %sall form entries%s, not only the entries displayed in the View.', 'The string placeholders are for emphasis HTML', 'gravityview' ), '<em>', '</em>' ); |
|
| 25 | + $this->widget_description = __( 'Displays the results of Poll Fields that exist in the form.', 'gravityview' ); |
|
| 26 | + $this->widget_subtitle = sprintf( _x( 'Note: this will display poll results for %sall form entries%s, not only the entries displayed in the View.', 'The string placeholders are for emphasis HTML', 'gravityview' ), '<em>', '</em>' ); |
|
| 27 | 27 | |
| 28 | 28 | $default_values = array( |
| 29 | 29 | 'header' => 1, |
@@ -32,27 +32,27 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $settings = array( |
| 34 | 34 | 'percentages' => array( |
| 35 | - 'label' => __('Display Percentages', 'gravityview'), |
|
| 35 | + 'label' => __( 'Display Percentages', 'gravityview' ), |
|
| 36 | 36 | 'type' => 'checkbox', |
| 37 | 37 | 'value' => true, |
| 38 | 38 | 'tooltip' => __( 'Display results percentages as part of results? Supported values are: true, false. Defaults to "true".', 'gravityview' ), |
| 39 | 39 | ), |
| 40 | 40 | 'counts' => array( |
| 41 | - 'label' => __('Display Counts', 'gravityview'), |
|
| 41 | + 'label' => __( 'Display Counts', 'gravityview' ), |
|
| 42 | 42 | 'type' => 'checkbox', |
| 43 | 43 | 'value' => true, |
| 44 | 44 | 'tooltip' => __( 'Display number of times each choice has been selected when displaying results? Supported values are: true, false. Defaults to "true".', 'gravityview' ), |
| 45 | 45 | ), |
| 46 | 46 | 'style' => array( |
| 47 | 47 | 'type' => 'select', |
| 48 | - 'label' => __('Style', 'gravityview'), |
|
| 48 | + 'label' => __( 'Style', 'gravityview' ), |
|
| 49 | 49 | 'tooltip' => __( 'The Polls Add-On currently supports 4 built in styles: red, green, orange, blue. Defaults to "green".', 'gravityview' ), |
| 50 | 50 | 'value' => 'green', |
| 51 | 51 | 'choices' => array( |
| 52 | - 'green' => __('Green', 'gravityview'), |
|
| 53 | - 'blue' => __('Blue', 'gravityview'), |
|
| 54 | - 'red' => __('Red', 'gravityview'), |
|
| 55 | - 'orange' => __('Orange', 'gravityview'), |
|
| 52 | + 'green' => __( 'Green', 'gravityview' ), |
|
| 53 | + 'blue' => __( 'Blue', 'gravityview' ), |
|
| 54 | + 'red' => __( 'Red', 'gravityview' ), |
|
| 55 | + 'orange' => __( 'Orange', 'gravityview' ), |
|
| 56 | 56 | ), |
| 57 | 57 | ), |
| 58 | 58 | ); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - parent::__construct( __( 'Poll Results', 'gravityview' ) , null, $default_values, $settings ); |
|
| 65 | + parent::__construct( __( 'Poll Results', 'gravityview' ), null, $default_values, $settings ); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $GFPolls = GFPolls::get_instance(); |
| 91 | 91 | |
| 92 | - wp_enqueue_script('gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array('jquery'), $GFPolls->_version); |
|
| 92 | + wp_enqueue_script( 'gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array( 'jquery' ), $GFPolls->_version ); |
|
| 93 | 93 | |
| 94 | 94 | $GFPolls->localize_scripts(); |
| 95 | 95 | |
| 96 | - wp_enqueue_style('gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version); |
|
| 96 | + wp_enqueue_style( 'gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function pre_render_frontend() { |
| 105 | 105 | |
| 106 | - if( ! class_exists('GFPolls') ) { |
|
| 106 | + if ( ! class_exists( 'GFPolls' ) ) { |
|
| 107 | 107 | |
| 108 | 108 | gravityview()->log->error( 'Poll Widget not displayed; the Poll Addon is not loaded' ); |
| 109 | 109 | |
@@ -112,10 +112,10 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | $view = gravityview()->views->get(); |
| 114 | 114 | |
| 115 | - $poll_fields = array( $view->form->form['id'] => GFCommon::get_fields_by_type( $view->form, array( 'poll' ) ) ); |
|
| 115 | + $poll_fields = array( $view->form->form[ 'id' ] => GFCommon::get_fields_by_type( $view->form, array( 'poll' ) ) ); |
|
| 116 | 116 | |
| 117 | 117 | foreach ( $view->joins as $join ) { |
| 118 | - $poll_fields[ $join->join_on->form['id'] ] = GFCommon::get_fields_by_type( $join->join_on->form, array( 'poll' ) ); |
|
| 118 | + $poll_fields[ $join->join_on->form[ 'id' ] ] = GFCommon::get_fields_by_type( $join->join_on->form, array( 'poll' ) ); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | $poll_fields = array_filter( $poll_fields ); |
@@ -167,12 +167,12 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | public function render_frontend( $widget_args, $content = '', $context = '' ) { |
| 169 | 169 | |
| 170 | - if( ! $this->pre_render_frontend() ) { |
|
| 170 | + if ( ! $this->pre_render_frontend() ) { |
|
| 171 | 171 | return; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // Make sure the class is loaded in DataTables |
| 175 | - if( !class_exists( 'GFFormDisplay' ) ) { |
|
| 175 | + if ( ! class_exists( 'GFFormDisplay' ) ) { |
|
| 176 | 176 | include_once( GFCommon::get_base_path() . '/form_display.php' ); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -180,14 +180,14 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $settings = $this->get_frontend_settings( $widget_args ); |
| 182 | 182 | |
| 183 | - $percentages = empty( $settings['percentages'] ) ? 'false' : 'true'; |
|
| 183 | + $percentages = empty( $settings[ 'percentages' ] ) ? 'false' : 'true'; |
|
| 184 | 184 | |
| 185 | - $counts = empty( $settings['counts'] ) ? 'false' : 'true'; |
|
| 185 | + $counts = empty( $settings[ 'counts' ] ) ? 'false' : 'true'; |
|
| 186 | 186 | |
| 187 | - if( !empty( $settings['field'] ) ) { |
|
| 188 | - $merge_tag = sprintf( '{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings['field'], $settings['style'], $percentages, $counts ); |
|
| 187 | + if ( ! empty( $settings[ 'field' ] ) ) { |
|
| 188 | + $merge_tag = sprintf( '{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings[ 'field' ], $settings[ 'style' ], $percentages, $counts ); |
|
| 189 | 189 | } else { |
| 190 | - $merge_tag = sprintf( '{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings['style'], $percentages, $counts ); |
|
| 190 | + $merge_tag = sprintf( '{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings[ 'style' ], $percentages, $counts ); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | $gravityview_view = GravityView_View::getInstance(); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | $gravityview_view->poll_settings = $settings; |
| 198 | 198 | $gravityview_view->poll_fields = $this->poll_fields; |
| 199 | 199 | |
| 200 | - $gravityview_view->render('widget', 'poll', false ); |
|
| 200 | + $gravityview_view->render( 'widget', 'poll', false ); |
|
| 201 | 201 | |
| 202 | 202 | unset( $gravityview_view->poll_merge_tag, $gravityview_view->poll_settings, $gravityview_view->poll_form, $gravityview_view->poll_fields ); |
| 203 | 203 | } |