@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | $format = '(?:\.(?P<format>html|json))?'; |
134 | 134 | |
135 | - register_rest_route( $namespace, sprintf( '/%s/(?P<id>[\d]+)/%s/(?P<s_id>[\w-]+)%s', $base, $sub_type, $format ) , array( |
|
135 | + register_rest_route( $namespace, sprintf( '/%s/(?P<id>[\d]+)/%s/(?P<s_id>[\w-]+)%s', $base, $sub_type, $format ), array( |
|
136 | 136 | array( |
137 | 137 | 'methods' => \WP_REST_Server::READABLE, |
138 | 138 | 'callback' => array( $this, 'get_sub_item' ), |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @return \WP_REST_Response |
384 | 384 | */ |
385 | 385 | protected function not_implemented( ) { |
386 | - $error = new \WP_Error( 'not-implemented-yet', __( 'Endpoint Not Yet Implemented.', 'gravityview' ) ); |
|
386 | + $error = new \WP_Error( 'not-implemented-yet', __( 'Endpoint Not Yet Implemented.', 'gravityview' ) ); |
|
387 | 387 | return new \WP_REST_Response( $error, 501 ); |
388 | 388 | } |
389 | 389 |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | function load() { |
116 | 116 | |
117 | 117 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
118 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
118 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
119 | 119 | |
120 | 120 | // Don't display an embedded form when editing an entry |
121 | 121 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
122 | 122 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
123 | 123 | |
124 | 124 | // Stop Gravity Forms processing what is ours! |
125 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
125 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
126 | 126 | |
127 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
127 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
128 | 128 | |
129 | 129 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
130 | 130 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
136 | 136 | |
137 | 137 | // Add fields expected by GFFormDisplay::validate() |
138 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
138 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
139 | 139 | |
140 | 140 | // Fix multiselect value for GF 2.2 |
141 | 141 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | public function prevent_render_form() { |
155 | - if( $this->is_edit_entry() ) { |
|
156 | - if( 'wp_head' === current_filter() ) { |
|
155 | + if ( $this->is_edit_entry() ) { |
|
156 | + if ( 'wp_head' === current_filter() ) { |
|
157 | 157 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
158 | 158 | } else { |
159 | 159 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function prevent_maybe_process_form() { |
170 | 170 | |
171 | - if( ! empty( $_POST ) ) { |
|
171 | + if ( ! empty( $_POST ) ) { |
|
172 | 172 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
173 | 173 | } |
174 | 174 | |
175 | - if( $this->is_edit_entry_submission() ) { |
|
176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
175 | + if ( $this->is_edit_entry_submission() ) { |
|
176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function is_edit_entry() { |
186 | 186 | |
187 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
187 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
188 | 188 | |
189 | 189 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return boolean |
196 | 196 | */ |
197 | 197 | public function is_edit_entry_submission() { |
198 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
198 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | $entries = $gravityview_view->getEntries(); |
211 | - self::$original_entry = $entries[0]; |
|
212 | - $this->entry = $entries[0]; |
|
211 | + self::$original_entry = $entries[ 0 ]; |
|
212 | + $this->entry = $entries[ 0 ]; |
|
213 | 213 | |
214 | 214 | self::$original_form = $gravityview_view->getForm(); |
215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->view_id = $gravityview_view->getViewId(); |
218 | 218 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
219 | 219 | |
220 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
220 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | // Multiple Views embedded, don't proceed if nonce fails |
244 | - if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
244 | + if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
245 | 245 | gravityview()->log->error( 'Nonce validation failed for the Edit Entry request; returning' ); |
246 | 246 | return; |
247 | 247 | } |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | private function print_scripts() { |
269 | 269 | $gravityview_view = GravityView_View::getInstance(); |
270 | 270 | |
271 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
271 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
272 | 272 | |
273 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
273 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
274 | 274 | |
275 | 275 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
276 | 276 | |
@@ -286,19 +286,19 @@ discard block |
||
286 | 286 | */ |
287 | 287 | private function process_save( $gv_data ) { |
288 | 288 | |
289 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
289 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
290 | 290 | return; |
291 | 291 | } |
292 | 292 | |
293 | 293 | // Make sure the entry, view, and form IDs are all correct |
294 | 294 | $valid = $this->verify_nonce(); |
295 | 295 | |
296 | - if ( !$valid ) { |
|
296 | + if ( ! $valid ) { |
|
297 | 297 | gravityview()->log->error( 'Nonce validation failed.' ); |
298 | 298 | return; |
299 | 299 | } |
300 | 300 | |
301 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
301 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
302 | 302 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
303 | 303 | return; |
304 | 304 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | $this->validate(); |
311 | 311 | |
312 | - if( $this->is_valid ) { |
|
312 | + if ( $this->is_valid ) { |
|
313 | 313 | |
314 | 314 | gravityview()->log->debug( 'Submission is valid.' ); |
315 | 315 | |
@@ -321,22 +321,22 @@ discard block |
||
321 | 321 | /** |
322 | 322 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
323 | 323 | */ |
324 | - unset( $_GET['page'] ); |
|
324 | + unset( $_GET[ 'page' ] ); |
|
325 | 325 | |
326 | - $date_created = $this->entry['date_created']; |
|
326 | + $date_created = $this->entry[ 'date_created' ]; |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
330 | 330 | * @since 1.17.2 |
331 | 331 | */ |
332 | - unset( $this->entry['date_created'] ); |
|
332 | + unset( $this->entry[ 'date_created' ] ); |
|
333 | 333 | |
334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
335 | 335 | |
336 | 336 | // Delete the values for hidden inputs |
337 | 337 | $this->unset_hidden_field_values(); |
338 | 338 | |
339 | - $this->entry['date_created'] = $date_created; |
|
339 | + $this->entry[ 'date_created' ] = $date_created; |
|
340 | 340 | |
341 | 341 | // Process calculation fields |
342 | 342 | $this->update_calculation_fields(); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * @param GravityView_Edit_Entry_Render $this This object |
358 | 358 | * @param GravityView_View_Data $gv_data The View data |
359 | 359 | */ |
360 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
360 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
361 | 361 | |
362 | 362 | } else { |
363 | 363 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | */ |
386 | 386 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
387 | 387 | |
388 | - if( ! $unset_hidden_field_values ) { |
|
388 | + if ( ! $unset_hidden_field_values ) { |
|
389 | 389 | return; |
390 | 390 | } |
391 | 391 | |
392 | 392 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
393 | 393 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
394 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
394 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
395 | 395 | } else { |
396 | 396 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
397 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
397 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | } |
476 | 476 | |
477 | 477 | /** No file is being uploaded. */ |
478 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
478 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
479 | 479 | /** So return the original upload */ |
480 | 480 | return $entry[ $input_id ]; |
481 | 481 | } |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | * @return mixed |
494 | 494 | */ |
495 | 495 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
496 | - if( ! $this->is_edit_entry() ) { |
|
496 | + if ( ! $this->is_edit_entry() ) { |
|
497 | 497 | return $plupload_init; |
498 | 498 | } |
499 | 499 | |
500 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
500 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
501 | 501 | |
502 | 502 | return $plupload_init; |
503 | 503 | } |
@@ -512,22 +512,22 @@ discard block |
||
512 | 512 | $form = $this->form; |
513 | 513 | |
514 | 514 | /** @var GF_Field $field */ |
515 | - foreach( $form['fields'] as $k => &$field ) { |
|
515 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
516 | 516 | |
517 | 517 | /** |
518 | 518 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
519 | 519 | * @since 1.16.3 |
520 | 520 | * @var GF_Field $field |
521 | 521 | */ |
522 | - if( $field->has_calculation() ) { |
|
523 | - unset( $form['fields'][ $k ] ); |
|
522 | + if ( $field->has_calculation() ) { |
|
523 | + unset( $form[ 'fields' ][ $k ] ); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | $field->adminOnly = false; |
527 | 527 | |
528 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
529 | - foreach( $field->inputs as $key => $input ) { |
|
530 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
528 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
529 | + foreach ( $field->inputs as $key => $input ) { |
|
530 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | } |
@@ -541,30 +541,30 @@ discard block |
||
541 | 541 | $update = false; |
542 | 542 | |
543 | 543 | // get the most up to date entry values |
544 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
544 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
545 | 545 | |
546 | - if( !empty( $this->fields_with_calculation ) ) { |
|
546 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
547 | 547 | $update = true; |
548 | 548 | foreach ( $this->fields_with_calculation as $calc_field ) { |
549 | 549 | $inputs = $calc_field->get_entry_inputs(); |
550 | 550 | if ( is_array( $inputs ) ) { |
551 | 551 | foreach ( $inputs as $input ) { |
552 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
553 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
552 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
553 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
554 | 554 | } |
555 | 555 | } else { |
556 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
557 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
556 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
557 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
561 | 561 | } |
562 | 562 | |
563 | - if( $update ) { |
|
563 | + if ( $update ) { |
|
564 | 564 | |
565 | 565 | $return_entry = GFAPI::update_entry( $entry ); |
566 | 566 | |
567 | - if( is_wp_error( $return_entry ) ) { |
|
567 | + if ( is_wp_error( $return_entry ) ) { |
|
568 | 568 | gravityview()->log->error( 'Updating the entry calculation fields failed', array( 'data' => $return_entry ) ); |
569 | 569 | } else { |
570 | 570 | gravityview()->log->debug( 'Updating the entry calculation fields succeeded' ); |
@@ -595,19 +595,19 @@ discard block |
||
595 | 595 | |
596 | 596 | $input_name = 'input_' . $field_id; |
597 | 597 | |
598 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
598 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
599 | 599 | |
600 | 600 | // We have a new image |
601 | 601 | |
602 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
602 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
603 | 603 | |
604 | 604 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
605 | 605 | $ary = stripslashes_deep( $ary ); |
606 | 606 | $img_url = \GV\Utils::get( $ary, 0 ); |
607 | 607 | |
608 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
609 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
610 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
608 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
609 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
610 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
611 | 611 | |
612 | 612 | $image_meta = array( |
613 | 613 | 'post_excerpt' => $img_caption, |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | |
617 | 617 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
618 | 618 | if ( ! empty( $img_title ) ) { |
619 | - $image_meta['post_title'] = $img_title; |
|
619 | + $image_meta[ 'post_title' ] = $img_title; |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -674,15 +674,15 @@ discard block |
||
674 | 674 | */ |
675 | 675 | private function maybe_update_post_fields( $form ) { |
676 | 676 | |
677 | - if( empty( $this->entry['post_id'] ) ) { |
|
677 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
678 | 678 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
679 | 679 | return; |
680 | 680 | } |
681 | 681 | |
682 | - $post_id = $this->entry['post_id']; |
|
682 | + $post_id = $this->entry[ 'post_id' ]; |
|
683 | 683 | |
684 | 684 | // Security check |
685 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
685 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
686 | 686 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
687 | 687 | return; |
688 | 688 | } |
@@ -695,25 +695,25 @@ discard block |
||
695 | 695 | |
696 | 696 | $field = RGFormsModel::get_field( $form, $field_id ); |
697 | 697 | |
698 | - if( ! $field ) { |
|
698 | + if ( ! $field ) { |
|
699 | 699 | continue; |
700 | 700 | } |
701 | 701 | |
702 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
702 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
703 | 703 | |
704 | 704 | // Get the value of the field, including $_POSTed value |
705 | 705 | $value = RGFormsModel::get_field_value( $field ); |
706 | 706 | |
707 | 707 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
708 | 708 | $entry_tmp = $this->entry; |
709 | - $entry_tmp["{$field_id}"] = $value; |
|
709 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
710 | 710 | |
711 | - switch( $field->type ) { |
|
711 | + switch ( $field->type ) { |
|
712 | 712 | |
713 | 713 | case 'post_title': |
714 | 714 | $post_title = $value; |
715 | 715 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
716 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
716 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
717 | 717 | } |
718 | 718 | $updated_post->post_title = $post_title; |
719 | 719 | $updated_post->post_name = $post_title; |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | case 'post_content': |
724 | 724 | $post_content = $value; |
725 | 725 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
726 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
726 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
727 | 727 | } |
728 | 728 | $updated_post->post_content = $post_content; |
729 | 729 | unset( $post_content ); |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | $value = $value[ $field_id ]; |
742 | 742 | } |
743 | 743 | |
744 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
744 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
745 | 745 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
746 | 746 | } |
747 | 747 | |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | } |
760 | 760 | |
761 | 761 | // update entry after |
762 | - $this->entry["{$field_id}"] = $value; |
|
762 | + $this->entry[ "{$field_id}" ] = $value; |
|
763 | 763 | |
764 | 764 | $update_entry = true; |
765 | 765 | |
@@ -768,11 +768,11 @@ discard block |
||
768 | 768 | |
769 | 769 | } |
770 | 770 | |
771 | - if( $update_entry ) { |
|
771 | + if ( $update_entry ) { |
|
772 | 772 | |
773 | 773 | $return_entry = GFAPI::update_entry( $this->entry ); |
774 | 774 | |
775 | - if( is_wp_error( $return_entry ) ) { |
|
775 | + if ( is_wp_error( $return_entry ) ) { |
|
776 | 776 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
777 | 777 | } else { |
778 | 778 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | |
783 | 783 | $return_post = wp_update_post( $updated_post, true ); |
784 | 784 | |
785 | - if( is_wp_error( $return_post ) ) { |
|
785 | + if ( is_wp_error( $return_post ) ) { |
|
786 | 786 | $return_post->add_data( $updated_post, '$updated_post' ); |
787 | 787 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
788 | 788 | } else { |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | $input_type = RGFormsModel::get_input_type( $field ); |
805 | 805 | |
806 | 806 | // Only certain custom field types are supported |
807 | - switch( $input_type ) { |
|
807 | + switch ( $input_type ) { |
|
808 | 808 | case 'fileupload': |
809 | 809 | case 'list': |
810 | 810 | case 'multiselect': |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
842 | 842 | |
843 | 843 | // replace conditional shortcodes |
844 | - if( $do_shortcode ) { |
|
844 | + if ( $do_shortcode ) { |
|
845 | 845 | $output = do_shortcode( $output ); |
846 | 846 | } |
847 | 847 | |
@@ -860,19 +860,19 @@ discard block |
||
860 | 860 | */ |
861 | 861 | private function after_update() { |
862 | 862 | |
863 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
864 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
863 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
864 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
865 | 865 | |
866 | 866 | // Re-define the entry now that we've updated it. |
867 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
867 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
868 | 868 | |
869 | 869 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
870 | 870 | |
871 | 871 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
872 | 872 | // We need to clear the cache because Gravity Forms caches the field values, which |
873 | 873 | // we have just updated. |
874 | - foreach ($this->form['fields'] as $key => $field) { |
|
875 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
874 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
875 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
876 | 876 | } |
877 | 877 | } |
878 | 878 | |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | |
892 | 892 | <div class="gv-edit-entry-wrapper"><?php |
893 | 893 | |
894 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
894 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
895 | 895 | |
896 | 896 | /** |
897 | 897 | * Fixes weird wpautop() issue |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | * @param string $edit_entry_title Modify the "Edit Entry" title |
908 | 908 | * @param GravityView_Edit_Entry_Render $this This object |
909 | 909 | */ |
910 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
910 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
911 | 911 | |
912 | 912 | echo esc_attr( $edit_entry_title ); |
913 | 913 | ?></span> |
@@ -957,16 +957,16 @@ discard block |
||
957 | 957 | |
958 | 958 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
959 | 959 | |
960 | - if( ! $this->is_valid ){ |
|
960 | + if ( ! $this->is_valid ) { |
|
961 | 961 | |
962 | 962 | // Keeping this compatible with Gravity Forms. |
963 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
964 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
963 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
964 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
965 | 965 | |
966 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
966 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
967 | 967 | |
968 | 968 | } else { |
969 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
969 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
970 | 970 | |
971 | 971 | /** |
972 | 972 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | * @param array $entry Gravity Forms entry array |
977 | 977 | * @param string $back_link URL to return to the original entry. @since 1.6 |
978 | 978 | */ |
979 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
979 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
980 | 980 | |
981 | 981 | echo GVCommon::generate_notice( $message ); |
982 | 982 | } |
@@ -1000,21 +1000,21 @@ discard block |
||
1000 | 1000 | */ |
1001 | 1001 | do_action( 'gravityview/edit-entry/render/before', $this ); |
1002 | 1002 | |
1003 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1004 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1003 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1004 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1005 | 1005 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
1006 | 1006 | |
1007 | 1007 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
1008 | 1008 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1009 | 1009 | |
1010 | 1010 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1011 | - unset( $_GET['page'] ); |
|
1011 | + unset( $_GET[ 'page' ] ); |
|
1012 | 1012 | |
1013 | 1013 | // TODO: Verify multiple-page forms |
1014 | 1014 | |
1015 | 1015 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1016 | 1016 | |
1017 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1017 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1018 | 1018 | |
1019 | 1019 | ob_get_clean(); |
1020 | 1020 | |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | * @return string |
1041 | 1041 | */ |
1042 | 1042 | public function render_form_buttons() { |
1043 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1043 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | |
@@ -1060,10 +1060,10 @@ discard block |
||
1060 | 1060 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1061 | 1061 | |
1062 | 1062 | // In case we have validated the form, use it to inject the validation results into the form render |
1063 | - if( isset( $this->form_after_validation ) ) { |
|
1063 | + if ( isset( $this->form_after_validation ) ) { |
|
1064 | 1064 | $form = $this->form_after_validation; |
1065 | 1065 | } else { |
1066 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1066 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | $form = $this->filter_conditional_logic( $form ); |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | $form = $this->prefill_conditional_logic( $form ); |
1072 | 1072 | |
1073 | 1073 | // for now we don't support Save and Continue feature. |
1074 | - if( ! self::$supports_save_and_continue ) { |
|
1075 | - unset( $form['save'] ); |
|
1074 | + if ( ! self::$supports_save_and_continue ) { |
|
1075 | + unset( $form[ 'save' ] ); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | return $form; |
@@ -1093,29 +1093,29 @@ discard block |
||
1093 | 1093 | */ |
1094 | 1094 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1095 | 1095 | |
1096 | - if( GFCommon::is_post_field( $field ) ) { |
|
1096 | + if ( GFCommon::is_post_field( $field ) ) { |
|
1097 | 1097 | |
1098 | 1098 | $message = null; |
1099 | 1099 | |
1100 | 1100 | // First, make sure they have the capability to edit the post. |
1101 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1101 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1102 | 1102 | |
1103 | 1103 | /** |
1104 | 1104 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1105 | 1105 | * @param string $message The existing "You don't have permission..." text |
1106 | 1106 | */ |
1107 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1107 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1108 | 1108 | |
1109 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1109 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1110 | 1110 | /** |
1111 | 1111 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1112 | 1112 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1113 | 1113 | */ |
1114 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1114 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | - if( $message ) { |
|
1118 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1117 | + if ( $message ) { |
|
1118 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1119 | 1119 | } |
1120 | 1120 | } |
1121 | 1121 | |
@@ -1140,8 +1140,8 @@ discard block |
||
1140 | 1140 | |
1141 | 1141 | // If the form has been submitted, then we don't need to pre-fill the values, |
1142 | 1142 | // Except for fileupload type and when a field input is overridden- run always!! |
1143 | - if( |
|
1144 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1143 | + if ( |
|
1144 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1145 | 1145 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1146 | 1146 | && ! GFCommon::is_product_field( $field->type ) |
1147 | 1147 | || ! empty( $field_content ) |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | $return = null; |
1162 | 1162 | |
1163 | 1163 | /** @var GravityView_Field $gv_field */ |
1164 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1164 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1165 | 1165 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1166 | 1166 | } else { |
1167 | 1167 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | // If there was output, it's an error |
1171 | 1171 | $warnings = ob_get_clean(); |
1172 | 1172 | |
1173 | - if( !empty( $warnings ) ) { |
|
1173 | + if ( ! empty( $warnings ) ) { |
|
1174 | 1174 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1175 | 1175 | } |
1176 | 1176 | |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1196 | 1196 | |
1197 | 1197 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1198 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1198 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1199 | 1199 | |
1200 | 1200 | $field_value = array(); |
1201 | 1201 | |
@@ -1204,10 +1204,10 @@ discard block |
||
1204 | 1204 | |
1205 | 1205 | foreach ( (array)$field->inputs as $input ) { |
1206 | 1206 | |
1207 | - $input_id = strval( $input['id'] ); |
|
1207 | + $input_id = strval( $input[ 'id' ] ); |
|
1208 | 1208 | |
1209 | 1209 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1210 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1210 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1211 | 1211 | $allow_pre_populated = false; |
1212 | 1212 | } |
1213 | 1213 | |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | |
1216 | 1216 | $pre_value = $field->get_value_submission( array(), false ); |
1217 | 1217 | |
1218 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1218 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1219 | 1219 | |
1220 | 1220 | } else { |
1221 | 1221 | |
@@ -1226,13 +1226,13 @@ discard block |
||
1226 | 1226 | |
1227 | 1227 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1228 | 1228 | // or pre-populated value if not empty and set to override saved value |
1229 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1229 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1230 | 1230 | |
1231 | 1231 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1232 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1232 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1233 | 1233 | $categories = array(); |
1234 | 1234 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1235 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1235 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1236 | 1236 | } |
1237 | 1237 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1238 | 1238 | } |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | * @param GF_Field $field Gravity Forms field object |
1261 | 1261 | * @param GravityView_Edit_Entry_Render $this Current object |
1262 | 1262 | */ |
1263 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1263 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1264 | 1264 | |
1265 | 1265 | return $field_value; |
1266 | 1266 | } |
@@ -1277,12 +1277,12 @@ discard block |
||
1277 | 1277 | */ |
1278 | 1278 | public function gform_pre_validation( $form ) { |
1279 | 1279 | |
1280 | - if( ! $this->verify_nonce() ) { |
|
1280 | + if ( ! $this->verify_nonce() ) { |
|
1281 | 1281 | return $form; |
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | // Fix PHP warning regarding undefined index. |
1285 | - foreach ( $form['fields'] as &$field) { |
|
1285 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1286 | 1286 | |
1287 | 1287 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1288 | 1288 | // expects certain field array items to be set. |
@@ -1290,7 +1290,7 @@ discard block |
||
1290 | 1290 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1291 | 1291 | } |
1292 | 1292 | |
1293 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1293 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1294 | 1294 | |
1295 | 1295 | /** |
1296 | 1296 | * 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. |
@@ -1304,26 +1304,26 @@ discard block |
||
1304 | 1304 | // Set the previous value |
1305 | 1305 | $entry = $this->get_entry(); |
1306 | 1306 | |
1307 | - $input_name = 'input_'.$field->id; |
|
1308 | - $form_id = $form['id']; |
|
1307 | + $input_name = 'input_' . $field->id; |
|
1308 | + $form_id = $form[ 'id' ]; |
|
1309 | 1309 | |
1310 | 1310 | $value = NULL; |
1311 | 1311 | |
1312 | 1312 | // Use the previous entry value as the default. |
1313 | - if( isset( $entry[ $field->id ] ) ) { |
|
1313 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1314 | 1314 | $value = $entry[ $field->id ]; |
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | // If this is a single upload file |
1318 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1319 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1320 | - $value = $file_path['url']; |
|
1318 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1319 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1320 | + $value = $file_path[ 'url' ]; |
|
1321 | 1321 | |
1322 | 1322 | } else { |
1323 | 1323 | |
1324 | 1324 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1325 | 1325 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1326 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1326 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1327 | 1327 | |
1328 | 1328 | } |
1329 | 1329 | |
@@ -1331,10 +1331,10 @@ discard block |
||
1331 | 1331 | |
1332 | 1332 | // If there are fresh uploads, process and merge them. |
1333 | 1333 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1334 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1334 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1335 | 1335 | $value = empty( $value ) ? '[]' : $value; |
1336 | 1336 | $value = stripslashes_deep( $value ); |
1337 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1337 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | } else { |
@@ -1352,8 +1352,8 @@ discard block |
||
1352 | 1352 | |
1353 | 1353 | case 'number': |
1354 | 1354 | // Fix "undefined index" issue at line 1286 in form_display.php |
1355 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1356 | - $_POST['input_'.$field->id ] = NULL; |
|
1355 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1356 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1357 | 1357 | } |
1358 | 1358 | break; |
1359 | 1359 | } |
@@ -1390,7 +1390,7 @@ discard block |
||
1390 | 1390 | * You can enter whatever you want! |
1391 | 1391 | * We try validating, and customize the results using `self::custom_validation()` |
1392 | 1392 | */ |
1393 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1393 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1394 | 1394 | |
1395 | 1395 | // Needed by the validate funtion |
1396 | 1396 | $failed_validation_page = NULL; |
@@ -1398,14 +1398,14 @@ discard block |
||
1398 | 1398 | |
1399 | 1399 | // Prevent entry limit from running when editing an entry, also |
1400 | 1400 | // prevent form scheduling from preventing editing |
1401 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1401 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1402 | 1402 | |
1403 | 1403 | // Hide fields depending on Edit Entry settings |
1404 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1404 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1405 | 1405 | |
1406 | 1406 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1407 | 1407 | |
1408 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1408 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | |
@@ -1428,7 +1428,7 @@ discard block |
||
1428 | 1428 | |
1429 | 1429 | $gv_valid = true; |
1430 | 1430 | |
1431 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1431 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1432 | 1432 | |
1433 | 1433 | $value = RGFormsModel::get_field_value( $field ); |
1434 | 1434 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1441,35 +1441,35 @@ discard block |
||
1441 | 1441 | case 'post_image': |
1442 | 1442 | |
1443 | 1443 | // in case nothing is uploaded but there are already files saved |
1444 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1444 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1445 | 1445 | $field->failed_validation = false; |
1446 | 1446 | unset( $field->validation_message ); |
1447 | 1447 | } |
1448 | 1448 | |
1449 | 1449 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1450 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1450 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1451 | 1451 | |
1452 | 1452 | $input_name = 'input_' . $field->id; |
1453 | 1453 | //uploaded |
1454 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1454 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1455 | 1455 | |
1456 | 1456 | //existent |
1457 | 1457 | $entry = $this->get_entry(); |
1458 | 1458 | $value = NULL; |
1459 | - if( isset( $entry[ $field->id ] ) ) { |
|
1459 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1460 | 1460 | $value = json_decode( $entry[ $field->id ], true ); |
1461 | 1461 | } |
1462 | 1462 | |
1463 | 1463 | // count uploaded files and existent entry files |
1464 | 1464 | $count_files = count( $file_names ) + count( $value ); |
1465 | 1465 | |
1466 | - if( $count_files > $field->maxFiles ) { |
|
1466 | + if ( $count_files > $field->maxFiles ) { |
|
1467 | 1467 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1468 | 1468 | $field->failed_validation = 1; |
1469 | 1469 | $gv_valid = false; |
1470 | 1470 | |
1471 | 1471 | // in case of error make sure the newest upload files are removed from the upload input |
1472 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1472 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1473 | 1473 | } |
1474 | 1474 | |
1475 | 1475 | } |
@@ -1480,7 +1480,7 @@ discard block |
||
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | // This field has failed validation. |
1483 | - if( !empty( $field->failed_validation ) ) { |
|
1483 | + if ( ! empty( $field->failed_validation ) ) { |
|
1484 | 1484 | |
1485 | 1485 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1486 | 1486 | |
@@ -1498,19 +1498,19 @@ discard block |
||
1498 | 1498 | } |
1499 | 1499 | |
1500 | 1500 | // You can't continue inside a switch, so we do it after. |
1501 | - if( empty( $field->failed_validation ) ) { |
|
1501 | + if ( empty( $field->failed_validation ) ) { |
|
1502 | 1502 | continue; |
1503 | 1503 | } |
1504 | 1504 | |
1505 | 1505 | // checks if the No Duplicates option is not validating entry against itself, since |
1506 | 1506 | // we're editing a stored entry, it would also assume it's a duplicate. |
1507 | - if( !empty( $field->noDuplicates ) ) { |
|
1507 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1508 | 1508 | |
1509 | 1509 | $entry = $this->get_entry(); |
1510 | 1510 | |
1511 | 1511 | // If the value of the entry is the same as the stored value |
1512 | 1512 | // Then we can assume it's not a duplicate, it's the same. |
1513 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1513 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1514 | 1514 | //if value submitted was not changed, then don't validate |
1515 | 1515 | $field->failed_validation = false; |
1516 | 1516 | |
@@ -1523,7 +1523,7 @@ discard block |
||
1523 | 1523 | } |
1524 | 1524 | |
1525 | 1525 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1526 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1526 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1527 | 1527 | unset( $field->validation_message ); |
1528 | 1528 | $field->validation_message = false; |
1529 | 1529 | continue; |
@@ -1535,12 +1535,12 @@ discard block |
||
1535 | 1535 | |
1536 | 1536 | } |
1537 | 1537 | |
1538 | - $validation_results['is_valid'] = $gv_valid; |
|
1538 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1539 | 1539 | |
1540 | 1540 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1541 | 1541 | |
1542 | 1542 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1543 | - $this->form_after_validation = $validation_results['form']; |
|
1543 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1544 | 1544 | |
1545 | 1545 | return $validation_results; |
1546 | 1546 | } |
@@ -1553,7 +1553,7 @@ discard block |
||
1553 | 1553 | */ |
1554 | 1554 | public function get_entry() { |
1555 | 1555 | |
1556 | - if( empty( $this->entry ) ) { |
|
1556 | + if ( empty( $this->entry ) ) { |
|
1557 | 1557 | // Get the database value of the entry that's being edited |
1558 | 1558 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1559 | 1559 | } |
@@ -1585,10 +1585,10 @@ discard block |
||
1585 | 1585 | } |
1586 | 1586 | |
1587 | 1587 | // If edit tab not yet configured, show all fields |
1588 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1588 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1589 | 1589 | |
1590 | 1590 | // Hide fields depending on admin settings |
1591 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1591 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1592 | 1592 | |
1593 | 1593 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1594 | 1594 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1620,7 +1620,7 @@ discard block |
||
1620 | 1620 | */ |
1621 | 1621 | private function filter_fields( $fields, $configured_fields ) { |
1622 | 1622 | |
1623 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1623 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1624 | 1624 | return $fields; |
1625 | 1625 | } |
1626 | 1626 | |
@@ -1633,18 +1633,18 @@ discard block |
||
1633 | 1633 | |
1634 | 1634 | // Remove the fields that have calculation properties and keep them to be used later |
1635 | 1635 | // @since 1.16.2 |
1636 | - if( $field->has_calculation() ) { |
|
1637 | - $this->fields_with_calculation[] = $field; |
|
1636 | + if ( $field->has_calculation() ) { |
|
1637 | + $this->fields_with_calculation[ ] = $field; |
|
1638 | 1638 | // don't remove the calculation fields on form render. |
1639 | 1639 | } |
1640 | 1640 | |
1641 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1641 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1642 | 1642 | unset( $fields[ $key ] ); |
1643 | 1643 | } |
1644 | 1644 | } |
1645 | 1645 | |
1646 | 1646 | // The Edit tab has not been configured, so we return all fields by default. |
1647 | - if( empty( $configured_fields ) ) { |
|
1647 | + if ( empty( $configured_fields ) ) { |
|
1648 | 1648 | return $fields; |
1649 | 1649 | } |
1650 | 1650 | |
@@ -1653,8 +1653,8 @@ discard block |
||
1653 | 1653 | |
1654 | 1654 | /** @var GF_Field $field */ |
1655 | 1655 | foreach ( $fields as $field ) { |
1656 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1657 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1656 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1657 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1658 | 1658 | break; |
1659 | 1659 | } |
1660 | 1660 | |
@@ -1677,14 +1677,14 @@ discard block |
||
1677 | 1677 | |
1678 | 1678 | $return_field = $field; |
1679 | 1679 | |
1680 | - if( empty( $field_setting['show_label'] ) ) { |
|
1680 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1681 | 1681 | $return_field->label = ''; |
1682 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1683 | - $return_field->label = $field_setting['custom_label']; |
|
1682 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1683 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1684 | 1684 | } |
1685 | 1685 | |
1686 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1687 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1686 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1687 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1688 | 1688 | } |
1689 | 1689 | |
1690 | 1690 | /** |
@@ -1722,16 +1722,16 @@ discard block |
||
1722 | 1722 | */ |
1723 | 1723 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1724 | 1724 | |
1725 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1726 | - foreach( $fields as $k => $field ) { |
|
1727 | - if( $field->adminOnly ) { |
|
1725 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1726 | + foreach ( $fields as $k => $field ) { |
|
1727 | + if ( $field->adminOnly ) { |
|
1728 | 1728 | unset( $fields[ $k ] ); |
1729 | 1729 | } |
1730 | 1730 | } |
1731 | 1731 | return $fields; |
1732 | 1732 | } |
1733 | 1733 | |
1734 | - foreach( $fields as &$field ) { |
|
1734 | + foreach ( $fields as &$field ) { |
|
1735 | 1735 | $field->adminOnly = false; |
1736 | 1736 | } |
1737 | 1737 | |
@@ -1755,22 +1755,22 @@ discard block |
||
1755 | 1755 | */ |
1756 | 1756 | function prefill_conditional_logic( $form ) { |
1757 | 1757 | |
1758 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1758 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1759 | 1759 | return $form; |
1760 | 1760 | } |
1761 | 1761 | |
1762 | 1762 | // Have Conditional Logic pre-fill fields as if the data were default values |
1763 | 1763 | /** @var GF_Field $field */ |
1764 | - foreach ( $form['fields'] as &$field ) { |
|
1764 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1765 | 1765 | |
1766 | - if( 'checkbox' === $field->type ) { |
|
1766 | + if ( 'checkbox' === $field->type ) { |
|
1767 | 1767 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1768 | - $input_id = $input['id']; |
|
1768 | + $input_id = $input[ 'id' ]; |
|
1769 | 1769 | $choice = $field->choices[ $key ]; |
1770 | 1770 | $value = \GV\Utils::get( $this->entry, $input_id ); |
1771 | 1771 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
1772 | - if( $match ) { |
|
1773 | - $field->choices[ $key ]['isSelected'] = true; |
|
1772 | + if ( $match ) { |
|
1773 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
1774 | 1774 | } |
1775 | 1775 | } |
1776 | 1776 | } else { |
@@ -1778,15 +1778,15 @@ discard block |
||
1778 | 1778 | // We need to run through each field to set the default values |
1779 | 1779 | foreach ( $this->entry as $field_id => $field_value ) { |
1780 | 1780 | |
1781 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1781 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1782 | 1782 | |
1783 | - if( 'list' === $field->type ) { |
|
1783 | + if ( 'list' === $field->type ) { |
|
1784 | 1784 | $list_rows = maybe_unserialize( $field_value ); |
1785 | 1785 | |
1786 | 1786 | $list_field_value = array(); |
1787 | - foreach ( (array) $list_rows as $row ) { |
|
1788 | - foreach ( (array) $row as $column ) { |
|
1789 | - $list_field_value[] = $column; |
|
1787 | + foreach ( (array)$list_rows as $row ) { |
|
1788 | + foreach ( (array)$row as $column ) { |
|
1789 | + $list_field_value[ ] = $column; |
|
1790 | 1790 | } |
1791 | 1791 | } |
1792 | 1792 | |
@@ -1821,16 +1821,16 @@ discard block |
||
1821 | 1821 | */ |
1822 | 1822 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1823 | 1823 | |
1824 | - if( $use_conditional_logic ) { |
|
1824 | + if ( $use_conditional_logic ) { |
|
1825 | 1825 | return $form; |
1826 | 1826 | } |
1827 | 1827 | |
1828 | - foreach( $form['fields'] as &$field ) { |
|
1828 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1829 | 1829 | /* @var GF_Field $field */ |
1830 | 1830 | $field->conditionalLogic = null; |
1831 | 1831 | } |
1832 | 1832 | |
1833 | - unset( $form['button']['conditionalLogic'] ); |
|
1833 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1834 | 1834 | |
1835 | 1835 | return $form; |
1836 | 1836 | |
@@ -1847,7 +1847,7 @@ discard block |
||
1847 | 1847 | */ |
1848 | 1848 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
1849 | 1849 | |
1850 | - if( ! $this->is_edit_entry() ) { |
|
1850 | + if ( ! $this->is_edit_entry() ) { |
|
1851 | 1851 | return $has_conditional_logic; |
1852 | 1852 | } |
1853 | 1853 | |
@@ -1879,44 +1879,44 @@ discard block |
||
1879 | 1879 | * 2. There are two entries embedded using oEmbed |
1880 | 1880 | * 3. One of the entries has just been saved |
1881 | 1881 | */ |
1882 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1882 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1883 | 1883 | |
1884 | 1884 | $error = true; |
1885 | 1885 | |
1886 | 1886 | } |
1887 | 1887 | |
1888 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1888 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1889 | 1889 | |
1890 | 1890 | $error = true; |
1891 | 1891 | |
1892 | - } elseif( ! $this->verify_nonce() ) { |
|
1892 | + } elseif ( ! $this->verify_nonce() ) { |
|
1893 | 1893 | |
1894 | 1894 | /** |
1895 | 1895 | * If the Entry is embedded, there may be two entries on the same page. |
1896 | 1896 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1897 | 1897 | */ |
1898 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1898 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1899 | 1899 | $error = true; |
1900 | 1900 | } else { |
1901 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1901 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1902 | 1902 | } |
1903 | 1903 | |
1904 | 1904 | } |
1905 | 1905 | |
1906 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1907 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1906 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1907 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1908 | 1908 | } |
1909 | 1909 | |
1910 | - if( $this->entry['status'] === 'trash' ) { |
|
1911 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1910 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1911 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1912 | 1912 | } |
1913 | 1913 | |
1914 | 1914 | // No errors; everything's fine here! |
1915 | - if( empty( $error ) ) { |
|
1915 | + if ( empty( $error ) ) { |
|
1916 | 1916 | return true; |
1917 | 1917 | } |
1918 | 1918 | |
1919 | - if( $echo && $error !== true ) { |
|
1919 | + if ( $echo && $error !== true ) { |
|
1920 | 1920 | |
1921 | 1921 | $error = esc_html( $error ); |
1922 | 1922 | |
@@ -1924,10 +1924,10 @@ discard block |
||
1924 | 1924 | * @since 1.9 |
1925 | 1925 | */ |
1926 | 1926 | if ( ! empty( $this->entry ) ) { |
1927 | - $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;" ) ); |
|
1927 | + $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;" ) ); |
|
1928 | 1928 | } |
1929 | 1929 | |
1930 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1930 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1931 | 1931 | } |
1932 | 1932 | |
1933 | 1933 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1947,17 +1947,17 @@ discard block |
||
1947 | 1947 | |
1948 | 1948 | $error = NULL; |
1949 | 1949 | |
1950 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1951 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
1950 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1951 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
1952 | 1952 | } |
1953 | 1953 | |
1954 | 1954 | // No errors; everything's fine here! |
1955 | - if( empty( $error ) ) { |
|
1955 | + if ( empty( $error ) ) { |
|
1956 | 1956 | return true; |
1957 | 1957 | } |
1958 | 1958 | |
1959 | - if( $echo ) { |
|
1960 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
1959 | + if ( $echo ) { |
|
1960 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
1961 | 1961 | } |
1962 | 1962 | |
1963 | 1963 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1978,14 +1978,14 @@ discard block |
||
1978 | 1978 | private function check_user_cap_edit_field( $field ) { |
1979 | 1979 | |
1980 | 1980 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
1981 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1981 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1982 | 1982 | return true; |
1983 | 1983 | } |
1984 | 1984 | |
1985 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
1985 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
1986 | 1986 | |
1987 | - if( $field_cap ) { |
|
1988 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
1987 | + if ( $field_cap ) { |
|
1988 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
1989 | 1989 | } |
1990 | 1990 | |
1991 | 1991 | return false; |
@@ -1999,17 +1999,17 @@ discard block |
||
1999 | 1999 | public function verify_nonce() { |
2000 | 2000 | |
2001 | 2001 | // Verify form submitted for editing single |
2002 | - if( $this->is_edit_entry_submission() ) { |
|
2002 | + if ( $this->is_edit_entry_submission() ) { |
|
2003 | 2003 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2004 | 2004 | } |
2005 | 2005 | |
2006 | 2006 | // Verify |
2007 | - else if( ! $this->is_edit_entry() ) { |
|
2007 | + else if ( ! $this->is_edit_entry() ) { |
|
2008 | 2008 | $valid = false; |
2009 | 2009 | } |
2010 | 2010 | |
2011 | 2011 | else { |
2012 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2012 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2013 | 2013 | } |
2014 | 2014 | |
2015 | 2015 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function register_noconflict( $items ) { |
55 | 55 | |
56 | - $items[] = 'gravityview-admin-installer'; |
|
56 | + $items[ ] = 'gravityview-admin-installer'; |
|
57 | 57 | |
58 | 58 | return $items; |
59 | 59 | } |
@@ -70,17 +70,17 @@ discard block |
||
70 | 70 | return; |
71 | 71 | } |
72 | 72 | |
73 | - add_filter( 'plugins_api', function ( $data, $action, $args ) use ( $downloads_data ) { |
|
73 | + add_filter( 'plugins_api', function( $data, $action, $args ) use ( $downloads_data ) { |
|
74 | 74 | foreach ( $downloads_data as $extension ) { |
75 | - if ( empty( $extension['info'] ) || empty( $args->slug ) || $args->slug !== $extension['info']['slug'] ) { |
|
75 | + if ( empty( $extension[ 'info' ] ) || empty( $args->slug ) || $args->slug !== $extension[ 'info' ][ 'slug' ] ) { |
|
76 | 76 | continue; |
77 | 77 | } |
78 | 78 | |
79 | - return (object) array( |
|
80 | - 'slug' => $extension['info']['slug'], |
|
81 | - 'name' => $extension['info']['title'], |
|
82 | - 'version' => $extension['licensing']['version'], |
|
83 | - 'download_link' => $extension['files'][0]['file'], |
|
79 | + return (object)array( |
|
80 | + 'slug' => $extension[ 'info' ][ 'slug' ], |
|
81 | + 'name' => $extension[ 'info' ][ 'title' ], |
|
82 | + 'version' => $extension[ 'licensing' ][ 'version' ], |
|
83 | + 'download_link' => $extension[ 'files' ][ 0 ][ 'file' ], |
|
84 | 84 | ); |
85 | 85 | } |
86 | 86 | |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | |
143 | 143 | foreach ( $all_plugins as $path => $plugin ) { |
144 | 144 | |
145 | - if ( empty( $plugin['TextDomain'] ) ) { |
|
145 | + if ( empty( $plugin[ 'TextDomain' ] ) ) { |
|
146 | 146 | continue; |
147 | 147 | } |
148 | 148 | |
149 | - $wp_plugins[ $plugin['TextDomain'] ] = array( |
|
149 | + $wp_plugins[ $plugin[ 'TextDomain' ] ] = array( |
|
150 | 150 | 'path' => $path, |
151 | - 'version' => $plugin['Version'], |
|
151 | + 'version' => $plugin[ 'Version' ], |
|
152 | 152 | 'activated' => is_plugin_active( $path ) |
153 | 153 | ); |
154 | 154 | } |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | |
231 | 231 | $downloads_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
232 | 232 | |
233 | - if ( empty( $downloads_data['products'] ) ) { |
|
233 | + if ( empty( $downloads_data[ 'products' ] ) ) { |
|
234 | 234 | return array(); |
235 | 235 | } |
236 | 236 | |
237 | - $this->set_downloads_data( $downloads_data['products'] ); |
|
237 | + $this->set_downloads_data( $downloads_data[ 'products' ] ); |
|
238 | 238 | |
239 | - return $downloads_data['products']; |
|
239 | + return $downloads_data[ 'products' ]; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | foreach ( $downloads_data as $extension ) { |
311 | 311 | |
312 | - if ( empty( $extension['info'] ) ) { |
|
312 | + if ( empty( $extension[ 'info' ] ) ) { |
|
313 | 313 | continue; |
314 | 314 | } |
315 | 315 | |
@@ -338,28 +338,28 @@ discard block |
||
338 | 338 | |
339 | 339 | $details = $this->get_download_display_details( $download, $wp_plugins ); |
340 | 340 | |
341 | - $download_info = $details['download_info']; |
|
341 | + $download_info = $details[ 'download_info' ]; |
|
342 | 342 | |
343 | 343 | ?> |
344 | - <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
|
344 | + <div class="item <?php echo esc_attr( $details[ 'item_class' ] ); ?>"> |
|
345 | 345 | <div class="addon-inner"> |
346 | - <a href="<?php echo esc_url( $download_info['link'] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info['thumbnail'] ); ?>" alt="" /></a> |
|
347 | - <h3><?php echo esc_html( $download_info['title'] ); ?></h3> |
|
346 | + <a href="<?php echo esc_url( $download_info[ 'link' ] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info[ 'thumbnail' ] ); ?>" alt="" /></a> |
|
347 | + <h3><?php echo esc_html( $download_info[ 'title' ] ); ?></h3> |
|
348 | 348 | <div> |
349 | - <?php if( $details['status_label'] ) { ?> |
|
350 | - <div class="status <?php echo esc_attr( $details['status'] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details['status_label'] ) ); ?>"> |
|
351 | - <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details['status_label'] ); ?></span> |
|
349 | + <?php if ( $details[ 'status_label' ] ) { ?> |
|
350 | + <div class="status <?php echo esc_attr( $details[ 'status' ] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details[ 'status_label' ] ) ); ?>"> |
|
351 | + <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details[ 'status_label' ] ); ?></span> |
|
352 | 352 | </div> |
353 | 353 | <?php } ?> |
354 | 354 | |
355 | - <a data-status="<?php echo esc_attr( $details['status'] ); ?>" data-plugin-path="<?php echo esc_attr( $details['plugin_path'] ); ?>" href="<?php echo esc_url( $details['href'] ); ?>" class="button <?php echo esc_attr( $details['button_class'] ); ?>" title="<?php echo esc_attr( $details['button_title'] ); ?>"> |
|
356 | - <span class="title"><?php echo esc_html( $details['button_label'] ); ?></span> |
|
357 | - <?php if( $details['spinner'] ) { ?><span class="spinner"></span><?php } ?> |
|
355 | + <a data-status="<?php echo esc_attr( $details[ 'status' ] ); ?>" data-plugin-path="<?php echo esc_attr( $details[ 'plugin_path' ] ); ?>" href="<?php echo esc_url( $details[ 'href' ] ); ?>" class="button <?php echo esc_attr( $details[ 'button_class' ] ); ?>" title="<?php echo esc_attr( $details[ 'button_title' ] ); ?>"> |
|
356 | + <span class="title"><?php echo esc_html( $details[ 'button_label' ] ); ?></span> |
|
357 | + <?php if ( $details[ 'spinner' ] ) { ?><span class="spinner"></span><?php } ?> |
|
358 | 358 | </a> |
359 | 359 | </div> |
360 | 360 | |
361 | 361 | <div class="addon-excerpt"> |
362 | - <?php echo wpautop( esc_html( $download_info['excerpt'] ) ); ?> |
|
362 | + <?php echo wpautop( esc_html( $download_info[ 'excerpt' ] ) ); ?> |
|
363 | 363 | </div> |
364 | 364 | </div> |
365 | 365 | </div> |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | */ |
390 | 390 | private function get_download_display_details( $download, $wp_plugins ) { |
391 | 391 | |
392 | - $download_info = wp_parse_args( (array) $download['info'], array( |
|
392 | + $download_info = wp_parse_args( (array)$download[ 'info' ], array( |
|
393 | 393 | 'thumbnail' => '', |
394 | 394 | 'title' => '', |
395 | 395 | 'textdomain' => '', |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | 'link' => '', |
399 | 399 | ) ); |
400 | 400 | |
401 | - $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info['textdomain'], false ); |
|
401 | + $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info[ 'textdomain' ], false ); |
|
402 | 402 | |
403 | - $has_access = ! empty( $download['files'] ); |
|
403 | + $has_access = ! empty( $download[ 'files' ] ); |
|
404 | 404 | $spinner = true; |
405 | 405 | $href = $plugin_path = '#'; |
406 | 406 | $status = $item_class = $button_title = $button_class = ''; |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $required_license = $galactic_only ? __( 'Galactic', 'gravityview' ) : __( 'Interstellar', 'gravityview' ); |
411 | 411 | |
412 | 412 | // The license is not active - no matter what level, this should not work |
413 | - if( ! $is_active && empty( $base_price ) ) { |
|
413 | + if ( ! $is_active && empty( $base_price ) ) { |
|
414 | 414 | $spinner = false; |
415 | 415 | $button_class = 'disabled disabled-license'; |
416 | 416 | $button_label = sprintf( __( 'Active %s License is Required.', 'gravityview' ), $required_license ); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $status_label = ''; |
423 | 423 | $button_label = sprintf( __( 'Purchase Now for %s', 'gravityview' ), '$' . $base_price ); |
424 | 424 | $button_class = 'button-primary button-large'; |
425 | - $href = $download_info['link']; |
|
425 | + $href = $download_info[ 'link' ]; |
|
426 | 426 | $item_class = 'featured'; |
427 | 427 | } |
428 | 428 | |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | $href = add_query_arg( |
442 | 442 | array( |
443 | 443 | 'action' => 'install-plugin', |
444 | - 'plugin' => $download_info['slug'], |
|
445 | - '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info['slug'] ), |
|
444 | + 'plugin' => $download_info[ 'slug' ], |
|
445 | + '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info[ 'slug' ] ), |
|
446 | 446 | ), |
447 | 447 | self_admin_url( 'update.php' ) |
448 | 448 | ); |
@@ -454,26 +454,26 @@ discard block |
||
454 | 454 | } |
455 | 455 | |
456 | 456 | // Access and the plugin is installed but not active |
457 | - else if ( false === $wp_plugin['activated'] ) { |
|
457 | + else if ( false === $wp_plugin[ 'activated' ] ) { |
|
458 | 458 | |
459 | 459 | $status = 'inactive'; |
460 | 460 | $status_label = __( 'Inactive', 'gravityview' ); |
461 | 461 | $button_label = __( 'Activate', 'gravityview' ); |
462 | - $plugin_path = $wp_plugin['path']; |
|
462 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
463 | 463 | |
464 | 464 | } |
465 | 465 | |
466 | 466 | // Access and the plugin is installed and active |
467 | 467 | else { |
468 | 468 | |
469 | - $plugin_path = $wp_plugin['path']; |
|
469 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
470 | 470 | $status = 'active'; |
471 | 471 | $status_label = __( 'Active', 'gravityview' ); |
472 | 472 | $button_label = __( 'Deactivate', 'gravityview' ); |
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | - return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
476 | + return compact( 'download_info', 'plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
489 | 489 | $base_price = \GFCommon::to_number( $base_price ); |
490 | 490 | |
491 | - unset( $download['pricing']['amount'] ); |
|
491 | + unset( $download[ 'pricing' ][ 'amount' ] ); |
|
492 | 492 | |
493 | 493 | // Price options array, not single price |
494 | - if ( ! $base_price && ! empty( $download['pricing'] ) ) { |
|
495 | - $base_price = array_shift( $download['pricing'] ); |
|
494 | + if ( ! $base_price && ! empty( $download[ 'pricing' ] ) ) { |
|
495 | + $base_price = array_shift( $download[ 'pricing' ] ); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | return floatval( $base_price ); |
@@ -506,13 +506,13 @@ discard block |
||
506 | 506 | public function activate_download() { |
507 | 507 | $data = \GV\Utils::_POST( 'data', array() ); |
508 | 508 | |
509 | - if ( empty( $data['path'] ) ) { |
|
509 | + if ( empty( $data[ 'path' ] ) ) { |
|
510 | 510 | return; |
511 | 511 | } |
512 | 512 | |
513 | - $result = activate_plugin( $data['path'] ); |
|
513 | + $result = activate_plugin( $data[ 'path' ] ); |
|
514 | 514 | |
515 | - if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
|
515 | + if ( is_wp_error( $result ) || ! is_plugin_active( $data[ 'path' ] ) ) { |
|
516 | 516 | wp_send_json_error( array( |
517 | 517 | 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
518 | 518 | ) ); |
@@ -529,13 +529,13 @@ discard block |
||
529 | 529 | public function deactivate_download() { |
530 | 530 | $data = \GV\Utils::_POST( 'data', array() ); |
531 | 531 | |
532 | - if ( empty( $data['path'] ) ) { |
|
532 | + if ( empty( $data[ 'path' ] ) ) { |
|
533 | 533 | return; |
534 | 534 | } |
535 | 535 | |
536 | - deactivate_plugins( $data['path'] ); |
|
536 | + deactivate_plugins( $data[ 'path' ] ); |
|
537 | 537 | |
538 | - if( is_plugin_active( $data['path'] ) ) { |
|
538 | + if ( is_plugin_active( $data[ 'path' ] ) ) { |
|
539 | 539 | wp_send_json_error( array( |
540 | 540 | 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
541 | 541 | ) ); |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | private function add_hooks() { |
40 | 40 | |
41 | 41 | // in case entry is edited (on admin or frontend) |
42 | - add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2); |
|
42 | + add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 ); |
|
43 | 43 | |
44 | 44 | // when using the User opt-in field, check on entry submission |
45 | 45 | add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 ); |
46 | 46 | |
47 | 47 | // process ajax approve entry requests |
48 | - add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved')); |
|
48 | + add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) ); |
|
49 | 49 | |
50 | 50 | // autounapprove |
51 | 51 | add_action( 'gravityview/edit_entry/after_update', array( __CLASS__, 'autounapprove' ), 10, 4 ); |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public static function get_entry_status( $entry, $value_or_label = 'label' ) { |
67 | 67 | |
68 | - $entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry, true ); |
|
68 | + $entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry, true ); |
|
69 | 69 | |
70 | 70 | $status = gform_get_meta( $entry_id, self::meta_key ); |
71 | 71 | |
72 | 72 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
73 | 73 | |
74 | - if( 'value' === $value_or_label ) { |
|
74 | + if ( 'value' === $value_or_label ) { |
|
75 | 75 | return $status; |
76 | 76 | } |
77 | 77 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $nonce = \GV\Utils::_POST( 'nonce' ); |
110 | 110 | |
111 | 111 | // Valid status |
112 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
112 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
113 | 113 | |
114 | 114 | gravityview()->log->error( 'Invalid approval status', array( 'data' => $_POST ) ); |
115 | 115 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
142 | 142 | |
143 | - $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') ); |
|
143 | + $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) ); |
|
144 | 144 | |
145 | 145 | } |
146 | 146 | |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | // Set default |
194 | - self::update_approved_meta( $entry['id'], $default_status, $entry['form_id'] ); |
|
194 | + self::update_approved_meta( $entry[ 'id' ], $default_status, $entry[ 'form_id' ] ); |
|
195 | 195 | |
196 | 196 | // Then check for if there is an approval column, and use that value instead |
197 | - $this->after_update_entry_update_approved_meta( $form , $entry['id'] ); |
|
197 | + $this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
210 | 210 | |
211 | - $approved_column = self::get_approved_column( $form['id'] ); |
|
211 | + $approved_column = self::get_approved_column( $form[ 'id' ] ); |
|
212 | 212 | |
213 | 213 | /** |
214 | 214 | * If the form doesn't contain the approve field, don't assume anything. |
215 | 215 | */ |
216 | - if( empty( $approved_column ) ) { |
|
216 | + if ( empty( $approved_column ) ) { |
|
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $value = GravityView_Entry_Approval_Status::APPROVED; |
228 | 228 | } |
229 | 229 | |
230 | - self::update_approved_meta( $entry_id, $value, $form['id'] ); |
|
230 | + self::update_approved_meta( $entry_id, $value, $form[ 'id' ] ); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public static function update_bulk( $entries = array(), $approved, $form_id ) { |
247 | 247 | |
248 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
248 | + if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) { |
|
249 | 249 | gravityview()->log->error( 'Entries were empty or malformed.', array( 'data' => $entries ) ); |
250 | 250 | return NULL; |
251 | 251 | } |
252 | 252 | |
253 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
253 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
254 | 254 | gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' ); |
255 | 255 | return NULL; |
256 | 256 | } |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | $approved_column_id = self::get_approved_column( $form_id ); |
266 | 266 | |
267 | 267 | $success = true; |
268 | - foreach( $entries as $entry_id ) { |
|
268 | + foreach ( $entries as $entry_id ) { |
|
269 | 269 | $update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
270 | 270 | |
271 | - if( ! $update_success ) { |
|
271 | + if ( ! $update_success ) { |
|
272 | 272 | $success = false; |
273 | 273 | } |
274 | 274 | } |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public static function update_approved( $entry_id = 0, $approved = 2, $form_id = 0, $approvedcolumn = 0 ) { |
294 | 294 | |
295 | - if( !class_exists( 'GFAPI' ) ) { |
|
295 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
296 | 296 | gravityview()->log->error( 'GFAPI does not exist' ); |
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | |
300 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
300 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
301 | 301 | gravityview()->log->error( 'Not a valid approval value.' ); |
302 | 302 | return false; |
303 | 303 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | // If the form has an Approve/Reject field, update that value |
315 | 315 | $result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn ); |
316 | 316 | |
317 | - if( is_wp_error( $result ) ) { |
|
317 | + if ( is_wp_error( $result ) ) { |
|
318 | 318 | gravityview()->log->error( 'Entry approval not updated: {error}', array( 'error' => $result->get_error_message() ) ); |
319 | 319 | return false; |
320 | 320 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | // add note to entry if approval field updating worked or there was no approved field |
328 | 328 | // There's no validation for the meta |
329 | - if( true === $result ) { |
|
329 | + if ( true === $result ) { |
|
330 | 330 | |
331 | 331 | // Add an entry note |
332 | 332 | self::add_approval_status_updated_note( $entry_id, $approved ); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | $note_id = false; |
381 | 381 | |
382 | - if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
382 | + if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
383 | 383 | |
384 | 384 | $current_user = wp_get_current_user(); |
385 | 385 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | */ |
402 | 402 | private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) { |
403 | 403 | |
404 | - if( empty( $approvedcolumn ) ) { |
|
404 | + if ( empty( $approvedcolumn ) ) { |
|
405 | 405 | $approvedcolumn = self::get_approved_column( $form_id ); |
406 | 406 | } |
407 | 407 | |
@@ -424,12 +424,12 @@ discard block |
||
424 | 424 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
425 | 425 | |
426 | 426 | $new_value = ''; |
427 | - if( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
427 | + if ( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
428 | 428 | $new_value = self::get_approved_column_input_label( $form_id, $approvedcolumn ); |
429 | 429 | } |
430 | 430 | |
431 | 431 | //update entry |
432 | - $entry["{$approvedcolumn}"] = $new_value; |
|
432 | + $entry[ "{$approvedcolumn}" ] = $new_value; |
|
433 | 433 | |
434 | 434 | /** |
435 | 435 | * Note: GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves |
@@ -460,12 +460,12 @@ discard block |
||
460 | 460 | // If the user has enabled a different value than the label (for some reason), use it. |
461 | 461 | // This is highly unlikely |
462 | 462 | if ( is_array( $field->choices ) && ! empty( $field->choices ) ) { |
463 | - return isset( $field->choices[0]['value'] ) ? $field->choices[0]['value'] : $field->choices[0]['text']; |
|
463 | + return isset( $field->choices[ 0 ][ 'value' ] ) ? $field->choices[ 0 ][ 'value' ] : $field->choices[ 0 ][ 'text' ]; |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | // Otherwise, fall back on the inputs array |
467 | 467 | if ( is_array( $field->inputs ) && ! empty( $field->inputs ) ) { |
468 | - return $field->inputs[0]['label']; |
|
468 | + return $field->inputs[ 0 ][ 'label' ]; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | return null; |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * @since 1.18 Added "unapproved" |
519 | 519 | * @param int $entry_id ID of the Gravity Forms entry |
520 | 520 | */ |
521 | - do_action( 'gravityview/approve_entries/' . $action , $entry_id ); |
|
521 | + do_action( 'gravityview/approve_entries/' . $action, $entry_id ); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -531,11 +531,11 @@ discard block |
||
531 | 531 | */ |
532 | 532 | static public function get_approved_column( $form ) { |
533 | 533 | |
534 | - if( empty( $form ) ) { |
|
534 | + if ( empty( $form ) ) { |
|
535 | 535 | return null; |
536 | 536 | } |
537 | 537 | |
538 | - if( !is_array( $form ) ) { |
|
538 | + if ( ! is_array( $form ) ) { |
|
539 | 539 | $form = GVCommon::get_form( $form ); |
540 | 540 | } |
541 | 541 | |
@@ -545,22 +545,22 @@ discard block |
||
545 | 545 | * @var string $key |
546 | 546 | * @var GF_Field $field |
547 | 547 | */ |
548 | - foreach( $form['fields'] as $key => $field ) { |
|
548 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
549 | 549 | |
550 | 550 | $inputs = $field->get_entry_inputs(); |
551 | 551 | |
552 | - if( !empty( $field->gravityview_approved ) ) { |
|
553 | - if ( ! empty( $inputs ) && !empty( $inputs[0]['id'] ) ) { |
|
554 | - $approved_column_id = $inputs[0]['id']; |
|
552 | + if ( ! empty( $field->gravityview_approved ) ) { |
|
553 | + if ( ! empty( $inputs ) && ! empty( $inputs[ 0 ][ 'id' ] ) ) { |
|
554 | + $approved_column_id = $inputs[ 0 ][ 'id' ]; |
|
555 | 555 | break; |
556 | 556 | } |
557 | 557 | } |
558 | 558 | |
559 | 559 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
560 | - if( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
560 | + if ( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
561 | 561 | foreach ( $inputs as $input ) { |
562 | - if ( 'approved' === strtolower( $input['label'] ) ) { |
|
563 | - $approved_column_id = $input['id']; |
|
562 | + if ( 'approved' === strtolower( $input[ 'label' ] ) ) { |
|
563 | + $approved_column_id = $input[ 'id' ]; |
|
564 | 564 | break; |
565 | 565 | } |
566 | 566 | } |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | |
587 | 587 | $view_keys = array_keys( $gv_data->get_views() ); |
588 | 588 | |
589 | - $view = \GV\View::by_id( $view_keys[0] ); |
|
589 | + $view = \GV\View::by_id( $view_keys[ 0 ] ); |
|
590 | 590 | |
591 | 591 | if ( ! $view->settings->get( 'unapprove_edit' ) ) { |
592 | 592 | return; |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | return; |
597 | 597 | } |
598 | 598 | |
599 | - self::update_approved_meta( $entry_id, GravityView_Entry_Approval_Status::UNAPPROVED, $form['id'] ); |
|
599 | + self::update_approved_meta( $entry_id, GravityView_Entry_Approval_Status::UNAPPROVED, $form[ 'id' ] ); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | } |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | gravityview()->log->debug( '$passed_atts: ', array( 'data' => $passed_atts ) ); |
49 | 49 | |
50 | 50 | // Get details about the current View |
51 | - if( !empty( $passed_atts['detail'] ) ) { |
|
52 | - return $this->get_view_detail( $passed_atts['detail'] ); |
|
51 | + if ( ! empty( $passed_atts[ 'detail' ] ) ) { |
|
52 | + return $this->get_view_detail( $passed_atts[ 'detail' ] ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $atts = $this->parse_and_sanitize_atts( $passed_atts ); |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
86 | 86 | |
87 | 87 | // Only keep the passed attributes after making sure that they're valid pairs |
88 | - $filtered_atts = array_intersect_key( (array) $passed_atts, $filtered_atts ); |
|
88 | + $filtered_atts = array_intersect_key( (array)$passed_atts, $filtered_atts ); |
|
89 | 89 | |
90 | 90 | $atts = array(); |
91 | 91 | |
92 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
92 | + foreach ( $filtered_atts as $key => $passed_value ) { |
|
93 | 93 | |
94 | 94 | // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by} |
95 | 95 | $passed_value = GravityView_Merge_Tags::replace_variables( $passed_value ); |
96 | 96 | |
97 | - switch( $defaults[ $key ]['type'] ) { |
|
97 | + switch ( $defaults[ $key ][ 'type' ] ) { |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Make sure number fields are numeric. |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
103 | 103 | */ |
104 | 104 | case 'number': |
105 | - if( is_numeric( $passed_value ) ) { |
|
105 | + if ( is_numeric( $passed_value ) ) { |
|
106 | 106 | $atts[ $key ] = ( $passed_value + 0 ); |
107 | 107 | } |
108 | 108 | break; |
109 | 109 | |
110 | 110 | /** @since 2.1 */ |
111 | 111 | case 'operator': |
112 | - if( GFFormsModel::is_valid_operator( $passed_value ) ) { |
|
112 | + if ( GFFormsModel::is_valid_operator( $passed_value ) ) { |
|
113 | 113 | $atts[ $key ] = $passed_value; |
114 | 114 | } |
115 | 115 | break; |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | */ |
125 | 125 | case 'select': |
126 | 126 | case 'radio': |
127 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
128 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
127 | + $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ]; |
|
128 | + if ( in_array( $passed_value, array_keys( $options ) ) ) { |
|
129 | 129 | $atts[ $key ] = $passed_value; |
130 | 130 | } |
131 | 131 | break; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $gravityview_view = GravityView_View::getInstance(); |
155 | 155 | $return = ''; |
156 | 156 | |
157 | - switch( $detail ) { |
|
157 | + switch ( $detail ) { |
|
158 | 158 | case 'total_entries': |
159 | 159 | $return = number_format_i18n( $gravityview_view->getTotalEntries() ); |
160 | 160 | break; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $supports = array( 'title', 'revisions' ); |
109 | 109 | |
110 | 110 | if ( $is_hierarchical ) { |
111 | - $supports[] = 'page-attributes'; |
|
111 | + $supports[ ] = 'page-attributes'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | $rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' ); |
211 | 211 | |
212 | 212 | add_filter( 'query_vars', function( $query_vars ) { |
213 | - $query_vars[] = 'csv'; |
|
213 | + $query_vars[ ] = 'csv'; |
|
214 | 214 | return $query_vars; |
215 | 215 | } ); |
216 | 216 | |
217 | - if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[0] ] ) ) { |
|
217 | + if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[ 0 ] ] ) ) { |
|
218 | 218 | call_user_func_array( 'add_rewrite_rule', $rule ); |
219 | 219 | } |
220 | 220 | } |
@@ -278,13 +278,13 @@ discard block |
||
278 | 278 | return $content; |
279 | 279 | } |
280 | 280 | |
281 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
281 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
282 | 282 | |
283 | 283 | /** |
284 | 284 | * Editing a single entry. |
285 | 285 | */ |
286 | 286 | if ( $entry = $request->is_edit_entry() ) { |
287 | - if ( $entry['status'] != 'active' ) { |
|
287 | + if ( $entry[ 'status' ] != 'active' ) { |
|
288 | 288 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
289 | 289 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
290 | 290 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
298 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
298 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
299 | 299 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
300 | 300 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
301 | 301 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * Viewing a single entry. |
309 | 309 | */ |
310 | 310 | } else if ( $entry = $request->is_entry() ) { |
311 | - if ( $entry['status'] != 'active' ) { |
|
311 | + if ( $entry[ 'status' ] != 'active' ) { |
|
312 | 312 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
313 | 313 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
314 | 314 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | } |
320 | 320 | |
321 | 321 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
322 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
322 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
323 | 323 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
324 | 324 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
325 | 325 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | $error = \GVCommon::check_entry_display( $entry->as_entry() ); |
329 | 329 | |
330 | - if( is_wp_error( $error ) ) { |
|
330 | + if ( is_wp_error( $error ) ) { |
|
331 | 331 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing: {message}', array( 'entry_id' => $entry->ID, 'message' => $error->get_error_message() ) ); |
332 | 332 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
333 | 333 | } |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column ); |
486 | 486 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column ); |
487 | 487 | |
488 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
488 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | return $joins; |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | |
528 | 528 | list( $join, $join_column, $join_on, $join_on_column ) = $meta; |
529 | 529 | |
530 | - $forms_ids [] = GF_Form::by_id( $join_on ); |
|
530 | + $forms_ids [ ] = GF_Form::by_id( $join_on ); |
|
531 | 531 | } |
532 | 532 | |
533 | - return ( !empty( $forms_ids) ) ? $forms_ids : null; |
|
533 | + return ( ! empty( $forms_ids ) ) ? $forms_ids : null; |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | if ( ! $view->form ) { |
562 | 562 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
563 | 563 | 'view_id' => $view->ID, |
564 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
564 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
565 | 565 | ) ); |
566 | 566 | } |
567 | 567 | |
@@ -787,28 +787,27 @@ discard block |
||
787 | 787 | * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
788 | 788 | */ |
789 | 789 | $parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID ); |
790 | - $parameters['context_view_id'] = $this->ID; |
|
790 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
791 | 791 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
792 | 792 | |
793 | 793 | if ( $request instanceof REST\Request ) { |
794 | 794 | $atts = $this->settings->as_atts(); |
795 | 795 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
796 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
796 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
797 | 797 | ) ); |
798 | - $parameters['paging'] = $paging_parameters['paging']; |
|
798 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
799 | 799 | } |
800 | 800 | |
801 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
802 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
801 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
803 | 802 | |
804 | 803 | if ( gravityview()->plugin->supports( Plugin::FEATURE_GFQUERY ) ) { |
805 | 804 | /** |
806 | 805 | * New \GF_Query stuff :) |
807 | 806 | */ |
808 | - $query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
807 | + $query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
809 | 808 | |
810 | - $query->limit( $parameters['paging']['page_size'] ) |
|
811 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
809 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
810 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
812 | 811 | |
813 | 812 | /** |
814 | 813 | * Any joins? |
@@ -848,15 +847,15 @@ discard block |
||
848 | 847 | } ); |
849 | 848 | } else { |
850 | 849 | $entries = $this->form->entries |
851 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
850 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
852 | 851 | ->offset( $this->settings->get( 'offset' ) ) |
853 | - ->limit( $parameters['paging']['page_size'] ) |
|
852 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
854 | 853 | ->page( $page ); |
855 | 854 | |
856 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
855 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
857 | 856 | $field = new \GV\Field(); |
858 | - $field->ID = $parameters['sorting']['key']; |
|
859 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
857 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
858 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
860 | 859 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
861 | 860 | } |
862 | 861 | } |
@@ -927,7 +926,7 @@ discard block |
||
927 | 926 | $allowed = $headers = array(); |
928 | 927 | |
929 | 928 | foreach ( $view->fields->by_position( "directory_*" )->by_visible()->all() as $field ) { |
930 | - $allowed[] = $field->ID; |
|
929 | + $allowed[ ] = $field->ID; |
|
931 | 930 | } |
932 | 931 | |
933 | 932 | $renderer = new Field_Renderer(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | $form = $gravityview_view->getForm(); |
33 | 33 | |
34 | - if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && ! empty( $GLOBALS['GravityView_API_field_label_override'] ) ) { |
|
34 | + if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && ! empty( $GLOBALS[ 'GravityView_API_field_label_override' ] ) ) { |
|
35 | 35 | /** Allow to fall through for back compatibility testing purposes. */ |
36 | 36 | } else { |
37 | 37 | return \GV\Mocks\GravityView_API_field_label( $form, $field, $entry, $force_show_label ); |
@@ -39,29 +39,29 @@ discard block |
||
39 | 39 | |
40 | 40 | $label = ''; |
41 | 41 | |
42 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
42 | + if ( ! empty( $field[ 'show_label' ] ) || $force_show_label ) { |
|
43 | 43 | |
44 | - $label = $field['label']; |
|
44 | + $label = $field[ 'label' ]; |
|
45 | 45 | |
46 | 46 | // Support Gravity Forms 1.9+ |
47 | - if( class_exists( 'GF_Field' ) ) { |
|
47 | + if ( class_exists( 'GF_Field' ) ) { |
|
48 | 48 | |
49 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
49 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
50 | 50 | |
51 | - if( $field_object ) { |
|
51 | + if ( $field_object ) { |
|
52 | 52 | |
53 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
53 | + $input = GFFormsModel::get_input( $field_object, $field[ 'id' ] ); |
|
54 | 54 | |
55 | 55 | // This is a complex field, with labels on a per-input basis |
56 | - if( $input ) { |
|
56 | + if ( $input ) { |
|
57 | 57 | |
58 | 58 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
59 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
59 | + $label = ! empty( $input[ 'customLabel' ] ) ? $input[ 'customLabel' ] : $input[ 'label' ]; |
|
60 | 60 | |
61 | 61 | } else { |
62 | 62 | |
63 | 63 | // This is a field with one label |
64 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
64 | + $label = $field_object->get_field_label( true, $field[ 'label' ] ); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
73 | - if ( !empty( $field['custom_label'] ) ) { |
|
73 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
74 | 74 | |
75 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
75 | + $label = self::replace_variables( $field[ 'custom_label' ], $form, $entry ); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | |
135 | 135 | $width = NULL; |
136 | 136 | |
137 | - if( !empty( $field['width'] ) ) { |
|
138 | - $width = absint( $field['width'] ); |
|
137 | + if ( ! empty( $field[ 'width' ] ) ) { |
|
138 | + $width = absint( $field[ 'width' ] ); |
|
139 | 139 | |
140 | 140 | // If using percentages, limit to 100% |
141 | - if( '%d%%' === $format && $width > 100 ) { |
|
141 | + if ( '%d%%' === $format && $width > 100 ) { |
|
142 | 142 | $width = 100; |
143 | 143 | } |
144 | 144 | |
@@ -159,42 +159,42 @@ discard block |
||
159 | 159 | public static function field_class( $field, $form = NULL, $entry = NULL ) { |
160 | 160 | $classes = array(); |
161 | 161 | |
162 | - if( !empty( $field['custom_class'] ) ) { |
|
162 | + if ( ! empty( $field[ 'custom_class' ] ) ) { |
|
163 | 163 | |
164 | - $custom_class = $field['custom_class']; |
|
164 | + $custom_class = $field[ 'custom_class' ]; |
|
165 | 165 | |
166 | - if( !empty( $entry ) ) { |
|
166 | + if ( ! empty( $entry ) ) { |
|
167 | 167 | |
168 | 168 | // We want the merge tag to be formatted as a class. The merge tag may be |
169 | 169 | // replaced by a multiple-word value that should be output as a single class. |
170 | 170 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
171 | - add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
171 | + add_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
172 | 172 | |
173 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
173 | + $custom_class = self::replace_variables( $custom_class, $form, $entry ); |
|
174 | 174 | |
175 | 175 | // And then we want life to return to normal |
176 | - remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
176 | + remove_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | // And now we want the spaces to be handled nicely. |
180 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
180 | + $classes[ ] = gravityview_sanitize_html_class( $custom_class ); |
|
181 | 181 | |
182 | 182 | } |
183 | 183 | |
184 | - if(!empty($field['id'])) { |
|
185 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
186 | - $form_id = '-'.$form['id']; |
|
184 | + if ( ! empty( $field[ 'id' ] ) ) { |
|
185 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
186 | + $form_id = '-' . $form[ 'id' ]; |
|
187 | 187 | } else { |
188 | 188 | // @deprecated path. Form should always be given. |
189 | 189 | gravityview()->log->warning( 'GravityView_View::getInstance() legacy API called' ); |
190 | 190 | $gravityview_view = GravityView_View::getInstance(); |
191 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
191 | + $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
192 | 192 | } |
193 | 193 | |
194 | - $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
|
194 | + $classes[ ] = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
195 | 195 | } |
196 | 196 | |
197 | - return esc_attr(implode(' ', $classes)); |
|
197 | + return esc_attr( implode( ' ', $classes ) ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | * @return string Sanitized unique HTML `id` attribute for the field |
211 | 211 | */ |
212 | 212 | public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
213 | - $id = $field['id']; |
|
213 | + $id = $field[ 'id' ]; |
|
214 | 214 | |
215 | 215 | if ( ! empty( $id ) ) { |
216 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
217 | - $form_id = '-' . $form['id']; |
|
216 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
217 | + $form_id = '-' . $form[ 'id' ]; |
|
218 | 218 | } else { |
219 | 219 | // @deprecated path. Form should always be given. |
220 | 220 | gravityview()->log->warning( 'GravityView_View::getInstance() legacy API called' ); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
223 | 223 | } |
224 | 224 | |
225 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
225 | + $id = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | return esc_attr( $id ); |
@@ -262,14 +262,14 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array(), $base_id = null ) { |
264 | 264 | |
265 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
265 | + if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry[ 'id' ] ) ) { |
|
266 | 266 | gravityview()->log->debug( 'Entry not defined; returning null', array( 'data' => $entry ) ); |
267 | 267 | return NULL; |
268 | 268 | } |
269 | 269 | |
270 | 270 | $href = self::entry_link( $entry, $base_id ); |
271 | 271 | |
272 | - if( '' === $href ) { |
|
272 | + if ( '' === $href ) { |
|
273 | 273 | return NULL; |
274 | 274 | } |
275 | 275 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | } else { |
307 | 307 | $gravityview_view = GravityView_View::getInstance(); |
308 | 308 | |
309 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
309 | + if ( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
310 | 310 | $is_search = true; |
311 | 311 | } |
312 | 312 | } |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | |
403 | 403 | // If we've saved the permalink in memory, use it |
404 | 404 | // @since 1.3 |
405 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
405 | + $link = wp_cache_get( 'gv_directory_link_' . $post_id ); |
|
406 | 406 | |
407 | - if ( (int) $post_id === (int) get_option( 'page_on_front' ) ) { |
|
407 | + if ( (int)$post_id === (int)get_option( 'page_on_front' ) ) { |
|
408 | 408 | $link = home_url(); |
409 | 409 | } |
410 | 410 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | |
414 | 414 | // If not yet saved, cache the permalink. |
415 | 415 | // @since 1.3 |
416 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
416 | + wp_cache_set( 'gv_directory_link_' . $post_id, $link ); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | // Deal with returning to proper pagination for embedded views |
@@ -421,13 +421,13 @@ discard block |
||
421 | 421 | |
422 | 422 | $args = array(); |
423 | 423 | |
424 | - if( $pagenum = \GV\Utils::_GET( 'pagenum' ) ) { |
|
425 | - $args['pagenum'] = intval( $pagenum ); |
|
424 | + if ( $pagenum = \GV\Utils::_GET( 'pagenum' ) ) { |
|
425 | + $args[ 'pagenum' ] = intval( $pagenum ); |
|
426 | 426 | } |
427 | 427 | |
428 | - if( $sort = \GV\Utils::_GET( 'sort' ) ) { |
|
429 | - $args['sort'] = $sort; |
|
430 | - $args['dir'] = \GV\Utils::_GET( 'dir' ); |
|
428 | + if ( $sort = \GV\Utils::_GET( 'sort' ) ) { |
|
429 | + $args[ 'sort' ] = $sort; |
|
430 | + $args[ 'dir' ] = \GV\Utils::_GET( 'dir' ); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | $link = add_query_arg( $args, $link ); |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | private static function get_custom_entry_slug( $id, $entry = array() ) { |
465 | 465 | |
466 | 466 | // Generate an unique hash to use as the default value |
467 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
467 | + $slug = substr( wp_hash( $id, 'gravityview' . $id ), 0, 8 ); |
|
468 | 468 | |
469 | 469 | /** |
470 | 470 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
476 | 476 | |
477 | 477 | // Make sure we have something - use the original ID as backup. |
478 | - if( empty( $slug ) ) { |
|
478 | + if ( empty( $slug ) ) { |
|
479 | 479 | $slug = $id; |
480 | 480 | } |
481 | 481 | |
@@ -569,15 +569,15 @@ discard block |
||
569 | 569 | * @param boolean $custom Should we process the custom entry slug? |
570 | 570 | */ |
571 | 571 | $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
572 | - if( $custom ) { |
|
572 | + if ( $custom ) { |
|
573 | 573 | // create the gravityview_unique_id and save it |
574 | 574 | |
575 | 575 | // Get the entry hash |
576 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
576 | + $hash = self::get_custom_entry_slug( $entry[ 'id' ], $entry ); |
|
577 | 577 | |
578 | - gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry['id'], 'hash' => $hash ) ); |
|
578 | + gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry[ 'id' ], 'hash' => $hash ) ); |
|
579 | 579 | |
580 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) ); |
|
580 | + gform_update_meta( $entry[ 'id' ], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) ); |
|
581 | 581 | |
582 | 582 | } |
583 | 583 | } |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | |
597 | 597 | if ( ! empty( $entry ) && ! is_array( $entry ) ) { |
598 | 598 | $entry = GVCommon::get_entry( $entry ); |
599 | - } else if( empty( $entry ) ) { |
|
599 | + } else if ( empty( $entry ) ) { |
|
600 | 600 | // @deprecated path |
601 | 601 | $entry = GravityView_frontend::getInstance()->getEntry(); |
602 | 602 | } |
@@ -616,9 +616,9 @@ discard block |
||
616 | 616 | |
617 | 617 | $query_arg_name = \GV\Entry::get_endpoint_name(); |
618 | 618 | |
619 | - $entry_slug = self::get_entry_slug( $entry['id'], $entry ); |
|
619 | + $entry_slug = self::get_entry_slug( $entry[ 'id' ], $entry ); |
|
620 | 620 | |
621 | - if ( get_option('permalink_structure') && !is_preview() ) { |
|
621 | + if ( get_option( 'permalink_structure' ) && ! is_preview() ) { |
|
622 | 622 | |
623 | 623 | $args = array(); |
624 | 624 | |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | */ |
629 | 629 | $link_parts = explode( '?', $directory_link ); |
630 | 630 | |
631 | - $query = !empty( $link_parts[1] ) ? '?'.$link_parts[1] : ''; |
|
631 | + $query = ! empty( $link_parts[ 1 ] ) ? '?' . $link_parts[ 1 ] : ''; |
|
632 | 632 | |
633 | - $directory_link = trailingslashit( $link_parts[0] ) . $query_arg_name . '/'. $entry_slug .'/' . $query; |
|
633 | + $directory_link = trailingslashit( $link_parts[ 0 ] ) . $query_arg_name . '/' . $entry_slug . '/' . $query; |
|
634 | 634 | |
635 | 635 | } else { |
636 | 636 | |
@@ -642,22 +642,22 @@ discard block |
||
642 | 642 | */ |
643 | 643 | if ( $add_directory_args ) { |
644 | 644 | |
645 | - if ( ! empty( $_GET['pagenum'] ) ) { |
|
646 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
645 | + if ( ! empty( $_GET[ 'pagenum' ] ) ) { |
|
646 | + $args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] ); |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | /** |
650 | 650 | * @since 1.7 |
651 | 651 | */ |
652 | 652 | if ( $sort = \GV\Utils::_GET( 'sort' ) ) { |
653 | - $args['sort'] = $sort; |
|
654 | - $args['dir'] = \GV\Utils::_GET( 'dir' ); |
|
653 | + $args[ 'sort' ] = $sort; |
|
654 | + $args[ 'dir' ] = \GV\Utils::_GET( 'dir' ); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | } |
658 | 658 | |
659 | 659 | if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
660 | - $args['gvid'] = gravityview_get_view_id(); |
|
660 | + $args[ 'gvid' ] = gravityview_get_view_id(); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | return add_query_arg( $args, $directory_link ); |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | } |
679 | 679 | |
680 | 680 | function gv_class( $field, $form = NULL, $entry = array() ) { |
681 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
681 | + return GravityView_API::field_class( $field, $form, $entry ); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | /** |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | $view_id = 0; |
702 | 702 | if ( $context->view ) { |
703 | 703 | $view_id = $context->view->ID; |
704 | - if( $context->view->settings->get( 'hide_until_searched' ) ) { |
|
704 | + if ( $context->view->settings->get( 'hide_until_searched' ) ) { |
|
705 | 705 | $hide_until_searched = ( empty( $context->entry ) && ! $context->request->is_search() ); |
706 | 706 | } |
707 | 707 | } |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | $default_css_class .= ' gv-container-no-results'; |
730 | 730 | } |
731 | 731 | |
732 | - $css_class = trim( $passed_css_class . ' '. $default_css_class ); |
|
732 | + $css_class = trim( $passed_css_class . ' ' . $default_css_class ); |
|
733 | 733 | |
734 | 734 | /** |
735 | 735 | * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | |
757 | 757 | $value = GravityView_API::field_value( $entry, $field ); |
758 | 758 | |
759 | - if( $value === '' ) { |
|
759 | + if ( $value === '' ) { |
|
760 | 760 | /** |
761 | 761 | * @filter `gravityview_empty_value` What to display when a field is empty |
762 | 762 | * @param string $value (empty string) |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | */ |
870 | 870 | function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
871 | 871 | |
872 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
872 | + if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
873 | 873 | |
874 | 874 | // For the complete field value as generated by Gravity Forms |
875 | 875 | return $display_value; |
@@ -903,16 +903,16 @@ discard block |
||
903 | 903 | $terms = explode( ', ', $value ); |
904 | 904 | } |
905 | 905 | |
906 | - foreach ($terms as $term_name ) { |
|
906 | + foreach ( $terms as $term_name ) { |
|
907 | 907 | |
908 | 908 | // If we're processing a category, |
909 | - if( $taxonomy === 'category' ) { |
|
909 | + if ( $taxonomy === 'category' ) { |
|
910 | 910 | |
911 | 911 | // Use rgexplode to prevent errors if : doesn't exist |
912 | 912 | list( $term_name, $term_id ) = rgexplode( ':', $term_name, 2 ); |
913 | 913 | |
914 | 914 | // The explode was succesful; we have the category ID |
915 | - if( !empty( $term_id )) { |
|
915 | + if ( ! empty( $term_id ) ) { |
|
916 | 916 | $term = get_term_by( 'id', $term_id, $taxonomy ); |
917 | 917 | } else { |
918 | 918 | // We have to fall back to the name |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | } |
926 | 926 | |
927 | 927 | // There's still a tag/category here. |
928 | - if( $term ) { |
|
928 | + if ( $term ) { |
|
929 | 929 | |
930 | 930 | $term_link = get_term_link( $term, $taxonomy ); |
931 | 931 | |
@@ -934,11 +934,11 @@ discard block |
||
934 | 934 | continue; |
935 | 935 | } |
936 | 936 | |
937 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
937 | + $output[ ] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
938 | 938 | } |
939 | 939 | } |
940 | 940 | |
941 | - return implode(', ', $output ); |
|
941 | + return implode( ', ', $output ); |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | /** |
@@ -952,8 +952,8 @@ discard block |
||
952 | 952 | |
953 | 953 | $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
954 | 954 | |
955 | - if( empty( $link ) ) { |
|
956 | - return strip_tags( $output); |
|
955 | + if ( empty( $link ) ) { |
|
956 | + return strip_tags( $output ); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | return $output; |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | $fe = GravityView_frontend::getInstance(); |
973 | 973 | |
974 | 974 | // Solve problem when loading content via admin-ajax.php |
975 | - if( ! $fe->getGvOutputData() ) { |
|
975 | + if ( ! $fe->getGvOutputData() ) { |
|
976 | 976 | |
977 | 977 | gravityview()->log->debug( 'gv_output_data not defined; parsing content.' ); |
978 | 978 | |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | } |
981 | 981 | |
982 | 982 | // Make 100% sure that we're dealing with a properly called situation |
983 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
983 | + if ( ! is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
984 | 984 | |
985 | 985 | gravityview()->log->debug( 'gv_output_data not an object or get_view not callable.', array( 'data' => $fe->getGvOutputData() ) ); |
986 | 986 | |
@@ -1202,12 +1202,12 @@ discard block |
||
1202 | 1202 | function gravityview_get_files_array( $value, $gv_class = '', $context = null ) { |
1203 | 1203 | /** @define "GRAVITYVIEW_DIR" "../" */ |
1204 | 1204 | |
1205 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
1206 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
1205 | + if ( ! class_exists( 'GravityView_Field' ) ) { |
|
1206 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' ); |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1210 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field-fileupload.php' ); |
|
1209 | + if ( ! class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1210 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field-fileupload.php' ); |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | return GravityView_Field_FileUpload::get_files_array( $value, $gv_class, $context ); |
@@ -1306,21 +1306,21 @@ discard block |
||
1306 | 1306 | } else { |
1307 | 1307 | // @deprecated path |
1308 | 1308 | // Required fields. |
1309 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
1309 | + if ( empty( $args[ 'field' ] ) || empty( $args[ 'form' ] ) ) { |
|
1310 | 1310 | gravityview()->log->error( 'Field or form are empty.', array( 'data' => $args ) ); |
1311 | 1311 | return ''; |
1312 | 1312 | } |
1313 | 1313 | } |
1314 | 1314 | |
1315 | 1315 | if ( $context instanceof \GV\Template_Context ) { |
1316 | - $entry = $args['entry'] ? : ( $context->entry ? $context->entry->as_entry() : array() ); |
|
1317 | - $field = $args['field'] ? : ( $context->field ? $context->field->as_configuration() : array() ); |
|
1318 | - $form = $args['form'] ? : ( $context->view->form ? $context->view->form->form : array() ); |
|
1316 | + $entry = $args[ 'entry' ] ?: ( $context->entry ? $context->entry->as_entry() : array() ); |
|
1317 | + $field = $args[ 'field' ] ?: ( $context->field ? $context->field->as_configuration() : array() ); |
|
1318 | + $form = $args[ 'form' ] ?: ( $context->view->form ? $context->view->form->form : array() ); |
|
1319 | 1319 | } else { |
1320 | 1320 | // @deprecated path |
1321 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
1322 | - $field = $args['field']; |
|
1323 | - $form = $args['form']; |
|
1321 | + $entry = empty( $args[ 'entry' ] ) ? array() : $args[ 'entry' ]; |
|
1322 | + $field = $args[ 'field' ]; |
|
1323 | + $form = $args[ 'form' ]; |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | /** |
@@ -1338,40 +1338,40 @@ discard block |
||
1338 | 1338 | ); |
1339 | 1339 | |
1340 | 1340 | if ( $context instanceof \GV\Template_Context ) { |
1341 | - $placeholders['value'] = \GV\Utils::get( $args, 'value', '' ); |
|
1341 | + $placeholders[ 'value' ] = \GV\Utils::get( $args, 'value', '' ); |
|
1342 | 1342 | } else { |
1343 | 1343 | // @deprecated path |
1344 | - $placeholders['value'] = gv_value( $entry, $field ); |
|
1344 | + $placeholders[ 'value' ] = gv_value( $entry, $field ); |
|
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | // If the value is empty and we're hiding empty, return empty. |
1348 | - if ( $placeholders['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
1348 | + if ( $placeholders[ 'value' ] === '' && ! empty( $args[ 'hide_empty' ] ) ) { |
|
1349 | 1349 | return ''; |
1350 | 1350 | } |
1351 | 1351 | |
1352 | - if ( $placeholders['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
1353 | - $placeholders['value'] = wpautop( $placeholders['value'] ); |
|
1352 | + if ( $placeholders[ 'value' ] !== '' && ! empty( $args[ 'wpautop' ] ) ) { |
|
1353 | + $placeholders[ 'value' ] = wpautop( $placeholders[ 'value' ] ); |
|
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | // Get width setting, if exists |
1357 | - $placeholders['width'] = GravityView_API::field_width( $field ); |
|
1357 | + $placeholders[ 'width' ] = GravityView_API::field_width( $field ); |
|
1358 | 1358 | |
1359 | 1359 | // If replacing with CSS inline formatting, let's do it. |
1360 | - $placeholders['width:style'] = GravityView_API::field_width( $field, 'width:' . $placeholders['width'] . '%;' ); |
|
1360 | + $placeholders[ 'width:style' ] = GravityView_API::field_width( $field, 'width:' . $placeholders[ 'width' ] . '%;' ); |
|
1361 | 1361 | |
1362 | 1362 | // Grab the Class using `gv_class` |
1363 | - $placeholders['class'] = gv_class( $field, $form, $entry ); |
|
1364 | - $placeholders['field_id'] = GravityView_API::field_html_attr_id( $field, $form, $entry ); |
|
1363 | + $placeholders[ 'class' ] = gv_class( $field, $form, $entry ); |
|
1364 | + $placeholders[ 'field_id' ] = GravityView_API::field_html_attr_id( $field, $form, $entry ); |
|
1365 | 1365 | |
1366 | 1366 | if ( $context instanceof \GV\Template_Context ) { |
1367 | - $placeholders['label_value'] = \GV\Utils::get( $args, 'label' ); |
|
1367 | + $placeholders[ 'label_value' ] = \GV\Utils::get( $args, 'label' ); |
|
1368 | 1368 | } else { |
1369 | 1369 | // Default Label value |
1370 | - $placeholders['label_value'] = gv_label( $field, $entry ); |
|
1370 | + $placeholders[ 'label_value' ] = gv_label( $field, $entry ); |
|
1371 | 1371 | } |
1372 | 1372 | |
1373 | - if ( empty( $placeholders['label'] ) && ! empty( $placeholders['label_value'] ) ){ |
|
1374 | - $placeholders['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
1373 | + if ( empty( $placeholders[ 'label' ] ) && ! empty( $placeholders[ 'label_value' ] ) ) { |
|
1374 | + $placeholders[ 'label' ] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | /** |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | * @since 2.0 |
1383 | 1383 | * @param \GV\Template_Context $context The context. |
1384 | 1384 | */ |
1385 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args, $context ); |
|
1385 | + $html = apply_filters( 'gravityview/field_output/pre_html', $args[ 'markup' ], $args, $context ); |
|
1386 | 1386 | |
1387 | 1387 | /** |
1388 | 1388 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | foreach ( $placeholders as $tag => $value ) { |
1410 | 1410 | |
1411 | 1411 | // If the tag doesn't exist just skip it |
1412 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
1412 | + if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ) { |
|
1413 | 1413 | continue; |
1414 | 1414 | } |
1415 | 1415 |
@@ -72,13 +72,13 @@ |
||
72 | 72 | $hide_empty = apply_filters( 'gravityview/render/hide-empty-zone', Utils::get( $extras, 'hide_empty', $this->view->settings->get( 'hide_empty', false ) ), $context ); |
73 | 73 | |
74 | 74 | if ( is_numeric( $field->ID ) ) { |
75 | - $extras['field'] = $field->as_configuration(); |
|
75 | + $extras[ 'field' ] = $field->as_configuration(); |
|
76 | 76 | } |
77 | 77 | |
78 | - $extras['entry'] = $entry->as_entry(); |
|
79 | - $extras['hide_empty'] = $hide_empty; |
|
80 | - $extras['label'] = $label; |
|
81 | - $extras['value'] = $value; |
|
78 | + $extras[ 'entry' ] = $entry->as_entry(); |
|
79 | + $extras[ 'hide_empty' ] = $hide_empty; |
|
80 | + $extras[ 'label' ] = $label; |
|
81 | + $extras[ 'value' ] = $value; |
|
82 | 82 | |
83 | 83 | return \gravityview_field_output( $extras, $context ); |
84 | 84 | } |
@@ -57,13 +57,13 @@ |
||
57 | 57 | $hide_empty = apply_filters( 'gravityview/render/hide-empty-zone', Utils::get( $extras, 'hide_empty', $this->view->settings->get( 'hide_empty', false ) ), $context ); |
58 | 58 | |
59 | 59 | if ( is_numeric( $field->ID ) ) { |
60 | - $extras['field'] = $field->as_configuration(); |
|
60 | + $extras[ 'field' ] = $field->as_configuration(); |
|
61 | 61 | } |
62 | 62 | |
63 | - $extras['entry'] = $this->entry->as_entry(); |
|
64 | - $extras['hide_empty'] = $hide_empty; |
|
65 | - $extras['label'] = $label; |
|
66 | - $extras['value'] = $value; |
|
63 | + $extras[ 'entry' ] = $this->entry->as_entry(); |
|
64 | + $extras[ 'hide_empty' ] = $hide_empty; |
|
65 | + $extras[ 'label' ] = $label; |
|
66 | + $extras[ 'value' ] = $value; |
|
67 | 67 | |
68 | 68 | return \gravityview_field_output( $extras, $context ); |
69 | 69 | } |