@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @since 2.9.2 |
| 65 | 65 | * |
| 66 | - * @param $component |
|
| 66 | + * @param string $component |
|
| 67 | 67 | */ |
| 68 | 68 | private function load_components( $component ) { |
| 69 | 69 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param array $args Existing reserved args |
| 110 | 110 | * |
| 111 | - * @return array |
|
| 111 | + * @return string[] |
|
| 112 | 112 | */ |
| 113 | 113 | public function add_reserved_arg( $args ) { |
| 114 | 114 | |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | * @uses GFAPI::delete_entry() |
| 441 | 441 | * @uses GFAPI::update_entry_property() |
| 442 | 442 | * |
| 443 | - * @return WP_Error|string "deleted" or "trashed" if successful, WP_Error if GFAPI::delete_entry() or updating entry failed. |
|
| 443 | + * @return string "deleted" or "trashed" if successful, WP_Error if GFAPI::delete_entry() or updating entry failed. |
|
| 444 | 444 | */ |
| 445 | 445 | private function delete_or_trash_entry( $entry ) { |
| 446 | 446 | |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | * |
| 608 | 608 | * @since 1.5.1 |
| 609 | 609 | * @param array $entry Gravity Forms entry array |
| 610 | - * @return boolean|WP_Error True: can edit form. WP_Error: nope. |
|
| 610 | + * @return string True: can edit form. WP_Error: nope. |
|
| 611 | 611 | */ |
| 612 | 612 | function user_can_delete_entry( $entry = array(), $view_id = null ) { |
| 613 | 613 | |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | * |
| 649 | 649 | * @param array $entry Gravity Forms entry array |
| 650 | 650 | * @param array $field Field settings (optional) |
| 651 | - * @param int|\GV\View $view Pass a View ID to check caps against. If not set, check against current View (@deprecated no longer optional) |
|
| 651 | + * @param integer $view Pass a View ID to check caps against. If not set, check against current View (@deprecated no longer optional) |
|
| 652 | 652 | * @return bool |
| 653 | 653 | */ |
| 654 | 654 | public static function check_user_cap_delete_entry( $entry, $field = array(), $view = 0 ) { |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function add_reserved_arg( $args ) { |
| 114 | 114 | |
| 115 | - $args[] = 'delete'; |
|
| 115 | + $args[ ] = 'delete'; |
|
| 116 | 116 | |
| 117 | 117 | return $args; |
| 118 | 118 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | // Index 100 is the default GravityView template path. |
| 184 | 184 | // Index 110 is Edit Entry link |
| 185 | - $file_paths[115] = self::$file; |
|
| 185 | + $file_paths[ 115 ] = self::$file; |
|
| 186 | 186 | |
| 187 | 187 | return $file_paths; |
| 188 | 188 | } |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | $attributes = array( |
| 288 | 288 | 'class' => 'btn btn-sm button button-small alignright pull-right btn-danger gv-button-delete', |
| 289 | - 'tabindex' => ( GFCommon::$tab_index ++ ), |
|
| 289 | + 'tabindex' => ( GFCommon::$tab_index++ ), |
|
| 290 | 290 | 'onclick' => self::get_confirm_dialog(), |
| 291 | 291 | ); |
| 292 | 292 | |
@@ -322,12 +322,12 @@ discard block |
||
| 322 | 322 | ); |
| 323 | 323 | |
| 324 | 324 | // If the form is not submitted, return early |
| 325 | - if ( 'delete' !== $get_fields['action'] || empty( $get_fields['entry_id'] ) ) { |
|
| 325 | + if ( 'delete' !== $get_fields[ 'action' ] || empty( $get_fields[ 'entry_id' ] ) ) { |
|
| 326 | 326 | return; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // Make sure it's a GravityView request |
| 330 | - $valid_nonce_key = wp_verify_nonce( $get_fields['delete'], self::get_nonce_key( $get_fields['entry_id'] ) ); |
|
| 330 | + $valid_nonce_key = wp_verify_nonce( $get_fields[ 'delete' ], self::get_nonce_key( $get_fields[ 'entry_id' ] ) ); |
|
| 331 | 331 | |
| 332 | 332 | if ( ! $valid_nonce_key ) { |
| 333 | 333 | gravityview()->log->debug( 'Delete entry not processed: nonce validation failed.' ); |
@@ -336,10 +336,10 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | // Get the entry slug |
| 339 | - $entry_slug = esc_attr( $get_fields['entry_id'] ); |
|
| 339 | + $entry_slug = esc_attr( $get_fields[ 'entry_id' ] ); |
|
| 340 | 340 | |
| 341 | 341 | // Redirect after deleting the entry. |
| 342 | - $view = \GV\View::by_id( $get_fields['view_id'] ); |
|
| 342 | + $view = \GV\View::by_id( $get_fields[ 'view_id' ] ); |
|
| 343 | 343 | |
| 344 | 344 | // See if there's an entry there |
| 345 | 345 | $entry = gravityview_get_entry( $entry_slug, true, false, $view ); |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | $this->_redirect_and_exit( $delete_redirect_base, $delete_response->get_error_message(), 'error' ); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if ( (int) $view->settings->get( 'delete_redirect' ) === self::REDIRECT_TO_URL_VALUE ) { |
|
| 369 | + if ( (int)$view->settings->get( 'delete_redirect' ) === self::REDIRECT_TO_URL_VALUE ) { |
|
| 370 | 370 | |
| 371 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
| 371 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
| 372 | 372 | $redirect_url_setting = $view->settings->get( 'delete_redirect_url' ); |
| 373 | 373 | $redirect_url = GFCommon::replace_variables( $redirect_url_setting, $form, $entry, false, false, false, 'text' ); |
| 374 | 374 | |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | */ |
| 445 | 445 | private function delete_or_trash_entry( $entry ) { |
| 446 | 446 | |
| 447 | - $entry_id = $entry['id']; |
|
| 447 | + $entry_id = $entry[ 'id' ]; |
|
| 448 | 448 | |
| 449 | 449 | $mode = $this->get_delete_mode(); |
| 450 | 450 | |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | public function process_connected_posts( $entry_id = 0, $entry = array() ) { |
| 509 | 509 | |
| 510 | 510 | // The entry had no connected post |
| 511 | - if ( empty( $entry['post_id'] ) ) { |
|
| 511 | + if ( empty( $entry[ 'post_id' ] ) ) { |
|
| 512 | 512 | return; |
| 513 | 513 | } |
| 514 | 514 | |
@@ -526,9 +526,9 @@ discard block |
||
| 526 | 526 | $action = current_action(); |
| 527 | 527 | |
| 528 | 528 | if ( 'gravityview/delete-entry/deleted' === $action ) { |
| 529 | - $result = wp_delete_post( $entry['post_id'], true ); |
|
| 529 | + $result = wp_delete_post( $entry[ 'post_id' ], true ); |
|
| 530 | 530 | } else { |
| 531 | - $result = wp_trash_post( $entry['post_id'] ); |
|
| 531 | + $result = wp_trash_post( $entry[ 'post_id' ] ); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | if ( false === $result ) { |
@@ -559,13 +559,13 @@ discard block |
||
| 559 | 559 | public function verify_nonce() { |
| 560 | 560 | |
| 561 | 561 | // No delete entry request was made |
| 562 | - if ( empty( $_GET['entry_id'] ) || empty( $_GET['delete'] ) ) { |
|
| 562 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'delete' ] ) ) { |
|
| 563 | 563 | return false; |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
| 566 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
| 567 | 567 | |
| 568 | - $valid = wp_verify_nonce( $_GET['delete'], $nonce_key ); |
|
| 568 | + $valid = wp_verify_nonce( $_GET[ 'delete' ], $nonce_key ); |
|
| 569 | 569 | |
| 570 | 570 | /** |
| 571 | 571 | * @filter `gravityview/delete-entry/verify_nonce` Override Delete Entry nonce validation. Return true to declare nonce valid. |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | $error = __( 'You do not have permission to delete this entry.', 'gravityview' ); |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - if ( $entry['status'] === 'trash' ) { |
|
| 624 | + if ( $entry[ 'status' ] === 'trash' ) { |
|
| 625 | 625 | if ( 'trash' === $this->get_delete_mode() ) { |
| 626 | 626 | $error = __( 'The entry is already in the trash.', 'gravityview' ); |
| 627 | 627 | } else { |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | |
| 666 | 666 | $current_user = wp_get_current_user(); |
| 667 | 667 | |
| 668 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : null; |
|
| 668 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : null; |
|
| 669 | 669 | |
| 670 | 670 | // Or if they can delete any entries (as defined in Gravity Forms), we're good. |
| 671 | 671 | if ( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { |
@@ -679,17 +679,17 @@ discard block |
||
| 679 | 679 | if ( ! empty( $field ) ) { |
| 680 | 680 | |
| 681 | 681 | // If capability is not defined, something is not right! |
| 682 | - if ( empty( $field['allow_edit_cap'] ) ) { |
|
| 682 | + if ( empty( $field[ 'allow_edit_cap' ] ) ) { |
|
| 683 | 683 | |
| 684 | 684 | gravityview()->log->error( 'Cannot read delete entry field caps', array( 'data' => $field ) ); |
| 685 | 685 | |
| 686 | 686 | return false; |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - if ( GVCommon::has_cap( $field['allow_edit_cap'] ) ) { |
|
| 689 | + if ( GVCommon::has_cap( $field[ 'allow_edit_cap' ] ) ) { |
|
| 690 | 690 | |
| 691 | 691 | // Do not return true if cap is read, as we need to check if the current user created the entry |
| 692 | - if ( $field['allow_edit_cap'] !== 'read' ) { |
|
| 692 | + if ( $field[ 'allow_edit_cap' ] !== 'read' ) { |
|
| 693 | 693 | return true; |
| 694 | 694 | } |
| 695 | 695 | } else { |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | } |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | - if ( ! isset( $entry['created_by'] ) ) { |
|
| 703 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
| 704 | 704 | |
| 705 | 705 | gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
| 706 | 706 | |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | // If the logged-in user is the same as the user who created the entry, we're good. |
| 719 | - if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 719 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
| 720 | 720 | |
| 721 | 721 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) ); |
| 722 | 722 | |
@@ -741,12 +741,12 @@ discard block |
||
| 741 | 741 | */ |
| 742 | 742 | public function maybe_display_message( $current_view_id = 0 ) { |
| 743 | 743 | |
| 744 | - if ( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
| 744 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
| 745 | 745 | return; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | // Entry wasn't deleted from current View |
| 749 | - if ( isset( $_GET['view_id'] ) && intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) { |
|
| 749 | + if ( isset( $_GET[ 'view_id' ] ) && intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) { |
|
| 750 | 750 | return; |
| 751 | 751 | } |
| 752 | 752 | |
@@ -755,11 +755,11 @@ discard block |
||
| 755 | 755 | |
| 756 | 756 | public function display_message() { |
| 757 | 757 | |
| 758 | - if ( empty( $_GET['status'] ) || empty( $_GET['delete'] ) ) { |
|
| 758 | + if ( empty( $_GET[ 'status' ] ) || empty( $_GET[ 'delete' ] ) ) { |
|
| 759 | 759 | return; |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - $status = esc_attr( $_GET['status'] ); |
|
| 762 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
| 763 | 763 | $message_from_url = \GV\Utils::_GET( 'message' ); |
| 764 | 764 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) ); |
| 765 | 765 | $class = ''; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @param array $args Existing reserved args |
| 81 | 81 | * |
| 82 | - * @return array |
|
| 82 | + * @return string[] |
|
| 83 | 83 | */ |
| 84 | 84 | public function add_reserved_arg( $args ) { |
| 85 | 85 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @param array $fields Array of field types not editable by users |
| 153 | 153 | * |
| 154 | - * @return array |
|
| 154 | + * @return string[] |
|
| 155 | 155 | */ |
| 156 | 156 | public function _filter_sortable_fields( $fields ) { |
| 157 | 157 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * |
| 170 | 170 | * @param array $file_paths List of template paths ordered |
| 171 | 171 | * |
| 172 | - * @return array File paths, with duplicate field path added at index 117 |
|
| 172 | + * @return string[] File paths, with duplicate field path added at index 117 |
|
| 173 | 173 | */ |
| 174 | 174 | public function add_template_path( $file_paths ) { |
| 175 | 175 | |
@@ -275,7 +275,6 @@ discard block |
||
| 275 | 275 | * @since 2.5 |
| 276 | 276 | * |
| 277 | 277 | * @param array $visibility_caps Array of capabilities to display in field dropdown. |
| 278 | - * @param string $field_type Type of field options to render (`field` or `widget`) |
|
| 279 | 278 | * @param string $template_id Table slug |
| 280 | 279 | * @param float|string $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` |
| 281 | 280 | * @param string $context What context are we in? Example: `single` or `directory` |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function add_reserved_arg( $args ) { |
| 85 | 85 | |
| 86 | - $args[] = 'duplicate'; |
|
| 86 | + $args[ ] = 'duplicate'; |
|
| 87 | 87 | |
| 88 | 88 | return $args; |
| 89 | 89 | } |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function _filter_sortable_fields( $fields ) { |
| 157 | 157 | |
| 158 | - $fields = (array) $fields; |
|
| 158 | + $fields = (array)$fields; |
|
| 159 | 159 | |
| 160 | - $fields[] = 'duplicate_link'; |
|
| 160 | + $fields[ ] = 'duplicate_link'; |
|
| 161 | 161 | |
| 162 | 162 | return $fields; |
| 163 | 163 | } |
@@ -196,12 +196,12 @@ discard block |
||
| 196 | 196 | public function duplicate_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 197 | 197 | |
| 198 | 198 | // Always a link, never a filter, always same window |
| 199 | - unset( $field_options['show_as_link'], $field_options['search_filter'], $field_options['new_window'] ); |
|
| 199 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ], $field_options[ 'new_window' ] ); |
|
| 200 | 200 | |
| 201 | 201 | // Duplicate Entry link should only appear to visitors capable of editing entries |
| 202 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
| 202 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
| 203 | 203 | |
| 204 | - $add_option['duplicate_link'] = array( |
|
| 204 | + $add_option[ 'duplicate_link' ] = array( |
|
| 205 | 205 | 'type' => 'text', |
| 206 | 206 | 'label' => __( 'Duplicate Link Text', 'gravityview' ), |
| 207 | 207 | 'desc' => NULL, |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | 'merge_tags' => true, |
| 210 | 210 | ); |
| 211 | 211 | |
| 212 | - $field_options['allow_duplicate_cap'] = array( |
|
| 212 | + $field_options[ 'allow_duplicate_cap' ] = array( |
|
| 213 | 213 | 'type' => 'select', |
| 214 | 214 | 'label' => __( 'Allow the following users to duplicate the entry:', 'gravityview' ), |
| 215 | 215 | 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | public function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
| 237 | 237 | |
| 238 | 238 | if ( 'edit' !== $zone ) { |
| 239 | - $entry_default_fields['duplicate_link'] = array( |
|
| 239 | + $entry_default_fields[ 'duplicate_link' ] = array( |
|
| 240 | 240 | 'label' => __( 'Duplicate Entry', 'gravityview' ), |
| 241 | 241 | 'type' => 'duplicate_link', |
| 242 | 242 | 'desc' => __( 'A link to duplicate the entry. Respects the Duplicate Entry permissions.', 'gravityview' ), |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public function add_available_field( $available_fields = array() ) { |
| 260 | 260 | |
| 261 | - $available_fields['duplicate_link'] = array( |
|
| 261 | + $available_fields[ 'duplicate_link' ] = array( |
|
| 262 | 262 | 'label_text' => __( 'Duplicate Entry', 'gravityview' ), |
| 263 | 263 | 'field_id' => 'duplicate_link', |
| 264 | 264 | 'label_type' => 'field', |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | if ( 'duplicate_link' === $field_id ) { |
| 292 | 292 | |
| 293 | 293 | // Remove other built-in caps. |
| 294 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['duplicate_others_posts'] ); |
|
| 294 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'duplicate_others_posts' ] ); |
|
| 295 | 295 | |
| 296 | - $caps['read'] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
| 296 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | return $caps; |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | */ |
| 329 | 329 | public static function get_duplicate_link( $entry, $view_id, $post_id = null ) { |
| 330 | 330 | |
| 331 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
| 331 | + $base = GravityView_API::directory_link( $post_id ?: $view_id, true ); |
|
| 332 | 332 | |
| 333 | 333 | if ( empty( $base ) ) { |
| 334 | 334 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -337,12 +337,12 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | $actionurl = add_query_arg( array( |
| 339 | 339 | 'action' => 'duplicate', |
| 340 | - 'entry_id' => $entry['id'], |
|
| 340 | + 'entry_id' => $entry[ 'id' ], |
|
| 341 | 341 | 'gvid' => $view_id, |
| 342 | 342 | 'view_id' => $view_id, |
| 343 | 343 | ), $base ); |
| 344 | 344 | |
| 345 | - return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry['id'] ) ), $actionurl ); |
|
| 345 | + return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry[ 'id' ] ) ), $actionurl ); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
@@ -363,12 +363,12 @@ discard block |
||
| 363 | 363 | public function process_duplicate() { |
| 364 | 364 | |
| 365 | 365 | // If the form is submitted |
| 366 | - if ( ( ! isset( $_GET['action'] ) ) || 'duplicate' !== $_GET['action'] || ( ! isset( $_GET['entry_id'] ) ) ) { |
|
| 366 | + if ( ( ! isset( $_GET[ 'action' ] ) ) || 'duplicate' !== $_GET[ 'action' ] || ( ! isset( $_GET[ 'entry_id' ] ) ) ) { |
|
| 367 | 367 | return; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | // Make sure it's a GravityView request |
| 371 | - $valid_nonce_key = wp_verify_nonce( \GV\Utils::_GET( 'duplicate' ), self::get_nonce_key( $_GET['entry_id'] ) ); |
|
| 371 | + $valid_nonce_key = wp_verify_nonce( \GV\Utils::_GET( 'duplicate' ), self::get_nonce_key( $_GET[ 'entry_id' ] ) ); |
|
| 372 | 372 | |
| 373 | 373 | if ( ! $valid_nonce_key ) { |
| 374 | 374 | gravityview()->log->debug( 'Duplicate entry not processed: nonce validation failed.' ); |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | // Get the entry slug |
| 379 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
| 379 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] ); |
|
| 380 | 380 | |
| 381 | 381 | // See if there's an entry there |
| 382 | 382 | $entry = gravityview_get_entry( $entry_slug, true, false ); |
@@ -470,17 +470,17 @@ discard block |
||
| 470 | 470 | return new WP_Error( 'gravityview-duplicate-entry-missing', __( 'The entry does not exist.', 'gravityview' ) ); |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
| 473 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
| 474 | 474 | |
| 475 | - $row['id'] = null; |
|
| 476 | - $row['date_created'] = date( 'Y-m-d H:i:s', time() ); |
|
| 477 | - $row['date_updated'] = $row['date_created']; |
|
| 478 | - $row['is_starred'] = false; |
|
| 479 | - $row['is_read'] = false; |
|
| 480 | - $row['ip'] = rgars( $form, 'personalData/preventIP' ) ? '' : GFFormsModel::get_ip(); |
|
| 481 | - $row['source_url'] = esc_url_raw( remove_query_arg( array( 'action', 'gvid', 'result', 'duplicate', 'entry_id' ) ) ); |
|
| 482 | - $row['user_agent'] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
| 483 | - $row['created_by'] = wp_get_current_user()->ID; |
|
| 475 | + $row[ 'id' ] = null; |
|
| 476 | + $row[ 'date_created' ] = date( 'Y-m-d H:i:s', time() ); |
|
| 477 | + $row[ 'date_updated' ] = $row[ 'date_created' ]; |
|
| 478 | + $row[ 'is_starred' ] = false; |
|
| 479 | + $row[ 'is_read' ] = false; |
|
| 480 | + $row[ 'ip' ] = rgars( $form, 'personalData/preventIP' ) ? '' : GFFormsModel::get_ip(); |
|
| 481 | + $row[ 'source_url' ] = esc_url_raw( remove_query_arg( array( 'action', 'gvid', 'result', 'duplicate', 'entry_id' ) ) ); |
|
| 482 | + $row[ 'user_agent' ] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
| 483 | + $row[ 'created_by' ] = wp_get_current_user()->ID; |
|
| 484 | 484 | |
| 485 | 485 | /** |
| 486 | 486 | * @filter `gravityview/entry/duplicate/details` Modify the new entry details before it's created. |
@@ -508,15 +508,15 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | $save_this_meta = array(); |
| 510 | 510 | foreach ( $duplicate_meta->get_output() as $m ) { |
| 511 | - $save_this_meta[] = array( |
|
| 512 | - 'meta_key' => $m['meta_key'], |
|
| 513 | - 'meta_value' => $m['meta_value'], |
|
| 514 | - 'item_index' => $m['item_index'], |
|
| 511 | + $save_this_meta[ ] = array( |
|
| 512 | + 'meta_key' => $m[ 'meta_key' ], |
|
| 513 | + 'meta_value' => $m[ 'meta_value' ], |
|
| 514 | + 'item_index' => $m[ 'item_index' ], |
|
| 515 | 515 | ); |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | // Update the row ID for later usage |
| 519 | - $row['id'] = $duplicated_id; |
|
| 519 | + $row[ 'id' ] = $duplicated_id; |
|
| 520 | 520 | |
| 521 | 521 | /** |
| 522 | 522 | * @filter `gravityview/entry/duplicate/meta` Modify the new entry meta details. |
@@ -527,8 +527,8 @@ discard block |
||
| 527 | 527 | $save_this_meta = apply_filters( 'gravityview/entry/duplicate/meta', $save_this_meta, $row, $entry ); |
| 528 | 528 | |
| 529 | 529 | foreach ( $save_this_meta as $data ) { |
| 530 | - $data['form_id'] = $entry['form_id']; |
|
| 531 | - $data['entry_id'] = $duplicated_id; |
|
| 530 | + $data[ 'form_id' ] = $entry[ 'form_id' ]; |
|
| 531 | + $data[ 'entry_id' ] = $duplicated_id; |
|
| 532 | 532 | |
| 533 | 533 | if ( ! $wpdb->insert( $entry_meta_table, $data ) ) { |
| 534 | 534 | return new WP_Error( 'gravityview-duplicate-entry-db-meta', __( 'There was an error duplicating the entry.', 'gravityview' ) ); |
@@ -562,13 +562,13 @@ discard block |
||
| 562 | 562 | public function verify_nonce() { |
| 563 | 563 | |
| 564 | 564 | // No duplicate entry request was made |
| 565 | - if ( empty( $_GET['entry_id'] ) || empty( $_GET['duplicate'] ) ) { |
|
| 565 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'duplicate' ] ) ) { |
|
| 566 | 566 | return false; |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
| 569 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
| 570 | 570 | |
| 571 | - $valid = wp_verify_nonce( $_GET['duplicate'], $nonce_key ); |
|
| 571 | + $valid = wp_verify_nonce( $_GET[ 'duplicate' ], $nonce_key ); |
|
| 572 | 572 | |
| 573 | 573 | /** |
| 574 | 574 | * @filter `gravityview/duplicate-entry/verify_nonce` Override Duplicate Entry nonce validation. Return true to declare nonce valid. |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | return ''; |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
| 607 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');'; |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | /** |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | public static function check_user_cap_duplicate_entry( $entry, $field = array(), $view_id = 0 ) { |
| 659 | 659 | $current_user = wp_get_current_user(); |
| 660 | 660 | |
| 661 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : null; |
|
| 661 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : null; |
|
| 662 | 662 | |
| 663 | 663 | // Or if they can duplicate any entries (as defined in Gravity Forms), we're good. |
| 664 | 664 | if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gform_full_access', 'gravityview_full_access' ), $entry_id ) ) { |
@@ -673,17 +673,17 @@ discard block |
||
| 673 | 673 | if ( ! empty( $field ) ) { |
| 674 | 674 | |
| 675 | 675 | // If capability is not defined, something is not right! |
| 676 | - if ( empty( $field['allow_duplicate_cap'] ) ) { |
|
| 676 | + if ( empty( $field[ 'allow_duplicate_cap' ] ) ) { |
|
| 677 | 677 | |
| 678 | 678 | gravityview()->log->error( 'Cannot read duplicate entry field caps', array( 'data' => $field ) ); |
| 679 | 679 | |
| 680 | 680 | return false; |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - if ( GVCommon::has_cap( $field['allow_duplicate_cap'] ) ) { |
|
| 683 | + if ( GVCommon::has_cap( $field[ 'allow_duplicate_cap' ] ) ) { |
|
| 684 | 684 | |
| 685 | 685 | // Do not return true if cap is read, as we need to check if the current user created the entry |
| 686 | - if ( 'read' !== $field['allow_duplicate_cap'] ) { |
|
| 686 | + if ( 'read' !== $field[ 'allow_duplicate_cap' ] ) { |
|
| 687 | 687 | return true; |
| 688 | 688 | } |
| 689 | 689 | |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - if ( ! isset( $entry['created_by'] ) ) { |
|
| 699 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
| 700 | 700 | |
| 701 | 701 | gravityview()->log->error( 'Cannot duplicate entry; entry `created_by` doesn\'t exist.' ); |
| 702 | 702 | |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | // If the logged-in user is the same as the user who created the entry, we're good. |
| 724 | - if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 724 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
| 725 | 725 | |
| 726 | 726 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) ); |
| 727 | 727 | |
@@ -745,12 +745,12 @@ discard block |
||
| 745 | 745 | * @return void |
| 746 | 746 | */ |
| 747 | 747 | public function maybe_display_message( $current_view_id = 0 ) { |
| 748 | - if ( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
| 748 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
| 749 | 749 | return; |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | // Entry wasn't duplicated from current View |
| 753 | - if ( isset( $_GET['view_id'] ) && ( intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) ) { |
|
| 753 | + if ( isset( $_GET[ 'view_id' ] ) && ( intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) ) { |
|
| 754 | 754 | return; |
| 755 | 755 | } |
| 756 | 756 | |
@@ -758,11 +758,11 @@ discard block |
||
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | public function display_message() { |
| 761 | - if ( empty( $_GET['status'] ) || empty( $_GET['duplicate'] ) ) { |
|
| 761 | + if ( empty( $_GET[ 'status' ] ) || empty( $_GET[ 'duplicate' ] ) ) { |
|
| 762 | 762 | return; |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - $status = esc_attr( $_GET['status'] ); |
|
| 765 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
| 766 | 766 | $message_from_url = \GV\Utils::_GET( 'message' ); |
| 767 | 767 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) ); |
| 768 | 768 | $class = ''; |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | $message = apply_filters( 'gravityview/duplicate-entry/message', esc_attr( $message ), $status, $message_from_url ); |
| 789 | 789 | |
| 790 | 790 | // DISPLAY ERROR/SUCCESS MESSAGE |
| 791 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
| 791 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>'; |
|
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | /** |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | ?> |
| 819 | 819 | <span class="gv-duplicate"> |
| 820 | 820 | | |
| 821 | - <a href="<?php echo wp_nonce_url( add_query_arg( 'entry_id', $entry['id'] ), self::get_nonce_key( $entry['id'] ), 'duplicate' ); ?>"><?php esc_html_e( 'Duplicate', 'gravityview' ); ?></a> |
|
| 821 | + <a href="<?php echo wp_nonce_url( add_query_arg( 'entry_id', $entry[ 'id' ] ), self::get_nonce_key( $entry[ 'id' ] ), 'duplicate' ); ?>"><?php esc_html_e( 'Duplicate', 'gravityview' ); ?></a> |
|
| 822 | 822 | </span> |
| 823 | 823 | <?php |
| 824 | 824 | } |
@@ -840,9 +840,9 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | if ( 'success' === \GV\Utils::_GET( 'result' ) ) { |
| 842 | 842 | add_filter( 'gform_admin_messages', function( $messages ) { |
| 843 | - $messages = (array) $messages; |
|
| 843 | + $messages = (array)$messages; |
|
| 844 | 844 | |
| 845 | - $messages[] = esc_html__( 'Entry duplicated.', 'gravityview' ); |
|
| 845 | + $messages[ ] = esc_html__( 'Entry duplicated.', 'gravityview' ); |
|
| 846 | 846 | return $messages; |
| 847 | 847 | } ); |
| 848 | 848 | } |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | |
| 854 | 854 | $check_logs_message = ''; |
| 855 | 855 | |
| 856 | - if( $is_logging_active ) { |
|
| 856 | + if ( $is_logging_active ) { |
|
| 857 | 857 | $check_logs_message = sprintf( ' <a href="%s">%s</a>', |
| 858 | 858 | esc_url( admin_url( 'admin.php?page=gf_settings&subview=gravityformslogging' ) ), |
| 859 | 859 | esc_html_x( 'Check the GravityView logs for more information.', 'Error message links to logging page', 'gravityview' ) |
@@ -861,9 +861,9 @@ discard block |
||
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | add_filter( 'gform_admin_error_messages', function( $messages ) use ( $check_logs_message ) { |
| 864 | - $messages = (array) $messages; |
|
| 864 | + $messages = (array)$messages; |
|
| 865 | 865 | |
| 866 | - $messages[] = esc_html__( 'There was an error duplicating the entry.', 'gravityview' ) . $check_logs_message; |
|
| 866 | + $messages[ ] = esc_html__( 'There was an error duplicating the entry.', 'gravityview' ) . $check_logs_message; |
|
| 867 | 867 | |
| 868 | 868 | return $messages; |
| 869 | 869 | } ); |
@@ -64,6 +64,9 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | |
| 67 | + /** |
|
| 68 | + * @param string $component |
|
| 69 | + */ |
|
| 67 | 70 | private function load_components( $component ) { |
| 68 | 71 | |
| 69 | 72 | $dir = trailingslashit( self::$file ); |
@@ -104,7 +107,7 @@ discard block |
||
| 104 | 107 | * |
| 105 | 108 | * @param array $args Existing reserved args |
| 106 | 109 | * |
| 107 | - * @return array |
|
| 110 | + * @return string[] |
|
| 108 | 111 | */ |
| 109 | 112 | public function add_reserved_arg( $args ) { |
| 110 | 113 | |
@@ -200,7 +203,7 @@ discard block |
||
| 200 | 203 | * "You can edit this post from the post page" fields, for example. |
| 201 | 204 | * |
| 202 | 205 | * @param $entry array Gravity Forms entry object |
| 203 | - * @param $view_id int GravityView view id |
|
| 206 | + * @param integer $view_id int GravityView view id |
|
| 204 | 207 | * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
| 205 | 208 | * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
| 206 | 209 | * @return string |
@@ -303,7 +306,7 @@ discard block |
||
| 303 | 306 | * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
| 304 | 307 | * |
| 305 | 308 | * @param array $entry Gravity Forms entry array |
| 306 | - * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
| 309 | + * @param integer $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
| 307 | 310 | * @return bool |
| 308 | 311 | */ |
| 309 | 312 | public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
@@ -18,84 +18,84 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | class GravityView_Edit_Entry { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 21 | + /** |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | 24 | static $file; |
| 25 | 25 | |
| 26 | 26 | static $instance; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Component instances. |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 32 | - public $instances = array(); |
|
| 28 | + /** |
|
| 29 | + * Component instances. |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | + public $instances = array(); |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | function __construct() { |
| 36 | 36 | |
| 37 | - self::$file = plugin_dir_path( __FILE__ ); |
|
| 37 | + self::$file = plugin_dir_path( __FILE__ ); |
|
| 38 | 38 | |
| 39 | - if( is_admin() ) { |
|
| 40 | - $this->load_components( 'admin' ); |
|
| 41 | - } |
|
| 39 | + if( is_admin() ) { |
|
| 40 | + $this->load_components( 'admin' ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | $this->load_components( 'locking' ); |
| 44 | 44 | |
| 45 | - $this->load_components( 'render' ); |
|
| 45 | + $this->load_components( 'render' ); |
|
| 46 | 46 | |
| 47 | - // If GF User Registration Add-on exists |
|
| 48 | - $this->load_components( 'user-registration' ); |
|
| 47 | + // If GF User Registration Add-on exists |
|
| 48 | + $this->load_components( 'user-registration' ); |
|
| 49 | 49 | |
| 50 | - $this->add_hooks(); |
|
| 50 | + $this->add_hooks(); |
|
| 51 | 51 | |
| 52 | 52 | // Process hooks for addons that may or may not be present |
| 53 | 53 | $this->addon_specific_hooks(); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - static function getInstance() { |
|
| 57 | + static function getInstance() { |
|
| 58 | 58 | |
| 59 | - if( empty( self::$instance ) ) { |
|
| 60 | - self::$instance = new GravityView_Edit_Entry; |
|
| 61 | - } |
|
| 59 | + if( empty( self::$instance ) ) { |
|
| 60 | + self::$instance = new GravityView_Edit_Entry; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return self::$instance; |
|
| 64 | - } |
|
| 63 | + return self::$instance; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | - private function load_components( $component ) { |
|
| 67 | + private function load_components( $component ) { |
|
| 68 | 68 | |
| 69 | - $dir = trailingslashit( self::$file ); |
|
| 69 | + $dir = trailingslashit( self::$file ); |
|
| 70 | 70 | |
| 71 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
| 72 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
| 71 | + $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
| 72 | + $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
| 73 | 73 | |
| 74 | - // Loads component and pass extension's instance so that component can |
|
| 75 | - // talk each other. |
|
| 76 | - require_once $filename; |
|
| 77 | - $this->instances[ $component ] = new $classname( $this ); |
|
| 78 | - $this->instances[ $component ]->load(); |
|
| 74 | + // Loads component and pass extension's instance so that component can |
|
| 75 | + // talk each other. |
|
| 76 | + require_once $filename; |
|
| 77 | + $this->instances[ $component ] = new $classname( $this ); |
|
| 78 | + $this->instances[ $component ]->load(); |
|
| 79 | 79 | |
| 80 | - } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - private function add_hooks() { |
|
| 82 | + private function add_hooks() { |
|
| 83 | 83 | |
| 84 | - // Add front-end access to Gravity Forms delete file action |
|
| 85 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 84 | + // Add front-end access to Gravity Forms delete file action |
|
| 85 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 86 | 86 | |
| 87 | - // Make sure this hook is run for non-admins |
|
| 88 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 87 | + // Make sure this hook is run for non-admins |
|
| 88 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 89 | 89 | |
| 90 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
| 90 | + add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
| 91 | 91 | |
| 92 | - // add template path to check for field |
|
| 93 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
| 92 | + // add template path to check for field |
|
| 93 | + add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
| 94 | 94 | |
| 95 | 95 | add_filter( 'gravityview/field/is_visible', array( $this, 'maybe_not_visible' ), 10, 3 ); |
| 96 | 96 | |
| 97 | 97 | add_filter( 'gravityview/api/reserved_query_args', array( $this, 'add_reserved_arg' ) ); |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Adds "edit" to the list of internal reserved query args |
@@ -166,74 +166,74 @@ discard block |
||
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - /** |
|
| 170 | - * Include this extension templates path |
|
| 171 | - * @param array $file_paths List of template paths ordered |
|
| 172 | - */ |
|
| 173 | - public function add_template_path( $file_paths ) { |
|
| 174 | - |
|
| 175 | - // Index 100 is the default GravityView template path. |
|
| 176 | - $file_paths[ 110 ] = self::$file; |
|
| 177 | - |
|
| 178 | - return $file_paths; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * |
|
| 183 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
| 184 | - * |
|
| 185 | - * @param $view_id int GravityView view id |
|
| 186 | - * @param $form_id int Gravity Forms form id |
|
| 187 | - * @param $entry_id int Gravity Forms entry id |
|
| 188 | - * @return string |
|
| 189 | - */ |
|
| 190 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
| 191 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * The edit entry link creates a secure link with a nonce |
|
| 197 | - * |
|
| 198 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
| 199 | - * it formats the display of the edit form like it does in the backend, like |
|
| 200 | - * "You can edit this post from the post page" fields, for example. |
|
| 201 | - * |
|
| 202 | - * @param $entry array Gravity Forms entry object |
|
| 203 | - * @param $view_id int GravityView view id |
|
| 204 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
| 205 | - * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
| 206 | - * @return string |
|
| 207 | - */ |
|
| 208 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
| 209 | - |
|
| 210 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 211 | - |
|
| 212 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
| 213 | - |
|
| 214 | - $url = add_query_arg( array( |
|
| 215 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
| 216 | - ), $base ); |
|
| 217 | - |
|
| 218 | - if( $post_id ) { |
|
| 219 | - $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * Allow passing params to dynamically populate entry with values |
|
| 224 | - * @since 1.9.2 |
|
| 225 | - */ |
|
| 226 | - if( !empty( $field_values ) ) { |
|
| 227 | - |
|
| 228 | - if( is_array( $field_values ) ) { |
|
| 229 | - // If already an array, no parse_str() needed |
|
| 230 | - $params = $field_values; |
|
| 231 | - } else { |
|
| 232 | - parse_str( $field_values, $params ); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - $url = add_query_arg( $params, $url ); |
|
| 236 | - } |
|
| 169 | + /** |
|
| 170 | + * Include this extension templates path |
|
| 171 | + * @param array $file_paths List of template paths ordered |
|
| 172 | + */ |
|
| 173 | + public function add_template_path( $file_paths ) { |
|
| 174 | + |
|
| 175 | + // Index 100 is the default GravityView template path. |
|
| 176 | + $file_paths[ 110 ] = self::$file; |
|
| 177 | + |
|
| 178 | + return $file_paths; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * |
|
| 183 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
| 184 | + * |
|
| 185 | + * @param $view_id int GravityView view id |
|
| 186 | + * @param $form_id int Gravity Forms form id |
|
| 187 | + * @param $entry_id int Gravity Forms entry id |
|
| 188 | + * @return string |
|
| 189 | + */ |
|
| 190 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
| 191 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * The edit entry link creates a secure link with a nonce |
|
| 197 | + * |
|
| 198 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
| 199 | + * it formats the display of the edit form like it does in the backend, like |
|
| 200 | + * "You can edit this post from the post page" fields, for example. |
|
| 201 | + * |
|
| 202 | + * @param $entry array Gravity Forms entry object |
|
| 203 | + * @param $view_id int GravityView view id |
|
| 204 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
| 205 | + * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
| 206 | + * @return string |
|
| 207 | + */ |
|
| 208 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
| 209 | + |
|
| 210 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 211 | + |
|
| 212 | + $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
| 213 | + |
|
| 214 | + $url = add_query_arg( array( |
|
| 215 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
| 216 | + ), $base ); |
|
| 217 | + |
|
| 218 | + if( $post_id ) { |
|
| 219 | + $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * Allow passing params to dynamically populate entry with values |
|
| 224 | + * @since 1.9.2 |
|
| 225 | + */ |
|
| 226 | + if( !empty( $field_values ) ) { |
|
| 227 | + |
|
| 228 | + if( is_array( $field_values ) ) { |
|
| 229 | + // If already an array, no parse_str() needed |
|
| 230 | + $params = $field_values; |
|
| 231 | + } else { |
|
| 232 | + parse_str( $field_values, $params ); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + $url = add_query_arg( $params, $url ); |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | 238 | /** |
| 239 | 239 | * @filter `gravityview/edit/link` Filter the edit URL link. |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * @param \GV\View $view The View. |
| 243 | 243 | */ |
| 244 | 244 | return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) ); |
| 245 | - } |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * Edit mode doesn't allow certain field types. |
@@ -297,19 +297,19 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | |
| 300 | - /** |
|
| 301 | - * checks if user has permissions to edit a specific entry |
|
| 302 | - * |
|
| 303 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
| 304 | - * |
|
| 305 | - * @param array $entry Gravity Forms entry array |
|
| 306 | - * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
| 307 | - * @return bool |
|
| 308 | - */ |
|
| 309 | - public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
| 300 | + /** |
|
| 301 | + * checks if user has permissions to edit a specific entry |
|
| 302 | + * |
|
| 303 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
| 304 | + * |
|
| 305 | + * @param array $entry Gravity Forms entry array |
|
| 306 | + * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0 |
|
| 307 | + * @return bool |
|
| 308 | + */ |
|
| 309 | + public static function check_user_cap_edit_entry( $entry, $view = 0 ) { |
|
| 310 | 310 | |
| 311 | - // No permission by default |
|
| 312 | - $user_can_edit = false; |
|
| 311 | + // No permission by default |
|
| 312 | + $user_can_edit = false; |
|
| 313 | 313 | |
| 314 | 314 | // get user_edit setting |
| 315 | 315 | if ( empty( $view ) ) { |
@@ -327,60 +327,60 @@ discard block |
||
| 327 | 327 | $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - // If they can edit any entries (as defined in Gravity Forms) |
|
| 331 | - // Or if they can edit other people's entries |
|
| 332 | - // Then we're good. |
|
| 333 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 330 | + // If they can edit any entries (as defined in Gravity Forms) |
|
| 331 | + // Or if they can edit other people's entries |
|
| 332 | + // Then we're good. |
|
| 333 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 334 | 334 | |
| 335 | - gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
| 335 | + gravityview()->log->debug( 'User has ability to edit all entries.' ); |
|
| 336 | 336 | |
| 337 | - $user_can_edit = true; |
|
| 337 | + $user_can_edit = true; |
|
| 338 | 338 | |
| 339 | - } else if( !isset( $entry['created_by'] ) ) { |
|
| 339 | + } else if( !isset( $entry['created_by'] ) ) { |
|
| 340 | 340 | |
| 341 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
| 341 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
| 342 | 342 | |
| 343 | - $user_can_edit = false; |
|
| 343 | + $user_can_edit = false; |
|
| 344 | 344 | |
| 345 | - } else { |
|
| 345 | + } else { |
|
| 346 | 346 | |
| 347 | - $current_user = wp_get_current_user(); |
|
| 347 | + $current_user = wp_get_current_user(); |
|
| 348 | 348 | |
| 349 | - // User edit is disabled |
|
| 350 | - if( empty( $user_edit ) ) { |
|
| 349 | + // User edit is disabled |
|
| 350 | + if( empty( $user_edit ) ) { |
|
| 351 | 351 | |
| 352 | - gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
| 352 | + gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
|
| 353 | 353 | |
| 354 | - $user_can_edit = false; |
|
| 355 | - } |
|
| 354 | + $user_can_edit = false; |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
| 358 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 357 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
| 358 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 359 | 359 | |
| 360 | - gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
| 360 | + gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
|
| 361 | 361 | |
| 362 | - $user_can_edit = true; |
|
| 362 | + $user_can_edit = true; |
|
| 363 | 363 | |
| 364 | - } else if( ! is_user_logged_in() ) { |
|
| 364 | + } else if( ! is_user_logged_in() ) { |
|
| 365 | 365 | |
| 366 | - gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
| 366 | + gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
|
| 367 | 367 | |
| 368 | - $user_can_edit = false; // Here just for clarity |
|
| 369 | - } |
|
| 368 | + $user_can_edit = false; // Here just for clarity |
|
| 369 | + } |
|
| 370 | 370 | |
| 371 | - } |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - /** |
|
| 374 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
| 375 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
| 376 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
| 377 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
| 378 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
| 379 | - */ |
|
| 380 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
| 373 | + /** |
|
| 374 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
| 375 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
| 376 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
| 377 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
| 378 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
| 379 | + */ |
|
| 380 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
| 381 | 381 | |
| 382 | - return (bool) $user_can_edit; |
|
| 383 | - } |
|
| 382 | + return (bool) $user_can_edit; |
|
| 383 | + } |
|
| 384 | 384 | |
| 385 | 385 | |
| 386 | 386 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | self::$file = plugin_dir_path( __FILE__ ); |
| 38 | 38 | |
| 39 | - if( is_admin() ) { |
|
| 39 | + if ( is_admin() ) { |
|
| 40 | 40 | $this->load_components( 'admin' ); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | static function getInstance() { |
| 58 | 58 | |
| 59 | - if( empty( self::$instance ) ) { |
|
| 59 | + if ( empty( self::$instance ) ) { |
|
| 60 | 60 | self::$instance = new GravityView_Edit_Entry; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | private function add_hooks() { |
| 83 | 83 | |
| 84 | 84 | // Add front-end access to Gravity Forms delete file action |
| 85 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 85 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file' ) ); |
|
| 86 | 86 | |
| 87 | 87 | // Make sure this hook is run for non-admins |
| 88 | - add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') ); |
|
| 88 | + add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file' ) ); |
|
| 89 | 89 | |
| 90 | 90 | add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
| 91 | 91 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function add_reserved_arg( $args ) { |
| 110 | 110 | |
| 111 | - $args[] = 'edit'; |
|
| 111 | + $args[ ] = 'edit'; |
|
| 112 | 112 | |
| 113 | 113 | return $args; |
| 114 | 114 | } |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | private function addon_specific_hooks() { |
| 121 | 121 | |
| 122 | - if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
| 123 | - add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script')); |
|
| 122 | + if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
| 123 | + add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | } |
@@ -207,15 +207,15 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
| 209 | 209 | |
| 210 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
| 210 | + $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] ); |
|
| 211 | 211 | |
| 212 | - $base = gv_entry_link( $entry, $post_id ? : $view_id ); |
|
| 212 | + $base = gv_entry_link( $entry, $post_id ?: $view_id ); |
|
| 213 | 213 | |
| 214 | 214 | $url = add_query_arg( array( |
| 215 | 215 | 'edit' => wp_create_nonce( $nonce_key ) |
| 216 | 216 | ), $base ); |
| 217 | 217 | |
| 218 | - if( $post_id ) { |
|
| 218 | + if ( $post_id ) { |
|
| 219 | 219 | $url = add_query_arg( array( 'gvid' => $view_id ), $url ); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -223,9 +223,9 @@ discard block |
||
| 223 | 223 | * Allow passing params to dynamically populate entry with values |
| 224 | 224 | * @since 1.9.2 |
| 225 | 225 | */ |
| 226 | - if( !empty( $field_values ) ) { |
|
| 226 | + if ( ! empty( $field_values ) ) { |
|
| 227 | 227 | |
| 228 | - if( is_array( $field_values ) ) { |
|
| 228 | + if ( is_array( $field_values ) ) { |
|
| 229 | 229 | // If already an array, no parse_str() needed |
| 230 | 230 | $params = $field_values; |
| 231 | 231 | } else { |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param array $entry The entry. |
| 242 | 242 | * @param \GV\View $view The View. |
| 243 | 243 | */ |
| 244 | - return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) ); |
|
| 244 | + return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id ) ); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public function modify_field_blacklist( $fields = array(), $context = NULL ) { |
| 254 | 254 | |
| 255 | - if( empty( $context ) || $context !== 'edit' ) { |
|
| 255 | + if ( empty( $context ) || $context !== 'edit' ) { |
|
| 256 | 256 | return $fields; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -330,15 +330,15 @@ discard block |
||
| 330 | 330 | // If they can edit any entries (as defined in Gravity Forms) |
| 331 | 331 | // Or if they can edit other people's entries |
| 332 | 332 | // Then we're good. |
| 333 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
| 333 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) { |
|
| 334 | 334 | |
| 335 | 335 | gravityview()->log->debug( 'User has ability to edit all entries.' ); |
| 336 | 336 | |
| 337 | 337 | $user_can_edit = true; |
| 338 | 338 | |
| 339 | - } else if( !isset( $entry['created_by'] ) ) { |
|
| 339 | + } else if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
| 340 | 340 | |
| 341 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
| 341 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
|
| 342 | 342 | |
| 343 | 343 | $user_can_edit = false; |
| 344 | 344 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | $current_user = wp_get_current_user(); |
| 348 | 348 | |
| 349 | 349 | // User edit is disabled |
| 350 | - if( empty( $user_edit ) ) { |
|
| 350 | + if ( empty( $user_edit ) ) { |
|
| 351 | 351 | |
| 352 | 352 | gravityview()->log->debug( 'User Edit is disabled. Returning false.' ); |
| 353 | 353 | |
@@ -355,13 +355,13 @@ discard block |
||
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
| 358 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 358 | + else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
| 359 | 359 | |
| 360 | 360 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) ); |
| 361 | 361 | |
| 362 | 362 | $user_can_edit = true; |
| 363 | 363 | |
| 364 | - } else if( ! is_user_logged_in() ) { |
|
| 364 | + } else if ( ! is_user_logged_in() ) { |
|
| 365 | 365 | |
| 366 | 366 | gravityview()->log->debug( 'No user defined; edit entry requires logged in user' ); |
| 367 | 367 | |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | */ |
| 380 | 380 | $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
| 381 | 381 | |
| 382 | - return (bool) $user_can_edit; |
|
| 382 | + return (bool)$user_can_edit; |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $form = $gravityview_view->getForm(); |
| 32 | 32 | |
| 33 | - if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && ! empty( $GLOBALS['GravityView_API_field_label_override'] ) ) { |
|
| 33 | + if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && ! empty( $GLOBALS[ 'GravityView_API_field_label_override' ] ) ) { |
|
| 34 | 34 | /** Allow to fall through for back compatibility testing purposes. */ |
| 35 | 35 | } else { |
| 36 | 36 | return \GV\Mocks\GravityView_API_field_label( $form, $field, $entry, $force_show_label ); |
@@ -38,29 +38,29 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $label = ''; |
| 40 | 40 | |
| 41 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
| 41 | + if ( ! empty( $field[ 'show_label' ] ) || $force_show_label ) { |
|
| 42 | 42 | |
| 43 | - $label = $field['label']; |
|
| 43 | + $label = $field[ 'label' ]; |
|
| 44 | 44 | |
| 45 | 45 | // Support Gravity Forms 1.9+ |
| 46 | - if( class_exists( 'GF_Field' ) ) { |
|
| 46 | + if ( class_exists( 'GF_Field' ) ) { |
|
| 47 | 47 | |
| 48 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
| 48 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
| 49 | 49 | |
| 50 | - if( $field_object ) { |
|
| 50 | + if ( $field_object ) { |
|
| 51 | 51 | |
| 52 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
| 52 | + $input = GFFormsModel::get_input( $field_object, $field[ 'id' ] ); |
|
| 53 | 53 | |
| 54 | 54 | // This is a complex field, with labels on a per-input basis |
| 55 | - if( $input ) { |
|
| 55 | + if ( $input ) { |
|
| 56 | 56 | |
| 57 | 57 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
| 58 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
| 58 | + $label = ! empty( $input[ 'customLabel' ] ) ? $input[ 'customLabel' ] : $input[ 'label' ]; |
|
| 59 | 59 | |
| 60 | 60 | } else { |
| 61 | 61 | |
| 62 | 62 | // This is a field with one label |
| 63 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
| 63 | + $label = $field_object->get_field_label( true, $field[ 'label' ] ); |
|
| 64 | 64 | |
| 65 | 65 | } |
| 66 | 66 | |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
| 72 | - if ( !empty( $field['custom_label'] ) ) { |
|
| 72 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
| 73 | 73 | |
| 74 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
| 74 | + $label = self::replace_variables( $field[ 'custom_label' ], $form, $entry ); |
|
| 75 | 75 | |
| 76 | 76 | } |
| 77 | 77 | |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | $width = NULL; |
| 135 | 135 | |
| 136 | - if( !empty( $field['width'] ) ) { |
|
| 137 | - $width = absint( $field['width'] ); |
|
| 136 | + if ( ! empty( $field[ 'width' ] ) ) { |
|
| 137 | + $width = absint( $field[ 'width' ] ); |
|
| 138 | 138 | |
| 139 | 139 | // If using percentages, limit to 100% |
| 140 | - if( '%d%%' === $format && $width > 100 ) { |
|
| 140 | + if ( '%d%%' === $format && $width > 100 ) { |
|
| 141 | 141 | $width = 100; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -157,42 +157,42 @@ discard block |
||
| 157 | 157 | public static function field_class( $field, $form = NULL, $entry = NULL ) { |
| 158 | 158 | $classes = array(); |
| 159 | 159 | |
| 160 | - if( !empty( $field['custom_class'] ) ) { |
|
| 160 | + if ( ! empty( $field[ 'custom_class' ] ) ) { |
|
| 161 | 161 | |
| 162 | - $custom_class = $field['custom_class']; |
|
| 162 | + $custom_class = $field[ 'custom_class' ]; |
|
| 163 | 163 | |
| 164 | - if( !empty( $entry ) ) { |
|
| 164 | + if ( ! empty( $entry ) ) { |
|
| 165 | 165 | |
| 166 | 166 | // We want the merge tag to be formatted as a class. The merge tag may be |
| 167 | 167 | // replaced by a multiple-word value that should be output as a single class. |
| 168 | 168 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
| 169 | - add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 169 | + add_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
| 170 | 170 | |
| 171 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
| 171 | + $custom_class = self::replace_variables( $custom_class, $form, $entry ); |
|
| 172 | 172 | |
| 173 | 173 | // And then we want life to return to normal |
| 174 | - remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 174 | + remove_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // And now we want the spaces to be handled nicely. |
| 178 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
| 178 | + $classes[ ] = gravityview_sanitize_html_class( $custom_class ); |
|
| 179 | 179 | |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if(!empty($field['id'])) { |
|
| 183 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
| 184 | - $form_id = '-'.$form['id']; |
|
| 182 | + if ( ! empty( $field[ 'id' ] ) ) { |
|
| 183 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
| 184 | + $form_id = '-' . $form[ 'id' ]; |
|
| 185 | 185 | } else { |
| 186 | 186 | // @deprecated path. Form should always be given. |
| 187 | 187 | gravityview()->log->warning( 'GravityView_View::getInstance() legacy API called' ); |
| 188 | 188 | $gravityview_view = GravityView_View::getInstance(); |
| 189 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
| 189 | + $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
|
| 192 | + $classes[ ] = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - return esc_attr(implode(' ', $classes)); |
|
| 195 | + return esc_attr( implode( ' ', $classes ) ); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | * @return string Sanitized unique HTML `id` attribute for the field |
| 208 | 208 | */ |
| 209 | 209 | public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
| 210 | - $id = $field['id']; |
|
| 210 | + $id = $field[ 'id' ]; |
|
| 211 | 211 | |
| 212 | 212 | if ( ! empty( $id ) ) { |
| 213 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
| 214 | - $form_id = '-' . $form['id']; |
|
| 213 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
| 214 | + $form_id = '-' . $form[ 'id' ]; |
|
| 215 | 215 | } else { |
| 216 | 216 | // @deprecated path. Form should always be given. |
| 217 | 217 | gravityview()->log->warning( 'GravityView_View::getInstance() legacy API called' ); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
| 222 | + $id = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | return esc_attr( $id ); |
@@ -258,14 +258,14 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array(), $base_id = null ) { |
| 260 | 260 | |
| 261 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
| 261 | + if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry[ 'id' ] ) ) { |
|
| 262 | 262 | gravityview()->log->debug( 'Entry not defined; returning null', array( 'data' => $entry ) ); |
| 263 | 263 | return NULL; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | $href = self::entry_link( $entry, $base_id ); |
| 267 | 267 | |
| 268 | - if( '' === $href ) { |
|
| 268 | + if ( '' === $href ) { |
|
| 269 | 269 | return NULL; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | } else { |
| 303 | 303 | $gravityview_view = GravityView_View::getInstance(); |
| 304 | 304 | |
| 305 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
| 305 | + if ( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
| 306 | 306 | $is_search = true; |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | $output = esc_html__( 'This search returned no results.', 'gravityview' ); |
| 315 | 315 | |
| 316 | - if( $context ) { |
|
| 316 | + if ( $context ) { |
|
| 317 | 317 | $setting = $context->view->settings->get( 'no_search_results_text', $output ); |
| 318 | 318 | } |
| 319 | 319 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | $output = esc_html__( 'No entries match your request.', 'gravityview' ); |
| 323 | 323 | |
| 324 | - if( $context ) { |
|
| 324 | + if ( $context ) { |
|
| 325 | 325 | $setting = $context->view->settings->get( 'no_results_text', $output ); |
| 326 | 326 | } |
| 327 | 327 | } |
@@ -439,9 +439,9 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | // If we've saved the permalink in memory, use it |
| 441 | 441 | // @since 1.3 |
| 442 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
| 442 | + $link = wp_cache_get( 'gv_directory_link_' . $post_id ); |
|
| 443 | 443 | |
| 444 | - if ( (int) $post_id === (int) get_option( 'page_on_front' ) ) { |
|
| 444 | + if ( (int)$post_id === (int)get_option( 'page_on_front' ) ) { |
|
| 445 | 445 | $link = home_url(); |
| 446 | 446 | } |
| 447 | 447 | |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | |
| 451 | 451 | // If not yet saved, cache the permalink. |
| 452 | 452 | // @since 1.3 |
| 453 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
| 453 | + wp_cache_set( 'gv_directory_link_' . $post_id, $link ); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | // Deal with returning to proper pagination for embedded views |
@@ -458,13 +458,13 @@ discard block |
||
| 458 | 458 | |
| 459 | 459 | $args = isset( $_GET ) ? $_GET : array(); |
| 460 | 460 | |
| 461 | - if( $pagenum = \GV\Utils::_GET( 'pagenum' ) ) { |
|
| 462 | - $args['pagenum'] = intval( $pagenum ); |
|
| 461 | + if ( $pagenum = \GV\Utils::_GET( 'pagenum' ) ) { |
|
| 462 | + $args[ 'pagenum' ] = intval( $pagenum ); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - if( $sort = \GV\Utils::_GET( 'sort' ) ) { |
|
| 466 | - $args['sort'] = $sort; |
|
| 467 | - $args['dir'] = \GV\Utils::_GET( 'dir' ); |
|
| 465 | + if ( $sort = \GV\Utils::_GET( 'sort' ) ) { |
|
| 466 | + $args[ 'sort' ] = $sort; |
|
| 467 | + $args[ 'dir' ] = \GV\Utils::_GET( 'dir' ); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | $link = add_query_arg( $args, $link ); |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | private static function get_custom_entry_slug( $id, $entry = array() ) { |
| 502 | 502 | |
| 503 | 503 | // Generate an unique hash to use as the default value |
| 504 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
| 504 | + $slug = substr( wp_hash( $id, 'gravityview' . $id ), 0, 8 ); |
|
| 505 | 505 | |
| 506 | 506 | /** |
| 507 | 507 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
| 513 | 513 | |
| 514 | 514 | // Make sure we have something - use the original ID as backup. |
| 515 | - if( empty( $slug ) ) { |
|
| 515 | + if ( empty( $slug ) ) { |
|
| 516 | 516 | $slug = $id; |
| 517 | 517 | } |
| 518 | 518 | |
@@ -606,15 +606,15 @@ discard block |
||
| 606 | 606 | * @param boolean $custom Should we process the custom entry slug? |
| 607 | 607 | */ |
| 608 | 608 | $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
| 609 | - if( $custom ) { |
|
| 609 | + if ( $custom ) { |
|
| 610 | 610 | // create the gravityview_unique_id and save it |
| 611 | 611 | |
| 612 | 612 | // Get the entry hash |
| 613 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
| 613 | + $hash = self::get_custom_entry_slug( $entry[ 'id' ], $entry ); |
|
| 614 | 614 | |
| 615 | - gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry['id'], 'hash' => $hash ) ); |
|
| 615 | + gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry[ 'id' ], 'hash' => $hash ) ); |
|
| 616 | 616 | |
| 617 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) ); |
|
| 617 | + gform_update_meta( $entry[ 'id' ], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) ); |
|
| 618 | 618 | |
| 619 | 619 | } |
| 620 | 620 | } |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | |
| 641 | 641 | if ( ! empty( $entry ) && ! is_array( $entry ) ) { |
| 642 | 642 | $entry = GVCommon::get_entry( $entry ); |
| 643 | - } else if( empty( $entry ) ) { |
|
| 643 | + } else if ( empty( $entry ) ) { |
|
| 644 | 644 | // @deprecated path |
| 645 | 645 | $entry = GravityView_frontend::getInstance()->getEntry(); |
| 646 | 646 | } |
@@ -660,32 +660,32 @@ discard block |
||
| 660 | 660 | |
| 661 | 661 | $query_arg_name = \GV\Entry::get_endpoint_name(); |
| 662 | 662 | |
| 663 | - if ( ! empty( $entry['_multi'] ) ) { |
|
| 663 | + if ( ! empty( $entry[ '_multi' ] ) ) { |
|
| 664 | 664 | $entry_slugs = array(); |
| 665 | 665 | |
| 666 | - foreach ( $entry['_multi'] as $_multi ) { |
|
| 666 | + foreach ( $entry[ '_multi' ] as $_multi ) { |
|
| 667 | 667 | |
| 668 | - if( $gv_multi = \GV\GF_Entry::from_entry( $_multi ) ) { |
|
| 669 | - $entry_slugs[] = $gv_multi->get_slug(); |
|
| 668 | + if ( $gv_multi = \GV\GF_Entry::from_entry( $_multi ) ) { |
|
| 669 | + $entry_slugs[ ] = $gv_multi->get_slug(); |
|
| 670 | 670 | } else { |
| 671 | 671 | // TODO: This path isn't covered by unit tests |
| 672 | - $entry_slugs[] = \GravityView_API::get_entry_slug( $_multi['id'], $_multi ); |
|
| 672 | + $entry_slugs[ ] = \GravityView_API::get_entry_slug( $_multi[ 'id' ], $_multi ); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | unset( $gv_multi ); |
| 676 | 676 | |
| 677 | - $forms[] = $_multi['form_id']; |
|
| 677 | + $forms[ ] = $_multi[ 'form_id' ]; |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | $entry_slug = implode( ',', $entry_slugs ); |
| 681 | 681 | } else { |
| 682 | 682 | |
| 683 | 683 | // Fallback when |
| 684 | - if( $gv_entry = \GV\GF_Entry::from_entry( $entry ) ) { |
|
| 684 | + if ( $gv_entry = \GV\GF_Entry::from_entry( $entry ) ) { |
|
| 685 | 685 | $entry_slug = $gv_entry->get_slug(); |
| 686 | 686 | } else { |
| 687 | 687 | // TODO: This path isn't covered by unit tests |
| 688 | - $entry_slug = \GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
| 688 | + $entry_slug = \GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | unset( $gv_entry ); |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | $args = gv_get_query_args(); |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - if ( get_option('permalink_structure') && ! is_preview() ) { |
|
| 707 | + if ( get_option( 'permalink_structure' ) && ! is_preview() ) { |
|
| 708 | 708 | |
| 709 | 709 | /** |
| 710 | 710 | * Make sure the $directory_link doesn't contain any query otherwise it will break when adding the entry slug. |
@@ -712,13 +712,13 @@ discard block |
||
| 712 | 712 | */ |
| 713 | 713 | $link_parts = explode( '?', $directory_link ); |
| 714 | 714 | |
| 715 | - $query = !empty( $link_parts[1] ) ? '?'.$link_parts[1] : ''; |
|
| 715 | + $query = ! empty( $link_parts[ 1 ] ) ? '?' . $link_parts[ 1 ] : ''; |
|
| 716 | 716 | |
| 717 | - $directory_link = trailingslashit( $link_parts[0] ) . $query_arg_name . '/'. $entry_slug .'/' . $query; |
|
| 717 | + $directory_link = trailingslashit( $link_parts[ 0 ] ) . $query_arg_name . '/' . $entry_slug . '/' . $query; |
|
| 718 | 718 | |
| 719 | 719 | } else { |
| 720 | 720 | |
| 721 | - $args[] = array( $query_arg_name => $entry_slug ); |
|
| 721 | + $args[ ] = array( $query_arg_name => $entry_slug ); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | /** |
@@ -726,21 +726,21 @@ discard block |
||
| 726 | 726 | */ |
| 727 | 727 | if ( $add_directory_args ) { |
| 728 | 728 | |
| 729 | - if ( ! empty( $_GET['pagenum'] ) ) { |
|
| 730 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
| 729 | + if ( ! empty( $_GET[ 'pagenum' ] ) ) { |
|
| 730 | + $args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] ); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | /** |
| 734 | 734 | * @since 1.7 |
| 735 | 735 | */ |
| 736 | 736 | if ( $sort = \GV\Utils::_GET( 'sort' ) ) { |
| 737 | - $args['sort'] = $sort; |
|
| 738 | - $args['dir'] = \GV\Utils::_GET( 'dir' ); |
|
| 737 | + $args[ 'sort' ] = $sort; |
|
| 738 | + $args[ 'dir' ] = \GV\Utils::_GET( 'dir' ); |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - if( $post_id ) { |
|
| 743 | + if ( $post_id ) { |
|
| 744 | 744 | $passed_post = get_post( $post_id ); |
| 745 | 745 | $views = \GV\View_Collection::from_post( $passed_post ); |
| 746 | 746 | $has_multiple_views = $views->count() > 1; |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | if ( $has_multiple_views ) { |
| 752 | - $args['gvid'] = $view_id ? $view_id : gravityview_get_view_id(); |
|
| 752 | + $args[ 'gvid' ] = $view_id ? $view_id : gravityview_get_view_id(); |
|
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | return add_query_arg( $args, $directory_link ); |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | function gv_class( $field, $form = NULL, $entry = array() ) { |
| 822 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
| 822 | + return GravityView_API::field_class( $field, $form, $entry ); |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | /** |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | $view_id = 0; |
| 843 | 843 | if ( $context->view ) { |
| 844 | 844 | $view_id = $context->view->ID; |
| 845 | - if( $context->view->settings->get( 'hide_until_searched' ) ) { |
|
| 845 | + if ( $context->view->settings->get( 'hide_until_searched' ) ) { |
|
| 846 | 846 | $hide_until_searched = ( empty( $context->entry ) && ! $context->request->is_search() ); |
| 847 | 847 | } |
| 848 | 848 | } |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | $default_css_class .= ' ' . $context->view->settings->get( 'class', '' ); |
| 875 | 875 | } |
| 876 | 876 | |
| 877 | - $css_class = trim( $passed_css_class . ' '. $default_css_class ); |
|
| 877 | + $css_class = trim( $passed_css_class . ' ' . $default_css_class ); |
|
| 878 | 878 | |
| 879 | 879 | /** |
| 880 | 880 | * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View |
@@ -901,7 +901,7 @@ discard block |
||
| 901 | 901 | |
| 902 | 902 | $value = GravityView_API::field_value( $entry, $field ); |
| 903 | 903 | |
| 904 | - if( $value === '' ) { |
|
| 904 | + if ( $value === '' ) { |
|
| 905 | 905 | /** |
| 906 | 906 | * @filter `gravityview_empty_value` What to display when a field is empty |
| 907 | 907 | * @param string $value (empty string) |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | */ |
| 1015 | 1015 | function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
| 1016 | 1016 | |
| 1017 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
| 1017 | + if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
| 1018 | 1018 | |
| 1019 | 1019 | // For the complete field value as generated by Gravity Forms |
| 1020 | 1020 | return $display_value; |
@@ -1048,16 +1048,16 @@ discard block |
||
| 1048 | 1048 | $terms = explode( ', ', $value ); |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | - foreach ($terms as $term_name ) { |
|
| 1051 | + foreach ( $terms as $term_name ) { |
|
| 1052 | 1052 | |
| 1053 | 1053 | // If we're processing a category, |
| 1054 | - if( $taxonomy === 'category' ) { |
|
| 1054 | + if ( $taxonomy === 'category' ) { |
|
| 1055 | 1055 | |
| 1056 | 1056 | // Use rgexplode to prevent errors if : doesn't exist |
| 1057 | 1057 | list( $term_name, $term_id ) = rgexplode( ':', $term_name, 2 ); |
| 1058 | 1058 | |
| 1059 | 1059 | // The explode was succesful; we have the category ID |
| 1060 | - if( !empty( $term_id )) { |
|
| 1060 | + if ( ! empty( $term_id ) ) { |
|
| 1061 | 1061 | $term = get_term_by( 'id', $term_id, $taxonomy ); |
| 1062 | 1062 | } else { |
| 1063 | 1063 | // We have to fall back to the name |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | // There's still a tag/category here. |
| 1073 | - if( $term ) { |
|
| 1073 | + if ( $term ) { |
|
| 1074 | 1074 | |
| 1075 | 1075 | $term_link = get_term_link( $term, $taxonomy ); |
| 1076 | 1076 | |
@@ -1079,11 +1079,11 @@ discard block |
||
| 1079 | 1079 | continue; |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
| 1082 | + $output[ ] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
| 1083 | 1083 | } |
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | - return implode(', ', $output ); |
|
| 1086 | + return implode( ', ', $output ); |
|
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | /** |
@@ -1097,8 +1097,8 @@ discard block |
||
| 1097 | 1097 | |
| 1098 | 1098 | $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
| 1099 | 1099 | |
| 1100 | - if( empty( $link ) ) { |
|
| 1101 | - return strip_tags( $output); |
|
| 1100 | + if ( empty( $link ) ) { |
|
| 1101 | + return strip_tags( $output ); |
|
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | return $output; |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | $fe = GravityView_frontend::getInstance(); |
| 1118 | 1118 | |
| 1119 | 1119 | // Solve problem when loading content via admin-ajax.php |
| 1120 | - if( ! $fe->getGvOutputData() ) { |
|
| 1120 | + if ( ! $fe->getGvOutputData() ) { |
|
| 1121 | 1121 | |
| 1122 | 1122 | gravityview()->log->debug( 'gv_output_data not defined; parsing content.' ); |
| 1123 | 1123 | |
@@ -1125,7 +1125,7 @@ discard block |
||
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | 1127 | // Make 100% sure that we're dealing with a properly called situation |
| 1128 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
| 1128 | + if ( ! is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
| 1129 | 1129 | |
| 1130 | 1130 | gravityview()->log->debug( 'gv_output_data not an object or get_view not callable.', array( 'data' => $fe->getGvOutputData() ) ); |
| 1131 | 1131 | |
@@ -1356,12 +1356,12 @@ discard block |
||
| 1356 | 1356 | function gravityview_get_files_array( $value, $gv_class = '', $context = null ) { |
| 1357 | 1357 | /** @define "GRAVITYVIEW_DIR" "../" */ |
| 1358 | 1358 | |
| 1359 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
| 1360 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
| 1359 | + if ( ! class_exists( 'GravityView_Field' ) ) { |
|
| 1360 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' ); |
|
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
| 1364 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field-fileupload.php' ); |
|
| 1363 | + if ( ! class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
| 1364 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field-fileupload.php' ); |
|
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | 1367 | if ( is_null( $context ) ) { |
@@ -1464,21 +1464,21 @@ discard block |
||
| 1464 | 1464 | } else { |
| 1465 | 1465 | // @deprecated path |
| 1466 | 1466 | // Required fields. |
| 1467 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
| 1467 | + if ( empty( $args[ 'field' ] ) || empty( $args[ 'form' ] ) ) { |
|
| 1468 | 1468 | gravityview()->log->error( 'Field or form are empty.', array( 'data' => $args ) ); |
| 1469 | 1469 | return ''; |
| 1470 | 1470 | } |
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | 1473 | if ( $context instanceof \GV\Template_Context ) { |
| 1474 | - $entry = $args['entry'] ? : ( $context->entry ? $context->entry->as_entry() : array() ); |
|
| 1475 | - $field = $args['field'] ? : ( $context->field ? $context->field->as_configuration() : array() ); |
|
| 1476 | - $form = $args['form'] ? : ( $context->view->form ? $context->view->form->form : array() ); |
|
| 1474 | + $entry = $args[ 'entry' ] ?: ( $context->entry ? $context->entry->as_entry() : array() ); |
|
| 1475 | + $field = $args[ 'field' ] ?: ( $context->field ? $context->field->as_configuration() : array() ); |
|
| 1476 | + $form = $args[ 'form' ] ?: ( $context->view->form ? $context->view->form->form : array() ); |
|
| 1477 | 1477 | } else { |
| 1478 | 1478 | // @deprecated path |
| 1479 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
| 1480 | - $field = $args['field']; |
|
| 1481 | - $form = $args['form']; |
|
| 1479 | + $entry = empty( $args[ 'entry' ] ) ? array() : $args[ 'entry' ]; |
|
| 1480 | + $field = $args[ 'field' ]; |
|
| 1481 | + $form = $args[ 'form' ]; |
|
| 1482 | 1482 | } |
| 1483 | 1483 | |
| 1484 | 1484 | /** |
@@ -1498,43 +1498,43 @@ discard block |
||
| 1498 | 1498 | ); |
| 1499 | 1499 | |
| 1500 | 1500 | if ( $context instanceof \GV\Template_Context ) { |
| 1501 | - $placeholders['value'] = \GV\Utils::get( $args, 'value', '' ); |
|
| 1501 | + $placeholders[ 'value' ] = \GV\Utils::get( $args, 'value', '' ); |
|
| 1502 | 1502 | } else { |
| 1503 | 1503 | // @deprecated path |
| 1504 | - $placeholders['value'] = gv_value( $entry, $field ); |
|
| 1504 | + $placeholders[ 'value' ] = gv_value( $entry, $field ); |
|
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | 1507 | // If the value is empty and we're hiding empty, return empty. |
| 1508 | - if ( $placeholders['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
| 1508 | + if ( $placeholders[ 'value' ] === '' && ! empty( $args[ 'hide_empty' ] ) ) { |
|
| 1509 | 1509 | return ''; |
| 1510 | 1510 | } |
| 1511 | 1511 | |
| 1512 | - if ( $placeholders['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
| 1513 | - $placeholders['value'] = wpautop( $placeholders['value'] ); |
|
| 1512 | + if ( $placeholders[ 'value' ] !== '' && ! empty( $args[ 'wpautop' ] ) ) { |
|
| 1513 | + $placeholders[ 'value' ] = wpautop( $placeholders[ 'value' ] ); |
|
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | // Get width setting, if exists |
| 1517 | - $placeholders['width'] = GravityView_API::field_width( $field ); |
|
| 1517 | + $placeholders[ 'width' ] = GravityView_API::field_width( $field ); |
|
| 1518 | 1518 | |
| 1519 | 1519 | // If replacing with CSS inline formatting, let's do it. |
| 1520 | - $placeholders['width:style'] = GravityView_API::field_width( $field, 'width:' . $placeholders['width'] . '%;' ); |
|
| 1520 | + $placeholders[ 'width:style' ] = GravityView_API::field_width( $field, 'width:' . $placeholders[ 'width' ] . '%;' ); |
|
| 1521 | 1521 | |
| 1522 | 1522 | // Grab the Class using `gv_class` |
| 1523 | - $placeholders['class'] = gv_class( $field, $form, $entry ); |
|
| 1524 | - $placeholders['field_id'] = GravityView_API::field_html_attr_id( $field, $form, $entry ); |
|
| 1523 | + $placeholders[ 'class' ] = gv_class( $field, $form, $entry ); |
|
| 1524 | + $placeholders[ 'field_id' ] = GravityView_API::field_html_attr_id( $field, $form, $entry ); |
|
| 1525 | 1525 | |
| 1526 | 1526 | if ( $context instanceof \GV\Template_Context ) { |
| 1527 | - $placeholders['label_value'] = \GV\Utils::get( $args, 'label' ); |
|
| 1527 | + $placeholders[ 'label_value' ] = \GV\Utils::get( $args, 'label' ); |
|
| 1528 | 1528 | } else { |
| 1529 | 1529 | // Default Label value |
| 1530 | - $placeholders['label_value'] = gv_label( $field, $entry ); |
|
| 1530 | + $placeholders[ 'label_value' ] = gv_label( $field, $entry ); |
|
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | - $placeholders['label_value:data-label'] = trim( esc_attr( strip_tags( str_replace( '> ', '>', $placeholders['label_value'] ) ) ) ); |
|
| 1534 | - $placeholders['label_value:esc_attr'] = esc_attr( $placeholders['label_value'] ); |
|
| 1533 | + $placeholders[ 'label_value:data-label' ] = trim( esc_attr( strip_tags( str_replace( '> ', '>', $placeholders[ 'label_value' ] ) ) ) ); |
|
| 1534 | + $placeholders[ 'label_value:esc_attr' ] = esc_attr( $placeholders[ 'label_value' ] ); |
|
| 1535 | 1535 | |
| 1536 | - if ( empty( $placeholders['label'] ) && ! empty( $placeholders['label_value'] ) ){ |
|
| 1537 | - $placeholders['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
| 1536 | + if ( empty( $placeholders[ 'label' ] ) && ! empty( $placeholders[ 'label_value' ] ) ) { |
|
| 1537 | + $placeholders[ 'label' ] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
| 1538 | 1538 | } |
| 1539 | 1539 | |
| 1540 | 1540 | /** |
@@ -1545,7 +1545,7 @@ discard block |
||
| 1545 | 1545 | * @since 2.0 |
| 1546 | 1546 | * @param \GV\Template_Context $context The context. |
| 1547 | 1547 | */ |
| 1548 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args, $context ); |
|
| 1548 | + $html = apply_filters( 'gravityview/field_output/pre_html', $args[ 'markup' ], $args, $context ); |
|
| 1549 | 1549 | |
| 1550 | 1550 | /** |
| 1551 | 1551 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
@@ -1572,7 +1572,7 @@ discard block |
||
| 1572 | 1572 | foreach ( $placeholders as $tag => $value ) { |
| 1573 | 1573 | |
| 1574 | 1574 | // If the tag doesn't exist just skip it |
| 1575 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
| 1575 | + if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ) { |
|
| 1576 | 1576 | continue; |
| 1577 | 1577 | } |
| 1578 | 1578 | |