@@ -359,9 +359,9 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | /** |
| 361 | 361 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
| 362 | - * @since 1.22.2 |
|
| 363 | - * @param bool $unset_hidden_field_values Default: true |
|
| 364 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 362 | + * @since 1.22.2 |
|
| 363 | + * @param bool $unset_hidden_field_values Default: true |
|
| 364 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 365 | 365 | */ |
| 366 | 366 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
| 367 | 367 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | return; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
|
| 372 | + if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
|
| 373 | 373 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 374 | 374 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
| 375 | 375 | } else { |
@@ -1766,8 +1766,8 @@ discard block |
||
| 1766 | 1766 | * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
| 1767 | 1767 | * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
| 1768 | 1768 | * @since 1.9.1 |
| 1769 | - * @since 1.22.6 Deprecated |
|
| 1770 | - * @deprecated Use gravityview/edit_entry/use_gf_visibility_setting instead |
|
| 1769 | + * @since 1.22.6 Deprecated |
|
| 1770 | + * @deprecated Use gravityview/edit_entry/use_gf_visibility_setting instead |
|
| 1771 | 1771 | * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
| 1772 | 1772 | * @param array $form GF Form array |
| 1773 | 1773 | * @param int $view_id View ID |
@@ -1800,7 +1800,7 @@ discard block |
||
| 1800 | 1800 | * @filter `gravityview/edit_entry/make_all_fields_visible` Set field visibility to "visible" for all fields |
| 1801 | 1801 | * @since 1.22.6 |
| 1802 | 1802 | * @param string $visibility 'visible' by default. Default options are 'hidden', 'visible', and 'administrative' |
| 1803 | - * @param GF_Field $field Form field being modified |
|
| 1803 | + * @param GF_Field $field Form field being modified |
|
| 1804 | 1804 | * @param int $view_id Current View ID |
| 1805 | 1805 | */ |
| 1806 | 1806 | $visibility = apply_filters( 'gravityview/edit_entry/field_visibility', 'visible', $field, $view_id ); |
@@ -106,16 +106,16 @@ discard block |
||
| 106 | 106 | function load() { |
| 107 | 107 | |
| 108 | 108 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 109 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 109 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 110 | 110 | |
| 111 | 111 | // Don't display an embedded form when editing an entry |
| 112 | 112 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
| 113 | 113 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
| 114 | 114 | |
| 115 | 115 | // Stop Gravity Forms processing what is ours! |
| 116 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
| 116 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
| 117 | 117 | |
| 118 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 118 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 119 | 119 | |
| 120 | 120 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
| 121 | 121 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 127 | 127 | |
| 128 | 128 | // Add fields expected by GFFormDisplay::validate() |
| 129 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 129 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 130 | 130 | |
| 131 | 131 | // Fix multiselect value for GF 2.2 |
| 132 | 132 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | * @return void |
| 144 | 144 | */ |
| 145 | 145 | public function prevent_render_form() { |
| 146 | - if( $this->is_edit_entry() ) { |
|
| 147 | - if( 'wp_head' === current_filter() ) { |
|
| 146 | + if ( $this->is_edit_entry() ) { |
|
| 147 | + if ( 'wp_head' === current_filter() ) { |
|
| 148 | 148 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 149 | 149 | } else { |
| 150 | 150 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function prevent_maybe_process_form() { |
| 161 | 161 | |
| 162 | - if( ! empty( $_POST ) ) { |
|
| 162 | + if ( ! empty( $_POST ) ) { |
|
| 163 | 163 | do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if( $this->is_edit_entry_submission() ) { |
|
| 167 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 168 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 166 | + if ( $this->is_edit_entry_submission() ) { |
|
| 167 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 168 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public function is_edit_entry() { |
| 177 | 177 | |
| 178 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
| 178 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
| 179 | 179 | |
| 180 | 180 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 181 | 181 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @return boolean |
| 187 | 187 | */ |
| 188 | 188 | public function is_edit_entry_submission() { |
| 189 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 189 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -197,15 +197,15 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | $entries = $gravityview_view->getEntries(); |
| 200 | - self::$original_entry = $entries[0]; |
|
| 201 | - $this->entry = $entries[0]; |
|
| 200 | + self::$original_entry = $entries[ 0 ]; |
|
| 201 | + $this->entry = $entries[ 0 ]; |
|
| 202 | 202 | |
| 203 | 203 | self::$original_form = $gravityview_view->getForm(); |
| 204 | 204 | $this->form = $gravityview_view->getForm(); |
| 205 | 205 | $this->form_id = $gravityview_view->getFormId(); |
| 206 | 206 | $this->view_id = $gravityview_view->getViewId(); |
| 207 | 207 | |
| 208 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 208 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -226,14 +226,14 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | // Multiple Views embedded, don't proceed if nonce fails |
| 228 | 228 | $multiple_views = defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? gravityview()->views->count() > 1 : $gv_data->has_multiple_views(); |
| 229 | - if( $multiple_views && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
| 230 | - do_action('gravityview_log_error', __METHOD__ . ': Nonce validation failed for the Edit Entry request; returning' ); |
|
| 229 | + if ( $multiple_views && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
| 230 | + do_action( 'gravityview_log_error', __METHOD__ . ': Nonce validation failed for the Edit Entry request; returning' ); |
|
| 231 | 231 | return; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // Sorry, you're not allowed here. |
| 235 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
| 236 | - do_action('gravityview_log_error', __METHOD__ . ': User is not allowed to edit this entry; returning', $this->entry ); |
|
| 235 | + if ( false === $this->user_can_edit_entry( true ) ) { |
|
| 236 | + do_action( 'gravityview_log_error', __METHOD__ . ': User is not allowed to edit this entry; returning', $this->entry ); |
|
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | private function print_scripts() { |
| 254 | 254 | $gravityview_view = GravityView_View::getInstance(); |
| 255 | 255 | |
| 256 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 256 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 257 | 257 | |
| 258 | - GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false); |
|
| 258 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
| 259 | 259 | |
| 260 | 260 | // Sack is required for images |
| 261 | 261 | wp_print_scripts( array( 'sack', 'gform_gravityforms' ) ); |
@@ -267,32 +267,32 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | private function process_save() { |
| 269 | 269 | |
| 270 | - if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 270 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 271 | 271 | return; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // Make sure the entry, view, and form IDs are all correct |
| 275 | 275 | $valid = $this->verify_nonce(); |
| 276 | 276 | |
| 277 | - if( !$valid ) { |
|
| 278 | - do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
| 277 | + if ( ! $valid ) { |
|
| 278 | + do_action( 'gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
| 279 | 279 | return; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 283 | - do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
| 282 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 283 | + do_action( 'gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
| 284 | 284 | return; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - do_action('gravityview_log_debug', __METHOD__ . ': $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 287 | + do_action( 'gravityview_log_debug', __METHOD__ . ': $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 288 | 288 | |
| 289 | 289 | $this->process_save_process_files( $this->form_id ); |
| 290 | 290 | |
| 291 | 291 | $this->validate(); |
| 292 | 292 | |
| 293 | - if( $this->is_valid ) { |
|
| 293 | + if ( $this->is_valid ) { |
|
| 294 | 294 | |
| 295 | - do_action('gravityview_log_debug', __METHOD__ . ': Submission is valid.' ); |
|
| 295 | + do_action( 'gravityview_log_debug', __METHOD__ . ': Submission is valid.' ); |
|
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | 298 | * @hack This step is needed to fix field visibility, to add the calculation fields |
@@ -302,22 +302,22 @@ discard block |
||
| 302 | 302 | /** |
| 303 | 303 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 304 | 304 | */ |
| 305 | - unset( $_GET['page'] ); |
|
| 305 | + unset( $_GET[ 'page' ] ); |
|
| 306 | 306 | |
| 307 | - $date_created = $this->entry['date_created']; |
|
| 307 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 308 | 308 | |
| 309 | 309 | /** |
| 310 | 310 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 311 | 311 | * @since 1.17.2 |
| 312 | 312 | */ |
| 313 | - unset( $this->entry['date_created'] ); |
|
| 313 | + unset( $this->entry[ 'date_created' ] ); |
|
| 314 | 314 | |
| 315 | 315 | GFFormsModel::save_lead( $form, $this->entry ); |
| 316 | 316 | |
| 317 | 317 | // Delete the values for hidden inputs |
| 318 | 318 | $this->unset_hidden_field_values(); |
| 319 | 319 | |
| 320 | - $this->entry['date_created'] = $date_created; |
|
| 320 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 321 | 321 | |
| 322 | 322 | // Process calculation fields |
| 323 | 323 | $this->update_calculation_fields(); |
@@ -337,10 +337,10 @@ discard block |
||
| 337 | 337 | * @param string $entry_id Numeric ID of the entry that was updated |
| 338 | 338 | * @param GravityView_Edit_Entry_Render $this This object |
| 339 | 339 | */ |
| 340 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this ); |
|
| 340 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this ); |
|
| 341 | 341 | |
| 342 | 342 | } else { |
| 343 | - do_action('gravityview_log_error', __METHOD__ . ': Submission is NOT valid.', $this->entry ); |
|
| 343 | + do_action( 'gravityview_log_error', __METHOD__ . ': Submission is NOT valid.', $this->entry ); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | } // process_save |
@@ -365,16 +365,16 @@ discard block |
||
| 365 | 365 | */ |
| 366 | 366 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
| 367 | 367 | |
| 368 | - if( ! $unset_hidden_field_values ) { |
|
| 368 | + if ( ! $unset_hidden_field_values ) { |
|
| 369 | 369 | return; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 373 | 373 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 374 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 374 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 375 | 375 | } else { |
| 376 | 376 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 377 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 377 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | /** No file is being uploaded. */ |
| 458 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 458 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 459 | 459 | /** So return the original upload */ |
| 460 | 460 | return $entry[ $input_id ]; |
| 461 | 461 | } |
@@ -473,11 +473,11 @@ discard block |
||
| 473 | 473 | * @return mixed |
| 474 | 474 | */ |
| 475 | 475 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 476 | - if( ! $this->is_edit_entry() ) { |
|
| 476 | + if ( ! $this->is_edit_entry() ) { |
|
| 477 | 477 | return $plupload_init; |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 480 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 481 | 481 | |
| 482 | 482 | return $plupload_init; |
| 483 | 483 | } |
@@ -492,22 +492,22 @@ discard block |
||
| 492 | 492 | $form = $this->form; |
| 493 | 493 | |
| 494 | 494 | /** @var GF_Field $field */ |
| 495 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 495 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 496 | 496 | |
| 497 | 497 | /** |
| 498 | 498 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 499 | 499 | * @since 1.16.3 |
| 500 | 500 | * @var GF_Field $field |
| 501 | 501 | */ |
| 502 | - if( $field->has_calculation() ) { |
|
| 503 | - unset( $form['fields'][ $k ] ); |
|
| 502 | + if ( $field->has_calculation() ) { |
|
| 503 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | $field->visibility = 'visible'; |
| 507 | 507 | |
| 508 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 509 | - foreach( $field->inputs as $key => $input ) { |
|
| 510 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 508 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 509 | + foreach ( $field->inputs as $key => $input ) { |
|
| 510 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | } |
@@ -521,21 +521,21 @@ discard block |
||
| 521 | 521 | $update = false; |
| 522 | 522 | |
| 523 | 523 | // get the most up to date entry values |
| 524 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 524 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 525 | 525 | |
| 526 | - if( !empty( $this->fields_with_calculation ) ) { |
|
| 526 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
| 527 | 527 | $update = true; |
| 528 | 528 | foreach ( $this->fields_with_calculation as $calc_field ) { |
| 529 | 529 | $inputs = $calc_field->get_entry_inputs(); |
| 530 | 530 | if ( is_array( $inputs ) ) { |
| 531 | 531 | foreach ( $inputs as $input ) { |
| 532 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 532 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
| 533 | 533 | list( $prefix, $field_id, $input_id ) = rgexplode( '_', $input_name, 3 ); |
| 534 | 534 | |
| 535 | 535 | switch ( $input_id ) { |
| 536 | 536 | case 1: |
| 537 | 537 | /** Never void the labels. */ |
| 538 | - $value = $entry[ $input['id'] ]; |
|
| 538 | + $value = $entry[ $input[ 'id' ] ]; |
|
| 539 | 539 | break; |
| 540 | 540 | case 2: |
| 541 | 541 | /** Always recalcualte the final price. */ |
@@ -543,25 +543,25 @@ discard block |
||
| 543 | 543 | break; |
| 544 | 544 | case 3: |
| 545 | 545 | /** Fetch the quantity form the request. */ |
| 546 | - $value = rgpost( $input_name, $entry[ $input['id'] ] ); |
|
| 546 | + $value = rgpost( $input_name, $entry[ $input[ 'id' ] ] ); |
|
| 547 | 547 | break; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, $value, $input_name, $entry['id'], $entry ); |
|
| 550 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, $value, $input_name, $entry[ 'id' ], $entry ); |
|
| 551 | 551 | } |
| 552 | 552 | } else { |
| 553 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 554 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 553 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
| 554 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - if( $update ) { |
|
| 560 | + if ( $update ) { |
|
| 561 | 561 | |
| 562 | 562 | $return_entry = GFAPI::update_entry( $entry ); |
| 563 | 563 | |
| 564 | - if( is_wp_error( $return_entry ) ) { |
|
| 564 | + if ( is_wp_error( $return_entry ) ) { |
|
| 565 | 565 | do_action( 'gravityview_log_error', 'Updating the entry calculation fields failed', $return_entry ); |
| 566 | 566 | } else { |
| 567 | 567 | do_action( 'gravityview_log_debug', 'Updating the entry calculation fields succeeded' ); |
@@ -592,19 +592,19 @@ discard block |
||
| 592 | 592 | |
| 593 | 593 | $input_name = 'input_' . $field_id; |
| 594 | 594 | |
| 595 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 595 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 596 | 596 | |
| 597 | 597 | // We have a new image |
| 598 | 598 | |
| 599 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 599 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 600 | 600 | |
| 601 | 601 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 602 | 602 | $ary = stripslashes_deep( $ary ); |
| 603 | 603 | $img_url = rgar( $ary, 0 ); |
| 604 | 604 | |
| 605 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 606 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 607 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 605 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 606 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 607 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 608 | 608 | |
| 609 | 609 | $image_meta = array( |
| 610 | 610 | 'post_excerpt' => $img_caption, |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | |
| 614 | 614 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 615 | 615 | if ( ! empty( $img_title ) ) { |
| 616 | - $image_meta['post_title'] = $img_title; |
|
| 616 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | /** |
@@ -627,11 +627,11 @@ discard block |
||
| 627 | 627 | set_post_thumbnail( $post_id, $media_id ); |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - } elseif ( !empty( $_POST[ $input_name ] ) && is_array( $value ) ) { |
|
| 630 | + } elseif ( ! empty( $_POST[ $input_name ] ) && is_array( $value ) ) { |
|
| 631 | 631 | |
| 632 | 632 | $img_url = rgpost( $input_name ); |
| 633 | - $img_title = rgpost( $input_name . '_1' ); |
|
| 634 | - $img_caption = rgpost( $input_name . '_4' ); |
|
| 633 | + $img_title = rgpost( $input_name . '_1' ); |
|
| 634 | + $img_caption = rgpost( $input_name . '_4' ); |
|
| 635 | 635 | $img_description = rgpost( $input_name . '_7' ); |
| 636 | 636 | |
| 637 | 637 | $value = ! empty( $img_url ) ? $img_url . "|:|" . $img_title . "|:|" . $img_caption . "|:|" . $img_description : ''; |
@@ -670,16 +670,16 @@ discard block |
||
| 670 | 670 | */ |
| 671 | 671 | private function maybe_update_post_fields( $form ) { |
| 672 | 672 | |
| 673 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 673 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 674 | 674 | do_action( 'gravityview_log_debug', __METHOD__ . ': This entry has no post fields. Continuing...' ); |
| 675 | 675 | return; |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - $post_id = $this->entry['post_id']; |
|
| 678 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 679 | 679 | |
| 680 | 680 | // Security check |
| 681 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 682 | - do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id ); |
|
| 681 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 682 | + do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id ); |
|
| 683 | 683 | return; |
| 684 | 684 | } |
| 685 | 685 | |
@@ -691,25 +691,25 @@ discard block |
||
| 691 | 691 | |
| 692 | 692 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 693 | 693 | |
| 694 | - if( ! $field ) { |
|
| 694 | + if ( ! $field ) { |
|
| 695 | 695 | continue; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 698 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 699 | 699 | |
| 700 | 700 | // Get the value of the field, including $_POSTed value |
| 701 | 701 | $value = RGFormsModel::get_field_value( $field ); |
| 702 | 702 | |
| 703 | 703 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 704 | 704 | $entry_tmp = $this->entry; |
| 705 | - $entry_tmp["{$field_id}"] = $value; |
|
| 705 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 706 | 706 | |
| 707 | - switch( $field->type ) { |
|
| 707 | + switch ( $field->type ) { |
|
| 708 | 708 | |
| 709 | 709 | case 'post_title': |
| 710 | 710 | $post_title = $value; |
| 711 | - if( rgar( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 712 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 711 | + if ( rgar( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 712 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 713 | 713 | } |
| 714 | 714 | $updated_post->post_title = $post_title; |
| 715 | 715 | $updated_post->post_name = $post_title; |
@@ -718,8 +718,8 @@ discard block |
||
| 718 | 718 | |
| 719 | 719 | case 'post_content': |
| 720 | 720 | $post_content = $value; |
| 721 | - if( rgar( $form, 'postContentTemplateEnabled' ) ) { |
|
| 722 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 721 | + if ( rgar( $form, 'postContentTemplateEnabled' ) ) { |
|
| 722 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 723 | 723 | } |
| 724 | 724 | $updated_post->post_content = $post_content; |
| 725 | 725 | unset( $post_content ); |
@@ -737,12 +737,12 @@ discard block |
||
| 737 | 737 | $value = $value[ $field_id ]; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 740 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 741 | 741 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
| 745 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 745 | + $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | // update entry after |
| 758 | - $this->entry["{$field_id}"] = $value; |
|
| 758 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 759 | 759 | |
| 760 | 760 | $update_entry = true; |
| 761 | 761 | |
@@ -764,25 +764,25 @@ discard block |
||
| 764 | 764 | |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | - if( $update_entry ) { |
|
| 767 | + if ( $update_entry ) { |
|
| 768 | 768 | |
| 769 | 769 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 770 | 770 | |
| 771 | - if( is_wp_error( $return_entry ) ) { |
|
| 771 | + if ( is_wp_error( $return_entry ) ) { |
|
| 772 | 772 | do_action( 'gravityview_log_error', 'Updating the entry post fields failed', array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ); |
| 773 | 773 | } else { |
| 774 | - do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' ); |
|
| 774 | + do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded' ); |
|
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | $return_post = wp_update_post( $updated_post, true ); |
| 780 | 780 | |
| 781 | - if( is_wp_error( $return_post ) ) { |
|
| 781 | + if ( is_wp_error( $return_post ) ) { |
|
| 782 | 782 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 783 | 783 | do_action( 'gravityview_log_error', 'Updating the post content failed', compact( 'updated_post', 'return_post' ) ); |
| 784 | 784 | } else { |
| 785 | - do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded', $updated_post ); |
|
| 785 | + do_action( 'gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded', $updated_post ); |
|
| 786 | 786 | } |
| 787 | 787 | } |
| 788 | 788 | |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | $input_type = RGFormsModel::get_input_type( $field ); |
| 801 | 801 | |
| 802 | 802 | // Only certain custom field types are supported |
| 803 | - switch( $input_type ) { |
|
| 803 | + switch ( $input_type ) { |
|
| 804 | 804 | case 'fileupload': |
| 805 | 805 | case 'list': |
| 806 | 806 | case 'multiselect': |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 838 | 838 | |
| 839 | 839 | // replace conditional shortcodes |
| 840 | - if( $do_shortcode ) { |
|
| 840 | + if ( $do_shortcode ) { |
|
| 841 | 841 | $output = do_shortcode( $output ); |
| 842 | 842 | } |
| 843 | 843 | |
@@ -856,19 +856,19 @@ discard block |
||
| 856 | 856 | */ |
| 857 | 857 | private function after_update() { |
| 858 | 858 | |
| 859 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
| 860 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
| 859 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 860 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 861 | 861 | |
| 862 | 862 | // Re-define the entry now that we've updated it. |
| 863 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 863 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 864 | 864 | |
| 865 | 865 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
| 866 | 866 | |
| 867 | 867 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 868 | 868 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 869 | 869 | // we have just updated. |
| 870 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 871 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 870 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 871 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 872 | 872 | } |
| 873 | 873 | } |
| 874 | 874 | |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | |
| 888 | 888 | <div class="gv-edit-entry-wrapper"><?php |
| 889 | 889 | |
| 890 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 890 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 891 | 891 | |
| 892 | 892 | /** |
| 893 | 893 | * Fixes weird wpautop() issue |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 904 | 904 | * @param GravityView_Edit_Entry_Render $this This object |
| 905 | 905 | */ |
| 906 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 906 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 907 | 907 | |
| 908 | 908 | echo esc_attr( $edit_entry_title ); |
| 909 | 909 | ?></span> |
@@ -949,20 +949,20 @@ discard block |
||
| 949 | 949 | */ |
| 950 | 950 | private function maybe_print_message() { |
| 951 | 951 | |
| 952 | - if( rgpost('action') === 'update' ) { |
|
| 952 | + if ( rgpost( 'action' ) === 'update' ) { |
|
| 953 | 953 | |
| 954 | 954 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
| 955 | 955 | |
| 956 | - if( ! $this->is_valid ){ |
|
| 956 | + if ( ! $this->is_valid ) { |
|
| 957 | 957 | |
| 958 | 958 | // Keeping this compatible with Gravity Forms. |
| 959 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 960 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 959 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 960 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 961 | 961 | |
| 962 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 962 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 963 | 963 | |
| 964 | 964 | } else { |
| 965 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
| 965 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
| 966 | 966 | |
| 967 | 967 | /** |
| 968 | 968 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | * @param array $entry Gravity Forms entry array |
| 973 | 973 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 974 | 974 | */ |
| 975 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 975 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 976 | 976 | |
| 977 | 977 | echo GVCommon::generate_notice( $message ); |
| 978 | 978 | } |
@@ -996,21 +996,21 @@ discard block |
||
| 996 | 996 | */ |
| 997 | 997 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 998 | 998 | |
| 999 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1000 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 999 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1000 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1001 | 1001 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1002 | 1002 | |
| 1003 | 1003 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
| 1004 | 1004 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1005 | 1005 | |
| 1006 | 1006 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1007 | - unset( $_GET['page'] ); |
|
| 1007 | + unset( $_GET[ 'page' ] ); |
|
| 1008 | 1008 | |
| 1009 | 1009 | // TODO: Verify multiple-page forms |
| 1010 | 1010 | |
| 1011 | 1011 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1012 | 1012 | |
| 1013 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1013 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1014 | 1014 | |
| 1015 | 1015 | ob_get_clean(); |
| 1016 | 1016 | |
@@ -1036,7 +1036,7 @@ discard block |
||
| 1036 | 1036 | * @return string |
| 1037 | 1037 | */ |
| 1038 | 1038 | public function render_form_buttons() { |
| 1039 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1039 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | |
@@ -1056,10 +1056,10 @@ discard block |
||
| 1056 | 1056 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1057 | 1057 | |
| 1058 | 1058 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1059 | - if( isset( $this->form_after_validation ) ) { |
|
| 1059 | + if ( isset( $this->form_after_validation ) ) { |
|
| 1060 | 1060 | $form = $this->form_after_validation; |
| 1061 | 1061 | } else { |
| 1062 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1062 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | $form = $this->filter_conditional_logic( $form ); |
@@ -1067,8 +1067,8 @@ discard block |
||
| 1067 | 1067 | $form = $this->prefill_conditional_logic( $form ); |
| 1068 | 1068 | |
| 1069 | 1069 | // for now we don't support Save and Continue feature. |
| 1070 | - if( ! self::$supports_save_and_continue ) { |
|
| 1071 | - unset( $form['save'] ); |
|
| 1070 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1071 | + unset( $form[ 'save' ] ); |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | return $form; |
@@ -1089,29 +1089,29 @@ discard block |
||
| 1089 | 1089 | */ |
| 1090 | 1090 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 1091 | 1091 | |
| 1092 | - if( GFCommon::is_post_field( $field ) ) { |
|
| 1092 | + if ( GFCommon::is_post_field( $field ) ) { |
|
| 1093 | 1093 | |
| 1094 | 1094 | $message = null; |
| 1095 | 1095 | |
| 1096 | 1096 | // First, make sure they have the capability to edit the post. |
| 1097 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1097 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1098 | 1098 | |
| 1099 | 1099 | /** |
| 1100 | 1100 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1101 | 1101 | * @param string $message The existing "You don't have permission..." text |
| 1102 | 1102 | */ |
| 1103 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1103 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1104 | 1104 | |
| 1105 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1105 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1106 | 1106 | /** |
| 1107 | 1107 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1108 | 1108 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1109 | 1109 | */ |
| 1110 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1110 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | - if( $message ) { |
|
| 1114 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1113 | + if ( $message ) { |
|
| 1114 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | } |
| 1117 | 1117 | |
@@ -1136,8 +1136,8 @@ discard block |
||
| 1136 | 1136 | |
| 1137 | 1137 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1138 | 1138 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1139 | - if( |
|
| 1140 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1139 | + if ( |
|
| 1140 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1141 | 1141 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1142 | 1142 | && ! GFCommon::is_product_field( $field->type ) |
| 1143 | 1143 | || ! empty( $field_content ) |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | $return = null; |
| 1158 | 1158 | |
| 1159 | 1159 | /** @var GravityView_Field $gv_field */ |
| 1160 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1160 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1161 | 1161 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1162 | 1162 | } else { |
| 1163 | 1163 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1166,7 +1166,7 @@ discard block |
||
| 1166 | 1166 | // If there was output, it's an error |
| 1167 | 1167 | $warnings = ob_get_clean(); |
| 1168 | 1168 | |
| 1169 | - if( !empty( $warnings ) ) { |
|
| 1169 | + if ( ! empty( $warnings ) ) { |
|
| 1170 | 1170 | do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value ); |
| 1171 | 1171 | } |
| 1172 | 1172 | |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1192 | 1192 | |
| 1193 | 1193 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1194 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1194 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1195 | 1195 | |
| 1196 | 1196 | $field_value = array(); |
| 1197 | 1197 | |
@@ -1200,10 +1200,10 @@ discard block |
||
| 1200 | 1200 | |
| 1201 | 1201 | foreach ( (array)$field->inputs as $input ) { |
| 1202 | 1202 | |
| 1203 | - $input_id = strval( $input['id'] ); |
|
| 1203 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1204 | 1204 | |
| 1205 | 1205 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1206 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1206 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1207 | 1207 | $allow_pre_populated = false; |
| 1208 | 1208 | } |
| 1209 | 1209 | |
@@ -1211,7 +1211,7 @@ discard block |
||
| 1211 | 1211 | |
| 1212 | 1212 | $pre_value = $field->get_value_submission( array(), false ); |
| 1213 | 1213 | |
| 1214 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1214 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1215 | 1215 | |
| 1216 | 1216 | } else { |
| 1217 | 1217 | |
@@ -1222,13 +1222,13 @@ discard block |
||
| 1222 | 1222 | |
| 1223 | 1223 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1224 | 1224 | // or pre-populated value if not empty and set to override saved value |
| 1225 | - $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1225 | + $field_value = ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1226 | 1226 | |
| 1227 | 1227 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1228 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1228 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1229 | 1229 | $categories = array(); |
| 1230 | 1230 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1231 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1231 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1232 | 1232 | } |
| 1233 | 1233 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1234 | 1234 | } |
@@ -1256,7 +1256,7 @@ discard block |
||
| 1256 | 1256 | * @param GF_Field $field Gravity Forms field object |
| 1257 | 1257 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1258 | 1258 | */ |
| 1259 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1259 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1260 | 1260 | |
| 1261 | 1261 | return $field_value; |
| 1262 | 1262 | } |
@@ -1273,12 +1273,12 @@ discard block |
||
| 1273 | 1273 | */ |
| 1274 | 1274 | public function gform_pre_validation( $form ) { |
| 1275 | 1275 | |
| 1276 | - if( ! $this->verify_nonce() ) { |
|
| 1276 | + if ( ! $this->verify_nonce() ) { |
|
| 1277 | 1277 | return $form; |
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | // Fix PHP warning regarding undefined index. |
| 1281 | - foreach ( $form['fields'] as &$field) { |
|
| 1281 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1282 | 1282 | |
| 1283 | 1283 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1284 | 1284 | // expects certain field array items to be set. |
@@ -1286,7 +1286,7 @@ discard block |
||
| 1286 | 1286 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1287 | 1287 | } |
| 1288 | 1288 | |
| 1289 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1289 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1290 | 1290 | |
| 1291 | 1291 | /** |
| 1292 | 1292 | * 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. |
@@ -1300,37 +1300,37 @@ discard block |
||
| 1300 | 1300 | // Set the previous value |
| 1301 | 1301 | $entry = $this->get_entry(); |
| 1302 | 1302 | |
| 1303 | - $input_name = 'input_'.$field->id; |
|
| 1304 | - $form_id = $form['id']; |
|
| 1303 | + $input_name = 'input_' . $field->id; |
|
| 1304 | + $form_id = $form[ 'id' ]; |
|
| 1305 | 1305 | |
| 1306 | 1306 | $value = NULL; |
| 1307 | 1307 | |
| 1308 | 1308 | // Use the previous entry value as the default. |
| 1309 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1309 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1310 | 1310 | $value = $entry[ $field->id ]; |
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | 1313 | // If this is a single upload file |
| 1314 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1315 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1316 | - $value = $file_path['url']; |
|
| 1314 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1315 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1316 | + $value = $file_path[ 'url' ]; |
|
| 1317 | 1317 | |
| 1318 | 1318 | } else { |
| 1319 | 1319 | |
| 1320 | 1320 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1321 | 1321 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1322 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1322 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1323 | 1323 | |
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | - if( rgar($field, "multipleFiles") ) { |
|
| 1326 | + if ( rgar( $field, "multipleFiles" ) ) { |
|
| 1327 | 1327 | |
| 1328 | 1328 | // If there are fresh uploads, process and merge them. |
| 1329 | 1329 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1330 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1330 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1331 | 1331 | $value = empty( $value ) ? '[]' : $value; |
| 1332 | 1332 | $value = stripslashes_deep( $value ); |
| 1333 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1333 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | } else { |
@@ -1348,8 +1348,8 @@ discard block |
||
| 1348 | 1348 | |
| 1349 | 1349 | case 'number': |
| 1350 | 1350 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1351 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1352 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1351 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1352 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1353 | 1353 | } |
| 1354 | 1354 | break; |
| 1355 | 1355 | } |
@@ -1391,7 +1391,7 @@ discard block |
||
| 1391 | 1391 | * You can enter whatever you want! |
| 1392 | 1392 | * We try validating, and customize the results using `self::custom_validation()` |
| 1393 | 1393 | */ |
| 1394 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1394 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1395 | 1395 | |
| 1396 | 1396 | // Needed by the validate funtion |
| 1397 | 1397 | $failed_validation_page = NULL; |
@@ -1399,14 +1399,14 @@ discard block |
||
| 1399 | 1399 | |
| 1400 | 1400 | // Prevent entry limit from running when editing an entry, also |
| 1401 | 1401 | // prevent form scheduling from preventing editing |
| 1402 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1402 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1403 | 1403 | |
| 1404 | 1404 | // Hide fields depending on Edit Entry settings |
| 1405 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1405 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1406 | 1406 | |
| 1407 | 1407 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1408 | 1408 | |
| 1409 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1409 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1410 | 1410 | remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'user_registration_validation' ), 10 ); |
| 1411 | 1411 | } |
| 1412 | 1412 | |
@@ -1423,7 +1423,7 @@ discard block |
||
| 1423 | 1423 | $user_registration = GF_User_Registration::get_instance(); |
| 1424 | 1424 | |
| 1425 | 1425 | $entry = $this->get_entry(); |
| 1426 | - $form = $validation_results['form']; |
|
| 1426 | + $form = $validation_results[ 'form' ]; |
|
| 1427 | 1427 | |
| 1428 | 1428 | if ( ! $feed = $user_registration->get_single_submission_feed( $entry, $form ) ) { |
| 1429 | 1429 | return $validation_results; |
@@ -1439,18 +1439,18 @@ discard block |
||
| 1439 | 1439 | if ( $user_email != $value && email_exists( $value ) ) { |
| 1440 | 1440 | $email_field->failed_validation = 1; |
| 1441 | 1441 | $email_field->validation_message = __( 'This email is already in use', 'gravityview' ); |
| 1442 | - $validation_results['is_valid'] = false; |
|
| 1442 | + $validation_results[ 'is_valid' ] = false; |
|
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | 1445 | $value = RGFormsModel::get_field_value( $username_field ); |
| 1446 | 1446 | if ( $username != $value ) { |
| 1447 | 1447 | $username_field->failed_validation = 1; |
| 1448 | 1448 | $username_field->validation_message = __( 'Usernames cannot be changed', 'gravityview' ); |
| 1449 | - $validation_results['is_valid'] = false; |
|
| 1449 | + $validation_results[ 'is_valid' ] = false; |
|
| 1450 | 1450 | } |
| 1451 | 1451 | |
| 1452 | 1452 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1453 | - $this->form_after_validation = $validation_results['form']; |
|
| 1453 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1454 | 1454 | |
| 1455 | 1455 | return $validation_results; |
| 1456 | 1456 | } |
@@ -1468,13 +1468,13 @@ discard block |
||
| 1468 | 1468 | */ |
| 1469 | 1469 | public function custom_validation( $validation_results ) { |
| 1470 | 1470 | |
| 1471 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
| 1471 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
| 1472 | 1472 | |
| 1473 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 1473 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 1474 | 1474 | |
| 1475 | 1475 | $gv_valid = true; |
| 1476 | 1476 | |
| 1477 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1477 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1478 | 1478 | |
| 1479 | 1479 | $value = RGFormsModel::get_field_value( $field ); |
| 1480 | 1480 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1487,35 +1487,35 @@ discard block |
||
| 1487 | 1487 | case 'post_image': |
| 1488 | 1488 | |
| 1489 | 1489 | // in case nothing is uploaded but there are already files saved |
| 1490 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1490 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1491 | 1491 | $field->failed_validation = false; |
| 1492 | 1492 | unset( $field->validation_message ); |
| 1493 | 1493 | } |
| 1494 | 1494 | |
| 1495 | 1495 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1496 | - if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { |
|
| 1496 | + if ( rgobj( $field, 'maxFiles' ) && rgobj( $field, 'multipleFiles' ) ) { |
|
| 1497 | 1497 | |
| 1498 | 1498 | $input_name = 'input_' . $field->id; |
| 1499 | 1499 | //uploaded |
| 1500 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1500 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1501 | 1501 | |
| 1502 | 1502 | //existent |
| 1503 | 1503 | $entry = $this->get_entry(); |
| 1504 | 1504 | $value = NULL; |
| 1505 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1505 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1506 | 1506 | $value = json_decode( $entry[ $field->id ], true ); |
| 1507 | 1507 | } |
| 1508 | 1508 | |
| 1509 | 1509 | // count uploaded files and existent entry files |
| 1510 | 1510 | $count_files = count( $file_names ) + count( $value ); |
| 1511 | 1511 | |
| 1512 | - if( $count_files > $field->maxFiles ) { |
|
| 1512 | + if ( $count_files > $field->maxFiles ) { |
|
| 1513 | 1513 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1514 | 1514 | $field->failed_validation = 1; |
| 1515 | 1515 | $gv_valid = false; |
| 1516 | 1516 | |
| 1517 | 1517 | // in case of error make sure the newest upload files are removed from the upload input |
| 1518 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1518 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1519 | 1519 | } |
| 1520 | 1520 | |
| 1521 | 1521 | } |
@@ -1526,7 +1526,7 @@ discard block |
||
| 1526 | 1526 | } |
| 1527 | 1527 | |
| 1528 | 1528 | // This field has failed validation. |
| 1529 | - if( !empty( $field->failed_validation ) ) { |
|
| 1529 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1530 | 1530 | |
| 1531 | 1531 | do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) ); |
| 1532 | 1532 | |
@@ -1544,32 +1544,32 @@ discard block |
||
| 1544 | 1544 | } |
| 1545 | 1545 | |
| 1546 | 1546 | // You can't continue inside a switch, so we do it after. |
| 1547 | - if( empty( $field->failed_validation ) ) { |
|
| 1547 | + if ( empty( $field->failed_validation ) ) { |
|
| 1548 | 1548 | continue; |
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | 1551 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1552 | 1552 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1553 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1553 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1554 | 1554 | |
| 1555 | 1555 | $entry = $this->get_entry(); |
| 1556 | 1556 | |
| 1557 | 1557 | // If the value of the entry is the same as the stored value |
| 1558 | 1558 | // Then we can assume it's not a duplicate, it's the same. |
| 1559 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1559 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1560 | 1560 | //if value submitted was not changed, then don't validate |
| 1561 | 1561 | $field->failed_validation = false; |
| 1562 | 1562 | |
| 1563 | 1563 | unset( $field->validation_message ); |
| 1564 | 1564 | |
| 1565 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
| 1565 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
| 1566 | 1566 | |
| 1567 | 1567 | continue; |
| 1568 | 1568 | } |
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | 1571 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1572 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1572 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1573 | 1573 | unset( $field->validation_message ); |
| 1574 | 1574 | $field->validation_message = false; |
| 1575 | 1575 | continue; |
@@ -1581,12 +1581,12 @@ discard block |
||
| 1581 | 1581 | |
| 1582 | 1582 | } |
| 1583 | 1583 | |
| 1584 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1584 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1585 | 1585 | |
| 1586 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
| 1586 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
| 1587 | 1587 | |
| 1588 | 1588 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1589 | - $this->form_after_validation = $validation_results['form']; |
|
| 1589 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1590 | 1590 | |
| 1591 | 1591 | return $validation_results; |
| 1592 | 1592 | } |
@@ -1599,7 +1599,7 @@ discard block |
||
| 1599 | 1599 | */ |
| 1600 | 1600 | public function get_entry() { |
| 1601 | 1601 | |
| 1602 | - if( empty( $this->entry ) ) { |
|
| 1602 | + if ( empty( $this->entry ) ) { |
|
| 1603 | 1603 | // Get the database value of the entry that's being edited |
| 1604 | 1604 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1605 | 1605 | } |
@@ -1634,10 +1634,10 @@ discard block |
||
| 1634 | 1634 | } |
| 1635 | 1635 | |
| 1636 | 1636 | // If edit tab not yet configured, show all fields |
| 1637 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1637 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1638 | 1638 | |
| 1639 | 1639 | // Hide fields depending on admin settings |
| 1640 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1640 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1641 | 1641 | |
| 1642 | 1642 | // If Edit Entry fields are configured, remove hidden/administrative field settings. Otherwise, don't. |
| 1643 | 1643 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1669,7 +1669,7 @@ discard block |
||
| 1669 | 1669 | */ |
| 1670 | 1670 | private function filter_fields( $fields, $configured_fields ) { |
| 1671 | 1671 | |
| 1672 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1672 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1673 | 1673 | return $fields; |
| 1674 | 1674 | } |
| 1675 | 1675 | |
@@ -1682,18 +1682,18 @@ discard block |
||
| 1682 | 1682 | |
| 1683 | 1683 | // Remove the fields that have calculation properties and keep them to be used later |
| 1684 | 1684 | // @since 1.16.2 |
| 1685 | - if( $field->has_calculation() ) { |
|
| 1686 | - $this->fields_with_calculation[] = $field; |
|
| 1685 | + if ( $field->has_calculation() ) { |
|
| 1686 | + $this->fields_with_calculation[ ] = $field; |
|
| 1687 | 1687 | // don't remove the calculation fields on form render. |
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1690 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1691 | 1691 | unset( $fields[ $key ] ); |
| 1692 | 1692 | } |
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | 1695 | // The Edit tab has not been configured, so we return all fields by default. |
| 1696 | - if( empty( $configured_fields ) ) { |
|
| 1696 | + if ( empty( $configured_fields ) ) { |
|
| 1697 | 1697 | return $fields; |
| 1698 | 1698 | } |
| 1699 | 1699 | |
@@ -1703,8 +1703,8 @@ discard block |
||
| 1703 | 1703 | /** @var GF_Field $field */ |
| 1704 | 1704 | foreach ( $fields as $field ) { |
| 1705 | 1705 | |
| 1706 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1707 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1706 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1707 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1708 | 1708 | break; |
| 1709 | 1709 | } |
| 1710 | 1710 | |
@@ -1727,14 +1727,14 @@ discard block |
||
| 1727 | 1727 | |
| 1728 | 1728 | $return_field = $field; |
| 1729 | 1729 | |
| 1730 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1730 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1731 | 1731 | $return_field->label = ''; |
| 1732 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1733 | - $return_field->label = $field_setting['custom_label']; |
|
| 1732 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1733 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1737 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1736 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1737 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1738 | 1738 | } |
| 1739 | 1739 | |
| 1740 | 1740 | /** |
@@ -1785,16 +1785,16 @@ discard block |
||
| 1785 | 1785 | */ |
| 1786 | 1786 | $use_gf_visibility_setting = apply_filters( 'gravityview/edit_entry/use_gf_visibility_setting', empty( $edit_fields ), $form, $view_id ); |
| 1787 | 1787 | |
| 1788 | - if( $use_gf_adminonly_setting && $use_gf_visibility_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1789 | - foreach( $fields as $k => $field ) { |
|
| 1790 | - if( 'administrative' === $field->visibility ) { |
|
| 1788 | + if ( $use_gf_adminonly_setting && $use_gf_visibility_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1789 | + foreach ( $fields as $k => $field ) { |
|
| 1790 | + if ( 'administrative' === $field->visibility ) { |
|
| 1791 | 1791 | unset( $fields[ $k ] ); |
| 1792 | 1792 | } |
| 1793 | 1793 | } |
| 1794 | 1794 | return $fields; |
| 1795 | 1795 | } |
| 1796 | 1796 | |
| 1797 | - foreach( $fields as &$field ) { |
|
| 1797 | + foreach ( $fields as &$field ) { |
|
| 1798 | 1798 | |
| 1799 | 1799 | /** |
| 1800 | 1800 | * @filter `gravityview/edit_entry/make_all_fields_visible` Set field visibility to "visible" for all fields |
@@ -1828,22 +1828,22 @@ discard block |
||
| 1828 | 1828 | */ |
| 1829 | 1829 | function prefill_conditional_logic( $form ) { |
| 1830 | 1830 | |
| 1831 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1831 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1832 | 1832 | return $form; |
| 1833 | 1833 | } |
| 1834 | 1834 | |
| 1835 | 1835 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 1836 | 1836 | /** @var GF_Field $field */ |
| 1837 | - foreach ( $form['fields'] as &$field ) { |
|
| 1837 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1838 | 1838 | |
| 1839 | - if( 'checkbox' === $field->type ) { |
|
| 1839 | + if ( 'checkbox' === $field->type ) { |
|
| 1840 | 1840 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1841 | - $input_id = $input['id']; |
|
| 1841 | + $input_id = $input[ 'id' ]; |
|
| 1842 | 1842 | $choice = $field->choices[ $key ]; |
| 1843 | 1843 | $value = rgar( $this->entry, $input_id ); |
| 1844 | 1844 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 1845 | - if( $match ) { |
|
| 1846 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1845 | + if ( $match ) { |
|
| 1846 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 1847 | 1847 | } |
| 1848 | 1848 | } |
| 1849 | 1849 | } else { |
@@ -1851,15 +1851,15 @@ discard block |
||
| 1851 | 1851 | // We need to run through each field to set the default values |
| 1852 | 1852 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1853 | 1853 | |
| 1854 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1854 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1855 | 1855 | |
| 1856 | - if( 'list' === $field->type ) { |
|
| 1856 | + if ( 'list' === $field->type ) { |
|
| 1857 | 1857 | $list_rows = maybe_unserialize( $field_value ); |
| 1858 | 1858 | |
| 1859 | 1859 | $list_field_value = array(); |
| 1860 | - foreach ( (array) $list_rows as $row ) { |
|
| 1861 | - foreach ( (array) $row as $column ) { |
|
| 1862 | - $list_field_value[] = $column; |
|
| 1860 | + foreach ( (array)$list_rows as $row ) { |
|
| 1861 | + foreach ( (array)$row as $column ) { |
|
| 1862 | + $list_field_value[ ] = $column; |
|
| 1863 | 1863 | } |
| 1864 | 1864 | } |
| 1865 | 1865 | |
@@ -1894,16 +1894,16 @@ discard block |
||
| 1894 | 1894 | */ |
| 1895 | 1895 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 1896 | 1896 | |
| 1897 | - if( $use_conditional_logic ) { |
|
| 1897 | + if ( $use_conditional_logic ) { |
|
| 1898 | 1898 | return $form; |
| 1899 | 1899 | } |
| 1900 | 1900 | |
| 1901 | - foreach( $form['fields'] as &$field ) { |
|
| 1901 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1902 | 1902 | /* @var GF_Field $field */ |
| 1903 | 1903 | $field->conditionalLogic = null; |
| 1904 | 1904 | } |
| 1905 | 1905 | |
| 1906 | - unset( $form['button']['conditionalLogic'] ); |
|
| 1906 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 1907 | 1907 | |
| 1908 | 1908 | return $form; |
| 1909 | 1909 | |
@@ -1920,7 +1920,7 @@ discard block |
||
| 1920 | 1920 | */ |
| 1921 | 1921 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 1922 | 1922 | |
| 1923 | - if( ! $this->is_edit_entry() ) { |
|
| 1923 | + if ( ! $this->is_edit_entry() ) { |
|
| 1924 | 1924 | return $has_conditional_logic; |
| 1925 | 1925 | } |
| 1926 | 1926 | |
@@ -1952,44 +1952,44 @@ discard block |
||
| 1952 | 1952 | * 2. There are two entries embedded using oEmbed |
| 1953 | 1953 | * 3. One of the entries has just been saved |
| 1954 | 1954 | */ |
| 1955 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 1955 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 1956 | 1956 | |
| 1957 | 1957 | $error = true; |
| 1958 | 1958 | |
| 1959 | 1959 | } |
| 1960 | 1960 | |
| 1961 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 1961 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 1962 | 1962 | |
| 1963 | 1963 | $error = true; |
| 1964 | 1964 | |
| 1965 | - } elseif( ! $this->verify_nonce() ) { |
|
| 1965 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 1966 | 1966 | |
| 1967 | 1967 | /** |
| 1968 | 1968 | * If the Entry is embedded, there may be two entries on the same page. |
| 1969 | 1969 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 1970 | 1970 | */ |
| 1971 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1971 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1972 | 1972 | $error = true; |
| 1973 | 1973 | } else { |
| 1974 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 1974 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 1975 | 1975 | } |
| 1976 | 1976 | |
| 1977 | 1977 | } |
| 1978 | 1978 | |
| 1979 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1980 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 1979 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1980 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | - if( $this->entry['status'] === 'trash' ) { |
|
| 1984 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1983 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 1984 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | // No errors; everything's fine here! |
| 1988 | - if( empty( $error ) ) { |
|
| 1988 | + if ( empty( $error ) ) { |
|
| 1989 | 1989 | return true; |
| 1990 | 1990 | } |
| 1991 | 1991 | |
| 1992 | - if( $echo && $error !== true ) { |
|
| 1992 | + if ( $echo && $error !== true ) { |
|
| 1993 | 1993 | |
| 1994 | 1994 | $error = esc_html( $error ); |
| 1995 | 1995 | |
@@ -1997,13 +1997,13 @@ discard block |
||
| 1997 | 1997 | * @since 1.9 |
| 1998 | 1998 | */ |
| 1999 | 1999 | if ( ! empty( $this->entry ) ) { |
| 2000 | - $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;" ) ); |
|
| 2000 | + $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;" ) ); |
|
| 2001 | 2001 | } |
| 2002 | 2002 | |
| 2003 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 2003 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 2004 | 2004 | } |
| 2005 | 2005 | |
| 2006 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
| 2006 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
| 2007 | 2007 | |
| 2008 | 2008 | return false; |
| 2009 | 2009 | } |
@@ -2020,20 +2020,20 @@ discard block |
||
| 2020 | 2020 | |
| 2021 | 2021 | $error = NULL; |
| 2022 | 2022 | |
| 2023 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2024 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 2023 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2024 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 2025 | 2025 | } |
| 2026 | 2026 | |
| 2027 | 2027 | // No errors; everything's fine here! |
| 2028 | - if( empty( $error ) ) { |
|
| 2028 | + if ( empty( $error ) ) { |
|
| 2029 | 2029 | return true; |
| 2030 | 2030 | } |
| 2031 | 2031 | |
| 2032 | - if( $echo ) { |
|
| 2033 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 2032 | + if ( $echo ) { |
|
| 2033 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 2034 | 2034 | } |
| 2035 | 2035 | |
| 2036 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
| 2036 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
| 2037 | 2037 | |
| 2038 | 2038 | return false; |
| 2039 | 2039 | |
@@ -2051,15 +2051,15 @@ discard block |
||
| 2051 | 2051 | private function check_user_cap_edit_field( $field ) { |
| 2052 | 2052 | |
| 2053 | 2053 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 2054 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2054 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2055 | 2055 | return true; |
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 2058 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 2059 | 2059 | |
| 2060 | 2060 | // If the field has custom editing capaibilities set, check those |
| 2061 | - if( $field_cap ) { |
|
| 2062 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 2061 | + if ( $field_cap ) { |
|
| 2062 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 2063 | 2063 | } |
| 2064 | 2064 | |
| 2065 | 2065 | return false; |
@@ -2073,17 +2073,17 @@ discard block |
||
| 2073 | 2073 | public function verify_nonce() { |
| 2074 | 2074 | |
| 2075 | 2075 | // Verify form submitted for editing single |
| 2076 | - if( $this->is_edit_entry_submission() ) { |
|
| 2076 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2077 | 2077 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | 2080 | // Verify |
| 2081 | - else if( ! $this->is_edit_entry() ) { |
|
| 2081 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2082 | 2082 | $valid = false; |
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | 2085 | else { |
| 2086 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2086 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2087 | 2087 | } |
| 2088 | 2088 | |
| 2089 | 2089 | /** |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @return GV_License_Handler |
| 48 | 48 | */ |
| 49 | 49 | public static function get_instance( GravityView_Settings $GFAddOn ) { |
| 50 | - if( empty( self::$instance ) ) { |
|
| 50 | + if ( empty( self::$instance ) ) { |
|
| 51 | 51 | self::$instance = new self( $GFAddOn ); |
| 52 | 52 | } |
| 53 | 53 | return self::$instance; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | 'url' => home_url(), |
| 124 | 124 | 'site_data' => $this->get_site_data(), |
| 125 | 125 | ), |
| 126 | - )); |
|
| 126 | + ) ); |
|
| 127 | 127 | |
| 128 | 128 | // make sure the response came back okay |
| 129 | 129 | if ( is_wp_error( $response ) ) { |
@@ -149,16 +149,16 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function refresh_license_status() { |
| 151 | 151 | |
| 152 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
| 152 | + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 153 | 153 | return; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | global $pagenow; |
| 157 | 157 | |
| 158 | - $is_force_check = ( isset( $pagenow ) && 'update-core.php' === $pagenow && isset( $_REQUEST['force-check'] ) && '1' === $_REQUEST['force-check'] ); |
|
| 158 | + $is_force_check = ( isset( $pagenow ) && 'update-core.php' === $pagenow && isset( $_REQUEST[ 'force-check' ] ) && '1' === $_REQUEST[ 'force-check' ] ); |
|
| 159 | 159 | |
| 160 | 160 | // The transient is fresh; don't fetch. |
| 161 | - if( $status = get_transient( self::status_transient_key ) && ! $is_force_check ) { |
|
| 161 | + if ( $status = get_transient( self::status_transient_key ) && ! $is_force_check ) { |
|
| 162 | 162 | return; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -191,49 +191,49 @@ discard block |
||
| 191 | 191 | $theme_data = wp_get_theme(); |
| 192 | 192 | $theme = $theme_data->Name . ' ' . $theme_data->Version; |
| 193 | 193 | |
| 194 | - $data['gv_version'] = GravityView_Plugin::version; |
|
| 195 | - $data['php_version'] = phpversion(); |
|
| 196 | - $data['wp_version'] = get_bloginfo( 'version' ); |
|
| 197 | - $data['gf_version'] = GFForms::$version; |
|
| 198 | - $data['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : ''; |
|
| 199 | - $data['multisite'] = is_multisite(); |
|
| 200 | - $data['theme'] = $theme; |
|
| 201 | - $data['url'] = home_url(); |
|
| 202 | - $data['license_key'] = GravityView_Settings::get_instance()->get_app_setting( 'license_key' ); |
|
| 203 | - $data['beta'] = GravityView_Settings::get_instance()->get_app_setting( 'beta' ); |
|
| 194 | + $data[ 'gv_version' ] = GravityView_Plugin::version; |
|
| 195 | + $data[ 'php_version' ] = phpversion(); |
|
| 196 | + $data[ 'wp_version' ] = get_bloginfo( 'version' ); |
|
| 197 | + $data[ 'gf_version' ] = GFForms::$version; |
|
| 198 | + $data[ 'server' ] = isset( $_SERVER[ 'SERVER_SOFTWARE' ] ) ? $_SERVER[ 'SERVER_SOFTWARE' ] : ''; |
|
| 199 | + $data[ 'multisite' ] = is_multisite(); |
|
| 200 | + $data[ 'theme' ] = $theme; |
|
| 201 | + $data[ 'url' ] = home_url(); |
|
| 202 | + $data[ 'license_key' ] = GravityView_Settings::get_instance()->get_app_setting( 'license_key' ); |
|
| 203 | + $data[ 'beta' ] = GravityView_Settings::get_instance()->get_app_setting( 'beta' ); |
|
| 204 | 204 | |
| 205 | 205 | // View Data |
| 206 | - $gravityview_posts = get_posts('numberposts=-1&post_type=gravityview&post_status=publish&order=ASC'); |
|
| 206 | + $gravityview_posts = get_posts( 'numberposts=-1&post_type=gravityview&post_status=publish&order=ASC' ); |
|
| 207 | 207 | |
| 208 | 208 | if ( ! empty( $gravityview_posts ) ) { |
| 209 | 209 | $first = array_shift( $gravityview_posts ); |
| 210 | 210 | $latest = array_pop( $gravityview_posts ); |
| 211 | - $data['view_count'] = count( $gravityview_posts ); |
|
| 212 | - $data['view_first'] = $first->post_date; |
|
| 213 | - $data['view_latest'] = $latest->post_date; |
|
| 211 | + $data[ 'view_count' ] = count( $gravityview_posts ); |
|
| 212 | + $data[ 'view_first' ] = $first->post_date; |
|
| 213 | + $data[ 'view_latest' ] = $latest->post_date; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // Form counts |
| 217 | 217 | if ( class_exists( 'GFFormsModel' ) ) { |
| 218 | 218 | $form_data = GFFormsModel::get_form_count(); |
| 219 | - $data['forms_total'] = rgar( $form_data, 'total', 0 ); |
|
| 220 | - $data['forms_active'] = rgar( $form_data, 'active', 0 ); |
|
| 221 | - $data['forms_inactive'] = rgar( $form_data, 'inactive', 0 ); |
|
| 222 | - $data['forms_trash'] = rgar( $form_data, 'inactive', 0 ); |
|
| 219 | + $data[ 'forms_total' ] = rgar( $form_data, 'total', 0 ); |
|
| 220 | + $data[ 'forms_active' ] = rgar( $form_data, 'active', 0 ); |
|
| 221 | + $data[ 'forms_inactive' ] = rgar( $form_data, 'inactive', 0 ); |
|
| 222 | + $data[ 'forms_trash' ] = rgar( $form_data, 'inactive', 0 ); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // Retrieve current plugin information |
| 226 | - if( ! function_exists( 'get_plugins' ) ) { |
|
| 226 | + if ( ! function_exists( 'get_plugins' ) ) { |
|
| 227 | 227 | include ABSPATH . '/wp-admin/includes/plugin.php'; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - $data['integrations'] = self::get_related_plugins_and_extensions(); |
|
| 231 | - $data['active_plugins'] = get_option( 'active_plugins', array() ); |
|
| 232 | - $data['inactive_plugins'] = array(); |
|
| 233 | - $data['locale'] = get_locale(); |
|
| 230 | + $data[ 'integrations' ] = self::get_related_plugins_and_extensions(); |
|
| 231 | + $data[ 'active_plugins' ] = get_option( 'active_plugins', array() ); |
|
| 232 | + $data[ 'inactive_plugins' ] = array(); |
|
| 233 | + $data[ 'locale' ] = get_locale(); |
|
| 234 | 234 | |
| 235 | 235 | // Validate request on the GV server |
| 236 | - $data['hash'] = 'gv_version.url.locale:' . sha1( $data['gv_version'] . $data['url'] . $data['locale'] ); |
|
| 236 | + $data[ 'hash' ] = 'gv_version.url.locale:' . sha1( $data[ 'gv_version' ] . $data[ 'url' ] . $data[ 'locale' ] ); |
|
| 237 | 237 | |
| 238 | 238 | return $data; |
| 239 | 239 | } |
@@ -265,10 +265,10 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | $plugin_data = get_plugin_data( $active_plugin ); |
| 267 | 267 | |
| 268 | - $extensions[] = sprintf( '%s %s', $plugin_data['Name'], $plugin_data['Version'] ); |
|
| 268 | + $extensions[ ] = sprintf( '%s %s', $plugin_data[ 'Name' ], $plugin_data[ 'Version' ] ); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if( ! empty( $extensions ) ) { |
|
| 271 | + if ( ! empty( $extensions ) ) { |
|
| 272 | 272 | set_site_transient( self::related_plugins_key, $extensions, HOUR_IN_SECONDS ); |
| 273 | 273 | } else { |
| 274 | 274 | return 'There was an error fetching related plugins.'; |
@@ -287,37 +287,37 @@ discard block |
||
| 287 | 287 | $status = trim( $this->Addon->get_app_setting( 'license_key_status' ) ); |
| 288 | 288 | $key = trim( $this->Addon->get_app_setting( 'license_key' ) ); |
| 289 | 289 | |
| 290 | - if( !empty( $key ) ) { |
|
| 290 | + if ( ! empty( $key ) ) { |
|
| 291 | 291 | $response = $this->Addon->get_app_setting( 'license_key_response' ); |
| 292 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
| 292 | + $response = is_array( $response ) ? (object)$response : json_decode( $response ); |
|
| 293 | 293 | } else { |
| 294 | 294 | $response = array(); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array( |
| 298 | 298 | 'license_box' => $this->get_license_message( $response ) |
| 299 | - )); |
|
| 299 | + ) ); |
|
| 300 | 300 | |
| 301 | 301 | |
| 302 | 302 | $fields = array( |
| 303 | 303 | array( |
| 304 | 304 | 'name' => 'edd-activate', |
| 305 | - 'value' => __('Activate License', 'gravityview'), |
|
| 306 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
| 305 | + 'value' => __( 'Activate License', 'gravityview' ), |
|
| 306 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
| 307 | 307 | 'data-edd_action' => 'activate_license', |
| 308 | 308 | 'class' => 'button-primary', |
| 309 | 309 | ), |
| 310 | 310 | array( |
| 311 | 311 | 'name' => 'edd-deactivate', |
| 312 | - 'value' => __('Deactivate License', 'gravityview'), |
|
| 313 | - 'data-pending_text' => __('Deactivating license…', 'gravityview'), |
|
| 312 | + 'value' => __( 'Deactivate License', 'gravityview' ), |
|
| 313 | + 'data-pending_text' => __( 'Deactivating license…', 'gravityview' ), |
|
| 314 | 314 | 'data-edd_action' => 'deactivate_license', |
| 315 | 315 | 'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ), |
| 316 | 316 | ), |
| 317 | 317 | array( |
| 318 | 318 | 'name' => 'edd-check', |
| 319 | - 'value' => __('Check License', 'gravityview'), |
|
| 320 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
| 319 | + 'value' => __( 'Check License', 'gravityview' ), |
|
| 320 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
| 321 | 321 | 'title' => 'Check the license before saving it', |
| 322 | 322 | 'data-edd_action' => 'check_license', |
| 323 | 323 | 'class' => 'button-secondary', |
@@ -327,17 +327,17 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | $class = 'button gv-edd-action'; |
| 329 | 329 | |
| 330 | - $class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
| 330 | + $class .= ( ! empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
| 331 | 331 | |
| 332 | 332 | $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled'; |
| 333 | 333 | |
| 334 | 334 | $submit = '<div class="gv-edd-button-wrapper">'; |
| 335 | 335 | foreach ( $fields as $field ) { |
| 336 | - $field['type'] = 'button'; |
|
| 337 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
| 338 | - $field['style'] = 'margin-left: 10px;'; |
|
| 339 | - if( $disabled_attribute ) { |
|
| 340 | - $field['disabled'] = $disabled_attribute; |
|
| 336 | + $field[ 'type' ] = 'button'; |
|
| 337 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class; |
|
| 338 | + $field[ 'style' ] = 'margin-left: 10px;'; |
|
| 339 | + if ( $disabled_attribute ) { |
|
| 340 | + $field[ 'disabled' ] = $disabled_attribute; |
|
| 341 | 341 | } |
| 342 | 342 | $submit .= $this->Addon->settings_submit( $field, $echo ); |
| 343 | 343 | } |
@@ -356,8 +356,8 @@ discard block |
||
| 356 | 356 | */ |
| 357 | 357 | public function setup_edd() { |
| 358 | 358 | |
| 359 | - if( !class_exists('EDD_SL_Plugin_Updater') ) { |
|
| 360 | - require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
| 359 | + if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
| 360 | + require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php' ); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | // setup the updater |
@@ -395,8 +395,8 @@ discard block |
||
| 395 | 395 | 'beta' => $this->Addon->get_app_setting( 'beta' ), |
| 396 | 396 | ); |
| 397 | 397 | |
| 398 | - if( !empty( $action ) ) { |
|
| 399 | - $settings['edd_action'] = esc_attr( $action ); |
|
| 398 | + if ( ! empty( $action ) ) { |
|
| 399 | + $settings[ 'edd_action' ] = esc_attr( $action ); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | $settings = array_map( 'urlencode', $settings ); |
@@ -410,14 +410,14 @@ discard block |
||
| 410 | 410 | */ |
| 411 | 411 | private function _license_get_remote_response( $data, $license = '' ) { |
| 412 | 412 | |
| 413 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
| 413 | + $api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license ); |
|
| 414 | 414 | |
| 415 | 415 | $url = add_query_arg( $api_params, self::url ); |
| 416 | 416 | |
| 417 | 417 | $response = wp_remote_get( $url, array( |
| 418 | 418 | 'timeout' => 15, |
| 419 | 419 | 'sslverify' => false, |
| 420 | - )); |
|
| 420 | + ) ); |
|
| 421 | 421 | |
| 422 | 422 | if ( is_wp_error( $response ) ) { |
| 423 | 423 | |
@@ -455,11 +455,11 @@ discard block |
||
| 455 | 455 | */ |
| 456 | 456 | function get_license_message( $license_data ) { |
| 457 | 457 | |
| 458 | - if( empty( $license_data ) ) { |
|
| 458 | + if ( empty( $license_data ) ) { |
|
| 459 | 459 | $message = ''; |
| 460 | 460 | } else { |
| 461 | 461 | |
| 462 | - if( ! empty( $license_data->error ) ) { |
|
| 462 | + if ( ! empty( $license_data->error ) ) { |
|
| 463 | 463 | $class = 'error'; |
| 464 | 464 | $string_key = $license_data->error; |
| 465 | 465 | } else { |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | $string_key = $license_data->license; |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) ); |
|
| 470 | + $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings( 'status' ), $this->strings( $string_key, $license_data ) ); |
|
| 471 | 471 | |
| 472 | 472 | $message = $this->generate_license_box( $message, $class ); |
| 473 | 473 | } |
@@ -504,18 +504,18 @@ discard block |
||
| 504 | 504 | */ |
| 505 | 505 | public function license_details( $response = array() ) { |
| 506 | 506 | |
| 507 | - $response = (array) $response; |
|
| 507 | + $response = (array)$response; |
|
| 508 | 508 | |
| 509 | 509 | $return = ''; |
| 510 | 510 | $wrapper = '<span class="gv-license-details" aria-live="polite" aria-busy="false">%s</span>'; |
| 511 | 511 | |
| 512 | - if( ! empty( $response['license_key'] ) ) { |
|
| 512 | + if ( ! empty( $response[ 'license_key' ] ) ) { |
|
| 513 | 513 | |
| 514 | 514 | $return .= '<h3>' . esc_html__( 'License Details:', 'gravityview' ) . '</h3>'; |
| 515 | 515 | |
| 516 | 516 | if ( in_array( rgar( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { |
| 517 | - $return .= $this->strings( $response['license'], $response ); |
|
| 518 | - } elseif ( ! empty( $response['license_name'] ) ) { |
|
| 517 | + $return .= $this->strings( $response[ 'license' ], $response ); |
|
| 518 | + } elseif ( ! empty( $response[ 'license_name' ] ) ) { |
|
| 519 | 519 | |
| 520 | 520 | $response_keys = array( |
| 521 | 521 | 'license_name' => '', |
@@ -530,19 +530,19 @@ discard block |
||
| 530 | 530 | // Make sure all the keys are set |
| 531 | 531 | $response = wp_parse_args( $response, $response_keys ); |
| 532 | 532 | |
| 533 | - $login_link = sprintf( '<a href="%s" class="howto" 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' ) ); |
|
| 534 | - $local_text = ( ! empty( $response['is_local'] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
| 533 | + $login_link = sprintf( '<a href="%s" class="howto" 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' ) ); |
|
| 534 | + $local_text = ( ! empty( $response[ 'is_local' ] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
| 535 | 535 | $details = array( |
| 536 | - 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response['license_name'] ), esc_html( $response['license_limit'] ) ), |
|
| 537 | - 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response['customer_name'], 'gravityview' ), esc_html__( $response['customer_email'], 'gravityview' ) ) . $login_link, |
|
| 538 | - 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response['site_count'] ), esc_html( $response['license_limit'] ) ) . $local_text, |
|
| 539 | - 'expires' => 'lifetime' === $response['expires'] ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response['expires'] ) - DAY_IN_SECONDS ) ), |
|
| 540 | - 'upgrade' => $this->get_upgrade_html( $response['upgrades'] ), |
|
| 536 | + 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response[ 'license_name' ] ), esc_html( $response[ 'license_limit' ] ) ), |
|
| 537 | + 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response[ 'customer_name' ], 'gravityview' ), esc_html__( $response[ 'customer_email' ], 'gravityview' ) ) . $login_link, |
|
| 538 | + 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response[ 'site_count' ] ), esc_html( $response[ 'license_limit' ] ) ) . $local_text, |
|
| 539 | + 'expires' => 'lifetime' === $response[ 'expires' ] ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response[ 'expires' ] ) - DAY_IN_SECONDS ) ), |
|
| 540 | + 'upgrade' => $this->get_upgrade_html( $response[ 'upgrades' ] ), |
|
| 541 | 541 | ); |
| 542 | 542 | |
| 543 | - if ( ! empty( $response['error'] ) && 'expired' === $response['error'] ) { |
|
| 544 | - unset( $details['upgrade'] ); |
|
| 545 | - $details['expires'] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
| 543 | + if ( ! empty( $response[ 'error' ] ) && 'expired' === $response[ 'error' ] ) { |
|
| 544 | + unset( $details[ 'upgrade' ] ); |
|
| 545 | + $details[ 'expires' ] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | $return .= '<ul><li>' . implode( '</li><li>', array_filter( $details ) ) . '</li></ul>'; |
@@ -565,11 +565,11 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | $output = ''; |
| 567 | 567 | |
| 568 | - if( ! empty( $upgrades ) ) { |
|
| 568 | + if ( ! empty( $upgrades ) ) { |
|
| 569 | 569 | |
| 570 | 570 | $locale_parts = explode( '_', get_locale() ); |
| 571 | 571 | |
| 572 | - $is_english = ( 'en' === $locale_parts[0] ); |
|
| 572 | + $is_english = ( 'en' === $locale_parts[ 0 ] ); |
|
| 573 | 573 | |
| 574 | 574 | $output .= '<h4>' . esc_html__( 'Upgrades available:', 'gravityview' ) . '</h4>'; |
| 575 | 575 | |
@@ -577,14 +577,14 @@ discard block |
||
| 577 | 577 | |
| 578 | 578 | foreach ( $upgrades as $upgrade_id => $upgrade ) { |
| 579 | 579 | |
| 580 | - $upgrade = (object) $upgrade; |
|
| 580 | + $upgrade = (object)$upgrade; |
|
| 581 | 581 | |
| 582 | 582 | $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 ) ); |
| 583 | 583 | |
| 584 | - if( $is_english && isset( $upgrade->description ) ) { |
|
| 584 | + if ( $is_english && isset( $upgrade->description ) ) { |
|
| 585 | 585 | $message = esc_html( $upgrade->description ); |
| 586 | 586 | } else { |
| 587 | - switch( $upgrade->price_id ) { |
|
| 587 | + switch ( $upgrade->price_id ) { |
|
| 588 | 588 | // Interstellar |
| 589 | 589 | case 1: |
| 590 | 590 | default: |
@@ -622,16 +622,16 @@ discard block |
||
| 622 | 622 | */ |
| 623 | 623 | public function license_call( $array = array() ) { |
| 624 | 624 | |
| 625 | - $is_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
|
| 626 | - $data = empty( $array ) ? $_POST['data'] : $array; |
|
| 625 | + $is_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
| 626 | + $data = empty( $array ) ? $_POST[ 'data' ] : $array; |
|
| 627 | 627 | $has_cap = GVCommon::has_cap( 'gravityview_edit_settings' ); |
| 628 | 628 | |
| 629 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
| 630 | - die( - 1 ); |
|
| 629 | + if ( $is_ajax && empty( $data[ 'license' ] ) ) { |
|
| 630 | + die( -1 ); |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | // If the user isn't allowed to edit settings, show an error message |
| 634 | - if( ! $has_cap && empty( $data['all_caps'] ) ) { |
|
| 634 | + if ( ! $has_cap && empty( $data[ 'all_caps' ] ) ) { |
|
| 635 | 635 | $license_data = new stdClass(); |
| 636 | 636 | $license_data->error = 'capability'; |
| 637 | 637 | $license_data->message = $this->get_license_message( $license_data ); |
@@ -655,11 +655,11 @@ discard block |
||
| 655 | 655 | |
| 656 | 656 | $json = json_encode( $license_data ); |
| 657 | 657 | |
| 658 | - $update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) ); |
|
| 658 | + $update_license = ( ! isset( $data[ 'update' ] ) || ! empty( $data[ 'update' ] ) ); |
|
| 659 | 659 | |
| 660 | - $is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
| 660 | + $is_check_action_button = ( 'check_license' === $data[ 'edd_action' ] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
| 661 | 661 | |
| 662 | - if( $is_check_action_button ) { |
|
| 662 | + if ( $is_check_action_button ) { |
|
| 663 | 663 | delete_transient( self::status_transient_key ); |
| 664 | 664 | } |
| 665 | 665 | // Failed is the response from trying to de-activate a license and it didn't work. |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | // most likely a mistake. |
| 669 | 669 | else if ( $license_data->license !== 'failed' && $update_license ) { |
| 670 | 670 | |
| 671 | - if ( ! empty( $data['field_id'] ) ) { |
|
| 671 | + if ( ! empty( $data[ 'field_id' ] ) ) { |
|
| 672 | 672 | set_transient( self::status_transient_key, $license_data, DAY_IN_SECONDS ); |
| 673 | 673 | } |
| 674 | 674 | |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | if ( $is_ajax ) { |
| 680 | 680 | exit( $json ); |
| 681 | 681 | } else { // Non-ajax call |
| 682 | - return ( rgget('format', $data ) === 'object' ) ? $license_data : $json; |
|
| 682 | + return ( rgget( 'format', $data ) === 'object' ) ? $license_data : $json; |
|
| 683 | 683 | } |
| 684 | 684 | } |
| 685 | 685 | |
@@ -693,9 +693,9 @@ discard block |
||
| 693 | 693 | // Update option with passed data license |
| 694 | 694 | $settings = $this->Addon->get_app_settings(); |
| 695 | 695 | |
| 696 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
| 697 | - $settings['license_key_status'] = $license_data->license; |
|
| 698 | - $settings['license_key_response'] = (array)$license_data; |
|
| 696 | + $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] ); |
|
| 697 | + $settings[ 'license_key_status' ] = $license_data->license; |
|
| 698 | + $settings[ 'license_key_response' ] = (array)$license_data; |
|
| 699 | 699 | |
| 700 | 700 | $this->Addon->update_app_settings( $settings ); |
| 701 | 701 | } |
@@ -710,9 +710,9 @@ discard block |
||
| 710 | 710 | |
| 711 | 711 | $license_data = is_array( $license_data ) ? (object)$license_data : $license_data; |
| 712 | 712 | |
| 713 | - if( ! empty( $license_data->renewal_url ) ) { |
|
| 713 | + if ( ! empty( $license_data->renewal_url ) ) { |
|
| 714 | 714 | $renew_license_url = $license_data->renewal_url; |
| 715 | - } elseif( ! empty( $license_data->license_key ) ) { |
|
| 715 | + } elseif ( ! empty( $license_data->license_key ) ) { |
|
| 716 | 716 | $renew_license_url = sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s', $license_data->license_key ); |
| 717 | 717 | } else { |
| 718 | 718 | $renew_license_url = 'https://gravityview.co/account/'; |
@@ -734,31 +734,31 @@ discard block |
||
| 734 | 734 | |
| 735 | 735 | |
| 736 | 736 | $strings = array( |
| 737 | - 'status' => esc_html__('Status', 'gravityview'), |
|
| 738 | - 'error' => esc_html__('There was an error processing the request.', 'gravityview'), |
|
| 739 | - 'failed' => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'), |
|
| 740 | - 'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
|
| 741 | - 'inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
|
| 742 | - 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
| 743 | - 'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'), |
|
| 744 | - 'valid' => esc_html__('The license key is valid and active.', 'gravityview'), |
|
| 745 | - 'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'), |
|
| 746 | - 'missing' => esc_html__('Invalid license key.', 'gravityview'), |
|
| 747 | - 'revoked' => esc_html__('This license key has been revoked.', 'gravityview'), |
|
| 748 | - '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>' ), |
|
| 737 | + 'status' => esc_html__( 'Status', 'gravityview' ), |
|
| 738 | + 'error' => esc_html__( 'There was an error processing the request.', 'gravityview' ), |
|
| 739 | + 'failed' => esc_html__( 'Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview' ), |
|
| 740 | + 'site_inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ), |
|
| 741 | + 'inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ), |
|
| 742 | + 'no_activations_left' => esc_html__( 'Invalid: this license has reached its activation limit.', 'gravityview' ) . ' ' . sprintf( esc_html__( 'You can manage license activations %son your GravityView account page%s.', 'gravityview' ), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
| 743 | + 'deactivated' => esc_html__( 'The license has been deactivated.', 'gravityview' ), |
|
| 744 | + 'valid' => esc_html__( 'The license key is valid and active.', 'gravityview' ), |
|
| 745 | + 'invalid' => esc_html__( 'The license key entered is invalid.', 'gravityview' ), |
|
| 746 | + 'missing' => esc_html__( 'Invalid license key.', 'gravityview' ), |
|
| 747 | + 'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ), |
|
| 748 | + '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>' ), |
|
| 749 | 749 | 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
| 750 | 750 | |
| 751 | - 'verifying_license' => esc_html__('Verifying license…', 'gravityview'), |
|
| 752 | - 'activate_license' => esc_html__('Activate License', 'gravityview'), |
|
| 753 | - 'deactivate_license' => esc_html__('Deactivate License', 'gravityview'), |
|
| 754 | - 'check_license' => esc_html__('Verify License', 'gravityview'), |
|
| 751 | + 'verifying_license' => esc_html__( 'Verifying license…', 'gravityview' ), |
|
| 752 | + 'activate_license' => esc_html__( 'Activate License', 'gravityview' ), |
|
| 753 | + 'deactivate_license' => esc_html__( 'Deactivate License', 'gravityview' ), |
|
| 754 | + 'check_license' => esc_html__( 'Verify License', 'gravityview' ), |
|
| 755 | 755 | ); |
| 756 | 756 | |
| 757 | - if( empty( $status ) ) { |
|
| 757 | + if ( empty( $status ) ) { |
|
| 758 | 758 | return $strings; |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - if( isset( $strings[ $status ] ) ) { |
|
| 761 | + if ( isset( $strings[ $status ] ) ) { |
|
| 762 | 762 | return $strings[ $status ]; |
| 763 | 763 | } |
| 764 | 764 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | function edit_entry_fix_hidden_fields( $fields ) { |
| 50 | 50 | |
| 51 | 51 | /** @var GF_Field $field */ |
| 52 | - foreach( $fields as &$field ) { |
|
| 52 | + foreach ( $fields as &$field ) { |
|
| 53 | 53 | if ( 'hidden' === $field->type ) { |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | $reveal_hidden_field = apply_filters( 'gravityview/edit_entry/reveal_hidden_field', true, $field ); |
| 62 | 62 | |
| 63 | - if( ! $reveal_hidden_field ) { |
|
| 63 | + if ( ! $reveal_hidden_field ) { |
|
| 64 | 64 | continue; |
| 65 | 65 | } |
| 66 | 66 | |