@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function register_noconflict( $items ) { |
55 | 55 | |
56 | - $items[] = 'gravityview-admin-installer'; |
|
56 | + $items[ ] = 'gravityview-admin-installer'; |
|
57 | 57 | |
58 | 58 | return $items; |
59 | 59 | } |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | - add_filter( 'plugins_api', function ( $data, $action, $args ) use ( $downloads_data ) { |
|
75 | + add_filter( 'plugins_api', function( $data, $action, $args ) use ( $downloads_data ) { |
|
76 | 76 | foreach ( $downloads_data as $extension ) { |
77 | - if ( empty( $extension['info'] ) || empty( $args->slug ) || $args->slug !== $extension['info']['slug'] ) { |
|
77 | + if ( empty( $extension[ 'info' ] ) || empty( $args->slug ) || $args->slug !== $extension[ 'info' ][ 'slug' ] ) { |
|
78 | 78 | continue; |
79 | 79 | } |
80 | 80 | |
81 | - return (object) array( |
|
82 | - 'slug' => $extension['info']['slug'], |
|
83 | - 'name' => $extension['info']['title'], |
|
84 | - 'version' => $extension['licensing']['version'], |
|
85 | - 'download_link' => $extension['files'][0]['file'], |
|
81 | + return (object)array( |
|
82 | + 'slug' => $extension[ 'info' ][ 'slug' ], |
|
83 | + 'name' => $extension[ 'info' ][ 'title' ], |
|
84 | + 'version' => $extension[ 'licensing' ][ 'version' ], |
|
85 | + 'download_link' => $extension[ 'files' ][ 0 ][ 'file' ], |
|
86 | 86 | ); |
87 | 87 | } |
88 | 88 | |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | |
145 | 145 | foreach ( $all_plugins as $path => $plugin ) { |
146 | 146 | |
147 | - if ( empty( $plugin['TextDomain'] ) ) { |
|
147 | + if ( empty( $plugin[ 'TextDomain' ] ) ) { |
|
148 | 148 | continue; |
149 | 149 | } |
150 | 150 | |
151 | - $wp_plugins[ $plugin['TextDomain'] ] = array( |
|
151 | + $wp_plugins[ $plugin[ 'TextDomain' ] ] = array( |
|
152 | 152 | 'path' => $path, |
153 | - 'version' => $plugin['Version'], |
|
153 | + 'version' => $plugin[ 'Version' ], |
|
154 | 154 | 'activated' => is_plugin_active( $path ) |
155 | 155 | ); |
156 | 156 | } |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | |
233 | 233 | $downloads_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
234 | 234 | |
235 | - if ( empty( $downloads_data['products'] ) ) { |
|
235 | + if ( empty( $downloads_data[ 'products' ] ) ) { |
|
236 | 236 | return array(); |
237 | 237 | } |
238 | 238 | |
239 | - $this->set_downloads_data( $downloads_data['products'] ); |
|
239 | + $this->set_downloads_data( $downloads_data[ 'products' ] ); |
|
240 | 240 | |
241 | - return $downloads_data['products']; |
|
241 | + return $downloads_data[ 'products' ]; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | |
312 | 312 | foreach ( $downloads_data as $extension ) { |
313 | 313 | |
314 | - if ( empty( $extension['info'] ) ) { |
|
314 | + if ( empty( $extension[ 'info' ] ) ) { |
|
315 | 315 | continue; |
316 | 316 | } |
317 | 317 | |
@@ -340,29 +340,29 @@ discard block |
||
340 | 340 | |
341 | 341 | $details = $this->get_download_display_details( $download, $wp_plugins ); |
342 | 342 | |
343 | - $download_info = $details['download_info']; |
|
343 | + $download_info = $details[ 'download_info' ]; |
|
344 | 344 | |
345 | 345 | ?> |
346 | - <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
|
346 | + <div class="item <?php echo esc_attr( $details[ 'item_class' ] ); ?>"> |
|
347 | 347 | <div class="addon-inner"> |
348 | - <a href="<?php echo esc_url( $download_info['link'] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info['thumbnail'] ); ?>" alt="" /></a> |
|
349 | - <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info['title'] ) ); ?></h3> |
|
348 | + <a href="<?php echo esc_url( $download_info[ 'link' ] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info[ 'thumbnail' ] ); ?>" alt="" /></a> |
|
349 | + <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info[ 'title' ] ) ); ?></h3> |
|
350 | 350 | <div> |
351 | - <?php if( ! empty( $details['status_label'] ) ) { ?> |
|
352 | - <div class="status <?php echo esc_attr( $details['status'] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details['status_label'] ) ); ?>"> |
|
353 | - <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details['status_label'] ); ?></span> |
|
351 | + <?php if ( ! empty( $details[ 'status_label' ] ) ) { ?> |
|
352 | + <div class="status <?php echo esc_attr( $details[ 'status' ] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details[ 'status_label' ] ) ); ?>"> |
|
353 | + <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details[ 'status_label' ] ); ?></span> |
|
354 | 354 | </div> |
355 | 355 | <?php } ?> |
356 | 356 | |
357 | - <a data-status="<?php echo esc_attr( $details['status'] ); ?>" data-plugin-path="<?php echo esc_attr( $details['plugin_path'] ); ?>" href="<?php echo esc_url( $details['href'] ); ?>" class="button <?php echo esc_attr( $details['button_class'] ); ?>" title="<?php echo esc_attr( $details['button_title'] ); ?>"> |
|
358 | - <span class="title"><?php echo esc_html( $details['button_label'] ); ?></span> |
|
359 | - <?php if( $details['spinner'] ) { ?><span class="spinner"></span><?php } ?> |
|
357 | + <a data-status="<?php echo esc_attr( $details[ 'status' ] ); ?>" data-plugin-path="<?php echo esc_attr( $details[ 'plugin_path' ] ); ?>" href="<?php echo esc_url( $details[ 'href' ] ); ?>" class="button <?php echo esc_attr( $details[ 'button_class' ] ); ?>" title="<?php echo esc_attr( $details[ 'button_title' ] ); ?>"> |
|
358 | + <span class="title"><?php echo esc_html( $details[ 'button_label' ] ); ?></span> |
|
359 | + <?php if ( $details[ 'spinner' ] ) { ?><span class="spinner"></span><?php } ?> |
|
360 | 360 | </a> |
361 | 361 | </div> |
362 | 362 | |
363 | 363 | <div class="addon-excerpt"><?php |
364 | 364 | |
365 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
365 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info[ 'excerpt' ] ); |
|
366 | 366 | |
367 | 367 | // Allow some pure HTML tags, but remove everything else from the excerpt. |
368 | 368 | $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | private function get_download_display_details( $download, $wp_plugins ) { |
404 | 404 | |
405 | - $download_info = wp_parse_args( (array) $download['info'], array( |
|
405 | + $download_info = wp_parse_args( (array)$download[ 'info' ], array( |
|
406 | 406 | 'thumbnail' => '', |
407 | 407 | 'title' => '', |
408 | 408 | 'textdomain' => '', |
@@ -414,9 +414,9 @@ discard block |
||
414 | 414 | 'installer_excerpt' => null, // May not be defined |
415 | 415 | ) ); |
416 | 416 | |
417 | - $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info['textdomain'], false ); |
|
417 | + $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info[ 'textdomain' ], false ); |
|
418 | 418 | |
419 | - $has_access = ! empty( $download['files'] ); |
|
419 | + $has_access = ! empty( $download[ 'files' ] ); |
|
420 | 420 | $spinner = true; |
421 | 421 | $href = $plugin_path = '#'; |
422 | 422 | $status = $item_class = $button_title = $button_class = ''; |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | $required_license = $galactic_only ? __( 'All Access', 'gravityview' ) : __( 'Core + Extensions', 'gravityview' ); |
427 | 427 | |
428 | 428 | // The license is not active - no matter what level, this should not work |
429 | - if( ! $is_active && empty( $base_price ) ) { |
|
429 | + if ( ! $is_active && empty( $base_price ) ) { |
|
430 | 430 | $spinner = false; |
431 | 431 | $status_label = ''; |
432 | 432 | $button_class = 'disabled disabled-license'; |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | $status_label = ''; |
440 | 440 | $button_label = sprintf( __( 'Purchase Now for %s', 'gravityview' ), '$' . $base_price ); |
441 | 441 | $button_class = 'button-primary button-large'; |
442 | - $href = $download_info['link']; |
|
442 | + $href = $download_info[ 'link' ]; |
|
443 | 443 | $item_class = 'featured'; |
444 | 444 | } |
445 | 445 | |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
453 | 453 | } |
454 | 454 | |
455 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
455 | + elseif ( ! empty( $download_info[ 'coming_soon' ] ) ) { |
|
456 | 456 | $spinner = false; |
457 | 457 | $status = 'notinstalled'; |
458 | 458 | $status_label = __( 'Coming Soon', 'gravityview' ); |
@@ -467,8 +467,8 @@ discard block |
||
467 | 467 | $href = add_query_arg( |
468 | 468 | array( |
469 | 469 | 'action' => 'install-plugin', |
470 | - 'plugin' => $download_info['slug'], |
|
471 | - '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info['slug'] ), |
|
470 | + 'plugin' => $download_info[ 'slug' ], |
|
471 | + '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info[ 'slug' ] ), |
|
472 | 472 | ), |
473 | 473 | self_admin_url( 'update.php' ) |
474 | 474 | ); |
@@ -480,25 +480,25 @@ discard block |
||
480 | 480 | } |
481 | 481 | |
482 | 482 | // Access and the plugin is installed but not active |
483 | - elseif ( false === $wp_plugin['activated'] ) { |
|
483 | + elseif ( false === $wp_plugin[ 'activated' ] ) { |
|
484 | 484 | $status = 'inactive'; |
485 | 485 | $status_label = __( 'Inactive', 'gravityview' ); |
486 | 486 | $button_label = __( 'Activate', 'gravityview' ); |
487 | - $plugin_path = $wp_plugin['path']; |
|
487 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
488 | 488 | |
489 | 489 | } |
490 | 490 | |
491 | 491 | // Access and the plugin is installed and active |
492 | 492 | else { |
493 | 493 | |
494 | - $plugin_path = $wp_plugin['path']; |
|
494 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
495 | 495 | $status = 'active'; |
496 | 496 | $status_label = __( 'Active', 'gravityview' ); |
497 | 497 | $button_label = __( 'Deactivate', 'gravityview' ); |
498 | 498 | |
499 | 499 | } |
500 | 500 | |
501 | - return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
501 | + return compact( 'download_info', 'plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | /** |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
514 | 514 | $base_price = \GFCommon::to_number( $base_price ); |
515 | 515 | |
516 | - unset( $download['pricing']['amount'] ); |
|
516 | + unset( $download[ 'pricing' ][ 'amount' ] ); |
|
517 | 517 | |
518 | 518 | // Price options array, not single price |
519 | - if ( ! $base_price && ! empty( $download['pricing'] ) ) { |
|
520 | - $base_price = array_shift( $download['pricing'] ); |
|
519 | + if ( ! $base_price && ! empty( $download[ 'pricing' ] ) ) { |
|
520 | + $base_price = array_shift( $download[ 'pricing' ] ); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | return floatval( $base_price ); |
@@ -531,13 +531,13 @@ discard block |
||
531 | 531 | public function activate_download() { |
532 | 532 | $data = \GV\Utils::_POST( 'data', array() ); |
533 | 533 | |
534 | - if ( empty( $data['path'] ) ) { |
|
534 | + if ( empty( $data[ 'path' ] ) ) { |
|
535 | 535 | return; |
536 | 536 | } |
537 | 537 | |
538 | - $result = activate_plugin( $data['path'] ); |
|
538 | + $result = activate_plugin( $data[ 'path' ] ); |
|
539 | 539 | |
540 | - if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
|
540 | + if ( is_wp_error( $result ) || ! is_plugin_active( $data[ 'path' ] ) ) { |
|
541 | 541 | wp_send_json_error( array( |
542 | 542 | 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
543 | 543 | ) ); |
@@ -554,13 +554,13 @@ discard block |
||
554 | 554 | public function deactivate_download() { |
555 | 555 | $data = \GV\Utils::_POST( 'data', array() ); |
556 | 556 | |
557 | - if ( empty( $data['path'] ) ) { |
|
557 | + if ( empty( $data[ 'path' ] ) ) { |
|
558 | 558 | return; |
559 | 559 | } |
560 | 560 | |
561 | - deactivate_plugins( $data['path'] ); |
|
561 | + deactivate_plugins( $data[ 'path' ] ); |
|
562 | 562 | |
563 | - if( is_plugin_active( $data['path'] ) ) { |
|
563 | + if ( is_plugin_active( $data[ 'path' ] ) ) { |
|
564 | 564 | wp_send_json_error( array( |
565 | 565 | 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
566 | 566 | ) ); |
@@ -78,7 +78,7 @@ |
||
78 | 78 | $gv_page = gravityview()->request->is_admin( '', 'single' ); |
79 | 79 | |
80 | 80 | // New View or Edit View page |
81 | - if( $gv_page && $pagenow === 'post-new.php' ) { |
|
81 | + if ( $gv_page && $pagenow === 'post-new.php' ) { |
|
82 | 82 | remove_meta_box( 'woothemes-settings', 'gravityview', 'normal' ); |
83 | 83 | } |
84 | 84 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | parent::add_hooks(); |
69 | 69 | |
70 | - if( gravityview()->request->is_admin( '', null ) ) { |
|
70 | + if ( gravityview()->request->is_admin( '', null ) ) { |
|
71 | 71 | |
72 | 72 | // Make Yoast metabox go down to the bottom please. |
73 | 73 | add_filter( 'wpseo_metabox_prio', array( $this, 'return_low' ) ); |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function disable_content_analysis( $options ) { |
94 | 94 | |
95 | - $options['keyword_analysis_active'] = false; |
|
96 | - $options['content_analysis_active'] = false; |
|
95 | + $options[ 'keyword_analysis_active' ] = false; |
|
96 | + $options[ 'content_analysis_active' ] = false; |
|
97 | 97 | |
98 | 98 | return $options; |
99 | 99 | } |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | global $pagenow; |
113 | 113 | |
114 | 114 | // New View page |
115 | - if( $pagenow === 'post-new.php' ) { |
|
116 | - $options['hideeditbox-gravityview'] = true; |
|
115 | + if ( $pagenow === 'post-new.php' ) { |
|
116 | + $options[ 'hideeditbox-gravityview' ] = true; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | return $options; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function __construct() { |
19 | 19 | |
20 | - if( !GravityView_Compatibility::is_valid() ) { return; } |
|
20 | + if ( ! GravityView_Compatibility::is_valid() ) { return; } |
|
21 | 21 | |
22 | 22 | self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/'; |
23 | 23 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function initialize() { |
37 | 37 | |
38 | - add_action( 'add_meta_boxes', array( $this, 'register_metaboxes' )); |
|
38 | + add_action( 'add_meta_boxes', array( $this, 'register_metaboxes' ) ); |
|
39 | 39 | |
40 | - add_action( 'add_meta_boxes_gravityview' , array( $this, 'update_priority' ) ); |
|
40 | + add_action( 'add_meta_boxes_gravityview', array( $this, 'update_priority' ) ); |
|
41 | 41 | |
42 | 42 | // information box |
43 | 43 | add_action( 'post_submitbox_misc_actions', array( $this, 'render_shortcode_hint' ) ); |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | function update_priority() { |
52 | 52 | global $wp_meta_boxes; |
53 | 53 | |
54 | - if( ! empty( $wp_meta_boxes['gravityview'] ) ) { |
|
55 | - foreach( array( 'high', 'core', 'low' ) as $position ) { |
|
56 | - if( isset( $wp_meta_boxes['gravityview']['normal'][ $position ] ) ) { |
|
57 | - foreach( $wp_meta_boxes['gravityview']['normal'][ $position ] as $key => $meta_box ) { |
|
58 | - if( ! preg_match( '/^gravityview_/ism', $key ) ) { |
|
59 | - $wp_meta_boxes['gravityview']['advanced'][ $position ][ $key ] = $meta_box; |
|
60 | - unset( $wp_meta_boxes['gravityview']['normal'][ $position ][ $key ] ); |
|
54 | + if ( ! empty( $wp_meta_boxes[ 'gravityview' ] ) ) { |
|
55 | + foreach ( array( 'high', 'core', 'low' ) as $position ) { |
|
56 | + if ( isset( $wp_meta_boxes[ 'gravityview' ][ 'normal' ][ $position ] ) ) { |
|
57 | + foreach ( $wp_meta_boxes[ 'gravityview' ][ 'normal' ][ $position ] as $key => $meta_box ) { |
|
58 | + if ( ! preg_match( '/^gravityview_/ism', $key ) ) { |
|
59 | + $wp_meta_boxes[ 'gravityview' ][ 'advanced' ][ $position ][ $key ] = $meta_box; |
|
60 | + unset( $wp_meta_boxes[ 'gravityview' ][ 'normal' ][ $position ][ $key ] ); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | global $post; |
70 | 70 | |
71 | 71 | // On Comment Edit, for example, $post isn't set. |
72 | - if( empty( $post ) || !is_object( $post ) || !isset( $post->ID ) ) { |
|
72 | + if ( empty( $post ) || ! is_object( $post ) || ! isset( $post->ID ) ) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | */ |
153 | 153 | $metaboxes = apply_filters( 'gravityview/metaboxes/default', $metaboxes ); |
154 | 154 | |
155 | - foreach( $metaboxes as $m ) { |
|
155 | + foreach ( $metaboxes as $m ) { |
|
156 | 156 | |
157 | - $tab = new GravityView_Metabox_Tab( $m['id'], $m['title'], $m['file'], $m['icon-class'], $m['callback'], $m['callback_args'] ); |
|
157 | + $tab = new GravityView_Metabox_Tab( $m[ 'id' ], $m[ 'title' ], $m[ 'file' ], $m[ 'icon-class' ], $m[ 'callback' ], $m[ 'callback_args' ] ); |
|
158 | 158 | |
159 | 159 | GravityView_Metabox_Tabs::add( $tab ); |
160 | 160 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | |
181 | 181 | $links = GravityView_Admin_Views::get_connected_form_links( $current_form, false ); |
182 | 182 | |
183 | - if( !empty( $links ) ) { |
|
184 | - $links = '<span class="alignright gv-form-links">'. $links .'</span>'; |
|
183 | + if ( ! empty( $links ) ) { |
|
184 | + $links = '<span class="alignright gv-form-links">' . $links . '</span>'; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | return __( 'Data Source', 'gravityview' ) . $links; |
@@ -220,28 +220,28 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public static function render_merge_tags_scripts( $curr_form ) { |
222 | 222 | |
223 | - if( empty( $curr_form )) { |
|
223 | + if ( empty( $curr_form ) ) { |
|
224 | 224 | return NULL; |
225 | 225 | } |
226 | 226 | |
227 | 227 | $form = gravityview_get_form( $curr_form ); |
228 | 228 | |
229 | - $get_id_backup = isset($_GET['id']) ? $_GET['id'] : NULL; |
|
229 | + $get_id_backup = isset( $_GET[ 'id' ] ) ? $_GET[ 'id' ] : NULL; |
|
230 | 230 | |
231 | - if( isset( $form['id'] ) ) { |
|
232 | - $form_script = 'var form = ' . GFCommon::json_encode($form) . ';'; |
|
231 | + if ( isset( $form[ 'id' ] ) ) { |
|
232 | + $form_script = 'var form = ' . GFCommon::json_encode( $form ) . ';'; |
|
233 | 233 | |
234 | 234 | // The `gf_vars()` method needs a $_GET[id] variable set with the form ID. |
235 | - $_GET['id'] = $form['id']; |
|
235 | + $_GET[ 'id' ] = $form[ 'id' ]; |
|
236 | 236 | |
237 | 237 | } else { |
238 | 238 | $form_script = 'var form = new Form();'; |
239 | 239 | } |
240 | 240 | |
241 | - $output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars(false) . '</script>'; |
|
241 | + $output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars( false ) . '</script>'; |
|
242 | 242 | |
243 | 243 | // Restore previous $_GET setting |
244 | - $_GET['id'] = $get_id_backup; |
|
244 | + $_GET[ 'id' ] = $get_id_backup; |
|
245 | 245 | |
246 | 246 | return $output; |
247 | 247 | } |
@@ -299,12 +299,12 @@ discard block |
||
299 | 299 | global $post; |
300 | 300 | |
301 | 301 | // Only show this on GravityView post types. |
302 | - if( false === gravityview()->request->is_admin( '', null ) ) { |
|
302 | + if ( false === gravityview()->request->is_admin( '', null ) ) { |
|
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | 306 | // If the View hasn't been configured yet, don't show embed shortcode |
307 | - if( ! gravityview_get_directory_fields( $post->ID ) && ! gravityview_get_directory_widgets( $post->ID ) ) { |
|
307 | + if ( ! gravityview_get_directory_fields( $post->ID ) && ! gravityview_get_directory_widgets( $post->ID ) ) { |
|
308 | 308 | return; |
309 | 309 | } |
310 | 310 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - if( ! is_admin() ) { return; } |
|
21 | + if ( ! is_admin() ) { return; } |
|
22 | 22 | |
23 | 23 | $this->add_hooks(); |
24 | 24 | } |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | */ |
33 | 33 | private function add_hooks() { |
34 | 34 | //Hooks for no-conflict functionality |
35 | - add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000); |
|
36 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9); |
|
35 | + add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000 ); |
|
36 | + add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9 ); |
|
37 | 37 | |
38 | - add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000); |
|
39 | - add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11); |
|
40 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1); |
|
41 | - add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1); |
|
38 | + add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000 ); |
|
39 | + add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11 ); |
|
40 | + add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1 ); |
|
41 | + add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1 ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | function no_conflict_scripts() { |
52 | 52 | global $wp_scripts; |
53 | 53 | |
54 | - if( ! gravityview()->request->is_admin( '', null ) ) { |
|
54 | + if ( ! gravityview()->request->is_admin( '', null ) ) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | 58 | $no_conflict_mode = gravityview()->plugin->settings->get( 'no-conflict-mode' ); |
59 | 59 | |
60 | - if( empty( $no_conflict_mode ) ) { |
|
60 | + if ( empty( $no_conflict_mode ) ) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | function no_conflict_styles() { |
111 | 111 | global $wp_styles; |
112 | 112 | |
113 | - if( ! gravityview()->request->is_admin( '', null ) ) { |
|
113 | + if ( ! gravityview()->request->is_admin( '', null ) ) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Dequeue other jQuery styles even if no-conflict is off. |
118 | 118 | // Terrible-looking tabs help no one. |
119 | - if( !empty( $wp_styles->registered ) ) { |
|
120 | - foreach ($wp_styles->registered as $key => $style) { |
|
121 | - if( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
119 | + if ( ! empty( $wp_styles->registered ) ) { |
|
120 | + foreach ( $wp_styles->registered as $key => $style ) { |
|
121 | + if ( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
122 | 122 | wp_dequeue_style( $key ); |
123 | 123 | } |
124 | 124 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $no_conflict_mode = gravityview()->plugin->settings->get( 'no-conflict-mode' ); |
128 | 128 | |
129 | 129 | // If no conflict is off, jQuery will suffice. |
130 | - if( empty( $no_conflict_mode ) ) { |
|
130 | + if ( empty( $no_conflict_mode ) ) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * @action `gravityview_remove_conflicts_after` Runs after no-conflict styles are removed. You can re-add styles here. |
156 | 156 | */ |
157 | - do_action('gravityview_remove_conflicts_after'); |
|
157 | + do_action( 'gravityview_remove_conflicts_after' ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | |
179 | 179 | //reset queue |
180 | 180 | $queue = array(); |
181 | - foreach( $wp_objects->queue as $object ) { |
|
182 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
183 | - $queue[] = $object; |
|
181 | + foreach ( $wp_objects->queue as $object ) { |
|
182 | + if ( in_array( $object, $required_objects ) || preg_match( '/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
183 | + $queue[ ] = $object; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | $wp_objects->queue = $queue; |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | |
190 | 190 | //unregistering scripts |
191 | 191 | $registered = array(); |
192 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
193 | - if( in_array( $handle, $required_objects ) ){ |
|
192 | + foreach ( $wp_objects->registered as $handle => $script_registration ) { |
|
193 | + if ( in_array( $handle, $required_objects ) ) { |
|
194 | 194 | $registered[ $handle ] = $script_registration; |
195 | 195 | } |
196 | 196 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @param array $registered [description] |
206 | 206 | * @param array $scripts [description] |
207 | 207 | */ |
208 | - private function add_script_dependencies($registered, $scripts) { |
|
208 | + private function add_script_dependencies( $registered, $scripts ) { |
|
209 | 209 | |
210 | 210 | //gets all dependent scripts linked to the $scripts array passed |
211 | 211 | do { |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $deps = isset( $registered[ $script ] ) && is_array( $registered[ $script ]->deps ) ? $registered[ $script ]->deps : array(); |
215 | 215 | foreach ( $deps as $dep ) { |
216 | 216 | if ( ! in_array( $dep, $scripts ) && ! in_array( $dep, $dependents ) ) { |
217 | - $dependents[] = $dep; |
|
217 | + $dependents[ ] = $dep; |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @return array |
103 | 103 | */ |
104 | 104 | public function modify_app_settings_menu_title( $setting_tabs ) { |
105 | - $setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview' ); |
|
105 | + $setting_tabs[ 0 ][ 'label' ] = __( 'GravityView Settings', 'gravityview' ); |
|
106 | 106 | return $setting_tabs; |
107 | 107 | } |
108 | 108 | |
@@ -308,15 +308,15 @@ discard block |
||
308 | 308 | </ul> |
309 | 309 | <div class="gv-followup widefat"> |
310 | 310 | <p><strong><label for="gv-reason-details"><?php esc_html_e( 'Comments', 'gravityview' ); ?></label></strong></p> |
311 | - <textarea id="gv-reason-details" name="reason_details" data-default="<?php esc_attr_e('Please share your thoughts about GravityView', 'gravityview') ?>" placeholder="<?php esc_attr_e('Please share your thoughts about GravityView', 'gravityview'); ?>" class="large-text"></textarea> |
|
311 | + <textarea id="gv-reason-details" name="reason_details" data-default="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ) ?>" placeholder="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ); ?>" class="large-text"></textarea> |
|
312 | 312 | </div> |
313 | 313 | <div class="scale-description"> |
314 | 314 | <p><strong><?php esc_html_e( 'How likely are you to recommend GravityView?', 'gravityview' ); ?></strong></p> |
315 | 315 | <ul class="inline"> |
316 | 316 | <?php |
317 | 317 | $i = 0; |
318 | - while( $i < 11 ) { |
|
319 | - echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_'.$i.'" value="'.$i.'" type="radio"> '.$i.'</label></li>'; |
|
318 | + while ( $i < 11 ) { |
|
319 | + echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_' . $i . '" value="' . $i . '" type="radio"> ' . $i . '</label></li>'; |
|
320 | 320 | $i++; |
321 | 321 | } |
322 | 322 | ?> |
@@ -533,15 +533,15 @@ discard block |
||
533 | 533 | * @return string The HTML |
534 | 534 | */ |
535 | 535 | public function as_html( $field, $echo = true ) { |
536 | - $field['type'] = ( isset( $field['type'] ) && in_array( $field['type'], array( 'submit','reset','button' ) ) ) ? $field['type'] : 'submit'; |
|
536 | + $field[ 'type' ] = ( isset( $field[ 'type' ] ) && in_array( $field[ 'type' ], array( 'submit', 'reset', 'button' ) ) ) ? $field[ 'type' ] : 'submit'; |
|
537 | 537 | |
538 | 538 | $attributes = $this->get_field_attributes( $field ); |
539 | 539 | $default_value = Utils::get( $field, 'value', Utils::get( $field, 'default_value' ) ); |
540 | - $value = $this->get( $field['name'], $default_value ); |
|
540 | + $value = $this->get( $field[ 'name' ], $default_value ); |
|
541 | 541 | |
542 | 542 | |
543 | - $attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton'; |
|
544 | - $name = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_' . $field['name']; |
|
543 | + $attributes[ 'class' ] = isset( $attributes[ 'class' ] ) ? esc_attr( $attributes[ 'class' ] ) : 'button-primary gfbutton'; |
|
544 | + $name = ( $field[ 'name' ] === 'gform-settings-save' ) ? $field[ 'name' ] : '_gaddon_setting_' . $field[ 'name' ]; |
|
545 | 545 | |
546 | 546 | if ( empty( $value ) ) { |
547 | 547 | $value = __( 'Update Settings', 'gravityview' ); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | $attributes = $this->get_field_attributes( $field ); |
551 | 551 | |
552 | 552 | $html = '<input |
553 | - type="' . $field['type'] . '" |
|
553 | + type="' . $field[ 'type' ] . '" |
|
554 | 554 | name="' . esc_attr( $name ) . '" |
555 | 555 | value="' . $value . '" ' . |
556 | 556 | implode( ' ', $attributes ) . |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @return bool |
582 | 582 | */ |
583 | 583 | public function is_save_postback() { |
584 | - return isset( $_POST['gform-settings-save'] ) && isset( $_POST['_gravityview_save_settings_nonce'] ); |
|
584 | + return isset( $_POST[ 'gform-settings-save' ] ) && isset( $_POST[ '_gravityview_save_settings_nonce' ] ); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | */ |
592 | 592 | public function license_key_notice() { |
593 | 593 | |
594 | - if( $this->is_save_postback() ) { |
|
594 | + if ( $this->is_save_postback() ) { |
|
595 | 595 | $settings = $this->get_posted_settings(); |
596 | 596 | $license_key = \GV\Utils::get( $settings, 'license_key' ); |
597 | 597 | $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' ); |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | * but didn't want to mess up the translation strings for the translators. |
613 | 613 | */ |
614 | 614 | $message = mb_substr( $message, 0, mb_strlen( $message ) - 1 ); |
615 | - $title = __( 'Inactive License', 'gravityview'); |
|
615 | + $title = __( 'Inactive License', 'gravityview' ); |
|
616 | 616 | $status = ''; |
617 | 617 | $update_below = false; |
618 | 618 | $primary_button_link = admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ); |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | $update_below = __( 'Activate your license key below.', 'gravityview' ); |
643 | 643 | break; |
644 | 644 | } |
645 | - $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice'; |
|
645 | + $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice'; |
|
646 | 646 | |
647 | 647 | // Show a different notice on settings page for inactive licenses (hide the buttons) |
648 | 648 | if ( $update_below && gravityview()->request->is_admin( '', 'settings' ) ) { |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | public function scripts() { |
687 | 687 | $scripts = parent::scripts(); |
688 | 688 | |
689 | - $scripts[] = array( |
|
689 | + $scripts[ ] = array( |
|
690 | 690 | 'handle' => 'gform_tooltip_init', |
691 | 691 | 'enqueue' => array( |
692 | 692 | array( |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | public function styles() { |
706 | 706 | $styles = parent::styles(); |
707 | 707 | |
708 | - $styles[] = array( |
|
708 | + $styles[ ] = array( |
|
709 | 709 | 'handle' => 'gravityview_settings', |
710 | 710 | 'src' => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ), |
711 | 711 | 'version' => Plugin::$version, |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | * If multisite and not network admin, we don't want the settings to show. |
737 | 737 | * @since 1.7.6 |
738 | 738 | */ |
739 | - $show_submenu = ( ! is_multisite() ) || is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() ); |
|
739 | + $show_submenu = ( ! is_multisite() ) || is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() ); |
|
740 | 740 | |
741 | 741 | /** |
742 | 742 | * Override whether to show the Settings menu on a per-blog basis. |
@@ -784,26 +784,26 @@ discard block |
||
784 | 784 | 'label' => __( 'License Key', 'gravityview' ), |
785 | 785 | 'description' => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates & support.', 'gravityview' ) . $this->get_license_handler()->license_details( $this->get_app_setting( 'license_key_response' ) ), |
786 | 786 | 'type' => 'edd_license', |
787 | - 'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ), |
|
787 | + 'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ), |
|
788 | 788 | 'data-pending-text' => __( 'Verifying license…', 'gravityview' ), |
789 | - 'default_value' => $default_settings['license_key'], |
|
789 | + 'default_value' => $default_settings[ 'license_key' ], |
|
790 | 790 | 'class' => ( '' == $this->get( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key', |
791 | 791 | ), |
792 | 792 | array( |
793 | 793 | 'name' => 'license_key_response', |
794 | - 'default_value' => $default_settings['license_key_response'], |
|
794 | + 'default_value' => $default_settings[ 'license_key_response' ], |
|
795 | 795 | 'type' => 'hidden', |
796 | 796 | ), |
797 | 797 | array( |
798 | 798 | 'name' => 'license_key_status', |
799 | - 'default_value' => $default_settings['license_key_status'], |
|
799 | + 'default_value' => $default_settings[ 'license_key_status' ], |
|
800 | 800 | 'type' => 'hidden', |
801 | 801 | ), |
802 | 802 | array( |
803 | 803 | 'name' => 'support-email', |
804 | 804 | 'type' => 'text', |
805 | 805 | 'validate' => 'email', |
806 | - 'default_value' => $default_settings['support-email'], |
|
806 | + 'default_value' => $default_settings[ 'support-email' ], |
|
807 | 807 | 'label' => __( 'Support Email', 'gravityview' ), |
808 | 808 | 'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ), |
809 | 809 | 'class' => 'code regular-text', |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | 'name' => 'support_port', |
816 | 816 | 'type' => 'radio', |
817 | 817 | 'label' => __( 'Show Support Port?', 'gravityview' ), |
818 | - 'default_value' => $default_settings['support_port'], |
|
818 | + 'default_value' => $default_settings[ 'support_port' ], |
|
819 | 819 | 'horizontal' => 1, |
820 | 820 | 'choices' => array( |
821 | 821 | array( |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | 'name' => 'no-conflict-mode', |
835 | 835 | 'type' => 'radio', |
836 | 836 | 'label' => __( 'No-Conflict Mode', 'gravityview' ), |
837 | - 'default_value' => $default_settings['no-conflict-mode'], |
|
837 | + 'default_value' => $default_settings[ 'no-conflict-mode' ], |
|
838 | 838 | 'horizontal' => 1, |
839 | 839 | 'choices' => array( |
840 | 840 | array( |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | 'name' => 'rest_api', |
857 | 857 | 'type' => 'radio', |
858 | 858 | 'label' => __( 'REST API', 'gravityview' ), |
859 | - 'default_value' => $default_settings['rest_api'], |
|
859 | + 'default_value' => $default_settings[ 'rest_api' ], |
|
860 | 860 | 'horizontal' => 1, |
861 | 861 | 'choices' => array( |
862 | 862 | array( |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | 'name' => 'beta', |
876 | 876 | 'type' => 'checkbox', |
877 | 877 | 'label' => __( 'Become a Beta Tester', 'gravityview' ), |
878 | - 'default_value' => $default_settings['beta'], |
|
878 | + 'default_value' => $default_settings[ 'beta' ], |
|
879 | 879 | 'horizontal' => 1, |
880 | 880 | 'choices' => array( |
881 | 881 | array( |
@@ -908,17 +908,17 @@ discard block |
||
908 | 908 | * @since 1.7.4 |
909 | 909 | */ |
910 | 910 | foreach ( $fields as &$field ) { |
911 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : Utils::get( $field, 'id' ); |
|
912 | - $field['label'] = isset( $field['label'] ) ? $field['label'] : Utils::get( $field, 'title' ); |
|
913 | - $field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : Utils::get( $field, 'default' ); |
|
914 | - $field['description'] = isset( $field['description'] ) ? $field['description'] : Utils::get( $field, 'subtitle' ); |
|
911 | + $field[ 'name' ] = isset( $field[ 'name' ] ) ? $field[ 'name' ] : Utils::get( $field, 'id' ); |
|
912 | + $field[ 'label' ] = isset( $field[ 'label' ] ) ? $field[ 'label' ] : Utils::get( $field, 'title' ); |
|
913 | + $field[ 'default_value' ] = isset( $field[ 'default_value' ] ) ? $field[ 'default_value' ] : Utils::get( $field, 'default' ); |
|
914 | + $field[ 'description' ] = isset( $field[ 'description' ] ) ? $field[ 'description' ] : Utils::get( $field, 'subtitle' ); |
|
915 | 915 | |
916 | 916 | if ( $disabled_attribute ) { |
917 | - $field['disabled'] = $disabled_attribute; |
|
917 | + $field[ 'disabled' ] = $disabled_attribute; |
|
918 | 918 | } |
919 | 919 | |
920 | - if ( empty( $field['disabled'] ) ) { |
|
921 | - unset( $field['disabled'] ); |
|
920 | + if ( empty( $field[ 'disabled' ] ) ) { |
|
921 | + unset( $field[ 'disabled' ] ); |
|
922 | 922 | } |
923 | 923 | } |
924 | 924 | |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | ); |
937 | 937 | |
938 | 938 | if ( $disabled_attribute ) { |
939 | - $button['disabled'] = $disabled_attribute; |
|
939 | + $button[ 'disabled' ] = $disabled_attribute; |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | /** |
@@ -955,20 +955,20 @@ discard block |
||
955 | 955 | // If there are extensions, add a section for them |
956 | 956 | if ( ! empty( $extension_sections ) ) { |
957 | 957 | |
958 | - if( $disabled_attribute ) { |
|
958 | + if ( $disabled_attribute ) { |
|
959 | 959 | foreach ( $extension_sections as &$section ) { |
960 | - foreach ( $section['fields'] as &$field ) { |
|
961 | - $field['disabled'] = $disabled_attribute; |
|
960 | + foreach ( $section[ 'fields' ] as &$field ) { |
|
961 | + $field[ 'disabled' ] = $disabled_attribute; |
|
962 | 962 | } |
963 | 963 | } |
964 | 964 | } |
965 | 965 | |
966 | - $k = count( $extension_sections ) - 1 ; |
|
967 | - $extension_sections[ $k ]['fields'][] = $button; |
|
966 | + $k = count( $extension_sections ) - 1; |
|
967 | + $extension_sections[ $k ][ 'fields' ][ ] = $button; |
|
968 | 968 | $sections = array_merge( $sections, $extension_sections ); |
969 | 969 | } else { |
970 | 970 | // add the 'update settings' button to the general section |
971 | - $sections[0]['fields'][] = $button; |
|
971 | + $sections[ 0 ][ 'fields' ][ ] = $button; |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | return $sections; |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | protected function settings_edd_license( $field, $echo = true ) { |
1025 | 1025 | |
1026 | 1026 | if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) { |
1027 | - $field['input_type'] = 'password'; |
|
1027 | + $field[ 'input_type' ] = 'password'; |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | $text = $this->settings_text( $field, false ); |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | public function single_setting_row_html( $field ) { |
1074 | 1074 | ?> |
1075 | 1075 | |
1076 | - <tr id="gaddon-setting-row-<?php echo esc_attr( $field['name'] ); ?>"> |
|
1076 | + <tr id="gaddon-setting-row-<?php echo esc_attr( $field[ 'name' ] ); ?>"> |
|
1077 | 1077 | <td colspan="2"> |
1078 | 1078 | <?php $this->single_setting( $field ); ?> |
1079 | 1079 | </td> |
@@ -1091,10 +1091,10 @@ discard block |
||
1091 | 1091 | * @return string |
1092 | 1092 | */ |
1093 | 1093 | public function settings_save( $field, $echo = true ) { |
1094 | - $field['type'] = 'submit'; |
|
1095 | - $field['name'] = 'gform-settings-save'; |
|
1096 | - $field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton'; |
|
1097 | - $field['value'] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) ); |
|
1094 | + $field[ 'type' ] = 'submit'; |
|
1095 | + $field[ 'name' ] = 'gform-settings-save'; |
|
1096 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] : 'button-primary gfbutton'; |
|
1097 | + $field[ 'value' ] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) ); |
|
1098 | 1098 | |
1099 | 1099 | $output = $this->settings_submit( $field, false ); |
1100 | 1100 | |
@@ -1125,8 +1125,8 @@ discard block |
||
1125 | 1125 | * @return void |
1126 | 1126 | */ |
1127 | 1127 | public function single_setting_row( $field ) { |
1128 | - $field['gv_description'] = Utils::get( $field, 'description' ); |
|
1129 | - $field['description'] = Utils::get( $field, 'subtitle' ); |
|
1128 | + $field[ 'gv_description' ] = Utils::get( $field, 'description' ); |
|
1129 | + $field[ 'description' ] = Utils::get( $field, 'subtitle' ); |
|
1130 | 1130 | parent::single_setting_row( $field ); |
1131 | 1131 | } |
1132 | 1132 | |
@@ -1138,7 +1138,7 @@ discard block |
||
1138 | 1138 | public function single_setting_label( $field ) { |
1139 | 1139 | parent::single_setting_label( $field ); |
1140 | 1140 | if ( $description = Utils::get( $field, 'gv_description' ) ) { |
1141 | - echo '<span class="description">'. $description .'</span>'; |
|
1141 | + echo '<span class="description">' . $description . '</span>'; |
|
1142 | 1142 | } |
1143 | 1143 | } |
1144 | 1144 | |
@@ -1175,9 +1175,9 @@ discard block |
||
1175 | 1175 | // If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response), |
1176 | 1176 | // then we assume it's changed. If it's changed, unset the status and the previous response. |
1177 | 1177 | if ( $local_key !== $response_key ) { |
1178 | - unset( $posted_settings['license_key_response'] ); |
|
1179 | - unset( $posted_settings['license_key_status'] ); |
|
1180 | - \GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) ); |
|
1178 | + unset( $posted_settings[ 'license_key_response' ] ); |
|
1179 | + unset( $posted_settings[ 'license_key_status' ] ); |
|
1180 | + \GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) ); |
|
1181 | 1181 | } |
1182 | 1182 | return $posted_settings; |
1183 | 1183 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | $is_page = false; |
40 | 40 | |
41 | - if( function_exists( '\get_current_screen' ) || function_exists( 'get_current_screen' ) ) { |
|
41 | + if ( function_exists( '\get_current_screen' ) || function_exists( 'get_current_screen' ) ) { |
|
42 | 42 | $current_screen = \get_current_screen(); |
43 | 43 | } else { |
44 | 44 | $current_screen = false; |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | $is_page = 'single'; |
52 | 52 | } elseif ( $is_gv_settings = 'gravityview_page_gravityview_settings' === $current_screen->id ) { |
53 | 53 | $is_page = 'settings'; |
54 | - } elseif( $is_extensions = 'gravityview_page_gv-admin-installer' === $current_screen->id ) { |
|
54 | + } elseif ( $is_extensions = 'gravityview_page_gv-admin-installer' === $current_screen->id ) { |
|
55 | 55 | $is_page = 'downloads'; |
56 | - } elseif( $is_changelog = 'gravityview_page_gv-changelog' === $current_screen->id ) { |
|
56 | + } elseif ( $is_changelog = 'gravityview_page_gv-changelog' === $current_screen->id ) { |
|
57 | 57 | $is_page = 'changelog'; |
58 | - } elseif( $is_getting_started = 'gravityview_page_gv-getting-started' === $current_screen->id ) { |
|
58 | + } elseif ( $is_getting_started = 'gravityview_page_gv-getting-started' === $current_screen->id ) { |
|
59 | 59 | $is_page = 'getting-started'; |
60 | - } elseif( $is_credits = 'gravityview_page_gv-credits' === $current_screen->id ) { |
|
60 | + } elseif ( $is_credits = 'gravityview_page_gv-credits' === $current_screen->id ) { |
|
61 | 61 | $is_page = 'credits'; |
62 | 62 | } |
63 | 63 | } |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | |
95 | 95 | /** |
96 | 96 | * ID of the current post. May also be ID of the current View. |
97 | - * |
|
98 | - * @since 2.0.13 |
|
99 | - * |
|
100 | - * @var int |
|
97 | + * |
|
98 | + * @since 2.0.13 |
|
99 | + * |
|
100 | + * @var int |
|
101 | 101 | */ |
102 | 102 | public $post_id; |
103 | 103 | |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | public function prevent_maybe_process_form() { |
170 | 170 | |
171 | 171 | if( ! empty( $_POST ) ) { |
172 | - gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
172 | + gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | if( $this->is_edit_entry_submission() ) { |
176 | 176 | remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | * When Edit entry view is requested setup the vars |
203 | 203 | */ |
204 | 204 | private function setup_vars() { |
205 | - global $post; |
|
205 | + global $post; |
|
206 | 206 | |
207 | 207 | $gravityview_view = GravityView_View::getInstance(); |
208 | 208 | |
209 | 209 | |
210 | 210 | $entries = $gravityview_view->getEntries(); |
211 | - self::$original_entry = $entries[0]; |
|
212 | - $this->entry = $entries[0]; |
|
211 | + self::$original_entry = $entries[0]; |
|
212 | + $this->entry = $entries[0]; |
|
213 | 213 | |
214 | 214 | self::$original_form = $gravityview_view->getForm(); |
215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | |
334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
335 | 335 | |
336 | - // Delete the values for hidden inputs |
|
337 | - $this->unset_hidden_field_values(); |
|
336 | + // Delete the values for hidden inputs |
|
337 | + $this->unset_hidden_field_values(); |
|
338 | 338 | |
339 | 339 | $this->entry['date_created'] = $date_created; |
340 | 340 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | // Perform actions normally performed after updating a lead |
348 | 348 | $this->after_update(); |
349 | 349 | |
350 | - /** |
|
350 | + /** |
|
351 | 351 | * Must be AFTER after_update()! |
352 | 352 | * @see https://github.com/gravityview/GravityView/issues/764 |
353 | 353 | */ |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | |
356 | 356 | /** |
357 | 357 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
358 | - * @since 2.1 Added $gv_data parameter |
|
358 | + * @since 2.1 Added $gv_data parameter |
|
359 | 359 | * @param array $form Gravity Forms form array |
360 | 360 | * @param string $entry_id Numeric ID of the entry that was updated |
361 | 361 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | * @return void |
380 | 380 | */ |
381 | 381 | private function unset_hidden_field_values() { |
382 | - global $wpdb; |
|
382 | + global $wpdb; |
|
383 | 383 | |
384 | 384 | /** |
385 | 385 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -401,27 +401,27 @@ discard block |
||
401 | 401 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
402 | 402 | } |
403 | 403 | |
404 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
404 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
405 | 405 | |
406 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
406 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
407 | 407 | |
408 | - // Reset fields that are hidden |
|
409 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
410 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
408 | + // Reset fields that are hidden |
|
409 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
410 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
411 | 411 | |
412 | - // List fields are stored as empty arrays when empty |
|
413 | - $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
412 | + // List fields are stored as empty arrays when empty |
|
413 | + $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
414 | 414 | |
415 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
415 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
416 | 416 | |
417 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
417 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
418 | 418 | |
419 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
419 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
420 | 420 | // after submission |
421 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
422 | - $_POST[ $post_input_id ] = ''; |
|
423 | - } |
|
424 | - } |
|
421 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
422 | + $_POST[ $post_input_id ] = ''; |
|
423 | + } |
|
424 | + } |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | |
516 | 516 | $form = $this->form; |
517 | 517 | |
518 | - /** @var GF_Field $field */ |
|
518 | + /** @var GF_Field $field */ |
|
519 | 519 | foreach( $form['fields'] as $k => &$field ) { |
520 | 520 | |
521 | 521 | /** |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | |
532 | 532 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
533 | 533 | foreach( $field->inputs as $key => $input ) { |
534 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
534 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
535 | 535 | } |
536 | 536 | } |
537 | 537 | } |
@@ -552,13 +552,13 @@ discard block |
||
552 | 552 | foreach ( $this->fields_with_calculation as $calc_field ) { |
553 | 553 | $inputs = $calc_field->get_entry_inputs(); |
554 | 554 | if ( is_array( $inputs ) ) { |
555 | - foreach ( $inputs as $input ) { |
|
556 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
557 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
558 | - } |
|
555 | + foreach ( $inputs as $input ) { |
|
556 | + $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
557 | + $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
558 | + } |
|
559 | 559 | } else { |
560 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
561 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
560 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
561 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | } |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
622 | 622 | |
623 | 623 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
624 | - $ary = stripslashes_deep( $ary ); |
|
624 | + $ary = stripslashes_deep( $ary ); |
|
625 | 625 | $img_url = \GV\Utils::get( $ary, 0 ); |
626 | 626 | |
627 | 627 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | private function maybe_update_post_fields( $form ) { |
695 | 695 | |
696 | 696 | if( empty( $this->entry['post_id'] ) ) { |
697 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
697 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
698 | 698 | return; |
699 | 699 | } |
700 | 700 | |
@@ -729,51 +729,51 @@ discard block |
||
729 | 729 | |
730 | 730 | switch( $field->type ) { |
731 | 731 | |
732 | - case 'post_title': |
|
733 | - $post_title = $value; |
|
734 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
735 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
736 | - } |
|
737 | - $updated_post->post_title = $post_title; |
|
738 | - $updated_post->post_name = $post_title; |
|
739 | - unset( $post_title ); |
|
740 | - break; |
|
741 | - |
|
742 | - case 'post_content': |
|
743 | - $post_content = $value; |
|
744 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
745 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
746 | - } |
|
747 | - $updated_post->post_content = $post_content; |
|
748 | - unset( $post_content ); |
|
749 | - break; |
|
750 | - case 'post_excerpt': |
|
751 | - $updated_post->post_excerpt = $value; |
|
752 | - break; |
|
753 | - case 'post_tags': |
|
754 | - wp_set_post_tags( $post_id, $value, false ); |
|
755 | - break; |
|
756 | - case 'post_category': |
|
757 | - break; |
|
758 | - case 'post_custom_field': |
|
732 | + case 'post_title': |
|
733 | + $post_title = $value; |
|
734 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
735 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
736 | + } |
|
737 | + $updated_post->post_title = $post_title; |
|
738 | + $updated_post->post_name = $post_title; |
|
739 | + unset( $post_title ); |
|
740 | + break; |
|
741 | + |
|
742 | + case 'post_content': |
|
743 | + $post_content = $value; |
|
744 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
745 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
746 | + } |
|
747 | + $updated_post->post_content = $post_content; |
|
748 | + unset( $post_content ); |
|
749 | + break; |
|
750 | + case 'post_excerpt': |
|
751 | + $updated_post->post_excerpt = $value; |
|
752 | + break; |
|
753 | + case 'post_tags': |
|
754 | + wp_set_post_tags( $post_id, $value, false ); |
|
755 | + break; |
|
756 | + case 'post_category': |
|
757 | + break; |
|
758 | + case 'post_custom_field': |
|
759 | 759 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
760 | 760 | $value = $value[ $field_id ]; |
761 | 761 | } |
762 | 762 | |
763 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
764 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
765 | - } |
|
763 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
764 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
765 | + } |
|
766 | 766 | |
767 | - if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
768 | - $value = wp_json_encode( $value ); |
|
769 | - } |
|
767 | + if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
768 | + $value = wp_json_encode( $value ); |
|
769 | + } |
|
770 | 770 | |
771 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
772 | - break; |
|
771 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
772 | + break; |
|
773 | 773 | |
774 | - case 'post_image': |
|
775 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
776 | - break; |
|
774 | + case 'post_image': |
|
775 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
776 | + break; |
|
777 | 777 | |
778 | 778 | } |
779 | 779 | |
@@ -818,20 +818,20 @@ discard block |
||
818 | 818 | */ |
819 | 819 | private function is_field_json_encoded( $field ) { |
820 | 820 | |
821 | - $json_encoded = false; |
|
821 | + $json_encoded = false; |
|
822 | 822 | |
823 | 823 | $input_type = RGFormsModel::get_input_type( $field ); |
824 | 824 | |
825 | - // Only certain custom field types are supported |
|
826 | - switch( $input_type ) { |
|
827 | - case 'fileupload': |
|
828 | - case 'list': |
|
829 | - case 'multiselect': |
|
830 | - $json_encoded = true; |
|
831 | - break; |
|
832 | - } |
|
825 | + // Only certain custom field types are supported |
|
826 | + switch( $input_type ) { |
|
827 | + case 'fileupload': |
|
828 | + case 'list': |
|
829 | + case 'multiselect': |
|
830 | + $json_encoded = true; |
|
831 | + break; |
|
832 | + } |
|
833 | 833 | |
834 | - return $json_encoded; |
|
834 | + return $json_encoded; |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
@@ -921,14 +921,14 @@ discard block |
||
921 | 921 | ?><h2 class="gv-edit-entry-title"> |
922 | 922 | <span><?php |
923 | 923 | |
924 | - /** |
|
925 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
926 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
927 | - * @param GravityView_Edit_Entry_Render $this This object |
|
928 | - */ |
|
929 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
924 | + /** |
|
925 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
926 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
927 | + * @param GravityView_Edit_Entry_Render $this This object |
|
928 | + */ |
|
929 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
930 | 930 | |
931 | - echo esc_attr( $edit_entry_title ); |
|
931 | + echo esc_attr( $edit_entry_title ); |
|
932 | 932 | ?></span> |
933 | 933 | </h2> |
934 | 934 | |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | |
1038 | 1038 | ob_get_clean(); |
1039 | 1039 | |
1040 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1040 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1041 | 1041 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1042 | 1042 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
1043 | 1043 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | |
1092 | 1092 | // for now we don't support Save and Continue feature. |
1093 | 1093 | if( ! self::$supports_save_and_continue ) { |
1094 | - unset( $form['save'] ); |
|
1094 | + unset( $form['save'] ); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | $form = $this->unselect_default_values( $form ); |
@@ -1118,30 +1118,30 @@ discard block |
||
1118 | 1118 | return $field_content; |
1119 | 1119 | } |
1120 | 1120 | |
1121 | - $message = null; |
|
1121 | + $message = null; |
|
1122 | 1122 | |
1123 | - // First, make sure they have the capability to edit the post. |
|
1124 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1123 | + // First, make sure they have the capability to edit the post. |
|
1124 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1125 | 1125 | |
1126 | - /** |
|
1127 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1128 | - * @param string $message The existing "You don't have permission..." text |
|
1129 | - */ |
|
1130 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1126 | + /** |
|
1127 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1128 | + * @param string $message The existing "You don't have permission..." text |
|
1129 | + */ |
|
1130 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1131 | 1131 | |
1132 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1133 | - /** |
|
1134 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1135 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1136 | - */ |
|
1137 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1138 | - } |
|
1132 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1133 | + /** |
|
1134 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1135 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1136 | + */ |
|
1137 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1138 | + } |
|
1139 | 1139 | |
1140 | - if( $message ) { |
|
1141 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1142 | - } |
|
1140 | + if( $message ) { |
|
1141 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1142 | + } |
|
1143 | 1143 | |
1144 | - return $field_content; |
|
1144 | + return $field_content; |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | /** |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | || ! empty( $field_content ) |
1170 | 1170 | || in_array( $field->type, array( 'honeypot' ) ) |
1171 | 1171 | ) { |
1172 | - return $field_content; |
|
1172 | + return $field_content; |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1177,24 +1177,24 @@ discard block |
||
1177 | 1177 | |
1178 | 1178 | $field_value = $this->get_field_value( $field ); |
1179 | 1179 | |
1180 | - // Prevent any PHP warnings, like undefined index |
|
1181 | - ob_start(); |
|
1180 | + // Prevent any PHP warnings, like undefined index |
|
1181 | + ob_start(); |
|
1182 | 1182 | |
1183 | - $return = null; |
|
1183 | + $return = null; |
|
1184 | 1184 | |
1185 | 1185 | /** @var GravityView_Field $gv_field */ |
1186 | 1186 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1187 | 1187 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1188 | 1188 | } else { |
1189 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1190 | - } |
|
1189 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1190 | + } |
|
1191 | 1191 | |
1192 | - // If there was output, it's an error |
|
1193 | - $warnings = ob_get_clean(); |
|
1192 | + // If there was output, it's an error |
|
1193 | + $warnings = ob_get_clean(); |
|
1194 | 1194 | |
1195 | - if( !empty( $warnings ) ) { |
|
1196 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1197 | - } |
|
1195 | + if( !empty( $warnings ) ) { |
|
1196 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1197 | + } |
|
1198 | 1198 | |
1199 | 1199 | return $return; |
1200 | 1200 | } |
@@ -1229,8 +1229,8 @@ discard block |
||
1229 | 1229 | $input_id = strval( $input['id'] ); |
1230 | 1230 | |
1231 | 1231 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1232 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1233 | - $allow_pre_populated = false; |
|
1232 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1233 | + $allow_pre_populated = false; |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | } |
@@ -1254,7 +1254,7 @@ discard block |
||
1254 | 1254 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1255 | 1255 | $categories = array(); |
1256 | 1256 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1257 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1257 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1258 | 1258 | } |
1259 | 1259 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1260 | 1260 | } |
@@ -1264,25 +1264,25 @@ discard block |
||
1264 | 1264 | // if value is empty get the default value if defined |
1265 | 1265 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1266 | 1266 | |
1267 | - /** |
|
1268 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1269 | - * @since 1.11 |
|
1270 | - * @since 1.20 Added third param |
|
1271 | - * @param mixed $field_value field value used to populate the input |
|
1272 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1273 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1274 | - */ |
|
1275 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1276 | - |
|
1277 | - /** |
|
1278 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1279 | - * @since 1.17 |
|
1280 | - * @since 1.20 Added third param |
|
1281 | - * @param mixed $field_value field value used to populate the input |
|
1282 | - * @param GF_Field $field Gravity Forms field object |
|
1283 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1284 | - */ |
|
1285 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1267 | + /** |
|
1268 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1269 | + * @since 1.11 |
|
1270 | + * @since 1.20 Added third param |
|
1271 | + * @param mixed $field_value field value used to populate the input |
|
1272 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1273 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1274 | + */ |
|
1275 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1276 | + |
|
1277 | + /** |
|
1278 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1279 | + * @since 1.17 |
|
1280 | + * @since 1.20 Added third param |
|
1281 | + * @param mixed $field_value field value used to populate the input |
|
1282 | + * @param GF_Field $field Gravity Forms field object |
|
1283 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1284 | + */ |
|
1285 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1286 | 1286 | |
1287 | 1287 | return $field_value; |
1288 | 1288 | } |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1310 | 1310 | // expects certain field array items to be set. |
1311 | 1311 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1312 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1312 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1313 | 1313 | } |
1314 | 1314 | |
1315 | 1315 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1323,61 +1323,61 @@ discard block |
||
1323 | 1323 | */ |
1324 | 1324 | case 'fileupload': |
1325 | 1325 | |
1326 | - // Set the previous value |
|
1327 | - $entry = $this->get_entry(); |
|
1326 | + // Set the previous value |
|
1327 | + $entry = $this->get_entry(); |
|
1328 | 1328 | |
1329 | - $input_name = 'input_'.$field->id; |
|
1330 | - $form_id = $form['id']; |
|
1329 | + $input_name = 'input_'.$field->id; |
|
1330 | + $form_id = $form['id']; |
|
1331 | 1331 | |
1332 | - $value = NULL; |
|
1332 | + $value = NULL; |
|
1333 | 1333 | |
1334 | - // Use the previous entry value as the default. |
|
1335 | - if( isset( $entry[ $field->id ] ) ) { |
|
1336 | - $value = $entry[ $field->id ]; |
|
1337 | - } |
|
1334 | + // Use the previous entry value as the default. |
|
1335 | + if( isset( $entry[ $field->id ] ) ) { |
|
1336 | + $value = $entry[ $field->id ]; |
|
1337 | + } |
|
1338 | 1338 | |
1339 | - // If this is a single upload file |
|
1340 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1341 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1342 | - $value = $file_path['url']; |
|
1339 | + // If this is a single upload file |
|
1340 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1341 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1342 | + $value = $file_path['url']; |
|
1343 | 1343 | |
1344 | - } else { |
|
1344 | + } else { |
|
1345 | 1345 | |
1346 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1347 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1348 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1346 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1347 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1348 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1349 | 1349 | |
1350 | - } |
|
1350 | + } |
|
1351 | 1351 | |
1352 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1352 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1353 | 1353 | |
1354 | - // If there are fresh uploads, process and merge them. |
|
1355 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1356 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1357 | - $value = empty( $value ) ? '[]' : $value; |
|
1358 | - $value = stripslashes_deep( $value ); |
|
1359 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1360 | - } |
|
1354 | + // If there are fresh uploads, process and merge them. |
|
1355 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1356 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1357 | + $value = empty( $value ) ? '[]' : $value; |
|
1358 | + $value = stripslashes_deep( $value ); |
|
1359 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1360 | + } |
|
1361 | 1361 | |
1362 | - } else { |
|
1362 | + } else { |
|
1363 | 1363 | |
1364 | - // A file already exists when editing an entry |
|
1365 | - // We set this to solve issue when file upload fields are required. |
|
1366 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1364 | + // A file already exists when editing an entry |
|
1365 | + // We set this to solve issue when file upload fields are required. |
|
1366 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1367 | 1367 | |
1368 | - } |
|
1368 | + } |
|
1369 | 1369 | |
1370 | - $this->entry[ $input_name ] = $value; |
|
1371 | - $_POST[ $input_name ] = $value; |
|
1370 | + $this->entry[ $input_name ] = $value; |
|
1371 | + $_POST[ $input_name ] = $value; |
|
1372 | 1372 | |
1373 | - break; |
|
1373 | + break; |
|
1374 | 1374 | |
1375 | 1375 | case 'number': |
1376 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1377 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1378 | - $_POST['input_'.$field->id ] = NULL; |
|
1379 | - } |
|
1380 | - break; |
|
1376 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1377 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1378 | + $_POST['input_'.$field->id ] = NULL; |
|
1379 | + } |
|
1380 | + break; |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | 1383 | } |
@@ -1462,42 +1462,42 @@ discard block |
||
1462 | 1462 | case 'fileupload' : |
1463 | 1463 | case 'post_image': |
1464 | 1464 | |
1465 | - // in case nothing is uploaded but there are already files saved |
|
1466 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1467 | - $field->failed_validation = false; |
|
1468 | - unset( $field->validation_message ); |
|
1469 | - } |
|
1465 | + // in case nothing is uploaded but there are already files saved |
|
1466 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1467 | + $field->failed_validation = false; |
|
1468 | + unset( $field->validation_message ); |
|
1469 | + } |
|
1470 | 1470 | |
1471 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1472 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1471 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1472 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1473 | 1473 | |
1474 | - $input_name = 'input_' . $field->id; |
|
1475 | - //uploaded |
|
1476 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1474 | + $input_name = 'input_' . $field->id; |
|
1475 | + //uploaded |
|
1476 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1477 | 1477 | |
1478 | - //existent |
|
1479 | - $entry = $this->get_entry(); |
|
1480 | - $value = NULL; |
|
1481 | - if( isset( $entry[ $field->id ] ) ) { |
|
1482 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1483 | - } |
|
1478 | + //existent |
|
1479 | + $entry = $this->get_entry(); |
|
1480 | + $value = NULL; |
|
1481 | + if( isset( $entry[ $field->id ] ) ) { |
|
1482 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1483 | + } |
|
1484 | 1484 | |
1485 | - // count uploaded files and existent entry files |
|
1486 | - $count_files = count( $file_names ) + count( $value ); |
|
1485 | + // count uploaded files and existent entry files |
|
1486 | + $count_files = count( $file_names ) + count( $value ); |
|
1487 | 1487 | |
1488 | - if( $count_files > $field->maxFiles ) { |
|
1489 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1490 | - $field->failed_validation = 1; |
|
1491 | - $gv_valid = false; |
|
1488 | + if( $count_files > $field->maxFiles ) { |
|
1489 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1490 | + $field->failed_validation = 1; |
|
1491 | + $gv_valid = false; |
|
1492 | 1492 | |
1493 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1494 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1495 | - } |
|
1493 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1494 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1495 | + } |
|
1496 | 1496 | |
1497 | - } |
|
1497 | + } |
|
1498 | 1498 | |
1499 | 1499 | |
1500 | - break; |
|
1500 | + break; |
|
1501 | 1501 | |
1502 | 1502 | } |
1503 | 1503 | |
@@ -1508,47 +1508,47 @@ discard block |
||
1508 | 1508 | |
1509 | 1509 | switch ( $field_type ) { |
1510 | 1510 | |
1511 | - // Captchas don't need to be re-entered. |
|
1512 | - case 'captcha': |
|
1511 | + // Captchas don't need to be re-entered. |
|
1512 | + case 'captcha': |
|
1513 | 1513 | |
1514 | - // Post Image fields aren't editable, so we un-fail them. |
|
1515 | - case 'post_image': |
|
1516 | - $field->failed_validation = false; |
|
1517 | - unset( $field->validation_message ); |
|
1518 | - break; |
|
1514 | + // Post Image fields aren't editable, so we un-fail them. |
|
1515 | + case 'post_image': |
|
1516 | + $field->failed_validation = false; |
|
1517 | + unset( $field->validation_message ); |
|
1518 | + break; |
|
1519 | 1519 | |
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | // You can't continue inside a switch, so we do it after. |
1523 | 1523 | if( empty( $field->failed_validation ) ) { |
1524 | - continue; |
|
1524 | + continue; |
|
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | // checks if the No Duplicates option is not validating entry against itself, since |
1528 | 1528 | // we're editing a stored entry, it would also assume it's a duplicate. |
1529 | 1529 | if( !empty( $field->noDuplicates ) ) { |
1530 | 1530 | |
1531 | - $entry = $this->get_entry(); |
|
1531 | + $entry = $this->get_entry(); |
|
1532 | 1532 | |
1533 | - // If the value of the entry is the same as the stored value |
|
1534 | - // Then we can assume it's not a duplicate, it's the same. |
|
1535 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1536 | - //if value submitted was not changed, then don't validate |
|
1537 | - $field->failed_validation = false; |
|
1533 | + // If the value of the entry is the same as the stored value |
|
1534 | + // Then we can assume it's not a duplicate, it's the same. |
|
1535 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1536 | + //if value submitted was not changed, then don't validate |
|
1537 | + $field->failed_validation = false; |
|
1538 | 1538 | |
1539 | - unset( $field->validation_message ); |
|
1539 | + unset( $field->validation_message ); |
|
1540 | 1540 | |
1541 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1541 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1542 | 1542 | |
1543 | - continue; |
|
1544 | - } |
|
1543 | + continue; |
|
1544 | + } |
|
1545 | 1545 | } |
1546 | 1546 | |
1547 | 1547 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1548 | 1548 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1549 | - unset( $field->validation_message ); |
|
1550 | - $field->validation_message = false; |
|
1551 | - continue; |
|
1549 | + unset( $field->validation_message ); |
|
1550 | + $field->validation_message = false; |
|
1551 | + continue; |
|
1552 | 1552 | } |
1553 | 1553 | |
1554 | 1554 | $gv_valid = false; |
@@ -1612,8 +1612,8 @@ discard block |
||
1612 | 1612 | // Hide fields depending on admin settings |
1613 | 1613 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1614 | 1614 | |
1615 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1616 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1615 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1616 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1617 | 1617 | |
1618 | 1618 | /** |
1619 | 1619 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1673,11 +1673,11 @@ discard block |
||
1673 | 1673 | // The edit tab has been configured, so we loop through to configured settings |
1674 | 1674 | foreach ( $configured_fields as $configured_field ) { |
1675 | 1675 | |
1676 | - /** @var GF_Field $field */ |
|
1677 | - foreach ( $fields as $field ) { |
|
1676 | + /** @var GF_Field $field */ |
|
1677 | + foreach ( $fields as $field ) { |
|
1678 | 1678 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1679 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1680 | - break; |
|
1679 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1680 | + break; |
|
1681 | 1681 | } |
1682 | 1682 | |
1683 | 1683 | } |
@@ -1733,28 +1733,28 @@ discard block |
||
1733 | 1733 | */ |
1734 | 1734 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
1735 | 1735 | |
1736 | - /** |
|
1736 | + /** |
|
1737 | 1737 | * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true |
1738 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1739 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1740 | - * @since 1.9.1 |
|
1741 | - * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
1742 | - * @param array $form GF Form array |
|
1743 | - * @param int $view_id View ID |
|
1744 | - */ |
|
1745 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1746 | - |
|
1747 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1738 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1739 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1740 | + * @since 1.9.1 |
|
1741 | + * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
1742 | + * @param array $form GF Form array |
|
1743 | + * @param int $view_id View ID |
|
1744 | + */ |
|
1745 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1746 | + |
|
1747 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1748 | 1748 | foreach( $fields as $k => $field ) { |
1749 | 1749 | if( $field->adminOnly ) { |
1750 | - unset( $fields[ $k ] ); |
|
1750 | + unset( $fields[ $k ] ); |
|
1751 | 1751 | } |
1752 | 1752 | } |
1753 | 1753 | return $fields; |
1754 | 1754 | } |
1755 | 1755 | |
1756 | - foreach( $fields as &$field ) { |
|
1757 | - $field->adminOnly = false; |
|
1756 | + foreach( $fields as &$field ) { |
|
1757 | + $field->adminOnly = false; |
|
1758 | 1758 | } |
1759 | 1759 | |
1760 | 1760 | return $fields; |
@@ -1774,13 +1774,13 @@ discard block |
||
1774 | 1774 | */ |
1775 | 1775 | private function unselect_default_values( $form ) { |
1776 | 1776 | |
1777 | - foreach ( $form['fields'] as &$field ) { |
|
1777 | + foreach ( $form['fields'] as &$field ) { |
|
1778 | 1778 | |
1779 | 1779 | if ( empty( $field->choices ) ) { |
1780 | - continue; |
|
1780 | + continue; |
|
1781 | 1781 | } |
1782 | 1782 | |
1783 | - foreach ( $field->choices as &$choice ) { |
|
1783 | + foreach ( $field->choices as &$choice ) { |
|
1784 | 1784 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1785 | 1785 | $choice['isSelected'] = false; |
1786 | 1786 | } |
@@ -1817,36 +1817,36 @@ discard block |
||
1817 | 1817 | |
1818 | 1818 | if( 'checkbox' === $field->type ) { |
1819 | 1819 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1820 | - $input_id = $input['id']; |
|
1821 | - $choice = $field->choices[ $key ]; |
|
1822 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1823 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1824 | - if( $match ) { |
|
1825 | - $field->choices[ $key ]['isSelected'] = true; |
|
1826 | - } |
|
1820 | + $input_id = $input['id']; |
|
1821 | + $choice = $field->choices[ $key ]; |
|
1822 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1823 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1824 | + if( $match ) { |
|
1825 | + $field->choices[ $key ]['isSelected'] = true; |
|
1826 | + } |
|
1827 | 1827 | } |
1828 | 1828 | } else { |
1829 | 1829 | |
1830 | 1830 | // We need to run through each field to set the default values |
1831 | 1831 | foreach ( $this->entry as $field_id => $field_value ) { |
1832 | 1832 | |
1833 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1833 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1834 | 1834 | |
1835 | - if( 'list' === $field->type ) { |
|
1836 | - $list_rows = maybe_unserialize( $field_value ); |
|
1835 | + if( 'list' === $field->type ) { |
|
1836 | + $list_rows = maybe_unserialize( $field_value ); |
|
1837 | 1837 | |
1838 | - $list_field_value = array(); |
|
1839 | - foreach ( (array) $list_rows as $row ) { |
|
1840 | - foreach ( (array) $row as $column ) { |
|
1841 | - $list_field_value[] = $column; |
|
1842 | - } |
|
1843 | - } |
|
1838 | + $list_field_value = array(); |
|
1839 | + foreach ( (array) $list_rows as $row ) { |
|
1840 | + foreach ( (array) $row as $column ) { |
|
1841 | + $list_field_value[] = $column; |
|
1842 | + } |
|
1843 | + } |
|
1844 | 1844 | |
1845 | - $field->defaultValue = serialize( $list_field_value ); |
|
1846 | - } else { |
|
1847 | - $field->defaultValue = $field_value; |
|
1848 | - } |
|
1849 | - } |
|
1845 | + $field->defaultValue = serialize( $list_field_value ); |
|
1846 | + } else { |
|
1847 | + $field->defaultValue = $field_value; |
|
1848 | + } |
|
1849 | + } |
|
1850 | 1850 | } |
1851 | 1851 | } |
1852 | 1852 | } |
@@ -1903,7 +1903,7 @@ discard block |
||
1903 | 1903 | return $has_conditional_logic; |
1904 | 1904 | } |
1905 | 1905 | |
1906 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1906 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1907 | 1907 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
1908 | 1908 | } |
1909 | 1909 | |
@@ -1970,14 +1970,14 @@ discard block |
||
1970 | 1970 | |
1971 | 1971 | if( $echo && $error !== true ) { |
1972 | 1972 | |
1973 | - $error = esc_html( $error ); |
|
1973 | + $error = esc_html( $error ); |
|
1974 | 1974 | |
1975 | - /** |
|
1976 | - * @since 1.9 |
|
1977 | - */ |
|
1978 | - if ( ! empty( $this->entry ) ) { |
|
1979 | - $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;" ) ); |
|
1980 | - } |
|
1975 | + /** |
|
1976 | + * @since 1.9 |
|
1977 | + */ |
|
1978 | + if ( ! empty( $this->entry ) ) { |
|
1979 | + $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;" ) ); |
|
1980 | + } |
|
1981 | 1981 | |
1982 | 1982 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
1983 | 1983 | } |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | function load() { |
116 | 116 | |
117 | 117 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
118 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
118 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
119 | 119 | |
120 | 120 | // Don't display an embedded form when editing an entry |
121 | 121 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
122 | 122 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
123 | 123 | |
124 | 124 | // Stop Gravity Forms processing what is ours! |
125 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
125 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
126 | 126 | |
127 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
127 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
128 | 128 | |
129 | 129 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
130 | 130 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
136 | 136 | |
137 | 137 | // Add fields expected by GFFormDisplay::validate() |
138 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
138 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
139 | 139 | |
140 | 140 | // Fix multiselect value for GF 2.2 |
141 | 141 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | public function prevent_render_form() { |
155 | - if( $this->is_edit_entry() ) { |
|
156 | - if( 'wp_head' === current_filter() ) { |
|
155 | + if ( $this->is_edit_entry() ) { |
|
156 | + if ( 'wp_head' === current_filter() ) { |
|
157 | 157 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
158 | 158 | } else { |
159 | 159 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function prevent_maybe_process_form() { |
170 | 170 | |
171 | - if( ! empty( $_POST ) ) { |
|
171 | + if ( ! empty( $_POST ) ) { |
|
172 | 172 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
173 | 173 | } |
174 | 174 | |
175 | - if( $this->is_edit_entry_submission() ) { |
|
176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
175 | + if ( $this->is_edit_entry_submission() ) { |
|
176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function is_edit_entry() { |
186 | 186 | |
187 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
187 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
188 | 188 | |
189 | 189 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return boolean |
196 | 196 | */ |
197 | 197 | public function is_edit_entry_submission() { |
198 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
198 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | $entries = $gravityview_view->getEntries(); |
211 | - self::$original_entry = $entries[0]; |
|
212 | - $this->entry = $entries[0]; |
|
211 | + self::$original_entry = $entries[ 0 ]; |
|
212 | + $this->entry = $entries[ 0 ]; |
|
213 | 213 | |
214 | 214 | self::$original_form = $gravityview_view->getForm(); |
215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->view_id = $gravityview_view->getViewId(); |
218 | 218 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
219 | 219 | |
220 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
220 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | private function print_scripts() { |
269 | 269 | $gravityview_view = GravityView_View::getInstance(); |
270 | 270 | |
271 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
271 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
272 | 272 | |
273 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
273 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
274 | 274 | |
275 | 275 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
276 | 276 | |
@@ -286,19 +286,19 @@ discard block |
||
286 | 286 | */ |
287 | 287 | private function process_save( $gv_data ) { |
288 | 288 | |
289 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
289 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
290 | 290 | return; |
291 | 291 | } |
292 | 292 | |
293 | 293 | // Make sure the entry, view, and form IDs are all correct |
294 | 294 | $valid = $this->verify_nonce(); |
295 | 295 | |
296 | - if ( !$valid ) { |
|
296 | + if ( ! $valid ) { |
|
297 | 297 | gravityview()->log->error( 'Nonce validation failed.' ); |
298 | 298 | return; |
299 | 299 | } |
300 | 300 | |
301 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
301 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
302 | 302 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
303 | 303 | return; |
304 | 304 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | $this->validate(); |
311 | 311 | |
312 | - if( $this->is_valid ) { |
|
312 | + if ( $this->is_valid ) { |
|
313 | 313 | |
314 | 314 | gravityview()->log->debug( 'Submission is valid.' ); |
315 | 315 | |
@@ -321,22 +321,22 @@ discard block |
||
321 | 321 | /** |
322 | 322 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
323 | 323 | */ |
324 | - unset( $_GET['page'] ); |
|
324 | + unset( $_GET[ 'page' ] ); |
|
325 | 325 | |
326 | - $date_created = $this->entry['date_created']; |
|
326 | + $date_created = $this->entry[ 'date_created' ]; |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
330 | 330 | * @since 1.17.2 |
331 | 331 | */ |
332 | - unset( $this->entry['date_created'] ); |
|
332 | + unset( $this->entry[ 'date_created' ] ); |
|
333 | 333 | |
334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
335 | 335 | |
336 | 336 | // Delete the values for hidden inputs |
337 | 337 | $this->unset_hidden_field_values(); |
338 | 338 | |
339 | - $this->entry['date_created'] = $date_created; |
|
339 | + $this->entry[ 'date_created' ] = $date_created; |
|
340 | 340 | |
341 | 341 | // Process calculation fields |
342 | 342 | $this->update_calculation_fields(); |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @param GravityView_Edit_Entry_Render $this This object |
362 | 362 | * @param GravityView_View_Data $gv_data The View data |
363 | 363 | */ |
364 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
364 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
365 | 365 | |
366 | 366 | } else { |
367 | 367 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -389,16 +389,16 @@ discard block |
||
389 | 389 | */ |
390 | 390 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
391 | 391 | |
392 | - if( ! $unset_hidden_field_values ) { |
|
392 | + if ( ! $unset_hidden_field_values ) { |
|
393 | 393 | return; |
394 | 394 | } |
395 | 395 | |
396 | 396 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
397 | 397 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
398 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
398 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
399 | 399 | } else { |
400 | 400 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
401 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
401 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | } |
480 | 480 | |
481 | 481 | /** No file is being uploaded. */ |
482 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
482 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
483 | 483 | /** So return the original upload */ |
484 | 484 | return $entry[ $input_id ]; |
485 | 485 | } |
@@ -497,11 +497,11 @@ discard block |
||
497 | 497 | * @return mixed |
498 | 498 | */ |
499 | 499 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
500 | - if( ! $this->is_edit_entry() ) { |
|
500 | + if ( ! $this->is_edit_entry() ) { |
|
501 | 501 | return $plupload_init; |
502 | 502 | } |
503 | 503 | |
504 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
504 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
505 | 505 | |
506 | 506 | return $plupload_init; |
507 | 507 | } |
@@ -516,22 +516,22 @@ discard block |
||
516 | 516 | $form = $this->form; |
517 | 517 | |
518 | 518 | /** @var GF_Field $field */ |
519 | - foreach( $form['fields'] as $k => &$field ) { |
|
519 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
520 | 520 | |
521 | 521 | /** |
522 | 522 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
523 | 523 | * @since 1.16.3 |
524 | 524 | * @var GF_Field $field |
525 | 525 | */ |
526 | - if( $field->has_calculation() ) { |
|
527 | - unset( $form['fields'][ $k ] ); |
|
526 | + if ( $field->has_calculation() ) { |
|
527 | + unset( $form[ 'fields' ][ $k ] ); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | $field->adminOnly = false; |
531 | 531 | |
532 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
533 | - foreach( $field->inputs as $key => $input ) { |
|
534 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
532 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
533 | + foreach ( $field->inputs as $key => $input ) { |
|
534 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
535 | 535 | } |
536 | 536 | } |
537 | 537 | } |
@@ -545,20 +545,20 @@ discard block |
||
545 | 545 | $update = false; |
546 | 546 | |
547 | 547 | // get the most up to date entry values |
548 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
548 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
549 | 549 | |
550 | - if( !empty( $this->fields_with_calculation ) ) { |
|
550 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
551 | 551 | $update = true; |
552 | 552 | foreach ( $this->fields_with_calculation as $calc_field ) { |
553 | 553 | $inputs = $calc_field->get_entry_inputs(); |
554 | 554 | if ( is_array( $inputs ) ) { |
555 | 555 | foreach ( $inputs as $input ) { |
556 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
557 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
556 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
557 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
558 | 558 | } |
559 | 559 | } else { |
560 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
561 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
560 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
561 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | } |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | |
568 | 568 | $return_entry = GFAPI::update_entry( $entry ); |
569 | 569 | |
570 | - if( is_wp_error( $return_entry ) ) { |
|
570 | + if ( is_wp_error( $return_entry ) ) { |
|
571 | 571 | gravityview()->log->error( 'Updating the entry calculation fields failed', array( 'data' => $return_entry ) ); |
572 | 572 | } else { |
573 | 573 | gravityview()->log->debug( 'Updating the entry calculation fields succeeded' ); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | return; |
585 | 585 | } |
586 | 586 | |
587 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
587 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
588 | 588 | |
589 | 589 | foreach ( array( 'score', 'percent', 'grade', 'is_pass' ) as $meta ) { |
590 | 590 | GFQuiz::get_instance()->update_entry_meta( "gfquiz_$meta", $entry, self::$original_form ); |
@@ -614,19 +614,19 @@ discard block |
||
614 | 614 | |
615 | 615 | $input_name = 'input_' . $field_id; |
616 | 616 | |
617 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
617 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
618 | 618 | |
619 | 619 | // We have a new image |
620 | 620 | |
621 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
621 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
622 | 622 | |
623 | 623 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
624 | 624 | $ary = stripslashes_deep( $ary ); |
625 | 625 | $img_url = \GV\Utils::get( $ary, 0 ); |
626 | 626 | |
627 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
628 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
629 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
627 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
628 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
629 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
630 | 630 | |
631 | 631 | $image_meta = array( |
632 | 632 | 'post_excerpt' => $img_caption, |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | |
636 | 636 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
637 | 637 | if ( ! empty( $img_title ) ) { |
638 | - $image_meta['post_title'] = $img_title; |
|
638 | + $image_meta[ 'post_title' ] = $img_title; |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | /** |
@@ -693,15 +693,15 @@ discard block |
||
693 | 693 | */ |
694 | 694 | private function maybe_update_post_fields( $form ) { |
695 | 695 | |
696 | - if( empty( $this->entry['post_id'] ) ) { |
|
696 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
697 | 697 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
698 | 698 | return; |
699 | 699 | } |
700 | 700 | |
701 | - $post_id = $this->entry['post_id']; |
|
701 | + $post_id = $this->entry[ 'post_id' ]; |
|
702 | 702 | |
703 | 703 | // Security check |
704 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
704 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
705 | 705 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
706 | 706 | return; |
707 | 707 | } |
@@ -714,25 +714,25 @@ discard block |
||
714 | 714 | |
715 | 715 | $field = RGFormsModel::get_field( $form, $field_id ); |
716 | 716 | |
717 | - if( ! $field ) { |
|
717 | + if ( ! $field ) { |
|
718 | 718 | continue; |
719 | 719 | } |
720 | 720 | |
721 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
721 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
722 | 722 | |
723 | 723 | // Get the value of the field, including $_POSTed value |
724 | 724 | $value = RGFormsModel::get_field_value( $field ); |
725 | 725 | |
726 | 726 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
727 | 727 | $entry_tmp = $this->entry; |
728 | - $entry_tmp["{$field_id}"] = $value; |
|
728 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
729 | 729 | |
730 | - switch( $field->type ) { |
|
730 | + switch ( $field->type ) { |
|
731 | 731 | |
732 | 732 | case 'post_title': |
733 | 733 | $post_title = $value; |
734 | 734 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
735 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
735 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
736 | 736 | } |
737 | 737 | $updated_post->post_title = $post_title; |
738 | 738 | $updated_post->post_name = $post_title; |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | case 'post_content': |
743 | 743 | $post_content = $value; |
744 | 744 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
745 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
745 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
746 | 746 | } |
747 | 747 | $updated_post->post_content = $post_content; |
748 | 748 | unset( $post_content ); |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | $value = $value[ $field_id ]; |
761 | 761 | } |
762 | 762 | |
763 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
763 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
764 | 764 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
765 | 765 | } |
766 | 766 | |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | } |
779 | 779 | |
780 | 780 | // update entry after |
781 | - $this->entry["{$field_id}"] = $value; |
|
781 | + $this->entry[ "{$field_id}" ] = $value; |
|
782 | 782 | |
783 | 783 | $update_entry = true; |
784 | 784 | |
@@ -787,11 +787,11 @@ discard block |
||
787 | 787 | |
788 | 788 | } |
789 | 789 | |
790 | - if( $update_entry ) { |
|
790 | + if ( $update_entry ) { |
|
791 | 791 | |
792 | 792 | $return_entry = GFAPI::update_entry( $this->entry ); |
793 | 793 | |
794 | - if( is_wp_error( $return_entry ) ) { |
|
794 | + if ( is_wp_error( $return_entry ) ) { |
|
795 | 795 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
796 | 796 | } else { |
797 | 797 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | |
802 | 802 | $return_post = wp_update_post( $updated_post, true ); |
803 | 803 | |
804 | - if( is_wp_error( $return_post ) ) { |
|
804 | + if ( is_wp_error( $return_post ) ) { |
|
805 | 805 | $return_post->add_data( $updated_post, '$updated_post' ); |
806 | 806 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
807 | 807 | } else { |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | $input_type = RGFormsModel::get_input_type( $field ); |
824 | 824 | |
825 | 825 | // Only certain custom field types are supported |
826 | - switch( $input_type ) { |
|
826 | + switch ( $input_type ) { |
|
827 | 827 | case 'fileupload': |
828 | 828 | case 'list': |
829 | 829 | case 'multiselect': |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
861 | 861 | |
862 | 862 | // replace conditional shortcodes |
863 | - if( $do_shortcode ) { |
|
863 | + if ( $do_shortcode ) { |
|
864 | 864 | $output = do_shortcode( $output ); |
865 | 865 | } |
866 | 866 | |
@@ -879,19 +879,19 @@ discard block |
||
879 | 879 | */ |
880 | 880 | private function after_update() { |
881 | 881 | |
882 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
883 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
882 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
883 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
884 | 884 | |
885 | 885 | // Re-define the entry now that we've updated it. |
886 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
886 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
887 | 887 | |
888 | 888 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
889 | 889 | |
890 | 890 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
891 | 891 | // We need to clear the cache because Gravity Forms caches the field values, which |
892 | 892 | // we have just updated. |
893 | - foreach ($this->form['fields'] as $key => $field) { |
|
894 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
893 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
894 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | |
911 | 911 | <div class="gv-edit-entry-wrapper"><?php |
912 | 912 | |
913 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
913 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
914 | 914 | |
915 | 915 | /** |
916 | 916 | * Fixes weird wpautop() issue |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | * @param string $edit_entry_title Modify the "Edit Entry" title |
927 | 927 | * @param GravityView_Edit_Entry_Render $this This object |
928 | 928 | */ |
929 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
929 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
930 | 930 | |
931 | 931 | echo esc_attr( $edit_entry_title ); |
932 | 932 | ?></span> |
@@ -976,16 +976,16 @@ discard block |
||
976 | 976 | |
977 | 977 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
978 | 978 | |
979 | - if( ! $this->is_valid ){ |
|
979 | + if ( ! $this->is_valid ) { |
|
980 | 980 | |
981 | 981 | // Keeping this compatible with Gravity Forms. |
982 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
983 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
982 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
983 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
984 | 984 | |
985 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
985 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
986 | 986 | |
987 | 987 | } else { |
988 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
988 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
989 | 989 | |
990 | 990 | /** |
991 | 991 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -995,7 +995,7 @@ discard block |
||
995 | 995 | * @param array $entry Gravity Forms entry array |
996 | 996 | * @param string $back_link URL to return to the original entry. @since 1.6 |
997 | 997 | */ |
998 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
998 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
999 | 999 | |
1000 | 1000 | echo GVCommon::generate_notice( $message ); |
1001 | 1001 | } |
@@ -1019,21 +1019,21 @@ discard block |
||
1019 | 1019 | */ |
1020 | 1020 | do_action( 'gravityview/edit-entry/render/before', $this ); |
1021 | 1021 | |
1022 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1023 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1022 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1023 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1024 | 1024 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
1025 | 1025 | |
1026 | 1026 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
1027 | 1027 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1028 | 1028 | |
1029 | 1029 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1030 | - unset( $_GET['page'] ); |
|
1030 | + unset( $_GET[ 'page' ] ); |
|
1031 | 1031 | |
1032 | 1032 | // TODO: Verify multiple-page forms |
1033 | 1033 | |
1034 | 1034 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1035 | 1035 | |
1036 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1036 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1037 | 1037 | |
1038 | 1038 | ob_get_clean(); |
1039 | 1039 | |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | * @return string |
1060 | 1060 | */ |
1061 | 1061 | public function render_form_buttons() { |
1062 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1062 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | |
@@ -1079,10 +1079,10 @@ discard block |
||
1079 | 1079 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1080 | 1080 | |
1081 | 1081 | // In case we have validated the form, use it to inject the validation results into the form render |
1082 | - if( isset( $this->form_after_validation ) ) { |
|
1082 | + if ( isset( $this->form_after_validation ) ) { |
|
1083 | 1083 | $form = $this->form_after_validation; |
1084 | 1084 | } else { |
1085 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1085 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | $form = $this->filter_conditional_logic( $form ); |
@@ -1090,8 +1090,8 @@ discard block |
||
1090 | 1090 | $form = $this->prefill_conditional_logic( $form ); |
1091 | 1091 | |
1092 | 1092 | // for now we don't support Save and Continue feature. |
1093 | - if( ! self::$supports_save_and_continue ) { |
|
1094 | - unset( $form['save'] ); |
|
1093 | + if ( ! self::$supports_save_and_continue ) { |
|
1094 | + unset( $form[ 'save' ] ); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | $form = $this->unselect_default_values( $form ); |
@@ -1114,31 +1114,31 @@ discard block |
||
1114 | 1114 | */ |
1115 | 1115 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1116 | 1116 | |
1117 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
1117 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
1118 | 1118 | return $field_content; |
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | $message = null; |
1122 | 1122 | |
1123 | 1123 | // First, make sure they have the capability to edit the post. |
1124 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1124 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1125 | 1125 | |
1126 | 1126 | /** |
1127 | 1127 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1128 | 1128 | * @param string $message The existing "You don't have permission..." text |
1129 | 1129 | */ |
1130 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1130 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1131 | 1131 | |
1132 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1132 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1133 | 1133 | /** |
1134 | 1134 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1135 | 1135 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1136 | 1136 | */ |
1137 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1137 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1138 | 1138 | } |
1139 | 1139 | |
1140 | - if( $message ) { |
|
1141 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1140 | + if ( $message ) { |
|
1141 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | return $field_content; |
@@ -1162,8 +1162,8 @@ discard block |
||
1162 | 1162 | |
1163 | 1163 | // If the form has been submitted, then we don't need to pre-fill the values, |
1164 | 1164 | // Except for fileupload type and when a field input is overridden- run always!! |
1165 | - if( |
|
1166 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1165 | + if ( |
|
1166 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1167 | 1167 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1168 | 1168 | && ! GFCommon::is_product_field( $field->type ) |
1169 | 1169 | || ! empty( $field_content ) |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | $return = null; |
1184 | 1184 | |
1185 | 1185 | /** @var GravityView_Field $gv_field */ |
1186 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1186 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1187 | 1187 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1188 | 1188 | } else { |
1189 | 1189 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | // If there was output, it's an error |
1193 | 1193 | $warnings = ob_get_clean(); |
1194 | 1194 | |
1195 | - if( !empty( $warnings ) ) { |
|
1195 | + if ( ! empty( $warnings ) ) { |
|
1196 | 1196 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1197 | 1197 | } |
1198 | 1198 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1218 | 1218 | |
1219 | 1219 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1220 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1220 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1221 | 1221 | |
1222 | 1222 | $field_value = array(); |
1223 | 1223 | |
@@ -1226,10 +1226,10 @@ discard block |
||
1226 | 1226 | |
1227 | 1227 | foreach ( (array)$field->inputs as $input ) { |
1228 | 1228 | |
1229 | - $input_id = strval( $input['id'] ); |
|
1229 | + $input_id = strval( $input[ 'id' ] ); |
|
1230 | 1230 | |
1231 | 1231 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1232 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1232 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1233 | 1233 | $allow_pre_populated = false; |
1234 | 1234 | } |
1235 | 1235 | |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | |
1238 | 1238 | $pre_value = $field->get_value_submission( array(), false ); |
1239 | 1239 | |
1240 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1240 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1241 | 1241 | |
1242 | 1242 | } else { |
1243 | 1243 | |
@@ -1248,13 +1248,13 @@ discard block |
||
1248 | 1248 | |
1249 | 1249 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1250 | 1250 | // or pre-populated value if not empty and set to override saved value |
1251 | - $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; |
|
1251 | + $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; |
|
1252 | 1252 | |
1253 | 1253 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1254 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1254 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1255 | 1255 | $categories = array(); |
1256 | 1256 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1257 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1257 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1258 | 1258 | } |
1259 | 1259 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1260 | 1260 | } |
@@ -1282,7 +1282,7 @@ discard block |
||
1282 | 1282 | * @param GF_Field $field Gravity Forms field object |
1283 | 1283 | * @param GravityView_Edit_Entry_Render $this Current object |
1284 | 1284 | */ |
1285 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1285 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1286 | 1286 | |
1287 | 1287 | return $field_value; |
1288 | 1288 | } |
@@ -1299,12 +1299,12 @@ discard block |
||
1299 | 1299 | */ |
1300 | 1300 | public function gform_pre_validation( $form ) { |
1301 | 1301 | |
1302 | - if( ! $this->verify_nonce() ) { |
|
1302 | + if ( ! $this->verify_nonce() ) { |
|
1303 | 1303 | return $form; |
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | // Fix PHP warning regarding undefined index. |
1307 | - foreach ( $form['fields'] as &$field) { |
|
1307 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1308 | 1308 | |
1309 | 1309 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1310 | 1310 | // expects certain field array items to be set. |
@@ -1312,7 +1312,7 @@ discard block |
||
1312 | 1312 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1313 | 1313 | } |
1314 | 1314 | |
1315 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1315 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1316 | 1316 | |
1317 | 1317 | /** |
1318 | 1318 | * 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. |
@@ -1326,26 +1326,26 @@ discard block |
||
1326 | 1326 | // Set the previous value |
1327 | 1327 | $entry = $this->get_entry(); |
1328 | 1328 | |
1329 | - $input_name = 'input_'.$field->id; |
|
1330 | - $form_id = $form['id']; |
|
1329 | + $input_name = 'input_' . $field->id; |
|
1330 | + $form_id = $form[ 'id' ]; |
|
1331 | 1331 | |
1332 | 1332 | $value = NULL; |
1333 | 1333 | |
1334 | 1334 | // Use the previous entry value as the default. |
1335 | - if( isset( $entry[ $field->id ] ) ) { |
|
1335 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1336 | 1336 | $value = $entry[ $field->id ]; |
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | // If this is a single upload file |
1340 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1341 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1342 | - $value = $file_path['url']; |
|
1340 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1341 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1342 | + $value = $file_path[ 'url' ]; |
|
1343 | 1343 | |
1344 | 1344 | } else { |
1345 | 1345 | |
1346 | 1346 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1347 | 1347 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1348 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1348 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1349 | 1349 | |
1350 | 1350 | } |
1351 | 1351 | |
@@ -1353,10 +1353,10 @@ discard block |
||
1353 | 1353 | |
1354 | 1354 | // If there are fresh uploads, process and merge them. |
1355 | 1355 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1356 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1356 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1357 | 1357 | $value = empty( $value ) ? '[]' : $value; |
1358 | 1358 | $value = stripslashes_deep( $value ); |
1359 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1359 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | } else { |
@@ -1374,8 +1374,8 @@ discard block |
||
1374 | 1374 | |
1375 | 1375 | case 'number': |
1376 | 1376 | // Fix "undefined index" issue at line 1286 in form_display.php |
1377 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1378 | - $_POST['input_'.$field->id ] = NULL; |
|
1377 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1378 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1379 | 1379 | } |
1380 | 1380 | break; |
1381 | 1381 | } |
@@ -1412,7 +1412,7 @@ discard block |
||
1412 | 1412 | * You can enter whatever you want! |
1413 | 1413 | * We try validating, and customize the results using `self::custom_validation()` |
1414 | 1414 | */ |
1415 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1415 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1416 | 1416 | |
1417 | 1417 | // Needed by the validate funtion |
1418 | 1418 | $failed_validation_page = NULL; |
@@ -1420,14 +1420,14 @@ discard block |
||
1420 | 1420 | |
1421 | 1421 | // Prevent entry limit from running when editing an entry, also |
1422 | 1422 | // prevent form scheduling from preventing editing |
1423 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1423 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1424 | 1424 | |
1425 | 1425 | // Hide fields depending on Edit Entry settings |
1426 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1426 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1427 | 1427 | |
1428 | 1428 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1429 | 1429 | |
1430 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1430 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1431 | 1431 | } |
1432 | 1432 | |
1433 | 1433 | |
@@ -1450,7 +1450,7 @@ discard block |
||
1450 | 1450 | |
1451 | 1451 | $gv_valid = true; |
1452 | 1452 | |
1453 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1453 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1454 | 1454 | |
1455 | 1455 | $value = RGFormsModel::get_field_value( $field ); |
1456 | 1456 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1463,35 +1463,35 @@ discard block |
||
1463 | 1463 | case 'post_image': |
1464 | 1464 | |
1465 | 1465 | // in case nothing is uploaded but there are already files saved |
1466 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1466 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1467 | 1467 | $field->failed_validation = false; |
1468 | 1468 | unset( $field->validation_message ); |
1469 | 1469 | } |
1470 | 1470 | |
1471 | 1471 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1472 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1472 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1473 | 1473 | |
1474 | 1474 | $input_name = 'input_' . $field->id; |
1475 | 1475 | //uploaded |
1476 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1476 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1477 | 1477 | |
1478 | 1478 | //existent |
1479 | 1479 | $entry = $this->get_entry(); |
1480 | 1480 | $value = NULL; |
1481 | - if( isset( $entry[ $field->id ] ) ) { |
|
1481 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1482 | 1482 | $value = json_decode( $entry[ $field->id ], true ); |
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | // count uploaded files and existent entry files |
1486 | 1486 | $count_files = count( $file_names ) + count( $value ); |
1487 | 1487 | |
1488 | - if( $count_files > $field->maxFiles ) { |
|
1488 | + if ( $count_files > $field->maxFiles ) { |
|
1489 | 1489 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1490 | 1490 | $field->failed_validation = 1; |
1491 | 1491 | $gv_valid = false; |
1492 | 1492 | |
1493 | 1493 | // in case of error make sure the newest upload files are removed from the upload input |
1494 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1494 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | } |
@@ -1502,7 +1502,7 @@ discard block |
||
1502 | 1502 | } |
1503 | 1503 | |
1504 | 1504 | // This field has failed validation. |
1505 | - if( !empty( $field->failed_validation ) ) { |
|
1505 | + if ( ! empty( $field->failed_validation ) ) { |
|
1506 | 1506 | |
1507 | 1507 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1508 | 1508 | |
@@ -1520,19 +1520,19 @@ discard block |
||
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | // You can't continue inside a switch, so we do it after. |
1523 | - if( empty( $field->failed_validation ) ) { |
|
1523 | + if ( empty( $field->failed_validation ) ) { |
|
1524 | 1524 | continue; |
1525 | 1525 | } |
1526 | 1526 | |
1527 | 1527 | // checks if the No Duplicates option is not validating entry against itself, since |
1528 | 1528 | // we're editing a stored entry, it would also assume it's a duplicate. |
1529 | - if( !empty( $field->noDuplicates ) ) { |
|
1529 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1530 | 1530 | |
1531 | 1531 | $entry = $this->get_entry(); |
1532 | 1532 | |
1533 | 1533 | // If the value of the entry is the same as the stored value |
1534 | 1534 | // Then we can assume it's not a duplicate, it's the same. |
1535 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1535 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1536 | 1536 | //if value submitted was not changed, then don't validate |
1537 | 1537 | $field->failed_validation = false; |
1538 | 1538 | |
@@ -1545,7 +1545,7 @@ discard block |
||
1545 | 1545 | } |
1546 | 1546 | |
1547 | 1547 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1548 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1548 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1549 | 1549 | unset( $field->validation_message ); |
1550 | 1550 | $field->validation_message = false; |
1551 | 1551 | continue; |
@@ -1557,12 +1557,12 @@ discard block |
||
1557 | 1557 | |
1558 | 1558 | } |
1559 | 1559 | |
1560 | - $validation_results['is_valid'] = $gv_valid; |
|
1560 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1561 | 1561 | |
1562 | 1562 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1563 | 1563 | |
1564 | 1564 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1565 | - $this->form_after_validation = $validation_results['form']; |
|
1565 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1566 | 1566 | |
1567 | 1567 | return $validation_results; |
1568 | 1568 | } |
@@ -1575,7 +1575,7 @@ discard block |
||
1575 | 1575 | */ |
1576 | 1576 | public function get_entry() { |
1577 | 1577 | |
1578 | - if( empty( $this->entry ) ) { |
|
1578 | + if ( empty( $this->entry ) ) { |
|
1579 | 1579 | // Get the database value of the entry that's being edited |
1580 | 1580 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1581 | 1581 | } |
@@ -1607,10 +1607,10 @@ discard block |
||
1607 | 1607 | } |
1608 | 1608 | |
1609 | 1609 | // If edit tab not yet configured, show all fields |
1610 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1610 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1611 | 1611 | |
1612 | 1612 | // Hide fields depending on admin settings |
1613 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1613 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1614 | 1614 | |
1615 | 1615 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1616 | 1616 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1642,7 +1642,7 @@ discard block |
||
1642 | 1642 | */ |
1643 | 1643 | private function filter_fields( $fields, $configured_fields ) { |
1644 | 1644 | |
1645 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1645 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1646 | 1646 | return $fields; |
1647 | 1647 | } |
1648 | 1648 | |
@@ -1655,18 +1655,18 @@ discard block |
||
1655 | 1655 | |
1656 | 1656 | // Remove the fields that have calculation properties and keep them to be used later |
1657 | 1657 | // @since 1.16.2 |
1658 | - if( $field->has_calculation() ) { |
|
1659 | - $this->fields_with_calculation[] = $field; |
|
1658 | + if ( $field->has_calculation() ) { |
|
1659 | + $this->fields_with_calculation[ ] = $field; |
|
1660 | 1660 | // don't remove the calculation fields on form render. |
1661 | 1661 | } |
1662 | 1662 | |
1663 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1663 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1664 | 1664 | unset( $fields[ $key ] ); |
1665 | 1665 | } |
1666 | 1666 | } |
1667 | 1667 | |
1668 | 1668 | // The Edit tab has not been configured, so we return all fields by default. |
1669 | - if( empty( $configured_fields ) ) { |
|
1669 | + if ( empty( $configured_fields ) ) { |
|
1670 | 1670 | return $fields; |
1671 | 1671 | } |
1672 | 1672 | |
@@ -1675,8 +1675,8 @@ discard block |
||
1675 | 1675 | |
1676 | 1676 | /** @var GF_Field $field */ |
1677 | 1677 | foreach ( $fields as $field ) { |
1678 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1679 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1678 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1679 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1680 | 1680 | break; |
1681 | 1681 | } |
1682 | 1682 | |
@@ -1699,14 +1699,14 @@ discard block |
||
1699 | 1699 | |
1700 | 1700 | $return_field = $field; |
1701 | 1701 | |
1702 | - if( empty( $field_setting['show_label'] ) ) { |
|
1702 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1703 | 1703 | $return_field->label = ''; |
1704 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1705 | - $return_field->label = $field_setting['custom_label']; |
|
1704 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1705 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1706 | 1706 | } |
1707 | 1707 | |
1708 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1709 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1708 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1709 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1710 | 1710 | } |
1711 | 1711 | |
1712 | 1712 | /** |
@@ -1744,16 +1744,16 @@ discard block |
||
1744 | 1744 | */ |
1745 | 1745 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1746 | 1746 | |
1747 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1748 | - foreach( $fields as $k => $field ) { |
|
1749 | - if( $field->adminOnly ) { |
|
1747 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1748 | + foreach ( $fields as $k => $field ) { |
|
1749 | + if ( $field->adminOnly ) { |
|
1750 | 1750 | unset( $fields[ $k ] ); |
1751 | 1751 | } |
1752 | 1752 | } |
1753 | 1753 | return $fields; |
1754 | 1754 | } |
1755 | 1755 | |
1756 | - foreach( $fields as &$field ) { |
|
1756 | + foreach ( $fields as &$field ) { |
|
1757 | 1757 | $field->adminOnly = false; |
1758 | 1758 | } |
1759 | 1759 | |
@@ -1774,7 +1774,7 @@ discard block |
||
1774 | 1774 | */ |
1775 | 1775 | private function unselect_default_values( $form ) { |
1776 | 1776 | |
1777 | - foreach ( $form['fields'] as &$field ) { |
|
1777 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1778 | 1778 | |
1779 | 1779 | if ( empty( $field->choices ) ) { |
1780 | 1780 | continue; |
@@ -1782,7 +1782,7 @@ discard block |
||
1782 | 1782 | |
1783 | 1783 | foreach ( $field->choices as &$choice ) { |
1784 | 1784 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1785 | - $choice['isSelected'] = false; |
|
1785 | + $choice[ 'isSelected' ] = false; |
|
1786 | 1786 | } |
1787 | 1787 | } |
1788 | 1788 | } |
@@ -1807,22 +1807,22 @@ discard block |
||
1807 | 1807 | */ |
1808 | 1808 | function prefill_conditional_logic( $form ) { |
1809 | 1809 | |
1810 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1810 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1811 | 1811 | return $form; |
1812 | 1812 | } |
1813 | 1813 | |
1814 | 1814 | // Have Conditional Logic pre-fill fields as if the data were default values |
1815 | 1815 | /** @var GF_Field $field */ |
1816 | - foreach ( $form['fields'] as &$field ) { |
|
1816 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1817 | 1817 | |
1818 | - if( 'checkbox' === $field->type ) { |
|
1818 | + if ( 'checkbox' === $field->type ) { |
|
1819 | 1819 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1820 | - $input_id = $input['id']; |
|
1820 | + $input_id = $input[ 'id' ]; |
|
1821 | 1821 | $choice = $field->choices[ $key ]; |
1822 | 1822 | $value = \GV\Utils::get( $this->entry, $input_id ); |
1823 | 1823 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
1824 | - if( $match ) { |
|
1825 | - $field->choices[ $key ]['isSelected'] = true; |
|
1824 | + if ( $match ) { |
|
1825 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
1826 | 1826 | } |
1827 | 1827 | } |
1828 | 1828 | } else { |
@@ -1830,15 +1830,15 @@ discard block |
||
1830 | 1830 | // We need to run through each field to set the default values |
1831 | 1831 | foreach ( $this->entry as $field_id => $field_value ) { |
1832 | 1832 | |
1833 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1833 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1834 | 1834 | |
1835 | - if( 'list' === $field->type ) { |
|
1835 | + if ( 'list' === $field->type ) { |
|
1836 | 1836 | $list_rows = maybe_unserialize( $field_value ); |
1837 | 1837 | |
1838 | 1838 | $list_field_value = array(); |
1839 | - foreach ( (array) $list_rows as $row ) { |
|
1840 | - foreach ( (array) $row as $column ) { |
|
1841 | - $list_field_value[] = $column; |
|
1839 | + foreach ( (array)$list_rows as $row ) { |
|
1840 | + foreach ( (array)$row as $column ) { |
|
1841 | + $list_field_value[ ] = $column; |
|
1842 | 1842 | } |
1843 | 1843 | } |
1844 | 1844 | |
@@ -1873,16 +1873,16 @@ discard block |
||
1873 | 1873 | */ |
1874 | 1874 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1875 | 1875 | |
1876 | - if( $use_conditional_logic ) { |
|
1876 | + if ( $use_conditional_logic ) { |
|
1877 | 1877 | return $form; |
1878 | 1878 | } |
1879 | 1879 | |
1880 | - foreach( $form['fields'] as &$field ) { |
|
1880 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1881 | 1881 | /* @var GF_Field $field */ |
1882 | 1882 | $field->conditionalLogic = null; |
1883 | 1883 | } |
1884 | 1884 | |
1885 | - unset( $form['button']['conditionalLogic'] ); |
|
1885 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1886 | 1886 | |
1887 | 1887 | return $form; |
1888 | 1888 | |
@@ -1899,7 +1899,7 @@ discard block |
||
1899 | 1899 | */ |
1900 | 1900 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
1901 | 1901 | |
1902 | - if( ! $this->is_edit_entry() ) { |
|
1902 | + if ( ! $this->is_edit_entry() ) { |
|
1903 | 1903 | return $has_conditional_logic; |
1904 | 1904 | } |
1905 | 1905 | |
@@ -1931,44 +1931,44 @@ discard block |
||
1931 | 1931 | * 2. There are two entries embedded using oEmbed |
1932 | 1932 | * 3. One of the entries has just been saved |
1933 | 1933 | */ |
1934 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1934 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1935 | 1935 | |
1936 | 1936 | $error = true; |
1937 | 1937 | |
1938 | 1938 | } |
1939 | 1939 | |
1940 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1940 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1941 | 1941 | |
1942 | 1942 | $error = true; |
1943 | 1943 | |
1944 | - } elseif( ! $this->verify_nonce() ) { |
|
1944 | + } elseif ( ! $this->verify_nonce() ) { |
|
1945 | 1945 | |
1946 | 1946 | /** |
1947 | 1947 | * If the Entry is embedded, there may be two entries on the same page. |
1948 | 1948 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1949 | 1949 | */ |
1950 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1950 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1951 | 1951 | $error = true; |
1952 | 1952 | } else { |
1953 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1953 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1954 | 1954 | } |
1955 | 1955 | |
1956 | 1956 | } |
1957 | 1957 | |
1958 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1959 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1958 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1959 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1960 | 1960 | } |
1961 | 1961 | |
1962 | - if( $this->entry['status'] === 'trash' ) { |
|
1963 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1962 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1963 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1964 | 1964 | } |
1965 | 1965 | |
1966 | 1966 | // No errors; everything's fine here! |
1967 | - if( empty( $error ) ) { |
|
1967 | + if ( empty( $error ) ) { |
|
1968 | 1968 | return true; |
1969 | 1969 | } |
1970 | 1970 | |
1971 | - if( $echo && $error !== true ) { |
|
1971 | + if ( $echo && $error !== true ) { |
|
1972 | 1972 | |
1973 | 1973 | $error = esc_html( $error ); |
1974 | 1974 | |
@@ -1976,10 +1976,10 @@ discard block |
||
1976 | 1976 | * @since 1.9 |
1977 | 1977 | */ |
1978 | 1978 | if ( ! empty( $this->entry ) ) { |
1979 | - $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;" ) ); |
|
1979 | + $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;" ) ); |
|
1980 | 1980 | } |
1981 | 1981 | |
1982 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1982 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1983 | 1983 | } |
1984 | 1984 | |
1985 | 1985 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1999,17 +1999,17 @@ discard block |
||
1999 | 1999 | |
2000 | 2000 | $error = NULL; |
2001 | 2001 | |
2002 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2003 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
2002 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2003 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
2004 | 2004 | } |
2005 | 2005 | |
2006 | 2006 | // No errors; everything's fine here! |
2007 | - if( empty( $error ) ) { |
|
2007 | + if ( empty( $error ) ) { |
|
2008 | 2008 | return true; |
2009 | 2009 | } |
2010 | 2010 | |
2011 | - if( $echo ) { |
|
2012 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
2011 | + if ( $echo ) { |
|
2012 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
2013 | 2013 | } |
2014 | 2014 | |
2015 | 2015 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2030,14 +2030,14 @@ discard block |
||
2030 | 2030 | private function check_user_cap_edit_field( $field ) { |
2031 | 2031 | |
2032 | 2032 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
2033 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2033 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2034 | 2034 | return true; |
2035 | 2035 | } |
2036 | 2036 | |
2037 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
2037 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
2038 | 2038 | |
2039 | - if( $field_cap ) { |
|
2040 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
2039 | + if ( $field_cap ) { |
|
2040 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
2041 | 2041 | } |
2042 | 2042 | |
2043 | 2043 | return false; |
@@ -2051,17 +2051,17 @@ discard block |
||
2051 | 2051 | public function verify_nonce() { |
2052 | 2052 | |
2053 | 2053 | // Verify form submitted for editing single |
2054 | - if( $this->is_edit_entry_submission() ) { |
|
2054 | + if ( $this->is_edit_entry_submission() ) { |
|
2055 | 2055 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2056 | 2056 | } |
2057 | 2057 | |
2058 | 2058 | // Verify |
2059 | - else if( ! $this->is_edit_entry() ) { |
|
2059 | + else if ( ! $this->is_edit_entry() ) { |
|
2060 | 2060 | $valid = false; |
2061 | 2061 | } |
2062 | 2062 | |
2063 | 2063 | else { |
2064 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2064 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2065 | 2065 | } |
2066 | 2066 | |
2067 | 2067 | /** |
@@ -128,10 +128,10 @@ |
||
128 | 128 | */ |
129 | 129 | public function is_edit_entry( $form_id = 0 ) { |
130 | 130 | /** |
131 | - * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n |
|
132 | - * The Edit Entry functionality overrides this value. |
|
133 | - * @param boolean $is_edit_entry |
|
134 | - */ |
|
131 | + * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n |
|
132 | + * The Edit Entry functionality overrides this value. |
|
133 | + * @param boolean $is_edit_entry |
|
134 | + */ |
|
135 | 135 | if ( ( $entry = $this->is_entry( $form_id ) ) && apply_filters( 'gravityview_is_edit_entry', false ) ) { |
136 | 136 | return $entry; |
137 | 137 | } |