@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | add_action( 'wp', array( $this, 'process_delete' ), 10000 ); |
| 44 | 44 | |
| 45 | - add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field'), 10, 3 ); |
|
| 45 | + add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); |
|
| 46 | 46 | |
| 47 | 47 | add_action( 'gravityview_before', array( $this, 'display_message' ) ); |
| 48 | 48 | |
| 49 | 49 | // For the Delete Entry Link, you don't want visible to all users. |
| 50 | - add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps'), 10, 5 ); |
|
| 50 | + add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 ); |
|
| 51 | 51 | |
| 52 | 52 | // Modify the field options based on the name of the field type |
| 53 | 53 | add_filter( 'gravityview_template_delete_link_options', array( $this, 'delete_link_field_options' ), 10, 5 ); |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | // add template path to check for field |
| 56 | 56 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
| 57 | 57 | |
| 58 | - add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button'), 10, 4 ); |
|
| 58 | + add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button' ), 10, 4 ); |
|
| 59 | 59 | |
| 60 | - add_action ( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
| 61 | - add_action ( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
| 60 | + add_action( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
| 61 | + add_action( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | static function getInstance() { |
| 71 | 71 | |
| 72 | - if( empty( self::$instance ) ) { |
|
| 72 | + if ( empty( self::$instance ) ) { |
|
| 73 | 73 | self::$instance = new self; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -105,20 +105,20 @@ discard block |
||
| 105 | 105 | function delete_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 106 | 106 | |
| 107 | 107 | // Always a link, never a filter |
| 108 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
| 108 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
| 109 | 109 | |
| 110 | 110 | // Delete Entry link should only appear to visitors capable of editing entries |
| 111 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
| 111 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
| 112 | 112 | |
| 113 | - $add_option['delete_link'] = array( |
|
| 113 | + $add_option[ 'delete_link' ] = array( |
|
| 114 | 114 | 'type' => 'text', |
| 115 | 115 | 'label' => __( 'Delete Link Text', 'gravityview' ), |
| 116 | 116 | 'desc' => NULL, |
| 117 | - 'value' => __('Delete Entry', 'gravityview'), |
|
| 117 | + 'value' => __( 'Delete Entry', 'gravityview' ), |
|
| 118 | 118 | 'merge_tags' => true, |
| 119 | 119 | ); |
| 120 | 120 | |
| 121 | - $field_options['allow_edit_cap'] = array( |
|
| 121 | + $field_options[ 'allow_edit_cap' ] = array( |
|
| 122 | 122 | 'type' => 'select', |
| 123 | 123 | 'label' => __( 'Allow the following users to delete the entry:', 'gravityview' ), |
| 124 | 124 | 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
| 144 | 144 | |
| 145 | - if( 'edit' !== $zone ) { |
|
| 146 | - $entry_default_fields['delete_link'] = array( |
|
| 145 | + if ( 'edit' !== $zone ) { |
|
| 146 | + $entry_default_fields[ 'delete_link' ] = array( |
|
| 147 | 147 | 'label' => __( 'Delete Entry', 'gravityview' ), |
| 148 | 148 | 'type' => 'delete_link', |
| 149 | 149 | 'desc' => __( 'A link to delete the entry. Respects the Delete Entry permissions.', 'gravityview' ), |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | function add_available_field( $available_fields = array() ) { |
| 162 | 162 | |
| 163 | - $available_fields['delete_link'] = array( |
|
| 163 | + $available_fields[ 'delete_link' ] = array( |
|
| 164 | 164 | 'label_text' => __( 'Delete Entry', 'gravityview' ), |
| 165 | 165 | 'field_id' => 'delete_link', |
| 166 | 166 | 'label_type' => 'field', |
@@ -188,12 +188,12 @@ discard block |
||
| 188 | 188 | $caps = $visibility_caps; |
| 189 | 189 | |
| 190 | 190 | // If we're configuring fields in the edit context, we want a limited selection |
| 191 | - if( $field_id === 'delete_link' ) { |
|
| 191 | + if ( $field_id === 'delete_link' ) { |
|
| 192 | 192 | |
| 193 | 193 | // Remove other built-in caps. |
| 194 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
| 194 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] ); |
|
| 195 | 195 | |
| 196 | - $caps['read'] = _x('Entry Creator', 'User capability', 'gravityview'); |
|
| 196 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | return $caps; |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * @param [type] $entry [description] |
| 207 | 207 | */ |
| 208 | 208 | function set_entry( $entry = null ) { |
| 209 | - $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry; |
|
| 209 | + $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[ 0 ] : $entry; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | self::getInstance()->set_entry( $entry ); |
| 241 | 241 | |
| 242 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
| 242 | + $base = GravityView_API::directory_link( $post_id ?: $view_id, true ); |
|
| 243 | 243 | |
| 244 | 244 | if ( empty( $base ) ) { |
| 245 | 245 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | // Use the slug instead of the ID for consistent security |
| 250 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
| 250 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
| 251 | 251 | |
| 252 | 252 | $actionurl = add_query_arg( array( |
| 253 | 253 | 'action' => 'delete', |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | 'view_id' => $view_id, |
| 257 | 257 | ), $base ); |
| 258 | 258 | |
| 259 | - $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' ); |
|
| 259 | + $url = wp_nonce_url( $actionurl, 'delete_' . $entry_slug, 'delete' ); |
|
| 260 | 260 | |
| 261 | 261 | return $url; |
| 262 | 262 | } |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | public function add_delete_button( $form = array(), $entry = array(), $view_id = null, $post_id = null ) { |
| 279 | 279 | |
| 280 | 280 | // Only show the link to those who are allowed to see it. |
| 281 | - if( !self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
| 281 | + if ( ! self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
| 282 | 282 | return; |
| 283 | 283 | } |
| 284 | 284 | |
@@ -289,13 +289,13 @@ discard block |
||
| 289 | 289 | $show_delete_button = apply_filters( 'gravityview/delete-entry/show-delete-button', true ); |
| 290 | 290 | |
| 291 | 291 | // If the button is hidden by the filter, don't show. |
| 292 | - if( !$show_delete_button ) { |
|
| 292 | + if ( ! $show_delete_button ) { |
|
| 293 | 293 | return; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | $attributes = array( |
| 297 | 297 | 'class' => 'btn btn-sm button button-small alignright pull-right btn-danger gv-button-delete', |
| 298 | - 'tabindex' => ( GFCommon::$tab_index ++ ), |
|
| 298 | + 'tabindex' => ( GFCommon::$tab_index++ ), |
|
| 299 | 299 | 'onclick' => self::get_confirm_dialog(), |
| 300 | 300 | ); |
| 301 | 301 | |
@@ -319,27 +319,27 @@ discard block |
||
| 319 | 319 | function process_delete() { |
| 320 | 320 | |
| 321 | 321 | // If the form is submitted |
| 322 | - if( isset( $_GET['action'] ) && 'delete' === $_GET['action'] && isset( $_GET['entry_id'] ) ) { |
|
| 322 | + if ( isset( $_GET[ 'action' ] ) && 'delete' === $_GET[ 'action' ] && isset( $_GET[ 'entry_id' ] ) ) { |
|
| 323 | 323 | |
| 324 | 324 | // Make sure it's a GravityView request |
| 325 | - $valid_nonce_key = wp_verify_nonce( $_GET['delete'], self::get_nonce_key( $_GET['entry_id'] ) ); |
|
| 325 | + $valid_nonce_key = wp_verify_nonce( $_GET[ 'delete' ], self::get_nonce_key( $_GET[ 'entry_id' ] ) ); |
|
| 326 | 326 | |
| 327 | - if( ! $valid_nonce_key ) { |
|
| 327 | + if ( ! $valid_nonce_key ) { |
|
| 328 | 328 | gravityview()->log->debug( 'Delete entry not processed: nonce validation failed.' ); |
| 329 | 329 | return; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Get the entry slug |
| 333 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
| 333 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] ); |
|
| 334 | 334 | |
| 335 | 335 | // See if there's an entry there |
| 336 | 336 | $entry = gravityview_get_entry( $entry_slug, true, false ); |
| 337 | 337 | |
| 338 | - if( $entry ) { |
|
| 338 | + if ( $entry ) { |
|
| 339 | 339 | |
| 340 | 340 | $has_permission = $this->user_can_delete_entry( $entry ); |
| 341 | 341 | |
| 342 | - if( is_wp_error( $has_permission ) ) { |
|
| 342 | + if ( is_wp_error( $has_permission ) ) { |
|
| 343 | 343 | |
| 344 | 344 | $messages = array( |
| 345 | 345 | 'message' => urlencode( $has_permission->get_error_message() ), |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | // Delete the entry |
| 352 | 352 | $delete_response = $this->delete_or_trash_entry( $entry ); |
| 353 | 353 | |
| 354 | - if( is_wp_error( $delete_response ) ) { |
|
| 354 | + if ( is_wp_error( $delete_response ) ) { |
|
| 355 | 355 | |
| 356 | 356 | $messages = array( |
| 357 | 357 | 'message' => urlencode( $delete_response->get_error_message() ), |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | gravityview()->log->debug( 'Delete entry failed: there was no entry with the entry slug {entry_slug}', array( 'entry_slug' => $entry_slug ) ); |
| 374 | 374 | |
| 375 | 375 | $messages = array( |
| 376 | - 'message' => urlencode( __('The entry does not exist.', 'gravityview') ), |
|
| 376 | + 'message' => urlencode( __( 'The entry does not exist.', 'gravityview' ) ), |
|
| 377 | 377 | 'status' => 'error', |
| 378 | 378 | ); |
| 379 | 379 | } |
@@ -413,18 +413,18 @@ discard block |
||
| 413 | 413 | */ |
| 414 | 414 | private function delete_or_trash_entry( $entry ) { |
| 415 | 415 | |
| 416 | - $entry_id = $entry['id']; |
|
| 416 | + $entry_id = $entry[ 'id' ]; |
|
| 417 | 417 | |
| 418 | 418 | $mode = $this->get_delete_mode(); |
| 419 | 419 | |
| 420 | - if( 'delete' === $mode ) { |
|
| 420 | + if ( 'delete' === $mode ) { |
|
| 421 | 421 | |
| 422 | 422 | gravityview()->log->debug( 'Starting delete entry: {entry_id}', array( 'entry_id' => $entry_id ) ); |
| 423 | 423 | |
| 424 | 424 | // Delete the entry |
| 425 | 425 | $delete_response = GFAPI::delete_entry( $entry_id ); |
| 426 | 426 | |
| 427 | - if( ! is_wp_error( $delete_response ) ) { |
|
| 427 | + if ( ! is_wp_error( $delete_response ) ) { |
|
| 428 | 428 | $delete_response = 'deleted'; |
| 429 | 429 | |
| 430 | 430 | /** |
@@ -445,8 +445,8 @@ discard block |
||
| 445 | 445 | $trashed = GFAPI::update_entry_property( $entry_id, 'status', 'trash' ); |
| 446 | 446 | new GravityView_Cache; |
| 447 | 447 | |
| 448 | - if( ! $trashed ) { |
|
| 449 | - $delete_response = new WP_Error( 'trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview' ) ); |
|
| 448 | + if ( ! $trashed ) { |
|
| 449 | + $delete_response = new WP_Error( 'trash_entry_failed', __( 'Moving the entry to the trash failed.', 'gravityview' ) ); |
|
| 450 | 450 | } else { |
| 451 | 451 | |
| 452 | 452 | /** |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | public function process_connected_posts( $entry_id = 0, $entry = array() ) { |
| 478 | 478 | |
| 479 | 479 | // The entry had no connected post |
| 480 | - if( empty( $entry['post_id'] ) ) { |
|
| 480 | + if ( empty( $entry[ 'post_id' ] ) ) { |
|
| 481 | 481 | return; |
| 482 | 482 | } |
| 483 | 483 | |
@@ -488,19 +488,19 @@ discard block |
||
| 488 | 488 | */ |
| 489 | 489 | $delete_post = apply_filters( 'gravityview/delete-entry/delete-connected-post', true ); |
| 490 | 490 | |
| 491 | - if( false === $delete_post ) { |
|
| 491 | + if ( false === $delete_post ) { |
|
| 492 | 492 | return; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | $action = current_action(); |
| 496 | 496 | |
| 497 | - if( 'gravityview/delete-entry/deleted' === $action ) { |
|
| 498 | - $result = wp_delete_post( $entry['post_id'], true ); |
|
| 497 | + if ( 'gravityview/delete-entry/deleted' === $action ) { |
|
| 498 | + $result = wp_delete_post( $entry[ 'post_id' ], true ); |
|
| 499 | 499 | } else { |
| 500 | - $result = wp_trash_post( $entry['post_id'] ); |
|
| 500 | + $result = wp_trash_post( $entry[ 'post_id' ] ); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - if( false === $result ) { |
|
| 503 | + if ( false === $result ) { |
|
| 504 | 504 | gravityview()->log->error( '(called by {action}): Error processing the Post connected to the entry.', array( 'action' => $action, 'data' => $entry ) ); |
| 505 | 505 | } else { |
| 506 | 506 | gravityview()->log->debug( '(called by {action}): Successfully processed Post connected to the entry.', array( 'action' => $action, 'data' => $entry ) ); |
@@ -516,13 +516,13 @@ discard block |
||
| 516 | 516 | public function verify_nonce() { |
| 517 | 517 | |
| 518 | 518 | // No delete entry request was made |
| 519 | - if( empty( $_GET['entry_id'] ) || empty( $_GET['delete'] ) ) { |
|
| 519 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'delete' ] ) ) { |
|
| 520 | 520 | return false; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
| 523 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
| 524 | 524 | |
| 525 | - $valid = wp_verify_nonce( $_GET['delete'], $nonce_key ); |
|
| 525 | + $valid = wp_verify_nonce( $_GET[ 'delete' ], $nonce_key ); |
|
| 526 | 526 | |
| 527 | 527 | /** |
| 528 | 528 | * @filter `gravityview/delete-entry/verify_nonce` Override Delete Entry nonce validation. Return true to declare nonce valid. |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | */ |
| 545 | 545 | public static function get_confirm_dialog() { |
| 546 | 546 | |
| 547 | - $confirm = __('Are you sure you want to delete this entry? This cannot be undone.', 'gravityview'); |
|
| 547 | + $confirm = __( 'Are you sure you want to delete this entry? This cannot be undone.', 'gravityview' ); |
|
| 548 | 548 | |
| 549 | 549 | /** |
| 550 | 550 | * @filter `gravityview/delete-entry/confirm-text` Modify the Delete Entry Javascript confirmation text |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | */ |
| 553 | 553 | $confirm = apply_filters( 'gravityview/delete-entry/confirm-text', $confirm ); |
| 554 | 554 | |
| 555 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
| 555 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');'; |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | /** |
@@ -570,16 +570,16 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | $error = NULL; |
| 572 | 572 | |
| 573 | - if( ! $this->verify_nonce() ) { |
|
| 574 | - $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview'); |
|
| 573 | + if ( ! $this->verify_nonce() ) { |
|
| 574 | + $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - if( ! self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
| 578 | - $error = __( 'You do not have permission to delete this entry.', 'gravityview'); |
|
| 577 | + if ( ! self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
| 578 | + $error = __( 'You do not have permission to delete this entry.', 'gravityview' ); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - if( $entry['status'] === 'trash' ) { |
|
| 582 | - if( 'trash' === $this->get_delete_mode() ) { |
|
| 581 | + if ( $entry[ 'status' ] === 'trash' ) { |
|
| 582 | + if ( 'trash' === $this->get_delete_mode() ) { |
|
| 583 | 583 | $error = __( 'The entry is already in the trash.', 'gravityview' ); |
| 584 | 584 | } else { |
| 585 | 585 | $error = __( 'You cannot delete the entry; it is already in the trash.', 'gravityview' ); |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | // No errors; everything's fine here! |
| 590 | - if( empty( $error ) ) { |
|
| 590 | + if ( empty( $error ) ) { |
|
| 591 | 591 | return true; |
| 592 | 592 | } |
| 593 | 593 | |
@@ -616,10 +616,10 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | $current_user = wp_get_current_user(); |
| 618 | 618 | |
| 619 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL; |
|
| 619 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL; |
|
| 620 | 620 | |
| 621 | 621 | // Or if they can delete any entries (as defined in Gravity Forms), we're good. |
| 622 | - if( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { |
|
| 622 | + if ( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { |
|
| 623 | 623 | |
| 624 | 624 | gravityview()->log->debug( 'Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' ); |
| 625 | 625 | |
@@ -628,20 +628,20 @@ discard block |
||
| 628 | 628 | |
| 629 | 629 | |
| 630 | 630 | // If field options are passed, check if current user can view the link |
| 631 | - if( !empty( $field ) ) { |
|
| 631 | + if ( ! empty( $field ) ) { |
|
| 632 | 632 | |
| 633 | 633 | // If capability is not defined, something is not right! |
| 634 | - if( empty( $field['allow_edit_cap'] ) ) { |
|
| 634 | + if ( empty( $field[ 'allow_edit_cap' ] ) ) { |
|
| 635 | 635 | |
| 636 | 636 | gravityview()->log->error( 'Cannot read delete entry field caps', array( 'data' => $field ) ); |
| 637 | 637 | |
| 638 | 638 | return false; |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - if( GVCommon::has_cap( $field['allow_edit_cap'] ) ) { |
|
| 641 | + if ( GVCommon::has_cap( $field[ 'allow_edit_cap' ] ) ) { |
|
| 642 | 642 | |
| 643 | 643 | // Do not return true if cap is read, as we need to check if the current user created the entry |
| 644 | - if( $field['allow_edit_cap'] !== 'read' ) { |
|
| 644 | + if ( $field[ 'allow_edit_cap' ] !== 'read' ) { |
|
| 645 | 645 | return true; |
| 646 | 646 | } |
| 647 | 647 | |
@@ -654,21 +654,21 @@ discard block |
||
| 654 | 654 | |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - if( !isset( $entry['created_by'] ) ) { |
|
| 657 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
| 658 | 658 | |
| 659 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
| 659 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
|
| 660 | 660 | |
| 661 | 661 | return false; |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | // Only checks user_delete view option if view is already set |
| 665 | - if( $view_id ) { |
|
| 665 | + if ( $view_id ) { |
|
| 666 | 666 | |
| 667 | 667 | $current_view = gravityview_get_current_view_data( $view_id ); |
| 668 | 668 | |
| 669 | - $user_delete = isset( $current_view['atts']['user_delete'] ) ? $current_view['atts']['user_delete'] : false; |
|
| 669 | + $user_delete = isset( $current_view[ 'atts' ][ 'user_delete' ] ) ? $current_view[ 'atts' ][ 'user_delete' ] : false; |
|
| 670 | 670 | |
| 671 | - if( empty( $user_delete ) ) { |
|
| 671 | + if ( empty( $user_delete ) ) { |
|
| 672 | 672 | |
| 673 | 673 | gravityview()->log->debug( 'User Delete is disabled. Returning false.' ); |
| 674 | 674 | |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | // If the logged-in user is the same as the user who created the entry, we're good. |
| 680 | - if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 680 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
| 681 | 681 | |
| 682 | 682 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) ); |
| 683 | 683 | |
@@ -702,16 +702,16 @@ discard block |
||
| 702 | 702 | */ |
| 703 | 703 | public function display_message( $current_view_id = 0 ) { |
| 704 | 704 | |
| 705 | - if( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
| 705 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
| 706 | 706 | return; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | // Entry wasn't deleted from current View |
| 710 | - if( isset( $_GET['view_id'] ) && intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) { |
|
| 710 | + if ( isset( $_GET[ 'view_id' ] ) && intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) { |
|
| 711 | 711 | return; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - $status = esc_attr( $_GET['status'] ); |
|
| 714 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
| 715 | 715 | $message_from_url = \GV\Utils::_GET( 'message' ); |
| 716 | 716 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) ); |
| 717 | 717 | $class = ''; |
@@ -719,14 +719,14 @@ discard block |
||
| 719 | 719 | switch ( $status ) { |
| 720 | 720 | case 'error': |
| 721 | 721 | $class = ' gv-error error'; |
| 722 | - $error_message = __('There was an error deleting the entry: %s', 'gravityview'); |
|
| 722 | + $error_message = __( 'There was an error deleting the entry: %s', 'gravityview' ); |
|
| 723 | 723 | $message = sprintf( $error_message, $message_from_url ); |
| 724 | 724 | break; |
| 725 | 725 | case 'trashed': |
| 726 | - $message = __('The entry was successfully moved to the trash.', 'gravityview'); |
|
| 726 | + $message = __( 'The entry was successfully moved to the trash.', 'gravityview' ); |
|
| 727 | 727 | break; |
| 728 | 728 | default: |
| 729 | - $message = __('The entry was successfully deleted.', 'gravityview'); |
|
| 729 | + $message = __( 'The entry was successfully deleted.', 'gravityview' ); |
|
| 730 | 730 | break; |
| 731 | 731 | } |
| 732 | 732 | |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | $message = apply_filters( 'gravityview/delete-entry/message', esc_attr( $message ), $status, $message_from_url ); |
| 741 | 741 | |
| 742 | 742 | // DISPLAY ERROR/SUCCESS MESSAGE |
| 743 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
| 743 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>'; |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | <div id="publishing-action"> |
| 8 | 8 | <?php |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * @filter `gravityview/edit_entry/cancel_link` Modify the cancel button link URL |
|
| 12 | - * @since 1.11.1 |
|
| 13 | - * @param string $back_link Existing URL of the Cancel link |
|
| 14 | - * @param array $form The Gravity Forms form |
|
| 15 | - * @param array $entry The Gravity Forms entry |
|
| 16 | - * @param int $view_id The current View ID |
|
| 17 | - */ |
|
| 18 | - $back_link = apply_filters( 'gravityview/edit_entry/cancel_link', remove_query_arg( array( 'page', 'view', 'edit' ) ), $object->form, $object->entry, $object->view_id ); |
|
| 10 | + /** |
|
| 11 | + * @filter `gravityview/edit_entry/cancel_link` Modify the cancel button link URL |
|
| 12 | + * @since 1.11.1 |
|
| 13 | + * @param string $back_link Existing URL of the Cancel link |
|
| 14 | + * @param array $form The Gravity Forms form |
|
| 15 | + * @param array $entry The Gravity Forms entry |
|
| 16 | + * @param int $view_id The current View ID |
|
| 17 | + */ |
|
| 18 | + $back_link = apply_filters( 'gravityview/edit_entry/cancel_link', remove_query_arg( array( 'page', 'view', 'edit' ) ), $object->form, $object->entry, $object->view_id ); |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @action `gravityview/edit-entry/publishing-action/before` Triggered before the submit buttons in the Edit Entry screen, inside the `<div id="publishing-action">` container. |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @action `gravityview/edit-entry/publishing-action/after` Triggered after the submit buttons in the Edit Entry screen, inside the `<div id="publishing-action">` container. |
| 55 | 55 | * @since 1.5.1 |
| 56 | - * @since 2.0.13 Added $post_id |
|
| 56 | + * @since 2.0.13 Added $post_id |
|
| 57 | 57 | * @param array $form The Gravity Forms form |
| 58 | 58 | * @param array $entry The Gravity Forms entry |
| 59 | 59 | * @param int $view_id The current View ID |
| 60 | - * @param int $post_id The current Post ID |
|
| 60 | + * @param int $post_id The current Post ID |
|
| 61 | 61 | */ |
| 62 | 62 | do_action( 'gravityview/edit-entry/publishing-action/after', $object->form, $object->entry, $object->view_id, $object->post_id ); |
| 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(); |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | |
| 332 | 332 | GFFormsModel::save_lead( $form, $this->entry ); |
| 333 | 333 | |
| 334 | - // Delete the values for hidden inputs |
|
| 335 | - $this->unset_hidden_field_values(); |
|
| 334 | + // Delete the values for hidden inputs |
|
| 335 | + $this->unset_hidden_field_values(); |
|
| 336 | 336 | |
| 337 | 337 | $this->entry['date_created'] = $date_created; |
| 338 | 338 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | // Perform actions normally performed after updating a lead |
| 343 | 343 | $this->after_update(); |
| 344 | 344 | |
| 345 | - /** |
|
| 345 | + /** |
|
| 346 | 346 | * Must be AFTER after_update()! |
| 347 | 347 | * @see https://github.com/gravityview/GravityView/issues/764 |
| 348 | 348 | */ |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | * @return void |
| 373 | 373 | */ |
| 374 | 374 | private function unset_hidden_field_values() { |
| 375 | - global $wpdb; |
|
| 375 | + global $wpdb; |
|
| 376 | 376 | |
| 377 | 377 | /** |
| 378 | 378 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -394,27 +394,27 @@ discard block |
||
| 394 | 394 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
| 397 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
| 398 | 398 | |
| 399 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 399 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 400 | 400 | |
| 401 | - // Reset fields that are hidden |
|
| 402 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 403 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 401 | + // Reset fields that are hidden |
|
| 402 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 403 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 404 | 404 | |
| 405 | - // List fields are stored as empty arrays when empty |
|
| 406 | - $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
| 405 | + // List fields are stored as empty arrays when empty |
|
| 406 | + $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
| 407 | 407 | |
| 408 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 408 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 409 | 409 | |
| 410 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 410 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 411 | 411 | |
| 412 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 412 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 413 | 413 | // after submission |
| 414 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 415 | - $_POST[ $post_input_id ] = ''; |
|
| 416 | - } |
|
| 417 | - } |
|
| 414 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 415 | + $_POST[ $post_input_id ] = ''; |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | $form = $this->form; |
| 510 | 510 | |
| 511 | - /** @var GF_Field $field */ |
|
| 511 | + /** @var GF_Field $field */ |
|
| 512 | 512 | foreach( $form['fields'] as $k => &$field ) { |
| 513 | 513 | |
| 514 | 514 | /** |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | |
| 525 | 525 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
| 526 | 526 | foreach( $field->inputs as $key => $input ) { |
| 527 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 527 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 528 | 528 | } |
| 529 | 529 | } |
| 530 | 530 | } |
@@ -545,13 +545,13 @@ discard block |
||
| 545 | 545 | foreach ( $this->fields_with_calculation as $calc_field ) { |
| 546 | 546 | $inputs = $calc_field->get_entry_inputs(); |
| 547 | 547 | if ( is_array( $inputs ) ) { |
| 548 | - foreach ( $inputs as $input ) { |
|
| 549 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 550 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 551 | - } |
|
| 548 | + foreach ( $inputs as $input ) { |
|
| 549 | + $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 550 | + $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 551 | + } |
|
| 552 | 552 | } else { |
| 553 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 554 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 553 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 554 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
| 600 | 600 | |
| 601 | 601 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 602 | - $ary = stripslashes_deep( $ary ); |
|
| 602 | + $ary = stripslashes_deep( $ary ); |
|
| 603 | 603 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 604 | 604 | |
| 605 | 605 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | private function maybe_update_post_fields( $form ) { |
| 673 | 673 | |
| 674 | 674 | if( empty( $this->entry['post_id'] ) ) { |
| 675 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 675 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 676 | 676 | return; |
| 677 | 677 | } |
| 678 | 678 | |
@@ -707,51 +707,51 @@ discard block |
||
| 707 | 707 | |
| 708 | 708 | switch( $field->type ) { |
| 709 | 709 | |
| 710 | - case 'post_title': |
|
| 711 | - $post_title = $value; |
|
| 712 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 713 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 714 | - } |
|
| 715 | - $updated_post->post_title = $post_title; |
|
| 716 | - $updated_post->post_name = $post_title; |
|
| 717 | - unset( $post_title ); |
|
| 718 | - break; |
|
| 719 | - |
|
| 720 | - case 'post_content': |
|
| 721 | - $post_content = $value; |
|
| 722 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 723 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 724 | - } |
|
| 725 | - $updated_post->post_content = $post_content; |
|
| 726 | - unset( $post_content ); |
|
| 727 | - break; |
|
| 728 | - case 'post_excerpt': |
|
| 729 | - $updated_post->post_excerpt = $value; |
|
| 730 | - break; |
|
| 731 | - case 'post_tags': |
|
| 732 | - wp_set_post_tags( $post_id, $value, false ); |
|
| 733 | - break; |
|
| 734 | - case 'post_category': |
|
| 735 | - break; |
|
| 736 | - case 'post_custom_field': |
|
| 710 | + case 'post_title': |
|
| 711 | + $post_title = $value; |
|
| 712 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 713 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 714 | + } |
|
| 715 | + $updated_post->post_title = $post_title; |
|
| 716 | + $updated_post->post_name = $post_title; |
|
| 717 | + unset( $post_title ); |
|
| 718 | + break; |
|
| 719 | + |
|
| 720 | + case 'post_content': |
|
| 721 | + $post_content = $value; |
|
| 722 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 723 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 724 | + } |
|
| 725 | + $updated_post->post_content = $post_content; |
|
| 726 | + unset( $post_content ); |
|
| 727 | + break; |
|
| 728 | + case 'post_excerpt': |
|
| 729 | + $updated_post->post_excerpt = $value; |
|
| 730 | + break; |
|
| 731 | + case 'post_tags': |
|
| 732 | + wp_set_post_tags( $post_id, $value, false ); |
|
| 733 | + break; |
|
| 734 | + case 'post_category': |
|
| 735 | + break; |
|
| 736 | + case 'post_custom_field': |
|
| 737 | 737 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
| 738 | 738 | $value = $value[ $field_id ]; |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 742 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 743 | - } |
|
| 741 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 742 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | - if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
| 746 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 747 | - } |
|
| 745 | + if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
| 746 | + $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 747 | + } |
|
| 748 | 748 | |
| 749 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 750 | - break; |
|
| 749 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 750 | + break; |
|
| 751 | 751 | |
| 752 | - case 'post_image': |
|
| 753 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 754 | - break; |
|
| 752 | + case 'post_image': |
|
| 753 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 754 | + break; |
|
| 755 | 755 | |
| 756 | 756 | } |
| 757 | 757 | |
@@ -796,20 +796,20 @@ discard block |
||
| 796 | 796 | */ |
| 797 | 797 | private function is_field_json_encoded( $field ) { |
| 798 | 798 | |
| 799 | - $json_encoded = false; |
|
| 799 | + $json_encoded = false; |
|
| 800 | 800 | |
| 801 | 801 | $input_type = RGFormsModel::get_input_type( $field ); |
| 802 | 802 | |
| 803 | - // Only certain custom field types are supported |
|
| 804 | - switch( $input_type ) { |
|
| 805 | - case 'fileupload': |
|
| 806 | - case 'list': |
|
| 807 | - case 'multiselect': |
|
| 808 | - $json_encoded = true; |
|
| 809 | - break; |
|
| 810 | - } |
|
| 803 | + // Only certain custom field types are supported |
|
| 804 | + switch( $input_type ) { |
|
| 805 | + case 'fileupload': |
|
| 806 | + case 'list': |
|
| 807 | + case 'multiselect': |
|
| 808 | + $json_encoded = true; |
|
| 809 | + break; |
|
| 810 | + } |
|
| 811 | 811 | |
| 812 | - return $json_encoded; |
|
| 812 | + return $json_encoded; |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
@@ -899,14 +899,14 @@ discard block |
||
| 899 | 899 | ?><h2 class="gv-edit-entry-title"> |
| 900 | 900 | <span><?php |
| 901 | 901 | |
| 902 | - /** |
|
| 903 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 904 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 905 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 906 | - */ |
|
| 907 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 902 | + /** |
|
| 903 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 904 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 905 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 906 | + */ |
|
| 907 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 908 | 908 | |
| 909 | - echo esc_attr( $edit_entry_title ); |
|
| 909 | + echo esc_attr( $edit_entry_title ); |
|
| 910 | 910 | ?></span> |
| 911 | 911 | </h2> |
| 912 | 912 | |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | |
| 1016 | 1016 | ob_get_clean(); |
| 1017 | 1017 | |
| 1018 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1018 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1019 | 1019 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 1020 | 1020 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1021 | 1021 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | |
| 1070 | 1070 | // for now we don't support Save and Continue feature. |
| 1071 | 1071 | if( ! self::$supports_save_and_continue ) { |
| 1072 | - unset( $form['save'] ); |
|
| 1072 | + unset( $form['save'] ); |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | return $form; |
@@ -1144,7 +1144,7 @@ discard block |
||
| 1144 | 1144 | || ! empty( $field_content ) |
| 1145 | 1145 | || in_array( $field->type, array( 'honeypot' ) ) |
| 1146 | 1146 | ) { |
| 1147 | - return $field_content; |
|
| 1147 | + return $field_content; |
|
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | 1150 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1152,24 +1152,24 @@ discard block |
||
| 1152 | 1152 | |
| 1153 | 1153 | $field_value = $this->get_field_value( $field ); |
| 1154 | 1154 | |
| 1155 | - // Prevent any PHP warnings, like undefined index |
|
| 1156 | - ob_start(); |
|
| 1155 | + // Prevent any PHP warnings, like undefined index |
|
| 1156 | + ob_start(); |
|
| 1157 | 1157 | |
| 1158 | - $return = null; |
|
| 1158 | + $return = null; |
|
| 1159 | 1159 | |
| 1160 | 1160 | /** @var GravityView_Field $gv_field */ |
| 1161 | 1161 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
| 1162 | 1162 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1163 | 1163 | } else { |
| 1164 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1165 | - } |
|
| 1164 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1165 | + } |
|
| 1166 | 1166 | |
| 1167 | - // If there was output, it's an error |
|
| 1168 | - $warnings = ob_get_clean(); |
|
| 1167 | + // If there was output, it's an error |
|
| 1168 | + $warnings = ob_get_clean(); |
|
| 1169 | 1169 | |
| 1170 | - if( !empty( $warnings ) ) { |
|
| 1171 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1172 | - } |
|
| 1170 | + if( !empty( $warnings ) ) { |
|
| 1171 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1172 | + } |
|
| 1173 | 1173 | |
| 1174 | 1174 | return $return; |
| 1175 | 1175 | } |
@@ -1204,8 +1204,8 @@ discard block |
||
| 1204 | 1204 | $input_id = strval( $input['id'] ); |
| 1205 | 1205 | |
| 1206 | 1206 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1207 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1208 | - $allow_pre_populated = false; |
|
| 1207 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1208 | + $allow_pre_populated = false; |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | } |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
| 1230 | 1230 | $categories = array(); |
| 1231 | 1231 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1232 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1232 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1235 | 1235 | } |
@@ -1239,25 +1239,25 @@ discard block |
||
| 1239 | 1239 | // if value is empty get the default value if defined |
| 1240 | 1240 | $field_value = $field->get_value_default_if_empty( $field_value ); |
| 1241 | 1241 | |
| 1242 | - /** |
|
| 1243 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1244 | - * @since 1.11 |
|
| 1245 | - * @since 1.20 Added third param |
|
| 1246 | - * @param mixed $field_value field value used to populate the input |
|
| 1247 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1248 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1249 | - */ |
|
| 1250 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1251 | - |
|
| 1252 | - /** |
|
| 1253 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1254 | - * @since 1.17 |
|
| 1255 | - * @since 1.20 Added third param |
|
| 1256 | - * @param mixed $field_value field value used to populate the input |
|
| 1257 | - * @param GF_Field $field Gravity Forms field object |
|
| 1258 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1259 | - */ |
|
| 1260 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1242 | + /** |
|
| 1243 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1244 | + * @since 1.11 |
|
| 1245 | + * @since 1.20 Added third param |
|
| 1246 | + * @param mixed $field_value field value used to populate the input |
|
| 1247 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1248 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1249 | + */ |
|
| 1250 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1251 | + |
|
| 1252 | + /** |
|
| 1253 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1254 | + * @since 1.17 |
|
| 1255 | + * @since 1.20 Added third param |
|
| 1256 | + * @param mixed $field_value field value used to populate the input |
|
| 1257 | + * @param GF_Field $field Gravity Forms field object |
|
| 1258 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1259 | + */ |
|
| 1260 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1261 | 1261 | |
| 1262 | 1262 | return $field_value; |
| 1263 | 1263 | } |
@@ -1284,7 +1284,7 @@ discard block |
||
| 1284 | 1284 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1285 | 1285 | // expects certain field array items to be set. |
| 1286 | 1286 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
| 1287 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1287 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1288 | 1288 | } |
| 1289 | 1289 | |
| 1290 | 1290 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1298,61 +1298,61 @@ discard block |
||
| 1298 | 1298 | */ |
| 1299 | 1299 | case 'fileupload': |
| 1300 | 1300 | |
| 1301 | - // Set the previous value |
|
| 1302 | - $entry = $this->get_entry(); |
|
| 1301 | + // Set the previous value |
|
| 1302 | + $entry = $this->get_entry(); |
|
| 1303 | 1303 | |
| 1304 | - $input_name = 'input_'.$field->id; |
|
| 1305 | - $form_id = $form['id']; |
|
| 1304 | + $input_name = 'input_'.$field->id; |
|
| 1305 | + $form_id = $form['id']; |
|
| 1306 | 1306 | |
| 1307 | - $value = NULL; |
|
| 1307 | + $value = NULL; |
|
| 1308 | 1308 | |
| 1309 | - // Use the previous entry value as the default. |
|
| 1310 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1311 | - $value = $entry[ $field->id ]; |
|
| 1312 | - } |
|
| 1309 | + // Use the previous entry value as the default. |
|
| 1310 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1311 | + $value = $entry[ $field->id ]; |
|
| 1312 | + } |
|
| 1313 | 1313 | |
| 1314 | - // If this is a single upload file |
|
| 1315 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1316 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1317 | - $value = $file_path['url']; |
|
| 1314 | + // If this is a single upload file |
|
| 1315 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1316 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1317 | + $value = $file_path['url']; |
|
| 1318 | 1318 | |
| 1319 | - } else { |
|
| 1319 | + } else { |
|
| 1320 | 1320 | |
| 1321 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1322 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1323 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1321 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1322 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1323 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1324 | 1324 | |
| 1325 | - } |
|
| 1325 | + } |
|
| 1326 | 1326 | |
| 1327 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1327 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1328 | 1328 | |
| 1329 | - // If there are fresh uploads, process and merge them. |
|
| 1330 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1331 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1332 | - $value = empty( $value ) ? '[]' : $value; |
|
| 1333 | - $value = stripslashes_deep( $value ); |
|
| 1334 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1335 | - } |
|
| 1329 | + // If there are fresh uploads, process and merge them. |
|
| 1330 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1331 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1332 | + $value = empty( $value ) ? '[]' : $value; |
|
| 1333 | + $value = stripslashes_deep( $value ); |
|
| 1334 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1335 | + } |
|
| 1336 | 1336 | |
| 1337 | - } else { |
|
| 1337 | + } else { |
|
| 1338 | 1338 | |
| 1339 | - // A file already exists when editing an entry |
|
| 1340 | - // We set this to solve issue when file upload fields are required. |
|
| 1341 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1339 | + // A file already exists when editing an entry |
|
| 1340 | + // We set this to solve issue when file upload fields are required. |
|
| 1341 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1342 | 1342 | |
| 1343 | - } |
|
| 1343 | + } |
|
| 1344 | 1344 | |
| 1345 | - $this->entry[ $input_name ] = $value; |
|
| 1346 | - $_POST[ $input_name ] = $value; |
|
| 1345 | + $this->entry[ $input_name ] = $value; |
|
| 1346 | + $_POST[ $input_name ] = $value; |
|
| 1347 | 1347 | |
| 1348 | - break; |
|
| 1348 | + break; |
|
| 1349 | 1349 | |
| 1350 | 1350 | case 'number': |
| 1351 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1352 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1353 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1354 | - } |
|
| 1355 | - break; |
|
| 1351 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1352 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1353 | + $_POST['input_'.$field->id ] = NULL; |
|
| 1354 | + } |
|
| 1355 | + break; |
|
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | } |
@@ -1437,42 +1437,42 @@ discard block |
||
| 1437 | 1437 | case 'fileupload' : |
| 1438 | 1438 | case 'post_image': |
| 1439 | 1439 | |
| 1440 | - // in case nothing is uploaded but there are already files saved |
|
| 1441 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1442 | - $field->failed_validation = false; |
|
| 1443 | - unset( $field->validation_message ); |
|
| 1444 | - } |
|
| 1440 | + // in case nothing is uploaded but there are already files saved |
|
| 1441 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1442 | + $field->failed_validation = false; |
|
| 1443 | + unset( $field->validation_message ); |
|
| 1444 | + } |
|
| 1445 | 1445 | |
| 1446 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1447 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1446 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1447 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1448 | 1448 | |
| 1449 | - $input_name = 'input_' . $field->id; |
|
| 1450 | - //uploaded |
|
| 1451 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1449 | + $input_name = 'input_' . $field->id; |
|
| 1450 | + //uploaded |
|
| 1451 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1452 | 1452 | |
| 1453 | - //existent |
|
| 1454 | - $entry = $this->get_entry(); |
|
| 1455 | - $value = NULL; |
|
| 1456 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1457 | - $value = json_decode( $entry[ $field->id ], true ); |
|
| 1458 | - } |
|
| 1453 | + //existent |
|
| 1454 | + $entry = $this->get_entry(); |
|
| 1455 | + $value = NULL; |
|
| 1456 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1457 | + $value = json_decode( $entry[ $field->id ], true ); |
|
| 1458 | + } |
|
| 1459 | 1459 | |
| 1460 | - // count uploaded files and existent entry files |
|
| 1461 | - $count_files = count( $file_names ) + count( $value ); |
|
| 1460 | + // count uploaded files and existent entry files |
|
| 1461 | + $count_files = count( $file_names ) + count( $value ); |
|
| 1462 | 1462 | |
| 1463 | - if( $count_files > $field->maxFiles ) { |
|
| 1464 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1465 | - $field->failed_validation = 1; |
|
| 1466 | - $gv_valid = false; |
|
| 1463 | + if( $count_files > $field->maxFiles ) { |
|
| 1464 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1465 | + $field->failed_validation = 1; |
|
| 1466 | + $gv_valid = false; |
|
| 1467 | 1467 | |
| 1468 | - // in case of error make sure the newest upload files are removed from the upload input |
|
| 1469 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1470 | - } |
|
| 1468 | + // in case of error make sure the newest upload files are removed from the upload input |
|
| 1469 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1470 | + } |
|
| 1471 | 1471 | |
| 1472 | - } |
|
| 1472 | + } |
|
| 1473 | 1473 | |
| 1474 | 1474 | |
| 1475 | - break; |
|
| 1475 | + break; |
|
| 1476 | 1476 | |
| 1477 | 1477 | } |
| 1478 | 1478 | |
@@ -1483,47 +1483,47 @@ discard block |
||
| 1483 | 1483 | |
| 1484 | 1484 | switch ( $field_type ) { |
| 1485 | 1485 | |
| 1486 | - // Captchas don't need to be re-entered. |
|
| 1487 | - case 'captcha': |
|
| 1486 | + // Captchas don't need to be re-entered. |
|
| 1487 | + case 'captcha': |
|
| 1488 | 1488 | |
| 1489 | - // Post Image fields aren't editable, so we un-fail them. |
|
| 1490 | - case 'post_image': |
|
| 1491 | - $field->failed_validation = false; |
|
| 1492 | - unset( $field->validation_message ); |
|
| 1493 | - break; |
|
| 1489 | + // Post Image fields aren't editable, so we un-fail them. |
|
| 1490 | + case 'post_image': |
|
| 1491 | + $field->failed_validation = false; |
|
| 1492 | + unset( $field->validation_message ); |
|
| 1493 | + break; |
|
| 1494 | 1494 | |
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | 1497 | // You can't continue inside a switch, so we do it after. |
| 1498 | 1498 | if( empty( $field->failed_validation ) ) { |
| 1499 | - continue; |
|
| 1499 | + continue; |
|
| 1500 | 1500 | } |
| 1501 | 1501 | |
| 1502 | 1502 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1503 | 1503 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1504 | 1504 | if( !empty( $field->noDuplicates ) ) { |
| 1505 | 1505 | |
| 1506 | - $entry = $this->get_entry(); |
|
| 1506 | + $entry = $this->get_entry(); |
|
| 1507 | 1507 | |
| 1508 | - // If the value of the entry is the same as the stored value |
|
| 1509 | - // Then we can assume it's not a duplicate, it's the same. |
|
| 1510 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1511 | - //if value submitted was not changed, then don't validate |
|
| 1512 | - $field->failed_validation = false; |
|
| 1508 | + // If the value of the entry is the same as the stored value |
|
| 1509 | + // Then we can assume it's not a duplicate, it's the same. |
|
| 1510 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1511 | + //if value submitted was not changed, then don't validate |
|
| 1512 | + $field->failed_validation = false; |
|
| 1513 | 1513 | |
| 1514 | - unset( $field->validation_message ); |
|
| 1514 | + unset( $field->validation_message ); |
|
| 1515 | 1515 | |
| 1516 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1516 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1517 | 1517 | |
| 1518 | - continue; |
|
| 1519 | - } |
|
| 1518 | + continue; |
|
| 1519 | + } |
|
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1523 | 1523 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
| 1524 | - unset( $field->validation_message ); |
|
| 1525 | - $field->validation_message = false; |
|
| 1526 | - continue; |
|
| 1524 | + unset( $field->validation_message ); |
|
| 1525 | + $field->validation_message = false; |
|
| 1526 | + continue; |
|
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | 1529 | $gv_valid = false; |
@@ -1587,8 +1587,8 @@ discard block |
||
| 1587 | 1587 | // Hide fields depending on admin settings |
| 1588 | 1588 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
| 1589 | 1589 | |
| 1590 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1591 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1590 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1591 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1592 | 1592 | |
| 1593 | 1593 | /** |
| 1594 | 1594 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1648,11 +1648,11 @@ discard block |
||
| 1648 | 1648 | // The edit tab has been configured, so we loop through to configured settings |
| 1649 | 1649 | foreach ( $configured_fields as $configured_field ) { |
| 1650 | 1650 | |
| 1651 | - /** @var GF_Field $field */ |
|
| 1652 | - foreach ( $fields as $field ) { |
|
| 1651 | + /** @var GF_Field $field */ |
|
| 1652 | + foreach ( $fields as $field ) { |
|
| 1653 | 1653 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
| 1654 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1655 | - break; |
|
| 1654 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1655 | + break; |
|
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | 1658 | } |
@@ -1708,28 +1708,28 @@ discard block |
||
| 1708 | 1708 | */ |
| 1709 | 1709 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
| 1710 | 1710 | |
| 1711 | - /** |
|
| 1711 | + /** |
|
| 1712 | 1712 | * @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 |
| 1713 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1714 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1715 | - * @since 1.9.1 |
|
| 1716 | - * @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. |
|
| 1717 | - * @param array $form GF Form array |
|
| 1718 | - * @param int $view_id View ID |
|
| 1719 | - */ |
|
| 1720 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1721 | - |
|
| 1722 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1713 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1714 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1715 | + * @since 1.9.1 |
|
| 1716 | + * @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. |
|
| 1717 | + * @param array $form GF Form array |
|
| 1718 | + * @param int $view_id View ID |
|
| 1719 | + */ |
|
| 1720 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1721 | + |
|
| 1722 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1723 | 1723 | foreach( $fields as $k => $field ) { |
| 1724 | 1724 | if( $field->adminOnly ) { |
| 1725 | - unset( $fields[ $k ] ); |
|
| 1725 | + unset( $fields[ $k ] ); |
|
| 1726 | 1726 | } |
| 1727 | 1727 | } |
| 1728 | 1728 | return $fields; |
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | - foreach( $fields as &$field ) { |
|
| 1732 | - $field->adminOnly = false; |
|
| 1731 | + foreach( $fields as &$field ) { |
|
| 1732 | + $field->adminOnly = false; |
|
| 1733 | 1733 | } |
| 1734 | 1734 | |
| 1735 | 1735 | return $fields; |
@@ -1762,36 +1762,36 @@ discard block |
||
| 1762 | 1762 | |
| 1763 | 1763 | if( 'checkbox' === $field->type ) { |
| 1764 | 1764 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1765 | - $input_id = $input['id']; |
|
| 1766 | - $choice = $field->choices[ $key ]; |
|
| 1767 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1768 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1769 | - if( $match ) { |
|
| 1770 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1771 | - } |
|
| 1765 | + $input_id = $input['id']; |
|
| 1766 | + $choice = $field->choices[ $key ]; |
|
| 1767 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1768 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1769 | + if( $match ) { |
|
| 1770 | + $field->choices[ $key ]['isSelected'] = true; |
|
| 1771 | + } |
|
| 1772 | 1772 | } |
| 1773 | 1773 | } else { |
| 1774 | 1774 | |
| 1775 | 1775 | // We need to run through each field to set the default values |
| 1776 | 1776 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1777 | 1777 | |
| 1778 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1778 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1779 | 1779 | |
| 1780 | - if( 'list' === $field->type ) { |
|
| 1781 | - $list_rows = maybe_unserialize( $field_value ); |
|
| 1780 | + if( 'list' === $field->type ) { |
|
| 1781 | + $list_rows = maybe_unserialize( $field_value ); |
|
| 1782 | 1782 | |
| 1783 | - $list_field_value = array(); |
|
| 1784 | - foreach ( (array) $list_rows as $row ) { |
|
| 1785 | - foreach ( (array) $row as $column ) { |
|
| 1786 | - $list_field_value[] = $column; |
|
| 1787 | - } |
|
| 1788 | - } |
|
| 1783 | + $list_field_value = array(); |
|
| 1784 | + foreach ( (array) $list_rows as $row ) { |
|
| 1785 | + foreach ( (array) $row as $column ) { |
|
| 1786 | + $list_field_value[] = $column; |
|
| 1787 | + } |
|
| 1788 | + } |
|
| 1789 | 1789 | |
| 1790 | - $field->defaultValue = serialize( $list_field_value ); |
|
| 1791 | - } else { |
|
| 1792 | - $field->defaultValue = $field_value; |
|
| 1793 | - } |
|
| 1794 | - } |
|
| 1790 | + $field->defaultValue = serialize( $list_field_value ); |
|
| 1791 | + } else { |
|
| 1792 | + $field->defaultValue = $field_value; |
|
| 1793 | + } |
|
| 1794 | + } |
|
| 1795 | 1795 | } |
| 1796 | 1796 | } |
| 1797 | 1797 | } |
@@ -1848,7 +1848,7 @@ discard block |
||
| 1848 | 1848 | return $has_conditional_logic; |
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 1851 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 1852 | 1852 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
| 1853 | 1853 | } |
| 1854 | 1854 | |
@@ -1915,14 +1915,14 @@ discard block |
||
| 1915 | 1915 | |
| 1916 | 1916 | if( $echo && $error !== true ) { |
| 1917 | 1917 | |
| 1918 | - $error = esc_html( $error ); |
|
| 1918 | + $error = esc_html( $error ); |
|
| 1919 | 1919 | |
| 1920 | - /** |
|
| 1921 | - * @since 1.9 |
|
| 1922 | - */ |
|
| 1923 | - if ( ! empty( $this->entry ) ) { |
|
| 1924 | - $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;" ) ); |
|
| 1925 | - } |
|
| 1920 | + /** |
|
| 1921 | + * @since 1.9 |
|
| 1922 | + */ |
|
| 1923 | + if ( ! empty( $this->entry ) ) { |
|
| 1924 | + $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;" ) ); |
|
| 1925 | + } |
|
| 1926 | 1926 | |
| 1927 | 1927 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
| 1928 | 1928 | } |
@@ -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 = $post->ID; |
| 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 | |
@@ -241,13 +241,13 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // Multiple Views embedded, don't proceed if nonce fails |
| 244 | - if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
| 244 | + if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
| 245 | 245 | gravityview()->log->error( 'Nonce validation failed for the Edit Entry request; returning' ); |
| 246 | 246 | return; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | // Sorry, you're not allowed here. |
| 250 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
| 250 | + if ( false === $this->user_can_edit_entry( true ) ) { |
|
| 251 | 251 | gravityview()->log->error( 'User is not allowed to edit this entry; returning', array( 'data' => $this->entry ) ); |
| 252 | 252 | return; |
| 253 | 253 | } |
@@ -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 | |
@@ -284,19 +284,19 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | private function process_save() { |
| 286 | 286 | |
| 287 | - if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 287 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 288 | 288 | return; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // Make sure the entry, view, and form IDs are all correct |
| 292 | 292 | $valid = $this->verify_nonce(); |
| 293 | 293 | |
| 294 | - if( !$valid ) { |
|
| 294 | + if ( ! $valid ) { |
|
| 295 | 295 | gravityview()->log->error( 'Nonce validation failed.' ); |
| 296 | 296 | return; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 299 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 300 | 300 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
| 301 | 301 | return; |
| 302 | 302 | } |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | $this->validate(); |
| 309 | 309 | |
| 310 | - if( $this->is_valid ) { |
|
| 310 | + if ( $this->is_valid ) { |
|
| 311 | 311 | |
| 312 | 312 | gravityview()->log->debug( 'Submission is valid.' ); |
| 313 | 313 | |
@@ -319,22 +319,22 @@ discard block |
||
| 319 | 319 | /** |
| 320 | 320 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 321 | 321 | */ |
| 322 | - unset( $_GET['page'] ); |
|
| 322 | + unset( $_GET[ 'page' ] ); |
|
| 323 | 323 | |
| 324 | - $date_created = $this->entry['date_created']; |
|
| 324 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | 327 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 328 | 328 | * @since 1.17.2 |
| 329 | 329 | */ |
| 330 | - unset( $this->entry['date_created'] ); |
|
| 330 | + unset( $this->entry[ 'date_created' ] ); |
|
| 331 | 331 | |
| 332 | 332 | GFFormsModel::save_lead( $form, $this->entry ); |
| 333 | 333 | |
| 334 | 334 | // Delete the values for hidden inputs |
| 335 | 335 | $this->unset_hidden_field_values(); |
| 336 | 336 | |
| 337 | - $this->entry['date_created'] = $date_created; |
|
| 337 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 338 | 338 | |
| 339 | 339 | // Process calculation fields |
| 340 | 340 | $this->update_calculation_fields(); |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @param string $entry_id Numeric ID of the entry that was updated |
| 355 | 355 | * @param GravityView_Edit_Entry_Render $this This object |
| 356 | 356 | */ |
| 357 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this ); |
|
| 357 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this ); |
|
| 358 | 358 | |
| 359 | 359 | } else { |
| 360 | 360 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -382,16 +382,16 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
| 384 | 384 | |
| 385 | - if( ! $unset_hidden_field_values ) { |
|
| 385 | + if ( ! $unset_hidden_field_values ) { |
|
| 386 | 386 | return; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 390 | 390 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 391 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 391 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 392 | 392 | } else { |
| 393 | 393 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 394 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 394 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** No file is being uploaded. */ |
| 475 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 475 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 476 | 476 | /** So return the original upload */ |
| 477 | 477 | return $entry[ $input_id ]; |
| 478 | 478 | } |
@@ -490,11 +490,11 @@ discard block |
||
| 490 | 490 | * @return mixed |
| 491 | 491 | */ |
| 492 | 492 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 493 | - if( ! $this->is_edit_entry() ) { |
|
| 493 | + if ( ! $this->is_edit_entry() ) { |
|
| 494 | 494 | return $plupload_init; |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 497 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 498 | 498 | |
| 499 | 499 | return $plupload_init; |
| 500 | 500 | } |
@@ -509,22 +509,22 @@ discard block |
||
| 509 | 509 | $form = $this->form; |
| 510 | 510 | |
| 511 | 511 | /** @var GF_Field $field */ |
| 512 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 512 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 513 | 513 | |
| 514 | 514 | /** |
| 515 | 515 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 516 | 516 | * @since 1.16.3 |
| 517 | 517 | * @var GF_Field $field |
| 518 | 518 | */ |
| 519 | - if( $field->has_calculation() ) { |
|
| 520 | - unset( $form['fields'][ $k ] ); |
|
| 519 | + if ( $field->has_calculation() ) { |
|
| 520 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | $field->adminOnly = false; |
| 524 | 524 | |
| 525 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 526 | - foreach( $field->inputs as $key => $input ) { |
|
| 527 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 525 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 526 | + foreach ( $field->inputs as $key => $input ) { |
|
| 527 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 528 | 528 | } |
| 529 | 529 | } |
| 530 | 530 | } |
@@ -538,30 +538,30 @@ discard block |
||
| 538 | 538 | $update = false; |
| 539 | 539 | |
| 540 | 540 | // get the most up to date entry values |
| 541 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 541 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 542 | 542 | |
| 543 | - if( !empty( $this->fields_with_calculation ) ) { |
|
| 543 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
| 544 | 544 | $update = true; |
| 545 | 545 | foreach ( $this->fields_with_calculation as $calc_field ) { |
| 546 | 546 | $inputs = $calc_field->get_entry_inputs(); |
| 547 | 547 | if ( is_array( $inputs ) ) { |
| 548 | 548 | foreach ( $inputs as $input ) { |
| 549 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 550 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 549 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
| 550 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
| 551 | 551 | } |
| 552 | 552 | } else { |
| 553 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 554 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 553 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
| 554 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - if( $update ) { |
|
| 560 | + if ( $update ) { |
|
| 561 | 561 | |
| 562 | 562 | $return_entry = GFAPI::update_entry( $entry ); |
| 563 | 563 | |
| 564 | - if( is_wp_error( $return_entry ) ) { |
|
| 564 | + if ( is_wp_error( $return_entry ) ) { |
|
| 565 | 565 | gravityview()->log->error( 'Updating the entry calculation fields failed', array( 'data' => $return_entry ) ); |
| 566 | 566 | } else { |
| 567 | 567 | gravityview()->log->debug( 'Updating the entry calculation fields succeeded' ); |
@@ -592,19 +592,19 @@ discard block |
||
| 592 | 592 | |
| 593 | 593 | $input_name = 'input_' . $field_id; |
| 594 | 594 | |
| 595 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 595 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 596 | 596 | |
| 597 | 597 | // We have a new image |
| 598 | 598 | |
| 599 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 599 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 600 | 600 | |
| 601 | 601 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 602 | 602 | $ary = stripslashes_deep( $ary ); |
| 603 | 603 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 604 | 604 | |
| 605 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 606 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 607 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 605 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 606 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 607 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 608 | 608 | |
| 609 | 609 | $image_meta = array( |
| 610 | 610 | 'post_excerpt' => $img_caption, |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | |
| 614 | 614 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 615 | 615 | if ( ! empty( $img_title ) ) { |
| 616 | - $image_meta['post_title'] = $img_title; |
|
| 616 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | /** |
@@ -671,15 +671,15 @@ discard block |
||
| 671 | 671 | */ |
| 672 | 672 | private function maybe_update_post_fields( $form ) { |
| 673 | 673 | |
| 674 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 674 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 675 | 675 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
| 676 | 676 | return; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - $post_id = $this->entry['post_id']; |
|
| 679 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 680 | 680 | |
| 681 | 681 | // Security check |
| 682 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 682 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 683 | 683 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
| 684 | 684 | return; |
| 685 | 685 | } |
@@ -692,25 +692,25 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 694 | 694 | |
| 695 | - if( ! $field ) { |
|
| 695 | + if ( ! $field ) { |
|
| 696 | 696 | continue; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 699 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 700 | 700 | |
| 701 | 701 | // Get the value of the field, including $_POSTed value |
| 702 | 702 | $value = RGFormsModel::get_field_value( $field ); |
| 703 | 703 | |
| 704 | 704 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 705 | 705 | $entry_tmp = $this->entry; |
| 706 | - $entry_tmp["{$field_id}"] = $value; |
|
| 706 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 707 | 707 | |
| 708 | - switch( $field->type ) { |
|
| 708 | + switch ( $field->type ) { |
|
| 709 | 709 | |
| 710 | 710 | case 'post_title': |
| 711 | 711 | $post_title = $value; |
| 712 | 712 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
| 713 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 713 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 714 | 714 | } |
| 715 | 715 | $updated_post->post_title = $post_title; |
| 716 | 716 | $updated_post->post_name = $post_title; |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | case 'post_content': |
| 721 | 721 | $post_content = $value; |
| 722 | 722 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
| 723 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 723 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 724 | 724 | } |
| 725 | 725 | $updated_post->post_content = $post_content; |
| 726 | 726 | unset( $post_content ); |
@@ -738,12 +738,12 @@ discard block |
||
| 738 | 738 | $value = $value[ $field_id ]; |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 741 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 742 | 742 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
| 746 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 746 | + $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | // update entry after |
| 759 | - $this->entry["{$field_id}"] = $value; |
|
| 759 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 760 | 760 | |
| 761 | 761 | $update_entry = true; |
| 762 | 762 | |
@@ -765,11 +765,11 @@ discard block |
||
| 765 | 765 | |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | - if( $update_entry ) { |
|
| 768 | + if ( $update_entry ) { |
|
| 769 | 769 | |
| 770 | 770 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 771 | 771 | |
| 772 | - if( is_wp_error( $return_entry ) ) { |
|
| 772 | + if ( is_wp_error( $return_entry ) ) { |
|
| 773 | 773 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
| 774 | 774 | } else { |
| 775 | 775 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | |
| 780 | 780 | $return_post = wp_update_post( $updated_post, true ); |
| 781 | 781 | |
| 782 | - if( is_wp_error( $return_post ) ) { |
|
| 782 | + if ( is_wp_error( $return_post ) ) { |
|
| 783 | 783 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 784 | 784 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
| 785 | 785 | } else { |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | $input_type = RGFormsModel::get_input_type( $field ); |
| 802 | 802 | |
| 803 | 803 | // Only certain custom field types are supported |
| 804 | - switch( $input_type ) { |
|
| 804 | + switch ( $input_type ) { |
|
| 805 | 805 | case 'fileupload': |
| 806 | 806 | case 'list': |
| 807 | 807 | case 'multiselect': |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 839 | 839 | |
| 840 | 840 | // replace conditional shortcodes |
| 841 | - if( $do_shortcode ) { |
|
| 841 | + if ( $do_shortcode ) { |
|
| 842 | 842 | $output = do_shortcode( $output ); |
| 843 | 843 | } |
| 844 | 844 | |
@@ -857,19 +857,19 @@ discard block |
||
| 857 | 857 | */ |
| 858 | 858 | private function after_update() { |
| 859 | 859 | |
| 860 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
| 861 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
| 860 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 861 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 862 | 862 | |
| 863 | 863 | // Re-define the entry now that we've updated it. |
| 864 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 864 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 865 | 865 | |
| 866 | 866 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
| 867 | 867 | |
| 868 | 868 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 869 | 869 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 870 | 870 | // we have just updated. |
| 871 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 872 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 871 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 872 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 873 | 873 | } |
| 874 | 874 | } |
| 875 | 875 | |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | |
| 889 | 889 | <div class="gv-edit-entry-wrapper"><?php |
| 890 | 890 | |
| 891 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 891 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 892 | 892 | |
| 893 | 893 | /** |
| 894 | 894 | * Fixes weird wpautop() issue |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 905 | 905 | * @param GravityView_Edit_Entry_Render $this This object |
| 906 | 906 | */ |
| 907 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 907 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 908 | 908 | |
| 909 | 909 | echo esc_attr( $edit_entry_title ); |
| 910 | 910 | ?></span> |
@@ -954,16 +954,16 @@ discard block |
||
| 954 | 954 | |
| 955 | 955 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
| 956 | 956 | |
| 957 | - if( ! $this->is_valid ){ |
|
| 957 | + if ( ! $this->is_valid ) { |
|
| 958 | 958 | |
| 959 | 959 | // Keeping this compatible with Gravity Forms. |
| 960 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 961 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 960 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 961 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 962 | 962 | |
| 963 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 963 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 964 | 964 | |
| 965 | 965 | } else { |
| 966 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
| 966 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
| 967 | 967 | |
| 968 | 968 | /** |
| 969 | 969 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | * @param array $entry Gravity Forms entry array |
| 974 | 974 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 975 | 975 | */ |
| 976 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 976 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 977 | 977 | |
| 978 | 978 | echo GVCommon::generate_notice( $message ); |
| 979 | 979 | } |
@@ -997,21 +997,21 @@ discard block |
||
| 997 | 997 | */ |
| 998 | 998 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 999 | 999 | |
| 1000 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1001 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 1000 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1001 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1002 | 1002 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1003 | 1003 | |
| 1004 | 1004 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
| 1005 | 1005 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1006 | 1006 | |
| 1007 | 1007 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1008 | - unset( $_GET['page'] ); |
|
| 1008 | + unset( $_GET[ 'page' ] ); |
|
| 1009 | 1009 | |
| 1010 | 1010 | // TODO: Verify multiple-page forms |
| 1011 | 1011 | |
| 1012 | 1012 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1013 | 1013 | |
| 1014 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1014 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1015 | 1015 | |
| 1016 | 1016 | ob_get_clean(); |
| 1017 | 1017 | |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | * @return string |
| 1038 | 1038 | */ |
| 1039 | 1039 | public function render_form_buttons() { |
| 1040 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1040 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | 1043 | |
@@ -1057,10 +1057,10 @@ discard block |
||
| 1057 | 1057 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1058 | 1058 | |
| 1059 | 1059 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1060 | - if( isset( $this->form_after_validation ) ) { |
|
| 1060 | + if ( isset( $this->form_after_validation ) ) { |
|
| 1061 | 1061 | $form = $this->form_after_validation; |
| 1062 | 1062 | } else { |
| 1063 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1063 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | $form = $this->filter_conditional_logic( $form ); |
@@ -1068,8 +1068,8 @@ discard block |
||
| 1068 | 1068 | $form = $this->prefill_conditional_logic( $form ); |
| 1069 | 1069 | |
| 1070 | 1070 | // for now we don't support Save and Continue feature. |
| 1071 | - if( ! self::$supports_save_and_continue ) { |
|
| 1072 | - unset( $form['save'] ); |
|
| 1071 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1072 | + unset( $form[ 'save' ] ); |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | return $form; |
@@ -1090,29 +1090,29 @@ discard block |
||
| 1090 | 1090 | */ |
| 1091 | 1091 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 1092 | 1092 | |
| 1093 | - if( GFCommon::is_post_field( $field ) ) { |
|
| 1093 | + if ( GFCommon::is_post_field( $field ) ) { |
|
| 1094 | 1094 | |
| 1095 | 1095 | $message = null; |
| 1096 | 1096 | |
| 1097 | 1097 | // First, make sure they have the capability to edit the post. |
| 1098 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1098 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1099 | 1099 | |
| 1100 | 1100 | /** |
| 1101 | 1101 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1102 | 1102 | * @param string $message The existing "You don't have permission..." text |
| 1103 | 1103 | */ |
| 1104 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1104 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1105 | 1105 | |
| 1106 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1106 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1107 | 1107 | /** |
| 1108 | 1108 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1109 | 1109 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1110 | 1110 | */ |
| 1111 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1111 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | - if( $message ) { |
|
| 1115 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1114 | + if ( $message ) { |
|
| 1115 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1116 | 1116 | } |
| 1117 | 1117 | } |
| 1118 | 1118 | |
@@ -1137,8 +1137,8 @@ discard block |
||
| 1137 | 1137 | |
| 1138 | 1138 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1139 | 1139 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1140 | - if( |
|
| 1141 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1140 | + if ( |
|
| 1141 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1142 | 1142 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1143 | 1143 | && ! GFCommon::is_product_field( $field->type ) |
| 1144 | 1144 | || ! empty( $field_content ) |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | $return = null; |
| 1159 | 1159 | |
| 1160 | 1160 | /** @var GravityView_Field $gv_field */ |
| 1161 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1161 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1162 | 1162 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1163 | 1163 | } else { |
| 1164 | 1164 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | // If there was output, it's an error |
| 1168 | 1168 | $warnings = ob_get_clean(); |
| 1169 | 1169 | |
| 1170 | - if( !empty( $warnings ) ) { |
|
| 1170 | + if ( ! empty( $warnings ) ) { |
|
| 1171 | 1171 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
| 1172 | 1172 | } |
| 1173 | 1173 | |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1193 | 1193 | |
| 1194 | 1194 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1195 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1195 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1196 | 1196 | |
| 1197 | 1197 | $field_value = array(); |
| 1198 | 1198 | |
@@ -1201,10 +1201,10 @@ discard block |
||
| 1201 | 1201 | |
| 1202 | 1202 | foreach ( (array)$field->inputs as $input ) { |
| 1203 | 1203 | |
| 1204 | - $input_id = strval( $input['id'] ); |
|
| 1204 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1205 | 1205 | |
| 1206 | 1206 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1207 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1207 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1208 | 1208 | $allow_pre_populated = false; |
| 1209 | 1209 | } |
| 1210 | 1210 | |
@@ -1212,7 +1212,7 @@ discard block |
||
| 1212 | 1212 | |
| 1213 | 1213 | $pre_value = $field->get_value_submission( array(), false ); |
| 1214 | 1214 | |
| 1215 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1215 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1216 | 1216 | |
| 1217 | 1217 | } else { |
| 1218 | 1218 | |
@@ -1223,13 +1223,13 @@ discard block |
||
| 1223 | 1223 | |
| 1224 | 1224 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1225 | 1225 | // or pre-populated value if not empty and set to override saved value |
| 1226 | - $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; |
|
| 1226 | + $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; |
|
| 1227 | 1227 | |
| 1228 | 1228 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1229 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1229 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1230 | 1230 | $categories = array(); |
| 1231 | 1231 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1232 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1232 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1235 | 1235 | } |
@@ -1257,7 +1257,7 @@ discard block |
||
| 1257 | 1257 | * @param GF_Field $field Gravity Forms field object |
| 1258 | 1258 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1259 | 1259 | */ |
| 1260 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1260 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1261 | 1261 | |
| 1262 | 1262 | return $field_value; |
| 1263 | 1263 | } |
@@ -1274,12 +1274,12 @@ discard block |
||
| 1274 | 1274 | */ |
| 1275 | 1275 | public function gform_pre_validation( $form ) { |
| 1276 | 1276 | |
| 1277 | - if( ! $this->verify_nonce() ) { |
|
| 1277 | + if ( ! $this->verify_nonce() ) { |
|
| 1278 | 1278 | return $form; |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | // Fix PHP warning regarding undefined index. |
| 1282 | - foreach ( $form['fields'] as &$field) { |
|
| 1282 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1283 | 1283 | |
| 1284 | 1284 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1285 | 1285 | // expects certain field array items to be set. |
@@ -1287,7 +1287,7 @@ discard block |
||
| 1287 | 1287 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1288 | 1288 | } |
| 1289 | 1289 | |
| 1290 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1290 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1291 | 1291 | |
| 1292 | 1292 | /** |
| 1293 | 1293 | * 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. |
@@ -1301,26 +1301,26 @@ discard block |
||
| 1301 | 1301 | // Set the previous value |
| 1302 | 1302 | $entry = $this->get_entry(); |
| 1303 | 1303 | |
| 1304 | - $input_name = 'input_'.$field->id; |
|
| 1305 | - $form_id = $form['id']; |
|
| 1304 | + $input_name = 'input_' . $field->id; |
|
| 1305 | + $form_id = $form[ 'id' ]; |
|
| 1306 | 1306 | |
| 1307 | 1307 | $value = NULL; |
| 1308 | 1308 | |
| 1309 | 1309 | // Use the previous entry value as the default. |
| 1310 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1310 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1311 | 1311 | $value = $entry[ $field->id ]; |
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | 1314 | // If this is a single upload file |
| 1315 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1316 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1317 | - $value = $file_path['url']; |
|
| 1315 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1316 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1317 | + $value = $file_path[ 'url' ]; |
|
| 1318 | 1318 | |
| 1319 | 1319 | } else { |
| 1320 | 1320 | |
| 1321 | 1321 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1322 | 1322 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1323 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1323 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1324 | 1324 | |
| 1325 | 1325 | } |
| 1326 | 1326 | |
@@ -1328,10 +1328,10 @@ discard block |
||
| 1328 | 1328 | |
| 1329 | 1329 | // If there are fresh uploads, process and merge them. |
| 1330 | 1330 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1331 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1331 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1332 | 1332 | $value = empty( $value ) ? '[]' : $value; |
| 1333 | 1333 | $value = stripslashes_deep( $value ); |
| 1334 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1334 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | 1337 | } else { |
@@ -1349,8 +1349,8 @@ discard block |
||
| 1349 | 1349 | |
| 1350 | 1350 | case 'number': |
| 1351 | 1351 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1352 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1353 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1352 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1353 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1354 | 1354 | } |
| 1355 | 1355 | break; |
| 1356 | 1356 | } |
@@ -1387,7 +1387,7 @@ discard block |
||
| 1387 | 1387 | * You can enter whatever you want! |
| 1388 | 1388 | * We try validating, and customize the results using `self::custom_validation()` |
| 1389 | 1389 | */ |
| 1390 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1390 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1391 | 1391 | |
| 1392 | 1392 | // Needed by the validate funtion |
| 1393 | 1393 | $failed_validation_page = NULL; |
@@ -1395,14 +1395,14 @@ discard block |
||
| 1395 | 1395 | |
| 1396 | 1396 | // Prevent entry limit from running when editing an entry, also |
| 1397 | 1397 | // prevent form scheduling from preventing editing |
| 1398 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1398 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1399 | 1399 | |
| 1400 | 1400 | // Hide fields depending on Edit Entry settings |
| 1401 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1401 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1402 | 1402 | |
| 1403 | 1403 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1404 | 1404 | |
| 1405 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1405 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1406 | 1406 | } |
| 1407 | 1407 | |
| 1408 | 1408 | |
@@ -1425,7 +1425,7 @@ discard block |
||
| 1425 | 1425 | |
| 1426 | 1426 | $gv_valid = true; |
| 1427 | 1427 | |
| 1428 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1428 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1429 | 1429 | |
| 1430 | 1430 | $value = RGFormsModel::get_field_value( $field ); |
| 1431 | 1431 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1438,35 +1438,35 @@ discard block |
||
| 1438 | 1438 | case 'post_image': |
| 1439 | 1439 | |
| 1440 | 1440 | // in case nothing is uploaded but there are already files saved |
| 1441 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1441 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1442 | 1442 | $field->failed_validation = false; |
| 1443 | 1443 | unset( $field->validation_message ); |
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | 1446 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1447 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1447 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
| 1448 | 1448 | |
| 1449 | 1449 | $input_name = 'input_' . $field->id; |
| 1450 | 1450 | //uploaded |
| 1451 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1451 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1452 | 1452 | |
| 1453 | 1453 | //existent |
| 1454 | 1454 | $entry = $this->get_entry(); |
| 1455 | 1455 | $value = NULL; |
| 1456 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1456 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1457 | 1457 | $value = json_decode( $entry[ $field->id ], true ); |
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | 1460 | // count uploaded files and existent entry files |
| 1461 | 1461 | $count_files = count( $file_names ) + count( $value ); |
| 1462 | 1462 | |
| 1463 | - if( $count_files > $field->maxFiles ) { |
|
| 1463 | + if ( $count_files > $field->maxFiles ) { |
|
| 1464 | 1464 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1465 | 1465 | $field->failed_validation = 1; |
| 1466 | 1466 | $gv_valid = false; |
| 1467 | 1467 | |
| 1468 | 1468 | // in case of error make sure the newest upload files are removed from the upload input |
| 1469 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1469 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | 1472 | } |
@@ -1477,7 +1477,7 @@ discard block |
||
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | 1479 | // This field has failed validation. |
| 1480 | - if( !empty( $field->failed_validation ) ) { |
|
| 1480 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1481 | 1481 | |
| 1482 | 1482 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
| 1483 | 1483 | |
@@ -1495,19 +1495,19 @@ discard block |
||
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | 1497 | // You can't continue inside a switch, so we do it after. |
| 1498 | - if( empty( $field->failed_validation ) ) { |
|
| 1498 | + if ( empty( $field->failed_validation ) ) { |
|
| 1499 | 1499 | continue; |
| 1500 | 1500 | } |
| 1501 | 1501 | |
| 1502 | 1502 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1503 | 1503 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1504 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1504 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1505 | 1505 | |
| 1506 | 1506 | $entry = $this->get_entry(); |
| 1507 | 1507 | |
| 1508 | 1508 | // If the value of the entry is the same as the stored value |
| 1509 | 1509 | // Then we can assume it's not a duplicate, it's the same. |
| 1510 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1510 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1511 | 1511 | //if value submitted was not changed, then don't validate |
| 1512 | 1512 | $field->failed_validation = false; |
| 1513 | 1513 | |
@@ -1520,7 +1520,7 @@ discard block |
||
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1523 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1523 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1524 | 1524 | unset( $field->validation_message ); |
| 1525 | 1525 | $field->validation_message = false; |
| 1526 | 1526 | continue; |
@@ -1532,12 +1532,12 @@ discard block |
||
| 1532 | 1532 | |
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1535 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1536 | 1536 | |
| 1537 | 1537 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
| 1538 | 1538 | |
| 1539 | 1539 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1540 | - $this->form_after_validation = $validation_results['form']; |
|
| 1540 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1541 | 1541 | |
| 1542 | 1542 | return $validation_results; |
| 1543 | 1543 | } |
@@ -1550,7 +1550,7 @@ discard block |
||
| 1550 | 1550 | */ |
| 1551 | 1551 | public function get_entry() { |
| 1552 | 1552 | |
| 1553 | - if( empty( $this->entry ) ) { |
|
| 1553 | + if ( empty( $this->entry ) ) { |
|
| 1554 | 1554 | // Get the database value of the entry that's being edited |
| 1555 | 1555 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1556 | 1556 | } |
@@ -1582,10 +1582,10 @@ discard block |
||
| 1582 | 1582 | } |
| 1583 | 1583 | |
| 1584 | 1584 | // If edit tab not yet configured, show all fields |
| 1585 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1585 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1586 | 1586 | |
| 1587 | 1587 | // Hide fields depending on admin settings |
| 1588 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1588 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1589 | 1589 | |
| 1590 | 1590 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1591 | 1591 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1617,7 +1617,7 @@ discard block |
||
| 1617 | 1617 | */ |
| 1618 | 1618 | private function filter_fields( $fields, $configured_fields ) { |
| 1619 | 1619 | |
| 1620 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1620 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1621 | 1621 | return $fields; |
| 1622 | 1622 | } |
| 1623 | 1623 | |
@@ -1630,18 +1630,18 @@ discard block |
||
| 1630 | 1630 | |
| 1631 | 1631 | // Remove the fields that have calculation properties and keep them to be used later |
| 1632 | 1632 | // @since 1.16.2 |
| 1633 | - if( $field->has_calculation() ) { |
|
| 1634 | - $this->fields_with_calculation[] = $field; |
|
| 1633 | + if ( $field->has_calculation() ) { |
|
| 1634 | + $this->fields_with_calculation[ ] = $field; |
|
| 1635 | 1635 | // don't remove the calculation fields on form render. |
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1638 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1639 | 1639 | unset( $fields[ $key ] ); |
| 1640 | 1640 | } |
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | 1643 | // The Edit tab has not been configured, so we return all fields by default. |
| 1644 | - if( empty( $configured_fields ) ) { |
|
| 1644 | + if ( empty( $configured_fields ) ) { |
|
| 1645 | 1645 | return $fields; |
| 1646 | 1646 | } |
| 1647 | 1647 | |
@@ -1650,8 +1650,8 @@ discard block |
||
| 1650 | 1650 | |
| 1651 | 1651 | /** @var GF_Field $field */ |
| 1652 | 1652 | foreach ( $fields as $field ) { |
| 1653 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1654 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1653 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1654 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1655 | 1655 | break; |
| 1656 | 1656 | } |
| 1657 | 1657 | |
@@ -1674,14 +1674,14 @@ discard block |
||
| 1674 | 1674 | |
| 1675 | 1675 | $return_field = $field; |
| 1676 | 1676 | |
| 1677 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1677 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1678 | 1678 | $return_field->label = ''; |
| 1679 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1680 | - $return_field->label = $field_setting['custom_label']; |
|
| 1679 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1680 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1681 | 1681 | } |
| 1682 | 1682 | |
| 1683 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1684 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1683 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1684 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1685 | 1685 | } |
| 1686 | 1686 | |
| 1687 | 1687 | /** |
@@ -1719,16 +1719,16 @@ discard block |
||
| 1719 | 1719 | */ |
| 1720 | 1720 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 1721 | 1721 | |
| 1722 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1723 | - foreach( $fields as $k => $field ) { |
|
| 1724 | - if( $field->adminOnly ) { |
|
| 1722 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1723 | + foreach ( $fields as $k => $field ) { |
|
| 1724 | + if ( $field->adminOnly ) { |
|
| 1725 | 1725 | unset( $fields[ $k ] ); |
| 1726 | 1726 | } |
| 1727 | 1727 | } |
| 1728 | 1728 | return $fields; |
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | - foreach( $fields as &$field ) { |
|
| 1731 | + foreach ( $fields as &$field ) { |
|
| 1732 | 1732 | $field->adminOnly = false; |
| 1733 | 1733 | } |
| 1734 | 1734 | |
@@ -1752,22 +1752,22 @@ discard block |
||
| 1752 | 1752 | */ |
| 1753 | 1753 | function prefill_conditional_logic( $form ) { |
| 1754 | 1754 | |
| 1755 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1755 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1756 | 1756 | return $form; |
| 1757 | 1757 | } |
| 1758 | 1758 | |
| 1759 | 1759 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 1760 | 1760 | /** @var GF_Field $field */ |
| 1761 | - foreach ( $form['fields'] as &$field ) { |
|
| 1761 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1762 | 1762 | |
| 1763 | - if( 'checkbox' === $field->type ) { |
|
| 1763 | + if ( 'checkbox' === $field->type ) { |
|
| 1764 | 1764 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1765 | - $input_id = $input['id']; |
|
| 1765 | + $input_id = $input[ 'id' ]; |
|
| 1766 | 1766 | $choice = $field->choices[ $key ]; |
| 1767 | 1767 | $value = \GV\Utils::get( $this->entry, $input_id ); |
| 1768 | 1768 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 1769 | - if( $match ) { |
|
| 1770 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1769 | + if ( $match ) { |
|
| 1770 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 1771 | 1771 | } |
| 1772 | 1772 | } |
| 1773 | 1773 | } else { |
@@ -1775,15 +1775,15 @@ discard block |
||
| 1775 | 1775 | // We need to run through each field to set the default values |
| 1776 | 1776 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1777 | 1777 | |
| 1778 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1778 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1779 | 1779 | |
| 1780 | - if( 'list' === $field->type ) { |
|
| 1780 | + if ( 'list' === $field->type ) { |
|
| 1781 | 1781 | $list_rows = maybe_unserialize( $field_value ); |
| 1782 | 1782 | |
| 1783 | 1783 | $list_field_value = array(); |
| 1784 | - foreach ( (array) $list_rows as $row ) { |
|
| 1785 | - foreach ( (array) $row as $column ) { |
|
| 1786 | - $list_field_value[] = $column; |
|
| 1784 | + foreach ( (array)$list_rows as $row ) { |
|
| 1785 | + foreach ( (array)$row as $column ) { |
|
| 1786 | + $list_field_value[ ] = $column; |
|
| 1787 | 1787 | } |
| 1788 | 1788 | } |
| 1789 | 1789 | |
@@ -1818,16 +1818,16 @@ discard block |
||
| 1818 | 1818 | */ |
| 1819 | 1819 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 1820 | 1820 | |
| 1821 | - if( $use_conditional_logic ) { |
|
| 1821 | + if ( $use_conditional_logic ) { |
|
| 1822 | 1822 | return $form; |
| 1823 | 1823 | } |
| 1824 | 1824 | |
| 1825 | - foreach( $form['fields'] as &$field ) { |
|
| 1825 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1826 | 1826 | /* @var GF_Field $field */ |
| 1827 | 1827 | $field->conditionalLogic = null; |
| 1828 | 1828 | } |
| 1829 | 1829 | |
| 1830 | - unset( $form['button']['conditionalLogic'] ); |
|
| 1830 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 1831 | 1831 | |
| 1832 | 1832 | return $form; |
| 1833 | 1833 | |
@@ -1844,7 +1844,7 @@ discard block |
||
| 1844 | 1844 | */ |
| 1845 | 1845 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 1846 | 1846 | |
| 1847 | - if( ! $this->is_edit_entry() ) { |
|
| 1847 | + if ( ! $this->is_edit_entry() ) { |
|
| 1848 | 1848 | return $has_conditional_logic; |
| 1849 | 1849 | } |
| 1850 | 1850 | |
@@ -1876,44 +1876,44 @@ discard block |
||
| 1876 | 1876 | * 2. There are two entries embedded using oEmbed |
| 1877 | 1877 | * 3. One of the entries has just been saved |
| 1878 | 1878 | */ |
| 1879 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 1879 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 1880 | 1880 | |
| 1881 | 1881 | $error = true; |
| 1882 | 1882 | |
| 1883 | 1883 | } |
| 1884 | 1884 | |
| 1885 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 1885 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 1886 | 1886 | |
| 1887 | 1887 | $error = true; |
| 1888 | 1888 | |
| 1889 | - } elseif( ! $this->verify_nonce() ) { |
|
| 1889 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 1890 | 1890 | |
| 1891 | 1891 | /** |
| 1892 | 1892 | * If the Entry is embedded, there may be two entries on the same page. |
| 1893 | 1893 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 1894 | 1894 | */ |
| 1895 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1895 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1896 | 1896 | $error = true; |
| 1897 | 1897 | } else { |
| 1898 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 1898 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 1899 | 1899 | } |
| 1900 | 1900 | |
| 1901 | 1901 | } |
| 1902 | 1902 | |
| 1903 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1904 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 1903 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1904 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 1905 | 1905 | } |
| 1906 | 1906 | |
| 1907 | - if( $this->entry['status'] === 'trash' ) { |
|
| 1908 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1907 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 1908 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1909 | 1909 | } |
| 1910 | 1910 | |
| 1911 | 1911 | // No errors; everything's fine here! |
| 1912 | - if( empty( $error ) ) { |
|
| 1912 | + if ( empty( $error ) ) { |
|
| 1913 | 1913 | return true; |
| 1914 | 1914 | } |
| 1915 | 1915 | |
| 1916 | - if( $echo && $error !== true ) { |
|
| 1916 | + if ( $echo && $error !== true ) { |
|
| 1917 | 1917 | |
| 1918 | 1918 | $error = esc_html( $error ); |
| 1919 | 1919 | |
@@ -1921,10 +1921,10 @@ discard block |
||
| 1921 | 1921 | * @since 1.9 |
| 1922 | 1922 | */ |
| 1923 | 1923 | if ( ! empty( $this->entry ) ) { |
| 1924 | - $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;" ) ); |
|
| 1924 | + $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;" ) ); |
|
| 1925 | 1925 | } |
| 1926 | 1926 | |
| 1927 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 1927 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 1928 | 1928 | } |
| 1929 | 1929 | |
| 1930 | 1930 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1944,17 +1944,17 @@ discard block |
||
| 1944 | 1944 | |
| 1945 | 1945 | $error = NULL; |
| 1946 | 1946 | |
| 1947 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 1948 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 1947 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 1948 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 1949 | 1949 | } |
| 1950 | 1950 | |
| 1951 | 1951 | // No errors; everything's fine here! |
| 1952 | - if( empty( $error ) ) { |
|
| 1952 | + if ( empty( $error ) ) { |
|
| 1953 | 1953 | return true; |
| 1954 | 1954 | } |
| 1955 | 1955 | |
| 1956 | - if( $echo ) { |
|
| 1957 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 1956 | + if ( $echo ) { |
|
| 1957 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 1958 | 1958 | } |
| 1959 | 1959 | |
| 1960 | 1960 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1975,14 +1975,14 @@ discard block |
||
| 1975 | 1975 | private function check_user_cap_edit_field( $field ) { |
| 1976 | 1976 | |
| 1977 | 1977 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 1978 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 1978 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 1979 | 1979 | return true; |
| 1980 | 1980 | } |
| 1981 | 1981 | |
| 1982 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 1982 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 1983 | 1983 | |
| 1984 | - if( $field_cap ) { |
|
| 1985 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 1984 | + if ( $field_cap ) { |
|
| 1985 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 1986 | 1986 | } |
| 1987 | 1987 | |
| 1988 | 1988 | return false; |
@@ -1996,17 +1996,17 @@ discard block |
||
| 1996 | 1996 | public function verify_nonce() { |
| 1997 | 1997 | |
| 1998 | 1998 | // Verify form submitted for editing single |
| 1999 | - if( $this->is_edit_entry_submission() ) { |
|
| 1999 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2000 | 2000 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2001 | 2001 | } |
| 2002 | 2002 | |
| 2003 | 2003 | // Verify |
| 2004 | - else if( ! $this->is_edit_entry() ) { |
|
| 2004 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2005 | 2005 | $valid = false; |
| 2006 | 2006 | } |
| 2007 | 2007 | |
| 2008 | 2008 | else { |
| 2009 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2009 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2010 | 2010 | } |
| 2011 | 2011 | |
| 2012 | 2012 | /** |