@@ -101,8 +101,7 @@ discard block |
||
101 | 101 | $entries = $view->get_entries( gravityview()->request ); |
102 | 102 | } |
103 | 103 | |
104 | - $page = \GV\Utils::get( $parameters['paging'], 'current_page' ) ? |
|
105 | - : ( ( ( $parameters['paging']['offset'] - $view->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
104 | + $page = \GV\Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $view->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
106 | 105 | |
107 | 106 | /** Set paging, count and unwrap the entries. */ |
108 | 107 | $paging = array( |
@@ -141,16 +140,16 @@ discard block |
||
141 | 140 | * @return null|string The value of a field in an entry. |
142 | 141 | */ |
143 | 142 | function GravityView_API_field_value( $entry, $field_settings, $format ) { |
144 | - if ( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
143 | + if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) { |
|
145 | 144 | gravityview()->log->error( 'No entry or field_settings[id] supplied', array( 'data' => array( func_get_args() ) ) ); |
146 | 145 | return null; |
147 | 146 | } |
148 | 147 | |
149 | - if ( ! empty( $entry['_multi'] ) && ! empty( $field_settings['form_id'] ) && ! empty( $entry['_multi'][ $field_settings['form_id'] ] ) ) { |
|
150 | - $entry = $entry['_multi'][ $field_settings['form_id'] ]; |
|
148 | + if ( ! empty( $entry[ '_multi' ] ) && ! empty( $field_settings[ 'form_id' ] ) && ! empty( $entry[ '_multi' ][ $field_settings[ 'form_id' ] ] ) ) { |
|
149 | + $entry = $entry[ '_multi' ][ $field_settings[ 'form_id' ] ]; |
|
151 | 150 | } |
152 | 151 | |
153 | - if ( empty( $entry['id'] ) || ! $entry = \GV\GF_Entry::by_id( $entry['id'] ) ) { |
|
152 | + if ( empty( $entry[ 'id' ] ) || ! $entry = \GV\GF_Entry::by_id( $entry[ 'id' ] ) ) { |
|
154 | 153 | gravityview()->log->error( 'Invalid \GV\GF_Entry supplied', array( 'data' => $entry ) ); |
155 | 154 | return null; |
156 | 155 | } |
@@ -160,18 +159,18 @@ discard block |
||
160 | 159 | * |
161 | 160 | * Fields with a numeric ID are Gravity Forms ones. |
162 | 161 | */ |
163 | - $source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;; |
|
162 | + $source = is_numeric( $field_settings[ 'id' ] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL; ; |
|
164 | 163 | |
165 | 164 | /** Initialize the future field. */ |
166 | 165 | switch ( $source ): |
167 | 166 | /** The Gravity Forms backend. */ |
168 | 167 | case \GV\Source::BACKEND_GRAVITYFORMS: |
169 | - if ( ! $form = \GV\GF_Form::by_id( $entry['form_id'] ) ) { |
|
168 | + if ( ! $form = \GV\GF_Form::by_id( $entry[ 'form_id' ] ) ) { |
|
170 | 169 | gravityview()->log->error( 'No form Gravity Form found for entry', array( 'data' => $entry ) ); |
171 | 170 | return null; |
172 | 171 | } |
173 | 172 | |
174 | - if ( ! $field = $form::get_field( $form, $field_settings['id'] ) ) { |
|
173 | + if ( ! $field = $form::get_field( $form, $field_settings[ 'id' ] ) ) { |
|
175 | 174 | return null; |
176 | 175 | } |
177 | 176 | |
@@ -179,7 +178,7 @@ discard block |
||
179 | 178 | |
180 | 179 | /** Our internal backend. */ |
181 | 180 | case \GV\Source::BACKEND_INTERNAL: |
182 | - if ( ! $field = \GV\Internal_Source::get_field( $field_settings['id'] ) ) { |
|
181 | + if ( ! $field = \GV\Internal_Source::get_field( $field_settings[ 'id' ] ) ) { |
|
183 | 182 | return null; |
184 | 183 | } |
185 | 184 | |
@@ -213,13 +212,13 @@ discard block |
||
213 | 212 | |
214 | 213 | /** A bail condition. */ |
215 | 214 | $bail = function( $label, $field_settings, $entry, $force_show_label, $form ) { |
216 | - if ( ! empty( $field_settings['show_label'] ) || $force_show_label ) { |
|
215 | + if ( ! empty( $field_settings[ 'show_label' ] ) || $force_show_label ) { |
|
217 | 216 | |
218 | - $label = isset( $field_settings['label'] ) ? $field_settings['label'] : ''; |
|
217 | + $label = isset( $field_settings[ 'label' ] ) ? $field_settings[ 'label' ] : ''; |
|
219 | 218 | |
220 | 219 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
221 | - if ( ! empty( $field_settings['custom_label'] ) ) { |
|
222 | - $label = \GravityView_API::replace_variables( $field_settings['custom_label'], $form, $entry ); |
|
220 | + if ( ! empty( $field_settings[ 'custom_label' ] ) ) { |
|
221 | + $label = \GravityView_API::replace_variables( $field_settings[ 'custom_label' ], $form, $entry ); |
|
223 | 222 | } |
224 | 223 | |
225 | 224 | /** |
@@ -245,19 +244,19 @@ discard block |
||
245 | 244 | |
246 | 245 | $label = ''; |
247 | 246 | |
248 | - if ( ! empty( $entry['_multi'] ) && ! empty( $field_settings['form_id'] ) && ! empty( $entry['_multi'][ $field_settings['form_id'] ] ) ) { |
|
249 | - $entry = $entry['_multi'][ $field_settings['form_id'] ]; |
|
250 | - if ( $_form = \GV\GF_Form::by_id( $field_settings['form_id'] ) ) { |
|
247 | + if ( ! empty( $entry[ '_multi' ] ) && ! empty( $field_settings[ 'form_id' ] ) && ! empty( $entry[ '_multi' ][ $field_settings[ 'form_id' ] ] ) ) { |
|
248 | + $entry = $entry[ '_multi' ][ $field_settings[ 'form_id' ] ]; |
|
249 | + if ( $_form = \GV\GF_Form::by_id( $field_settings[ 'form_id' ] ) ) { |
|
251 | 250 | $form = $_form->form; |
252 | 251 | } |
253 | 252 | } |
254 | 253 | |
255 | - if ( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
254 | + if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) { |
|
256 | 255 | gravityview()->log->error( 'No entry or field_settings[id] supplied', array( 'data' => array( func_get_args() ) ) ); |
257 | 256 | return $bail( $label, $field_settings, $entry, $force_show_label, $form ); |
258 | 257 | } |
259 | 258 | |
260 | - if ( empty( $entry['id'] ) || ! $gv_entry = \GV\GF_Entry::by_id( $entry['id'] ) ) { |
|
259 | + if ( empty( $entry[ 'id' ] ) || ! $gv_entry = \GV\GF_Entry::by_id( $entry[ 'id' ] ) ) { |
|
261 | 260 | gravityview()->log->error( 'Invalid \GV\GF_Entry supplied', array( 'data' => $entry ) ); |
262 | 261 | return $bail( $label, $field_settings, $entry, $force_show_label, $form ); |
263 | 262 | } |
@@ -269,31 +268,31 @@ discard block |
||
269 | 268 | * |
270 | 269 | * Fields with a numeric ID are Gravity Forms ones. |
271 | 270 | */ |
272 | - $source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL; |
|
271 | + $source = is_numeric( $field_settings[ 'id' ] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL; |
|
273 | 272 | |
274 | 273 | /** Initialize the future field. */ |
275 | 274 | switch ( $source ): |
276 | 275 | /** The Gravity Forms backend. */ |
277 | 276 | case \GV\Source::BACKEND_GRAVITYFORMS: |
278 | - if ( ! $gf_form = \GV\GF_Form::by_id( $entry['form_id'] ) ) { |
|
277 | + if ( ! $gf_form = \GV\GF_Form::by_id( $entry[ 'form_id' ] ) ) { |
|
279 | 278 | gravityview()->log->error( 'No form Gravity Form found for entry', array( 'data' => $entry ) ); |
280 | 279 | return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $form ); |
281 | 280 | } |
282 | 281 | |
283 | - if ( ! $field = $gf_form::get_field( $gf_form, $field_settings['id'] ) ) { |
|
284 | - gravityview()->log->error( 'No field found for specified form and field ID #{field_id}', array( 'field_id' => $field_settings['id'], 'data' => $form ) ); |
|
282 | + if ( ! $field = $gf_form::get_field( $gf_form, $field_settings[ 'id' ] ) ) { |
|
283 | + gravityview()->log->error( 'No field found for specified form and field ID #{field_id}', array( 'field_id' => $field_settings[ 'id' ], 'data' => $form ) ); |
|
285 | 284 | return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $gf_form->form ); |
286 | 285 | } |
287 | - if ( empty( $field_settings['show_label'] ) ) { |
|
286 | + if ( empty( $field_settings[ 'show_label' ] ) ) { |
|
288 | 287 | /** The label never wins... */ |
289 | - $field_settings['label'] = ''; |
|
288 | + $field_settings[ 'label' ] = ''; |
|
290 | 289 | } |
291 | 290 | |
292 | 291 | break; |
293 | 292 | |
294 | 293 | /** Our internal backend. */ |
295 | 294 | case \GV\Source::BACKEND_INTERNAL: |
296 | - if ( ! $field = \GV\Internal_Source::get_field( $field_settings['id'] ) ) { |
|
295 | + if ( ! $field = \GV\Internal_Source::get_field( $field_settings[ 'id' ] ) ) { |
|
297 | 296 | return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $form ); |
298 | 297 | } |
299 | 298 | break; |
@@ -305,8 +304,8 @@ discard block |
||
305 | 304 | break; |
306 | 305 | endswitch; |
307 | 306 | |
308 | - if( $force_show_label ) { |
|
309 | - $field_settings['show_label'] = '1'; |
|
307 | + if ( $force_show_label ) { |
|
308 | + $field_settings[ 'show_label' ] = '1'; |
|
310 | 309 | } |
311 | 310 | |
312 | 311 | /** Add the field settings. */ |
@@ -440,7 +439,7 @@ discard block |
||
440 | 439 | '\GravityView_frontend::entry' => \GravityView_frontend::getInstance()->getEntry(), |
441 | 440 | '\GravityView_View::_current_entry' => \GravityView_View::getInstance()->getCurrentEntry(), |
442 | 441 | '\GravityView_View::fields' => \GravityView_View::getInstance()->getFields(), |
443 | - 'wp_actions[loop_start]' => empty( $wp_actions['loop_start'] ) ? 0 : $wp_actions['loop_start'], |
|
442 | + 'wp_actions[loop_start]' => empty( $wp_actions[ 'loop_start' ] ) ? 0 : $wp_actions[ 'loop_start' ], |
|
444 | 443 | 'wp_query::in_the_loop' => $wp_query->in_the_loop, |
445 | 444 | ); |
446 | 445 | } |
@@ -522,7 +521,7 @@ discard block |
||
522 | 521 | break; |
523 | 522 | case 'wp_actions[loop_start]': |
524 | 523 | global $wp_actions; |
525 | - $wp_actions['loop_start'] = $value; |
|
524 | + $wp_actions[ 'loop_start' ] = $value; |
|
526 | 525 | break; |
527 | 526 | case 'wp_query::in_the_loop': |
528 | 527 | global $wp_query; |
@@ -600,9 +599,7 @@ discard block |
||
600 | 599 | case 'request': |
601 | 600 | self::thaw( array( |
602 | 601 | '\GravityView_View::context' => ( |
603 | - $value->is_entry() ? 'single' : |
|
604 | - ( $value->is_edit_entry() ? 'edit' : |
|
605 | - ( $value->is_view() ? 'directory': null ) |
|
602 | + $value->is_entry() ? 'single' : ( $value->is_edit_entry() ? 'edit' : ( $value->is_view() ? 'directory' : null ) |
|
606 | 603 | ) |
607 | 604 | ), |
608 | 605 | '\GravityView_frontend::is_search' => $value->is_search(), |
@@ -656,14 +653,14 @@ discard block |
||
656 | 653 | global $wp_query, $wp_actions; |
657 | 654 | |
658 | 655 | $wp_query->in_the_loop = false; |
659 | - $wp_actions['loop_start'] = 0; |
|
656 | + $wp_actions[ 'loop_start' ] = 0; |
|
660 | 657 | } |
661 | 658 | } |
662 | 659 | |
663 | 660 | |
664 | 661 | /** Add some global fix for field capability discrepancies. */ |
665 | 662 | add_filter( 'gravityview/configuration/fields', function( $fields ) { |
666 | - if ( empty( $fields ) ) { |
|
663 | + if ( empty( $fields ) ) { |
|
667 | 664 | return $fields; |
668 | 665 | } |
669 | 666 | |
@@ -690,11 +687,11 @@ discard block |
||
690 | 687 | } |
691 | 688 | |
692 | 689 | foreach ( $_fields as $uid => &$_field ) { |
693 | - if ( ! isset( $_field['only_loggedin'] ) ) { |
|
690 | + if ( ! isset( $_field[ 'only_loggedin' ] ) ) { |
|
694 | 691 | continue; |
695 | 692 | } |
696 | 693 | /** If we do not require login, we don't require a cap. */ |
697 | - $_field['only_loggedin'] != '1' && ( $_field['only_loggedin_cap'] = '' ); |
|
694 | + $_field[ 'only_loggedin' ] != '1' && ( $_field[ 'only_loggedin_cap' ] = '' ); |
|
698 | 695 | } |
699 | 696 | } |
700 | 697 | return $fields; |
@@ -725,8 +722,8 @@ discard block |
||
725 | 722 | } |
726 | 723 | |
727 | 724 | foreach ( $_fields as $uid => &$_field ) { |
728 | - if ( ! empty( $_field['id'] ) && is_numeric( $_field['id'] ) && empty( $_field['form_id'] ) ) { |
|
729 | - $_field['form_id'] = $view->form->ID; |
|
725 | + if ( ! empty( $_field[ 'id' ] ) && is_numeric( $_field[ 'id' ] ) && empty( $_field[ 'form_id' ] ) ) { |
|
726 | + $_field[ 'form_id' ] = $view->form->ID; |
|
730 | 727 | } |
731 | 728 | } |
732 | 729 | } |
@@ -740,25 +737,25 @@ discard block |
||
740 | 737 | if ( class_exists( '\GravityView_frontend' ) ) { |
741 | 738 | global $wp_filter; |
742 | 739 | |
743 | - if ( empty( $wp_filter['gravityview_after'] ) ) { |
|
740 | + if ( empty( $wp_filter[ 'gravityview_after' ] ) ) { |
|
744 | 741 | return; |
745 | 742 | } |
746 | 743 | |
747 | 744 | /** WordPress 4.6 and lower compatibility, when WP_Hook classes were still absent. */ |
748 | - if ( is_array( $wp_filter['gravityview_after'] ) ) { |
|
749 | - if ( ! empty( $wp_filter['gravityview_after'][10] ) ) { |
|
750 | - foreach ( $wp_filter['gravityview_after'][10] as $function_key => $callback ) { |
|
745 | + if ( is_array( $wp_filter[ 'gravityview_after' ] ) ) { |
|
746 | + if ( ! empty( $wp_filter[ 'gravityview_after' ][ 10 ] ) ) { |
|
747 | + foreach ( $wp_filter[ 'gravityview_after' ][ 10 ] as $function_key => $callback ) { |
|
751 | 748 | if ( strpos( $function_key, 'context_not_configured_warning' ) ) { |
752 | - unset( $wp_filter['gravityview_after'][10][ $function_key ] ); |
|
749 | + unset( $wp_filter[ 'gravityview_after' ][ 10 ][ $function_key ] ); |
|
753 | 750 | } |
754 | 751 | } |
755 | 752 | } |
756 | 753 | return; |
757 | 754 | } |
758 | 755 | |
759 | - foreach ( $wp_filter['gravityview_after']->callbacks[10] as $function_key => $callback ) { |
|
756 | + foreach ( $wp_filter[ 'gravityview_after' ]->callbacks[ 10 ] as $function_key => $callback ) { |
|
760 | 757 | if ( strpos( $function_key, 'context_not_configured_warning' ) ) { |
761 | - unset( $wp_filter['gravityview_after']->callbacks[10][ $function_key ] ); |
|
758 | + unset( $wp_filter[ 'gravityview_after' ]->callbacks[ 10 ][ $function_key ] ); |
|
762 | 759 | } |
763 | 760 | } |
764 | 761 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @var array |
87 | 87 | */ |
88 | - private $template_data_var_names = array('data'); |
|
88 | + private $template_data_var_names = array( 'data' ); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Clean up template data. |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | public function set_template_data( $data, $var_name = 'data' ) { |
139 | 139 | global $wp_query; |
140 | 140 | |
141 | - $wp_query->query_vars[ $var_name ] = (object) $data; |
|
141 | + $wp_query->query_vars[ $var_name ] = (object)$data; |
|
142 | 142 | |
143 | 143 | // Add $var_name to custom variable store if not default value |
144 | - if( $var_name !== 'data' ) { |
|
145 | - $this->template_data_var_names[] = $var_name; |
|
144 | + if ( $var_name !== 'data' ) { |
|
145 | + $this->template_data_var_names[ ] = $var_name; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | return $this; |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | |
166 | 166 | // Remove each custom data reference from $wp_query |
167 | 167 | foreach ( $custom_var_names as $var ) { |
168 | - if ( isset( $wp_query->query_vars[$var] ) ) { |
|
169 | - unset( $wp_query->query_vars[$var] ); |
|
168 | + if ( isset( $wp_query->query_vars[ $var ] ) ) { |
|
169 | + unset( $wp_query->query_vars[ $var ] ); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | protected function get_template_file_names( $slug, $name ) { |
187 | 187 | $templates = array(); |
188 | 188 | if ( isset( $name ) ) { |
189 | - $templates[] = $slug . '-' . $name . '.php'; |
|
189 | + $templates[ ] = $slug . '-' . $name . '.php'; |
|
190 | 190 | } |
191 | - $templates[] = $slug . '.php'; |
|
191 | + $templates[ ] = $slug . '.php'; |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Allow template choices to be filtered. |
@@ -224,18 +224,18 @@ discard block |
||
224 | 224 | public function locate_template( $template_names, $load = false, $require_once = true ) { |
225 | 225 | |
226 | 226 | // Use $template_names as a cache key - either first element of array or the variable itself if it's a string |
227 | - $cache_key = is_array( $template_names ) ? $template_names[0] : $template_names; |
|
227 | + $cache_key = is_array( $template_names ) ? $template_names[ 0 ] : $template_names; |
|
228 | 228 | |
229 | 229 | // If the key is in the cache array, we've already located this file. |
230 | - if ( isset( $this->template_path_cache[$cache_key] ) ) { |
|
231 | - $located = $this->template_path_cache[$cache_key]; |
|
230 | + if ( isset( $this->template_path_cache[ $cache_key ] ) ) { |
|
231 | + $located = $this->template_path_cache[ $cache_key ]; |
|
232 | 232 | } else { |
233 | 233 | |
234 | 234 | // No file found yet. |
235 | 235 | $located = false; |
236 | 236 | |
237 | 237 | // Remove empty entries. |
238 | - $template_names = array_filter( (array) $template_names ); |
|
238 | + $template_names = array_filter( (array)$template_names ); |
|
239 | 239 | $template_paths = $this->get_template_paths(); |
240 | 240 | |
241 | 241 | // Try to find a template file. |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | if ( file_exists( $template_path . $template_name ) ) { |
249 | 249 | $located = $template_path . $template_name; |
250 | 250 | // Store the template path in the cache |
251 | - $this->template_path_cache[$cache_key] = $located; |
|
251 | + $this->template_path_cache[ $cache_key ] = $located; |
|
252 | 252 | break 2; |
253 | 253 | } |
254 | 254 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | // Only add this conditionally, so non-child themes don't redundantly check active theme twice. |
285 | 285 | if ( get_stylesheet_directory() !== get_template_directory() ) { |
286 | - $file_paths[1] = trailingslashit( get_stylesheet_directory() ) . $theme_directory; |
|
286 | + $file_paths[ 1 ] = trailingslashit( get_stylesheet_directory() ) . $theme_directory; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | $this->request = $request; |
87 | 87 | |
88 | 88 | /** Add granular overrides. */ |
89 | - add_filter( $this->filter_prefix . '_get_template_part', $this->_add_id_specific_templates_callback = self::add_id_specific_templates( $this ), 10, 3 ); |
|
89 | + add_filter( $this->filter_prefix . '_get_template_part', $this->_add_id_specific_templates_callback = self::add_id_specific_templates( $this ), 10, 3 ); |
|
90 | 90 | |
91 | 91 | parent::__construct(); |
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,59 +175,59 @@ 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 | - $specifics []= sprintf( '%sfield-%s.php', $slug_dir, $slug_name ); |
|
230 | - $specifics []= sprintf( '%sfield.php', $slug_dir ); |
|
229 | + $specifics [ ] = sprintf( '%sfield-%s.php', $slug_dir, $slug_name ); |
|
230 | + $specifics [ ] = sprintf( '%sfield.php', $slug_dir ); |
|
231 | 231 | |
232 | 232 | |
233 | 233 | return array_merge( $specifics, $templates ); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | /** Prevent any PHP warnings that may be generated. */ |
255 | 255 | ob_start(); |
256 | 256 | |
257 | - $display_value = \GFCommon::get_lead_field_display( $this->field->field, $value, $this->entry['currency'], false, 'html' ); |
|
257 | + $display_value = \GFCommon::get_lead_field_display( $this->field->field, $value, $this->entry[ 'currency' ], false, 'html' ); |
|
258 | 258 | |
259 | 259 | if ( $errors = ob_get_clean() ) { |
260 | 260 | gravityview()->log->error( 'Errors when calling GFCommon::get_lead_field_display()', array( 'data' => $errors ) ); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $supports = array( 'title', 'revisions' ); |
109 | 109 | |
110 | 110 | if ( $is_hierarchical ) { |
111 | - $supports[] = 'page-attributes'; |
|
111 | + $supports[ ] = 'page-attributes'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * Editing a single entry. |
283 | 283 | */ |
284 | 284 | if ( $entry = $request->is_edit_entry() ) { |
285 | - if ( $entry['status'] != 'active' ) { |
|
285 | + if ( $entry[ 'status' ] != 'active' ) { |
|
286 | 286 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
287 | 287 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
288 | 288 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | if ( $view->settings->get( 'show_only_approved' ) ) { |
296 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
296 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
297 | 297 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
298 | 298 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
299 | 299 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * Viewing a single entry. |
307 | 307 | */ |
308 | 308 | } else if ( $entry = $request->is_entry() ) { |
309 | - if ( $entry['status'] != 'active' ) { |
|
309 | + if ( $entry[ 'status' ] != 'active' ) { |
|
310 | 310 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
311 | 311 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
312 | 312 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | if ( $view->settings->get( 'show_only_approved' ) ) { |
320 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
320 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
321 | 321 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
322 | 322 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
323 | 323 | } |
@@ -365,11 +365,11 @@ discard block |
||
365 | 365 | if ( ! $view->form ) { |
366 | 366 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
367 | 367 | 'view_id' => $view->ID, |
368 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
368 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
369 | 369 | ) ); |
370 | 370 | } else if ( gravityview()->plugin->supports( Plugin::FEATURE_JOINS ) ) { |
371 | 371 | /** And the connected joins. */ |
372 | - foreach( (array)get_post_meta( $view->ID, '_gravityview_form_joins', true ) as $_join ) { |
|
372 | + foreach ( (array)get_post_meta( $view->ID, '_gravityview_form_joins', true ) as $_join ) { |
|
373 | 373 | if ( ! is_array( $_join ) || count( $_join ) != 4 ) { |
374 | 374 | continue; |
375 | 375 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column ); |
382 | 382 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column ); |
383 | 383 | |
384 | - $view->joins []= new Join( $join, $join_column, $join_on, $join_on_column ); |
|
384 | + $view->joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
@@ -605,28 +605,27 @@ discard block |
||
605 | 605 | * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
606 | 606 | */ |
607 | 607 | $parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID ); |
608 | - $parameters['context_view_id'] = $this->ID; |
|
608 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
609 | 609 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
610 | 610 | |
611 | 611 | if ( $request instanceof REST\Request ) { |
612 | 612 | $atts = $this->settings->as_atts(); |
613 | 613 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
614 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
614 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
615 | 615 | ) ); |
616 | - $parameters['paging'] = $paging_parameters['paging']; |
|
616 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
617 | 617 | } |
618 | 618 | |
619 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
620 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
619 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
621 | 620 | |
622 | 621 | if ( gravityview()->plugin->supports( Plugin::FEATURE_GFQUERY ) ) { |
623 | 622 | /** |
624 | 623 | * New \GF_Query stuff :) |
625 | 624 | */ |
626 | - $query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
625 | + $query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
627 | 626 | |
628 | - $query->limit( $parameters['paging']['page_size'] ) |
|
629 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
627 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
628 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
630 | 629 | |
631 | 630 | /** |
632 | 631 | * Any joins? |
@@ -666,15 +665,15 @@ discard block |
||
666 | 665 | } ); |
667 | 666 | } else { |
668 | 667 | $entries = $this->form->entries |
669 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
668 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
670 | 669 | ->offset( $this->settings->get( 'offset' ) ) |
671 | - ->limit( $parameters['paging']['page_size'] ) |
|
670 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
672 | 671 | ->page( $page ); |
673 | 672 | |
674 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
673 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
675 | 674 | $field = new \GV\Field(); |
676 | - $field->ID = $parameters['sorting']['key']; |
|
677 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
675 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
676 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
678 | 677 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
679 | 678 | } |
680 | 679 | } |
@@ -115,8 +115,8 @@ |
||
115 | 115 | 'entries' => $entries, |
116 | 116 | 'request' => $request, |
117 | 117 | ), empty( $parameters ) ? array() : array( |
118 | - 'paging' => $parameters['paging'], |
|
119 | - 'sorting' => $parameters['sorting'], |
|
118 | + 'paging' => $parameters[ 'paging' ], |
|
119 | + 'sorting' => $parameters[ 'sorting' ], |
|
120 | 120 | ), empty( $post ) ? array() : array( |
121 | 121 | 'post' => $post, |
122 | 122 | ) ) ); |
@@ -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; |
@@ -192,12 +192,12 @@ discard block |
||
192 | 192 | |
193 | 193 | $has_transaction_data = \GV\Utils::get( $entry, $meta, false ); |
194 | 194 | |
195 | - if( ! empty( $has_transaction_data ) ) { |
|
195 | + if ( ! empty( $has_transaction_data ) ) { |
|
196 | 196 | break; |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - return (bool) $has_transaction_data; |
|
200 | + return (bool)$has_transaction_data; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
237 | 237 | |
238 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
238 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
239 | 239 | |
240 | 240 | return $result; |
241 | 241 | } |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
254 | 254 | */ |
255 | - public static function get_forms( $active = true, $trash = false ) { |
|
255 | + public static function get_forms( $active = true, $trash = false ) { |
|
256 | 256 | $forms = array(); |
257 | 257 | if ( class_exists( 'GFAPI' ) ) { |
258 | - if( 'any' === $active ) { |
|
258 | + if ( 'any' === $active ) { |
|
259 | 259 | $active_forms = GFAPI::get_forms( true, $trash ); |
260 | 260 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
261 | 261 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | $has_post_fields = false; |
287 | 287 | |
288 | 288 | if ( $form ) { |
289 | - foreach ( $form['fields'] as $field ) { |
|
290 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
291 | - $fields["{$field['id']}"] = array( |
|
289 | + foreach ( $form[ 'fields' ] as $field ) { |
|
290 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
291 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
292 | 292 | 'label' => \GV\Utils::get( $field, 'label' ), |
293 | 293 | 'parent' => null, |
294 | 294 | 'type' => \GV\Utils::get( $field, 'type' ), |
@@ -297,10 +297,10 @@ discard block |
||
297 | 297 | ); |
298 | 298 | } |
299 | 299 | |
300 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
301 | - foreach ( $field['inputs'] as $input ) { |
|
300 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
301 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
302 | 302 | |
303 | - if( ! empty( $input['isHidden'] ) ) { |
|
303 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
304 | 304 | continue; |
305 | 305 | } |
306 | 306 | |
@@ -308,10 +308,10 @@ discard block |
||
308 | 308 | * @hack |
309 | 309 | * In case of email/email confirmation, the input for email has the same id as the parent field |
310 | 310 | */ |
311 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
311 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
312 | 312 | continue; |
313 | 313 | } |
314 | - $fields["{$input['id']}"] = array( |
|
314 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
315 | 315 | 'label' => \GV\Utils::get( $input, 'label' ), |
316 | 316 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
317 | 317 | 'parent' => $field, |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | } |
324 | 324 | |
325 | 325 | |
326 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
326 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
327 | 327 | $has_product_fields = true; |
328 | 328 | } |
329 | 329 | |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @since 1.7 |
338 | 338 | */ |
339 | 339 | if ( $has_post_fields ) { |
340 | - $fields['post_id'] = array( |
|
340 | + $fields[ 'post_id' ] = array( |
|
341 | 341 | 'label' => __( 'Post ID', 'gravityview' ), |
342 | 342 | 'type' => 'post_id', |
343 | 343 | ); |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | foreach ( $payment_fields as $payment_field ) { |
351 | 351 | |
352 | 352 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
353 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
353 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
354 | 354 | continue; |
355 | 355 | } |
356 | 356 | |
357 | - $fields["{$payment_field->name}"] = array( |
|
357 | + $fields[ "{$payment_field->name}" ] = array( |
|
358 | 358 | 'label' => $payment_field->label, |
359 | 359 | 'desc' => $payment_field->description, |
360 | 360 | 'type' => $payment_field->name, |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | |
387 | 387 | $fields = array(); |
388 | 388 | |
389 | - foreach ( $extra_fields as $key => $field ){ |
|
390 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
391 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
389 | + foreach ( $extra_fields as $key => $field ) { |
|
390 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
391 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
392 | 392 | } |
393 | 393 | } |
394 | 394 | |
@@ -428,33 +428,33 @@ discard block |
||
428 | 428 | 'search_criteria' => null, |
429 | 429 | 'sorting' => null, |
430 | 430 | 'paging' => null, |
431 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
431 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
432 | 432 | 'context_view_id' => null, |
433 | 433 | ); |
434 | 434 | |
435 | 435 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
436 | 436 | |
437 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
438 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
437 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
438 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
439 | 439 | |
440 | 440 | if ( ! is_array( $filter ) ) { |
441 | 441 | continue; |
442 | 442 | } |
443 | 443 | |
444 | 444 | // By default, we want searches to be wildcard for each field. |
445 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
445 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
446 | 446 | |
447 | 447 | /** |
448 | 448 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
449 | 449 | * @param string $operator Existing search operator |
450 | 450 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
451 | 451 | */ |
452 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
452 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | // don't send just the [mode] without any field filter. |
456 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
457 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
456 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
457 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | } |
@@ -465,33 +465,33 @@ discard block |
||
465 | 465 | * Prepare date formats to be in Gravity Forms DB format; |
466 | 466 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
467 | 467 | */ |
468 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
468 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
469 | 469 | |
470 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
470 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
471 | 471 | |
472 | 472 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
473 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
473 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
474 | 474 | |
475 | 475 | if ( $date ) { |
476 | 476 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
477 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
477 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
478 | 478 | } else { |
479 | - gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria['search_criteria'][ $key ] ) ); |
|
479 | + gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria[ 'search_criteria' ][ $key ] ) ); |
|
480 | 480 | |
481 | 481 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
482 | - unset( $criteria['search_criteria'][ $key ] ); |
|
482 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
487 | - if ( empty( $criteria['context_view_id'] ) ) { |
|
487 | + if ( empty( $criteria[ 'context_view_id' ] ) ) { |
|
488 | 488 | // Calculate the context view id and send it to the advanced filter |
489 | 489 | if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
490 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
490 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
491 | 491 | } else if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
492 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
492 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
493 | 493 | } else if ( 'delete' === GFForms::get( 'action' ) ) { |
494 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
494 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
495 | 495 | } |
496 | 496 | } |
497 | 497 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @param array $form_ids Forms to search |
502 | 502 | * @param int $view_id ID of the view being used to search |
503 | 503 | */ |
504 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
504 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
505 | 505 | |
506 | 506 | return (array)$criteria; |
507 | 507 | } |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | /** Reduce # of database calls */ |
532 | 532 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
533 | 533 | |
534 | - if ( ! empty( $criteria['cache'] ) ) { |
|
534 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
535 | 535 | |
536 | 536 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
537 | 537 | |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | |
540 | 540 | // Still update the total count when using cached results |
541 | 541 | if ( ! is_null( $total ) ) { |
542 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
542 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | $return = $entries; |
@@ -560,9 +560,9 @@ discard block |
||
560 | 560 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
561 | 561 | |
562 | 562 | // No entries returned from gravityview_before_get_entries |
563 | - if( is_null( $entries ) ) { |
|
563 | + if ( is_null( $entries ) ) { |
|
564 | 564 | |
565 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
565 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
566 | 566 | |
567 | 567 | if ( is_wp_error( $entries ) ) { |
568 | 568 | gravityview()->log->error( '{error}', array( 'error' => $entries->get_error_message(), 'data' => $entries ) ); |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | } |
574 | 574 | } |
575 | 575 | |
576 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
576 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
577 | 577 | |
578 | 578 | // Cache results |
579 | 579 | $Cache->set( $entries, 'entries' ); |
@@ -678,12 +678,12 @@ discard block |
||
678 | 678 | */ |
679 | 679 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
680 | 680 | |
681 | - if( $check_entry_display ) { |
|
681 | + if ( $check_entry_display ) { |
|
682 | 682 | // Is the entry allowed |
683 | 683 | $entry = self::check_entry_display( $entry ); |
684 | 684 | } |
685 | 685 | |
686 | - if( is_wp_error( $entry ) ) { |
|
686 | + if ( is_wp_error( $entry ) ) { |
|
687 | 687 | gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) ); |
688 | 688 | return false; |
689 | 689 | } |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | */ |
715 | 715 | public static function matches_operation( $val1, $val2, $operation ) { |
716 | 716 | |
717 | - $json_function = function_exists('wp_json_encode') ? 'wp_json_encode' : 'json_encode'; |
|
717 | + $json_function = function_exists( 'wp_json_encode' ) ? 'wp_json_encode' : 'json_encode'; |
|
718 | 718 | |
719 | 719 | // Only process strings |
720 | 720 | $val1 = ! is_string( $val1 ) ? $json_function( $val1 ) : $val1; |
@@ -722,12 +722,12 @@ discard block |
||
722 | 722 | |
723 | 723 | $value = false; |
724 | 724 | |
725 | - if( 'context' === $val1 ) { |
|
725 | + if ( 'context' === $val1 ) { |
|
726 | 726 | |
727 | 727 | $matching_contexts = array( $val2 ); |
728 | 728 | |
729 | 729 | // We allow for non-standard contexts. |
730 | - switch( $val2 ) { |
|
730 | + switch ( $val2 ) { |
|
731 | 731 | // Check for either single or edit |
732 | 732 | case 'singular': |
733 | 733 | $matching_contexts = array( 'single', 'edit' ); |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | $json_val_1 = json_decode( $val1, true ); |
771 | 771 | $json_val_2 = json_decode( $val2, true ); |
772 | 772 | |
773 | - if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
773 | + if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
774 | 774 | |
775 | 775 | $json_in = false; |
776 | 776 | $json_val_1 = $json_val_1 ? $json_val_1 : array( $val1 ); |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | foreach ( $json_val_2 as $item_2 ) { |
782 | 782 | $json_in = self::matches_operation( $item_1, $item_2, 'is' ); |
783 | 783 | |
784 | - if( $json_in ) { |
|
784 | + if ( $json_in ) { |
|
785 | 785 | break 2; |
786 | 786 | } |
787 | 787 | } |
@@ -829,62 +829,62 @@ discard block |
||
829 | 829 | public static function check_entry_display( $entry ) { |
830 | 830 | |
831 | 831 | if ( ! $entry || is_wp_error( $entry ) ) { |
832 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
832 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
833 | 833 | } |
834 | 834 | |
835 | - if ( empty( $entry['form_id'] ) ) { |
|
835 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
836 | 836 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
837 | 837 | } |
838 | 838 | |
839 | 839 | $criteria = self::calculate_get_entries_criteria(); |
840 | 840 | |
841 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
841 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
842 | 842 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No search criteria found:', array( 'data' => $criteria ) ); |
843 | 843 | return $entry; |
844 | 844 | } |
845 | 845 | |
846 | 846 | // Make sure the current View is connected to the same form as the Entry |
847 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
848 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
847 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
848 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
849 | 849 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
850 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
851 | - 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'] ); |
|
850 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
851 | + 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' ] ); |
|
852 | 852 | } |
853 | 853 | } |
854 | 854 | |
855 | - $search_criteria = $criteria['search_criteria']; |
|
855 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
856 | 856 | |
857 | 857 | // check entry status |
858 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
859 | - 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 ); |
|
858 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
859 | + 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 ); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | // check entry date |
863 | 863 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
864 | 864 | |
865 | 865 | // field_filters |
866 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
866 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
867 | 867 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No field filters criteria found:', array( 'data' => $search_criteria ) ); |
868 | 868 | return $entry; |
869 | 869 | } |
870 | 870 | |
871 | - $filters = $search_criteria['field_filters']; |
|
871 | + $filters = $search_criteria[ 'field_filters' ]; |
|
872 | 872 | |
873 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
873 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
874 | 874 | |
875 | 875 | // Prevent the mode from being processed below |
876 | - unset( $filters['mode'] ); |
|
876 | + unset( $filters[ 'mode' ] ); |
|
877 | 877 | |
878 | - $form = self::get_form( $entry['form_id'] ); |
|
878 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
879 | 879 | |
880 | 880 | foreach ( $filters as $filter ) { |
881 | 881 | |
882 | - if ( ! isset( $filter['key'] ) ) { |
|
882 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
883 | 883 | gravityview()->log->debug( '[apply_filters_to_entry] Filter key not set: {filter}', array( 'filter' => $filter ) ); |
884 | 884 | continue; |
885 | 885 | } |
886 | 886 | |
887 | - $k = $filter['key']; |
|
887 | + $k = $filter[ 'key' ]; |
|
888 | 888 | |
889 | 889 | $field = self::get_field( $form, $k ); |
890 | 890 | |
@@ -892,14 +892,14 @@ discard block |
||
892 | 892 | $field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null; |
893 | 893 | $field = $k; |
894 | 894 | } else { |
895 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
895 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
896 | 896 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
897 | 897 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? \GV\Utils::get( $field_value, $k ) : $field_value; |
898 | 898 | } |
899 | 899 | |
900 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
900 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
901 | 901 | |
902 | - $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
902 | + $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
903 | 903 | |
904 | 904 | // Any match is all we need to know |
905 | 905 | if ( $is_value_match && 'any' === $mode ) { |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | |
909 | 909 | // Any failed match is a total fail |
910 | 910 | if ( ! $is_value_match && 'all' === $mode ) { |
911 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
911 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
912 | 912 | } |
913 | 913 | } |
914 | 914 | |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved: all conditions were met' ); |
919 | 919 | return $entry; |
920 | 920 | } else { |
921 | - return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
921 | + return new WP_Error( 'failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | } |
@@ -959,18 +959,18 @@ discard block |
||
959 | 959 | * Gravity Forms code to adjust date to locally-configured Time Zone |
960 | 960 | * @see GFCommon::format_date() for original code |
961 | 961 | */ |
962 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
962 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
963 | 963 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
964 | 964 | |
965 | - $format = \GV\Utils::get( $atts, 'format' ); |
|
966 | - $is_human = ! empty( $atts['human'] ); |
|
967 | - $is_diff = ! empty( $atts['diff'] ); |
|
968 | - $is_raw = ! empty( $atts['raw'] ); |
|
969 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
970 | - $include_time = ! empty( $atts['time'] ); |
|
965 | + $format = \GV\Utils::get( $atts, 'format' ); |
|
966 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
967 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
968 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
969 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
970 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
971 | 971 | |
972 | 972 | // If we're using time diff, we want to have a different default format |
973 | - if( empty( $format ) ) { |
|
973 | + if ( empty( $format ) ) { |
|
974 | 974 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
975 | 975 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
976 | 976 | } |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | // If raw was specified, don't modify the stored value |
979 | 979 | if ( $is_raw ) { |
980 | 980 | $formatted_date = $date_string; |
981 | - } elseif( $is_timestamp ) { |
|
981 | + } elseif ( $is_timestamp ) { |
|
982 | 982 | $formatted_date = $date_local_timestamp; |
983 | 983 | } elseif ( $is_diff ) { |
984 | 984 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | |
1013 | 1013 | $label = \GV\Utils::get( $field, 'label' ); |
1014 | 1014 | |
1015 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1015 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1016 | 1016 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
1017 | 1017 | } |
1018 | 1018 | |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | $form = GFAPI::get_form( $form ); |
1041 | 1041 | } |
1042 | 1042 | |
1043 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
1043 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
1044 | 1044 | return GFFormsModel::get_field( $form, $field_id ); |
1045 | 1045 | } else { |
1046 | 1046 | return null; |
@@ -1087,19 +1087,19 @@ discard block |
||
1087 | 1087 | $shortcodes = array(); |
1088 | 1088 | |
1089 | 1089 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
1090 | - if ( empty( $matches ) ){ |
|
1090 | + if ( empty( $matches ) ) { |
|
1091 | 1091 | return false; |
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | foreach ( $matches as $shortcode ) { |
1095 | - if ( $tag === $shortcode[2] ) { |
|
1095 | + if ( $tag === $shortcode[ 2 ] ) { |
|
1096 | 1096 | |
1097 | 1097 | // Changed this to $shortcode instead of true so we get the parsed atts. |
1098 | - $shortcodes[] = $shortcode; |
|
1098 | + $shortcodes[ ] = $shortcode; |
|
1099 | 1099 | |
1100 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
1101 | - foreach( $results as $result ) { |
|
1102 | - $shortcodes[] = $result; |
|
1100 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
1101 | + foreach ( $results as $result ) { |
|
1102 | + $shortcodes[ ] = $result; |
|
1103 | 1103 | } |
1104 | 1104 | } |
1105 | 1105 | } |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | |
1287 | 1287 | $directory_widgets = wp_parse_args( $view_widgets, $defaults ); |
1288 | 1288 | |
1289 | - if( $json_decode ) { |
|
1289 | + if ( $json_decode ) { |
|
1290 | 1290 | $directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' ); |
1291 | 1291 | } |
1292 | 1292 | |
@@ -1302,7 +1302,7 @@ discard block |
||
1302 | 1302 | * @return string html |
1303 | 1303 | */ |
1304 | 1304 | public static function get_sortable_fields( $formid, $current = '' ) { |
1305 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1305 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1306 | 1306 | |
1307 | 1307 | if ( empty( $formid ) ) { |
1308 | 1308 | return $output; |
@@ -1315,11 +1315,11 @@ discard block |
||
1315 | 1315 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1316 | 1316 | |
1317 | 1317 | foreach ( $fields as $id => $field ) { |
1318 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1318 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1319 | 1319 | continue; |
1320 | 1320 | } |
1321 | 1321 | |
1322 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1322 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1323 | 1323 | } |
1324 | 1324 | } |
1325 | 1325 | |
@@ -1354,9 +1354,9 @@ discard block |
||
1354 | 1354 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1355 | 1355 | |
1356 | 1356 | // TODO: Convert to using array_filter |
1357 | - foreach( $fields as $id => $field ) { |
|
1357 | + foreach ( $fields as $id => $field ) { |
|
1358 | 1358 | |
1359 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1359 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1360 | 1360 | unset( $fields[ $id ] ); |
1361 | 1361 | } |
1362 | 1362 | } |
@@ -1397,14 +1397,14 @@ discard block |
||
1397 | 1397 | * @param int|array $field field key or field array |
1398 | 1398 | * @return boolean |
1399 | 1399 | */ |
1400 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1400 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1401 | 1401 | |
1402 | 1402 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1403 | 1403 | $form = self::get_form( $form ); |
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | // If entry meta, it's a string. Otherwise, numeric |
1407 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1407 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1408 | 1408 | $type = $field; |
1409 | 1409 | } else { |
1410 | 1410 | $type = self::get_field_type( $form, $field ); |
@@ -1418,9 +1418,9 @@ discard block |
||
1418 | 1418 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1419 | 1419 | |
1420 | 1420 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1421 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1422 | - if( true === $gv_field->is_numeric ) { |
|
1423 | - $numeric_types[] = $gv_field->is_numeric; |
|
1421 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1422 | + if ( true === $gv_field->is_numeric ) { |
|
1423 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1424 | 1424 | } |
1425 | 1425 | } |
1426 | 1426 | |
@@ -1570,18 +1570,18 @@ discard block |
||
1570 | 1570 | $final_atts = array_filter( $final_atts ); |
1571 | 1571 | |
1572 | 1572 | // If the href wasn't passed as an attribute, use the value passed to the function |
1573 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1574 | - $final_atts['href'] = $href; |
|
1573 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1574 | + $final_atts[ 'href' ] = $href; |
|
1575 | 1575 | } |
1576 | 1576 | |
1577 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1577 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1578 | 1578 | |
1579 | 1579 | /** |
1580 | 1580 | * Fix potential security issue with target=_blank |
1581 | 1581 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
1582 | 1582 | */ |
1583 | - if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1584 | - $final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1583 | + if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1584 | + $final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1585 | 1585 | } |
1586 | 1586 | |
1587 | 1587 | // Sort the attributes alphabetically, to help testing |
@@ -1593,7 +1593,7 @@ discard block |
||
1593 | 1593 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1594 | 1594 | } |
1595 | 1595 | |
1596 | - if( '' !== $output ) { |
|
1596 | + if ( '' !== $output ) { |
|
1597 | 1597 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1598 | 1598 | } |
1599 | 1599 | |
@@ -1620,7 +1620,7 @@ discard block |
||
1620 | 1620 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1621 | 1621 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1622 | 1622 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
1623 | - $merged[] = $value; |
|
1623 | + $merged[ ] = $value; |
|
1624 | 1624 | } else { |
1625 | 1625 | $merged[ $key ] = $value; |
1626 | 1626 | } |
@@ -1653,7 +1653,7 @@ discard block |
||
1653 | 1653 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1654 | 1654 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1655 | 1655 | */ |
1656 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1656 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1657 | 1657 | |
1658 | 1658 | return get_users( $get_users_settings ); |
1659 | 1659 | } |
@@ -1673,11 +1673,11 @@ discard block |
||
1673 | 1673 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
1674 | 1674 | |
1675 | 1675 | // If $cap is defined, only show notice if user has capability |
1676 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1676 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1677 | 1677 | return ''; |
1678 | 1678 | } |
1679 | 1679 | |
1680 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1680 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1681 | 1681 | } |
1682 | 1682 | |
1683 | 1683 | /** |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | $atts = shortcode_atts( self::$defaults, $atts ); |
77 | 77 | |
78 | - $atts['action'] = 'edit'; |
|
78 | + $atts[ 'action' ] = 'edit'; |
|
79 | 79 | |
80 | 80 | return $this->shortcode( $atts, $content, $context ); |
81 | 81 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $atts = shortcode_atts( self::$defaults, $atts ); |
93 | 93 | |
94 | - $atts['action'] = 'delete'; |
|
94 | + $atts[ 'action' ] = 'delete'; |
|
95 | 95 | |
96 | 96 | return $this->shortcode( $atts, $content, $context ); |
97 | 97 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | $this->settings = shortcode_atts( self::$defaults, $atts, $context ); |
133 | 133 | |
134 | - $this->view_id = empty( $this->settings['view_id'] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings['view_id'] ); |
|
134 | + $this->view_id = empty( $this->settings[ 'view_id' ] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings[ 'view_id' ] ); |
|
135 | 135 | |
136 | 136 | if ( empty( $this->view_id ) ) { |
137 | 137 | gravityview()->log->error( 'A View ID was not defined and we are not inside a View' ); |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | return null; |
140 | 140 | } |
141 | 141 | |
142 | - $this->entry = $this->get_entry( $this->settings['entry_id'] ); |
|
142 | + $this->entry = $this->get_entry( $this->settings[ 'entry_id' ] ); |
|
143 | 143 | |
144 | 144 | gravityview()->log->debug( '{context} atts:', array( 'context' => $context, 'data' => $atts ) ); |
145 | 145 | |
146 | 146 | if ( ! $this->has_cap() ) { |
147 | - gravityview()->log->error( 'User does not have the capability to {action} this entry: {entry_id}', array( 'action' => esc_attr( $this->settings['action'] ), 'entry_id' => $this->entry['id'] ) ); |
|
147 | + gravityview()->log->error( 'User does not have the capability to {action} this entry: {entry_id}', array( 'action' => esc_attr( $this->settings[ 'action' ] ), 'entry_id' => $this->entry[ 'id' ] ) ); |
|
148 | 148 | |
149 | 149 | return null; |
150 | 150 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | // Get just the URL, not the tag |
161 | - if ( 'url' === $this->settings['return'] ) { |
|
161 | + if ( 'url' === $this->settings[ 'return' ] ) { |
|
162 | 162 | return $url; |
163 | 163 | } |
164 | 164 | |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | */ |
180 | 180 | private function get_link_atts() { |
181 | 181 | |
182 | - wp_parse_str( $this->settings['link_atts'], $link_atts ); |
|
182 | + wp_parse_str( $this->settings[ 'link_atts' ], $link_atts ); |
|
183 | 183 | |
184 | - if ( 'delete' === $this->settings['action'] ) { |
|
185 | - $link_atts['onclick'] = isset( $link_atts['onclick'] ) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
184 | + if ( 'delete' === $this->settings[ 'action' ] ) { |
|
185 | + $link_atts[ 'onclick' ] = isset( $link_atts[ 'onclick' ] ) ? $link_atts[ 'onclick' ] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
186 | 186 | } |
187 | 187 | |
188 | - return (array) $link_atts; |
|
188 | + return (array)$link_atts; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | return $content; |
206 | 206 | } |
207 | 207 | |
208 | - switch ( $this->settings['action'] ) { |
|
208 | + switch ( $this->settings[ 'action' ] ) { |
|
209 | 209 | case 'edit': |
210 | 210 | $anchor_text = __( 'Edit Entry', 'gravityview' ); |
211 | 211 | break; |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | private function get_url() { |
234 | 234 | |
235 | 235 | // if post_id is not defined, default to view_id |
236 | - $post_id = empty( $this->settings['post_id'] ) ? null : absint( $this->settings['post_id'] ); |
|
236 | + $post_id = empty( $this->settings[ 'post_id' ] ) ? null : absint( $this->settings[ 'post_id' ] ); |
|
237 | 237 | |
238 | - switch ( $this->settings['action'] ) { |
|
238 | + switch ( $this->settings[ 'action' ] ) { |
|
239 | 239 | case 'edit': |
240 | 240 | $url = GravityView_Edit_Entry::get_edit_link( $this->entry, $this->view_id, $post_id ); |
241 | 241 | break; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | private function has_cap() { |
262 | 262 | |
263 | - switch ( $this->settings['action'] ) { |
|
263 | + switch ( $this->settings[ 'action' ] ) { |
|
264 | 264 | case 'edit': |
265 | 265 | $has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry, $this->view_id ); |
266 | 266 | break; |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | */ |
326 | 326 | private function maybe_add_field_values_query_args( $url ) { |
327 | 327 | |
328 | - if ( $url && ! empty( $this->settings['field_values'] ) ) { |
|
328 | + if ( $url && ! empty( $this->settings[ 'field_values' ] ) ) { |
|
329 | 329 | |
330 | - wp_parse_str( $this->settings['field_values'], $field_values ); |
|
330 | + wp_parse_str( $this->settings[ 'field_values' ], $field_values ); |
|
331 | 331 | |
332 | 332 | $url = add_query_arg( $field_values, $url ); |
333 | 333 | } |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | 'detail' => null, |
38 | 38 | ) ); |
39 | 39 | |
40 | - if ( ! $view_id = $atts['id'] ? : $atts['view_id'] ) { |
|
41 | - if ( $atts['detail'] && $view = $request->is_view() ) { |
|
40 | + if ( ! $view_id = $atts[ 'id' ] ?: $atts[ 'view_id' ] ) { |
|
41 | + if ( $atts[ 'detail' ] && $view = $request->is_view() ) { |
|
42 | 42 | $view_id = $view->ID; |
43 | 43 | } |
44 | 44 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | return get_the_password_form( $view->ID ); |
77 | 77 | } |
78 | 78 | |
79 | - if ( ! $view->form ) { |
|
79 | + if ( ! $view->form ) { |
|
80 | 80 | gravityview()->log->notice( 'View #{id} has no form attached to it.', array( 'id' => $view->ID ) ); |
81 | 81 | |
82 | 82 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | /** |
101 | 101 | * View details. |
102 | 102 | */ |
103 | - if ( $atts['detail'] ) { |
|
103 | + if ( $atts[ 'detail' ] ) { |
|
104 | 104 | return $this->detail( $view, $entries, $atts ); |
105 | 105 | |
106 | 106 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | return ''; |
115 | 115 | } |
116 | 116 | |
117 | - if ( $entry['status'] != 'active' ) { |
|
117 | + if ( $entry[ 'status' ] != 'active' ) { |
|
118 | 118 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
119 | 119 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
120 | 120 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | if ( $view->settings->get( 'show_only_approved' ) ) { |
128 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
128 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
129 | 129 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
130 | 130 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
131 | 131 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | return ''; |
146 | 146 | } |
147 | 147 | |
148 | - if ( $entry['status'] != 'active' ) { |
|
148 | + if ( $entry[ 'status' ] != 'active' ) { |
|
149 | 149 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
150 | 150 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
151 | 151 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | if ( $view->settings->get( 'show_only_approved' ) ) { |
159 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
159 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
160 | 160 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
161 | 161 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
162 | 162 | } |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | |
174 | 174 | // Mock the request with the actual View, not the global one |
175 | 175 | $mock_request = new \GV\Mock_Request(); |
176 | - $mock_request->returns['is_view'] = $view; |
|
177 | - $mock_request->returns['is_entry'] = $request->is_entry(); |
|
178 | - $mock_request->returns['is_edit_entry'] = $request->is_edit_entry(); |
|
179 | - $mock_request->returns['is_search'] = $request->is_search(); |
|
176 | + $mock_request->returns[ 'is_view' ] = $view; |
|
177 | + $mock_request->returns[ 'is_entry' ] = $request->is_entry(); |
|
178 | + $mock_request->returns[ 'is_edit_entry' ] = $request->is_edit_entry(); |
|
179 | + $mock_request->returns[ 'is_search' ] = $request->is_search(); |
|
180 | 180 | |
181 | 181 | $request = $mock_request; |
182 | 182 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | private function detail( $view, $entries, $atts ) { |
199 | 199 | $output = ''; |
200 | 200 | |
201 | - switch ( $key = $atts['detail'] ): |
|
201 | + switch ( $key = $atts[ 'detail' ] ): |
|
202 | 202 | case 'total_entries': |
203 | 203 | $output = number_format_i18n( $entries->total() ); |
204 | 204 | break; |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | |
79 | 79 | $non_gv_modifiers = array_diff( $modifiers, array_keys( $gv_modifiers ) ); |
80 | 80 | |
81 | - $return = $field->get_value_merge_tag( $value, '', array( 'currency' => '' ), array(), implode( '', $non_gv_modifiers ), $raw_value, false, false, 'text', false); |
|
81 | + $return = $field->get_value_merge_tag( $value, '', array( 'currency' => '' ), array(), implode( '', $non_gv_modifiers ), $raw_value, false, false, 'text', false ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | foreach ( $modifiers as $passed_modifier ) { |
85 | 85 | |
86 | - foreach( $gv_modifiers as $gv_modifier => $method ) { |
|
86 | + foreach ( $gv_modifiers as $gv_modifier => $method ) { |
|
87 | 87 | |
88 | 88 | // Uses ^ to only match the first modifier, to enforce same order as passed by GF |
89 | 89 | preg_match( '/^' . $gv_modifier . '/ism', $passed_modifier, $matches ); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | private static function modifier_timestamp( $raw_value, $matches ) { |
134 | 134 | |
135 | - if( empty( $matches[0] ) ) { |
|
135 | + if ( empty( $matches[ 0 ] ) ) { |
|
136 | 136 | return $raw_value; |
137 | 137 | } |
138 | 138 | |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private static function modifier_maxwords( $raw_value, $matches, $field = null ) { |
163 | 163 | |
164 | - if( ! is_string( $raw_value ) || empty( $matches[1] ) || ! function_exists( 'wp_trim_words' ) ) { |
|
164 | + if ( ! is_string( $raw_value ) || empty( $matches[ 1 ] ) || ! function_exists( 'wp_trim_words' ) ) { |
|
165 | 165 | return $raw_value; |
166 | 166 | } |
167 | 167 | |
168 | - $max = intval( $matches[1] ); |
|
168 | + $max = intval( $matches[ 1 ] ); |
|
169 | 169 | |
170 | 170 | $more_placeholder = '[GVMORE]'; |
171 | 171 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | private static function modifier_explode( $raw_value, $matches, $value, $field = null ) { |
235 | 235 | |
236 | 236 | // For JSON-encoded arrays |
237 | - if( $json_array = json_decode( $raw_value, true ) ) { |
|
237 | + if ( $json_array = json_decode( $raw_value, true ) ) { |
|
238 | 238 | return implode( ' ', $json_array ); |
239 | 239 | } |
240 | 240 | |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | */ |
256 | 256 | private static function modifier_strings( $raw_value, $matches, $value = '', $field = null ) { |
257 | 257 | |
258 | - if( empty( $matches[0] ) ) { |
|
258 | + if ( empty( $matches[ 0 ] ) ) { |
|
259 | 259 | return $raw_value; |
260 | 260 | } |
261 | 261 | |
262 | 262 | $return = $raw_value; |
263 | 263 | |
264 | - switch( $matches[0] ) { |
|
264 | + switch ( $matches[ 0 ] ) { |
|
265 | 265 | case 'urlencode': |
266 | 266 | $return = urlencode( $raw_value ); |
267 | 267 | break; |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | * @internal Fixed $form['title'] in Gravity Forms |
344 | 344 | * @see https://github.com/gravityforms/gravityforms/pull/27/files |
345 | 345 | */ |
346 | - $form['title'] = isset( $form['title'] ) ? $form['title'] : ''; |
|
347 | - $form['id'] = isset( $form['id'] ) ? $form['id'] : ''; |
|
348 | - $form['fields'] = isset( $form['fields'] ) ? $form['fields'] : array(); |
|
346 | + $form[ 'title' ] = isset( $form[ 'title' ] ) ? $form[ 'title' ] : ''; |
|
347 | + $form[ 'id' ] = isset( $form[ 'id' ] ) ? $form[ 'id' ] : ''; |
|
348 | + $form[ 'fields' ] = isset( $form[ 'fields' ] ) ? $form[ 'fields' ] : array(); |
|
349 | 349 | |
350 | 350 | return GFCommon::replace_variables( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format, $aux_data ); |
351 | 351 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | // Is there is {gv_entry_link} or {gv_entry_link:[post id]} or {gv_entry_link:[post id]:[action]} merge tag? |
407 | 407 | preg_match_all( "/{gv_entry_link(?:\:(\d+)\:?(.*?))?}/ism", $original_text, $matches, PREG_SET_ORDER ); |
408 | 408 | |
409 | - if( empty( $matches ) ) { |
|
409 | + if ( empty( $matches ) ) { |
|
410 | 410 | return $original_text; |
411 | 411 | } |
412 | 412 | |
@@ -427,18 +427,18 @@ discard block |
||
427 | 427 | * } |
428 | 428 | */ |
429 | 429 | foreach ( $matches as $match ) { |
430 | - $full_tag = $match[0]; |
|
430 | + $full_tag = $match[ 0 ]; |
|
431 | 431 | |
432 | 432 | $link_args = array( |
433 | 433 | 'return' => 'url', |
434 | - 'entry_id' => $entry['id'], |
|
434 | + 'entry_id' => $entry[ 'id' ], |
|
435 | 435 | 'post_id' => \GV\Utils::get( $match, 1, null ), |
436 | 436 | 'action' => \GV\Utils::get( $match, 2, 'read' ), |
437 | 437 | ); |
438 | 438 | |
439 | 439 | $entry_link = $Shortcode->read_shortcode( $link_args, null, 'gv_entry_link_merge_tag' ); |
440 | 440 | |
441 | - if( $url_encode ) { |
|
441 | + if ( $url_encode ) { |
|
442 | 442 | $entry_link = urlencode( $entry_link ); |
443 | 443 | } |
444 | 444 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | 'diff' => in_array( 'diff', $exploded ), // {date_created:diff} |
476 | 476 | 'raw' => in_array( 'raw', $exploded ), // {date_created:raw} |
477 | 477 | 'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp} |
478 | - 'time' => in_array( 'time', $exploded ), // {date_created:time} |
|
478 | + 'time' => in_array( 'time', $exploded ), // {date_created:time} |
|
479 | 479 | ); |
480 | 480 | |
481 | 481 | $formatted_date = GVCommon::format_date( $date_created, $atts ); |
@@ -552,8 +552,8 @@ discard block |
||
552 | 552 | return $original_text; |
553 | 553 | } |
554 | 554 | |
555 | - foreach ( (array) $matches as $match ) { |
|
556 | - $full_tag = $match[0]; |
|
555 | + foreach ( (array)$matches as $match ) { |
|
556 | + $full_tag = $match[ 0 ]; |
|
557 | 557 | $modifier = \GV\Utils::get( $match, 2, 'permalink' ); |
558 | 558 | |
559 | 559 | $replacement = false; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | $replacement = esc_html( $replacement ); |
572 | 572 | } |
573 | 573 | |
574 | - if( $url_encode ) { |
|
574 | + if ( $url_encode ) { |
|
575 | 575 | $replacement = urlencode( $replacement ); |
576 | 576 | } |
577 | 577 | |
@@ -611,14 +611,14 @@ discard block |
||
611 | 611 | preg_match_all( "/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER ); |
612 | 612 | |
613 | 613 | // If there are no matches OR the Entry `created_by` isn't set or is 0 (no user) |
614 | - if( empty( $matches ) ) { |
|
614 | + if ( empty( $matches ) ) { |
|
615 | 615 | return $text; |
616 | 616 | } |
617 | 617 | |
618 | 618 | foreach ( $matches as $match ) { |
619 | 619 | |
620 | - $full_tag = $match[0]; |
|
621 | - $property = $match[1]; |
|
620 | + $full_tag = $match[ 0 ]; |
|
621 | + $property = $match[ 1 ]; |
|
622 | 622 | |
623 | 623 | $value = stripslashes_deep( \GV\Utils::_GET( $property ) ); |
624 | 624 | |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * @since 1.15 |
643 | 643 | * @param bool $esc_html Whether to esc_html() the value. Default: `true` |
644 | 644 | */ |
645 | - $esc_html = apply_filters('gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
645 | + $esc_html = apply_filters( 'gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
646 | 646 | |
647 | 647 | $value = $esc_html ? esc_html( $value ) : $value; |
648 | 648 | |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * @param[in] array $form Gravity Forms form array |
654 | 654 | * @param[in] array $entry Entry array |
655 | 655 | */ |
656 | - $value = apply_filters('gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
656 | + $value = apply_filters( 'gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
657 | 657 | |
658 | 658 | $text = str_replace( $full_tag, $value, $text ); |
659 | 659 | } |