@@ -19,12 +19,12 @@ |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | function render_input( $override_input = null ) { |
22 | - if( isset( $override_input ) ) { |
|
22 | + if ( isset( $override_input ) ) { |
|
23 | 23 | echo $override_input; |
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
27 | - foreach( $this->field['options'] as $value => $label ) : ?> |
|
27 | + foreach ( $this->field[ 'options' ] as $value => $label ) : ?> |
|
28 | 28 | <label class="<?php echo $this->get_label_class(); ?>"> |
29 | 29 | <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>-<?php echo esc_attr( $value ); ?>" type="radio" value="<?php echo esc_attr( $value ); ?>" <?php checked( $value, $this->value, true ); ?> /> <?php echo esc_html( $label ); ?> |
30 | 30 | </label> |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | var $name = 'radio'; |
11 | 11 | |
12 | - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); |
|
12 | + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); |
|
13 | 13 | |
14 | 14 | var $_gf_field_class_name = 'GF_Field_Radio'; |
15 | 15 | |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | // Set the $_field_id var |
39 | 39 | $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type ); |
40 | 40 | |
41 | - if( $this->is_choice_value_enabled() ) { |
|
42 | - $field_options['choice_display'] = array( |
|
41 | + if ( $this->is_choice_value_enabled() ) { |
|
42 | + $field_options[ 'choice_display' ] = array( |
|
43 | 43 | 'type' => 'radio', |
44 | 44 | 'value' => 'value', |
45 | 45 | 'label' => __( 'What should be displayed:', 'gravityview' ), |
@@ -38,8 +38,8 @@ |
||
38 | 38 | // Set the $_field_id var |
39 | 39 | $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type ); |
40 | 40 | |
41 | - if( $this->is_choice_value_enabled() ) { |
|
42 | - $field_options['choice_display'] = array( |
|
41 | + if ( $this->is_choice_value_enabled() ) { |
|
42 | + $field_options[ 'choice_display' ] = array( |
|
43 | 43 | 'type' => 'radio', |
44 | 44 | 'value' => 'value', |
45 | 45 | 'label' => __( 'What should be displayed:', 'gravityview' ), |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | add_filter( 'gravityview/sortable/field_blacklist', array( $this, '_filter_sortable_fields' ), 1 ); |
111 | 111 | |
112 | - if( $this->_custom_merge_tag ) { |
|
112 | + if ( $this->_custom_merge_tag ) { |
|
113 | 113 | add_filter( 'gform_custom_merge_tags', array( $this, '_filter_gform_custom_merge_tags' ), 10, 4 ); |
114 | 114 | add_filter( 'gform_replace_merge_tags', array( $this, '_filter_gform_replace_merge_tags' ), 10, 7 ); |
115 | 115 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return string Original text if {_custom_merge_tag} isn't found. Otherwise, replaced text. |
133 | 133 | */ |
134 | - public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
134 | + public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * This prevents the gform_replace_merge_tags filter from being called twice, as defined in: |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @see GFCommon::replace_variables_prepopulate() |
140 | 140 | * @todo Remove eventually: Gravity Forms fixed this issue in 1.9.14 |
141 | 141 | */ |
142 | - if( false === $form ) { |
|
142 | + if ( false === $form ) { |
|
143 | 143 | return $text; |
144 | 144 | } |
145 | 145 | |
@@ -172,19 +172,19 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
174 | 174 | |
175 | - foreach( $matches as $match ) { |
|
175 | + foreach ( $matches as $match ) { |
|
176 | 176 | |
177 | - $full_tag = $match[0]; |
|
177 | + $full_tag = $match[ 0 ]; |
|
178 | 178 | |
179 | 179 | // Strip the Merge Tags |
180 | - $tag = str_replace( array( '{', '}'), '', $full_tag ); |
|
180 | + $tag = str_replace( array( '{', '}' ), '', $full_tag ); |
|
181 | 181 | |
182 | 182 | // Replace the value from the entry, if exists |
183 | - if( isset( $entry[ $tag ] ) ) { |
|
183 | + if ( isset( $entry[ $tag ] ) ) { |
|
184 | 184 | |
185 | 185 | $value = $entry[ $tag ]; |
186 | 186 | |
187 | - if( is_callable( array( $this, 'get_content') ) ) { |
|
187 | + if ( is_callable( array( $this, 'get_content' ) ) ) { |
|
188 | 188 | $value = $this->get_content( $value ); |
189 | 189 | } |
190 | 190 | |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function _filter_sortable_fields( $not_sortable ) { |
259 | 259 | |
260 | - if( ! $this->is_sortable ) { |
|
261 | - $not_sortable[] = $this->name; |
|
260 | + if ( ! $this->is_sortable ) { |
|
261 | + $not_sortable[ ] = $this->name; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | return $not_sortable; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | 'date_display' => array( |
288 | 288 | 'type' => 'text', |
289 | 289 | 'label' => __( 'Override Date Format', 'gravityview' ), |
290 | - 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview'), '<a href="https://codex.wordpress.org/Formatting_Date_and_Time">', '</a>' ), |
|
290 | + 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview' ), '<a href="https://codex.wordpress.org/Formatting_Date_and_Time">', '</a>' ), |
|
291 | 291 | /** |
292 | 292 | * @filter `gravityview_date_format` Override the date format with a [PHP date format](https://codex.wordpress.org/Formatting_Date_and_Time) |
293 | 293 | * @param[in,out] null|string $date_format Date Format (default: null) |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | |
313 | 313 | $options = $this->field_support_options(); |
314 | 314 | |
315 | - if( isset( $options[ $key ] ) ) { |
|
315 | + if ( isset( $options[ $key ] ) ) { |
|
316 | 316 | $field_options[ $key ] = $options[ $key ]; |
317 | 317 | } |
318 | 318 | |
@@ -376,11 +376,11 @@ discard block |
||
376 | 376 | $connected_form = rgpost( 'form_id' ); |
377 | 377 | |
378 | 378 | // Otherwise, get the Form ID from the Post page |
379 | - if( empty( $connected_form ) ) { |
|
379 | + if ( empty( $connected_form ) ) { |
|
380 | 380 | $connected_form = gravityview_get_form_id( get_the_ID() ); |
381 | 381 | } |
382 | 382 | |
383 | - if( empty( $connected_form ) ) { |
|
383 | + if ( empty( $connected_form ) ) { |
|
384 | 384 | do_action( 'gravityview_log_error', sprintf( '%s: Form not found for form ID "%s"', __METHOD__, $connected_form ) ); |
385 | 385 | return false; |
386 | 386 | } |
@@ -66,20 +66,20 @@ discard block |
||
66 | 66 | |
67 | 67 | /** Load common & connector functions */ |
68 | 68 | require_once( GRAVITYVIEW_DIR . 'includes/helper-functions.php' ); |
69 | -require_once( GRAVITYVIEW_DIR . 'includes/class-common.php'); |
|
70 | -require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php'); |
|
69 | +require_once( GRAVITYVIEW_DIR . 'includes/class-common.php' ); |
|
70 | +require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php' ); |
|
71 | 71 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-compatibility.php' ); |
72 | 72 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-roles-capabilities.php' ); |
73 | 73 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-notices.php' ); |
74 | 74 | |
75 | 75 | /** Register Post Types and Rewrite Rules */ |
76 | -require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php'); |
|
76 | +require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php' ); |
|
77 | 77 | |
78 | 78 | /** Add Cache Class */ |
79 | -require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php'); |
|
79 | +require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php' ); |
|
80 | 80 | |
81 | 81 | /** Register hooks that are fired when the plugin is activated and deactivated. */ |
82 | -if( is_admin() ) { |
|
82 | +if ( is_admin() ) { |
|
83 | 83 | register_activation_hook( __FILE__, array( 'GravityView_Plugin', 'activate' ) ); |
84 | 84 | register_deactivation_hook( __FILE__, array( 'GravityView_Plugin', 'deactivate' ) ); |
85 | 85 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public static function getInstance() { |
102 | 102 | |
103 | - if( empty( self::$instance ) ) { |
|
103 | + if ( empty( self::$instance ) ) { |
|
104 | 104 | self::$instance = new self; |
105 | 105 | } |
106 | 106 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | private function __construct() { |
111 | 111 | |
112 | 112 | |
113 | - if( ! GravityView_Compatibility::is_valid() ) { |
|
113 | + if ( ! GravityView_Compatibility::is_valid() ) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function include_files() { |
141 | 141 | |
142 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin.php' ); |
|
142 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin.php' ); |
|
143 | 143 | |
144 | 144 | // Load fields |
145 | 145 | include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-fields.php' ); |
@@ -150,20 +150,20 @@ discard block |
||
150 | 150 | include_once( $gv_field_filename ); |
151 | 151 | } |
152 | 152 | |
153 | - include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-notes.php' ); |
|
154 | - include_once( GRAVITYVIEW_DIR .'includes/load-plugin-and-theme-hooks.php' ); |
|
153 | + include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-notes.php' ); |
|
154 | + include_once( GRAVITYVIEW_DIR . 'includes/load-plugin-and-theme-hooks.php' ); |
|
155 | 155 | |
156 | 156 | // Load Extensions |
157 | 157 | // @todo: Convert to a scan of the directory or a method where this all lives |
158 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/edit-entry/class-edit-entry.php' ); |
|
159 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/delete-entry/class-delete-entry.php' ); |
|
160 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/entry-notes/class-gravityview-field-notes.php' ); |
|
158 | + include_once( GRAVITYVIEW_DIR . 'includes/extensions/edit-entry/class-edit-entry.php' ); |
|
159 | + include_once( GRAVITYVIEW_DIR . 'includes/extensions/delete-entry/class-delete-entry.php' ); |
|
160 | + include_once( GRAVITYVIEW_DIR . 'includes/extensions/entry-notes/class-gravityview-field-notes.php' ); |
|
161 | 161 | |
162 | 162 | // Load WordPress Widgets |
163 | - include_once( GRAVITYVIEW_DIR .'includes/wordpress-widgets/register-wordpress-widgets.php' ); |
|
163 | + include_once( GRAVITYVIEW_DIR . 'includes/wordpress-widgets/register-wordpress-widgets.php' ); |
|
164 | 164 | |
165 | 165 | // Load GravityView Widgets |
166 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/register-gravityview-widgets.php' ); |
|
166 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/register-gravityview-widgets.php' ); |
|
167 | 167 | |
168 | 168 | // Add oEmbed |
169 | 169 | include_once( GRAVITYVIEW_DIR . 'includes/class-oembed.php' ); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' ); |
177 | 177 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-bar.php' ); |
178 | 178 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-list.php' ); |
179 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php'); /** @since 1.8.4 */ |
|
179 | + include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php' ); /** @since 1.8.4 */ |
|
180 | 180 | include_once( GRAVITYVIEW_DIR . 'includes/class-data.php' ); |
181 | 181 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-shortcode.php' ); |
182 | 182 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-link-shortcode.php' ); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @return bool |
192 | 192 | */ |
193 | 193 | public static function is_network_activated() { |
194 | - return is_multisite() && ( function_exists('is_plugin_active_for_network') && is_plugin_active_for_network( 'gravityview/gravityview.php' ) ); |
|
194 | + return is_multisite() && ( function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'gravityview/gravityview.php' ) ); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @since 1.7.5.1 |
257 | 257 | */ |
258 | 258 | public static function include_widget_class() { |
259 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' ); |
|
259 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget.php' ); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | } |
279 | 279 | if ( ! $loaded ) { |
280 | 280 | $locale = apply_filters( 'plugin_locale', get_locale(), 'gravityview' ); |
281 | - $mofile = dirname( __FILE__ ) . '/languages/gravityview-'. $locale .'.mo'; |
|
281 | + $mofile = dirname( __FILE__ ) . '/languages/gravityview-' . $locale . '.mo'; |
|
282 | 282 | load_textdomain( 'gravityview', $mofile ); |
283 | 283 | } |
284 | 284 | |
@@ -309,12 +309,12 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function frontend_actions( $force = false ) { |
311 | 311 | |
312 | - if( self::is_admin() && ! $force ) { return; } |
|
312 | + if ( self::is_admin() && ! $force ) { return; } |
|
313 | 313 | |
314 | 314 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-image.php' ); |
315 | - include_once( GRAVITYVIEW_DIR .'includes/class-template.php' ); |
|
316 | - include_once( GRAVITYVIEW_DIR .'includes/class-api.php' ); |
|
317 | - include_once( GRAVITYVIEW_DIR .'includes/class-frontend-views.php' ); |
|
315 | + include_once( GRAVITYVIEW_DIR . 'includes/class-template.php' ); |
|
316 | + include_once( GRAVITYVIEW_DIR . 'includes/class-api.php' ); |
|
317 | + include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' ); |
|
318 | 318 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' ); |
319 | 319 | |
320 | 320 | |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | */ |
340 | 340 | public static function get_default_widget_areas() { |
341 | 341 | $default_areas = array( |
342 | - array( '1-1' => array( array( 'areaid' => 'top', 'title' => __('Top', 'gravityview' ) , 'subtitle' => '' ) ) ), |
|
343 | - array( '1-2' => array( array( 'areaid' => 'left', 'title' => __('Left', 'gravityview') , 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __('Right', 'gravityview') , 'subtitle' => '' ) ) ), |
|
342 | + array( '1-1' => array( array( 'areaid' => 'top', 'title' => __( 'Top', 'gravityview' ), 'subtitle' => '' ) ) ), |
|
343 | + array( '1-2' => array( array( 'areaid' => 'left', 'title' => __( 'Left', 'gravityview' ), 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __( 'Right', 'gravityview' ), 'subtitle' => '' ) ) ), |
|
344 | 344 | ); |
345 | 345 | |
346 | 346 | /** |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param mixed $data Additional data to display |
359 | 359 | * @return void |
360 | 360 | */ |
361 | - public static function log_debug( $message, $data = null ){ |
|
361 | + public static function log_debug( $message, $data = null ) { |
|
362 | 362 | /** |
363 | 363 | * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
364 | 364 | * @param string $message Message to display |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @param string $message log message |
373 | 373 | * @return void |
374 | 374 | */ |
375 | - public static function log_error( $message, $data = null ){ |
|
375 | + public static function log_error( $message, $data = null ) { |
|
376 | 376 | /** |
377 | 377 | * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
378 | 378 | * @param string $message Error message to display |
@@ -383,4 +383,4 @@ discard block |
||
383 | 383 | |
384 | 384 | } // end class GravityView_Plugin |
385 | 385 | |
386 | -add_action('plugins_loaded', array('GravityView_Plugin', 'getInstance'), 1); |
|
386 | +add_action( 'plugins_loaded', array( 'GravityView_Plugin', 'getInstance' ), 1 ); |
@@ -48,25 +48,25 @@ |
||
48 | 48 | |
49 | 49 | $quiz_fields = GFAPI::get_fields_by_type( $form, 'quiz' ); |
50 | 50 | |
51 | - if( ! empty( $quiz_fields ) ) { |
|
51 | + if ( ! empty( $quiz_fields ) ) { |
|
52 | 52 | |
53 | - $fields['gquiz_score'] = array( |
|
53 | + $fields[ 'gquiz_score' ] = array( |
|
54 | 54 | 'label' => __( 'Quiz Score Total', 'gravityview' ), |
55 | 55 | 'type' => 'quiz_score', |
56 | 56 | 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
57 | 57 | ); |
58 | - $fields['gquiz_percent'] = array( |
|
58 | + $fields[ 'gquiz_percent' ] = array( |
|
59 | 59 | 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
60 | 60 | 'type' => 'quiz_percent', |
61 | 61 | 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
62 | 62 | ); |
63 | - $fields['gquiz_grade'] = array( |
|
63 | + $fields[ 'gquiz_grade' ] = array( |
|
64 | 64 | /* translators: This is a field type used by the Gravity Forms Quiz Addon. "A" is 100-90, "B" is 89-80, "C" is 79-70, etc. */ |
65 | 65 | 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
66 | 66 | 'type' => 'quiz_grade', |
67 | 67 | 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
68 | 68 | ); |
69 | - $fields['gquiz_is_pass'] = array( |
|
69 | + $fields[ 'gquiz_is_pass' ] = array( |
|
70 | 70 | 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
71 | 71 | 'type' => 'quiz_is_pass', |
72 | 72 | 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $entry = self::get_entry( $entry_slug, true ); |
126 | 126 | |
127 | - $form = self::get_form( $entry['form_id'] ); |
|
127 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
128 | 128 | |
129 | 129 | return $form; |
130 | 130 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | $results = GFAPI::get_entries( 0, $search_criteria, null, $paging ); |
177 | 177 | |
178 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
178 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
179 | 179 | |
180 | 180 | return $result; |
181 | 181 | } |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | if ( class_exists( 'GFAPI' ) ) { |
194 | 194 | $gf_forms = GFAPI::get_forms(); |
195 | 195 | foreach ( $gf_forms as $form ) { |
196 | - $forms[] = array( |
|
197 | - 'id' => $form['id'], |
|
198 | - 'title' => $form['title'], |
|
196 | + $forms[ ] = array( |
|
197 | + 'id' => $form[ 'id' ], |
|
198 | + 'title' => $form[ 'title' ], |
|
199 | 199 | ); |
200 | 200 | } |
201 | 201 | } |
@@ -222,10 +222,10 @@ discard block |
||
222 | 222 | $has_post_fields = false; |
223 | 223 | |
224 | 224 | if ( $form ) { |
225 | - foreach ( $form['fields'] as $field ) { |
|
225 | + foreach ( $form[ 'fields' ] as $field ) { |
|
226 | 226 | |
227 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
228 | - $fields["{$field->id}"] = array( |
|
227 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
228 | + $fields[ "{$field->id}" ] = array( |
|
229 | 229 | 'label' => rgar( $field, 'label' ), |
230 | 230 | 'parent' => null, |
231 | 231 | 'type' => rgar( $field, 'type' ), |
@@ -240,10 +240,10 @@ discard block |
||
240 | 240 | * @hack |
241 | 241 | * In case of email/email confirmation, the input for email has the same id as the parent field |
242 | 242 | */ |
243 | - if( 'email' === $field->type && false === strpos( $input['id'], '.' ) ) { |
|
243 | + if ( 'email' === $field->type && false === strpos( $input[ 'id' ], '.' ) ) { |
|
244 | 244 | continue; |
245 | 245 | } |
246 | - $fields["{$input['id']}"] = array( |
|
246 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
247 | 247 | 'label' => rgar( $input, 'label' ), |
248 | 248 | 'customLabel' => rgar( $input, 'customLabel' ), |
249 | 249 | 'parent' => $field, |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | } |
256 | 256 | |
257 | 257 | |
258 | - if( GFCommon::is_product_field( $field->type ) ){ |
|
258 | + if ( GFCommon::is_product_field( $field->type ) ) { |
|
259 | 259 | $has_product_fields = true; |
260 | 260 | } |
261 | 261 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @since 1.7 |
270 | 270 | */ |
271 | 271 | if ( $has_post_fields ) { |
272 | - $fields['post_id'] = array( |
|
272 | + $fields[ 'post_id' ] = array( |
|
273 | 273 | 'label' => __( 'Post ID', 'gravityview' ), |
274 | 274 | 'type' => 'post_id', |
275 | 275 | ); |
@@ -280,10 +280,10 @@ discard block |
||
280 | 280 | $payment_fields = GravityView_Fields::get_all( 'pricing' ); |
281 | 281 | |
282 | 282 | foreach ( $payment_fields as $payment_field ) { |
283 | - if( isset( $fields["{$payment_field->name}"] ) ) { |
|
283 | + if ( isset( $fields[ "{$payment_field->name}" ] ) ) { |
|
284 | 284 | continue; |
285 | 285 | } |
286 | - $fields["{$payment_field->name}"] = array( |
|
286 | + $fields[ "{$payment_field->name}" ] = array( |
|
287 | 287 | 'label' => $payment_field->label, |
288 | 288 | 'desc' => $payment_field->description, |
289 | 289 | 'type' => $payment_field->name, |
@@ -315,9 +315,9 @@ discard block |
||
315 | 315 | |
316 | 316 | $fields = array(); |
317 | 317 | |
318 | - foreach ( $extra_fields as $key => $field ){ |
|
319 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
320 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
318 | + foreach ( $extra_fields as $key => $field ) { |
|
319 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
320 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
@@ -357,32 +357,32 @@ discard block |
||
357 | 357 | 'search_criteria' => null, |
358 | 358 | 'sorting' => null, |
359 | 359 | 'paging' => null, |
360 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
360 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? $passed_criteria[ 'cache' ] : true ), |
|
361 | 361 | ); |
362 | 362 | |
363 | 363 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
364 | 364 | |
365 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
366 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
365 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
366 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
367 | 367 | |
368 | 368 | if ( ! is_array( $filter ) ) { |
369 | 369 | continue; |
370 | 370 | } |
371 | 371 | |
372 | 372 | // By default, we want searches to be wildcard for each field. |
373 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
373 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
374 | 374 | |
375 | 375 | /** |
376 | 376 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
377 | 377 | * @param string $operator Existing search operator |
378 | 378 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
379 | 379 | */ |
380 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
380 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | // don't send just the [mode] without any field filter. |
384 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
385 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
384 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
385 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | } |
@@ -393,21 +393,21 @@ discard block |
||
393 | 393 | * Prepare date formats to be in Gravity Forms DB format; |
394 | 394 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
395 | 395 | */ |
396 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
396 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
397 | 397 | |
398 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
398 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
399 | 399 | |
400 | 400 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
401 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
401 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
402 | 402 | |
403 | 403 | if ( $date ) { |
404 | 404 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
405 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
405 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
406 | 406 | } else { |
407 | 407 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
408 | - unset( $criteria['search_criteria'][ $key ] ); |
|
408 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
409 | 409 | |
410 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
410 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | } |
@@ -415,12 +415,12 @@ discard block |
||
415 | 415 | |
416 | 416 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
417 | 417 | if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
418 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
418 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
419 | 419 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
420 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
421 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
420 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
421 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
422 | 422 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
423 | - $criteria['context_view_id'] = null; |
|
423 | + $criteria[ 'context_view_id' ] = null; |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * @param array $form_ids Forms to search |
430 | 430 | * @param int $view_id ID of the view being used to search |
431 | 431 | */ |
432 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
432 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
433 | 433 | |
434 | 434 | return (array)$criteria; |
435 | 435 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | /** Reduce # of database calls */ |
461 | 461 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
462 | 462 | |
463 | - if ( ! empty( $criteria['cache'] ) ) { |
|
463 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
464 | 464 | |
465 | 465 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
466 | 466 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | |
469 | 469 | // Still update the total count when using cached results |
470 | 470 | if ( ! is_null( $total ) ) { |
471 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
471 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | $return = $entries; |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
489 | 489 | |
490 | 490 | // No entries returned from gravityview_before_get_entries |
491 | - if( is_null( $entries ) ) { |
|
491 | + if ( is_null( $entries ) ) { |
|
492 | 492 | |
493 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
493 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
494 | 494 | |
495 | 495 | if ( is_wp_error( $entries ) ) { |
496 | 496 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
502 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
503 | 503 | |
504 | 504 | // Cache results |
505 | 505 | $Cache->set( $entries, 'entries' ); |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | */ |
587 | 587 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
588 | 588 | |
589 | - if( $check_entry_display ) { |
|
589 | + if ( $check_entry_display ) { |
|
590 | 590 | // Is the entry allowed |
591 | 591 | $entry = self::check_entry_display( $entry ); |
592 | 592 | } |
@@ -619,12 +619,12 @@ discard block |
||
619 | 619 | |
620 | 620 | $value = false; |
621 | 621 | |
622 | - if( 'context' === $val1 ) { |
|
622 | + if ( 'context' === $val1 ) { |
|
623 | 623 | |
624 | 624 | $matching_contexts = array( $val2 ); |
625 | 625 | |
626 | 626 | // We allow for non-standard contexts. |
627 | - switch( $val2 ) { |
|
627 | + switch ( $val2 ) { |
|
628 | 628 | // Check for either single or edit |
629 | 629 | case 'singular': |
630 | 630 | $matching_contexts = array( 'single', 'edit' ); |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | return false; |
685 | 685 | } |
686 | 686 | |
687 | - if ( empty( $entry['form_id'] ) ) { |
|
687 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
688 | 688 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
689 | 689 | return false; |
690 | 690 | } |
@@ -692,26 +692,26 @@ discard block |
||
692 | 692 | $criteria = self::calculate_get_entries_criteria(); |
693 | 693 | |
694 | 694 | // Make sure the current View is connected to the same form as the Entry |
695 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
696 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
695 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
696 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
697 | 697 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
698 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
699 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
698 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
699 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
700 | 700 | return false; |
701 | 701 | } |
702 | 702 | } |
703 | 703 | |
704 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
704 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
705 | 705 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
706 | 706 | return $entry; |
707 | 707 | } |
708 | 708 | |
709 | - $search_criteria = $criteria['search_criteria']; |
|
709 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
710 | 710 | unset( $criteria ); |
711 | 711 | |
712 | 712 | // check entry status |
713 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
714 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
713 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
714 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
715 | 715 | return false; |
716 | 716 | } |
717 | 717 | |
@@ -719,37 +719,37 @@ discard block |
||
719 | 719 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
720 | 720 | |
721 | 721 | // field_filters |
722 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
722 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
723 | 723 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
724 | 724 | return $entry; |
725 | 725 | } |
726 | 726 | |
727 | - $filters = $search_criteria['field_filters']; |
|
727 | + $filters = $search_criteria[ 'field_filters' ]; |
|
728 | 728 | unset( $search_criteria ); |
729 | 729 | |
730 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
731 | - unset( $filters['mode'] ); |
|
730 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
731 | + unset( $filters[ 'mode' ] ); |
|
732 | 732 | |
733 | - $form = self::get_form( $entry['form_id'] ); |
|
733 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
734 | 734 | |
735 | 735 | foreach ( $filters as $filter ) { |
736 | 736 | |
737 | - if ( ! isset( $filter['key'] ) ) { |
|
737 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
738 | 738 | continue; |
739 | 739 | } |
740 | 740 | |
741 | - $k = $filter['key']; |
|
741 | + $k = $filter[ 'key' ]; |
|
742 | 742 | |
743 | 743 | if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
744 | 744 | $field_value = $entry[ $k ]; |
745 | 745 | $field = null; |
746 | 746 | } else { |
747 | 747 | $field = self::get_field( $form, $k ); |
748 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
748 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
749 | 749 | } |
750 | 750 | |
751 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
752 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
751 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
752 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
753 | 753 | |
754 | 754 | // verify if we are already free to go! |
755 | 755 | if ( ! $is_value_match && 'all' === $mode ) { |
@@ -807,18 +807,18 @@ discard block |
||
807 | 807 | * Gravity Forms code to adjust date to locally-configured Time Zone |
808 | 808 | * @see GFCommon::format_date() for original code |
809 | 809 | */ |
810 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
810 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
811 | 811 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
812 | 812 | |
813 | - $format = rgar( $atts, 'format' ); |
|
814 | - $is_human = ! empty( $atts['human'] ); |
|
815 | - $is_diff = ! empty( $atts['diff'] ); |
|
816 | - $is_raw = ! empty( $atts['raw'] ); |
|
817 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
818 | - $include_time = ! empty( $atts['time'] ); |
|
813 | + $format = rgar( $atts, 'format' ); |
|
814 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
815 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
816 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
817 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
818 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
819 | 819 | |
820 | 820 | // If we're using time diff, we want to have a different default format |
821 | - if( empty( $format ) ) { |
|
821 | + if ( empty( $format ) ) { |
|
822 | 822 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
823 | 823 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
824 | 824 | } |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | // If raw was specified, don't modify the stored value |
827 | 827 | if ( $is_raw ) { |
828 | 828 | $formatted_date = $date_string; |
829 | - } elseif( $is_timestamp ) { |
|
829 | + } elseif ( $is_timestamp ) { |
|
830 | 830 | $formatted_date = $date_local_timestamp; |
831 | 831 | } elseif ( $is_diff ) { |
832 | 832 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | |
861 | 861 | $label = rgar( $field, 'label' ); |
862 | 862 | |
863 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
863 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
864 | 864 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
865 | 865 | } |
866 | 866 | |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | * @return GF_Field|null Gravity Forms field object, or NULL: Gravity Forms GFFormsModel does not exist or field at $field_id doesn't exist. |
882 | 882 | */ |
883 | 883 | public static function get_field( $form, $field_id ) { |
884 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
884 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
885 | 885 | return GFFormsModel::get_field( $form, $field_id ); |
886 | 886 | } else { |
887 | 887 | return null; |
@@ -928,19 +928,19 @@ discard block |
||
928 | 928 | $shortcodes = array(); |
929 | 929 | |
930 | 930 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
931 | - if ( empty( $matches ) ){ |
|
931 | + if ( empty( $matches ) ) { |
|
932 | 932 | return false; |
933 | 933 | } |
934 | 934 | |
935 | 935 | foreach ( $matches as $shortcode ) { |
936 | - if ( $tag === $shortcode[2] ) { |
|
936 | + if ( $tag === $shortcode[ 2 ] ) { |
|
937 | 937 | |
938 | 938 | // Changed this to $shortcode instead of true so we get the parsed atts. |
939 | - $shortcodes[] = $shortcode; |
|
939 | + $shortcodes[ ] = $shortcode; |
|
940 | 940 | |
941 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
942 | - foreach( $results as $result ) { |
|
943 | - $shortcodes[] = $result; |
|
941 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
942 | + foreach ( $results as $result ) { |
|
943 | + $shortcodes[ ] = $result; |
|
944 | 944 | } |
945 | 945 | } |
946 | 946 | } |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | * @return string html |
1102 | 1102 | */ |
1103 | 1103 | public static function get_sortable_fields( $formid, $current = '' ) { |
1104 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1104 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1105 | 1105 | |
1106 | 1106 | if ( empty( $formid ) ) { |
1107 | 1107 | return $output; |
@@ -1114,11 +1114,11 @@ discard block |
||
1114 | 1114 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1115 | 1115 | |
1116 | 1116 | foreach ( $fields as $id => $field ) { |
1117 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1117 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1118 | 1118 | continue; |
1119 | 1119 | } |
1120 | 1120 | |
1121 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1121 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1122 | 1122 | } |
1123 | 1123 | } |
1124 | 1124 | |
@@ -1153,9 +1153,9 @@ discard block |
||
1153 | 1153 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1154 | 1154 | |
1155 | 1155 | // TODO: Convert to using array_filter |
1156 | - foreach( $fields as $id => $field ) { |
|
1156 | + foreach ( $fields as $id => $field ) { |
|
1157 | 1157 | |
1158 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1158 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1159 | 1159 | unset( $fields[ $id ] ); |
1160 | 1160 | } |
1161 | 1161 | } |
@@ -1196,14 +1196,14 @@ discard block |
||
1196 | 1196 | * @param int|array $field field key or field array |
1197 | 1197 | * @return boolean |
1198 | 1198 | */ |
1199 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1199 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1200 | 1200 | |
1201 | 1201 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1202 | 1202 | $form = self::get_form( $form ); |
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | // If entry meta, it's a string. Otherwise, numeric |
1206 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1206 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1207 | 1207 | $type = $field; |
1208 | 1208 | } else { |
1209 | 1209 | $type = self::get_field_type( $form, $field ); |
@@ -1217,9 +1217,9 @@ discard block |
||
1217 | 1217 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1218 | 1218 | |
1219 | 1219 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1220 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1221 | - if( true === $gv_field->is_numeric ) { |
|
1222 | - $numeric_types[] = $gv_field->is_numeric; |
|
1220 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1221 | + if ( true === $gv_field->is_numeric ) { |
|
1222 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1223 | 1223 | } |
1224 | 1224 | } |
1225 | 1225 | |
@@ -1369,11 +1369,11 @@ discard block |
||
1369 | 1369 | $final_atts = array_filter( $final_atts ); |
1370 | 1370 | |
1371 | 1371 | // If the href wasn't passed as an attribute, use the value passed to the function |
1372 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1373 | - $final_atts['href'] = $href; |
|
1372 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1373 | + $final_atts[ 'href' ] = $href; |
|
1374 | 1374 | } |
1375 | 1375 | |
1376 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1376 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1377 | 1377 | |
1378 | 1378 | // Sort the attributes alphabetically, to help testing |
1379 | 1379 | ksort( $final_atts ); |
@@ -1384,7 +1384,7 @@ discard block |
||
1384 | 1384 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1385 | 1385 | } |
1386 | 1386 | |
1387 | - if( '' !== $output ) { |
|
1387 | + if ( '' !== $output ) { |
|
1388 | 1388 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1389 | 1389 | } |
1390 | 1390 | |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) { |
1409 | 1409 | $merged = $array1; |
1410 | 1410 | |
1411 | - foreach ( $array2 as $key => &$value ) { |
|
1411 | + foreach ( $array2 as $key => &$value ) { |
|
1412 | 1412 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1413 | 1413 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1414 | 1414 | } else { |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1444 | 1444 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1445 | 1445 | */ |
1446 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1446 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1447 | 1447 | |
1448 | 1448 | return get_users( $get_users_settings ); |
1449 | 1449 | } |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | * @return string |
1459 | 1459 | */ |
1460 | 1460 | public static function generate_notice( $notice, $class = '' ) { |
1461 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1461 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1462 | 1462 | } |
1463 | 1463 | |
1464 | 1464 | /** |
@@ -49,17 +49,17 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return string If a custom field label isn't set, return the field label for the password field |
51 | 51 | */ |
52 | - function field_label( $label = '', $field = array(), $form = array(), $entry = array() ){ |
|
52 | + function field_label( $label = '', $field = array(), $form = array(), $entry = array() ) { |
|
53 | 53 | |
54 | 54 | // If using a custom label, no need to fetch the parent label |
55 | - if( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) { |
|
55 | + if ( ! is_numeric( $field[ 'id' ] ) || ! empty( $field[ 'custom_label' ] ) ) { |
|
56 | 56 | return $label; |
57 | 57 | } |
58 | 58 | |
59 | - $field_object = GFFormsModel::get_field( $form, $field['id'] ); |
|
59 | + $field_object = GFFormsModel::get_field( $form, $field[ 'id' ] ); |
|
60 | 60 | |
61 | - if( $field_object && 'password' === $field_object->type ) { |
|
62 | - $label = $field['label']; |
|
61 | + if ( $field_object && 'password' === $field_object->type ) { |
|
62 | + $label = $field[ 'label' ]; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return $label; |
@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | function add_form_fields( $fields = array(), $form = array(), $include_parent_field = true ) { |
80 | 80 | |
81 | 81 | foreach ( $fields as $key => $field ) { |
82 | - if( 'password' === $field['type'] ) { |
|
82 | + if ( 'password' === $field[ 'type' ] ) { |
|
83 | 83 | |
84 | 84 | // The Enter Password input |
85 | - if( floor( $key ) === floatval( $key ) ) { |
|
86 | - $field['label'] = $field['parent']->label; |
|
87 | - $field['adminOnly'] = $field['parent']->adminOnly; |
|
88 | - $field['adminLabel'] = $field['parent']->adminLabel; |
|
85 | + if ( floor( $key ) === floatval( $key ) ) { |
|
86 | + $field[ 'label' ] = $field[ 'parent' ]->label; |
|
87 | + $field[ 'adminOnly' ] = $field[ 'parent' ]->adminOnly; |
|
88 | + $field[ 'adminLabel' ] = $field[ 'parent' ]->adminLabel; |
|
89 | 89 | |
90 | 90 | // Don't show as a child input |
91 | - unset( $field['parent'] ); |
|
91 | + unset( $field[ 'parent' ] ); |
|
92 | 92 | |
93 | 93 | $fields[ $key ] = $field; |
94 | 94 | } else { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | 'type' => 'radio', |
64 | 64 | 'full_width' => true, |
65 | 65 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
66 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
66 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
67 | 67 | 'value' => 'any', |
68 | 68 | 'class' => 'hide-if-js', |
69 | 69 | 'options' => array( |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
87 | 87 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
88 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
88 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
89 | 89 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
90 | 90 | |
91 | 91 | // ajax - get the searchable fields |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
150 | 150 | $script_source = empty( $script_min ) ? '/source' : ''; |
151 | 151 | |
152 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version ); |
|
152 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version ); |
|
153 | 153 | |
154 | 154 | |
155 | 155 | /** |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
205 | 205 | */ |
206 | 206 | public function register_no_conflict( $allowed ) { |
207 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
207 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
208 | 208 | return $allowed; |
209 | 209 | } |
210 | 210 | |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public static function get_searchable_fields() { |
219 | 219 | |
220 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
220 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
221 | 221 | exit( '0' ); |
222 | 222 | } |
223 | 223 | |
224 | 224 | $form = ''; |
225 | 225 | |
226 | 226 | // Fetch the form for the current View |
227 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
227 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
228 | 228 | |
229 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
229 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
230 | 230 | |
231 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
231 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
232 | 232 | |
233 | - $form = (int) $_POST['formid']; |
|
233 | + $form = (int)$_POST[ 'formid' ]; |
|
234 | 234 | |
235 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
235 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
236 | 236 | |
237 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
237 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
238 | 238 | |
239 | 239 | } |
240 | 240 | |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | ) |
280 | 280 | ); |
281 | 281 | |
282 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
283 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
282 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
283 | + $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] ); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // Get fields with sub-inputs and no parent |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | |
303 | 303 | foreach ( $fields as $id => $field ) { |
304 | 304 | |
305 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
305 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
306 | 306 | continue; |
307 | 307 | } |
308 | 308 | |
309 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
309 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
310 | 310 | |
311 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
311 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | public static function get_search_input_types( $id = '', $field_type = null ) { |
331 | 331 | |
332 | 332 | // @todo - This needs to be improved - many fields have . including products and addresses |
333 | - if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
333 | + if ( false !== strpos( (string)$id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
334 | 334 | $input_type = 'boolean'; // on/off checkbox |
335 | 335 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
336 | 336 | $input_type = 'multi'; //multiselect |
@@ -372,19 +372,19 @@ discard block |
||
372 | 372 | $post_id = 0; |
373 | 373 | |
374 | 374 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
375 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
376 | - $post_id = absint( $widget_args['post_id'] ); |
|
375 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
376 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
377 | 377 | } |
378 | 378 | // We're in the WordPress Widget context, and the base View ID should be used |
379 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
380 | - $post_id = absint( $widget_args['view_id'] ); |
|
379 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
380 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | $args = gravityview_get_permalink_query_args( $post_id ); |
384 | 384 | |
385 | 385 | // Add hidden fields to the search form |
386 | 386 | foreach ( $args as $key => $value ) { |
387 | - $search_fields[] = array( |
|
387 | + $search_fields[ ] = array( |
|
388 | 388 | 'name' => $key, |
389 | 389 | 'input' => 'hidden', |
390 | 390 | 'value' => $value, |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | */ |
406 | 406 | public function filter_entries( $search_criteria ) { |
407 | 407 | |
408 | - if( 'post' === $this->search_method ) { |
|
408 | + if ( 'post' === $this->search_method ) { |
|
409 | 409 | $get = $_POST; |
410 | 410 | } else { |
411 | 411 | $get = $_GET; |
@@ -422,15 +422,15 @@ discard block |
||
422 | 422 | $get = gv_map_deep( $get, 'urldecode' ); |
423 | 423 | |
424 | 424 | // add free search |
425 | - if ( ! empty( $get['gv_search'] ) ) { |
|
425 | + if ( ! empty( $get[ 'gv_search' ] ) ) { |
|
426 | 426 | |
427 | 427 | // Search for a piece |
428 | - $words = explode( ' ', $get['gv_search'] ); |
|
428 | + $words = explode( ' ', $get[ 'gv_search' ] ); |
|
429 | 429 | |
430 | 430 | $words = array_filter( $words ); |
431 | 431 | |
432 | 432 | foreach ( $words as $word ) { |
433 | - $search_criteria['field_filters'][] = array( |
|
433 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
434 | 434 | 'key' => null, // The field ID to search |
435 | 435 | 'value' => $word, // The value to search |
436 | 436 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | } |
440 | 440 | |
441 | 441 | //start date & end date |
442 | - $curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : ''; |
|
443 | - $curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : ''; |
|
442 | + $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : ''; |
|
443 | + $curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : ''; |
|
444 | 444 | |
445 | 445 | /** |
446 | 446 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -455,16 +455,16 @@ discard block |
||
455 | 455 | /** |
456 | 456 | * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries) |
457 | 457 | */ |
458 | - if( !empty( $curr_start ) ) { |
|
459 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
458 | + if ( ! empty( $curr_start ) ) { |
|
459 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
460 | 460 | } |
461 | - if( !empty( $curr_end ) ) { |
|
462 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
461 | + if ( ! empty( $curr_end ) ) { |
|
462 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | // search for a specific entry ID |
466 | 466 | if ( ! empty( $get[ 'gv_id' ] ) ) { |
467 | - $search_criteria['field_filters'][] = array( |
|
467 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
468 | 468 | 'key' => 'id', |
469 | 469 | 'value' => absint( $get[ 'gv_id' ] ), |
470 | 470 | 'operator' => '=', |
@@ -473,36 +473,36 @@ discard block |
||
473 | 473 | |
474 | 474 | // search for a specific Created_by ID |
475 | 475 | if ( ! empty( $get[ 'gv_by' ] ) ) { |
476 | - $search_criteria['field_filters'][] = array( |
|
476 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
477 | 477 | 'key' => 'created_by', |
478 | - 'value' => absint( $get['gv_by'] ), |
|
478 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
479 | 479 | 'operator' => '=', |
480 | 480 | ); |
481 | 481 | } |
482 | 482 | |
483 | 483 | |
484 | 484 | // Get search mode passed in URL |
485 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
485 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
486 | 486 | |
487 | 487 | // get the other search filters |
488 | 488 | foreach ( $get as $key => $value ) { |
489 | 489 | |
490 | - if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) { |
|
490 | + if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[ 0 ] ) ) ) { |
|
491 | 491 | continue; |
492 | 492 | } |
493 | 493 | |
494 | 494 | // could return simple filter or multiple filters |
495 | 495 | $filter = $this->prepare_field_filter( $key, $value ); |
496 | 496 | |
497 | - if ( isset( $filter[0]['value'] ) ) { |
|
498 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
497 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
498 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
499 | 499 | |
500 | 500 | // if date range type, set search mode to ALL |
501 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
501 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
502 | 502 | $mode = 'all'; |
503 | 503 | } |
504 | - } elseif( !empty( $filter ) ) { |
|
505 | - $search_criteria['field_filters'][] = $filter; |
|
504 | + } elseif ( ! empty( $filter ) ) { |
|
505 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * @since 1.5.1 |
512 | 512 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
513 | 513 | */ |
514 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
514 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
515 | 515 | |
516 | 516 | do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
517 | 517 | |
@@ -549,11 +549,11 @@ discard block |
||
549 | 549 | 'value' => $value, |
550 | 550 | ); |
551 | 551 | |
552 | - switch ( $form_field['type'] ) { |
|
552 | + switch ( $form_field[ 'type' ] ) { |
|
553 | 553 | |
554 | 554 | case 'select': |
555 | 555 | case 'radio': |
556 | - $filter['operator'] = 'is'; |
|
556 | + $filter[ 'operator' ] = 'is'; |
|
557 | 557 | break; |
558 | 558 | |
559 | 559 | case 'post_category': |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | |
568 | 568 | foreach ( $value as $val ) { |
569 | 569 | $cat = get_term( $val, 'category' ); |
570 | - $filter[] = array( |
|
570 | + $filter[ ] = array( |
|
571 | 571 | 'key' => $field_id, |
572 | 572 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
573 | 573 | 'operator' => 'is', |
@@ -586,18 +586,18 @@ discard block |
||
586 | 586 | $filter = array(); |
587 | 587 | |
588 | 588 | foreach ( $value as $val ) { |
589 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
589 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | break; |
593 | 593 | |
594 | 594 | case 'checkbox': |
595 | 595 | // convert checkbox on/off into the correct search filter |
596 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
597 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
598 | - if ( $input['id'] == $field_id ) { |
|
599 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
600 | - $filter['operator'] = 'is'; |
|
596 | + if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) { |
|
597 | + foreach ( $form_field[ 'inputs' ] as $k => $input ) { |
|
598 | + if ( $input[ 'id' ] == $field_id ) { |
|
599 | + $filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ]; |
|
600 | + $filter[ 'operator' ] = 'is'; |
|
601 | 601 | break; |
602 | 602 | } |
603 | 603 | } |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | $filter = array(); |
608 | 608 | |
609 | 609 | foreach ( $value as $val ) { |
610 | - $filter[] = array( |
|
610 | + $filter[ ] = array( |
|
611 | 611 | 'key' => $field_id, |
612 | 612 | 'value' => $val, |
613 | 613 | 'operator' => 'is', |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | foreach ( $words as $word ) { |
629 | 629 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
630 | 630 | // Keep the same key for each filter |
631 | - $filter['value'] = $word; |
|
631 | + $filter[ 'value' ] = $word; |
|
632 | 632 | // Add a search for the value |
633 | - $filters[] = $filter; |
|
633 | + $filters[ ] = $filter; |
|
634 | 634 | } |
635 | 635 | } |
636 | 636 | |
@@ -657,19 +657,19 @@ discard block |
||
657 | 657 | * @since 1.16.3 |
658 | 658 | * Safeguard until GF implements '<=' operator |
659 | 659 | */ |
660 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
660 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
661 | 661 | $operator = '<'; |
662 | 662 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
663 | 663 | } |
664 | 664 | |
665 | - $filter[] = array( |
|
665 | + $filter[ ] = array( |
|
666 | 666 | 'key' => $field_id, |
667 | 667 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
668 | 668 | 'operator' => $operator, |
669 | 669 | ); |
670 | 670 | } |
671 | 671 | } else { |
672 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
672 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | break; |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | 'ymd_dot' => 'Y.m.d', |
701 | 701 | ); |
702 | 702 | |
703 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
703 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
704 | 704 | $format = $datepicker[ $field->dateFormat ]; |
705 | 705 | } |
706 | 706 | |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | public function add_template_path( $file_paths ) { |
732 | 732 | |
733 | 733 | // Index 100 is the default GravityView template path. |
734 | - $file_paths[102] = self::$file . 'templates/'; |
|
734 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
735 | 735 | |
736 | 736 | return $file_paths; |
737 | 737 | } |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | } |
755 | 755 | |
756 | 756 | // get configured search fields |
757 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
757 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
758 | 758 | |
759 | 759 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
760 | 760 | do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
@@ -768,24 +768,24 @@ discard block |
||
768 | 768 | |
769 | 769 | $updated_field = $field; |
770 | 770 | |
771 | - if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) { |
|
771 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range' ) ) ) { |
|
772 | 772 | $has_date = true; |
773 | 773 | } |
774 | 774 | |
775 | 775 | $updated_field = $this->get_search_filter_details( $updated_field ); |
776 | 776 | |
777 | - switch ( $field['field'] ) { |
|
777 | + switch ( $field[ 'field' ] ) { |
|
778 | 778 | |
779 | 779 | case 'search_all': |
780 | - $updated_field['key'] = 'search_all'; |
|
781 | - $updated_field['input'] = 'search_all'; |
|
782 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
780 | + $updated_field[ 'key' ] = 'search_all'; |
|
781 | + $updated_field[ 'input' ] = 'search_all'; |
|
782 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
783 | 783 | break; |
784 | 784 | |
785 | 785 | case 'entry_date': |
786 | - $updated_field['key'] = 'entry_date'; |
|
787 | - $updated_field['input'] = 'entry_date'; |
|
788 | - $updated_field['value'] = array( |
|
786 | + $updated_field[ 'key' ] = 'entry_date'; |
|
787 | + $updated_field[ 'input' ] = 'entry_date'; |
|
788 | + $updated_field[ 'value' ] = array( |
|
789 | 789 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
790 | 790 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
791 | 791 | ); |
@@ -793,16 +793,16 @@ discard block |
||
793 | 793 | break; |
794 | 794 | |
795 | 795 | case 'entry_id': |
796 | - $updated_field['key'] = 'entry_id'; |
|
797 | - $updated_field['input'] = 'entry_id'; |
|
798 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
796 | + $updated_field[ 'key' ] = 'entry_id'; |
|
797 | + $updated_field[ 'input' ] = 'entry_id'; |
|
798 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
799 | 799 | break; |
800 | 800 | |
801 | 801 | case 'created_by': |
802 | - $updated_field['key'] = 'created_by'; |
|
803 | - $updated_field['name'] = 'gv_by'; |
|
804 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
805 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
802 | + $updated_field[ 'key' ] = 'created_by'; |
|
803 | + $updated_field[ 'name' ] = 'gv_by'; |
|
804 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
805 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
806 | 806 | break; |
807 | 807 | } |
808 | 808 | |
@@ -820,16 +820,16 @@ discard block |
||
820 | 820 | */ |
821 | 821 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
822 | 822 | |
823 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
823 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
824 | 824 | |
825 | 825 | /** @since 1.14 */ |
826 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
826 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
827 | 827 | |
828 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
828 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
829 | 829 | |
830 | 830 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
831 | 831 | |
832 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
832 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
833 | 833 | |
834 | 834 | if ( $has_date ) { |
835 | 835 | // enqueue datepicker stuff only if needed! |
@@ -851,10 +851,10 @@ discard block |
||
851 | 851 | public static function get_search_class( $custom_class = '' ) { |
852 | 852 | $gravityview_view = GravityView_View::getInstance(); |
853 | 853 | |
854 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
854 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
855 | 855 | |
856 | - if ( ! empty( $custom_class ) ) { |
|
857 | - $search_class .= ' '.$custom_class; |
|
856 | + if ( ! empty( $custom_class ) ) { |
|
857 | + $search_class .= ' ' . $custom_class; |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | /** |
@@ -896,11 +896,11 @@ discard block |
||
896 | 896 | |
897 | 897 | $label = rgget( 'label', $field ); |
898 | 898 | |
899 | - if( '' === $label ) { |
|
899 | + if ( '' === $label ) { |
|
900 | 900 | |
901 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
901 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
902 | 902 | |
903 | - switch( $field['field'] ) { |
|
903 | + switch ( $field[ 'field' ] ) { |
|
904 | 904 | case 'search_all': |
905 | 905 | $label = __( 'Search Entries:', 'gravityview' ); |
906 | 906 | break; |
@@ -918,10 +918,10 @@ discard block |
||
918 | 918 | break; |
919 | 919 | default: |
920 | 920 | // If this is a field input, not a field |
921 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
921 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
922 | 922 | |
923 | 923 | // Get the label for the field in question, which returns an array |
924 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
924 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
925 | 925 | |
926 | 926 | // Get the item with the `label` key |
927 | 927 | $values = wp_list_pluck( $items, 'label' ); |
@@ -958,32 +958,32 @@ discard block |
||
958 | 958 | $form = $gravityview_view->getForm(); |
959 | 959 | |
960 | 960 | // for advanced field ids (eg, first name / last name ) |
961 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
961 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
962 | 962 | |
963 | 963 | // get searched value from $_GET/$_POST (string or array) |
964 | 964 | $value = $this->rgget_or_rgpost( $name ); |
965 | 965 | |
966 | 966 | // get form field details |
967 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
967 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
968 | 968 | |
969 | 969 | $filter = array( |
970 | - 'key' => $field['field'], |
|
970 | + 'key' => $field[ 'field' ], |
|
971 | 971 | 'name' => $name, |
972 | 972 | 'label' => self::get_field_label( $field, $form_field ), |
973 | - 'input' => $field['input'], |
|
973 | + 'input' => $field[ 'input' ], |
|
974 | 974 | 'value' => $value, |
975 | - 'type' => $form_field['type'], |
|
975 | + 'type' => $form_field[ 'type' ], |
|
976 | 976 | ); |
977 | 977 | |
978 | 978 | // collect choices |
979 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
980 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
981 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
982 | - $filter['choices'] = $form_field['choices']; |
|
979 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
980 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
981 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
982 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
983 | 983 | } |
984 | 984 | |
985 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
986 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
985 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
986 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | return $filter; |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | |
1008 | 1008 | $choices = array(); |
1009 | 1009 | foreach ( $users as $user ) { |
1010 | - $choices[] = array( |
|
1010 | + $choices[ ] = array( |
|
1011 | 1011 | 'value' => $user->ID, |
1012 | 1012 | 'text' => $user->display_name, |
1013 | 1013 | ); |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | */ |
1063 | 1063 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1064 | 1064 | |
1065 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1065 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1066 | 1066 | |
1067 | 1067 | return $js_dependencies; |
1068 | 1068 | } |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | 'isRTL' => is_rtl(), |
1107 | 1107 | ), $view_data ); |
1108 | 1108 | |
1109 | - $localizations['datepicker'] = $datepicker_settings; |
|
1109 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1110 | 1110 | |
1111 | 1111 | return $localizations; |
1112 | 1112 | |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | * @return void |
1136 | 1136 | */ |
1137 | 1137 | private function maybe_enqueue_flexibility() { |
1138 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1138 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1139 | 1139 | wp_enqueue_script( 'gv-flexibility' ); |
1140 | 1140 | } |
1141 | 1141 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1158 | 1158 | |
1159 | 1159 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1160 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1160 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1161 | 1161 | |
1162 | 1162 | /** |
1163 | 1163 | * @filter `gravityview_search_datepicker_class` |