@@ -27,34 +27,34 @@ discard block |
||
27 | 27 | add_filter( 'gravityview_blocklist_field_types', array( $this, 'default_field_blocklist' ), 10, 2 ); |
28 | 28 | |
29 | 29 | // Tooltips |
30 | - add_filter( 'gform_tooltips', array( $this, 'tooltips') ); |
|
30 | + add_filter( 'gform_tooltips', array( $this, 'tooltips' ) ); |
|
31 | 31 | |
32 | 32 | add_filter( 'admin_body_class', array( $this, 'add_gf_version_css_class' ) ); |
33 | 33 | |
34 | 34 | // adding styles and scripts |
35 | - add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles'), 999 ); |
|
36 | - add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
37 | - add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
38 | - add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
39 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
40 | - |
|
41 | - add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas'), 10, 4 ); |
|
42 | - add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas'), 10, 3 ); |
|
43 | - add_action( 'gravityview_render_field_pickers', array( $this, 'render_field_pickers'), 10, 2 ); |
|
44 | - add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields'), 10, 2 ); |
|
45 | - add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets') ); |
|
46 | - add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas'), 10, 5 ); |
|
35 | + add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles' ), 999 ); |
|
36 | + add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict' ) ); |
|
37 | + add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
|
38 | + add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict' ) ); |
|
39 | + add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
|
40 | + |
|
41 | + add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas' ), 10, 4 ); |
|
42 | + add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas' ), 10, 3 ); |
|
43 | + add_action( 'gravityview_render_field_pickers', array( $this, 'render_field_pickers' ), 10, 2 ); |
|
44 | + add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields' ), 10, 2 ); |
|
45 | + add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets' ) ); |
|
46 | + add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas' ), 10, 5 ); |
|
47 | 47 | |
48 | 48 | // @todo check if this hook is needed.. |
49 | 49 | //add_action( 'gravityview_render_field_options', array( $this, 'render_field_options'), 10, 9 ); |
50 | 50 | |
51 | 51 | // Add Connected Form column |
52 | - add_filter('manage_gravityview_posts_columns' , array( $this, 'add_post_type_columns' ) ); |
|
52 | + add_filter( 'manage_gravityview_posts_columns', array( $this, 'add_post_type_columns' ) ); |
|
53 | 53 | |
54 | 54 | add_filter( 'gform_toolbar_menu', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 ); |
55 | 55 | add_action( 'gform_form_actions', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 ); |
56 | 56 | |
57 | - add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content'), 10, 2 ); |
|
57 | + add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content' ), 10, 2 ); |
|
58 | 58 | |
59 | 59 | add_action( 'restrict_manage_posts', array( $this, 'add_view_dropdown' ) ); |
60 | 60 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $major_version = explode( '.', GFForms::$version ); |
87 | 87 | |
88 | 88 | if ( 2 <= sizeof( $major_version ) ) { |
89 | - $class .= ' gf-minor-version-' . esc_attr( $major_version[0] . '-' . $major_version[1] ); |
|
89 | + $class .= ' gf-minor-version-' . esc_attr( $major_version[ 0 ] . '-' . $major_version[ 1 ] ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | return $class; |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function suggest_support_articles( $localization_data = array() ) { |
103 | 103 | |
104 | - if( ! gravityview()->request->is_view() ) { |
|
104 | + if ( ! gravityview()->request->is_view() ) { |
|
105 | 105 | return $localization_data; |
106 | 106 | } |
107 | 107 | |
108 | - $localization_data['suggest'] = array( |
|
108 | + $localization_data[ 'suggest' ] = array( |
|
109 | 109 | '57ef23539033602e61d4a560', |
110 | 110 | '54c67bb9e4b0512429885513', |
111 | 111 | '54c67bb9e4b0512429885512', |
@@ -134,20 +134,20 @@ discard block |
||
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
137 | - if ( ! isset( $query->query_vars['post_type'] ) ) { |
|
137 | + if ( ! isset( $query->query_vars[ 'post_type' ] ) ) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | 140 | |
141 | - if ( 'gravityview' !== $query->query_vars['post_type'] ) { |
|
141 | + if ( 'gravityview' !== $query->query_vars[ 'post_type' ] ) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - $form_id = (int) \GV\Utils::_GET( 'gravityview_form_id' ); |
|
145 | + $form_id = (int)\GV\Utils::_GET( 'gravityview_form_id' ); |
|
146 | 146 | |
147 | 147 | $meta_query = array(); |
148 | 148 | |
149 | 149 | if ( $form_id ) { |
150 | - $meta_query[] = array( |
|
150 | + $meta_query[ ] = array( |
|
151 | 151 | 'key' => '_gravityview_form_id', |
152 | 152 | 'value' => $form_id, |
153 | 153 | ); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $layout_id = \GV\Utils::_GET( 'gravityview_layout' ); |
157 | 157 | |
158 | 158 | if ( $layout_id ) { |
159 | - $meta_query[] = array( |
|
159 | + $meta_query[ ] = array( |
|
160 | 160 | 'key' => '_gravityview_directory_template', |
161 | 161 | 'value' => esc_attr( $layout_id ), |
162 | 162 | ); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | public function add_view_dropdown() { |
174 | 174 | $current_screen = get_current_screen(); |
175 | 175 | |
176 | - if( 'gravityview' !== $current_screen->post_type ) { |
|
176 | + if ( 'gravityview' !== $current_screen->post_type ) { |
|
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | $current_form = \GV\Utils::_GET( 'gravityview_form_id' ); |
182 | 182 | |
183 | 183 | // If there are no forms to select, show no forms. |
184 | - if( ! empty( $forms ) ) { ?> |
|
184 | + if ( ! empty( $forms ) ) { ?> |
|
185 | 185 | <label for="gravityview_form_id" class="screen-reader-text"><?php esc_html_e( 'Filter Views by form', 'gravityview' ); ?></label> |
186 | 186 | <select name="gravityview_form_id" id="gravityview_form_id"> |
187 | 187 | <option value="" <?php selected( '', $current_form, true ); ?>><?php esc_html_e( 'All forms', 'gravityview' ); ?></option> |
188 | - <?php foreach( $forms as $form ) { ?> |
|
189 | - <option value="<?php echo esc_attr( $form['id'] ); ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option> |
|
188 | + <?php foreach ( $forms as $form ) { ?> |
|
189 | + <option value="<?php echo esc_attr( $form[ 'id' ] ); ?>" <?php selected( $form[ 'id' ], $current_form, true ); ?>><?php echo esc_html( $form[ 'title' ] ); ?></option> |
|
190 | 190 | <?php } ?> |
191 | 191 | </select> |
192 | 192 | <?php } |
@@ -195,26 +195,26 @@ discard block |
||
195 | 195 | $current_layout = \GV\Utils::_GET( 'gravityview_layout' ); |
196 | 196 | |
197 | 197 | // If there are no forms to select, show no forms. |
198 | - if( ! empty( $layouts ) ) { ?> |
|
198 | + if ( ! empty( $layouts ) ) { ?> |
|
199 | 199 | <label for="gravityview_layout_name" class="screen-reader-text"><?php esc_html_e( 'Filter Views by layout', 'gravityview' ); ?></label> |
200 | 200 | <select name="gravityview_layout" id="gravityview_layout_name"> |
201 | 201 | <option value="" <?php selected( '', $current_layout, true ); ?>><?php esc_html_e( 'All layouts', 'gravityview' ); ?></option> |
202 | 202 | <optgroup label="<?php esc_html_e( 'Layouts', 'gravityview' ); ?>"> |
203 | - <?php foreach( $layouts as $layout_id => $layout ) { |
|
204 | - if ( in_array( $layout['type'], array( 'preset', 'internal' ), true ) ) { |
|
203 | + <?php foreach ( $layouts as $layout_id => $layout ) { |
|
204 | + if ( in_array( $layout[ 'type' ], array( 'preset', 'internal' ), true ) ) { |
|
205 | 205 | continue; |
206 | 206 | } |
207 | 207 | ?> |
208 | - <option value="<?php echo esc_attr( $layout_id ); ?>" <?php selected( $layout_id, $current_layout, true ); ?>><?php echo esc_html( $layout['label'] ); ?></option> |
|
208 | + <option value="<?php echo esc_attr( $layout_id ); ?>" <?php selected( $layout_id, $current_layout, true ); ?>><?php echo esc_html( $layout[ 'label' ] ); ?></option> |
|
209 | 209 | <?php } ?> |
210 | 210 | </optgroup> |
211 | 211 | <optgroup label="<?php esc_html_e( 'Form Presets', 'gravityview' ); ?>"> |
212 | - <?php foreach( $layouts as $layout_id => $layout ) { |
|
213 | - if ( ! in_array( $layout['type'], array( 'preset' ), true ) ) { |
|
212 | + <?php foreach ( $layouts as $layout_id => $layout ) { |
|
213 | + if ( ! in_array( $layout[ 'type' ], array( 'preset' ), true ) ) { |
|
214 | 214 | continue; |
215 | 215 | } |
216 | 216 | ?> |
217 | - <option value="<?php echo esc_attr( $layout_id ); ?>" <?php selected( $layout_id, $current_layout, true ); ?>><?php echo esc_html( $layout['label'] ); ?></option> |
|
217 | + <option value="<?php echo esc_attr( $layout_id ); ?>" <?php selected( $layout_id, $current_layout, true ); ?>><?php echo esc_html( $layout[ 'label' ] ); ?></option> |
|
218 | 218 | <?php } ?> |
219 | 219 | </optgroup> |
220 | 220 | </select> |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) { |
230 | 230 | _deprecated_function( 'GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row' ); |
231 | - GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name , $id ); |
|
231 | + GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name, $id ); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | |
259 | 259 | $priority = 0; |
260 | 260 | |
261 | - if( 'form_list' === GFForms::get_page() ) { |
|
261 | + if ( 'form_list' === GFForms::get_page() ) { |
|
262 | 262 | $priority = 790; |
263 | 263 | } |
264 | 264 | |
265 | - if( empty( $connected_views ) ) { |
|
265 | + if ( empty( $connected_views ) ) { |
|
266 | 266 | |
267 | - $menu_items['gravityview'] = array( |
|
267 | + $menu_items[ 'gravityview' ] = array( |
|
268 | 268 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
269 | 269 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', // Only appears in GF pre-2.5 |
270 | 270 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -280,23 +280,23 @@ discard block |
||
280 | 280 | $sub_menu_items = array(); |
281 | 281 | foreach ( (array)$connected_views as $view ) { |
282 | 282 | |
283 | - if( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) { |
|
283 | + if ( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) { |
|
284 | 284 | continue; |
285 | 285 | } |
286 | 286 | |
287 | - $label = empty( $view->post_title ) ? sprintf( __('No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title; |
|
287 | + $label = empty( $view->post_title ) ? sprintf( __( 'No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title; |
|
288 | 288 | |
289 | - $sub_menu_items[] = array( |
|
289 | + $sub_menu_items[ ] = array( |
|
290 | 290 | 'label' => esc_attr( $label ), |
291 | - 'url' => admin_url( 'post.php?action=edit&post='.$view->ID ), |
|
291 | + 'url' => admin_url( 'post.php?action=edit&post=' . $view->ID ), |
|
292 | 292 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
293 | 293 | ); |
294 | 294 | } |
295 | 295 | |
296 | 296 | // If there were no items added, then let's create the parent menu |
297 | - if( $sub_menu_items ) { |
|
297 | + if ( $sub_menu_items ) { |
|
298 | 298 | |
299 | - $sub_menu_items[] = array( |
|
299 | + $sub_menu_items[ ] = array( |
|
300 | 300 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
301 | 301 | 'icon' => '<span class="dashicons dashicons-plus"></span>', |
302 | 302 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | ); |
306 | 306 | |
307 | 307 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
308 | - $sub_menu_items[] = array( |
|
308 | + $sub_menu_items[ ] = array( |
|
309 | 309 | 'url' => '#', |
310 | 310 | 'label' => '', |
311 | 311 | 'menu_class' => 'hidden', |
312 | 312 | 'capabilities' => '', |
313 | 313 | ); |
314 | 314 | |
315 | - $menu_items['gravityview'] = array( |
|
315 | + $menu_items[ 'gravityview' ] = array( |
|
316 | 316 | 'label' => __( 'Connected Views', 'gravityview' ), |
317 | 317 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
318 | 318 | 'title' => __( 'GravityView Views using this form as a data source', 'gravityview' ), |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | $add = array( 'captcha', 'page' ); |
344 | 344 | |
345 | 345 | // Don't allowing editing the following values: |
346 | - if( $context === 'edit' ) { |
|
347 | - $add[] = 'post_id'; |
|
346 | + if ( $context === 'edit' ) { |
|
347 | + $add[ ] = 'post_id'; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | $return = array_merge( $array, $add ); |
@@ -375,27 +375,27 @@ discard block |
||
375 | 375 | foreach ( $default_args as $key => $arg ) { |
376 | 376 | |
377 | 377 | // If an arg has `tooltip` defined, but it's false, don't display a tooltip |
378 | - if( isset( $arg['tooltip'] ) && empty( $arg['tooltip'] ) ) { continue; } |
|
378 | + if ( isset( $arg[ 'tooltip' ] ) && empty( $arg[ 'tooltip' ] ) ) { continue; } |
|
379 | 379 | |
380 | 380 | // By default, use `tooltip` if defined. |
381 | - $tooltip = empty( $arg['tooltip'] ) ? NULL : $arg['tooltip']; |
|
381 | + $tooltip = empty( $arg[ 'tooltip' ] ) ? NULL : $arg[ 'tooltip' ]; |
|
382 | 382 | |
383 | 383 | // If there's no tooltip set, continue |
384 | - if( empty( $tooltip ) ) { |
|
384 | + if ( empty( $tooltip ) ) { |
|
385 | 385 | continue; |
386 | 386 | } |
387 | 387 | |
388 | 388 | // Add the tooltip |
389 | - $gv_tooltips[ 'gv_'.$key ] = array( |
|
390 | - 'title' => $arg['label'], |
|
389 | + $gv_tooltips[ 'gv_' . $key ] = array( |
|
390 | + 'title' => $arg[ 'label' ], |
|
391 | 391 | 'value' => $tooltip, |
392 | 392 | ); |
393 | 393 | |
394 | 394 | } |
395 | 395 | |
396 | - $gv_tooltips['gv_css_merge_tags'] = array( |
|
397 | - 'title' => __('CSS Merge Tags', 'gravityview'), |
|
398 | - 'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>' ) |
|
396 | + $gv_tooltips[ 'gv_css_merge_tags' ] = array( |
|
397 | + 'title' => __( 'CSS Merge Tags', 'gravityview' ), |
|
398 | + 'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview' ), '<code>', '</code>' ) |
|
399 | 399 | ); |
400 | 400 | |
401 | 401 | /** |
@@ -413,9 +413,9 @@ discard block |
||
413 | 413 | |
414 | 414 | foreach ( $gv_tooltips as $key => $tooltip ) { |
415 | 415 | |
416 | - $title = empty( $tooltip['title'] ) ? '' : '<h6>'.esc_html( $tooltip['title'] ) .'</h6>'; |
|
416 | + $title = empty( $tooltip[ 'title' ] ) ? '' : '<h6>' . esc_html( $tooltip[ 'title' ] ) . '</h6>'; |
|
417 | 417 | |
418 | - $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip['value'] ) ); |
|
418 | + $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip[ 'value' ] ) ); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | return $tooltips; |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * |
430 | 430 | * @return void |
431 | 431 | */ |
432 | - public function add_custom_column_content( $column_name = null, $post_id = 0 ) { |
|
432 | + public function add_custom_column_content( $column_name = null, $post_id = 0 ) { |
|
433 | 433 | |
434 | 434 | $output = ''; |
435 | 435 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | // Generate backup if label doesn't exist: `example_name` => `Example Name` |
452 | 452 | $template_id_pretty = ucwords( implode( ' ', explode( '_', $template_id ) ) ); |
453 | 453 | |
454 | - $output = $template ? $template['label'] : $template_id_pretty; |
|
454 | + $output = $template ? $template[ 'label' ] : $template_id_pretty; |
|
455 | 455 | |
456 | 456 | break; |
457 | 457 | |
@@ -492,12 +492,12 @@ discard block |
||
492 | 492 | static public function get_connected_form_links( $form, $include_form_link = true ) { |
493 | 493 | |
494 | 494 | // Either the form is empty or the form ID is 0, not yet set. |
495 | - if( empty( $form ) ) { |
|
495 | + if ( empty( $form ) ) { |
|
496 | 496 | return ''; |
497 | 497 | } |
498 | 498 | |
499 | 499 | // The $form is passed as the form ID |
500 | - if( !is_array( $form ) ) { |
|
500 | + if ( ! is_array( $form ) ) { |
|
501 | 501 | $form = gravityview_get_form( $form ); |
502 | 502 | } |
503 | 503 | |
@@ -505,35 +505,35 @@ discard block |
||
505 | 505 | return ''; |
506 | 506 | } |
507 | 507 | |
508 | - $form_id = $form['id']; |
|
508 | + $form_id = $form[ 'id' ]; |
|
509 | 509 | $links = array(); |
510 | 510 | |
511 | - if( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) { |
|
511 | + if ( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) { |
|
512 | 512 | $form_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $form_id ) ); |
513 | - $form_link = '<strong class="gv-form-title">'.gravityview_get_link( $form_url, $form['title'], 'class=row-title' ).'</strong>'; |
|
514 | - $links[] = '<span>'.gravityview_get_link( $form_url, __('Edit Form', 'gravityview') ).'</span>'; |
|
513 | + $form_link = '<strong class="gv-form-title">' . gravityview_get_link( $form_url, $form[ 'title' ], 'class=row-title' ) . '</strong>'; |
|
514 | + $links[ ] = '<span>' . gravityview_get_link( $form_url, __( 'Edit Form', 'gravityview' ) ) . '</span>'; |
|
515 | 515 | } else { |
516 | - $form_link = '<strong class="gv-form-title">'. esc_html( $form['title'] ). '</strong>'; |
|
516 | + $form_link = '<strong class="gv-form-title">' . esc_html( $form[ 'title' ] ) . '</strong>'; |
|
517 | 517 | } |
518 | 518 | |
519 | - if( GVCommon::has_cap( 'gravityforms_view_entries' ) ) { |
|
519 | + if ( GVCommon::has_cap( 'gravityforms_view_entries' ) ) { |
|
520 | 520 | $entries_url = admin_url( sprintf( 'admin.php?page=gf_entries&id=%d', $form_id ) ); |
521 | - $links[] = '<span>'.gravityview_get_link( $entries_url, __('Entries', 'gravityview') ).'</span>'; |
|
521 | + $links[ ] = '<span>' . gravityview_get_link( $entries_url, __( 'Entries', 'gravityview' ) ) . '</span>'; |
|
522 | 522 | } |
523 | 523 | |
524 | - if( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) { |
|
524 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) { |
|
525 | 525 | $settings_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&view=settings&id=%d', $form_id ) ); |
526 | - $links[] = '<span>'.gravityview_get_link( $settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview') ).'</span>'; |
|
526 | + $links[ ] = '<span>' . gravityview_get_link( $settings_url, __( 'Settings', 'gravityview' ), 'title=' . __( 'Edit settings for this form', 'gravityview' ) ) . '</span>'; |
|
527 | 527 | } |
528 | 528 | |
529 | - if( GVCommon::has_cap( array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms") ) ) { |
|
529 | + if ( GVCommon::has_cap( array( "gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms" ) ) ) { |
|
530 | 530 | $preview_url = site_url( sprintf( '?gf_page=preview&id=%d', $form_id ) ); |
531 | - $links[] = '<span>'.gravityview_get_link( $preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview') ).'</span>'; |
|
531 | + $links[ ] = '<span>' . gravityview_get_link( $preview_url, __( 'Preview Form', 'gravityview' ), 'title=' . __( 'Preview this form', 'gravityview' ) ) . '</span>'; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | $output = ''; |
535 | 535 | |
536 | - if( !empty( $include_form_link ) ) { |
|
536 | + if ( ! empty( $include_form_link ) ) { |
|
537 | 537 | $output .= $form_link; |
538 | 538 | } |
539 | 539 | |
@@ -548,11 +548,11 @@ discard block |
||
548 | 548 | $css_class = 'row-actions'; |
549 | 549 | |
550 | 550 | // Is Screen Options > View mode set to "Extended view"? If so, keep actions visible. |
551 | - if( 'excerpt' === get_user_setting( 'posts_list_mode', 'list' ) ) { |
|
551 | + if ( 'excerpt' === get_user_setting( 'posts_list_mode', 'list' ) ) { |
|
552 | 552 | $css_class = 'row-actions visible'; |
553 | 553 | } |
554 | 554 | |
555 | - $output .= '<div class="' . $css_class . '">'. implode( ' | ', $links ) .'</div>'; |
|
555 | + $output .= '<div class="' . $css_class . '">' . implode( ' | ', $links ) . '</div>'; |
|
556 | 556 | |
557 | 557 | return $output; |
558 | 558 | } |
@@ -566,8 +566,8 @@ discard block |
||
566 | 566 | // Get the date column and save it for later to add back in. |
567 | 567 | // This adds it after the Data Source column. |
568 | 568 | // This way, we don't need to do array_slice, array_merge, etc. |
569 | - $date = $columns['date']; |
|
570 | - unset( $columns['date'] ); |
|
569 | + $date = $columns[ 'date' ]; |
|
570 | + unset( $columns[ 'date' ] ); |
|
571 | 571 | |
572 | 572 | $data_source_required_caps = array( |
573 | 573 | 'gravityforms_edit_forms', |
@@ -578,14 +578,14 @@ discard block |
||
578 | 578 | 'gravityforms_preview_forms', |
579 | 579 | ); |
580 | 580 | |
581 | - if( GVCommon::has_cap( $data_source_required_caps ) ) { |
|
582 | - $columns['gv_connected_form'] = __( 'Data Source', 'gravityview' ); |
|
581 | + if ( GVCommon::has_cap( $data_source_required_caps ) ) { |
|
582 | + $columns[ 'gv_connected_form' ] = __( 'Data Source', 'gravityview' ); |
|
583 | 583 | } |
584 | 584 | |
585 | - $columns['gv_template'] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' ); |
|
585 | + $columns[ 'gv_template' ] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' ); |
|
586 | 586 | |
587 | 587 | // Add the date back in. |
588 | - $columns['date'] = $date; |
|
588 | + $columns[ 'date' ] = $date; |
|
589 | 589 | |
590 | 590 | return $columns; |
591 | 591 | } |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | */ |
599 | 599 | function save_postdata( $post_id ) { |
600 | 600 | |
601 | - if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){ |
|
601 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
602 | 602 | return; |
603 | 603 | } |
604 | 604 | |
605 | 605 | // validate post_type |
606 | - if ( ! isset( $_POST['post_type'] ) || 'gravityview' != $_POST['post_type'] ) { |
|
606 | + if ( ! isset( $_POST[ 'post_type' ] ) || 'gravityview' != $_POST[ 'post_type' ] ) { |
|
607 | 607 | return; |
608 | 608 | } |
609 | 609 | |
@@ -618,63 +618,63 @@ discard block |
||
618 | 618 | $statii = array(); |
619 | 619 | |
620 | 620 | // check if this is a start fresh View |
621 | - if ( isset( $_POST['gravityview_select_form_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_form_nonce'], 'gravityview_select_form' ) ) { |
|
621 | + if ( isset( $_POST[ 'gravityview_select_form_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_select_form_nonce' ], 'gravityview_select_form' ) ) { |
|
622 | 622 | |
623 | - $form_id = !empty( $_POST['gravityview_form_id'] ) ? $_POST['gravityview_form_id'] : ''; |
|
623 | + $form_id = ! empty( $_POST[ 'gravityview_form_id' ] ) ? $_POST[ 'gravityview_form_id' ] : ''; |
|
624 | 624 | // save form id |
625 | - $statii['form_id'] = update_post_meta( $post_id, '_gravityview_form_id', $form_id ); |
|
625 | + $statii[ 'form_id' ] = update_post_meta( $post_id, '_gravityview_form_id', $form_id ); |
|
626 | 626 | |
627 | 627 | } |
628 | 628 | |
629 | - if( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii['form_id'] ) ) { |
|
629 | + if ( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii[ 'form_id' ] ) ) { |
|
630 | 630 | gravityview()->log->error( 'Current user does not have the capability to create a new Form.', array( 'data' => wp_get_current_user() ) ); |
631 | 631 | return; |
632 | 632 | } |
633 | 633 | |
634 | 634 | // Was this a start fresh? |
635 | - if ( ! empty( $_POST['gravityview_form_id_start_fresh'] ) ) { |
|
636 | - $statii['start_fresh'] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 ); |
|
635 | + if ( ! empty( $_POST[ 'gravityview_form_id_start_fresh' ] ) ) { |
|
636 | + $statii[ 'start_fresh' ] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 ); |
|
637 | 637 | } else { |
638 | - $statii['start_fresh'] = delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
638 | + $statii[ 'start_fresh' ] = delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | // Check if we have a template id |
642 | - if ( isset( $_POST['gravityview_select_template_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_template_nonce'], 'gravityview_select_template' ) ) { |
|
642 | + if ( isset( $_POST[ 'gravityview_select_template_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_select_template_nonce' ], 'gravityview_select_template' ) ) { |
|
643 | 643 | |
644 | - $template_id = !empty( $_POST['gravityview_directory_template'] ) ? $_POST['gravityview_directory_template'] : ''; |
|
644 | + $template_id = ! empty( $_POST[ 'gravityview_directory_template' ] ) ? $_POST[ 'gravityview_directory_template' ] : ''; |
|
645 | 645 | |
646 | 646 | // now save template id |
647 | - $statii['directory_template'] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id ); |
|
647 | + $statii[ 'directory_template' ] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id ); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | |
651 | 651 | // save View Configuration metabox |
652 | - if ( isset( $_POST['gravityview_view_configuration_nonce'] ) && wp_verify_nonce( $_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration' ) ) { |
|
652 | + if ( isset( $_POST[ 'gravityview_view_configuration_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_view_configuration_nonce' ], 'gravityview_view_configuration' ) ) { |
|
653 | 653 | |
654 | 654 | // template settings |
655 | - if( empty( $_POST['template_settings'] ) ) { |
|
656 | - $_POST['template_settings'] = array(); |
|
655 | + if ( empty( $_POST[ 'template_settings' ] ) ) { |
|
656 | + $_POST[ 'template_settings' ] = array(); |
|
657 | 657 | } |
658 | - $statii['template_settings'] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST['template_settings'] ); |
|
658 | + $statii[ 'template_settings' ] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST[ 'template_settings' ] ); |
|
659 | 659 | |
660 | 660 | // guard against unloaded View configuration page |
661 | - if ( isset( $_POST['gv_fields'] ) && isset( $_POST['gv_fields_done'] ) ) { |
|
661 | + if ( isset( $_POST[ 'gv_fields' ] ) && isset( $_POST[ 'gv_fields_done' ] ) ) { |
|
662 | 662 | $fields = array(); |
663 | 663 | |
664 | - if ( ! empty( $_POST['gv_fields'] ) ) { |
|
664 | + if ( ! empty( $_POST[ 'gv_fields' ] ) ) { |
|
665 | 665 | $fields = _gravityview_process_posted_fields(); |
666 | 666 | } |
667 | 667 | |
668 | 668 | $fields = wp_slash( $fields ); |
669 | 669 | |
670 | - $statii['directory_fields'] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields ); |
|
670 | + $statii[ 'directory_fields' ] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields ); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | // Directory Visible Widgets |
674 | - if( empty( $_POST['widgets'] ) ) { |
|
675 | - $_POST['widgets'] = array(); |
|
674 | + if ( empty( $_POST[ 'widgets' ] ) ) { |
|
675 | + $_POST[ 'widgets' ] = array(); |
|
676 | 676 | } |
677 | - $statii['directory_widgets'] = gravityview_set_directory_widgets( $post_id, $_POST['widgets'] ); |
|
677 | + $statii[ 'directory_widgets' ] = gravityview_set_directory_widgets( $post_id, $_POST[ 'widgets' ] ); |
|
678 | 678 | |
679 | 679 | } // end save view configuration |
680 | 680 | |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | * @param array $statii Array of statuses of the post meta saving processes. If saving worked, each key should be mapped to a value of the post ID (`directory_widgets` => `124`). If failed (or didn't change), the value will be false. |
685 | 685 | * @since 1.17.2 |
686 | 686 | */ |
687 | - do_action('gravityview_view_saved', $post_id, $statii ); |
|
687 | + do_action( 'gravityview_view_saved', $post_id, $statii ); |
|
688 | 688 | |
689 | 689 | gravityview()->log->debug( '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array( 'data' => array_map( 'intval', $statii ) ) ); |
690 | 690 | } |
@@ -735,20 +735,20 @@ discard block |
||
735 | 735 | |
736 | 736 | $output = ''; |
737 | 737 | |
738 | - if( !empty( $fields ) ) { |
|
738 | + if ( ! empty( $fields ) ) { |
|
739 | 739 | |
740 | - foreach( $fields as $id => $details ) { |
|
740 | + foreach ( $fields as $id => $details ) { |
|
741 | 741 | |
742 | - if( in_array( $details['type'], (array) $blocklist_field_types ) ) { |
|
742 | + if ( in_array( $details[ 'type' ], (array)$blocklist_field_types ) ) { |
|
743 | 743 | continue; |
744 | 744 | } |
745 | 745 | |
746 | 746 | // Edit mode only allows editing the parent fields, not single inputs. |
747 | - if( $context === 'edit' && ! empty( $details['parent'] ) ) { |
|
747 | + if ( $context === 'edit' && ! empty( $details[ 'parent' ] ) ) { |
|
748 | 748 | continue; |
749 | 749 | } |
750 | 750 | |
751 | - $output .= new GravityView_Admin_View_Field( $details['label'], $id, $details, array(), $form ); |
|
751 | + $output .= new GravityView_Admin_View_Field( $details[ 'label' ], $id, $details, array(), $form ); |
|
752 | 752 | |
753 | 753 | } // End foreach |
754 | 754 | } |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | echo $output; |
757 | 757 | |
758 | 758 | // For the EDIT view we only want to allow the form fields. |
759 | - if( $context === 'edit' ) { |
|
759 | + if ( $context === 'edit' ) { |
|
760 | 760 | return; |
761 | 761 | } |
762 | 762 | |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | $additional_fields = array( |
776 | 776 | array( |
777 | 777 | 'label_text' => __( 'Add All Form Fields', 'gravityview' ), |
778 | - 'desc' => __('Insert all the form fields at once.', 'gravityview'), |
|
778 | + 'desc' => __( 'Insert all the form fields at once.', 'gravityview' ), |
|
779 | 779 | 'field_id' => 'all-fields', |
780 | 780 | 'label_type' => 'field', |
781 | 781 | 'input_type' => null, |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | */ |
792 | 792 | $additional_fields = apply_filters( 'gravityview_additional_fields', $additional_fields ); |
793 | 793 | |
794 | - foreach ( (array) $additional_fields as $item ) { |
|
794 | + foreach ( (array)$additional_fields as $item ) { |
|
795 | 795 | |
796 | 796 | // Prevent items from not having index set |
797 | 797 | $item = wp_parse_args( $item, array( |
@@ -802,16 +802,16 @@ discard block |
||
802 | 802 | 'field_options' => null, |
803 | 803 | 'settings_html' => null, |
804 | 804 | 'icon' => null, |
805 | - )); |
|
805 | + ) ); |
|
806 | 806 | |
807 | 807 | // Backward compat. |
808 | - if( !empty( $item['field_options'] ) ) { |
|
808 | + if ( ! empty( $item[ 'field_options' ] ) ) { |
|
809 | 809 | // Use settings_html from now on. |
810 | - $item['settings_html'] = $item['field_options']; |
|
810 | + $item[ 'settings_html' ] = $item[ 'field_options' ]; |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | // Render a label for each of them |
814 | - echo new GravityView_Admin_View_Field( $item['label_text'], $item['field_id'], $item, $settings = array(), $form ); |
|
814 | + echo new GravityView_Admin_View_Field( $item[ 'label_text' ], $item[ 'field_id' ], $item, $settings = array(), $form ); |
|
815 | 815 | |
816 | 816 | } |
817 | 817 | |
@@ -823,12 +823,12 @@ discard block |
||
823 | 823 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
824 | 824 | * @return array |
825 | 825 | */ |
826 | - function get_entry_default_fields($form, $zone) { |
|
826 | + function get_entry_default_fields( $form, $zone ) { |
|
827 | 827 | |
828 | 828 | $entry_default_fields = array(); |
829 | 829 | |
830 | 830 | // if in zone directory or single |
831 | - if( in_array( $zone, array( 'directory', 'single' ), true ) ) { |
|
831 | + if ( in_array( $zone, array( 'directory', 'single' ), true ) ) { |
|
832 | 832 | |
833 | 833 | $meta_fields = GravityView_Fields::get_all( array( 'meta', 'gravityview', 'add-ons' ) ); |
834 | 834 | |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | * @param string|array $form form_ID or form object |
846 | 846 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
847 | 847 | */ |
848 | - return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
848 | + return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone ); |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | /** |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | */ |
857 | 857 | function get_available_fields( $form = '', $zone = NULL ) { |
858 | 858 | |
859 | - if( empty( $form ) ) { |
|
859 | + if ( empty( $form ) ) { |
|
860 | 860 | gravityview()->log->error( '$form is empty' ); |
861 | 861 | return array(); |
862 | 862 | } |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | $fields = gravityview_get_form_fields( $form, true ); |
866 | 866 | |
867 | 867 | // get meta fields ( only if form was already created ) |
868 | - if( !is_array( $form ) ) { |
|
868 | + if ( ! is_array( $form ) ) { |
|
869 | 869 | $meta_fields = gravityview_get_entry_meta( $form ); |
870 | 870 | } else { |
871 | 871 | $meta_fields = array(); |
@@ -878,8 +878,8 @@ discard block |
||
878 | 878 | $fields = $fields + $meta_fields + $default_fields; |
879 | 879 | |
880 | 880 | // Move Custom Content to top |
881 | - if ( isset( $fields['custom'] ) ) { |
|
882 | - $fields = array( 'custom' => $fields['custom'] ) + $fields; |
|
881 | + if ( isset( $fields[ 'custom' ] ) ) { |
|
882 | + $fields = array( 'custom' => $fields[ 'custom' ] ) + $fields; |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | $gv_fields = GravityView_Fields::get_all(); |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | foreach ( $fields as &$field ) { |
888 | 888 | foreach ( $gv_fields as $gv_field ) { |
889 | 889 | if ( \GV\Utils::get( $field, 'type' ) === $gv_field->name ) { |
890 | - $field['icon'] = \GV\Utils::get( $gv_field, 'icon' ); |
|
890 | + $field[ 'icon' ] = \GV\Utils::get( $gv_field, 'icon' ); |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 | } |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | } |
916 | 916 | |
917 | 917 | foreach ( $widgets as $id => $details ) { |
918 | - echo new GravityView_Admin_View_Widget( $details['label'], $id, $details ); |
|
918 | + echo new GravityView_Admin_View_Widget( $details[ 'label' ], $id, $details ); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | } |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | function render_active_areas( $template_id, $type, $zone, $rows, $values ) { |
946 | 946 | global $post; |
947 | 947 | |
948 | - if( $type === 'widget' ) { |
|
948 | + if ( $type === 'widget' ) { |
|
949 | 949 | $button_label = __( 'Add Widget', 'gravityview' ); |
950 | 950 | } else { |
951 | 951 | $button_label = __( 'Add Field', 'gravityview' ); |
@@ -971,10 +971,10 @@ discard block |
||
971 | 971 | $form_id = null; |
972 | 972 | |
973 | 973 | // if saved values, get available fields to label everyone |
974 | - if( !empty( $values ) && ( !empty( $post->ID ) || !empty( $_POST['template_id'] ) ) ) { |
|
974 | + if ( ! empty( $values ) && ( ! empty( $post->ID ) || ! empty( $_POST[ 'template_id' ] ) ) ) { |
|
975 | 975 | |
976 | - if( !empty( $_POST['template_id'] ) ) { |
|
977 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
976 | + if ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
977 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
978 | 978 | } else { |
979 | 979 | $form_id = $form = gravityview_get_form_id( $post->ID ); |
980 | 980 | } |
@@ -992,53 +992,53 @@ discard block |
||
992 | 992 | } |
993 | 993 | } |
994 | 994 | |
995 | - foreach( $rows as $row ) : |
|
996 | - foreach( $row as $col => $areas ) : |
|
997 | - $column = ($col == '2-2') ? '1-2' : $col; ?> |
|
995 | + foreach ( $rows as $row ) : |
|
996 | + foreach ( $row as $col => $areas ) : |
|
997 | + $column = ( $col == '2-2' ) ? '1-2' : $col; ?> |
|
998 | 998 | |
999 | 999 | <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
1000 | 1000 | |
1001 | - <?php foreach( $areas as $area ) : ?> |
|
1001 | + <?php foreach ( $areas as $area ) : ?> |
|
1002 | 1002 | |
1003 | - <div class="gv-droppable-area" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"> |
|
1004 | - <p class="gv-droppable-area-title" <?php if ( 'widget' === $type && empty( $area['subtitle'] ) ) { echo ' style="margin: 0; padding: 0;"'; } ?>> |
|
1005 | - <strong <?php if ( 'widget' === $type ) { echo 'class="screen-reader-text"'; } ?>><?php echo esc_html( $area['title'] ); ?></strong> |
|
1003 | + <div class="gv-droppable-area" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"> |
|
1004 | + <p class="gv-droppable-area-title" <?php if ( 'widget' === $type && empty( $area[ 'subtitle' ] ) ) { echo ' style="margin: 0; padding: 0;"'; } ?>> |
|
1005 | + <strong <?php if ( 'widget' === $type ) { echo 'class="screen-reader-text"'; } ?>><?php echo esc_html( $area[ 'title' ] ); ?></strong> |
|
1006 | 1006 | |
1007 | 1007 | <?php if ( 'widget' !== $type ) { ?> |
1008 | - <a class="clear-all-fields alignright" role="button" href="#" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>"><?php esc_html_e( 'Clear all fields', 'gravityview' ); ?></a> |
|
1008 | + <a class="clear-all-fields alignright" role="button" href="#" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>"><?php esc_html_e( 'Clear all fields', 'gravityview' ); ?></a> |
|
1009 | 1009 | <?php } ?> |
1010 | 1010 | |
1011 | - <?php if ( ! empty( $area['subtitle'] ) ) { ?> |
|
1012 | - <span class="gv-droppable-area-subtitle"><span class="gf_tooltip gv_tooltip tooltip" title="<?php echo esc_attr( $area['subtitle'] ); ?>"></span></span> |
|
1011 | + <?php if ( ! empty( $area[ 'subtitle' ] ) ) { ?> |
|
1012 | + <span class="gv-droppable-area-subtitle"><span class="gf_tooltip gv_tooltip tooltip" title="<?php echo esc_attr( $area[ 'subtitle' ] ); ?>"></span></span> |
|
1013 | 1013 | <?php } ?> |
1014 | 1014 | </p> |
1015 | 1015 | <div class="active-drop-container active-drop-container-<?php echo esc_attr( $type ); ?>"> |
1016 | - <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>"><?php // render saved fields |
|
1017 | - if( ! empty( $values[ $zone .'_'. $area['areaid'] ] ) ) { |
|
1016 | + <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>"><?php // render saved fields |
|
1017 | + if ( ! empty( $values[ $zone . '_' . $area[ 'areaid' ] ] ) ) { |
|
1018 | 1018 | |
1019 | - foreach( $values[ $zone .'_'. $area['areaid'] ] as $uniqid => $field ) { |
|
1019 | + foreach ( $values[ $zone . '_' . $area[ 'areaid' ] ] as $uniqid => $field ) { |
|
1020 | 1020 | |
1021 | 1021 | // Maybe has a form ID |
1022 | - $form_id = empty( $field['form_id'] ) ? $form_id : $field['form_id']; |
|
1022 | + $form_id = empty( $field[ 'form_id' ] ) ? $form_id : $field[ 'form_id' ]; |
|
1023 | 1023 | |
1024 | 1024 | $input_type = NULL; |
1025 | 1025 | |
1026 | 1026 | if ( $form_id ) { |
1027 | - $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
|
1027 | + $original_item = isset( $available_items[ $form_id ] [ $field[ 'id' ] ] ) ? $available_items[ $form_id ] [ $field[ 'id' ] ] : false; |
|
1028 | 1028 | } else { |
1029 | - $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
|
1029 | + $original_item = isset( $available_items[ $field[ 'id' ] ] ) ? $available_items[ $field[ 'id' ] ] : false; |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | - if ( !$original_item ) { |
|
1033 | - gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) ); |
|
1032 | + if ( ! $original_item ) { |
|
1033 | + gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array( ' data' => array( 'available_items' => $available_items, 'field' => $field ) ) ); |
|
1034 | 1034 | |
1035 | 1035 | $original_item = $field; |
1036 | 1036 | } else { |
1037 | - $input_type = isset( $original_item['type'] ) ? $original_item['type'] : NULL; |
|
1037 | + $input_type = isset( $original_item[ 'type' ] ) ? $original_item[ 'type' ] : NULL; |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | // Field options dialog box |
1041 | - $field_options = GravityView_Render_Settings::render_field_options( $form_id, $type, $template_id, $field['id'], $original_item['label'], $zone .'_'. $area['areaid'], $input_type, $uniqid, $field, $zone, $original_item ); |
|
1041 | + $field_options = GravityView_Render_Settings::render_field_options( $form_id, $type, $template_id, $field[ 'id' ], $original_item[ 'label' ], $zone . '_' . $area[ 'areaid' ], $input_type, $uniqid, $field, $zone, $original_item ); |
|
1042 | 1042 | |
1043 | 1043 | $item = array( |
1044 | 1044 | 'input_type' => $input_type, |
@@ -1051,12 +1051,12 @@ discard block |
||
1051 | 1051 | $item = wp_parse_args( $item, $original_item ); |
1052 | 1052 | } |
1053 | 1053 | |
1054 | - switch( $type ) { |
|
1054 | + switch ( $type ) { |
|
1055 | 1055 | case 'widget': |
1056 | - echo new GravityView_Admin_View_Widget( $item['label'], $field['id'], $item, $field ); |
|
1056 | + echo new GravityView_Admin_View_Widget( $item[ 'label' ], $field[ 'id' ], $item, $field ); |
|
1057 | 1057 | break; |
1058 | 1058 | default: |
1059 | - echo new GravityView_Admin_View_Field( $field['label'], $field['id'], $item, $field, $form_id ); |
|
1059 | + echo new GravityView_Admin_View_Field( $field[ 'label' ], $field[ 'id' ], $item, $field, $form_id ); |
|
1060 | 1060 | } |
1061 | 1061 | } |
1062 | 1062 | |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | <div class="gv-droppable-area-action"> |
1065 | 1065 | <a href="#" class="gv-add-field button button-link button-hero" title="" |
1066 | 1066 | data-objecttype="<?php echo esc_attr( $type ); ?>" |
1067 | - data-areaid="<?php echo esc_attr( $zone . '_' . $area['areaid'] ); ?>" |
|
1067 | + data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>" |
|
1068 | 1068 | data-context="<?php echo esc_attr( $zone ); ?>" |
1069 | 1069 | data-formid="<?php echo $view ? esc_attr( $view->form ? $view->form->ID : '' ) : ''; ?>"><?php echo '<span class="dashicons dashicons-plus-alt"></span>' . esc_html( $button_label ); ?></a> |
1070 | 1070 | </div> |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | // This is a new View, prefill the widgets |
1098 | 1098 | $widgets = array( |
1099 | 1099 | 'header_top' => array( |
1100 | - substr( md5( microtime( true ) ), 0, 13 ) => array ( |
|
1100 | + substr( md5( microtime( true ) ), 0, 13 ) => array( |
|
1101 | 1101 | 'id' => 'search_bar', |
1102 | 1102 | 'label' => __( 'Search Bar', 'gravityview' ), |
1103 | 1103 | 'search_layout' => 'horizontal', |
@@ -1172,12 +1172,12 @@ discard block |
||
1172 | 1172 | if ( $post ) { |
1173 | 1173 | $source_form_id = gravityview_get_form_id( $post->ID ); |
1174 | 1174 | if ( $source_form_id ) { |
1175 | - $form_ids[] = $source_form_id; |
|
1175 | + $form_ids[ ] = $source_form_id; |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | $joined_forms = \GV\View::get_joined_forms( $post->ID ); |
1179 | 1179 | foreach ( $joined_forms as $joined_form ) { |
1180 | - $form_ids[] = $joined_form->ID; |
|
1180 | + $form_ids[ ] = $joined_form->ID; |
|
1181 | 1181 | } |
1182 | 1182 | } |
1183 | 1183 | foreach ( array_unique( $form_ids ) as $form_id ) { |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | * @return string HTML of the active areas |
1216 | 1216 | */ |
1217 | 1217 | function render_directory_active_areas( $template_id = '', $context = 'single', $post_id = '', $echo = false ) { |
1218 | - if( empty( $template_id ) ) { |
|
1218 | + if ( empty( $template_id ) ) { |
|
1219 | 1219 | gravityview()->log->debug( '[render_directory_active_areas] {template_id} is empty', array( 'template_id' => $template_id ) ); |
1220 | 1220 | return ''; |
1221 | 1221 | } |
@@ -1229,12 +1229,12 @@ discard block |
||
1229 | 1229 | */ |
1230 | 1230 | $template_areas = apply_filters( 'gravityview_template_active_areas', array(), $template_id, $context ); |
1231 | 1231 | |
1232 | - if( empty( $template_areas ) ) { |
|
1232 | + if ( empty( $template_areas ) ) { |
|
1233 | 1233 | |
1234 | 1234 | gravityview()->log->debug( '[render_directory_active_areas] No areas defined. Maybe template {template_id} is disabled.', array( 'data' => $template_id ) ); |
1235 | 1235 | $output = '<div>'; |
1236 | - $output .= '<h2 class="description" style="font-size: 16px; margin:0">'. sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>'.$template_id.'</em>' ) .'</h2>'; |
|
1237 | - $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">'.esc_html__('The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview').'</p>'; |
|
1236 | + $output .= '<h2 class="description" style="font-size: 16px; margin:0">' . sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>' . $template_id . '</em>' ) . '</h2>'; |
|
1237 | + $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">' . esc_html__( 'The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview' ) . '</p>'; |
|
1238 | 1238 | $output .= '</div>'; |
1239 | 1239 | } else { |
1240 | 1240 | |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | } |
1251 | 1251 | |
1252 | - if( $echo ) { |
|
1252 | + if ( $echo ) { |
|
1253 | 1253 | echo $output; |
1254 | 1254 | } |
1255 | 1255 | |
@@ -1277,18 +1277,18 @@ discard block |
||
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | // Add the GV font (with the Astronaut) |
1280 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version ); |
|
1280 | + wp_enqueue_style( 'gravityview_global', plugins_url( 'assets/css/admin-global.css', GRAVITYVIEW_FILE ), array(), \GV\Plugin::$version ); |
|
1281 | 1281 | wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version ); |
1282 | 1282 | |
1283 | - wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true ); |
|
1283 | + wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), \GV\Plugin::$version, true ); |
|
1284 | 1284 | |
1285 | - if( GFForms::get_page() === 'form_list' ) { |
|
1285 | + if ( GFForms::get_page() === 'form_list' ) { |
|
1286 | 1286 | wp_enqueue_style( 'gravityview_views_styles' ); |
1287 | 1287 | return; |
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 | // Don't process any scripts below here if it's not a GravityView page. |
1291 | - if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) { |
|
1291 | + if ( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) { |
|
1292 | 1292 | return; |
1293 | 1293 | } |
1294 | 1294 | |
@@ -1296,15 +1296,15 @@ discard block |
||
1296 | 1296 | |
1297 | 1297 | wp_enqueue_script( 'jquery-ui-datepicker' ); |
1298 | 1298 | |
1299 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version ); |
|
1299 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url( 'assets/css/admin-datepicker.css', GRAVITYVIEW_FILE ), \GV\Plugin::$version ); |
|
1300 | 1300 | |
1301 | 1301 | // Enqueue scripts |
1302 | 1302 | wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version ); |
1303 | 1303 | |
1304 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1304 | + wp_localize_script( 'gravityview_views_scripts', 'gvGlobals', array( |
|
1305 | 1305 | 'cookiepath' => COOKIEPATH, |
1306 | 1306 | 'admin_cookiepath' => ADMIN_COOKIE_PATH, |
1307 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1307 | + 'passed_form_id' => (bool)\GV\Utils::_GET( 'form_id' ), |
|
1308 | 1308 | 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
1309 | 1309 | 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
1310 | 1310 | 'label_reorder_search_fields' => __( 'Reorder Search Fields', 'gravityview' ), |
@@ -1319,7 +1319,7 @@ discard block |
||
1319 | 1319 | 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
1320 | 1320 | 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
1321 | 1321 | 'remove_all_fields' => __( 'Would you like to remove all fields in this zone?', 'gravityview' ), |
1322 | - )); |
|
1322 | + ) ); |
|
1323 | 1323 | |
1324 | 1324 | wp_enqueue_style( 'gravityview_views_styles' ); |
1325 | 1325 | |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | self::enqueue_gravity_forms_scripts(); |
1328 | 1328 | |
1329 | 1329 | // 2.5 changed how Merge Tags are enqueued |
1330 | - if ( is_callable( array( 'GFCommon', 'output_hooks_javascript') ) ) { |
|
1330 | + if ( is_callable( array( 'GFCommon', 'output_hooks_javascript' ) ) ) { |
|
1331 | 1331 | GFCommon::output_hooks_javascript(); |
1332 | 1332 | } |
1333 | 1333 | } |
@@ -1351,7 +1351,7 @@ discard block |
||
1351 | 1351 | ); |
1352 | 1352 | |
1353 | 1353 | if ( wp_is_mobile() ) { |
1354 | - $scripts[] = 'jquery-touch-punch'; |
|
1354 | + $scripts[ ] = 'jquery-touch-punch'; |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | wp_enqueue_script( $scripts ); |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | |
66 | 66 | add_shortcode( 'gv_note_add', array( 'GravityView_Field_Notes', 'get_add_note_part' ) ); |
67 | 67 | |
68 | - add_action( 'wp', array( $this, 'maybe_delete_notes'), 1000 ); |
|
69 | - add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
70 | - add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
68 | + add_action( 'wp', array( $this, 'maybe_delete_notes' ), 1000 ); |
|
69 | + add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
70 | + add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
71 | 71 | |
72 | - add_action( 'wp', array( $this, 'maybe_add_note'), 1000 ); |
|
73 | - add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note') ); |
|
74 | - add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note') ); |
|
72 | + add_action( 'wp', array( $this, 'maybe_add_note' ), 1000 ); |
|
73 | + add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
74 | + add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
75 | 75 | |
76 | 76 | // add template path to check for field |
77 | 77 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
78 | 78 | add_filter( 'gravityview/template/fields_template_paths', array( $this, 'add_template_path' ) ); |
79 | 79 | |
80 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
80 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
81 | 81 | add_action( 'gravityview/field/notes/scripts', array( $this, 'enqueue_scripts' ) ); |
82 | 82 | |
83 | 83 | add_filter( 'gravityview_entry_default_fields', array( $this, 'add_entry_default_field' ), 10, 3 ); |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function add_entry_default_field( $entry_default_fields, $form, $zone ) { |
101 | 101 | |
102 | - if( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
103 | - $entry_default_fields['notes'] = array( |
|
102 | + if ( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
103 | + $entry_default_fields[ 'notes' ] = array( |
|
104 | 104 | 'label' => __( 'Entry Notes', 'gravityview' ), |
105 | 105 | 'type' => 'notes', |
106 | 106 | 'desc' => __( 'Display, add, and delete notes for an entry.', 'gravityview' ), |
@@ -134,23 +134,23 @@ discard block |
||
134 | 134 | public function enqueue_scripts() { |
135 | 135 | global $wp_actions; |
136 | 136 | |
137 | - if( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
137 | + if ( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
138 | 138 | wp_enqueue_style( 'gravityview-notes' ); |
139 | 139 | wp_enqueue_script( 'gravityview-notes' ); |
140 | 140 | } |
141 | 141 | |
142 | - if( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
142 | + if ( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
143 | 143 | |
144 | 144 | $strings = self::strings(); |
145 | 145 | |
146 | 146 | wp_localize_script( 'gravityview-notes', 'GVNotes', array( |
147 | 147 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
148 | 148 | 'text' => array( |
149 | - 'processing' => $strings['processing'], |
|
150 | - 'delete_confirm' => $strings['delete-confirm'], |
|
151 | - 'note_added' => $strings['added-note'], |
|
152 | - 'error_invalid' => $strings['error-invalid'], |
|
153 | - 'error_empty_note' => $strings['error-empty-note'], |
|
149 | + 'processing' => $strings[ 'processing' ], |
|
150 | + 'delete_confirm' => $strings[ 'delete-confirm' ], |
|
151 | + 'note_added' => $strings[ 'added-note' ], |
|
152 | + 'error_invalid' => $strings[ 'error-invalid' ], |
|
153 | + 'error_empty_note' => $strings[ 'error-empty-note' ], |
|
154 | 154 | ), |
155 | 155 | ) ); |
156 | 156 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return void |
167 | 167 | */ |
168 | 168 | function maybe_add_note() { |
169 | - if ( ! isset( $_POST['action'] ) || 'gv_note_add' !== $_POST['action'] ) { |
|
169 | + if ( ! isset( $_POST[ 'action' ] ) || 'gv_note_add' !== $_POST[ 'action' ] ) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | $post = wp_unslash( $_POST ); |
180 | 180 | |
181 | 181 | if ( $this->doing_ajax ) { |
182 | - parse_str( $post['data'], $data ); |
|
182 | + parse_str( $post[ 'data' ], $data ); |
|
183 | 183 | } else { |
184 | 184 | $data = $post; |
185 | 185 | } |
186 | 186 | |
187 | - $this->process_add_note( (array) $data ); |
|
187 | + $this->process_add_note( (array)$data ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -210,23 +210,23 @@ discard block |
||
210 | 210 | $error = false; |
211 | 211 | $success = false; |
212 | 212 | |
213 | - if( empty( $data['entry-slug'] ) ) { |
|
213 | + if ( empty( $data[ 'entry-slug' ] ) ) { |
|
214 | 214 | |
215 | - $error = self::strings('error-invalid'); |
|
215 | + $error = self::strings( 'error-invalid' ); |
|
216 | 216 | gravityview()->log->error( 'The note is missing an Entry ID.' ); |
217 | 217 | |
218 | 218 | } else { |
219 | 219 | |
220 | - $valid = wp_verify_nonce( $data['gv_note_add'], 'gv_note_add_' . $data['entry-slug'] ); |
|
220 | + $valid = wp_verify_nonce( $data[ 'gv_note_add' ], 'gv_note_add_' . $data[ 'entry-slug' ] ); |
|
221 | 221 | |
222 | 222 | $has_cap = GVCommon::has_cap( 'gravityview_add_entry_notes' ); |
223 | 223 | |
224 | - if( ! $has_cap ) { |
|
224 | + if ( ! $has_cap ) { |
|
225 | 225 | $error = self::strings( 'error-cap-add' ); |
226 | 226 | gravityview()->log->error( 'Adding a note failed: the user does not have the "gravityview_add_entry_notes" capability.' ); |
227 | 227 | } elseif ( $valid ) { |
228 | 228 | |
229 | - $entry = gravityview_get_entry( $data['entry-slug'], true, false ); |
|
229 | + $entry = gravityview_get_entry( $data[ 'entry-slug' ], true, false ); |
|
230 | 230 | |
231 | 231 | $added = $this->add_note( $entry, $data ); |
232 | 232 | |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | $this->maybe_send_entry_notes( $note, $entry, $data ); |
245 | 245 | |
246 | 246 | if ( $note ) { |
247 | - $success = self::display_note( $note, ! empty( $data['show-delete'] ) ); |
|
247 | + $success = self::display_note( $note, ! empty( $data[ 'show-delete' ] ) ); |
|
248 | 248 | gravityview()->log->debug( 'The note was successfully created', array( 'data' => compact( 'note', 'data' ) ) ); |
249 | 249 | } else { |
250 | - $error = self::strings('error-add-note'); |
|
250 | + $error = self::strings( 'error-add-note' ); |
|
251 | 251 | gravityview()->log->error( 'The note was not successfully created', array( 'data' => compact( 'note', 'data' ) ) ); |
252 | 252 | } |
253 | 253 | } |
254 | 254 | } else { |
255 | - $error = self::strings('error-invalid'); |
|
255 | + $error = self::strings( 'error-invalid' ); |
|
256 | 256 | gravityview()->log->error( 'Nonce validation failed; the note was not created' ); |
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | 260 | |
261 | - if( $this->doing_ajax ) { |
|
262 | - if( $success ) { |
|
261 | + if ( $this->doing_ajax ) { |
|
262 | + if ( $success ) { |
|
263 | 263 | wp_send_json_success( array( 'html' => $success ) ); |
264 | 264 | } else { |
265 | 265 | $error = $error ? $error : self::strings( 'error-invalid' ); |
@@ -285,11 +285,11 @@ discard block |
||
285 | 285 | return; |
286 | 286 | } |
287 | 287 | |
288 | - if ( isset( $_POST['action'] ) && 'gv_delete_notes' === $_POST['action'] ) { |
|
288 | + if ( isset( $_POST[ 'action' ] ) && 'gv_delete_notes' === $_POST[ 'action' ] ) { |
|
289 | 289 | |
290 | 290 | $post = wp_unslash( $_POST ); |
291 | 291 | if ( $this->doing_ajax ) { |
292 | - parse_str( $post['data'], $data ); |
|
292 | + parse_str( $post[ 'data' ], $data ); |
|
293 | 293 | } else { |
294 | 294 | $data = $post; |
295 | 295 | } |
@@ -320,18 +320,18 @@ discard block |
||
320 | 320 | */ |
321 | 321 | function process_delete_notes( $data ) { |
322 | 322 | |
323 | - $valid = wp_verify_nonce( $data['gv_delete_notes'], 'gv_delete_notes_' . $data['entry-slug'] ); |
|
323 | + $valid = wp_verify_nonce( $data[ 'gv_delete_notes' ], 'gv_delete_notes_' . $data[ 'entry-slug' ] ); |
|
324 | 324 | $has_cap = GVCommon::has_cap( 'gravityview_delete_entry_notes' ); |
325 | 325 | $success = false; |
326 | 326 | |
327 | 327 | if ( $valid && $has_cap ) { |
328 | - GravityView_Entry_Notes::delete_notes( $data['note'] ); |
|
328 | + GravityView_Entry_Notes::delete_notes( $data[ 'note' ] ); |
|
329 | 329 | $success = true; |
330 | 330 | } |
331 | 331 | |
332 | - if( $this->doing_ajax ) { |
|
332 | + if ( $this->doing_ajax ) { |
|
333 | 333 | |
334 | - if( $success ) { |
|
334 | + if ( $success ) { |
|
335 | 335 | wp_send_json_success(); |
336 | 336 | } else { |
337 | 337 | if ( ! $valid ) { |
@@ -364,13 +364,13 @@ discard block |
||
364 | 364 | |
365 | 365 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
366 | 366 | |
367 | - unset( $field_options['show_as_link'] ); |
|
367 | + unset( $field_options[ 'show_as_link' ] ); |
|
368 | 368 | |
369 | 369 | $notes_options = array( |
370 | 370 | 'notes' => array( |
371 | 371 | 'type' => 'checkboxes', |
372 | - 'label' => __('Note Settings', 'gravityview'), |
|
373 | - 'desc' => sprintf( _x('Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
372 | + 'label' => __( 'Note Settings', 'gravityview' ), |
|
373 | + 'desc' => sprintf( _x( 'Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
374 | 374 | 'options' => array( |
375 | 375 | 'view' => array( |
376 | 376 | 'label' => __( 'Display notes?', 'gravityview' ), |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | 'processing' => __( 'Processing…', 'gravityview' ), |
423 | 423 | 'other-email' => __( 'Other email address', 'gravityview' ), |
424 | 424 | 'email-label' => __( 'Email address', 'gravityview' ), |
425 | - 'email-placeholder' => _x('[email protected]', 'Example email address used as a placeholder', 'gravityview'), |
|
425 | + 'email-placeholder' => _x( '[email protected]', 'Example email address used as a placeholder', 'gravityview' ), |
|
426 | 426 | 'subject-label' => __( 'Subject', 'gravityview' ), |
427 | 427 | 'subject' => __( 'Email subject', 'gravityview' ), |
428 | 428 | 'default-email-subject' => __( 'New entry note', 'gravityview' ), |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | */ |
443 | 443 | $strings = gv_map_deep( apply_filters( 'gravityview/field/notes/strings', $strings ), 'esc_html' ); |
444 | 444 | |
445 | - if( $key ) { |
|
445 | + if ( $key ) { |
|
446 | 446 | return isset( $strings[ $key ] ) ? $strings[ $key ] : ''; |
447 | 447 | } |
448 | 448 | |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | */ |
465 | 465 | static public function display_note( $note, $show_delete = false, $context = null ) { |
466 | 466 | |
467 | - if( ! is_object( $note ) ) { |
|
467 | + if ( ! is_object( $note ) ) { |
|
468 | 468 | return ''; |
469 | 469 | } |
470 | 470 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | } |
520 | 520 | |
521 | 521 | $replacements = array( |
522 | - '{note_id}' => $note_content['note_id'], |
|
522 | + '{note_id}' => $note_content[ 'note_id' ], |
|
523 | 523 | '{row_class}' => 'gv-note', |
524 | 524 | '{note_detail}' => $note_detail_html |
525 | 525 | ); |
@@ -551,13 +551,13 @@ discard block |
||
551 | 551 | |
552 | 552 | $user_data = get_userdata( $current_user->ID ); |
553 | 553 | |
554 | - $note_content = trim( $data['gv-note-content'] ); |
|
554 | + $note_content = trim( $data[ 'gv-note-content' ] ); |
|
555 | 555 | |
556 | - if( empty( $note_content ) ) { |
|
556 | + if ( empty( $note_content ) ) { |
|
557 | 557 | return new WP_Error( 'gv-add-note-empty', __( 'The note is empty.', 'gravityview' ) ); |
558 | 558 | } |
559 | 559 | |
560 | - $return = GravityView_Entry_Notes::add_note( $entry['id'], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
560 | + $return = GravityView_Entry_Notes::add_note( $entry[ 'id' ], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
561 | 561 | |
562 | 562 | return $return; |
563 | 563 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | |
578 | 578 | $atts = shortcode_atts( array( 'entry' => null ), $atts ); |
579 | 579 | |
580 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
580 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
581 | 581 | gravityview()->log->error( 'User does not have permission to add entry notes ("gravityview_add_entry_notes").' ); |
582 | 582 | return ''; |
583 | 583 | } |
@@ -599,8 +599,8 @@ discard block |
||
599 | 599 | |
600 | 600 | $visibility_settings = $gravityview_view->getCurrentFieldSetting( 'notes' ); |
601 | 601 | |
602 | - if ( $atts['entry'] ) { |
|
603 | - $entry = GFAPI::get_entry( $atts['entry'] ); |
|
602 | + if ( $atts[ 'entry' ] ) { |
|
603 | + $entry = GFAPI::get_entry( $atts[ 'entry' ] ); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | if ( ! isset( $entry ) || ! $entry ) { |
@@ -618,14 +618,14 @@ discard block |
||
618 | 618 | |
619 | 619 | // Only generate the dropdown if the field settings allow it |
620 | 620 | $email_fields = ''; |
621 | - if( ! empty( $visibility_settings['email'] ) ) { |
|
621 | + if ( ! empty( $visibility_settings[ 'email' ] ) ) { |
|
622 | 622 | $email_fields = self::get_note_email_fields( $entry_slug ); |
623 | 623 | } |
624 | 624 | |
625 | 625 | $add_note_html = str_replace( '{entry_slug}', $entry_slug, $add_note_html ); |
626 | 626 | $add_note_html = str_replace( '{nonce_field}', $nonce_field, $add_note_html ); |
627 | - $add_note_html = str_replace( '{show_delete}', intval( empty( $visibility_settings['delete'] ) ? 0 : $visibility_settings['delete'] ), $add_note_html ); |
|
628 | - $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
627 | + $add_note_html = str_replace( '{show_delete}', intval( empty( $visibility_settings[ 'delete' ] ) ? 0 : $visibility_settings[ 'delete' ] ), $add_note_html ); |
|
628 | + $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
629 | 629 | $add_note_html = str_replace( '{url}', esc_url_raw( add_query_arg( array() ) ), $add_note_html ); |
630 | 630 | |
631 | 631 | return $add_note_html; |
@@ -650,8 +650,8 @@ discard block |
||
650 | 650 | $note_emails = array(); |
651 | 651 | |
652 | 652 | foreach ( $email_fields as $email_field ) { |
653 | - if ( ! empty( $entry["{$email_field->id}"] ) && is_email( $entry["{$email_field->id}"] ) ) { |
|
654 | - $note_emails[] = $entry["{$email_field->id}"]; |
|
653 | + if ( ! empty( $entry[ "{$email_field->id}" ] ) && is_email( $entry[ "{$email_field->id}" ] ) ) { |
|
654 | + $note_emails[ ] = $entry[ "{$email_field->id}" ]; |
|
655 | 655 | } |
656 | 656 | } |
657 | 657 | |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | */ |
664 | 664 | $note_emails = apply_filters( 'gravityview/field/notes/emails', $note_emails, $entry ); |
665 | 665 | |
666 | - return (array) $note_emails; |
|
666 | + return (array)$note_emails; |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | */ |
680 | 680 | private static function get_note_email_fields( $entry_slug = '' ) { |
681 | 681 | |
682 | - if( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
682 | + if ( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
683 | 683 | gravityview()->log->error( 'User does not have permission to email entry notes ("gravityview_email_entry_notes").' ); |
684 | 684 | return ''; |
685 | 685 | } |
@@ -701,27 +701,27 @@ discard block |
||
701 | 701 | |
702 | 702 | if ( ! empty( $note_emails ) || $include_custom ) { ?> |
703 | 703 | <div class="gv-note-email-container"> |
704 | - <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings['also-email']; ?></label> |
|
704 | + <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings[ 'also-email' ]; ?></label> |
|
705 | 705 | <select class="gv-note-email-to" name="gv-note-to" id="gv-note-email-to-<?php echo $entry_slug_esc; ?>"> |
706 | - <option value=""><?php echo $strings['also-email']; ?></option> |
|
706 | + <option value=""><?php echo $strings[ 'also-email' ]; ?></option> |
|
707 | 707 | <?php foreach ( $note_emails as $email ) { |
708 | 708 | ?> |
709 | 709 | <option value="<?php echo esc_attr( $email ); ?>"><?php echo esc_html( $email ); ?></option> |
710 | 710 | <?php } |
711 | - if( $include_custom ) { ?> |
|
712 | - <option value="custom"><?php echo self::strings('other-email'); ?></option> |
|
711 | + if ( $include_custom ) { ?> |
|
712 | + <option value="custom"><?php echo self::strings( 'other-email' ); ?></option> |
|
713 | 713 | <?php } ?> |
714 | 714 | </select> |
715 | 715 | <fieldset class="gv-note-to-container"> |
716 | - <?php if( $include_custom ) { ?> |
|
716 | + <?php if ( $include_custom ) { ?> |
|
717 | 717 | <div class='gv-note-to-custom-container'> |
718 | - <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings['email-label']; ?></label> |
|
719 | - <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings['email-placeholder']; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
718 | + <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'email-label' ]; ?></label> |
|
719 | + <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings[ 'email-placeholder' ]; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
720 | 720 | </div> |
721 | 721 | <?php } ?> |
722 | 722 | <div class='gv-note-subject-container'> |
723 | - <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings['subject-label']; ?></label> |
|
724 | - <input type="text" name="gv-note-subject" placeholder="<?php echo $strings['subject']; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
723 | + <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'subject-label' ]; ?></label> |
|
724 | + <input type="text" name="gv-note-subject" placeholder="<?php echo $strings[ 'subject' ]; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
725 | 725 | </div> |
726 | 726 | </fieldset> |
727 | 727 | </div> |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | */ |
745 | 745 | private function maybe_send_entry_notes( $note = false, $entry = array(), $data = array() ) { |
746 | 746 | |
747 | - if( ! $note || ! GVCommon::has_cap('gravityview_email_entry_notes') ) { |
|
747 | + if ( ! $note || ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
748 | 748 | gravityview()->log->debug( 'User doesn\'t have "gravityview_email_entry_notes" cap, or $note is empty', array( 'data' => $note ) ); |
749 | 749 | return; |
750 | 750 | } |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | gravityview()->log->debug( '$data', array( 'data' => $data ) ); |
753 | 753 | |
754 | 754 | //emailing notes if configured |
755 | - if ( ! empty( $data['gv-note-to'] ) ) { |
|
755 | + if ( ! empty( $data[ 'gv-note-to' ] ) ) { |
|
756 | 756 | |
757 | 757 | $default_data = array( |
758 | 758 | 'gv-note-to' => '', |
@@ -762,11 +762,11 @@ discard block |
||
762 | 762 | 'current-url' => '', |
763 | 763 | ); |
764 | 764 | |
765 | - $current_user = wp_get_current_user(); |
|
765 | + $current_user = wp_get_current_user(); |
|
766 | 766 | $email_data = wp_parse_args( $data, $default_data ); |
767 | 767 | |
768 | - $from = $current_user->user_email; |
|
769 | - $to = $email_data['gv-note-to']; |
|
768 | + $from = $current_user->user_email; |
|
769 | + $to = $email_data[ 'gv-note-to' ]; |
|
770 | 770 | |
771 | 771 | /** |
772 | 772 | * Documented in get_note_email_fields |
@@ -774,8 +774,8 @@ discard block |
||
774 | 774 | */ |
775 | 775 | $include_custom = apply_filters( 'gravityview/field/notes/custom-email', true ); |
776 | 776 | |
777 | - if( 'custom' === $to && $include_custom ) { |
|
778 | - $to = $email_data['gv-note-to-custom']; |
|
777 | + if ( 'custom' === $to && $include_custom ) { |
|
778 | + $to = $email_data[ 'gv-note-to-custom' ]; |
|
779 | 779 | gravityview()->log->debug( 'Sending note to a custom email address: {to}', array( 'to' => $to ) ); |
780 | 780 | } |
781 | 781 | |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | |
787 | 787 | $bcc = false; |
788 | 788 | $reply_to = $from; |
789 | - $subject = trim( $email_data['gv-note-subject'] ); |
|
789 | + $subject = trim( $email_data[ 'gv-note-subject' ] ); |
|
790 | 790 | |
791 | 791 | // We use empty() here because GF uses empty to check against, too. `0` isn't a valid subject to GF |
792 | 792 | $subject = empty( $subject ) ? self::strings( 'default-email-subject' ) : $subject; |
793 | - $message = $email_data['gv-note-content']; |
|
793 | + $message = $email_data[ 'gv-note-content' ]; |
|
794 | 794 | $email_footer = self::strings( 'email-footer' ); |
795 | - $from_name = $current_user->display_name; |
|
795 | + $from_name = $current_user->display_name; |
|
796 | 796 | $message_format = 'html'; |
797 | 797 | |
798 | 798 | /** |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | |
824 | 824 | GVCommon::send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, '', $entry, false ); |
825 | 825 | |
826 | - $form = isset( $entry['form_id'] ) ? GFAPI::get_form( $entry['form_id'] ) : array(); |
|
826 | + $form = isset( $entry[ 'form_id' ] ) ? GFAPI::get_form( $entry[ 'form_id' ] ) : array(); |
|
827 | 827 | |
828 | 828 | /** |
829 | 829 | * @see https://www.gravityhelp.com/documentation/article/10146-2/ It's here for compatibility with Gravity Forms |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | |
850 | 850 | $output = ''; |
851 | 851 | |
852 | - if( ! empty( $email_footer ) ) { |
|
852 | + if ( ! empty( $email_footer ) ) { |
|
853 | 853 | $url = \GV\Utils::get( $email_data, 'current-url' ); |
854 | 854 | $url = html_entity_decode( $url ); |
855 | 855 | $url = site_url( $url ); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | $gv_bulk_action = false; |
56 | 56 | |
57 | - if( version_compare( GFForms::$version, '2.0', '>=' ) ) { |
|
57 | + if ( version_compare( GFForms::$version, '2.0', '>=' ) ) { |
|
58 | 58 | $bulk_action = ( '-1' !== \GV\Utils::_POST( 'action' ) ) ? \GV\Utils::_POST( 'action' ) : \GV\Utils::_POST( 'action2' ); |
59 | 59 | } else { |
60 | 60 | // GF 1.9.x - Bulk action 2 is the bottom bulk action select form. |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | // Check the $bulk_action value against GV actions, see if they're the same. I hate strpos(). |
65 | - if( ! empty( $bulk_action ) && preg_match( '/^('. implode( '|', self::$bulk_action_prefixes ) .')/ism', $bulk_action ) ) { |
|
65 | + if ( ! empty( $bulk_action ) && preg_match( '/^(' . implode( '|', self::$bulk_action_prefixes ) . ')/ism', $bulk_action ) ) { |
|
66 | 66 | $gv_bulk_action = $bulk_action; |
67 | 67 | } |
68 | 68 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | // gforms_entry_list is the nonce that confirms we're on the right page |
88 | 88 | // gforms_update_note is sent when bulk editing entry notes. We don't want to process then. |
89 | - if ( ! ( $bulk_action && \GV\Utils::_POST( 'gforms_entry_list' ) && empty( $_POST['gforms_update_note'] ) ) ) { |
|
89 | + if ( ! ( $bulk_action && \GV\Utils::_POST( 'gforms_entry_list' ) && empty( $_POST[ 'gforms_update_note' ] ) ) ) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | // All entries are set to be updated, not just the visible ones |
109 | - if ( ! empty( $_POST['all_entries'] ) ) { |
|
109 | + if ( ! empty( $_POST[ 'all_entries' ] ) ) { |
|
110 | 110 | |
111 | 111 | // Convert the current entry search into GF-formatted search criteria |
112 | 112 | $search = array( |
113 | - 'search_field' => isset( $_POST['f'] ) ? $_POST['f'][0] : 0, |
|
114 | - 'search_value' => isset( $_POST['v'][0] ) ? $_POST['v'][0] : '', |
|
115 | - 'search_operator' => isset( $_POST['o'][0] ) ? $_POST['o'][0] : 'contains', |
|
113 | + 'search_field' => isset( $_POST[ 'f' ] ) ? $_POST[ 'f' ][ 0 ] : 0, |
|
114 | + 'search_value' => isset( $_POST[ 'v' ][ 0 ] ) ? $_POST[ 'v' ][ 0 ] : '', |
|
115 | + 'search_operator' => isset( $_POST[ 'o' ][ 0 ] ) ? $_POST[ 'o' ][ 0 ] : 'contains', |
|
116 | 116 | ); |
117 | 117 | |
118 | 118 | $search_criteria = GravityView_frontend::get_search_criteria( $search, $form_id ); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } else { |
124 | 124 | |
125 | 125 | // Changed from 'lead' to 'entry' in 2.0 |
126 | - $entries = isset( $_POST['lead'] ) ? $_POST['lead'] : $_POST['entry']; |
|
126 | + $entries = isset( $_POST[ 'lead' ] ) ? $_POST[ 'lead' ] : $_POST[ 'entry' ]; |
|
127 | 127 | |
128 | 128 | } |
129 | 129 | |
@@ -135,15 +135,15 @@ discard block |
||
135 | 135 | $entry_count = count( $entries ) > 1 ? sprintf( __( '%d entries', 'gravityview' ), count( $entries ) ) : __( '1 entry', 'gravityview' ); |
136 | 136 | |
137 | 137 | switch ( $approved_status ) { |
138 | - case self::$bulk_action_prefixes['approve']: |
|
138 | + case self::$bulk_action_prefixes[ 'approve' ]: |
|
139 | 139 | GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::APPROVED, $form_id ); |
140 | 140 | self::$bulk_update_message = sprintf( __( '%s approved.', 'gravityview' ), $entry_count ); |
141 | 141 | break; |
142 | - case self::$bulk_action_prefixes['unapprove']: |
|
142 | + case self::$bulk_action_prefixes[ 'unapprove' ]: |
|
143 | 143 | GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::UNAPPROVED, $form_id ); |
144 | 144 | self::$bulk_update_message = sprintf( __( '%s unapproved.', 'gravityview' ), $entry_count ); |
145 | 145 | break; |
146 | - case self::$bulk_action_prefixes['disapprove']: |
|
146 | + case self::$bulk_action_prefixes[ 'disapprove' ]: |
|
147 | 147 | GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::DISAPPROVED, $form_id ); |
148 | 148 | self::$bulk_update_message = sprintf( __( '%s disapproved.', 'gravityview' ), $entry_count ); |
149 | 149 | break; |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | $bulk_actions = array( |
166 | 166 | 'GravityView' => array( |
167 | 167 | array( |
168 | - 'label' => GravityView_Entry_Approval_Status::get_string('approved', 'action'), |
|
169 | - 'value' => sprintf( '%s-%d', self::$bulk_action_prefixes['approve'], $form_id ), |
|
168 | + 'label' => GravityView_Entry_Approval_Status::get_string( 'approved', 'action' ), |
|
169 | + 'value' => sprintf( '%s-%d', self::$bulk_action_prefixes[ 'approve' ], $form_id ), |
|
170 | 170 | ), |
171 | 171 | array( |
172 | - 'label' => GravityView_Entry_Approval_Status::get_string('disapproved', 'action'), |
|
173 | - 'value' => sprintf( '%s-%d', self::$bulk_action_prefixes['disapprove'], $form_id ), |
|
172 | + 'label' => GravityView_Entry_Approval_Status::get_string( 'disapproved', 'action' ), |
|
173 | + 'value' => sprintf( '%s-%d', self::$bulk_action_prefixes[ 'disapprove' ], $form_id ), |
|
174 | 174 | ), |
175 | 175 | array( |
176 | - 'label' => GravityView_Entry_Approval_Status::get_string('unapproved', 'action'), |
|
177 | - 'value' => sprintf( '%s-%d', self::$bulk_action_prefixes['unapprove'], $form_id ), |
|
176 | + 'label' => GravityView_Entry_Approval_Status::get_string( 'unapproved', 'action' ), |
|
177 | + 'value' => sprintf( '%s-%d', self::$bulk_action_prefixes[ 'unapprove' ], $form_id ), |
|
178 | 178 | ), |
179 | 179 | ), |
180 | 180 | ); |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | // Sanitize the values, just to be sure. |
192 | 192 | foreach ( $bulk_actions as $key => $group ) { |
193 | 193 | |
194 | - if( empty( $group ) ) { |
|
194 | + if ( empty( $group ) ) { |
|
195 | 195 | continue; |
196 | 196 | } |
197 | 197 | |
198 | 198 | foreach ( $group as $i => $action ) { |
199 | - $bulk_actions[ $key ][ $i ]['label'] = esc_html( $bulk_actions[ $key ][ $i ]['label'] ); |
|
200 | - $bulk_actions[ $key ][ $i ]['value'] = esc_attr( $bulk_actions[ $key ][ $i ]['value'] ); |
|
199 | + $bulk_actions[ $key ][ $i ][ 'label' ] = esc_html( $bulk_actions[ $key ][ $i ][ 'label' ] ); |
|
200 | + $bulk_actions[ $key ][ $i ][ 'value' ] = esc_attr( $bulk_actions[ $key ][ $i ][ 'value' ] ); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | */ |
48 | 48 | $atts = apply_filters( 'gravityview/shortcodes/gventry/atts', $atts ); |
49 | 49 | |
50 | - $view = \GV\View::by_id( $atts['view_id'] ); |
|
50 | + $view = \GV\View::by_id( $atts[ 'view_id' ] ); |
|
51 | 51 | |
52 | 52 | if ( ! $view ) { |
53 | - gravityview()->log->error( 'View does not exist #{view_id}', array( 'view_id' => $atts['view_id'] ) ); |
|
53 | + gravityview()->log->error( 'View does not exist #{view_id}', array( 'view_id' => $atts[ 'view_id' ] ) ); |
|
54 | 54 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', null, null, $atts ); |
55 | 55 | } |
56 | 56 | |
57 | - $entry_id = ! empty( $atts['entry_id'] ) ? $atts['entry_id'] : $atts['id']; |
|
57 | + $entry_id = ! empty( $atts[ 'entry_id' ] ) ? $atts[ 'entry_id' ] : $atts[ 'id' ]; |
|
58 | 58 | |
59 | - switch( $entry_id ): |
|
59 | + switch ( $entry_id ): |
|
60 | 60 | case 'last': |
61 | 61 | if ( class_exists( '\GF_Query' ) ) { |
62 | 62 | /** |
@@ -65,17 +65,17 @@ discard block |
||
65 | 65 | * Since we're using \GF_Query shorthand initialization we have to reverse the order parameters here. |
66 | 66 | */ |
67 | 67 | add_filter( 'gravityview_get_entries', $filter = function( $parameters, $args, $form_id ) { |
68 | - if ( ! empty( $parameters['sorting'] ) ) { |
|
68 | + if ( ! empty( $parameters[ 'sorting' ] ) ) { |
|
69 | 69 | /** |
70 | 70 | * Reverse existing sorts. |
71 | 71 | */ |
72 | - $sort = &$parameters['sorting']; |
|
73 | - $sort['direction'] = $sort['direction'] == 'RAND' ? : ( $sort['direction'] == 'ASC' ? 'DESC' : 'ASC' ); |
|
72 | + $sort = &$parameters[ 'sorting' ]; |
|
73 | + $sort[ 'direction' ] = $sort[ 'direction' ] == 'RAND' ?: ( $sort[ 'direction' ] == 'ASC' ? 'DESC' : 'ASC' ); |
|
74 | 74 | } else { |
75 | 75 | /** |
76 | 76 | * Otherwise, sort by date_created. |
77 | 77 | */ |
78 | - $parameters['sorting'] = array( |
|
78 | + $parameters[ 'sorting' ] = array( |
|
79 | 79 | 'key' => 'id', |
80 | 80 | 'direction' => 'ASC', |
81 | 81 | 'is_numeric' => true |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | /** If a sort already exists, reverse it. */ |
92 | 92 | if ( $sort = end( $entries->sorts ) ) { |
93 | - $entries = $entries->sort( new \GV\Entry_Sort( $sort->field, $sort->direction == \GV\Entry_Sort::RAND ? : ( $sort->direction == \GV\Entry_Sort::ASC ? \GV\Entry_Sort::DESC : \GV\Entry_Sort::ASC ) ), $sort->mode ); |
|
93 | + $entries = $entries->sort( new \GV\Entry_Sort( $sort->field, $sort->direction == \GV\Entry_Sort::RAND ?: ( $sort->direction == \GV\Entry_Sort::ASC ? \GV\Entry_Sort::DESC : \GV\Entry_Sort::ASC ) ), $sort->mode ); |
|
94 | 94 | } else { |
95 | 95 | /** Otherwise, sort by date_created */ |
96 | 96 | $entries = $entries->sort( new \GV\Entry_Sort( \GV\Internal_Field::by_id( 'id' ), \GV\Entry_Sort::ASC ), \GV\Entry_Sort::NUMERIC ); |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | break; |
109 | 109 | default: |
110 | 110 | if ( ! $entry = \GV\GF_Entry::by_id( $entry_id ) ) { |
111 | - gravityview()->log->error( 'Entry #{entry_id} not found', array( 'view_id' => $atts['view_id'] ) ); |
|
111 | + gravityview()->log->error( 'Entry #{entry_id} not found', array( 'view_id' => $atts[ 'view_id' ] ) ); |
|
112 | 112 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, null, $atts ); |
113 | 113 | } |
114 | 114 | endswitch; |
115 | 115 | |
116 | - if ( $view->form->ID != $entry['form_id'] ) { |
|
116 | + if ( $view->form->ID != $entry[ 'form_id' ] ) { |
|
117 | 117 | gravityview()->log->error( 'Entry does not belong to view (form mismatch)' ); |
118 | 118 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts ); |
119 | 119 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | return apply_filters( 'gravityview/shortcodes/gventry/output', get_the_password_form( $view->ID ), $view, $entry, $atts ); |
124 | 124 | } |
125 | 125 | |
126 | - if ( ! $view->form ) { |
|
126 | + if ( ! $view->form ) { |
|
127 | 127 | gravityview()->log->notice( 'View #{id} has no form attached to it.', array( 'id' => $view->ID ) ); |
128 | 128 | |
129 | 129 | /** |
@@ -146,50 +146,50 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | /** Unapproved entries. */ |
149 | - if ( $entry['status'] != 'active' ) { |
|
149 | + if ( $entry[ 'status' ] != 'active' ) { |
|
150 | 150 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
151 | 151 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts ); |
152 | 152 | } |
153 | 153 | |
154 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
154 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
155 | 155 | |
156 | 156 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
157 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
157 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
158 | 158 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
159 | 159 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts ); |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | 163 | if ( \GV\Utils::get( $_GET, 'edit' ) && \GV\Utils::get( $_GET, 'gvid' ) ) { |
164 | - $atts['edit'] = 1; |
|
164 | + $atts[ 'edit' ] = 1; |
|
165 | 165 | } |
166 | 166 | |
167 | - if ( $atts['edit'] ) { |
|
167 | + if ( $atts[ 'edit' ] ) { |
|
168 | 168 | /** |
169 | 169 | * Based on code in our unit-tests. |
170 | 170 | * Mocks old context, etc. |
171 | 171 | */ |
172 | 172 | $loader = \GravityView_Edit_Entry::getInstance(); |
173 | - $render = $loader->instances['render']; |
|
173 | + $render = $loader->instances[ 'render' ]; |
|
174 | 174 | |
175 | 175 | add_filter( 'gravityview/is_single_entry', '__return_true' ); |
176 | 176 | |
177 | - $form = \GFAPI::get_form( $entry['form_id'] ); |
|
177 | + $form = \GFAPI::get_form( $entry[ 'form_id' ] ); |
|
178 | 178 | |
179 | 179 | $data = \GravityView_View_Data::getInstance( $view ); |
180 | 180 | $template = \GravityView_View::getInstance( array( |
181 | 181 | 'form' => $form, |
182 | - 'form_id' => $form['id'], |
|
182 | + 'form_id' => $form[ 'id' ], |
|
183 | 183 | 'view_id' => $view->ID, |
184 | 184 | 'entries' => array( $entry ), |
185 | 185 | 'atts' => \GVCommon::get_template_settings( $view->ID ), |
186 | 186 | ) ); |
187 | 187 | |
188 | - $_GET['edit'] = wp_create_nonce( |
|
189 | - \GravityView_Edit_Entry::get_nonce_key( $view->ID, $form['id'], $entry['id'] ) |
|
188 | + $_GET[ 'edit' ] = wp_create_nonce( |
|
189 | + \GravityView_Edit_Entry::get_nonce_key( $view->ID, $form[ 'id' ], $entry[ 'id' ] ) |
|
190 | 190 | ); |
191 | 191 | |
192 | - add_filter( 'gravityview/edit_entry/success', $callback = function ( $message, $_view_id, $_entry, $back_link, $redirect_url ) use ( $view, $entry, $atts ) { |
|
192 | + add_filter( 'gravityview/edit_entry/success', $callback = function( $message, $_view_id, $_entry, $back_link, $redirect_url ) use ( $view, $entry, $atts ) { |
|
193 | 193 | /** |
194 | 194 | * @filter `gravityview/shortcodes/gventry/edit/success` Modify the edit entry success message in [gventry]. |
195 | 195 | * |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | return apply_filters( 'gravityview/shortcodes/gventry/edit/success', $message, $view, $entry, $atts, $back_link, $redirect_url ); |
206 | 206 | }, 10, 5 ); |
207 | 207 | |
208 | - ob_start() && $render->init( $data, \GV\GF_Entry::by_id( $entry['id'] ), $view ); |
|
208 | + ob_start() && $render->init( $data, \GV\GF_Entry::by_id( $entry[ 'id' ] ), $view ); |
|
209 | 209 | $output = ob_get_clean(); // Render :) |
210 | 210 | |
211 | 211 | remove_filter( 'gravityview/is_single_entry', '__return_true' ); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $renderer = new \GV\Entry_Renderer(); |
218 | 218 | |
219 | 219 | $request = new \GV\Mock_Request(); |
220 | - $request->returns['is_entry'] = $entry; |
|
220 | + $request->returns[ 'is_entry' ] = $entry; |
|
221 | 221 | |
222 | 222 | $output = $renderer->render( $entry, $view, $request ); |
223 | 223 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | self::$file = plugin_dir_path( __FILE__ ); |
38 | 38 | |
39 | - if( is_admin() ) { |
|
39 | + if ( is_admin() ) { |
|
40 | 40 | $this->load_components( 'admin' ); |
41 | 41 | } |
42 | 42 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | static function getInstance() { |
58 | 58 | |
59 | - if( empty( self::$instance ) ) { |
|
59 | + if ( empty( self::$instance ) ) { |
|
60 | 60 | self::$instance = new GravityView_Edit_Entry; |
61 | 61 | } |
62 | 62 | |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | private function add_hooks() { |
83 | 83 | |
84 | 84 | // Add front-end access to Gravity Forms delete file action |
85 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( $this, 'delete_file') ); |
|
85 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( $this, 'delete_file' ) ); |
|
86 | 86 | |
87 | 87 | // Make sure this hook is run for non-admins |
88 | - add_action( 'wp_ajax_rg_delete_file', array( $this, 'delete_file') ); |
|
88 | + add_action( 'wp_ajax_rg_delete_file', array( $this, 'delete_file' ) ); |
|
89 | 89 | |
90 | 90 | add_filter( 'gravityview_blocklist_field_types', array( $this, 'modify_field_blocklist' ), 10, 2 ); |
91 | 91 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function add_reserved_arg( $args ) { |
110 | 110 | |
111 | - $args[] = 'edit'; |
|
111 | + $args[ ] = 'edit'; |
|
112 | 112 | |
113 | 113 | return $args; |
114 | 114 | } |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | */ |
120 | 120 | private function addon_specific_hooks() { |
121 | 121 | |
122 | - if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
123 | - add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script')); |
|
122 | + if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
123 | + add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | } |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
209 | 209 | |
210 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
210 | + $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] ); |
|
211 | 211 | |
212 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
212 | + $base = gv_entry_link( $entry, $post_id ?: $view_id ); |
|
213 | 213 | |
214 | 214 | $url = add_query_arg( array( |
215 | 215 | 'edit' => wp_create_nonce( $nonce_key ) |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | * Allow passing params to dynamically populate entry with values |
224 | 224 | * @since 1.9.2 |
225 | 225 | */ |
226 | - if( !empty( $field_values ) ) { |
|
226 | + if ( ! empty( $field_values ) ) { |
|
227 | 227 | |
228 | - if( is_array( $field_values ) ) { |
|
228 | + if ( is_array( $field_values ) ) { |
|
229 | 229 | // If already an array, no parse_str() needed |
230 | 230 | $params = $field_values; |
231 | 231 | } else { |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | */ |
274 | 274 | public function modify_field_blocklist( $fields = array(), $context = NULL ) { |
275 | 275 | |
276 | - if( empty( $context ) || $context !== 'edit' ) { |
|
276 | + if ( empty( $context ) || $context !== 'edit' ) { |
|
277 | 277 | return $fields; |
278 | 278 | } |
279 | 279 | |
@@ -370,15 +370,15 @@ discard block |
||
370 | 370 | // If they can edit any entries (as defined in Gravity Forms) |
371 | 371 | // Or if they can edit other people's entries |
372 | 372 | // Then we're good. |
373 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
373 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) { |
|
374 | 374 | |
375 | 375 | gravityview()->log->debug( 'User has ability to edit all entries.' ); |
376 | 376 | |
377 | 377 | $user_can_edit = true; |
378 | 378 | |
379 | - } else if( !isset( $entry['created_by'] ) ) { |
|
379 | + } else if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
380 | 380 | |
381 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
381 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
|
382 | 382 | |
383 | 383 | $user_can_edit = false; |
384 | 384 | |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | $current_user = wp_get_current_user(); |
388 | 388 | |
389 | 389 | // User edit is disabled |
390 | - if( empty( $user_edit ) ) { |
|
390 | + if ( empty( $user_edit ) ) { |
|
391 | 391 | |
392 | 392 | gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
393 | 393 | |
@@ -395,13 +395,13 @@ discard block |
||
395 | 395 | } |
396 | 396 | |
397 | 397 | // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
398 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
398 | + else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
399 | 399 | |
400 | 400 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
401 | 401 | |
402 | 402 | $user_can_edit = true; |
403 | 403 | |
404 | - } else if( ! is_user_logged_in() ) { |
|
404 | + } else if ( ! is_user_logged_in() ) { |
|
405 | 405 | |
406 | 406 | gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
407 | 407 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
421 | 421 | |
422 | - return (bool) $user_can_edit; |
|
422 | + return (bool)$user_can_edit; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | * @uses GFForms::delete_file() |
431 | 431 | */ |
432 | 432 | public function delete_file() { |
433 | - add_filter( 'user_has_cap', function ( $caps ) { |
|
434 | - $caps['gravityforms_delete_entries'] = true; |
|
433 | + add_filter( 'user_has_cap', function( $caps ) { |
|
434 | + $caps[ 'gravityforms_delete_entries' ] = true; |
|
435 | 435 | |
436 | 436 | return $caps; |
437 | 437 |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | function load() { |
136 | 136 | |
137 | 137 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
138 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
138 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
139 | 139 | |
140 | 140 | // Don't display an embedded form when editing an entry |
141 | 141 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | add_action( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
146 | 146 | add_action( 'admin_init', array( $this, 'prevent_maybe_process_form' ), 8 ); |
147 | 147 | |
148 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
148 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
149 | 149 | |
150 | 150 | add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 ); |
151 | 151 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
157 | 157 | |
158 | 158 | // Add fields expected by GFFormDisplay::validate() |
159 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
159 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
160 | 160 | |
161 | 161 | // Fix multiselect value for GF 2.2 |
162 | 162 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | public function prevent_render_form() { |
176 | - if( $this->is_edit_entry() ) { |
|
177 | - if( 'wp_head' === current_filter() ) { |
|
176 | + if ( $this->is_edit_entry() ) { |
|
177 | + if ( 'wp_head' === current_filter() ) { |
|
178 | 178 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
179 | 179 | } else { |
180 | 180 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -189,17 +189,17 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function prevent_maybe_process_form() { |
191 | 191 | |
192 | - if( ! $this->is_edit_entry_submission() ) { |
|
192 | + if ( ! $this->is_edit_entry_submission() ) { |
|
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
196 | 196 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' ); |
197 | 197 | |
198 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
199 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
198 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
199 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
200 | 200 | |
201 | - remove_action( 'admin_init', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
202 | - remove_action( 'admin_init', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
201 | + remove_action( 'admin_init', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
202 | + remove_action( 'admin_init', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | $is_edit_entry = |
212 | 212 | ( GravityView_frontend::is_single_entry() || gravityview()->request->is_entry() ) |
213 | - && ( ! empty( $_GET['edit'] ) ); |
|
213 | + && ( ! empty( $_GET[ 'edit' ] ) ); |
|
214 | 214 | |
215 | 215 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
216 | 216 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return boolean |
222 | 222 | */ |
223 | 223 | public function is_edit_entry_submission() { |
224 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
224 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -243,20 +243,20 @@ discard block |
||
243 | 243 | } else { |
244 | 244 | $gravityview_view = GravityView_View::getInstance(); |
245 | 245 | $entries = $gravityview_view->getEntries(); |
246 | - self::$original_entry = $entries[0]; |
|
247 | - $this->entry = $entries[0]; |
|
246 | + self::$original_entry = $entries[ 0 ]; |
|
247 | + $this->entry = $entries[ 0 ]; |
|
248 | 248 | } |
249 | 249 | |
250 | - self::$original_form = GFAPI::get_form( $this->entry['form_id'] ); |
|
250 | + self::$original_form = GFAPI::get_form( $this->entry[ 'form_id' ] ); |
|
251 | 251 | $this->form = self::$original_form; |
252 | 252 | |
253 | - $this->form_id = $this->entry['form_id']; |
|
253 | + $this->form_id = $this->entry[ 'form_id' ]; |
|
254 | 254 | |
255 | 255 | $this->view_id = $view ? $view->ID : $gravityview_view->getViewId(); |
256 | 256 | |
257 | 257 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
258 | 258 | |
259 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
259 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | private function print_scripts() { |
319 | 319 | $gravityview_view = GravityView_View::getInstance(); |
320 | 320 | |
321 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
321 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
322 | 322 | |
323 | 323 | GFFormDisplay::enqueue_form_scripts( $this->form ? $this->form : $gravityview_view->getForm(), false ); |
324 | 324 | |
@@ -339,19 +339,19 @@ discard block |
||
339 | 339 | */ |
340 | 340 | private function process_save( $gv_data ) { |
341 | 341 | |
342 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
342 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
343 | 343 | return; |
344 | 344 | } |
345 | 345 | |
346 | 346 | // Make sure the entry, view, and form IDs are all correct |
347 | 347 | $valid = $this->verify_nonce(); |
348 | 348 | |
349 | - if ( !$valid ) { |
|
349 | + if ( ! $valid ) { |
|
350 | 350 | gravityview()->log->error( 'Nonce validation failed.' ); |
351 | 351 | return; |
352 | 352 | } |
353 | 353 | |
354 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
354 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
355 | 355 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
356 | 356 | return; |
357 | 357 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | |
363 | 363 | $this->validate(); |
364 | 364 | |
365 | - if( $this->is_valid ) { |
|
365 | + if ( $this->is_valid ) { |
|
366 | 366 | |
367 | 367 | gravityview()->log->debug( 'Submission is valid.' ); |
368 | 368 | |
@@ -374,15 +374,15 @@ discard block |
||
374 | 374 | /** |
375 | 375 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
376 | 376 | */ |
377 | - unset( $_GET['page'] ); |
|
377 | + unset( $_GET[ 'page' ] ); |
|
378 | 378 | |
379 | - $date_created = $this->entry['date_created']; |
|
379 | + $date_created = $this->entry[ 'date_created' ]; |
|
380 | 380 | |
381 | 381 | /** |
382 | 382 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
383 | 383 | * @since 1.17.2 |
384 | 384 | */ |
385 | - unset( $this->entry['date_created'] ); |
|
385 | + unset( $this->entry[ 'date_created' ] ); |
|
386 | 386 | |
387 | 387 | /** |
388 | 388 | * @action `gravityview/edit_entry/before_update` Perform an action before the entry has been updated using Edit Entry |
@@ -392,14 +392,14 @@ discard block |
||
392 | 392 | * @param GravityView_Edit_Entry_Render $this This object |
393 | 393 | * @param GravityView_View_Data $gv_data The View data |
394 | 394 | */ |
395 | - do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data ); |
|
395 | + do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data ); |
|
396 | 396 | |
397 | 397 | GFFormsModel::save_lead( $form, $this->entry ); |
398 | 398 | |
399 | 399 | // Delete the values for hidden inputs |
400 | 400 | $this->unset_hidden_field_values(); |
401 | 401 | |
402 | - $this->entry['date_created'] = $date_created; |
|
402 | + $this->entry[ 'date_created' ] = $date_created; |
|
403 | 403 | |
404 | 404 | // Process calculation fields |
405 | 405 | $this->update_calculation_fields(); |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param GravityView_Edit_Entry_Render $this This object |
425 | 425 | * @param GravityView_View_Data $gv_data The View data |
426 | 426 | */ |
427 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
427 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
428 | 428 | |
429 | 429 | } else { |
430 | 430 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -460,10 +460,10 @@ discard block |
||
460 | 460 | |
461 | 461 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
462 | 462 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
463 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
463 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
464 | 464 | } else { |
465 | 465 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
466 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
466 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -481,11 +481,11 @@ discard block |
||
481 | 481 | |
482 | 482 | $empty_value = $field->get_value_save_entry( |
483 | 483 | is_array( $field->get_entry_inputs() ) ? array() : '', |
484 | - $this->form, '', $this->entry['id'], $this->entry |
|
484 | + $this->form, '', $this->entry[ 'id' ], $this->entry |
|
485 | 485 | ); |
486 | 486 | |
487 | 487 | if ( $field->has_calculation() ) { |
488 | - $this->unset_hidden_calculations[] = $field->id; // Unset |
|
488 | + $this->unset_hidden_calculations[ ] = $field->id; // Unset |
|
489 | 489 | $empty_value = ''; |
490 | 490 | } |
491 | 491 | |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | private function preset_approval_fields() { |
515 | 515 | $has_approved_field = false; |
516 | 516 | |
517 | - foreach ( self::$original_form['fields'] as $field ) { |
|
517 | + foreach ( self::$original_form[ 'fields' ] as $field ) { |
|
518 | 518 | if ( $field->gravityview_approved ) { |
519 | 519 | $has_approved_field = true; |
520 | 520 | break; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | |
528 | 528 | $is_field_hidden = true; |
529 | 529 | |
530 | - foreach ( $this->form['fields'] as $field ) { |
|
530 | + foreach ( $this->form[ 'fields' ] as $field ) { |
|
531 | 531 | if ( $field->gravityview_approved ) { |
532 | 532 | $is_field_hidden = false; |
533 | 533 | break; |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | remove_filter( 'gravityview/approve_entries/update_unapproved_meta', array( $this, 'prevent_update_unapproved_meta' ), 9 ); |
554 | 554 | |
555 | - if ( ! $value = gform_get_meta( $entry['id'], 'is_approved' ) ) { |
|
555 | + if ( ! $value = gform_get_meta( $entry[ 'id' ], 'is_approved' ) ) { |
|
556 | 556 | |
557 | 557 | $value = GravityView_Entry_Approval_Status::UNAPPROVED; |
558 | 558 | |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | } |
618 | 618 | |
619 | 619 | /** No file is being uploaded. */ |
620 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
620 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
621 | 621 | /** So return the original upload, with $value as backup (it can be empty during edit form rendering) */ |
622 | 622 | return rgar( $entry, $input_id, $value ); |
623 | 623 | } |
@@ -635,11 +635,11 @@ discard block |
||
635 | 635 | * @return mixed |
636 | 636 | */ |
637 | 637 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
638 | - if( ! $this->is_edit_entry() ) { |
|
638 | + if ( ! $this->is_edit_entry() ) { |
|
639 | 639 | return $plupload_init; |
640 | 640 | } |
641 | 641 | |
642 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
642 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
643 | 643 | |
644 | 644 | return $plupload_init; |
645 | 645 | } |
@@ -654,26 +654,26 @@ discard block |
||
654 | 654 | $form = $this->filter_conditional_logic( $this->form ); |
655 | 655 | |
656 | 656 | /** @type GF_Field $field */ |
657 | - foreach( $form['fields'] as $k => &$field ) { |
|
657 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
658 | 658 | |
659 | 659 | /** |
660 | 660 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
661 | 661 | * @since 1.16.3 |
662 | 662 | */ |
663 | - if( $field->has_calculation() ) { |
|
664 | - unset( $form['fields'][ $k ] ); |
|
663 | + if ( $field->has_calculation() ) { |
|
664 | + unset( $form[ 'fields' ][ $k ] ); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | $field->adminOnly = false; |
668 | 668 | |
669 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
670 | - foreach( $field->inputs as $key => $input ) { |
|
671 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
669 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
670 | + foreach ( $field->inputs as $key => $input ) { |
|
671 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | } |
675 | 675 | |
676 | - $form['fields'] = array_values( $form['fields'] ); |
|
676 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
677 | 677 | |
678 | 678 | return $form; |
679 | 679 | } |
@@ -685,14 +685,14 @@ discard block |
||
685 | 685 | $update = false; |
686 | 686 | |
687 | 687 | // get the most up to date entry values |
688 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
688 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
689 | 689 | |
690 | 690 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
691 | 691 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
692 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
692 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
693 | 693 | } else { |
694 | 694 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
695 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
695 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | |
@@ -709,24 +709,24 @@ discard block |
||
709 | 709 | $inputs = $field->get_entry_inputs(); |
710 | 710 | if ( is_array( $inputs ) ) { |
711 | 711 | foreach ( $inputs as $input ) { |
712 | - list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
|
712 | + list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 ); |
|
713 | 713 | |
714 | 714 | if ( 'product' === $field->type ) { |
715 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
715 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
716 | 716 | |
717 | 717 | // Only allow quantity to be set if it's allowed to be edited |
718 | 718 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
719 | 719 | } else { // otherwise set to what it previously was |
720 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
720 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
721 | 721 | } |
722 | 722 | } else { |
723 | 723 | // Set to what it previously was if it's not editable |
724 | 724 | if ( ! in_array( $field_id, $allowed_fields ) ) { |
725 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
725 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
726 | 726 | } |
727 | 727 | } |
728 | 728 | |
729 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
729 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
730 | 730 | } |
731 | 731 | } else { |
732 | 732 | // Set to what it previously was if it's not editable |
@@ -766,19 +766,19 @@ discard block |
||
766 | 766 | |
767 | 767 | $input_name = 'input_' . $field_id; |
768 | 768 | |
769 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
769 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
770 | 770 | |
771 | 771 | // We have a new image |
772 | 772 | |
773 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
773 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
774 | 774 | |
775 | 775 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
776 | 776 | $ary = stripslashes_deep( $ary ); |
777 | 777 | $img_url = \GV\Utils::get( $ary, 0 ); |
778 | 778 | |
779 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
780 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
781 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
779 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
780 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
781 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
782 | 782 | |
783 | 783 | $image_meta = array( |
784 | 784 | 'post_excerpt' => $img_caption, |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | |
788 | 788 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
789 | 789 | if ( ! empty( $img_title ) ) { |
790 | - $image_meta['post_title'] = $img_title; |
|
790 | + $image_meta[ 'post_title' ] = $img_title; |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | /** |
@@ -845,15 +845,15 @@ discard block |
||
845 | 845 | */ |
846 | 846 | private function maybe_update_post_fields( $form ) { |
847 | 847 | |
848 | - if( empty( $this->entry['post_id'] ) ) { |
|
848 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
849 | 849 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
850 | 850 | return; |
851 | 851 | } |
852 | 852 | |
853 | - $post_id = $this->entry['post_id']; |
|
853 | + $post_id = $this->entry[ 'post_id' ]; |
|
854 | 854 | |
855 | 855 | // Security check |
856 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
856 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
857 | 857 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
858 | 858 | return; |
859 | 859 | } |
@@ -866,25 +866,25 @@ discard block |
||
866 | 866 | |
867 | 867 | $field = RGFormsModel::get_field( $form, $field_id ); |
868 | 868 | |
869 | - if( ! $field ) { |
|
869 | + if ( ! $field ) { |
|
870 | 870 | continue; |
871 | 871 | } |
872 | 872 | |
873 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
873 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
874 | 874 | |
875 | 875 | // Get the value of the field, including $_POSTed value |
876 | 876 | $value = RGFormsModel::get_field_value( $field ); |
877 | 877 | |
878 | 878 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
879 | 879 | $entry_tmp = $this->entry; |
880 | - $entry_tmp["{$field_id}"] = $value; |
|
880 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
881 | 881 | |
882 | - switch( $field->type ) { |
|
882 | + switch ( $field->type ) { |
|
883 | 883 | |
884 | 884 | case 'post_title': |
885 | 885 | $post_title = $value; |
886 | 886 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
887 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
887 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
888 | 888 | } |
889 | 889 | $updated_post->post_title = $post_title; |
890 | 890 | $updated_post->post_name = $post_title; |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | case 'post_content': |
895 | 895 | $post_content = $value; |
896 | 896 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
897 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
897 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
898 | 898 | } |
899 | 899 | $updated_post->post_content = $post_content; |
900 | 900 | unset( $post_content ); |
@@ -912,11 +912,11 @@ discard block |
||
912 | 912 | $value = $value[ $field_id ]; |
913 | 913 | } |
914 | 914 | |
915 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
915 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
916 | 916 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
917 | 917 | } |
918 | 918 | |
919 | - $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
919 | + $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
920 | 920 | |
921 | 921 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
922 | 922 | break; |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | } |
929 | 929 | |
930 | 930 | // update entry after |
931 | - $this->entry["{$field_id}"] = $value; |
|
931 | + $this->entry[ "{$field_id}" ] = $value; |
|
932 | 932 | |
933 | 933 | $update_entry = true; |
934 | 934 | |
@@ -937,11 +937,11 @@ discard block |
||
937 | 937 | |
938 | 938 | } |
939 | 939 | |
940 | - if( $update_entry ) { |
|
940 | + if ( $update_entry ) { |
|
941 | 941 | |
942 | 942 | $return_entry = GFAPI::update_entry( $this->entry ); |
943 | 943 | |
944 | - if( is_wp_error( $return_entry ) ) { |
|
944 | + if ( is_wp_error( $return_entry ) ) { |
|
945 | 945 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
946 | 946 | } else { |
947 | 947 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | |
952 | 952 | $return_post = wp_update_post( $updated_post, true ); |
953 | 953 | |
954 | - if( is_wp_error( $return_post ) ) { |
|
954 | + if ( is_wp_error( $return_post ) ) { |
|
955 | 955 | $return_post->add_data( $updated_post, '$updated_post' ); |
956 | 956 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
957 | 957 | } else { |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
986 | 986 | |
987 | 987 | // replace conditional shortcodes |
988 | - if( $do_shortcode ) { |
|
988 | + if ( $do_shortcode ) { |
|
989 | 989 | $output = do_shortcode( $output ); |
990 | 990 | } |
991 | 991 | |
@@ -1004,19 +1004,19 @@ discard block |
||
1004 | 1004 | */ |
1005 | 1005 | private function after_update() { |
1006 | 1006 | |
1007 | - do_action( 'gform_after_update_entry', self::$original_form, $this->entry['id'], self::$original_entry ); |
|
1008 | - do_action( "gform_after_update_entry_{$this->form['id']}", self::$original_form, $this->entry['id'], self::$original_entry ); |
|
1007 | + do_action( 'gform_after_update_entry', self::$original_form, $this->entry[ 'id' ], self::$original_entry ); |
|
1008 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", self::$original_form, $this->entry[ 'id' ], self::$original_entry ); |
|
1009 | 1009 | |
1010 | 1010 | // Re-define the entry now that we've updated it. |
1011 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
1011 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
1012 | 1012 | |
1013 | 1013 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
1014 | 1014 | |
1015 | 1015 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
1016 | 1016 | // We need to clear the cache because Gravity Forms caches the field values, which |
1017 | 1017 | // we have just updated. |
1018 | - foreach ($this->form['fields'] as $key => $field) { |
|
1019 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
1018 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
1019 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
1020 | 1020 | } |
1021 | 1021 | } |
1022 | 1022 | |
@@ -1026,11 +1026,11 @@ discard block |
||
1026 | 1026 | * @since develop |
1027 | 1027 | */ |
1028 | 1028 | if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) { |
1029 | - $feeds = GFAPI::get_feeds( null, $entry['form_id'] ); |
|
1029 | + $feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] ); |
|
1030 | 1030 | if ( ! is_wp_error( $feeds ) ) { |
1031 | 1031 | $registered_feeds = array(); |
1032 | 1032 | foreach ( GFAddOn::get_registered_addons() as $registered_feed ) { |
1033 | - if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
1033 | + if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
1034 | 1034 | if ( method_exists( $registered_feed, 'get_instance' ) ) { |
1035 | 1035 | $registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) ); |
1036 | 1036 | $registered_feeds[ $registered_feed->get_slug() ] = $registered_feed; |
@@ -1038,8 +1038,8 @@ discard block |
||
1038 | 1038 | } |
1039 | 1039 | } |
1040 | 1040 | foreach ( $feeds as $feed ) { |
1041 | - if ( in_array( $feed['id'], $allowed_feeds ) ) { |
|
1042 | - if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) { |
|
1041 | + if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) { |
|
1042 | + if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) { |
|
1043 | 1043 | $returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form ); |
1044 | 1044 | if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) { |
1045 | 1045 | $entry = $returned_entry; |
@@ -1067,9 +1067,9 @@ discard block |
||
1067 | 1067 | |
1068 | 1068 | $view = \GV\View::by_id( $this->view_id ); |
1069 | 1069 | |
1070 | - if( $view->settings->get( 'edit_locking' ) ) { |
|
1070 | + if ( $view->settings->get( 'edit_locking' ) ) { |
|
1071 | 1071 | $locking = new GravityView_Edit_Entry_Locking(); |
1072 | - $locking->maybe_lock_object( $this->entry['id'] ); |
|
1072 | + $locking->maybe_lock_object( $this->entry[ 'id' ] ); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | ?> |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | |
1083 | 1083 | <div class="gv-edit-entry-wrapper"><?php |
1084 | 1084 | |
1085 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
1085 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
1086 | 1086 | |
1087 | 1087 | /** |
1088 | 1088 | * Fixes weird wpautop() issue |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | * @param string $edit_entry_title Modify the "Edit Entry" title |
1099 | 1099 | * @param GravityView_Edit_Entry_Render $this This object |
1100 | 1100 | */ |
1101 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1101 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
1102 | 1102 | |
1103 | 1103 | echo esc_attr( $edit_entry_title ); |
1104 | 1104 | ?></span> |
@@ -1175,18 +1175,18 @@ discard block |
||
1175 | 1175 | */ |
1176 | 1176 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1177 | 1177 | |
1178 | - $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
|
1178 | + $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels[ 'submit' ]; |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | $back_link = remove_query_arg( array( 'page', 'view', 'edit', 'gvid' ) ); |
1182 | 1182 | |
1183 | - if( ! $this->is_valid ){ |
|
1183 | + if ( ! $this->is_valid ) { |
|
1184 | 1184 | |
1185 | 1185 | // Keeping this compatible with Gravity Forms. |
1186 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
1187 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
1186 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
1187 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
1188 | 1188 | |
1189 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
1189 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
1190 | 1190 | |
1191 | 1191 | } elseif ( false === $this->is_paged_submitted ) { |
1192 | 1192 | // Paged form that hasn't been submitted on the last page yet |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | * @param int $view_id View ID |
1200 | 1200 | * @param array $entry Gravity Forms entry array |
1201 | 1201 | */ |
1202 | - $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message , $this->view_id, $this->entry ); |
|
1202 | + $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message, $this->view_id, $this->entry ); |
|
1203 | 1203 | |
1204 | 1204 | echo GVCommon::generate_notice( $message ); |
1205 | 1205 | } else { |
@@ -1211,23 +1211,23 @@ discard block |
||
1211 | 1211 | |
1212 | 1212 | case '0': |
1213 | 1213 | $redirect_url = $back_link; |
1214 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1214 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
1215 | 1215 | break; |
1216 | 1216 | |
1217 | 1217 | case '1': |
1218 | 1218 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
1219 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1219 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1220 | 1220 | break; |
1221 | 1221 | |
1222 | 1222 | case '2': |
1223 | 1223 | $redirect_url = $edit_redirect_url; |
1224 | 1224 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
1225 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1225 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1226 | 1226 | break; |
1227 | 1227 | |
1228 | 1228 | case '': |
1229 | 1229 | default: |
1230 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1230 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
1231 | 1231 | break; |
1232 | 1232 | } |
1233 | 1233 | |
@@ -1268,8 +1268,8 @@ discard block |
||
1268 | 1268 | */ |
1269 | 1269 | do_action( 'gravityview/edit-entry/render/before', $this ); |
1270 | 1270 | |
1271 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1272 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1271 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1272 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1273 | 1273 | add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
1274 | 1274 | add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
1275 | 1275 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
@@ -1278,14 +1278,14 @@ discard block |
||
1278 | 1278 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1279 | 1279 | |
1280 | 1280 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1281 | - unset( $_GET['page'] ); |
|
1281 | + unset( $_GET[ 'page' ] ); |
|
1282 | 1282 | |
1283 | 1283 | $this->show_next_button = false; |
1284 | 1284 | $this->show_previous_button = false; |
1285 | 1285 | |
1286 | 1286 | // TODO: Verify multiple-page forms |
1287 | 1287 | if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) { |
1288 | - if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form['id'], 0 ) ) ) { |
|
1288 | + if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form[ 'id' ], 0 ) ) ) { |
|
1289 | 1289 | |
1290 | 1290 | $labels = array( |
1291 | 1291 | 'cancel' => __( 'Cancel', 'gravityview' ), |
@@ -1304,20 +1304,20 @@ discard block |
||
1304 | 1304 | */ |
1305 | 1305 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1306 | 1306 | |
1307 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
|
1308 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true; |
|
1307 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form; |
|
1308 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true; |
|
1309 | 1309 | |
1310 | - if ( \GV\Utils::_POST( 'save' ) === $labels['next'] ) { |
|
1310 | + if ( \GV\Utils::_POST( 'save' ) === $labels[ 'next' ] ) { |
|
1311 | 1311 | $last_page = \GFFormDisplay::get_max_page_number( $this->form ); |
1312 | 1312 | |
1313 | 1313 | while ( ++$page_number < $last_page && RGFormsModel::is_page_hidden( $this->form, $page_number, \GV\Utils::_POST( 'gform_field_values' ) ) ) { |
1314 | 1314 | } // Advance to next visible page |
1315 | - } elseif ( \GV\Utils::_POST( 'save' ) === $labels['previous'] ) { |
|
1315 | + } elseif ( \GV\Utils::_POST( 'save' ) === $labels[ 'previous' ] ) { |
|
1316 | 1316 | while ( --$page_number > 1 && RGFormsModel::is_page_hidden( $this->form, $page_number, \GV\Utils::_POST( 'gform_field_values' ) ) ) { |
1317 | 1317 | } // Advance to next visible page |
1318 | 1318 | } |
1319 | 1319 | |
1320 | - GFFormDisplay::$submission[ $this->form['id'] ]['page_number'] = $page_number; |
|
1320 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number; |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | if ( ( $page_number = intval( $page_number ) ) < 2 ) { |
@@ -1343,7 +1343,7 @@ discard block |
||
1343 | 1343 | |
1344 | 1344 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1345 | 1345 | |
1346 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1346 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1347 | 1347 | |
1348 | 1348 | ob_get_clean(); |
1349 | 1349 | |
@@ -1371,7 +1371,7 @@ discard block |
||
1371 | 1371 | * @return string |
1372 | 1372 | */ |
1373 | 1373 | public function render_form_buttons() { |
1374 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1374 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | |
@@ -1390,15 +1390,15 @@ discard block |
||
1390 | 1390 | */ |
1391 | 1391 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1392 | 1392 | |
1393 | - if( $form['id'] != $this->form_id ) { |
|
1393 | + if ( $form[ 'id' ] != $this->form_id ) { |
|
1394 | 1394 | return $form; |
1395 | 1395 | } |
1396 | 1396 | |
1397 | 1397 | // In case we have validated the form, use it to inject the validation results into the form render |
1398 | - if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) { |
|
1398 | + if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) { |
|
1399 | 1399 | $form = $this->form_after_validation; |
1400 | 1400 | } else { |
1401 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1401 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1402 | 1402 | } |
1403 | 1403 | |
1404 | 1404 | $form = $this->filter_conditional_logic( $form ); |
@@ -1406,8 +1406,8 @@ discard block |
||
1406 | 1406 | $form = $this->prefill_conditional_logic( $form ); |
1407 | 1407 | |
1408 | 1408 | // for now we don't support Save and Continue feature. |
1409 | - if( ! self::$supports_save_and_continue ) { |
|
1410 | - unset( $form['save'] ); |
|
1409 | + if ( ! self::$supports_save_and_continue ) { |
|
1410 | + unset( $form[ 'save' ] ); |
|
1411 | 1411 | } |
1412 | 1412 | |
1413 | 1413 | $form = $this->unselect_default_values( $form ); |
@@ -1430,31 +1430,31 @@ discard block |
||
1430 | 1430 | */ |
1431 | 1431 | public function verify_user_can_edit_post( $field_content = '', $field = null, $value = '', $lead_id = 0, $form_id = 0 ) { |
1432 | 1432 | |
1433 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
1433 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
1434 | 1434 | return $field_content; |
1435 | 1435 | } |
1436 | 1436 | |
1437 | 1437 | $message = null; |
1438 | 1438 | |
1439 | 1439 | // First, make sure they have the capability to edit the post. |
1440 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1440 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1441 | 1441 | |
1442 | 1442 | /** |
1443 | 1443 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1444 | 1444 | * @param string $message The existing "You don't have permission..." text |
1445 | 1445 | */ |
1446 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1446 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1447 | 1447 | |
1448 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1448 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1449 | 1449 | /** |
1450 | 1450 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1451 | 1451 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1452 | 1452 | */ |
1453 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1453 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1454 | 1454 | } |
1455 | 1455 | |
1456 | - if( $message ) { |
|
1457 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1456 | + if ( $message ) { |
|
1457 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1458 | 1458 | } |
1459 | 1459 | |
1460 | 1460 | return $field_content; |
@@ -1478,8 +1478,8 @@ discard block |
||
1478 | 1478 | |
1479 | 1479 | // If the form has been submitted, then we don't need to pre-fill the values, |
1480 | 1480 | // Except for fileupload type and when a field input is overridden- run always!! |
1481 | - if( |
|
1482 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1481 | + if ( |
|
1482 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1483 | 1483 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1484 | 1484 | && ! GFCommon::is_product_field( $field->type ) |
1485 | 1485 | || ! empty( $field_content ) |
@@ -1499,7 +1499,7 @@ discard block |
||
1499 | 1499 | $return = null; |
1500 | 1500 | |
1501 | 1501 | /** @var GravityView_Field $gv_field */ |
1502 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1502 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1503 | 1503 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1504 | 1504 | } else { |
1505 | 1505 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1508,7 +1508,7 @@ discard block |
||
1508 | 1508 | // If there was output, it's an error |
1509 | 1509 | $warnings = ob_get_clean(); |
1510 | 1510 | |
1511 | - if( !empty( $warnings ) ) { |
|
1511 | + if ( ! empty( $warnings ) ) { |
|
1512 | 1512 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1513 | 1513 | } |
1514 | 1514 | |
@@ -1533,7 +1533,7 @@ discard block |
||
1533 | 1533 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1534 | 1534 | |
1535 | 1535 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1536 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1536 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1537 | 1537 | |
1538 | 1538 | $field_value = array(); |
1539 | 1539 | |
@@ -1542,10 +1542,10 @@ discard block |
||
1542 | 1542 | |
1543 | 1543 | foreach ( (array)$field->inputs as $input ) { |
1544 | 1544 | |
1545 | - $input_id = strval( $input['id'] ); |
|
1545 | + $input_id = strval( $input[ 'id' ] ); |
|
1546 | 1546 | |
1547 | 1547 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1548 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1548 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1549 | 1549 | $allow_pre_populated = false; |
1550 | 1550 | } |
1551 | 1551 | |
@@ -1553,7 +1553,7 @@ discard block |
||
1553 | 1553 | |
1554 | 1554 | $pre_value = $field->get_value_submission( array(), false ); |
1555 | 1555 | |
1556 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1556 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1557 | 1557 | |
1558 | 1558 | } else { |
1559 | 1559 | |
@@ -1564,13 +1564,13 @@ discard block |
||
1564 | 1564 | |
1565 | 1565 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1566 | 1566 | // or pre-populated value if not empty and set to override saved value |
1567 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1567 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1568 | 1568 | |
1569 | 1569 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1570 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1570 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1571 | 1571 | $categories = array(); |
1572 | 1572 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1573 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1573 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1574 | 1574 | } |
1575 | 1575 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1576 | 1576 | } |
@@ -1598,7 +1598,7 @@ discard block |
||
1598 | 1598 | * @param GF_Field $field Gravity Forms field object |
1599 | 1599 | * @param GravityView_Edit_Entry_Render $this Current object |
1600 | 1600 | */ |
1601 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1601 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1602 | 1602 | |
1603 | 1603 | return $field_value; |
1604 | 1604 | } |
@@ -1615,12 +1615,12 @@ discard block |
||
1615 | 1615 | */ |
1616 | 1616 | public function gform_pre_validation( $form ) { |
1617 | 1617 | |
1618 | - if( ! $this->verify_nonce() ) { |
|
1618 | + if ( ! $this->verify_nonce() ) { |
|
1619 | 1619 | return $form; |
1620 | 1620 | } |
1621 | 1621 | |
1622 | 1622 | // Fix PHP warning regarding undefined index. |
1623 | - foreach ( $form['fields'] as &$field) { |
|
1623 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1624 | 1624 | |
1625 | 1625 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1626 | 1626 | // expects certain field array items to be set. |
@@ -1628,7 +1628,7 @@ discard block |
||
1628 | 1628 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1629 | 1629 | } |
1630 | 1630 | |
1631 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1631 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1632 | 1632 | |
1633 | 1633 | /** |
1634 | 1634 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1642,26 +1642,26 @@ discard block |
||
1642 | 1642 | // Set the previous value |
1643 | 1643 | $entry = $this->get_entry(); |
1644 | 1644 | |
1645 | - $input_name = 'input_'.$field->id; |
|
1646 | - $form_id = $form['id']; |
|
1645 | + $input_name = 'input_' . $field->id; |
|
1646 | + $form_id = $form[ 'id' ]; |
|
1647 | 1647 | |
1648 | 1648 | $value = NULL; |
1649 | 1649 | |
1650 | 1650 | // Use the previous entry value as the default. |
1651 | - if( isset( $entry[ $field->id ] ) ) { |
|
1651 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1652 | 1652 | $value = $entry[ $field->id ]; |
1653 | 1653 | } |
1654 | 1654 | |
1655 | 1655 | // If this is a single upload file |
1656 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1657 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1658 | - $value = $file_path['url']; |
|
1656 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1657 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1658 | + $value = $file_path[ 'url' ]; |
|
1659 | 1659 | |
1660 | 1660 | } else { |
1661 | 1661 | |
1662 | 1662 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1663 | 1663 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1664 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1664 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1665 | 1665 | |
1666 | 1666 | } |
1667 | 1667 | |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
1672 | 1672 | $value = empty( $value ) ? '[]' : $value; |
1673 | 1673 | $value = stripslashes_deep( $value ); |
1674 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array() ); |
|
1674 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1675 | 1675 | } else if ( GFCommon::is_json( $value ) ) { |
1676 | 1676 | // Existing file; let GF derive the value from the `$_gf_uploaded_files` object (see `\GF_Field_FileUpload::get_multifile_value()`) |
1677 | 1677 | global $_gf_uploaded_files; |
@@ -1691,8 +1691,8 @@ discard block |
||
1691 | 1691 | |
1692 | 1692 | case 'number': |
1693 | 1693 | // Fix "undefined index" issue at line 1286 in form_display.php |
1694 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1695 | - $_POST['input_'.$field->id ] = NULL; |
|
1694 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1695 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1696 | 1696 | } |
1697 | 1697 | break; |
1698 | 1698 | } |
@@ -1729,7 +1729,7 @@ discard block |
||
1729 | 1729 | * You can enter whatever you want! |
1730 | 1730 | * We try validating, and customize the results using `self::custom_validation()` |
1731 | 1731 | */ |
1732 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1732 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1733 | 1733 | |
1734 | 1734 | // Needed by the validate funtion |
1735 | 1735 | $failed_validation_page = NULL; |
@@ -1737,14 +1737,14 @@ discard block |
||
1737 | 1737 | |
1738 | 1738 | // Prevent entry limit from running when editing an entry, also |
1739 | 1739 | // prevent form scheduling from preventing editing |
1740 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1740 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1741 | 1741 | |
1742 | 1742 | // Hide fields depending on Edit Entry settings |
1743 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1743 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1744 | 1744 | |
1745 | 1745 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1746 | 1746 | |
1747 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1747 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1748 | 1748 | } |
1749 | 1749 | |
1750 | 1750 | |
@@ -1772,7 +1772,7 @@ discard block |
||
1772 | 1772 | |
1773 | 1773 | $gv_valid = true; |
1774 | 1774 | |
1775 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1775 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1776 | 1776 | $value = RGFormsModel::get_field_value( $field ); |
1777 | 1777 | $field_type = RGFormsModel::get_input_type( $field ); |
1778 | 1778 | $is_required = ! empty( $field->isRequired ); |
@@ -1780,7 +1780,7 @@ discard block |
||
1780 | 1780 | |
1781 | 1781 | // Manually validate required fields as they can be skipped be skipped by GF's validation |
1782 | 1782 | // This can happen when the field is considered "hidden" (see `GFFormDisplay::validate`) due to unmet conditional logic |
1783 | - if ( $is_required && !$failed_validation && rgblank( $value ) ) { |
|
1783 | + if ( $is_required && ! $failed_validation && rgblank( $value ) ) { |
|
1784 | 1784 | $field->failed_validation = true; |
1785 | 1785 | $field->validation_message = esc_html__( 'This field is required.', 'gravityview' ); |
1786 | 1786 | |
@@ -1804,7 +1804,7 @@ discard block |
||
1804 | 1804 | if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
1805 | 1805 | $input_name = 'input_' . $field->id; |
1806 | 1806 | //uploaded |
1807 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1807 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1808 | 1808 | |
1809 | 1809 | //existent |
1810 | 1810 | $entry = $this->get_entry(); |
@@ -1823,7 +1823,7 @@ discard block |
||
1823 | 1823 | $gv_valid = false; |
1824 | 1824 | |
1825 | 1825 | // in case of error make sure the newest upload files are removed from the upload input |
1826 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1826 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1827 | 1827 | } |
1828 | 1828 | } |
1829 | 1829 | |
@@ -1831,7 +1831,7 @@ discard block |
||
1831 | 1831 | } |
1832 | 1832 | |
1833 | 1833 | // This field has failed validation. |
1834 | - if( !empty( $field->failed_validation ) ) { |
|
1834 | + if ( ! empty( $field->failed_validation ) ) { |
|
1835 | 1835 | |
1836 | 1836 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1837 | 1837 | |
@@ -1849,19 +1849,19 @@ discard block |
||
1849 | 1849 | } |
1850 | 1850 | |
1851 | 1851 | // You can't continue inside a switch, so we do it after. |
1852 | - if( empty( $field->failed_validation ) ) { |
|
1852 | + if ( empty( $field->failed_validation ) ) { |
|
1853 | 1853 | continue; |
1854 | 1854 | } |
1855 | 1855 | |
1856 | 1856 | // checks if the No Duplicates option is not validating entry against itself, since |
1857 | 1857 | // we're editing a stored entry, it would also assume it's a duplicate. |
1858 | - if( !empty( $field->noDuplicates ) ) { |
|
1858 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1859 | 1859 | |
1860 | 1860 | $entry = $this->get_entry(); |
1861 | 1861 | |
1862 | 1862 | // If the value of the entry is the same as the stored value |
1863 | 1863 | // Then we can assume it's not a duplicate, it's the same. |
1864 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1864 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1865 | 1865 | //if value submitted was not changed, then don't validate |
1866 | 1866 | $field->failed_validation = false; |
1867 | 1867 | |
@@ -1874,7 +1874,7 @@ discard block |
||
1874 | 1874 | } |
1875 | 1875 | |
1876 | 1876 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1877 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1877 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1878 | 1878 | unset( $field->validation_message ); |
1879 | 1879 | $field->failed_validation = false; |
1880 | 1880 | continue; |
@@ -1886,12 +1886,12 @@ discard block |
||
1886 | 1886 | |
1887 | 1887 | } |
1888 | 1888 | |
1889 | - $validation_results['is_valid'] = $gv_valid; |
|
1889 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1890 | 1890 | |
1891 | 1891 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1892 | 1892 | |
1893 | 1893 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1894 | - $this->form_after_validation = $validation_results['form']; |
|
1894 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1895 | 1895 | |
1896 | 1896 | return $validation_results; |
1897 | 1897 | } |
@@ -1904,7 +1904,7 @@ discard block |
||
1904 | 1904 | */ |
1905 | 1905 | public function get_entry() { |
1906 | 1906 | |
1907 | - if( empty( $this->entry ) ) { |
|
1907 | + if ( empty( $this->entry ) ) { |
|
1908 | 1908 | // Get the database value of the entry that's being edited |
1909 | 1909 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1910 | 1910 | } |
@@ -1936,10 +1936,10 @@ discard block |
||
1936 | 1936 | } |
1937 | 1937 | |
1938 | 1938 | // If edit tab not yet configured, show all fields |
1939 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1939 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1940 | 1940 | |
1941 | 1941 | // Hide fields depending on admin settings |
1942 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1942 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1943 | 1943 | |
1944 | 1944 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1945 | 1945 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1972,7 +1972,7 @@ discard block |
||
1972 | 1972 | */ |
1973 | 1973 | private function filter_fields( $fields, $configured_fields ) { |
1974 | 1974 | |
1975 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1975 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1976 | 1976 | return $fields; |
1977 | 1977 | } |
1978 | 1978 | |
@@ -1989,12 +1989,12 @@ discard block |
||
1989 | 1989 | |
1990 | 1990 | // Remove the fields that have calculation properties and keep them to be used later |
1991 | 1991 | // @since 1.16.2 |
1992 | - if( $field->has_calculation() ) { |
|
1993 | - $this->fields_with_calculation[] = $field; |
|
1992 | + if ( $field->has_calculation() ) { |
|
1993 | + $this->fields_with_calculation[ ] = $field; |
|
1994 | 1994 | // don't remove the calculation fields on form render. |
1995 | 1995 | } |
1996 | 1996 | |
1997 | - if( in_array( $field->type, $field_type_blocklist ) ) { |
|
1997 | + if ( in_array( $field->type, $field_type_blocklist ) ) { |
|
1998 | 1998 | unset( $fields[ $key ] ); |
1999 | 1999 | } |
2000 | 2000 | } |
@@ -2024,7 +2024,7 @@ discard block |
||
2024 | 2024 | continue; // Never include when no fields are configured |
2025 | 2025 | } |
2026 | 2026 | |
2027 | - $out_fields[] = $field; |
|
2027 | + $out_fields[ ] = $field; |
|
2028 | 2028 | } |
2029 | 2029 | |
2030 | 2030 | return array_values( $out_fields ); |
@@ -2035,8 +2035,8 @@ discard block |
||
2035 | 2035 | |
2036 | 2036 | /** @var GF_Field $field */ |
2037 | 2037 | foreach ( $fields as $field ) { |
2038 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
2039 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
2038 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
2039 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
2040 | 2040 | break; |
2041 | 2041 | } |
2042 | 2042 | |
@@ -2059,14 +2059,14 @@ discard block |
||
2059 | 2059 | |
2060 | 2060 | $return_field = $field; |
2061 | 2061 | |
2062 | - if( empty( $field_setting['show_label'] ) ) { |
|
2062 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
2063 | 2063 | $return_field->label = ''; |
2064 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
2065 | - $return_field->label = $field_setting['custom_label']; |
|
2064 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
2065 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
2066 | 2066 | } |
2067 | 2067 | |
2068 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
2069 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
2068 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
2069 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
2070 | 2070 | } |
2071 | 2071 | |
2072 | 2072 | /** |
@@ -2104,16 +2104,16 @@ discard block |
||
2104 | 2104 | */ |
2105 | 2105 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
2106 | 2106 | |
2107 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
2108 | - foreach( $fields as $k => $field ) { |
|
2109 | - if( $field->adminOnly ) { |
|
2107 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
2108 | + foreach ( $fields as $k => $field ) { |
|
2109 | + if ( $field->adminOnly ) { |
|
2110 | 2110 | unset( $fields[ $k ] ); |
2111 | 2111 | } |
2112 | 2112 | } |
2113 | 2113 | return array_values( $fields ); |
2114 | 2114 | } |
2115 | 2115 | |
2116 | - foreach( $fields as &$field ) { |
|
2116 | + foreach ( $fields as &$field ) { |
|
2117 | 2117 | $field->adminOnly = false; |
2118 | 2118 | } |
2119 | 2119 | |
@@ -2134,7 +2134,7 @@ discard block |
||
2134 | 2134 | */ |
2135 | 2135 | private function unselect_default_values( $form ) { |
2136 | 2136 | |
2137 | - foreach ( $form['fields'] as &$field ) { |
|
2137 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2138 | 2138 | |
2139 | 2139 | if ( empty( $field->choices ) ) { |
2140 | 2140 | continue; |
@@ -2142,7 +2142,7 @@ discard block |
||
2142 | 2142 | |
2143 | 2143 | foreach ( $field->choices as &$choice ) { |
2144 | 2144 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
2145 | - $choice['isSelected'] = false; |
|
2145 | + $choice[ 'isSelected' ] = false; |
|
2146 | 2146 | } |
2147 | 2147 | } |
2148 | 2148 | } |
@@ -2167,22 +2167,22 @@ discard block |
||
2167 | 2167 | */ |
2168 | 2168 | function prefill_conditional_logic( $form ) { |
2169 | 2169 | |
2170 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
2170 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
2171 | 2171 | return $form; |
2172 | 2172 | } |
2173 | 2173 | |
2174 | 2174 | // Have Conditional Logic pre-fill fields as if the data were default values |
2175 | 2175 | /** @var GF_Field $field */ |
2176 | - foreach ( $form['fields'] as &$field ) { |
|
2176 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2177 | 2177 | |
2178 | - if( 'checkbox' === $field->type ) { |
|
2178 | + if ( 'checkbox' === $field->type ) { |
|
2179 | 2179 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
2180 | - $input_id = $input['id']; |
|
2180 | + $input_id = $input[ 'id' ]; |
|
2181 | 2181 | $choice = $field->choices[ $key ]; |
2182 | 2182 | $value = \GV\Utils::get( $this->entry, $input_id ); |
2183 | 2183 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
2184 | - if( $match ) { |
|
2185 | - $field->choices[ $key ]['isSelected'] = true; |
|
2184 | + if ( $match ) { |
|
2185 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
2186 | 2186 | } |
2187 | 2187 | } |
2188 | 2188 | } else { |
@@ -2190,15 +2190,15 @@ discard block |
||
2190 | 2190 | // We need to run through each field to set the default values |
2191 | 2191 | foreach ( $this->entry as $field_id => $field_value ) { |
2192 | 2192 | |
2193 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2193 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2194 | 2194 | |
2195 | - if( 'list' === $field->type ) { |
|
2195 | + if ( 'list' === $field->type ) { |
|
2196 | 2196 | $list_rows = maybe_unserialize( $field_value ); |
2197 | 2197 | |
2198 | 2198 | $list_field_value = array(); |
2199 | - foreach ( (array) $list_rows as $row ) { |
|
2200 | - foreach ( (array) $row as $column ) { |
|
2201 | - $list_field_value[] = $column; |
|
2199 | + foreach ( (array)$list_rows as $row ) { |
|
2200 | + foreach ( (array)$row as $column ) { |
|
2201 | + $list_field_value[ ] = $column; |
|
2202 | 2202 | } |
2203 | 2203 | } |
2204 | 2204 | |
@@ -2231,32 +2231,32 @@ discard block |
||
2231 | 2231 | * @see https://github.com/gravityview/GravityView/issues/840 |
2232 | 2232 | * @since develop |
2233 | 2233 | */ |
2234 | - $the_form = GFAPI::get_form( $form['id'] ); |
|
2234 | + $the_form = GFAPI::get_form( $form[ 'id' ] ); |
|
2235 | 2235 | $editable_ids = array(); |
2236 | - foreach ( $form['fields'] as $field ) { |
|
2237 | - $editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context |
|
2236 | + foreach ( $form[ 'fields' ] as $field ) { |
|
2237 | + $editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context |
|
2238 | 2238 | } |
2239 | 2239 | $remove_conditions_rule = array(); |
2240 | - foreach ( $the_form['fields'] as $field ) { |
|
2241 | - if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) { |
|
2242 | - foreach ( $field->conditionalLogic['rules'] as $i => $rule ) { |
|
2243 | - if ( ! in_array( $rule['fieldId'], $editable_ids ) ) { |
|
2240 | + foreach ( $the_form[ 'fields' ] as $field ) { |
|
2241 | + if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) { |
|
2242 | + foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) { |
|
2243 | + if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) { |
|
2244 | 2244 | /** |
2245 | 2245 | * This conditional field is not editable in this View. |
2246 | 2246 | * We need to remove the rule, but only if it matches. |
2247 | 2247 | */ |
2248 | - if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) { |
|
2248 | + if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) { |
|
2249 | 2249 | $value = $_field->get_value_export( $this->entry ); |
2250 | - } elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) { |
|
2251 | - $value = $this->entry[ $rule['fieldId'] ]; |
|
2250 | + } elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) { |
|
2251 | + $value = $this->entry[ $rule[ 'fieldId' ] ]; |
|
2252 | 2252 | } else { |
2253 | - $value = gform_get_meta( $this->entry['id'], $rule['fieldId'] ); |
|
2253 | + $value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] ); |
|
2254 | 2254 | } |
2255 | 2255 | |
2256 | - $match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] ); |
|
2256 | + $match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] ); |
|
2257 | 2257 | |
2258 | 2258 | if ( $match ) { |
2259 | - $remove_conditions_rule[] = array( $field['id'], $i ); |
|
2259 | + $remove_conditions_rule[ ] = array( $field[ 'id' ], $i ); |
|
2260 | 2260 | } |
2261 | 2261 | } |
2262 | 2262 | } |
@@ -2264,21 +2264,21 @@ discard block |
||
2264 | 2264 | } |
2265 | 2265 | |
2266 | 2266 | if ( $remove_conditions_rule ) { |
2267 | - foreach ( $form['fields'] as &$field ) { |
|
2267 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2268 | 2268 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2269 | 2269 | |
2270 | 2270 | list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
2271 | 2271 | |
2272 | - if ( $field['id'] == $rule_field_id ) { |
|
2273 | - unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
|
2274 | - gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) ); |
|
2272 | + if ( $field[ 'id' ] == $rule_field_id ) { |
|
2273 | + unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] ); |
|
2274 | + gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) ); |
|
2275 | 2275 | } |
2276 | 2276 | } |
2277 | 2277 | } |
2278 | 2278 | } |
2279 | 2279 | |
2280 | 2280 | /** Normalize the indices... */ |
2281 | - $form['fields'] = array_values( $form['fields'] ); |
|
2281 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
2282 | 2282 | |
2283 | 2283 | /** |
2284 | 2284 | * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields? |
@@ -2288,16 +2288,16 @@ discard block |
||
2288 | 2288 | */ |
2289 | 2289 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
2290 | 2290 | |
2291 | - if( $use_conditional_logic ) { |
|
2291 | + if ( $use_conditional_logic ) { |
|
2292 | 2292 | return $form; |
2293 | 2293 | } |
2294 | 2294 | |
2295 | - foreach( $form['fields'] as &$field ) { |
|
2295 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2296 | 2296 | /* @var GF_Field $field */ |
2297 | 2297 | $field->conditionalLogic = null; |
2298 | 2298 | } |
2299 | 2299 | |
2300 | - unset( $form['button']['conditionalLogic'] ); |
|
2300 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
2301 | 2301 | |
2302 | 2302 | return $form; |
2303 | 2303 | |
@@ -2314,7 +2314,7 @@ discard block |
||
2314 | 2314 | */ |
2315 | 2315 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
2316 | 2316 | |
2317 | - if( ! $this->is_edit_entry() ) { |
|
2317 | + if ( ! $this->is_edit_entry() ) { |
|
2318 | 2318 | return $has_conditional_logic; |
2319 | 2319 | } |
2320 | 2320 | |
@@ -2346,44 +2346,44 @@ discard block |
||
2346 | 2346 | * 2. There are two entries embedded using oEmbed |
2347 | 2347 | * 3. One of the entries has just been saved |
2348 | 2348 | */ |
2349 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
2349 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
2350 | 2350 | |
2351 | 2351 | $error = true; |
2352 | 2352 | |
2353 | 2353 | } |
2354 | 2354 | |
2355 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
2355 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
2356 | 2356 | |
2357 | 2357 | $error = true; |
2358 | 2358 | |
2359 | - } elseif( ! $this->verify_nonce() ) { |
|
2359 | + } elseif ( ! $this->verify_nonce() ) { |
|
2360 | 2360 | |
2361 | 2361 | /** |
2362 | 2362 | * If the Entry is embedded, there may be two entries on the same page. |
2363 | 2363 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
2364 | 2364 | */ |
2365 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
2365 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
2366 | 2366 | $error = true; |
2367 | 2367 | } else { |
2368 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
2368 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
2369 | 2369 | } |
2370 | 2370 | |
2371 | 2371 | } |
2372 | 2372 | |
2373 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
2374 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
2373 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
2374 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
2375 | 2375 | } |
2376 | 2376 | |
2377 | - if( $this->entry['status'] === 'trash' ) { |
|
2378 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
2377 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
2378 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
2379 | 2379 | } |
2380 | 2380 | |
2381 | 2381 | // No errors; everything's fine here! |
2382 | - if( empty( $error ) ) { |
|
2382 | + if ( empty( $error ) ) { |
|
2383 | 2383 | return true; |
2384 | 2384 | } |
2385 | 2385 | |
2386 | - if( $echo && $error !== true ) { |
|
2386 | + if ( $echo && $error !== true ) { |
|
2387 | 2387 | |
2388 | 2388 | $error = esc_html( $error ); |
2389 | 2389 | |
@@ -2391,10 +2391,10 @@ discard block |
||
2391 | 2391 | * @since 1.9 |
2392 | 2392 | */ |
2393 | 2393 | if ( ! empty( $this->entry ) ) { |
2394 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
2394 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
2395 | 2395 | } |
2396 | 2396 | |
2397 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
2397 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
2398 | 2398 | } |
2399 | 2399 | |
2400 | 2400 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2414,17 +2414,17 @@ discard block |
||
2414 | 2414 | |
2415 | 2415 | $error = NULL; |
2416 | 2416 | |
2417 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2418 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
2417 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2418 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
2419 | 2419 | } |
2420 | 2420 | |
2421 | 2421 | // No errors; everything's fine here! |
2422 | - if( empty( $error ) ) { |
|
2422 | + if ( empty( $error ) ) { |
|
2423 | 2423 | return true; |
2424 | 2424 | } |
2425 | 2425 | |
2426 | - if( $echo ) { |
|
2427 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
2426 | + if ( $echo ) { |
|
2427 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
2428 | 2428 | } |
2429 | 2429 | |
2430 | 2430 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2445,14 +2445,14 @@ discard block |
||
2445 | 2445 | private function check_user_cap_edit_field( $field ) { |
2446 | 2446 | |
2447 | 2447 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
2448 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2448 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2449 | 2449 | return true; |
2450 | 2450 | } |
2451 | 2451 | |
2452 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
2452 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
2453 | 2453 | |
2454 | - if( $field_cap ) { |
|
2455 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
2454 | + if ( $field_cap ) { |
|
2455 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
2456 | 2456 | } |
2457 | 2457 | |
2458 | 2458 | return false; |
@@ -2466,17 +2466,17 @@ discard block |
||
2466 | 2466 | public function verify_nonce() { |
2467 | 2467 | |
2468 | 2468 | // Verify form submitted for editing single |
2469 | - if( $this->is_edit_entry_submission() ) { |
|
2469 | + if ( $this->is_edit_entry_submission() ) { |
|
2470 | 2470 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2471 | 2471 | } |
2472 | 2472 | |
2473 | 2473 | // Verify |
2474 | - else if( ! $this->is_edit_entry() ) { |
|
2474 | + else if ( ! $this->is_edit_entry() ) { |
|
2475 | 2475 | $valid = false; |
2476 | 2476 | } |
2477 | 2477 | |
2478 | 2478 | else { |
2479 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2479 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2480 | 2480 | } |
2481 | 2481 | |
2482 | 2482 | /** |
@@ -2536,7 +2536,7 @@ discard block |
||
2536 | 2536 | */ |
2537 | 2537 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
2538 | 2538 | |
2539 | - return (array) $labels; |
|
2539 | + return (array)$labels; |
|
2540 | 2540 | } |
2541 | 2541 | |
2542 | 2542 | } //end class |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | ); |
107 | 107 | |
108 | 108 | if ( ! empty( $action ) ) { |
109 | - $settings['edd_action'] = esc_attr( $action ); |
|
109 | + $settings[ 'edd_action' ] = esc_attr( $action ); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | return array_map( 'urlencode', $settings ); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // If doing ajax, get outta here. |
129 | - if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST('action') ) ) { |
|
129 | + if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST( 'action' ) ) ) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | 'format' => 'json', |
174 | 174 | ) ); |
175 | 175 | |
176 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
176 | + if ( $is_ajax && empty( $data[ 'license' ] ) ) { |
|
177 | 177 | die( -1 ); |
178 | 178 | } |
179 | 179 | |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | |
202 | 202 | $json = json_encode( $license_data ); |
203 | 203 | |
204 | - $update_license = Utils::get( $data, 'update' ) || 'gravityview_license' === Utils::_POST('action'); |
|
204 | + $update_license = Utils::get( $data, 'update' ) || 'gravityview_license' === Utils::_POST( 'action' ); |
|
205 | 205 | |
206 | 206 | $is_check_action_button = ( 'check_license' === Utils::get( $data, 'edd_action' ) && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
207 | 207 | |
208 | - do_action('gravityview/admin_installer/delete_downloads_data', true ); |
|
208 | + do_action( 'gravityview/admin_installer/delete_downloads_data', true ); |
|
209 | 209 | |
210 | 210 | if ( $is_check_action_button ) { |
211 | 211 | delete_transient( self::status_transient_key ); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | // most likely a mistake. |
217 | 217 | } else if ( $license_data->license !== 'failed' && $update_license ) { |
218 | 218 | |
219 | - if ( ! empty( $data['field_id'] ) ) { |
|
219 | + if ( ! empty( $data[ 'field_id' ] ) ) { |
|
220 | 220 | set_transient( self::status_transient_key, $license_data, DAY_IN_SECONDS ); |
221 | 221 | } |
222 | 222 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $class = 'hide'; |
245 | 245 | $message = ''; |
246 | 246 | } else { |
247 | - if( ! empty( $license_data->error ) ) { |
|
247 | + if ( ! empty( $license_data->error ) ) { |
|
248 | 248 | $class = 'error'; |
249 | 249 | $string_key = $license_data->error; |
250 | 250 | } else { $class = $license_data->license; |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public function license_details( $response = array() ) { |
270 | 270 | |
271 | - $response = (array) $response; |
|
271 | + $response = (array)$response; |
|
272 | 272 | |
273 | 273 | $return = ''; |
274 | 274 | $wrapper = '<span class="gv-license-details" aria-live="polite" aria-busy="false">%s</span>'; |
275 | 275 | |
276 | - if ( ! empty( $response['license_key'] ) ) { |
|
276 | + if ( ! empty( $response[ 'license_key' ] ) ) { |
|
277 | 277 | $return .= '<h3>' . rtrim( esc_html__( 'License Details:', 'gravityview' ), ':' ) . '</h3>'; |
278 | 278 | |
279 | 279 | if ( in_array( Utils::get( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | |
285 | - $return .= $this->strings( $response['license'], $response ); |
|
286 | - } elseif ( ! empty( $response['license_name'] ) ) { |
|
285 | + $return .= $this->strings( $response[ 'license' ], $response ); |
|
286 | + } elseif ( ! empty( $response[ 'license_name' ] ) ) { |
|
287 | 287 | $response_keys = array( |
288 | 288 | 'license_name' => '', |
289 | 289 | 'license_limit' => '', |
@@ -298,22 +298,22 @@ discard block |
||
298 | 298 | $response = wp_parse_args( $response, $response_keys ); |
299 | 299 | |
300 | 300 | $login_link_class = gravityview()->plugin->is_GF_25() ? 'button button-outline outline' : 'text-link'; |
301 | - $renews_on = ( 'lifetime' === $response['expires'] ) ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response['expires'] ) - DAY_IN_SECONDS ) ); |
|
302 | - $login_link = sprintf( '<a href="%s" class="gv-access-account ' . $login_link_class . '" rel="external">%s</a>', esc_url( sprintf( 'https://www.gravitykit.com/wp-login.php?username=%s', $response['customer_email'] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
303 | - $local_text = ( ! empty( $response['is_local'] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
304 | - $license_limit = empty( $response['license_limit'] ) ? __( 'Unlimited', 'gravityview' ) : (int) $response['license_limit']; |
|
301 | + $renews_on = ( 'lifetime' === $response[ 'expires' ] ) ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response[ 'expires' ] ) - DAY_IN_SECONDS ) ); |
|
302 | + $login_link = sprintf( '<a href="%s" class="gv-access-account ' . $login_link_class . '" rel="external">%s</a>', esc_url( sprintf( 'https://www.gravitykit.com/wp-login.php?username=%s', $response[ 'customer_email' ] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
303 | + $local_text = ( ! empty( $response[ 'is_local' ] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
304 | + $license_limit = empty( $response[ 'license_limit' ] ) ? __( 'Unlimited', 'gravityview' ) : (int)$response[ 'license_limit' ]; |
|
305 | 305 | |
306 | 306 | |
307 | 307 | $details = array( |
308 | - 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), '<span class="gv-license-detail">' . esc_html( $response['license_name'] ) . '</span>' ), |
|
309 | - 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), '<span class="gv-license-detail">' . esc_html__( $response['customer_name'], 'gravityview' ), esc_html__( $response['customer_email'], 'gravityview' ) ) . '</span>' . $renews_on . $login_link, |
|
310 | - 'activations' => sprintf( str_replace( '%d', '%s', esc_html__( 'Activations: %d of %s sites', 'gravityview' ) ), '<span class="gv-license-detail">' . intval( $response['site_count'] ), esc_html( $license_limit ) ) . '</span>' . $local_text, |
|
311 | - 'upgrade' => $this->get_upgrade_html( $response['upgrades'] ), |
|
308 | + 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), '<span class="gv-license-detail">' . esc_html( $response[ 'license_name' ] ) . '</span>' ), |
|
309 | + 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), '<span class="gv-license-detail">' . esc_html__( $response[ 'customer_name' ], 'gravityview' ), esc_html__( $response[ 'customer_email' ], 'gravityview' ) ) . '</span>' . $renews_on . $login_link, |
|
310 | + 'activations' => sprintf( str_replace( '%d', '%s', esc_html__( 'Activations: %d of %s sites', 'gravityview' ) ), '<span class="gv-license-detail">' . intval( $response[ 'site_count' ] ), esc_html( $license_limit ) ) . '</span>' . $local_text, |
|
311 | + 'upgrade' => $this->get_upgrade_html( $response[ 'upgrades' ] ), |
|
312 | 312 | ); |
313 | 313 | |
314 | - if ( ! empty( $response['error'] ) && 'expired' === $response['error'] ) { |
|
315 | - unset( $details['upgrade'] ); |
|
316 | - $details['licensed_to'] .= '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
314 | + if ( ! empty( $response[ 'error' ] ) && 'expired' === $response[ 'error' ] ) { |
|
315 | + unset( $details[ 'upgrade' ] ); |
|
316 | + $details[ 'licensed_to' ] .= '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | $return .= '<ul>'; |
@@ -345,20 +345,20 @@ discard block |
||
345 | 345 | if ( ! empty( $upgrades ) ) { |
346 | 346 | |
347 | 347 | $locale_parts = explode( '_', get_locale() ); |
348 | - $is_english = ( 'en' === $locale_parts[0] ); |
|
348 | + $is_english = ( 'en' === $locale_parts[ 0 ] ); |
|
349 | 349 | |
350 | 350 | $output .= '<h4>' . esc_html__( 'Upgrades available:', 'gravityview' ) . '</h4>'; |
351 | 351 | $output .= '<ul>'; |
352 | 352 | |
353 | 353 | foreach ( $upgrades as $upgrade_id => $upgrade ) { |
354 | - $upgrade = (object) $upgrade; |
|
354 | + $upgrade = (object)$upgrade; |
|
355 | 355 | |
356 | 356 | $anchor_text = sprintf( esc_html_x( 'Upgrade to %1$s for %2$s', '1: GravityView upgrade name, 2: Cost of upgrade', 'gravityview' ), esc_attr( $upgrade->name ), esc_attr( $upgrade->price ) ); |
357 | 357 | |
358 | 358 | if ( $is_english && isset( $upgrade->description ) ) { |
359 | 359 | $message = esc_html( $upgrade->description ); |
360 | 360 | } else { |
361 | - switch( $upgrade->price_id ) { |
|
361 | + switch ( $upgrade->price_id ) { |
|
362 | 362 | // Interstellar |
363 | 363 | case 1: |
364 | 364 | default: |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | 'invalid_item_id' => esc_html__( 'This license key does not have access to this plugin.', 'gravityview' ), |
438 | 438 | 'missing' => esc_html__( 'The license key entered is invalid.', 'gravityview' ), // Missing is "the license couldn't be found", not "you submitted an empty license" |
439 | 439 | 'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ), |
440 | - 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), |
|
440 | + 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="' . esc_url( $this->get_license_renewal_url( $license_data ) ) . '">', '</a>' ), |
|
441 | 441 | 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
442 | 442 | 'verifying_license' => esc_html__( 'Verifying license…', 'gravityview' ), |
443 | 443 | 'activate_license' => esc_html__( 'Activate License', 'gravityview' ), |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | |
466 | 466 | if ( ! empty( $license_data->renewal_url ) ) { |
467 | 467 | $renew_license_url = $license_data->renewal_url; |
468 | - } elseif( ! empty( $license_data->license_key ) ) { |
|
468 | + } elseif ( ! empty( $license_data->license_key ) ) { |
|
469 | 469 | $renew_license_url = sprintf( 'https://www.gravitykit.com/checkout/?download_id=17&edd_license_key=%s', $license_data->license_key ); |
470 | 470 | } else { |
471 | 471 | $renew_license_url = 'https://www.gravitykit.com/account/'; |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | * @return array|\WP_Error |
483 | 483 | */ |
484 | 484 | private function _license_get_remote_response( $data, $license = '' ) { |
485 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
485 | + $api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license ); |
|
486 | 486 | |
487 | 487 | $url = add_query_arg( $api_params, self::url ); |
488 | 488 | |
@@ -522,9 +522,9 @@ discard block |
||
522 | 522 | private function license_call_update_settings( $license_data, $data ) { |
523 | 523 | $settings = array(); |
524 | 524 | |
525 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
526 | - $settings['license_key_status'] = $license_data->license; |
|
527 | - $settings['license_key_response'] = (array)$license_data; |
|
525 | + $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] ); |
|
526 | + $settings[ 'license_key_status' ] = $license_data->license; |
|
527 | + $settings[ 'license_key_response' ] = (array)$license_data; |
|
528 | 528 | |
529 | 529 | $this->settings->set( $settings ); |
530 | 530 | } |
@@ -544,9 +544,9 @@ discard block |
||
544 | 544 | $status = trim( $this->settings->get( 'license_key_status' ) ); |
545 | 545 | $key = trim( $this->settings->get( 'license_key' ) ); |
546 | 546 | |
547 | - if ( !empty( $key ) ) { |
|
547 | + if ( ! empty( $key ) ) { |
|
548 | 548 | $response = $this->settings->get( 'license_key_response' ); |
549 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
549 | + $response = is_array( $response ) ? (object)$response : json_decode( $response ); |
|
550 | 550 | } else { |
551 | 551 | $response = array(); |
552 | 552 | } |
@@ -589,11 +589,11 @@ discard block |
||
589 | 589 | |
590 | 590 | $submit = '<div class="gv-edd-button-wrapper">'; |
591 | 591 | foreach ( $fields as $field ) { |
592 | - $field['type'] = 'button'; |
|
593 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
594 | - $field['style'] = 'margin-left: 10px;'; |
|
595 | - if( $disabled_attribute ) { |
|
596 | - $field['disabled'] = $disabled_attribute; |
|
592 | + $field[ 'type' ] = 'button'; |
|
593 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class; |
|
594 | + $field[ 'style' ] = 'margin-left: 10px;'; |
|
595 | + if ( $disabled_attribute ) { |
|
596 | + $field[ 'disabled' ] = $disabled_attribute; |
|
597 | 597 | } |
598 | 598 | $submit .= $this->settings->as_html( $field, $echo ); |
599 | 599 | } |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | 'url' => home_url(), |
672 | 672 | 'site_data' => $this->get_site_data(), |
673 | 673 | ), |
674 | - )); |
|
674 | + ) ); |
|
675 | 675 | |
676 | 676 | // make sure the response came back okay |
677 | 677 | if ( is_wp_error( $response ) ) { |
@@ -701,45 +701,45 @@ discard block |
||
701 | 701 | $theme_data = wp_get_theme(); |
702 | 702 | $theme = $theme_data->Name . ' ' . $theme_data->Version; |
703 | 703 | |
704 | - $data['gv_version'] = Plugin::$version; |
|
705 | - $data['php_version'] = phpversion(); |
|
706 | - $data['wp_version'] = get_bloginfo( 'version' ); |
|
707 | - $data['gf_version'] = \GFForms::$version; |
|
708 | - $data['server'] = Utils::get( $_SERVER, 'SERVER_SOFTWARE' ); |
|
709 | - $data['multisite'] = is_multisite(); |
|
710 | - $data['theme'] = $theme; |
|
711 | - $data['url'] = home_url(); |
|
712 | - $data['license_key'] = $this->settings->get( 'license_key' ); |
|
713 | - $data['beta'] = $this->settings->get( 'beta' ); |
|
704 | + $data[ 'gv_version' ] = Plugin::$version; |
|
705 | + $data[ 'php_version' ] = phpversion(); |
|
706 | + $data[ 'wp_version' ] = get_bloginfo( 'version' ); |
|
707 | + $data[ 'gf_version' ] = \GFForms::$version; |
|
708 | + $data[ 'server' ] = Utils::get( $_SERVER, 'SERVER_SOFTWARE' ); |
|
709 | + $data[ 'multisite' ] = is_multisite(); |
|
710 | + $data[ 'theme' ] = $theme; |
|
711 | + $data[ 'url' ] = home_url(); |
|
712 | + $data[ 'license_key' ] = $this->settings->get( 'license_key' ); |
|
713 | + $data[ 'beta' ] = $this->settings->get( 'beta' ); |
|
714 | 714 | |
715 | 715 | // View Data |
716 | 716 | $gravityview_posts = wp_count_posts( 'gravityview', 'readable' ); |
717 | 717 | |
718 | - $data['view_count'] = null; |
|
719 | - $data['view_first'] = null; |
|
720 | - $data['view_latest'] = null; |
|
718 | + $data[ 'view_count' ] = null; |
|
719 | + $data[ 'view_first' ] = null; |
|
720 | + $data[ 'view_latest' ] = null; |
|
721 | 721 | |
722 | 722 | if ( $gravityview_posts->publish ) { |
723 | - $data['view_count'] = $gravityview_posts->publish; |
|
723 | + $data[ 'view_count' ] = $gravityview_posts->publish; |
|
724 | 724 | |
725 | 725 | $first = get_posts( 'numberposts=1&post_type=gravityview&post_status=publish&order=ASC' ); |
726 | 726 | $latest = get_posts( 'numberposts=1&post_type=gravityview&post_status=publish&order=DESC' ); |
727 | 727 | |
728 | 728 | if ( $first = array_shift( $first ) ) { |
729 | - $data['view_first'] = $first->post_date; |
|
729 | + $data[ 'view_first' ] = $first->post_date; |
|
730 | 730 | } |
731 | 731 | if ( $latest = array_pop( $latest ) ) { |
732 | - $data['view_latest'] = $latest->post_date; |
|
732 | + $data[ 'view_latest' ] = $latest->post_date; |
|
733 | 733 | } |
734 | 734 | } |
735 | 735 | |
736 | 736 | // Form counts |
737 | 737 | if ( class_exists( 'GFFormsModel' ) ) { |
738 | 738 | $form_data = \GFFormsModel::get_form_count(); |
739 | - $data['forms_total'] = Utils::get( $form_data, 'total', 0 ); |
|
740 | - $data['forms_active'] = Utils::get( $form_data, 'active', 0 ); |
|
741 | - $data['forms_inactive'] = Utils::get( $form_data, 'inactive', 0 ); |
|
742 | - $data['forms_trash'] = Utils::get( $form_data, 'inactive', 0 ); |
|
739 | + $data[ 'forms_total' ] = Utils::get( $form_data, 'total', 0 ); |
|
740 | + $data[ 'forms_active' ] = Utils::get( $form_data, 'active', 0 ); |
|
741 | + $data[ 'forms_inactive' ] = Utils::get( $form_data, 'inactive', 0 ); |
|
742 | + $data[ 'forms_trash' ] = Utils::get( $form_data, 'inactive', 0 ); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | // Retrieve current plugin information |
@@ -747,13 +747,13 @@ discard block |
||
747 | 747 | include ABSPATH . '/wp-admin/includes/plugin.php'; |
748 | 748 | } |
749 | 749 | |
750 | - $data['integrations'] = self::get_related_plugins_and_extensions(); |
|
751 | - $data['active_plugins'] = get_option( 'active_plugins', array() ); |
|
752 | - $data['inactive_plugins'] = array(); |
|
753 | - $data['locale'] = get_locale(); |
|
750 | + $data[ 'integrations' ] = self::get_related_plugins_and_extensions(); |
|
751 | + $data[ 'active_plugins' ] = get_option( 'active_plugins', array() ); |
|
752 | + $data[ 'inactive_plugins' ] = array(); |
|
753 | + $data[ 'locale' ] = get_locale(); |
|
754 | 754 | |
755 | 755 | // Validate request on the GV server |
756 | - $data['hash'] = 'gv_version.url.locale:' . sha1( $data['gv_version'] . $data['url'] . $data['locale'] ); |
|
756 | + $data[ 'hash' ] = 'gv_version.url.locale:' . sha1( $data[ 'gv_version' ] . $data[ 'url' ] . $data[ 'locale' ] ); |
|
757 | 757 | |
758 | 758 | return $data; |
759 | 759 | } |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | |
784 | 784 | $plugin_data = get_plugin_data( $active_plugin ); |
785 | 785 | |
786 | - $extensions[] = sprintf( '%s %s', $plugin_data['Name'], $plugin_data['Version'] ); |
|
786 | + $extensions[ ] = sprintf( '%s %s', $plugin_data[ 'Name' ], $plugin_data[ 'Version' ] ); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | if ( ! empty( $extensions ) ) { |
@@ -26,52 +26,52 @@ |
||
26 | 26 | |
27 | 27 | <?php // list all the available templates (type= fresh or custom ) ?> |
28 | 28 | <div class="gv-grid"> |
29 | - <?php foreach( $templates as $id => $template ) { |
|
29 | + <?php foreach ( $templates as $id => $template ) { |
|
30 | 30 | $selected = ( $id == $current_template ) ? ' gv-selected' : ''; |
31 | - $placeholder = ! empty( $template['buy_source'] ); |
|
32 | - $is_included = ! empty( $template['included'] ); |
|
31 | + $placeholder = ! empty( $template[ 'buy_source' ] ); |
|
32 | + $is_included = ! empty( $template[ 'included' ] ); |
|
33 | 33 | $plugin_data = GravityView_Admin_Installer::get_wp_plugins_data( \GV\Utils::get( $template, 'textdomain', '' ) ); |
34 | 34 | $button_text = empty( $plugin_data ) ? esc_html__( 'Install Layout', 'gravityview' ) : esc_html__( 'Activate & Select Layout', 'gravityview' ); |
35 | 35 | $button_class = 'gv-layout-' . ( empty( $plugin_data ) ? 'install' : 'activate' ); |
36 | - $template_path = isset($plugin_data['path']) ? $plugin_data['path'] : ''; |
|
36 | + $template_path = isset( $plugin_data[ 'path' ] ) ? $plugin_data[ 'path' ] : ''; |
|
37 | 37 | |
38 | 38 | ?> |
39 | 39 | <div class="gv-grid-col-1-4"> |
40 | - <div class="gv-view-types-module<?php echo $selected; if( $placeholder ) { echo ' gv-view-template-placeholder'; } ?>" data-filter="<?php echo esc_attr( $template['type'] ); ?>"> |
|
40 | + <div class="gv-view-types-module<?php echo $selected; if ( $placeholder ) { echo ' gv-view-template-placeholder'; } ?>" data-filter="<?php echo esc_attr( $template[ 'type' ] ); ?>"> |
|
41 | 41 | <div class="gv-view-types-normal"> |
42 | - <img src="<?php echo esc_url( $template['logo'] ); ?>" alt="<?php echo esc_attr( $template['label'] ); ?>"> |
|
43 | - <h5><?php echo esc_html( $template['label'] ); ?></h5> |
|
44 | - <p class="description"><?php echo esc_html( $template['description'] ); ?></p> |
|
42 | + <img src="<?php echo esc_url( $template[ 'logo' ] ); ?>" alt="<?php echo esc_attr( $template[ 'label' ] ); ?>"> |
|
43 | + <h5><?php echo esc_html( $template[ 'label' ] ); ?></h5> |
|
44 | + <p class="description"><?php echo esc_html( $template[ 'description' ] ); ?></p> |
|
45 | 45 | </div> |
46 | 46 | <div class="gv-view-types-hover"> |
47 | 47 | <div> |
48 | 48 | <?php |
49 | - if( $is_included ) { |
|
49 | + if ( $is_included ) { |
|
50 | 50 | ?> |
51 | 51 | <p><a href="<?php echo esc_url( admin_url( 'edit.php?post_type=gravityview&page=gv-admin-installer' ) ); ?>" class="button button-secondary button-hero <?php echo $button_class; ?>" rel="internal" data-template-path="<?php echo $template_path; ?>"><?php echo $button_text; ?></a></p> |
52 | - <?php if( !empty( $template['license'] ) ) { ?> |
|
53 | - <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), esc_html( str_replace( ' ', ' ', $template['license'] ) ) ); ?></p> |
|
52 | + <?php if ( ! empty( $template[ 'license' ] ) ) { ?> |
|
53 | + <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), esc_html( str_replace( ' ', ' ', $template[ 'license' ] ) ) ); ?></p> |
|
54 | 54 | <?php } ?> |
55 | 55 | <?php |
56 | - } elseif( $placeholder ) { |
|
57 | - $utm_string = '?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=' . urlencode( $template['license'] ) . '&utm_content=' . urlencode( $template['slug'] ); |
|
56 | + } elseif ( $placeholder ) { |
|
57 | + $utm_string = '?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=' . urlencode( $template[ 'license' ] ) . '&utm_content=' . urlencode( $template[ 'slug' ] ); |
|
58 | 58 | ?> |
59 | - <p><a href="<?php echo esc_url( $template['buy_source'] ); ?>" class="button button-primary button-hero" rel="noreferrer noopener external"><?php esc_html_e( 'Buy Now', 'gravityview'); ?></a></p> |
|
59 | + <p><a href="<?php echo esc_url( $template[ 'buy_source' ] ); ?>" class="button button-primary button-hero" rel="noreferrer noopener external"><?php esc_html_e( 'Buy Now', 'gravityview' ); ?></a></p> |
|
60 | 60 | |
61 | - <?php if( !empty( $template['preview'] ) ) { ?> |
|
62 | - <p><a href="<?php echo esc_url( $template['preview'] ); ?>" rel="noreferrer noopener external" class="button button-secondary"><i class="dashicons dashicons-external" style="vertical-align: middle;" title="<?php esc_html_e( 'View a live demo of this layout', 'gravityview'); ?>"></i> <?php esc_html_e( 'Try a demo', 'gravityview' ); ?></a></p> |
|
61 | + <?php if ( ! empty( $template[ 'preview' ] ) ) { ?> |
|
62 | + <p><a href="<?php echo esc_url( $template[ 'preview' ] ); ?>" rel="noreferrer noopener external" class="button button-secondary"><i class="dashicons dashicons-external" style="vertical-align: middle;" title="<?php esc_html_e( 'View a live demo of this layout', 'gravityview' ); ?>"></i> <?php esc_html_e( 'Try a demo', 'gravityview' ); ?></a></p> |
|
63 | 63 | <?php } ?> |
64 | 64 | |
65 | - <?php if( ! empty( $template['license'] ) ) { ?> |
|
66 | - <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), '<a href="https://www.gravitykit.com/pricing/' . esc_attr( $utm_string ) . '" rel="noreferrer noopener external">' . esc_html( str_replace( ' ', ' ', $template['license'] ) ) . '</a>' ); ?></p> |
|
65 | + <?php if ( ! empty( $template[ 'license' ] ) ) { ?> |
|
66 | + <p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), '<a href="https://www.gravitykit.com/pricing/' . esc_attr( $utm_string ) . '" rel="noreferrer noopener external">' . esc_html( str_replace( ' ', ' ', $template[ 'license' ] ) ) . '</a>' ); ?></p> |
|
67 | 67 | <?php } ?> |
68 | 68 | <?php } |
69 | 69 | |
70 | - if ($placeholder || $is_included) { ?> </div><div class="hidden"> <?php } ?> |
|
70 | + if ( $placeholder || $is_included ) { ?> </div><div class="hidden"> <?php } ?> |
|
71 | 71 | |
72 | - <p><a href="#gv_select_template" role="button" class="gv_select_template button button-hero button-primary" data-templateid="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Select', 'gravityview'); ?></a></p> |
|
73 | - <?php if( !empty( $template['preview'] ) ) { ?> |
|
74 | - <a href="<?php echo esc_url( $template['preview'] ); ?>" rel="external" class="gv-site-preview"><i class="dashicons dashicons-welcome-view-site" title="<?php esc_html_e( 'View a live demo of this preset', 'gravityview'); ?>"></i></a> |
|
72 | + <p><a href="#gv_select_template" role="button" class="gv_select_template button button-hero button-primary" data-templateid="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Select', 'gravityview' ); ?></a></p> |
|
73 | + <?php if ( ! empty( $template[ 'preview' ] ) ) { ?> |
|
74 | + <a href="<?php echo esc_url( $template[ 'preview' ] ); ?>" rel="external" class="gv-site-preview"><i class="dashicons dashicons-welcome-view-site" title="<?php esc_html_e( 'View a live demo of this preset', 'gravityview' ); ?>"></i></a> |
|
75 | 75 | <?php } ?> |
76 | 76 | </div> |
77 | 77 | </div> |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @return GravityView_Compatibility |
77 | 77 | */ |
78 | 78 | public static function getInstance() { |
79 | - if( self::$instance ) { |
|
79 | + if ( self::$instance ) { |
|
80 | 80 | return self::$instance; |
81 | 81 | } |
82 | 82 | return new self; |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | // If Gravity Forms doesn't exist or is outdated, load the admin view class to |
139 | 139 | // show the notice, but not load any post types or process shortcodes. |
140 | 140 | // Without Gravity Forms, there is no GravityView. Beautiful, really. |
141 | - if( ! self::is_valid() ) { |
|
141 | + if ( ! self::is_valid() ) { |
|
142 | 142 | |
143 | 143 | // If the plugin's not loaded, might as well hide the shortcode for people. |
144 | - add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice') ); |
|
144 | + add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice' ) ); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | } |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function _shortcode_gf_notice( $atts = array(), $content = null, $shortcode = 'gravityview' ) { |
169 | 169 | |
170 | - if( ! GVCommon::has_cap( 'activate_plugins' ) ) { |
|
170 | + if ( ! GVCommon::has_cap( 'activate_plugins' ) ) { |
|
171 | 171 | return null; |
172 | 172 | } |
173 | 173 | |
174 | 174 | $notices = self::get_notices(); |
175 | 175 | |
176 | - $message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>' . esc_html__( 'You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview') . '</em></p>'; |
|
177 | - foreach( (array)$notices as $notice ) { |
|
178 | - $message .= wpautop( $notice['message'] ); |
|
176 | + $message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>' . esc_html__( 'You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview' ) . '</em></p>'; |
|
177 | + foreach ( (array)$notices as $notice ) { |
|
178 | + $message .= wpautop( $notice[ 'message' ] ); |
|
179 | 179 | } |
180 | 180 | $message .= '</div>'; |
181 | 181 | |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | |
196 | 196 | if ( ! gravityview()->plugin->is_compatible_php() ) { |
197 | 197 | |
198 | - self::$notices['php_version'] = array( |
|
198 | + self::$notices[ 'php_version' ] = array( |
|
199 | 199 | 'class' => 'error', |
200 | - 'message' => sprintf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' ), |
|
200 | + 'message' => sprintf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . phpversion() . '</span>' ), |
|
201 | 201 | 'cap' => 'manage_options', |
202 | 202 | 'dismiss' => 'php_version', |
203 | 203 | ); |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | if ( ! gravityview()->plugin->is_compatible_future_php() ) { |
209 | 209 | |
210 | 210 | // Show the notice on every update. Yes, annoying, but not as annoying as a plugin breaking. |
211 | - $key = sprintf('php_%s_%s', GV_FUTURE_MIN_PHP_VERSION, GravityView_Plugin::version ); |
|
211 | + $key = sprintf( 'php_%s_%s', GV_FUTURE_MIN_PHP_VERSION, GravityView_Plugin::version ); |
|
212 | 212 | |
213 | 213 | self::$notices[ $key ] = array( |
214 | 214 | 'class' => 'error', |
215 | - 'message' => sprintf( __( "%sGravityView will soon require PHP Version %s.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_FUTURE_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' ), |
|
215 | + 'message' => sprintf( __( "%sGravityView will soon require PHP Version %s.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_FUTURE_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . phpversion() . '</span>' ), |
|
216 | 216 | 'cap' => 'manage_options', |
217 | 217 | 'dismiss' => $key, |
218 | 218 | ); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | if ( ! gravityview()->plugin->is_compatible_wordpress() ) { |
239 | 239 | |
240 | - self::$notices['wp_version'] = array( |
|
240 | + self::$notices[ 'wp_version' ] = array( |
|
241 | 241 | 'class' => 'error', |
242 | 242 | 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . $wp_version . '</span>' ), |
243 | 243 | 'cap' => 'update_core', |
@@ -271,17 +271,17 @@ discard block |
||
271 | 271 | public static function check_gravityforms() { |
272 | 272 | |
273 | 273 | // Bypass other checks: if the class exists |
274 | - if( class_exists( 'GFCommon' ) ) { |
|
274 | + if ( class_exists( 'GFCommon' ) ) { |
|
275 | 275 | |
276 | 276 | // Does the version meet future requirements? |
277 | - if( true === gravityview()->plugin->is_compatible_future_gravityforms() ) { |
|
277 | + if ( true === gravityview()->plugin->is_compatible_future_gravityforms() ) { |
|
278 | 278 | return true; |
279 | 279 | } |
280 | 280 | |
281 | 281 | // Does it meet minimum requirements? |
282 | 282 | $meets_minimum = gravityview()->plugin->is_compatible_gravityforms(); |
283 | 283 | |
284 | - if( $meets_minimum ) { |
|
284 | + if ( $meets_minimum ) { |
|
285 | 285 | /* translators: first placeholder is the future required version of Gravity Forms. The second placeholder is the current version of Gravity Forms. */ |
286 | 286 | $title = __( 'In the future, GravityView will require Gravity Forms Version %s or newer.', 'gravityview' ); |
287 | 287 | $version = GV_FUTURE_MIN_GF_VERSION; |
@@ -296,14 +296,14 @@ discard block |
||
296 | 296 | $message = '<h3>' . esc_html( sprintf( $title, $version ) ) . '</h3>'; |
297 | 297 | |
298 | 298 | /* translators: the placeholder is the current version of Gravity Forms. */ |
299 | - $message .= '<p>' . sprintf( esc_html__( "You're using Version %s. Please update your Gravity Forms or purchase a license.", 'gravityview' ), '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>' ) . '</p>'; |
|
299 | + $message .= '<p>' . sprintf( esc_html__( "You're using Version %s. Please update your Gravity Forms or purchase a license.", 'gravityview' ), '<span style="font-family: Consolas, Courier, monospace;">' . GFCommon::$version . '</span>' ) . '</p>'; |
|
300 | 300 | |
301 | 301 | /* translators: In this context, "get" means purchase */ |
302 | 302 | $message .= '<p><a href="https://www.gravitykit.com/gravityforms/" class="button button-secondary button-large button-hero">' . esc_html__( 'Get the Latest Gravity Forms', 'gravityview' ) . '</a></p>'; |
303 | 303 | |
304 | 304 | |
305 | 305 | // Show the notice even if the future version requirements aren't met |
306 | - self::$notices['gf_version'] = array( |
|
306 | + self::$notices[ 'gf_version' ] = array( |
|
307 | 307 | 'class' => $class, |
308 | 308 | 'message' => $message, |
309 | 309 | 'cap' => 'update_plugins', |
@@ -321,42 +321,42 @@ discard block |
||
321 | 321 | * OR |
322 | 322 | * It's the Network Admin and we just don't know whether the sites have GF activated themselves. |
323 | 323 | */ |
324 | - if( true === $gf_status || is_network_admin() ) { |
|
324 | + if ( true === $gf_status || is_network_admin() ) { |
|
325 | 325 | return true; |
326 | 326 | } |
327 | 327 | |
328 | 328 | // If GFCommon doesn't exist, assume GF not active |
329 | 329 | $return = false; |
330 | 330 | |
331 | - switch( $gf_status ) { |
|
331 | + switch ( $gf_status ) { |
|
332 | 332 | case 'inactive': |
333 | 333 | |
334 | 334 | // Required for multisite |
335 | - if( ! function_exists('wp_create_nonce') ) { |
|
335 | + if ( ! function_exists( 'wp_create_nonce' ) ) { |
|
336 | 336 | require_once ABSPATH . WPINC . '/pluggable.php'; |
337 | 337 | } |
338 | 338 | |
339 | 339 | // Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE" |
340 | - if( is_multisite() ) { |
|
340 | + if ( is_multisite() ) { |
|
341 | 341 | wp_cookie_constants(); |
342 | 342 | } |
343 | 343 | |
344 | 344 | $return = false; |
345 | 345 | |
346 | - $button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php') . '" class="button button-large">'; |
|
346 | + $button = function_exists( 'is_network_admin' ) && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="' . wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php' ) . '" class="button button-large">'; |
|
347 | 347 | |
348 | - self::$notices['gf_inactive'] = array( |
|
348 | + self::$notices[ 'gf_inactive' ] = array( |
|
349 | 349 | 'class' => 'error', |
350 | - 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview' ), '<h3>', "</h3>\n\n". $button, '</a></strong>' ), |
|
350 | + 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview' ), '<h3>', "</h3>\n\n" . $button, '</a></strong>' ), |
|
351 | 351 | 'cap' => 'activate_plugins', |
352 | 352 | 'dismiss' => 'gf_inactive', |
353 | 353 | ); |
354 | 354 | |
355 | 355 | break; |
356 | 356 | default: |
357 | - self::$notices['gf_installed'] = array( |
|
357 | + self::$notices[ 'gf_installed' ] = array( |
|
358 | 358 | 'class' => 'error', |
359 | - 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $59%s%s', 'gravityview' ), '<h3>', "</h3>\n\n".'<a href="https://www.gravitykit.com/gravityforms/" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'), |
|
359 | + 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $59%s%s', 'gravityview' ), '<h3>', "</h3>\n\n" . '<a href="https://www.gravitykit.com/gravityforms/" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>' ), |
|
360 | 360 | 'cap' => 'install_plugins', |
361 | 361 | 'dismiss' => 'gf_installed', |
362 | 362 | ); |
@@ -373,10 +373,10 @@ discard block |
||
373 | 373 | */ |
374 | 374 | private static function check_gf_directory() { |
375 | 375 | |
376 | - if( class_exists( 'GFDirectory' ) ) { |
|
377 | - self::$notices['gf_directory'] = array( |
|
376 | + if ( class_exists( 'GFDirectory' ) ) { |
|
377 | + self::$notices[ 'gf_directory' ] = array( |
|
378 | 378 | 'class' => 'error is-dismissible', |
379 | - 'title' => __('Potential Conflict', 'gravityview' ), |
|
379 | + 'title' => __( 'Potential Conflict', 'gravityview' ), |
|
380 | 380 | 'message' => __( 'GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview' ), |
381 | 381 | 'dismiss' => 'gf_directory', |
382 | 382 | 'cap' => 'activate_plugins', |
@@ -394,21 +394,21 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public static function get_plugin_status( $location = '' ) { |
396 | 396 | |
397 | - if( ! function_exists('is_plugin_active') ) { |
|
397 | + if ( ! function_exists( 'is_plugin_active' ) ) { |
|
398 | 398 | include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
399 | 399 | } |
400 | 400 | |
401 | - if( is_network_admin() && is_plugin_active_for_network( $location ) ) { |
|
401 | + if ( is_network_admin() && is_plugin_active_for_network( $location ) ) { |
|
402 | 402 | return true; |
403 | 403 | } |
404 | 404 | |
405 | - if( ! is_network_admin() && is_plugin_active( $location ) ) { |
|
405 | + if ( ! is_network_admin() && is_plugin_active( $location ) ) { |
|
406 | 406 | return true; |
407 | 407 | } |
408 | 408 | |
409 | - if( |
|
410 | - !file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) && |
|
411 | - !file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location ) |
|
409 | + if ( |
|
410 | + ! file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) && |
|
411 | + ! file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location ) |
|
412 | 412 | ) { |
413 | 413 | return false; |
414 | 414 | } |