@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | function load() { |
| 136 | 136 | |
| 137 | 137 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 138 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 138 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 139 | 139 | |
| 140 | 140 | // Don't display an embedded form when editing an entry |
| 141 | 141 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | add_action( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
| 146 | 146 | add_action( 'admin_init', array( $this, 'prevent_maybe_process_form' ), 8 ); |
| 147 | 147 | |
| 148 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 148 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 149 | 149 | |
| 150 | 150 | add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 ); |
| 151 | 151 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 157 | 157 | |
| 158 | 158 | // Add fields expected by GFFormDisplay::validate() |
| 159 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 159 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 160 | 160 | |
| 161 | 161 | // Fix multiselect value for GF 2.2 |
| 162 | 162 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | * @return void |
| 174 | 174 | */ |
| 175 | 175 | public function prevent_render_form() { |
| 176 | - if( $this->is_edit_entry() ) { |
|
| 177 | - if( 'wp_head' === current_filter() ) { |
|
| 176 | + if ( $this->is_edit_entry() ) { |
|
| 177 | + if ( 'wp_head' === current_filter() ) { |
|
| 178 | 178 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 179 | 179 | } else { |
| 180 | 180 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -189,17 +189,17 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function prevent_maybe_process_form() { |
| 191 | 191 | |
| 192 | - if( ! $this->is_edit_entry_submission() ) { |
|
| 192 | + if ( ! $this->is_edit_entry_submission() ) { |
|
| 193 | 193 | return; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' ); |
| 197 | 197 | |
| 198 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 199 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 198 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 199 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 200 | 200 | |
| 201 | - remove_action( 'admin_init', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 202 | - remove_action( 'admin_init', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 201 | + remove_action( 'admin_init', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 202 | + remove_action( 'admin_init', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | $is_edit_entry = |
| 212 | 212 | ( GravityView_frontend::is_single_entry() || gravityview()->request->is_entry() ) |
| 213 | - && ( ! empty( $_GET['edit'] ) ); |
|
| 213 | + && ( ! empty( $_GET[ 'edit' ] ) ); |
|
| 214 | 214 | |
| 215 | 215 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 216 | 216 | } |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @return boolean |
| 222 | 222 | */ |
| 223 | 223 | public function is_edit_entry_submission() { |
| 224 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 224 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -234,16 +234,16 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | |
| 236 | 236 | $entries = $gravityview_view->getEntries(); |
| 237 | - self::$original_entry = $entries[0]; |
|
| 238 | - $this->entry = $entries[0]; |
|
| 237 | + self::$original_entry = $entries[ 0 ]; |
|
| 238 | + $this->entry = $entries[ 0 ]; |
|
| 239 | 239 | |
| 240 | - self::$original_form = GFAPI::get_form( $this->entry['form_id'] ); |
|
| 240 | + self::$original_form = GFAPI::get_form( $this->entry[ 'form_id' ] ); |
|
| 241 | 241 | $this->form = self::$original_form; |
| 242 | - $this->form_id = $this->entry['form_id']; |
|
| 242 | + $this->form_id = $this->entry[ 'form_id' ]; |
|
| 243 | 243 | $this->view_id = $gravityview_view->getViewId(); |
| 244 | 244 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
| 245 | 245 | |
| 246 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 246 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | private function print_scripts() { |
| 303 | 303 | $gravityview_view = GravityView_View::getInstance(); |
| 304 | 304 | |
| 305 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 305 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 306 | 306 | |
| 307 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
| 307 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
| 308 | 308 | |
| 309 | 309 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
| 310 | 310 | |
@@ -323,19 +323,19 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | private function process_save( $gv_data ) { |
| 325 | 325 | |
| 326 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 326 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 327 | 327 | return; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | // Make sure the entry, view, and form IDs are all correct |
| 331 | 331 | $valid = $this->verify_nonce(); |
| 332 | 332 | |
| 333 | - if ( !$valid ) { |
|
| 333 | + if ( ! $valid ) { |
|
| 334 | 334 | gravityview()->log->error( 'Nonce validation failed.' ); |
| 335 | 335 | return; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 338 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 339 | 339 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
| 340 | 340 | return; |
| 341 | 341 | } |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | $this->validate(); |
| 348 | 348 | |
| 349 | - if( $this->is_valid ) { |
|
| 349 | + if ( $this->is_valid ) { |
|
| 350 | 350 | |
| 351 | 351 | gravityview()->log->debug( 'Submission is valid.' ); |
| 352 | 352 | |
@@ -358,15 +358,15 @@ discard block |
||
| 358 | 358 | /** |
| 359 | 359 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 360 | 360 | */ |
| 361 | - unset( $_GET['page'] ); |
|
| 361 | + unset( $_GET[ 'page' ] ); |
|
| 362 | 362 | |
| 363 | - $date_created = $this->entry['date_created']; |
|
| 363 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | 366 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 367 | 367 | * @since 1.17.2 |
| 368 | 368 | */ |
| 369 | - unset( $this->entry['date_created'] ); |
|
| 369 | + unset( $this->entry[ 'date_created' ] ); |
|
| 370 | 370 | |
| 371 | 371 | /** |
| 372 | 372 | * @action `gravityview/edit_entry/before_update` Perform an action before the entry has been updated using Edit Entry |
@@ -376,14 +376,14 @@ discard block |
||
| 376 | 376 | * @param GravityView_Edit_Entry_Render $this This object |
| 377 | 377 | * @param GravityView_View_Data $gv_data The View data |
| 378 | 378 | */ |
| 379 | - do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data ); |
|
| 379 | + do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 380 | 380 | |
| 381 | 381 | GFFormsModel::save_lead( $form, $this->entry ); |
| 382 | 382 | |
| 383 | 383 | // Delete the values for hidden inputs |
| 384 | 384 | $this->unset_hidden_field_values(); |
| 385 | 385 | |
| 386 | - $this->entry['date_created'] = $date_created; |
|
| 386 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 387 | 387 | |
| 388 | 388 | // Process calculation fields |
| 389 | 389 | $this->update_calculation_fields(); |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * @param GravityView_Edit_Entry_Render $this This object |
| 409 | 409 | * @param GravityView_View_Data $gv_data The View data |
| 410 | 410 | */ |
| 411 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
| 411 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 412 | 412 | |
| 413 | 413 | } else { |
| 414 | 414 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -444,10 +444,10 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 446 | 446 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 447 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 447 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 448 | 448 | } else { |
| 449 | 449 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 450 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 450 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -465,11 +465,11 @@ discard block |
||
| 465 | 465 | |
| 466 | 466 | $empty_value = $field->get_value_save_entry( |
| 467 | 467 | is_array( $field->get_entry_inputs() ) ? array() : '', |
| 468 | - $this->form, '', $this->entry['id'], $this->entry |
|
| 468 | + $this->form, '', $this->entry[ 'id' ], $this->entry |
|
| 469 | 469 | ); |
| 470 | 470 | |
| 471 | 471 | if ( $field->has_calculation() ) { |
| 472 | - $this->unset_hidden_calculations[] = $field->id; // Unset |
|
| 472 | + $this->unset_hidden_calculations[ ] = $field->id; // Unset |
|
| 473 | 473 | $empty_value = ''; |
| 474 | 474 | } |
| 475 | 475 | |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | private function preset_approval_fields() { |
| 499 | 499 | $has_approved_field = false; |
| 500 | 500 | |
| 501 | - foreach ( self::$original_form['fields'] as $field ) { |
|
| 501 | + foreach ( self::$original_form[ 'fields' ] as $field ) { |
|
| 502 | 502 | if ( $field->gravityview_approved ) { |
| 503 | 503 | $has_approved_field = true; |
| 504 | 504 | break; |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | |
| 512 | 512 | $is_field_hidden = true; |
| 513 | 513 | |
| 514 | - foreach ( $this->form['fields'] as $field ) { |
|
| 514 | + foreach ( $this->form[ 'fields' ] as $field ) { |
|
| 515 | 515 | if ( $field->gravityview_approved ) { |
| 516 | 516 | $is_field_hidden = false; |
| 517 | 517 | break; |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | |
| 537 | 537 | remove_filter( 'gravityview/approve_entries/update_unapproved_meta', array( $this, 'prevent_update_unapproved_meta' ), 9 ); |
| 538 | 538 | |
| 539 | - if ( ! $value = gform_get_meta( $entry['id'], 'is_approved' ) ) { |
|
| 539 | + if ( ! $value = gform_get_meta( $entry[ 'id' ], 'is_approved' ) ) { |
|
| 540 | 540 | |
| 541 | 541 | $value = GravityView_Entry_Approval_Status::UNAPPROVED; |
| 542 | 542 | |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | /** No file is being uploaded. */ |
| 604 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 604 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 605 | 605 | /** So return the original upload, with $value as backup (it can be empty during edit form rendering) */ |
| 606 | 606 | return rgar( $entry, $input_id, $value ); |
| 607 | 607 | } |
@@ -619,11 +619,11 @@ discard block |
||
| 619 | 619 | * @return mixed |
| 620 | 620 | */ |
| 621 | 621 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 622 | - if( ! $this->is_edit_entry() ) { |
|
| 622 | + if ( ! $this->is_edit_entry() ) { |
|
| 623 | 623 | return $plupload_init; |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 626 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 627 | 627 | |
| 628 | 628 | return $plupload_init; |
| 629 | 629 | } |
@@ -638,26 +638,26 @@ discard block |
||
| 638 | 638 | $form = $this->filter_conditional_logic( $this->form ); |
| 639 | 639 | |
| 640 | 640 | /** @type GF_Field $field */ |
| 641 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 641 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 642 | 642 | |
| 643 | 643 | /** |
| 644 | 644 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 645 | 645 | * @since 1.16.3 |
| 646 | 646 | */ |
| 647 | - if( $field->has_calculation() ) { |
|
| 648 | - unset( $form['fields'][ $k ] ); |
|
| 647 | + if ( $field->has_calculation() ) { |
|
| 648 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | $field->adminOnly = false; |
| 652 | 652 | |
| 653 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 654 | - foreach( $field->inputs as $key => $input ) { |
|
| 655 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 653 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 654 | + foreach ( $field->inputs as $key => $input ) { |
|
| 655 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 656 | 656 | } |
| 657 | 657 | } |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 660 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 661 | 661 | |
| 662 | 662 | return $form; |
| 663 | 663 | } |
@@ -669,14 +669,14 @@ discard block |
||
| 669 | 669 | $update = false; |
| 670 | 670 | |
| 671 | 671 | // get the most up to date entry values |
| 672 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 672 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 673 | 673 | |
| 674 | 674 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 675 | 675 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 676 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
| 676 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
| 677 | 677 | } else { |
| 678 | 678 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 679 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
| 679 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | |
@@ -693,24 +693,24 @@ discard block |
||
| 693 | 693 | $inputs = $field->get_entry_inputs(); |
| 694 | 694 | if ( is_array( $inputs ) ) { |
| 695 | 695 | foreach ( $inputs as $input ) { |
| 696 | - list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
|
| 696 | + list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 ); |
|
| 697 | 697 | |
| 698 | 698 | if ( 'product' === $field->type ) { |
| 699 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 699 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
| 700 | 700 | |
| 701 | 701 | // Only allow quantity to be set if it's allowed to be edited |
| 702 | 702 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
| 703 | 703 | } else { // otherwise set to what it previously was |
| 704 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
| 704 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
| 705 | 705 | } |
| 706 | 706 | } else { |
| 707 | 707 | // Set to what it previously was if it's not editable |
| 708 | 708 | if ( ! in_array( $field_id, $allowed_fields ) ) { |
| 709 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
| 709 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
| 710 | 710 | } |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
| 713 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
| 714 | 714 | } |
| 715 | 715 | } else { |
| 716 | 716 | // Set to what it previously was if it's not editable |
@@ -750,19 +750,19 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | $input_name = 'input_' . $field_id; |
| 752 | 752 | |
| 753 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 753 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 754 | 754 | |
| 755 | 755 | // We have a new image |
| 756 | 756 | |
| 757 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 757 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 758 | 758 | |
| 759 | 759 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 760 | 760 | $ary = stripslashes_deep( $ary ); |
| 761 | 761 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 762 | 762 | |
| 763 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 764 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 765 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 763 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 764 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 765 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 766 | 766 | |
| 767 | 767 | $image_meta = array( |
| 768 | 768 | 'post_excerpt' => $img_caption, |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | |
| 772 | 772 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 773 | 773 | if ( ! empty( $img_title ) ) { |
| 774 | - $image_meta['post_title'] = $img_title; |
|
| 774 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | /** |
@@ -829,15 +829,15 @@ discard block |
||
| 829 | 829 | */ |
| 830 | 830 | private function maybe_update_post_fields( $form ) { |
| 831 | 831 | |
| 832 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 832 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 833 | 833 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
| 834 | 834 | return; |
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - $post_id = $this->entry['post_id']; |
|
| 837 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 838 | 838 | |
| 839 | 839 | // Security check |
| 840 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 840 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 841 | 841 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
| 842 | 842 | return; |
| 843 | 843 | } |
@@ -850,25 +850,25 @@ discard block |
||
| 850 | 850 | |
| 851 | 851 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 852 | 852 | |
| 853 | - if( ! $field ) { |
|
| 853 | + if ( ! $field ) { |
|
| 854 | 854 | continue; |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 857 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 858 | 858 | |
| 859 | 859 | // Get the value of the field, including $_POSTed value |
| 860 | 860 | $value = RGFormsModel::get_field_value( $field ); |
| 861 | 861 | |
| 862 | 862 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 863 | 863 | $entry_tmp = $this->entry; |
| 864 | - $entry_tmp["{$field_id}"] = $value; |
|
| 864 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 865 | 865 | |
| 866 | - switch( $field->type ) { |
|
| 866 | + switch ( $field->type ) { |
|
| 867 | 867 | |
| 868 | 868 | case 'post_title': |
| 869 | 869 | $post_title = $value; |
| 870 | 870 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
| 871 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 871 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 872 | 872 | } |
| 873 | 873 | $updated_post->post_title = $post_title; |
| 874 | 874 | $updated_post->post_name = $post_title; |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | case 'post_content': |
| 879 | 879 | $post_content = $value; |
| 880 | 880 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
| 881 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 881 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 882 | 882 | } |
| 883 | 883 | $updated_post->post_content = $post_content; |
| 884 | 884 | unset( $post_content ); |
@@ -896,11 +896,11 @@ discard block |
||
| 896 | 896 | $value = $value[ $field_id ]; |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 899 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 900 | 900 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | - $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
| 903 | + $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
| 904 | 904 | |
| 905 | 905 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
| 906 | 906 | break; |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | // update entry after |
| 915 | - $this->entry["{$field_id}"] = $value; |
|
| 915 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 916 | 916 | |
| 917 | 917 | $update_entry = true; |
| 918 | 918 | |
@@ -921,11 +921,11 @@ discard block |
||
| 921 | 921 | |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - if( $update_entry ) { |
|
| 924 | + if ( $update_entry ) { |
|
| 925 | 925 | |
| 926 | 926 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 927 | 927 | |
| 928 | - if( is_wp_error( $return_entry ) ) { |
|
| 928 | + if ( is_wp_error( $return_entry ) ) { |
|
| 929 | 929 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
| 930 | 930 | } else { |
| 931 | 931 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | |
| 936 | 936 | $return_post = wp_update_post( $updated_post, true ); |
| 937 | 937 | |
| 938 | - if( is_wp_error( $return_post ) ) { |
|
| 938 | + if ( is_wp_error( $return_post ) ) { |
|
| 939 | 939 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 940 | 940 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
| 941 | 941 | } else { |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 970 | 970 | |
| 971 | 971 | // replace conditional shortcodes |
| 972 | - if( $do_shortcode ) { |
|
| 972 | + if ( $do_shortcode ) { |
|
| 973 | 973 | $output = do_shortcode( $output ); |
| 974 | 974 | } |
| 975 | 975 | |
@@ -988,19 +988,19 @@ discard block |
||
| 988 | 988 | */ |
| 989 | 989 | private function after_update() { |
| 990 | 990 | |
| 991 | - do_action( 'gform_after_update_entry', self::$original_form, $this->entry['id'], self::$original_entry ); |
|
| 992 | - do_action( "gform_after_update_entry_{$this->form['id']}", self::$original_form, $this->entry['id'], self::$original_entry ); |
|
| 991 | + do_action( 'gform_after_update_entry', self::$original_form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 992 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", self::$original_form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 993 | 993 | |
| 994 | 994 | // Re-define the entry now that we've updated it. |
| 995 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 995 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 996 | 996 | |
| 997 | 997 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
| 998 | 998 | |
| 999 | 999 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 1000 | 1000 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 1001 | 1001 | // we have just updated. |
| 1002 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 1003 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 1002 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 1003 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | } |
| 1006 | 1006 | |
@@ -1010,11 +1010,11 @@ discard block |
||
| 1010 | 1010 | * @since develop |
| 1011 | 1011 | */ |
| 1012 | 1012 | if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) { |
| 1013 | - $feeds = GFAPI::get_feeds( null, $entry['form_id'] ); |
|
| 1013 | + $feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] ); |
|
| 1014 | 1014 | if ( ! is_wp_error( $feeds ) ) { |
| 1015 | 1015 | $registered_feeds = array(); |
| 1016 | 1016 | foreach ( GFAddOn::get_registered_addons() as $registered_feed ) { |
| 1017 | - if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
| 1017 | + if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
| 1018 | 1018 | if ( method_exists( $registered_feed, 'get_instance' ) ) { |
| 1019 | 1019 | $registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) ); |
| 1020 | 1020 | $registered_feeds[ $registered_feed->get_slug() ] = $registered_feed; |
@@ -1022,8 +1022,8 @@ discard block |
||
| 1022 | 1022 | } |
| 1023 | 1023 | } |
| 1024 | 1024 | foreach ( $feeds as $feed ) { |
| 1025 | - if ( in_array( $feed['id'], $allowed_feeds ) ) { |
|
| 1026 | - if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) { |
|
| 1025 | + if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) { |
|
| 1026 | + if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) { |
|
| 1027 | 1027 | $returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form ); |
| 1028 | 1028 | if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) { |
| 1029 | 1029 | $entry = $returned_entry; |
@@ -1051,9 +1051,9 @@ discard block |
||
| 1051 | 1051 | |
| 1052 | 1052 | $view = \GV\View::by_id( $this->view_id ); |
| 1053 | 1053 | |
| 1054 | - if( $view->settings->get( 'edit_locking' ) ) { |
|
| 1054 | + if ( $view->settings->get( 'edit_locking' ) ) { |
|
| 1055 | 1055 | $locking = new GravityView_Edit_Entry_Locking(); |
| 1056 | - $locking->maybe_lock_object( $this->entry['id'] ); |
|
| 1056 | + $locking->maybe_lock_object( $this->entry[ 'id' ] ); |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | ?> |
@@ -1066,7 +1066,7 @@ discard block |
||
| 1066 | 1066 | |
| 1067 | 1067 | <div class="gv-edit-entry-wrapper"><?php |
| 1068 | 1068 | |
| 1069 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 1069 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 1070 | 1070 | |
| 1071 | 1071 | /** |
| 1072 | 1072 | * Fixes weird wpautop() issue |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 1083 | 1083 | * @param GravityView_Edit_Entry_Render $this This object |
| 1084 | 1084 | */ |
| 1085 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 1085 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 1086 | 1086 | |
| 1087 | 1087 | echo esc_attr( $edit_entry_title ); |
| 1088 | 1088 | ?></span> |
@@ -1159,18 +1159,18 @@ discard block |
||
| 1159 | 1159 | */ |
| 1160 | 1160 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1161 | 1161 | |
| 1162 | - $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
|
| 1162 | + $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels[ 'submit' ]; |
|
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
| 1166 | 1166 | |
| 1167 | - if( ! $this->is_valid ){ |
|
| 1167 | + if ( ! $this->is_valid ) { |
|
| 1168 | 1168 | |
| 1169 | 1169 | // Keeping this compatible with Gravity Forms. |
| 1170 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 1171 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 1170 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 1171 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 1172 | 1172 | |
| 1173 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 1173 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 1174 | 1174 | |
| 1175 | 1175 | } elseif ( false === $this->is_paged_submitted ) { |
| 1176 | 1176 | // Paged form that hasn't been submitted on the last page yet |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | * @param int $view_id View ID |
| 1184 | 1184 | * @param array $entry Gravity Forms entry array |
| 1185 | 1185 | */ |
| 1186 | - $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message , $this->view_id, $this->entry ); |
|
| 1186 | + $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message, $this->view_id, $this->entry ); |
|
| 1187 | 1187 | |
| 1188 | 1188 | echo GVCommon::generate_notice( $message ); |
| 1189 | 1189 | } else { |
@@ -1195,23 +1195,23 @@ discard block |
||
| 1195 | 1195 | |
| 1196 | 1196 | case '0': |
| 1197 | 1197 | $redirect_url = $back_link; |
| 1198 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1198 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
| 1199 | 1199 | break; |
| 1200 | 1200 | |
| 1201 | 1201 | case '1': |
| 1202 | 1202 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
| 1203 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
| 1203 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
| 1204 | 1204 | break; |
| 1205 | 1205 | |
| 1206 | 1206 | case '2': |
| 1207 | 1207 | $redirect_url = $edit_redirect_url; |
| 1208 | 1208 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
| 1209 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
| 1209 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
| 1210 | 1210 | break; |
| 1211 | 1211 | |
| 1212 | 1212 | case '': |
| 1213 | 1213 | default: |
| 1214 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1214 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
| 1215 | 1215 | break; |
| 1216 | 1216 | } |
| 1217 | 1217 | |
@@ -1227,7 +1227,7 @@ discard block |
||
| 1227 | 1227 | * @param array $entry Gravity Forms entry array |
| 1228 | 1228 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 1229 | 1229 | */ |
| 1230 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 1230 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 1231 | 1231 | |
| 1232 | 1232 | echo GVCommon::generate_notice( $message ); |
| 1233 | 1233 | } |
@@ -1249,8 +1249,8 @@ discard block |
||
| 1249 | 1249 | */ |
| 1250 | 1250 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 1251 | 1251 | |
| 1252 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1253 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 1252 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1253 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1254 | 1254 | add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
| 1255 | 1255 | add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
| 1256 | 1256 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
@@ -1259,14 +1259,14 @@ discard block |
||
| 1259 | 1259 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1260 | 1260 | |
| 1261 | 1261 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1262 | - unset( $_GET['page'] ); |
|
| 1262 | + unset( $_GET[ 'page' ] ); |
|
| 1263 | 1263 | |
| 1264 | 1264 | $this->show_next_button = false; |
| 1265 | 1265 | $this->show_previous_button = false; |
| 1266 | 1266 | |
| 1267 | 1267 | // TODO: Verify multiple-page forms |
| 1268 | 1268 | if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) { |
| 1269 | - if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form['id'], 0 ) ) ) { |
|
| 1269 | + if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form[ 'id' ], 0 ) ) ) { |
|
| 1270 | 1270 | |
| 1271 | 1271 | $labels = array( |
| 1272 | 1272 | 'cancel' => __( 'Cancel', 'gravityview' ), |
@@ -1285,20 +1285,20 @@ discard block |
||
| 1285 | 1285 | */ |
| 1286 | 1286 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1287 | 1287 | |
| 1288 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
|
| 1289 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true; |
|
| 1288 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form; |
|
| 1289 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true; |
|
| 1290 | 1290 | |
| 1291 | - if ( \GV\Utils::_POST( 'save' ) === $labels['next'] ) { |
|
| 1291 | + if ( \GV\Utils::_POST( 'save' ) === $labels[ 'next' ] ) { |
|
| 1292 | 1292 | $last_page = \GFFormDisplay::get_max_page_number( $this->form ); |
| 1293 | 1293 | |
| 1294 | 1294 | while ( ++$page_number < $last_page && RGFormsModel::is_page_hidden( $this->form, $page_number, \GV\Utils::_POST( 'gform_field_values' ) ) ) { |
| 1295 | 1295 | } // Advance to next visible page |
| 1296 | - } elseif ( \GV\Utils::_POST( 'save' ) === $labels['previous'] ) { |
|
| 1296 | + } elseif ( \GV\Utils::_POST( 'save' ) === $labels[ 'previous' ] ) { |
|
| 1297 | 1297 | while ( --$page_number > 1 && RGFormsModel::is_page_hidden( $this->form, $page_number, \GV\Utils::_POST( 'gform_field_values' ) ) ) { |
| 1298 | 1298 | } // Advance to next visible page |
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | - GFFormDisplay::$submission[ $this->form['id'] ]['page_number'] = $page_number; |
|
| 1301 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number; |
|
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | 1304 | if ( ( $page_number = intval( $page_number ) ) < 2 ) { |
@@ -1324,7 +1324,7 @@ discard block |
||
| 1324 | 1324 | |
| 1325 | 1325 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1326 | 1326 | |
| 1327 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1327 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1328 | 1328 | |
| 1329 | 1329 | ob_get_clean(); |
| 1330 | 1330 | |
@@ -1352,7 +1352,7 @@ discard block |
||
| 1352 | 1352 | * @return string |
| 1353 | 1353 | */ |
| 1354 | 1354 | public function render_form_buttons() { |
| 1355 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1355 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | |
@@ -1371,15 +1371,15 @@ discard block |
||
| 1371 | 1371 | */ |
| 1372 | 1372 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1373 | 1373 | |
| 1374 | - if( $form['id'] != $this->form_id ) { |
|
| 1374 | + if ( $form[ 'id' ] != $this->form_id ) { |
|
| 1375 | 1375 | return $form; |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1379 | - if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) { |
|
| 1379 | + if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) { |
|
| 1380 | 1380 | $form = $this->form_after_validation; |
| 1381 | 1381 | } else { |
| 1382 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1382 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1383 | 1383 | } |
| 1384 | 1384 | |
| 1385 | 1385 | $form = $this->filter_conditional_logic( $form ); |
@@ -1387,8 +1387,8 @@ discard block |
||
| 1387 | 1387 | $form = $this->prefill_conditional_logic( $form ); |
| 1388 | 1388 | |
| 1389 | 1389 | // for now we don't support Save and Continue feature. |
| 1390 | - if( ! self::$supports_save_and_continue ) { |
|
| 1391 | - unset( $form['save'] ); |
|
| 1390 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1391 | + unset( $form[ 'save' ] ); |
|
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | 1394 | $form = $this->unselect_default_values( $form ); |
@@ -1411,31 +1411,31 @@ discard block |
||
| 1411 | 1411 | */ |
| 1412 | 1412 | public function verify_user_can_edit_post( $field_content = '', $field = null, $value = '', $lead_id = 0, $form_id = 0 ) { |
| 1413 | 1413 | |
| 1414 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
| 1414 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
| 1415 | 1415 | return $field_content; |
| 1416 | 1416 | } |
| 1417 | 1417 | |
| 1418 | 1418 | $message = null; |
| 1419 | 1419 | |
| 1420 | 1420 | // First, make sure they have the capability to edit the post. |
| 1421 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1421 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1422 | 1422 | |
| 1423 | 1423 | /** |
| 1424 | 1424 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1425 | 1425 | * @param string $message The existing "You don't have permission..." text |
| 1426 | 1426 | */ |
| 1427 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1427 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1428 | 1428 | |
| 1429 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1429 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1430 | 1430 | /** |
| 1431 | 1431 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1432 | 1432 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1433 | 1433 | */ |
| 1434 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1434 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1435 | 1435 | } |
| 1436 | 1436 | |
| 1437 | - if( $message ) { |
|
| 1438 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1437 | + if ( $message ) { |
|
| 1438 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1439 | 1439 | } |
| 1440 | 1440 | |
| 1441 | 1441 | return $field_content; |
@@ -1459,8 +1459,8 @@ discard block |
||
| 1459 | 1459 | |
| 1460 | 1460 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1461 | 1461 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1462 | - if( |
|
| 1463 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1462 | + if ( |
|
| 1463 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1464 | 1464 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1465 | 1465 | && ! GFCommon::is_product_field( $field->type ) |
| 1466 | 1466 | || ! empty( $field_content ) |
@@ -1480,7 +1480,7 @@ discard block |
||
| 1480 | 1480 | $return = null; |
| 1481 | 1481 | |
| 1482 | 1482 | /** @var GravityView_Field $gv_field */ |
| 1483 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1483 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1484 | 1484 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1485 | 1485 | } else { |
| 1486 | 1486 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1489,7 +1489,7 @@ discard block |
||
| 1489 | 1489 | // If there was output, it's an error |
| 1490 | 1490 | $warnings = ob_get_clean(); |
| 1491 | 1491 | |
| 1492 | - if( !empty( $warnings ) ) { |
|
| 1492 | + if ( ! empty( $warnings ) ) { |
|
| 1493 | 1493 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
| 1494 | 1494 | } |
| 1495 | 1495 | |
@@ -1514,7 +1514,7 @@ discard block |
||
| 1514 | 1514 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1515 | 1515 | |
| 1516 | 1516 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1517 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1517 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1518 | 1518 | |
| 1519 | 1519 | $field_value = array(); |
| 1520 | 1520 | |
@@ -1523,10 +1523,10 @@ discard block |
||
| 1523 | 1523 | |
| 1524 | 1524 | foreach ( (array)$field->inputs as $input ) { |
| 1525 | 1525 | |
| 1526 | - $input_id = strval( $input['id'] ); |
|
| 1526 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1527 | 1527 | |
| 1528 | 1528 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1529 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1529 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1530 | 1530 | $allow_pre_populated = false; |
| 1531 | 1531 | } |
| 1532 | 1532 | |
@@ -1534,7 +1534,7 @@ discard block |
||
| 1534 | 1534 | |
| 1535 | 1535 | $pre_value = $field->get_value_submission( array(), false ); |
| 1536 | 1536 | |
| 1537 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1537 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1538 | 1538 | |
| 1539 | 1539 | } else { |
| 1540 | 1540 | |
@@ -1545,13 +1545,13 @@ discard block |
||
| 1545 | 1545 | |
| 1546 | 1546 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1547 | 1547 | // or pre-populated value if not empty and set to override saved value |
| 1548 | - $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; |
|
| 1548 | + $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; |
|
| 1549 | 1549 | |
| 1550 | 1550 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1551 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1551 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1552 | 1552 | $categories = array(); |
| 1553 | 1553 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1554 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1554 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1555 | 1555 | } |
| 1556 | 1556 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1557 | 1557 | } |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | * @param GF_Field $field Gravity Forms field object |
| 1580 | 1580 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1581 | 1581 | */ |
| 1582 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1582 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1583 | 1583 | |
| 1584 | 1584 | return $field_value; |
| 1585 | 1585 | } |
@@ -1596,12 +1596,12 @@ discard block |
||
| 1596 | 1596 | */ |
| 1597 | 1597 | public function gform_pre_validation( $form ) { |
| 1598 | 1598 | |
| 1599 | - if( ! $this->verify_nonce() ) { |
|
| 1599 | + if ( ! $this->verify_nonce() ) { |
|
| 1600 | 1600 | return $form; |
| 1601 | 1601 | } |
| 1602 | 1602 | |
| 1603 | 1603 | // Fix PHP warning regarding undefined index. |
| 1604 | - foreach ( $form['fields'] as &$field) { |
|
| 1604 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1605 | 1605 | |
| 1606 | 1606 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1607 | 1607 | // expects certain field array items to be set. |
@@ -1609,7 +1609,7 @@ discard block |
||
| 1609 | 1609 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1610 | 1610 | } |
| 1611 | 1611 | |
| 1612 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1612 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1613 | 1613 | |
| 1614 | 1614 | /** |
| 1615 | 1615 | * 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. |
@@ -1623,26 +1623,26 @@ discard block |
||
| 1623 | 1623 | // Set the previous value |
| 1624 | 1624 | $entry = $this->get_entry(); |
| 1625 | 1625 | |
| 1626 | - $input_name = 'input_'.$field->id; |
|
| 1627 | - $form_id = $form['id']; |
|
| 1626 | + $input_name = 'input_' . $field->id; |
|
| 1627 | + $form_id = $form[ 'id' ]; |
|
| 1628 | 1628 | |
| 1629 | 1629 | $value = NULL; |
| 1630 | 1630 | |
| 1631 | 1631 | // Use the previous entry value as the default. |
| 1632 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1632 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1633 | 1633 | $value = $entry[ $field->id ]; |
| 1634 | 1634 | } |
| 1635 | 1635 | |
| 1636 | 1636 | // If this is a single upload file |
| 1637 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1638 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1639 | - $value = $file_path['url']; |
|
| 1637 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1638 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1639 | + $value = $file_path[ 'url' ]; |
|
| 1640 | 1640 | |
| 1641 | 1641 | } else { |
| 1642 | 1642 | |
| 1643 | 1643 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1644 | 1644 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1645 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1645 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1646 | 1646 | |
| 1647 | 1647 | } |
| 1648 | 1648 | |
@@ -1652,7 +1652,7 @@ discard block |
||
| 1652 | 1652 | if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
| 1653 | 1653 | $value = empty( $value ) ? '[]' : $value; |
| 1654 | 1654 | $value = stripslashes_deep( $value ); |
| 1655 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array() ); |
|
| 1655 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1656 | 1656 | } else if ( GFCommon::is_json( $value ) ) { |
| 1657 | 1657 | // Existing file; let GF derive the value from the `$_gf_uploaded_files` object (see `\GF_Field_FileUpload::get_multifile_value()`) |
| 1658 | 1658 | global $_gf_uploaded_files; |
@@ -1672,8 +1672,8 @@ discard block |
||
| 1672 | 1672 | |
| 1673 | 1673 | case 'number': |
| 1674 | 1674 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1675 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1676 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1675 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1676 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1677 | 1677 | } |
| 1678 | 1678 | break; |
| 1679 | 1679 | } |
@@ -1710,7 +1710,7 @@ discard block |
||
| 1710 | 1710 | * You can enter whatever you want! |
| 1711 | 1711 | * We try validating, and customize the results using `self::custom_validation()` |
| 1712 | 1712 | */ |
| 1713 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1713 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1714 | 1714 | |
| 1715 | 1715 | // Needed by the validate funtion |
| 1716 | 1716 | $failed_validation_page = NULL; |
@@ -1718,14 +1718,14 @@ discard block |
||
| 1718 | 1718 | |
| 1719 | 1719 | // Prevent entry limit from running when editing an entry, also |
| 1720 | 1720 | // prevent form scheduling from preventing editing |
| 1721 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1721 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1722 | 1722 | |
| 1723 | 1723 | // Hide fields depending on Edit Entry settings |
| 1724 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1724 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1725 | 1725 | |
| 1726 | 1726 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1727 | 1727 | |
| 1728 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1728 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | 1731 | |
@@ -1753,7 +1753,7 @@ discard block |
||
| 1753 | 1753 | |
| 1754 | 1754 | $gv_valid = true; |
| 1755 | 1755 | |
| 1756 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1756 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1757 | 1757 | $value = RGFormsModel::get_field_value( $field ); |
| 1758 | 1758 | $field_type = RGFormsModel::get_input_type( $field ); |
| 1759 | 1759 | $is_required = ! empty( $field->isRequired ); |
@@ -1761,7 +1761,7 @@ discard block |
||
| 1761 | 1761 | |
| 1762 | 1762 | // Manually validate required fields as they can be skipped be skipped by GF's validation |
| 1763 | 1763 | // This can happen when the field is considered "hidden" (see `GFFormDisplay::validate`) due to unmet conditional logic |
| 1764 | - if ( $is_required && !$failed_validation && rgblank( $value ) ) { |
|
| 1764 | + if ( $is_required && ! $failed_validation && rgblank( $value ) ) { |
|
| 1765 | 1765 | $field->failed_validation = true; |
| 1766 | 1766 | $field->validation_message = esc_html__( 'This field is required.', 'gravityview' ); |
| 1767 | 1767 | |
@@ -1785,7 +1785,7 @@ discard block |
||
| 1785 | 1785 | if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
| 1786 | 1786 | $input_name = 'input_' . $field->id; |
| 1787 | 1787 | //uploaded |
| 1788 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1788 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1789 | 1789 | |
| 1790 | 1790 | //existent |
| 1791 | 1791 | $entry = $this->get_entry(); |
@@ -1804,7 +1804,7 @@ discard block |
||
| 1804 | 1804 | $gv_valid = false; |
| 1805 | 1805 | |
| 1806 | 1806 | // in case of error make sure the newest upload files are removed from the upload input |
| 1807 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1807 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1808 | 1808 | } |
| 1809 | 1809 | } |
| 1810 | 1810 | |
@@ -1812,7 +1812,7 @@ discard block |
||
| 1812 | 1812 | } |
| 1813 | 1813 | |
| 1814 | 1814 | // This field has failed validation. |
| 1815 | - if( !empty( $field->failed_validation ) ) { |
|
| 1815 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1816 | 1816 | |
| 1817 | 1817 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
| 1818 | 1818 | |
@@ -1830,19 +1830,19 @@ discard block |
||
| 1830 | 1830 | } |
| 1831 | 1831 | |
| 1832 | 1832 | // You can't continue inside a switch, so we do it after. |
| 1833 | - if( empty( $field->failed_validation ) ) { |
|
| 1833 | + if ( empty( $field->failed_validation ) ) { |
|
| 1834 | 1834 | continue; |
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | 1837 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1838 | 1838 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1839 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1839 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1840 | 1840 | |
| 1841 | 1841 | $entry = $this->get_entry(); |
| 1842 | 1842 | |
| 1843 | 1843 | // If the value of the entry is the same as the stored value |
| 1844 | 1844 | // Then we can assume it's not a duplicate, it's the same. |
| 1845 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1845 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1846 | 1846 | //if value submitted was not changed, then don't validate |
| 1847 | 1847 | $field->failed_validation = false; |
| 1848 | 1848 | |
@@ -1855,7 +1855,7 @@ discard block |
||
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | 1857 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1858 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1858 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1859 | 1859 | unset( $field->validation_message ); |
| 1860 | 1860 | $field->failed_validation = false; |
| 1861 | 1861 | continue; |
@@ -1867,12 +1867,12 @@ discard block |
||
| 1867 | 1867 | |
| 1868 | 1868 | } |
| 1869 | 1869 | |
| 1870 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1870 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1871 | 1871 | |
| 1872 | 1872 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
| 1873 | 1873 | |
| 1874 | 1874 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1875 | - $this->form_after_validation = $validation_results['form']; |
|
| 1875 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1876 | 1876 | |
| 1877 | 1877 | return $validation_results; |
| 1878 | 1878 | } |
@@ -1885,7 +1885,7 @@ discard block |
||
| 1885 | 1885 | */ |
| 1886 | 1886 | public function get_entry() { |
| 1887 | 1887 | |
| 1888 | - if( empty( $this->entry ) ) { |
|
| 1888 | + if ( empty( $this->entry ) ) { |
|
| 1889 | 1889 | // Get the database value of the entry that's being edited |
| 1890 | 1890 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1891 | 1891 | } |
@@ -1917,10 +1917,10 @@ discard block |
||
| 1917 | 1917 | } |
| 1918 | 1918 | |
| 1919 | 1919 | // If edit tab not yet configured, show all fields |
| 1920 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1920 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1921 | 1921 | |
| 1922 | 1922 | // Hide fields depending on admin settings |
| 1923 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1923 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1924 | 1924 | |
| 1925 | 1925 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1926 | 1926 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1953,7 +1953,7 @@ discard block |
||
| 1953 | 1953 | */ |
| 1954 | 1954 | private function filter_fields( $fields, $configured_fields ) { |
| 1955 | 1955 | |
| 1956 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1956 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1957 | 1957 | return $fields; |
| 1958 | 1958 | } |
| 1959 | 1959 | |
@@ -1970,12 +1970,12 @@ discard block |
||
| 1970 | 1970 | |
| 1971 | 1971 | // Remove the fields that have calculation properties and keep them to be used later |
| 1972 | 1972 | // @since 1.16.2 |
| 1973 | - if( $field->has_calculation() ) { |
|
| 1974 | - $this->fields_with_calculation[] = $field; |
|
| 1973 | + if ( $field->has_calculation() ) { |
|
| 1974 | + $this->fields_with_calculation[ ] = $field; |
|
| 1975 | 1975 | // don't remove the calculation fields on form render. |
| 1976 | 1976 | } |
| 1977 | 1977 | |
| 1978 | - if( in_array( $field->type, $field_type_blocklist ) ) { |
|
| 1978 | + if ( in_array( $field->type, $field_type_blocklist ) ) { |
|
| 1979 | 1979 | unset( $fields[ $key ] ); |
| 1980 | 1980 | } |
| 1981 | 1981 | } |
@@ -2005,7 +2005,7 @@ discard block |
||
| 2005 | 2005 | continue; // Never include when no fields are configured |
| 2006 | 2006 | } |
| 2007 | 2007 | |
| 2008 | - $out_fields[] = $field; |
|
| 2008 | + $out_fields[ ] = $field; |
|
| 2009 | 2009 | } |
| 2010 | 2010 | |
| 2011 | 2011 | return array_values( $out_fields ); |
@@ -2016,8 +2016,8 @@ discard block |
||
| 2016 | 2016 | |
| 2017 | 2017 | /** @var GF_Field $field */ |
| 2018 | 2018 | foreach ( $fields as $field ) { |
| 2019 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 2020 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 2019 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 2020 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 2021 | 2021 | break; |
| 2022 | 2022 | } |
| 2023 | 2023 | |
@@ -2040,14 +2040,14 @@ discard block |
||
| 2040 | 2040 | |
| 2041 | 2041 | $return_field = $field; |
| 2042 | 2042 | |
| 2043 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 2043 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 2044 | 2044 | $return_field->label = ''; |
| 2045 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 2046 | - $return_field->label = $field_setting['custom_label']; |
|
| 2045 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 2046 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 2047 | 2047 | } |
| 2048 | 2048 | |
| 2049 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 2050 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 2049 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 2050 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 2051 | 2051 | } |
| 2052 | 2052 | |
| 2053 | 2053 | /** |
@@ -2085,16 +2085,16 @@ discard block |
||
| 2085 | 2085 | */ |
| 2086 | 2086 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 2087 | 2087 | |
| 2088 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 2089 | - foreach( $fields as $k => $field ) { |
|
| 2090 | - if( $field->adminOnly ) { |
|
| 2088 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 2089 | + foreach ( $fields as $k => $field ) { |
|
| 2090 | + if ( $field->adminOnly ) { |
|
| 2091 | 2091 | unset( $fields[ $k ] ); |
| 2092 | 2092 | } |
| 2093 | 2093 | } |
| 2094 | 2094 | return array_values( $fields ); |
| 2095 | 2095 | } |
| 2096 | 2096 | |
| 2097 | - foreach( $fields as &$field ) { |
|
| 2097 | + foreach ( $fields as &$field ) { |
|
| 2098 | 2098 | $field->adminOnly = false; |
| 2099 | 2099 | } |
| 2100 | 2100 | |
@@ -2115,7 +2115,7 @@ discard block |
||
| 2115 | 2115 | */ |
| 2116 | 2116 | private function unselect_default_values( $form ) { |
| 2117 | 2117 | |
| 2118 | - foreach ( $form['fields'] as &$field ) { |
|
| 2118 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2119 | 2119 | |
| 2120 | 2120 | if ( empty( $field->choices ) ) { |
| 2121 | 2121 | continue; |
@@ -2123,7 +2123,7 @@ discard block |
||
| 2123 | 2123 | |
| 2124 | 2124 | foreach ( $field->choices as &$choice ) { |
| 2125 | 2125 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 2126 | - $choice['isSelected'] = false; |
|
| 2126 | + $choice[ 'isSelected' ] = false; |
|
| 2127 | 2127 | } |
| 2128 | 2128 | } |
| 2129 | 2129 | } |
@@ -2148,22 +2148,22 @@ discard block |
||
| 2148 | 2148 | */ |
| 2149 | 2149 | function prefill_conditional_logic( $form ) { |
| 2150 | 2150 | |
| 2151 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 2151 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 2152 | 2152 | return $form; |
| 2153 | 2153 | } |
| 2154 | 2154 | |
| 2155 | 2155 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 2156 | 2156 | /** @var GF_Field $field */ |
| 2157 | - foreach ( $form['fields'] as &$field ) { |
|
| 2157 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2158 | 2158 | |
| 2159 | - if( 'checkbox' === $field->type ) { |
|
| 2159 | + if ( 'checkbox' === $field->type ) { |
|
| 2160 | 2160 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 2161 | - $input_id = $input['id']; |
|
| 2161 | + $input_id = $input[ 'id' ]; |
|
| 2162 | 2162 | $choice = $field->choices[ $key ]; |
| 2163 | 2163 | $value = \GV\Utils::get( $this->entry, $input_id ); |
| 2164 | 2164 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 2165 | - if( $match ) { |
|
| 2166 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 2165 | + if ( $match ) { |
|
| 2166 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 2167 | 2167 | } |
| 2168 | 2168 | } |
| 2169 | 2169 | } else { |
@@ -2171,15 +2171,15 @@ discard block |
||
| 2171 | 2171 | // We need to run through each field to set the default values |
| 2172 | 2172 | foreach ( $this->entry as $field_id => $field_value ) { |
| 2173 | 2173 | |
| 2174 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2174 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2175 | 2175 | |
| 2176 | - if( 'list' === $field->type ) { |
|
| 2176 | + if ( 'list' === $field->type ) { |
|
| 2177 | 2177 | $list_rows = maybe_unserialize( $field_value ); |
| 2178 | 2178 | |
| 2179 | 2179 | $list_field_value = array(); |
| 2180 | - foreach ( (array) $list_rows as $row ) { |
|
| 2181 | - foreach ( (array) $row as $column ) { |
|
| 2182 | - $list_field_value[] = $column; |
|
| 2180 | + foreach ( (array)$list_rows as $row ) { |
|
| 2181 | + foreach ( (array)$row as $column ) { |
|
| 2182 | + $list_field_value[ ] = $column; |
|
| 2183 | 2183 | } |
| 2184 | 2184 | } |
| 2185 | 2185 | |
@@ -2212,32 +2212,32 @@ discard block |
||
| 2212 | 2212 | * @see https://github.com/gravityview/GravityView/issues/840 |
| 2213 | 2213 | * @since develop |
| 2214 | 2214 | */ |
| 2215 | - $the_form = GFAPI::get_form( $form['id'] ); |
|
| 2215 | + $the_form = GFAPI::get_form( $form[ 'id' ] ); |
|
| 2216 | 2216 | $editable_ids = array(); |
| 2217 | - foreach ( $form['fields'] as $field ) { |
|
| 2218 | - $editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context |
|
| 2217 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 2218 | + $editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context |
|
| 2219 | 2219 | } |
| 2220 | 2220 | $remove_conditions_rule = array(); |
| 2221 | - foreach ( $the_form['fields'] as $field ) { |
|
| 2222 | - if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) { |
|
| 2223 | - foreach ( $field->conditionalLogic['rules'] as $i => $rule ) { |
|
| 2224 | - if ( ! in_array( $rule['fieldId'], $editable_ids ) ) { |
|
| 2221 | + foreach ( $the_form[ 'fields' ] as $field ) { |
|
| 2222 | + if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) { |
|
| 2223 | + foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) { |
|
| 2224 | + if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) { |
|
| 2225 | 2225 | /** |
| 2226 | 2226 | * This conditional field is not editable in this View. |
| 2227 | 2227 | * We need to remove the rule, but only if it matches. |
| 2228 | 2228 | */ |
| 2229 | - if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) { |
|
| 2229 | + if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) { |
|
| 2230 | 2230 | $value = $_field->get_value_export( $this->entry ); |
| 2231 | - } elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) { |
|
| 2232 | - $value = $this->entry[ $rule['fieldId'] ]; |
|
| 2231 | + } elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) { |
|
| 2232 | + $value = $this->entry[ $rule[ 'fieldId' ] ]; |
|
| 2233 | 2233 | } else { |
| 2234 | - $value = gform_get_meta( $this->entry['id'], $rule['fieldId'] ); |
|
| 2234 | + $value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] ); |
|
| 2235 | 2235 | } |
| 2236 | 2236 | |
| 2237 | - $match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] ); |
|
| 2237 | + $match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] ); |
|
| 2238 | 2238 | |
| 2239 | 2239 | if ( $match ) { |
| 2240 | - $remove_conditions_rule[] = array( $field['id'], $i ); |
|
| 2240 | + $remove_conditions_rule[ ] = array( $field[ 'id' ], $i ); |
|
| 2241 | 2241 | } |
| 2242 | 2242 | } |
| 2243 | 2243 | } |
@@ -2245,21 +2245,21 @@ discard block |
||
| 2245 | 2245 | } |
| 2246 | 2246 | |
| 2247 | 2247 | if ( $remove_conditions_rule ) { |
| 2248 | - foreach ( $form['fields'] as &$field ) { |
|
| 2248 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2249 | 2249 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
| 2250 | 2250 | |
| 2251 | 2251 | list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
| 2252 | 2252 | |
| 2253 | - if ( $field['id'] == $rule_field_id ) { |
|
| 2254 | - unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
|
| 2255 | - gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) ); |
|
| 2253 | + if ( $field[ 'id' ] == $rule_field_id ) { |
|
| 2254 | + unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] ); |
|
| 2255 | + gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) ); |
|
| 2256 | 2256 | } |
| 2257 | 2257 | } |
| 2258 | 2258 | } |
| 2259 | 2259 | } |
| 2260 | 2260 | |
| 2261 | 2261 | /** Normalize the indices... */ |
| 2262 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 2262 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 2263 | 2263 | |
| 2264 | 2264 | /** |
| 2265 | 2265 | * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields? |
@@ -2269,16 +2269,16 @@ discard block |
||
| 2269 | 2269 | */ |
| 2270 | 2270 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 2271 | 2271 | |
| 2272 | - if( $use_conditional_logic ) { |
|
| 2272 | + if ( $use_conditional_logic ) { |
|
| 2273 | 2273 | return $form; |
| 2274 | 2274 | } |
| 2275 | 2275 | |
| 2276 | - foreach( $form['fields'] as &$field ) { |
|
| 2276 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2277 | 2277 | /* @var GF_Field $field */ |
| 2278 | 2278 | $field->conditionalLogic = null; |
| 2279 | 2279 | } |
| 2280 | 2280 | |
| 2281 | - unset( $form['button']['conditionalLogic'] ); |
|
| 2281 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 2282 | 2282 | |
| 2283 | 2283 | return $form; |
| 2284 | 2284 | |
@@ -2295,7 +2295,7 @@ discard block |
||
| 2295 | 2295 | */ |
| 2296 | 2296 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 2297 | 2297 | |
| 2298 | - if( ! $this->is_edit_entry() ) { |
|
| 2298 | + if ( ! $this->is_edit_entry() ) { |
|
| 2299 | 2299 | return $has_conditional_logic; |
| 2300 | 2300 | } |
| 2301 | 2301 | |
@@ -2327,44 +2327,44 @@ discard block |
||
| 2327 | 2327 | * 2. There are two entries embedded using oEmbed |
| 2328 | 2328 | * 3. One of the entries has just been saved |
| 2329 | 2329 | */ |
| 2330 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 2330 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 2331 | 2331 | |
| 2332 | 2332 | $error = true; |
| 2333 | 2333 | |
| 2334 | 2334 | } |
| 2335 | 2335 | |
| 2336 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 2336 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 2337 | 2337 | |
| 2338 | 2338 | $error = true; |
| 2339 | 2339 | |
| 2340 | - } elseif( ! $this->verify_nonce() ) { |
|
| 2340 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 2341 | 2341 | |
| 2342 | 2342 | /** |
| 2343 | 2343 | * If the Entry is embedded, there may be two entries on the same page. |
| 2344 | 2344 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 2345 | 2345 | */ |
| 2346 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 2346 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 2347 | 2347 | $error = true; |
| 2348 | 2348 | } else { |
| 2349 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 2349 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 2350 | 2350 | } |
| 2351 | 2351 | |
| 2352 | 2352 | } |
| 2353 | 2353 | |
| 2354 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 2355 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 2354 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 2355 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 2356 | 2356 | } |
| 2357 | 2357 | |
| 2358 | - if( $this->entry['status'] === 'trash' ) { |
|
| 2359 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 2358 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 2359 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 2360 | 2360 | } |
| 2361 | 2361 | |
| 2362 | 2362 | // No errors; everything's fine here! |
| 2363 | - if( empty( $error ) ) { |
|
| 2363 | + if ( empty( $error ) ) { |
|
| 2364 | 2364 | return true; |
| 2365 | 2365 | } |
| 2366 | 2366 | |
| 2367 | - if( $echo && $error !== true ) { |
|
| 2367 | + if ( $echo && $error !== true ) { |
|
| 2368 | 2368 | |
| 2369 | 2369 | $error = esc_html( $error ); |
| 2370 | 2370 | |
@@ -2372,10 +2372,10 @@ discard block |
||
| 2372 | 2372 | * @since 1.9 |
| 2373 | 2373 | */ |
| 2374 | 2374 | if ( ! empty( $this->entry ) ) { |
| 2375 | - $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;" ) ); |
|
| 2375 | + $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;" ) ); |
|
| 2376 | 2376 | } |
| 2377 | 2377 | |
| 2378 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 2378 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 2379 | 2379 | } |
| 2380 | 2380 | |
| 2381 | 2381 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2395,17 +2395,17 @@ discard block |
||
| 2395 | 2395 | |
| 2396 | 2396 | $error = NULL; |
| 2397 | 2397 | |
| 2398 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2399 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 2398 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2399 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 2400 | 2400 | } |
| 2401 | 2401 | |
| 2402 | 2402 | // No errors; everything's fine here! |
| 2403 | - if( empty( $error ) ) { |
|
| 2403 | + if ( empty( $error ) ) { |
|
| 2404 | 2404 | return true; |
| 2405 | 2405 | } |
| 2406 | 2406 | |
| 2407 | - if( $echo ) { |
|
| 2408 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 2407 | + if ( $echo ) { |
|
| 2408 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 2409 | 2409 | } |
| 2410 | 2410 | |
| 2411 | 2411 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2426,14 +2426,14 @@ discard block |
||
| 2426 | 2426 | private function check_user_cap_edit_field( $field ) { |
| 2427 | 2427 | |
| 2428 | 2428 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 2429 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2429 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2430 | 2430 | return true; |
| 2431 | 2431 | } |
| 2432 | 2432 | |
| 2433 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 2433 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 2434 | 2434 | |
| 2435 | - if( $field_cap ) { |
|
| 2436 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 2435 | + if ( $field_cap ) { |
|
| 2436 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 2437 | 2437 | } |
| 2438 | 2438 | |
| 2439 | 2439 | return false; |
@@ -2447,17 +2447,17 @@ discard block |
||
| 2447 | 2447 | public function verify_nonce() { |
| 2448 | 2448 | |
| 2449 | 2449 | // Verify form submitted for editing single |
| 2450 | - if( $this->is_edit_entry_submission() ) { |
|
| 2450 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2451 | 2451 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2452 | 2452 | } |
| 2453 | 2453 | |
| 2454 | 2454 | // Verify |
| 2455 | - else if( ! $this->is_edit_entry() ) { |
|
| 2455 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2456 | 2456 | $valid = false; |
| 2457 | 2457 | } |
| 2458 | 2458 | |
| 2459 | 2459 | else { |
| 2460 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2460 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2461 | 2461 | } |
| 2462 | 2462 | |
| 2463 | 2463 | /** |
@@ -2517,7 +2517,7 @@ discard block |
||
| 2517 | 2517 | */ |
| 2518 | 2518 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 2519 | 2519 | |
| 2520 | - return (array) $labels; |
|
| 2520 | + return (array)$labels; |
|
| 2521 | 2521 | } |
| 2522 | 2522 | |
| 2523 | 2523 | } //end class |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | 'author' => self::author, |
| 99 | 99 | 'language' => get_locale(), |
| 100 | 100 | 'url' => home_url(), |
| 101 | - 'beta' => $this->settings->get( 'beta' ), |
|
| 101 | + 'beta' => $this->settings->get( 'beta' ), |
|
| 102 | 102 | 'php_version' => phpversion(), |
| 103 | 103 | 'wp_version' => get_bloginfo( 'version' ), |
| 104 | 104 | 'gv_version' => \GV\Plugin::$version, |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | private function license_call_update_settings( $license_data, $data ) { |
| 523 | 523 | $settings = array(); |
| 524 | 524 | |
| 525 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
| 525 | + $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
| 526 | 526 | $settings['license_key_status'] = $license_data->license; |
| 527 | 527 | $settings['license_key_response'] = (array)$license_data; |
| 528 | 528 | |
@@ -663,14 +663,14 @@ discard block |
||
| 663 | 663 | // Call the custom API. |
| 664 | 664 | $response = wp_remote_post( self::url, array( |
| 665 | 665 | 'timeout' => 15, |
| 666 | - 'sslverify' => false, |
|
| 667 | - 'body' => array( |
|
| 668 | - 'edd_action' => 'check_license', |
|
| 669 | - 'license' => trim( $this->settings->get( 'license_key' ) ), |
|
| 670 | - 'item_name' => self::name, |
|
| 671 | - 'url' => home_url(), |
|
| 672 | - 'site_data' => $this->get_site_data(), |
|
| 673 | - ), |
|
| 666 | + 'sslverify' => false, |
|
| 667 | + 'body' => array( |
|
| 668 | + 'edd_action' => 'check_license', |
|
| 669 | + 'license' => trim( $this->settings->get( 'license_key' ) ), |
|
| 670 | + 'item_name' => self::name, |
|
| 671 | + 'url' => home_url(), |
|
| 672 | + 'site_data' => $this->get_site_data(), |
|
| 673 | + ), |
|
| 674 | 674 | )); |
| 675 | 675 | |
| 676 | 676 | // make sure the response came back okay |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | 108 | if ( ! empty( $action ) ) { |
| 109 | - $settings['edd_action'] = esc_attr( $action ); |
|
| 109 | + $settings[ 'edd_action' ] = esc_attr( $action ); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | return array_map( 'urlencode', $settings ); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // If doing ajax, get outta here. |
| 129 | - if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST('action') ) ) { |
|
| 129 | + if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST( 'action' ) ) ) { |
|
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | 'format' => 'json', |
| 174 | 174 | ) ); |
| 175 | 175 | |
| 176 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
| 176 | + if ( $is_ajax && empty( $data[ 'license' ] ) ) { |
|
| 177 | 177 | die( -1 ); |
| 178 | 178 | } |
| 179 | 179 | |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | $json = json_encode( $license_data ); |
| 203 | 203 | |
| 204 | - $update_license = Utils::get( $data, 'update' ) || 'gravityview_license' === Utils::_POST('action'); |
|
| 204 | + $update_license = Utils::get( $data, 'update' ) || 'gravityview_license' === Utils::_POST( 'action' ); |
|
| 205 | 205 | |
| 206 | 206 | $is_check_action_button = ( 'check_license' === Utils::get( $data, 'edd_action' ) && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
| 207 | 207 | |
| 208 | - do_action('gravityview/admin_installer/delete_downloads_data', true ); |
|
| 208 | + do_action( 'gravityview/admin_installer/delete_downloads_data', true ); |
|
| 209 | 209 | |
| 210 | 210 | if ( $is_check_action_button ) { |
| 211 | 211 | delete_transient( self::status_transient_key ); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | // most likely a mistake. |
| 217 | 217 | } else if ( $license_data->license !== 'failed' && $update_license ) { |
| 218 | 218 | |
| 219 | - if ( ! empty( $data['field_id'] ) ) { |
|
| 219 | + if ( ! empty( $data[ 'field_id' ] ) ) { |
|
| 220 | 220 | set_transient( self::status_transient_key, $license_data, DAY_IN_SECONDS ); |
| 221 | 221 | } |
| 222 | 222 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $class = 'hide'; |
| 245 | 245 | $message = ''; |
| 246 | 246 | } else { |
| 247 | - if( ! empty( $license_data->error ) ) { |
|
| 247 | + if ( ! empty( $license_data->error ) ) { |
|
| 248 | 248 | $class = 'error'; |
| 249 | 249 | $string_key = $license_data->error; |
| 250 | 250 | } else { $class = $license_data->license; |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public function license_details( $response = array() ) { |
| 270 | 270 | |
| 271 | - $response = (array) $response; |
|
| 271 | + $response = (array)$response; |
|
| 272 | 272 | |
| 273 | 273 | $return = ''; |
| 274 | 274 | $wrapper = '<span class="gv-license-details" aria-live="polite" aria-busy="false">%s</span>'; |
| 275 | 275 | |
| 276 | - if ( ! empty( $response['license_key'] ) ) { |
|
| 276 | + if ( ! empty( $response[ 'license_key' ] ) ) { |
|
| 277 | 277 | $return .= '<h3>' . rtrim( esc_html__( 'License Details:', 'gravityview' ), ':' ) . '</h3>'; |
| 278 | 278 | |
| 279 | 279 | if ( in_array( Utils::get( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { |
@@ -282,8 +282,8 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
| 285 | - $return .= $this->strings( $response['license'], $response ); |
|
| 286 | - } elseif ( ! empty( $response['license_name'] ) ) { |
|
| 285 | + $return .= $this->strings( $response[ 'license' ], $response ); |
|
| 286 | + } elseif ( ! empty( $response[ 'license_name' ] ) ) { |
|
| 287 | 287 | $response_keys = array( |
| 288 | 288 | 'license_name' => '', |
| 289 | 289 | 'license_limit' => '', |
@@ -298,22 +298,22 @@ discard block |
||
| 298 | 298 | $response = wp_parse_args( $response, $response_keys ); |
| 299 | 299 | |
| 300 | 300 | $login_link_class = gravityview()->plugin->is_GF_25() ? 'button button-outline outline' : 'text-link'; |
| 301 | - $renews_on = ( 'lifetime' === $response['expires'] ) ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response['expires'] ) - DAY_IN_SECONDS ) ); |
|
| 302 | - $login_link = sprintf( '<a href="%s" class="gv-access-account ' . $login_link_class . '" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response['customer_email'] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
| 303 | - $local_text = ( ! empty( $response['is_local'] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
| 304 | - $license_limit = empty( $response['license_limit'] ) ? __( 'Unlimited', 'gravityview' ) : (int) $response['license_limit']; |
|
| 301 | + $renews_on = ( 'lifetime' === $response[ 'expires' ] ) ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response[ 'expires' ] ) - DAY_IN_SECONDS ) ); |
|
| 302 | + $login_link = sprintf( '<a href="%s" class="gv-access-account ' . $login_link_class . '" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response[ 'customer_email' ] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
| 303 | + $local_text = ( ! empty( $response[ 'is_local' ] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
| 304 | + $license_limit = empty( $response[ 'license_limit' ] ) ? __( 'Unlimited', 'gravityview' ) : (int)$response[ 'license_limit' ]; |
|
| 305 | 305 | |
| 306 | 306 | |
| 307 | 307 | $details = array( |
| 308 | - 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), '<span class="gv-license-detail">' . esc_html( $response['license_name'] ) . '</span>' ), |
|
| 309 | - 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), '<span class="gv-license-detail">' . esc_html__( $response['customer_name'], 'gravityview' ), esc_html__( $response['customer_email'], 'gravityview' ) ) . '</span>' . $renews_on . $login_link, |
|
| 310 | - 'activations' => sprintf( str_replace( '%d', '%s', esc_html__( 'Activations: %d of %s sites', 'gravityview' ) ), '<span class="gv-license-detail">' . intval( $response['site_count'] ), esc_html( $license_limit ) ) . '</span>' . $local_text, |
|
| 311 | - 'upgrade' => $this->get_upgrade_html( $response['upgrades'] ), |
|
| 308 | + 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), '<span class="gv-license-detail">' . esc_html( $response[ 'license_name' ] ) . '</span>' ), |
|
| 309 | + 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), '<span class="gv-license-detail">' . esc_html__( $response[ 'customer_name' ], 'gravityview' ), esc_html__( $response[ 'customer_email' ], 'gravityview' ) ) . '</span>' . $renews_on . $login_link, |
|
| 310 | + 'activations' => sprintf( str_replace( '%d', '%s', esc_html__( 'Activations: %d of %s sites', 'gravityview' ) ), '<span class="gv-license-detail">' . intval( $response[ 'site_count' ] ), esc_html( $license_limit ) ) . '</span>' . $local_text, |
|
| 311 | + 'upgrade' => $this->get_upgrade_html( $response[ 'upgrades' ] ), |
|
| 312 | 312 | ); |
| 313 | 313 | |
| 314 | - if ( ! empty( $response['error'] ) && 'expired' === $response['error'] ) { |
|
| 315 | - unset( $details['upgrade'] ); |
|
| 316 | - $details['licensed_to'] .= '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
| 314 | + if ( ! empty( $response[ 'error' ] ) && 'expired' === $response[ 'error' ] ) { |
|
| 315 | + unset( $details[ 'upgrade' ] ); |
|
| 316 | + $details[ 'licensed_to' ] .= '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | $return .= '<ul>'; |
@@ -345,20 +345,20 @@ discard block |
||
| 345 | 345 | if ( ! empty( $upgrades ) ) { |
| 346 | 346 | |
| 347 | 347 | $locale_parts = explode( '_', get_locale() ); |
| 348 | - $is_english = ( 'en' === $locale_parts[0] ); |
|
| 348 | + $is_english = ( 'en' === $locale_parts[ 0 ] ); |
|
| 349 | 349 | |
| 350 | 350 | $output .= '<h4>' . esc_html__( 'Upgrades available:', 'gravityview' ) . '</h4>'; |
| 351 | 351 | $output .= '<ul>'; |
| 352 | 352 | |
| 353 | 353 | foreach ( $upgrades as $upgrade_id => $upgrade ) { |
| 354 | - $upgrade = (object) $upgrade; |
|
| 354 | + $upgrade = (object)$upgrade; |
|
| 355 | 355 | |
| 356 | 356 | $anchor_text = sprintf( esc_html_x( 'Upgrade to %1$s for %2$s', '1: GravityView upgrade name, 2: Cost of upgrade', 'gravityview' ), esc_attr( $upgrade->name ), esc_attr( $upgrade->price ) ); |
| 357 | 357 | |
| 358 | 358 | if ( $is_english && isset( $upgrade->description ) ) { |
| 359 | 359 | $message = esc_html( $upgrade->description ); |
| 360 | 360 | } else { |
| 361 | - switch( $upgrade->price_id ) { |
|
| 361 | + switch ( $upgrade->price_id ) { |
|
| 362 | 362 | // Interstellar |
| 363 | 363 | case 1: |
| 364 | 364 | default: |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | 'invalid_item_id' => esc_html__( 'This license key does not have access to this plugin.', 'gravityview' ), |
| 438 | 438 | 'missing' => esc_html__( 'The license key entered is invalid.', 'gravityview' ), // Missing is "the license couldn't be found", not "you submitted an empty license" |
| 439 | 439 | 'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ), |
| 440 | - 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), |
|
| 440 | + 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="' . esc_url( $this->get_license_renewal_url( $license_data ) ) . '">', '</a>' ), |
|
| 441 | 441 | 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
| 442 | 442 | 'verifying_license' => esc_html__( 'Verifying license…', 'gravityview' ), |
| 443 | 443 | 'activate_license' => esc_html__( 'Activate License', 'gravityview' ), |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | |
| 466 | 466 | if ( ! empty( $license_data->renewal_url ) ) { |
| 467 | 467 | $renew_license_url = $license_data->renewal_url; |
| 468 | - } elseif( ! empty( $license_data->license_key ) ) { |
|
| 468 | + } elseif ( ! empty( $license_data->license_key ) ) { |
|
| 469 | 469 | $renew_license_url = sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s', $license_data->license_key ); |
| 470 | 470 | } else { |
| 471 | 471 | $renew_license_url = 'https://gravityview.co/account/'; |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | * @return array|\WP_Error |
| 483 | 483 | */ |
| 484 | 484 | private function _license_get_remote_response( $data, $license = '' ) { |
| 485 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
| 485 | + $api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license ); |
|
| 486 | 486 | |
| 487 | 487 | $url = add_query_arg( $api_params, self::url ); |
| 488 | 488 | |
@@ -522,9 +522,9 @@ discard block |
||
| 522 | 522 | private function license_call_update_settings( $license_data, $data ) { |
| 523 | 523 | $settings = array(); |
| 524 | 524 | |
| 525 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
| 526 | - $settings['license_key_status'] = $license_data->license; |
|
| 527 | - $settings['license_key_response'] = (array)$license_data; |
|
| 525 | + $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] ); |
|
| 526 | + $settings[ 'license_key_status' ] = $license_data->license; |
|
| 527 | + $settings[ 'license_key_response' ] = (array)$license_data; |
|
| 528 | 528 | |
| 529 | 529 | $this->settings->set( $settings ); |
| 530 | 530 | } |
@@ -544,9 +544,9 @@ discard block |
||
| 544 | 544 | $status = trim( $this->settings->get( 'license_key_status' ) ); |
| 545 | 545 | $key = trim( $this->settings->get( 'license_key' ) ); |
| 546 | 546 | |
| 547 | - if ( !empty( $key ) ) { |
|
| 547 | + if ( ! empty( $key ) ) { |
|
| 548 | 548 | $response = $this->settings->get( 'license_key_response' ); |
| 549 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
| 549 | + $response = is_array( $response ) ? (object)$response : json_decode( $response ); |
|
| 550 | 550 | } else { |
| 551 | 551 | $response = array(); |
| 552 | 552 | } |
@@ -589,11 +589,11 @@ discard block |
||
| 589 | 589 | |
| 590 | 590 | $submit = '<div class="gv-edd-button-wrapper">'; |
| 591 | 591 | foreach ( $fields as $field ) { |
| 592 | - $field['type'] = 'button'; |
|
| 593 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
| 594 | - $field['style'] = 'margin-left: 10px;'; |
|
| 595 | - if( $disabled_attribute ) { |
|
| 596 | - $field['disabled'] = $disabled_attribute; |
|
| 592 | + $field[ 'type' ] = 'button'; |
|
| 593 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class; |
|
| 594 | + $field[ 'style' ] = 'margin-left: 10px;'; |
|
| 595 | + if ( $disabled_attribute ) { |
|
| 596 | + $field[ 'disabled' ] = $disabled_attribute; |
|
| 597 | 597 | } |
| 598 | 598 | $submit .= $this->settings->as_html( $field, $echo ); |
| 599 | 599 | } |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | 'url' => home_url(), |
| 672 | 672 | 'site_data' => $this->get_site_data(), |
| 673 | 673 | ), |
| 674 | - )); |
|
| 674 | + ) ); |
|
| 675 | 675 | |
| 676 | 676 | // make sure the response came back okay |
| 677 | 677 | if ( is_wp_error( $response ) ) { |
@@ -701,45 +701,45 @@ discard block |
||
| 701 | 701 | $theme_data = wp_get_theme(); |
| 702 | 702 | $theme = $theme_data->Name . ' ' . $theme_data->Version; |
| 703 | 703 | |
| 704 | - $data['gv_version'] = Plugin::$version; |
|
| 705 | - $data['php_version'] = phpversion(); |
|
| 706 | - $data['wp_version'] = get_bloginfo( 'version' ); |
|
| 707 | - $data['gf_version'] = \GFForms::$version; |
|
| 708 | - $data['server'] = Utils::get( $_SERVER, 'SERVER_SOFTWARE' ); |
|
| 709 | - $data['multisite'] = is_multisite(); |
|
| 710 | - $data['theme'] = $theme; |
|
| 711 | - $data['url'] = home_url(); |
|
| 712 | - $data['license_key'] = $this->settings->get( 'license_key' ); |
|
| 713 | - $data['beta'] = $this->settings->get( 'beta' ); |
|
| 704 | + $data[ 'gv_version' ] = Plugin::$version; |
|
| 705 | + $data[ 'php_version' ] = phpversion(); |
|
| 706 | + $data[ 'wp_version' ] = get_bloginfo( 'version' ); |
|
| 707 | + $data[ 'gf_version' ] = \GFForms::$version; |
|
| 708 | + $data[ 'server' ] = Utils::get( $_SERVER, 'SERVER_SOFTWARE' ); |
|
| 709 | + $data[ 'multisite' ] = is_multisite(); |
|
| 710 | + $data[ 'theme' ] = $theme; |
|
| 711 | + $data[ 'url' ] = home_url(); |
|
| 712 | + $data[ 'license_key' ] = $this->settings->get( 'license_key' ); |
|
| 713 | + $data[ 'beta' ] = $this->settings->get( 'beta' ); |
|
| 714 | 714 | |
| 715 | 715 | // View Data |
| 716 | 716 | $gravityview_posts = wp_count_posts( 'gravityview', 'readable' ); |
| 717 | 717 | |
| 718 | - $data['view_count'] = null; |
|
| 719 | - $data['view_first'] = null; |
|
| 720 | - $data['view_latest'] = null; |
|
| 718 | + $data[ 'view_count' ] = null; |
|
| 719 | + $data[ 'view_first' ] = null; |
|
| 720 | + $data[ 'view_latest' ] = null; |
|
| 721 | 721 | |
| 722 | 722 | if ( $gravityview_posts->publish ) { |
| 723 | - $data['view_count'] = $gravityview_posts->publish; |
|
| 723 | + $data[ 'view_count' ] = $gravityview_posts->publish; |
|
| 724 | 724 | |
| 725 | 725 | $first = get_posts( 'numberposts=1&post_type=gravityview&post_status=publish&order=ASC' ); |
| 726 | 726 | $latest = get_posts( 'numberposts=1&post_type=gravityview&post_status=publish&order=DESC' ); |
| 727 | 727 | |
| 728 | 728 | if ( $first = array_shift( $first ) ) { |
| 729 | - $data['view_first'] = $first->post_date; |
|
| 729 | + $data[ 'view_first' ] = $first->post_date; |
|
| 730 | 730 | } |
| 731 | 731 | if ( $latest = array_pop( $latest ) ) { |
| 732 | - $data['view_latest'] = $latest->post_date; |
|
| 732 | + $data[ 'view_latest' ] = $latest->post_date; |
|
| 733 | 733 | } |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | // Form counts |
| 737 | 737 | if ( class_exists( 'GFFormsModel' ) ) { |
| 738 | 738 | $form_data = \GFFormsModel::get_form_count(); |
| 739 | - $data['forms_total'] = Utils::get( $form_data, 'total', 0 ); |
|
| 740 | - $data['forms_active'] = Utils::get( $form_data, 'active', 0 ); |
|
| 741 | - $data['forms_inactive'] = Utils::get( $form_data, 'inactive', 0 ); |
|
| 742 | - $data['forms_trash'] = Utils::get( $form_data, 'inactive', 0 ); |
|
| 739 | + $data[ 'forms_total' ] = Utils::get( $form_data, 'total', 0 ); |
|
| 740 | + $data[ 'forms_active' ] = Utils::get( $form_data, 'active', 0 ); |
|
| 741 | + $data[ 'forms_inactive' ] = Utils::get( $form_data, 'inactive', 0 ); |
|
| 742 | + $data[ 'forms_trash' ] = Utils::get( $form_data, 'inactive', 0 ); |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | // Retrieve current plugin information |
@@ -747,13 +747,13 @@ discard block |
||
| 747 | 747 | include ABSPATH . '/wp-admin/includes/plugin.php'; |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | - $data['integrations'] = self::get_related_plugins_and_extensions(); |
|
| 751 | - $data['active_plugins'] = get_option( 'active_plugins', array() ); |
|
| 752 | - $data['inactive_plugins'] = array(); |
|
| 753 | - $data['locale'] = get_locale(); |
|
| 750 | + $data[ 'integrations' ] = self::get_related_plugins_and_extensions(); |
|
| 751 | + $data[ 'active_plugins' ] = get_option( 'active_plugins', array() ); |
|
| 752 | + $data[ 'inactive_plugins' ] = array(); |
|
| 753 | + $data[ 'locale' ] = get_locale(); |
|
| 754 | 754 | |
| 755 | 755 | // Validate request on the GV server |
| 756 | - $data['hash'] = 'gv_version.url.locale:' . sha1( $data['gv_version'] . $data['url'] . $data['locale'] ); |
|
| 756 | + $data[ 'hash' ] = 'gv_version.url.locale:' . sha1( $data[ 'gv_version' ] . $data[ 'url' ] . $data[ 'locale' ] ); |
|
| 757 | 757 | |
| 758 | 758 | return $data; |
| 759 | 759 | } |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | $plugin_data = get_plugin_data( $active_plugin ); |
| 785 | 785 | |
| 786 | - $extensions[] = sprintf( '%s %s', $plugin_data['Name'], $plugin_data['Version'] ); |
|
| 786 | + $extensions[ ] = sprintf( '%s %s', $plugin_data[ 'Name' ], $plugin_data[ 'Version' ] ); |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | if ( ! empty( $extensions ) ) { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // If doing ajax, get outta here. |
| 129 | - if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST('action') ) ) { |
|
| 129 | + if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST('action') ) ) { |
|
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -191,7 +191,8 @@ discard block |
||
| 191 | 191 | if ( empty( $license_data ) ) { |
| 192 | 192 | if ( $is_ajax ) { |
| 193 | 193 | exit( json_encode( array() ) ); |
| 194 | - } else { // Non-ajax call |
|
| 194 | + } else { |
|
| 195 | +// Non-ajax call |
|
| 195 | 196 | return json_encode( array() ); |
| 196 | 197 | } |
| 197 | 198 | } |
@@ -226,7 +227,8 @@ discard block |
||
| 226 | 227 | |
| 227 | 228 | if ( $is_ajax ) { |
| 228 | 229 | exit( $json ); |
| 229 | - } else { // Non-ajax call |
|
| 230 | + } else { |
|
| 231 | +// Non-ajax call |
|
| 230 | 232 | return ( Utils::_GET( 'format', Utils::get( $data, 'format' ) ) === 'object' ) ? $license_data : $json; |
| 231 | 233 | } |
| 232 | 234 | } |
@@ -311,17 +311,17 @@ |
||
| 311 | 311 | $this->_remote_update_url, |
| 312 | 312 | $this->_path, |
| 313 | 313 | array( |
| 314 | - 'version' => $this->_version, // current version number |
|
| 315 | - 'license' => \GV\Utils::get( $license, 'license_key', \GV\Utils::get( $license, 'license', null ) ), |
|
| 316 | - 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
|
| 317 | - 'item_name' => $this->_title, // name of this plugin |
|
| 318 | - 'author' => strip_tags( $this->_author ), // author of this plugin |
|
| 319 | - 'php_version' => phpversion(), |
|
| 320 | - 'wp_version' => get_bloginfo( 'version' ), |
|
| 321 | - 'gv_version' => \GV\Plugin::$version, |
|
| 322 | - 'environment' => function_exists( 'wp_get_environment_type' ) ? wp_get_environment_type() : 'production', |
|
| 323 | - ), |
|
| 324 | - ); |
|
| 314 | + 'version' => $this->_version, // current version number |
|
| 315 | + 'license' => \GV\Utils::get( $license, 'license_key', \GV\Utils::get( $license, 'license', null ) ), |
|
| 316 | + 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
|
| 317 | + 'item_name' => $this->_title, // name of this plugin |
|
| 318 | + 'author' => strip_tags( $this->_author ), // author of this plugin |
|
| 319 | + 'php_version' => phpversion(), |
|
| 320 | + 'wp_version' => get_bloginfo( 'version' ), |
|
| 321 | + 'gv_version' => \GV\Plugin::$version, |
|
| 322 | + 'environment' => function_exists( 'wp_get_environment_type' ) ? wp_get_environment_type() : 'production', |
|
| 323 | + ), |
|
| 324 | + ); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | $tab = wp_parse_args( $tab_settings, $tab_defaults ); |
| 181 | 181 | |
| 182 | 182 | // Force the screen to be GravityView |
| 183 | - $tab['screen'] = 'gravityview'; |
|
| 183 | + $tab[ 'screen' ] = 'gravityview'; |
|
| 184 | 184 | |
| 185 | 185 | if ( class_exists( 'GravityView_Metabox_Tab' ) ) { |
| 186 | - $metabox = new \GravityView_Metabox_Tab( $tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args'] ); |
|
| 186 | + $metabox = new \GravityView_Metabox_Tab( $tab[ 'id' ], $tab[ 'title' ], $tab[ 'file' ], $tab[ 'icon-class' ], $tab[ 'callback' ], $tab[ 'callback_args' ] ); |
|
| 187 | 187 | \GravityView_Metabox_Tabs::add( $metabox ); |
| 188 | 188 | } else { |
| 189 | - add_meta_box( 'gravityview_' . $tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority'] ); |
|
| 189 | + add_meta_box( 'gravityview_' . $tab[ 'id' ], $tab[ 'title' ], $tab[ 'callback' ], $tab[ 'screen' ], $tab[ 'context' ], $tab[ 'priority' ] ); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | protected function is_extension_supported() { |
| 213 | 213 | |
| 214 | - self::$is_compatible = is_array( self::$is_compatible ) ? self::$is_compatible : array( get_called_class() => (bool) self::$is_compatible ); |
|
| 214 | + self::$is_compatible = is_array( self::$is_compatible ) ? self::$is_compatible : array( get_called_class() => (bool)self::$is_compatible ); |
|
| 215 | 215 | |
| 216 | 216 | if ( ! function_exists( 'gravityview' ) ) { |
| 217 | 217 | $message = sprintf( __( 'Could not activate the %s Extension; GravityView is not active.', 'gravityview' ), esc_html( $this->_title ) ); |
| 218 | - } else if ( false === version_compare( Plugin::$version, $this->_min_gravityview_version , ">=" ) ) { |
|
| 219 | - $message = sprintf( __( 'The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), esc_html( $this->_title ), '<tt>'.$this->_min_gravityview_version.'</tt>' ); |
|
| 220 | - } else if ( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version , ">=" ) ) { |
|
| 221 | - $message = sprintf( __( 'The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), esc_html( $this->_title ), '<tt>'.$this->_min_php_version.'</tt>' ); |
|
| 218 | + } else if ( false === version_compare( Plugin::$version, $this->_min_gravityview_version, ">=" ) ) { |
|
| 219 | + $message = sprintf( __( 'The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), esc_html( $this->_title ), '<tt>' . $this->_min_gravityview_version . '</tt>' ); |
|
| 220 | + } else if ( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version, ">=" ) ) { |
|
| 221 | + $message = sprintf( __( 'The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), esc_html( $this->_title ), '<tt>' . $this->_min_php_version . '</tt>' ); |
|
| 222 | 222 | } else if ( ! empty( $this->_max_gravityview_version ) && false === version_compare( $this->_max_gravityview_version, Plugin::$version, ">" ) ) { |
| 223 | 223 | $message = sprintf( __( 'The %s Extension is not compatible with this version of GravityView. Please update the Extension to the latest version.', 'gravityview' ), esc_html( $this->_title ) ); |
| 224 | 224 | } else { |
@@ -258,12 +258,12 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | $locale = get_locale(); |
| 260 | 260 | |
| 261 | - if ( function_exists('get_user_locale') && is_admin() ) { |
|
| 261 | + if ( function_exists( 'get_user_locale' ) && is_admin() ) { |
|
| 262 | 262 | $locale = get_user_locale(); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // Traditional WordPress plugin locale filter |
| 266 | - $locale = apply_filters( 'plugin_locale', $locale, $this->_text_domain ); |
|
| 266 | + $locale = apply_filters( 'plugin_locale', $locale, $this->_text_domain ); |
|
| 267 | 267 | |
| 268 | 268 | $mofile = sprintf( '%1$s-%2$s.mo', $this->_text_domain, $locale ); |
| 269 | 269 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | public function settings() { |
| 292 | 292 | |
| 293 | 293 | // If doing ajax, get outta here. |
| 294 | - if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST('action') ) ) { |
|
| 294 | + if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST( 'action' ) ) ) { |
|
| 295 | 295 | return; |
| 296 | 296 | } |
| 297 | 297 | |
@@ -314,8 +314,8 @@ discard block |
||
| 314 | 314 | 'version' => $this->_version, // current version number |
| 315 | 315 | 'license' => \GV\Utils::get( $license, 'license_key', \GV\Utils::get( $license, 'license', null ) ), |
| 316 | 316 | 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
| 317 | - 'item_name' => $this->_title, // name of this plugin |
|
| 318 | - 'author' => strip_tags( $this->_author ), // author of this plugin |
|
| 317 | + 'item_name' => $this->_title, // name of this plugin |
|
| 318 | + 'author' => strip_tags( $this->_author ), // author of this plugin |
|
| 319 | 319 | 'php_version' => phpversion(), |
| 320 | 320 | 'wp_version' => get_bloginfo( 'version' ), |
| 321 | 321 | 'gv_version' => \GV\Plugin::$version, |
@@ -347,16 +347,16 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | public static function add_notice( $notice = array() ) { |
| 349 | 349 | |
| 350 | - if ( is_array( $notice ) && empty( $notice['message'] ) ) { |
|
| 350 | + if ( is_array( $notice ) && empty( $notice[ 'message' ] ) ) { |
|
| 351 | 351 | gravityview()->log->error( 'Notice not set', array( 'data' => $notice ) ); |
| 352 | 352 | return; |
| 353 | 353 | } else if ( is_string( $notice ) ) { |
| 354 | 354 | $notice = array( 'message' => $notice ); |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - $notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class']; |
|
| 357 | + $notice[ 'class' ] = empty( $notice[ 'class' ] ) ? 'error' : $notice[ 'class' ]; |
|
| 358 | 358 | |
| 359 | - self::$admin_notices []= $notice; |
|
| 359 | + self::$admin_notices [ ] = $notice; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -370,8 +370,8 @@ discard block |
||
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | foreach ( self::$admin_notices as $key => $notice ) { |
| 373 | - echo '<div id="message" class="'. esc_attr( $notice['class'] ).'">'; |
|
| 374 | - echo wpautop( $notice['message'] ); |
|
| 373 | + echo '<div id="message" class="' . esc_attr( $notice[ 'class' ] ) . '">'; |
|
| 374 | + echo wpautop( $notice[ 'message' ] ); |
|
| 375 | 375 | echo '<div class="clear"></div>'; |
| 376 | 376 | echo '</div>'; |
| 377 | 377 | } |
@@ -291,7 +291,7 @@ |
||
| 291 | 291 | public function settings() { |
| 292 | 292 | |
| 293 | 293 | // If doing ajax, get outta here. |
| 294 | - if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST('action') ) ) { |
|
| 294 | + if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST('action') ) ) { |
|
| 295 | 295 | return; |
| 296 | 296 | } |
| 297 | 297 | |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | $this->plugin_file = $_plugin_file; |
| 50 | 50 | $this->name = plugin_basename( $_plugin_file ); |
| 51 | 51 | $this->slug = basename( $_plugin_file, '.php' ); |
| 52 | - $this->version = $_api_data['version']; |
|
| 53 | - $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false; |
|
| 54 | - $this->beta = ! empty( $this->api_data['beta'] ) ? true : false; |
|
| 52 | + $this->version = $_api_data[ 'version' ]; |
|
| 53 | + $this->wp_override = isset( $_api_data[ 'wp_override' ] ) ? (bool)$_api_data[ 'wp_override' ] : false; |
|
| 54 | + $this->beta = ! empty( $this->api_data[ 'beta' ] ) ? true : false; |
|
| 55 | 55 | $this->failed_request_cache_key = 'edd_sl_failed_http_' . md5( $this->api_url ); |
| 56 | 56 | |
| 57 | 57 | $edd_plugin_data[ $this->slug ] = $this->api_data; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | printf( |
| 230 | 230 | /* translators: the plugin name. */ |
| 231 | 231 | esc_html__( 'There is a new version of %1$s available.', 'easy-digital-downloads' ), |
| 232 | - esc_html( $plugin['Name'] ) |
|
| 232 | + esc_html( $plugin[ 'Name' ] ) |
|
| 233 | 233 | ); |
| 234 | 234 | |
| 235 | 235 | if ( ! current_user_can( 'update_plugins' ) ) { |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | * @return array |
| 275 | 275 | */ |
| 276 | 276 | private function get_active_plugins() { |
| 277 | - $active_plugins = (array) get_option( 'active_plugins' ); |
|
| 278 | - $active_network_plugins = (array) get_site_option( 'active_sitewide_plugins' ); |
|
| 277 | + $active_plugins = (array)get_option( 'active_plugins' ); |
|
| 278 | + $active_network_plugins = (array)get_site_option( 'active_sitewide_plugins' ); |
|
| 279 | 279 | |
| 280 | 280 | return array_merge( $active_plugins, array_keys( $active_network_plugins ) ); |
| 281 | 281 | } |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | public function http_request_args( $args, $url ) { |
| 394 | 394 | |
| 395 | 395 | if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
| 396 | - $args['sslverify'] = $this->verify_ssl(); |
|
| 396 | + $args[ 'sslverify' ] = $this->verify_ssl(); |
|
| 397 | 397 | } |
| 398 | 398 | return $args; |
| 399 | 399 | |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | private function api_request( $_action, $_data ) { |
| 414 | 414 | $data = array_merge( $this->api_data, $_data ); |
| 415 | 415 | |
| 416 | - if ( $data['slug'] !== $this->slug ) { |
|
| 416 | + if ( $data[ 'slug' ] !== $this->slug ) { |
|
| 417 | 417 | return; |
| 418 | 418 | } |
| 419 | 419 | |
@@ -477,15 +477,15 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | public function show_changelog() { |
| 479 | 479 | |
| 480 | - if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' !== $_REQUEST['edd_sl_action'] ) { |
|
| 480 | + if ( empty( $_REQUEST[ 'edd_sl_action' ] ) || 'view_plugin_changelog' !== $_REQUEST[ 'edd_sl_action' ] ) { |
|
| 481 | 481 | return; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - if ( empty( $_REQUEST['plugin'] ) ) { |
|
| 484 | + if ( empty( $_REQUEST[ 'plugin' ] ) ) { |
|
| 485 | 485 | return; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - if ( empty( $_REQUEST['slug'] ) || $this->slug !== $_REQUEST['slug'] ) { |
|
| 488 | + if ( empty( $_REQUEST[ 'slug' ] ) || $this->slug !== $_REQUEST[ 'slug' ] ) { |
|
| 489 | 489 | return; |
| 490 | 490 | } |
| 491 | 491 | |
@@ -496,8 +496,8 @@ discard block |
||
| 496 | 496 | $version_info = $this->get_repo_api_data(); |
| 497 | 497 | if ( isset( $version_info->sections ) ) { |
| 498 | 498 | $sections = $this->convert_object_to_array( $version_info->sections ); |
| 499 | - if ( ! empty( $sections['changelog'] ) ) { |
|
| 500 | - echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>'; |
|
| 499 | + if ( ! empty( $sections[ 'changelog' ] ) ) { |
|
| 500 | + echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections[ 'changelog' ] ) . '</div>'; |
|
| 501 | 501 | } |
| 502 | 502 | } |
| 503 | 503 | |
@@ -512,12 +512,12 @@ discard block |
||
| 512 | 512 | private function get_version_from_remote() { |
| 513 | 513 | $api_params = array( |
| 514 | 514 | 'edd_action' => 'get_version', |
| 515 | - 'license' => ! empty( $this->api_data['license'] ) ? $this->api_data['license'] : '', |
|
| 516 | - 'item_name' => isset( $this->api_data['item_name'] ) ? $this->api_data['item_name'] : false, |
|
| 517 | - 'item_id' => isset( $this->api_data['item_id'] ) ? $this->api_data['item_id'] : false, |
|
| 518 | - 'version' => isset( $this->api_data['version'] ) ? $this->api_data['version'] : false, |
|
| 515 | + 'license' => ! empty( $this->api_data[ 'license' ] ) ? $this->api_data[ 'license' ] : '', |
|
| 516 | + 'item_name' => isset( $this->api_data[ 'item_name' ] ) ? $this->api_data[ 'item_name' ] : false, |
|
| 517 | + 'item_id' => isset( $this->api_data[ 'item_id' ] ) ? $this->api_data[ 'item_id' ] : false, |
|
| 518 | + 'version' => isset( $this->api_data[ 'version' ] ) ? $this->api_data[ 'version' ] : false, |
|
| 519 | 519 | 'slug' => $this->slug, |
| 520 | - 'author' => $this->api_data['author'], |
|
| 520 | + 'author' => $this->api_data[ 'author' ], |
|
| 521 | 521 | 'url' => home_url(), |
| 522 | 522 | 'beta' => $this->beta, |
| 523 | 523 | 'php_version' => phpversion(), |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | |
| 567 | 567 | if ( ! empty( $request->sections ) ) { |
| 568 | 568 | foreach ( $request->sections as $key => $section ) { |
| 569 | - $request->$key = (array) $section; |
|
| 569 | + $request->$key = (array)$section; |
|
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | |
@@ -588,17 +588,17 @@ discard block |
||
| 588 | 588 | $cache = get_option( $cache_key ); |
| 589 | 589 | |
| 590 | 590 | // Cache is expired |
| 591 | - if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { |
|
| 591 | + if ( empty( $cache[ 'timeout' ] ) || time() > $cache[ 'timeout' ] ) { |
|
| 592 | 592 | return false; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point. |
| 596 | - $cache['value'] = json_decode( $cache['value'] ); |
|
| 597 | - if ( ! empty( $cache['value']->icons ) ) { |
|
| 598 | - $cache['value']->icons = (array) $cache['value']->icons; |
|
| 596 | + $cache[ 'value' ] = json_decode( $cache[ 'value' ] ); |
|
| 597 | + if ( ! empty( $cache[ 'value' ]->icons ) ) { |
|
| 598 | + $cache[ 'value' ]->icons = (array)$cache[ 'value' ]->icons; |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - return $cache['value']; |
|
| 601 | + return $cache[ 'value' ]; |
|
| 602 | 602 | |
| 603 | 603 | } |
| 604 | 604 | |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | update_option( $cache_key, $data, 'no' ); |
| 623 | 623 | |
| 624 | 624 | // Delete the duplicate option |
| 625 | - delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ) ); |
|
| 625 | + delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data[ 'license' ] . $this->beta ) ) ); |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | /** |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | * @return bool |
| 633 | 633 | */ |
| 634 | 634 | private function verify_ssl() { |
| 635 | - return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
|
| 635 | + return (bool)apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | /** |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | * @return string |
| 643 | 643 | */ |
| 644 | 644 | private function get_cache_key() { |
| 645 | - $string = $this->slug . $this->api_data['license'] . $this->beta; |
|
| 645 | + $string = $this->slug . $this->api_data[ 'license' ] . $this->beta; |
|
| 646 | 646 | |
| 647 | 647 | return 'edd_sl_' . md5( serialize( $string ) ); |
| 648 | 648 | } |