@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | wp_nonce_field( 'gravityview_select_form', 'gravityview_select_form_nonce' ); |
12 | 12 | |
13 | 13 | //current value |
14 | -$current_form = (int) rgar( (array) $_GET, 'form_id', gravityview_get_form_id( $post->ID ) ); |
|
14 | +$current_form = (int)rgar( (array)$_GET, 'form_id', gravityview_get_form_id( $post->ID ) ); |
|
15 | 15 | |
16 | 16 | // If form is in trash or not existing, show error |
17 | 17 | GravityView_Admin::connected_form_warning( $current_form ); |
18 | 18 | |
19 | 19 | // check for available gravity forms |
20 | -$forms = gravityview_get_forms('any'); |
|
20 | +$forms = gravityview_get_forms( 'any' ); |
|
21 | 21 | ?> |
22 | 22 | <label for="gravityview_form_id" ><?php esc_html_e( 'Where would you like the data to come from for this View?', 'gravityview' ); ?></label> |
23 | 23 | |
@@ -28,24 +28,24 @@ discard block |
||
28 | 28 | ?> |
29 | 29 | <a class="button button-primary" href="#gv_start_fresh" title="<?php esc_attr_e( 'Start Fresh', 'gravityview' ); ?>"><?php esc_html_e( 'Start Fresh', 'gravityview' ); ?></a> |
30 | 30 | |
31 | - <?php if( !empty( $forms ) ) { ?> |
|
31 | + <?php if ( ! empty( $forms ) ) { ?> |
|
32 | 32 | <span> <?php esc_html_e( 'or use an existing form', 'gravityview' ); ?> </span> |
33 | 33 | <?php } |
34 | 34 | } |
35 | 35 | |
36 | 36 | // If there are no forms to select, show no forms. |
37 | - if( !empty( $forms ) ) { ?> |
|
37 | + if ( ! empty( $forms ) ) { ?> |
|
38 | 38 | <select name="gravityview_form_id" id="gravityview_form_id"> |
39 | 39 | <option value="" <?php selected( '', $current_form, true ); ?>>— <?php esc_html_e( 'list of forms', 'gravityview' ); ?> —</option> |
40 | - <?php foreach( $forms as $form ) { ?> |
|
41 | - <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option> |
|
40 | + <?php foreach ( $forms as $form ) { ?> |
|
41 | + <option value="<?php echo $form[ 'id' ]; ?>" <?php selected( $form[ 'id' ], $current_form, true ); ?>><?php echo esc_html( $form[ 'title' ] ); ?></option> |
|
42 | 42 | <?php } ?> |
43 | 43 | </select> |
44 | 44 | <?php } else { ?> |
45 | 45 | <select name="gravityview_form_id" id="gravityview_form_id" class="hidden"><option selected="selected" value=""></option></select> |
46 | 46 | <?php } ?> |
47 | 47 | |
48 | - <a class="button button-primary" <?php if( empty( $current_form ) ) { echo 'style="display:none;"'; } ?> id="gv_switch_view_button" href="#gv_switch_view" title="<?php esc_attr_e( 'Switch View', 'gravityview' ); ?>"><?php esc_html_e( 'Switch View Type', 'gravityview' ); ?></a> |
|
48 | + <a class="button button-primary" <?php if ( empty( $current_form ) ) { echo 'style="display:none;"'; } ?> id="gv_switch_view_button" href="#gv_switch_view" title="<?php esc_attr_e( 'Switch View', 'gravityview' ); ?>"><?php esc_html_e( 'Switch View Type', 'gravityview' ); ?></a> |
|
49 | 49 | </p> |
50 | 50 | |
51 | 51 | <?php // confirm dialog box ?> |
@@ -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 | } |
51 | 51 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public static function get_entry_status( $entry, $value_or_label = 'label' ) { |
64 | 64 | |
65 | - $entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry, true ); |
|
65 | + $entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry, true ); |
|
66 | 66 | |
67 | 67 | $status = gform_get_meta( $entry_id, self::meta_key ); |
68 | 68 | |
69 | 69 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
70 | 70 | |
71 | - if( 'value' === $value_or_label ) { |
|
71 | + if ( 'value' === $value_or_label ) { |
|
72 | 72 | return $status; |
73 | 73 | } |
74 | 74 | |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function ajax_update_approved() { |
95 | 95 | |
96 | - $form_id = intval( rgpost('form_id') ); |
|
96 | + $form_id = intval( rgpost( 'form_id' ) ); |
|
97 | 97 | |
98 | 98 | // We always want requests from the admin to allow entry IDs, but not from the frontend |
99 | 99 | // There's another nonce sent when approving entries in the admin that we check |
100 | 100 | $force_entry_ids = rgpost( 'admin_nonce' ) && wp_verify_nonce( rgpost( 'admin_nonce' ), 'gravityview_admin_entry_approval' ); |
101 | 101 | |
102 | - $entry_id = GVCommon::get_entry_id( rgpost('entry_slug'), $force_entry_ids ); |
|
102 | + $entry_id = GVCommon::get_entry_id( rgpost( 'entry_slug' ), $force_entry_ids ); |
|
103 | 103 | |
104 | - $approval_status = rgpost('approved'); |
|
104 | + $approval_status = rgpost( 'approved' ); |
|
105 | 105 | |
106 | - $nonce = rgpost('nonce'); |
|
106 | + $nonce = rgpost( 'nonce' ); |
|
107 | 107 | |
108 | 108 | // Valid status |
109 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
109 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
110 | 110 | |
111 | 111 | do_action( 'gravityview_log_error', __METHOD__ . ': Invalid approval status', $_POST ); |
112 | 112 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
139 | 139 | |
140 | - $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') ); |
|
140 | + $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) ); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param $form array Gravity Forms form object |
171 | 171 | */ |
172 | 172 | public function after_submission( $entry, $form ) { |
173 | - $this->after_update_entry_update_approved_meta( $form , $entry['id'] ); |
|
173 | + $this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] ); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
186 | 186 | |
187 | - $approved_column = self::get_approved_column( $form['id'] ); |
|
187 | + $approved_column = self::get_approved_column( $form[ 'id' ] ); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * If the form doesn't contain the approve field, don't assume anything. |
191 | 191 | */ |
192 | - if( empty( $approved_column ) ) { |
|
192 | + if ( empty( $approved_column ) ) { |
|
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $value = GravityView_Entry_Approval_Status::APPROVED; |
204 | 204 | } |
205 | 205 | |
206 | - self::update_approved_meta( $entry_id, $value, $form['id'] ); |
|
206 | + self::update_approved_meta( $entry_id, $value, $form[ 'id' ] ); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public static function update_bulk( $entries = array(), $approved, $form_id ) { |
223 | 223 | |
224 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
224 | + if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) { |
|
225 | 225 | do_action( 'gravityview_log_error', __METHOD__ . ' Entries were empty or malformed.', $entries ); |
226 | 226 | return NULL; |
227 | 227 | } |
228 | 228 | |
229 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
229 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
230 | 230 | do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
231 | 231 | return NULL; |
232 | 232 | } |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | $approved_column_id = self::get_approved_column( $form_id ); |
242 | 242 | |
243 | 243 | $success = true; |
244 | - foreach( $entries as $entry_id ) { |
|
244 | + foreach ( $entries as $entry_id ) { |
|
245 | 245 | $update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
246 | 246 | |
247 | - if( ! $update_success ) { |
|
247 | + if ( ! $update_success ) { |
|
248 | 248 | $success = false; |
249 | 249 | } |
250 | 250 | } |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public static function update_approved( $entry_id = 0, $approved = 2, $form_id = 0, $approvedcolumn = 0 ) { |
270 | 270 | |
271 | - if( !class_exists( 'GFAPI' ) ) { |
|
271 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
272 | 272 | do_action( 'gravityview_log_error', __METHOD__ . 'GFAPI does not exist' ); |
273 | 273 | return false; |
274 | 274 | } |
275 | 275 | |
276 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
276 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
277 | 277 | do_action( 'gravityview_log_error', __METHOD__ . ': Not a valid approval value.' ); |
278 | 278 | return false; |
279 | 279 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | // If the form has an Approve/Reject field, update that value |
291 | 291 | $result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn ); |
292 | 292 | |
293 | - if( is_wp_error( $result ) ) { |
|
293 | + if ( is_wp_error( $result ) ) { |
|
294 | 294 | do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - Entry approval not updated: %s', $result->get_error_message() ) ); |
295 | 295 | return false; |
296 | 296 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | // add note to entry if approval field updating worked or there was no approved field |
304 | 304 | // There's no validation for the meta |
305 | - if( true === $result ) { |
|
305 | + if ( true === $result ) { |
|
306 | 306 | |
307 | 307 | // Add an entry note |
308 | 308 | self::add_approval_status_updated_note( $entry_id, $approved ); |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | |
356 | 356 | $note_id = false; |
357 | 357 | |
358 | - if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
358 | + if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
359 | 359 | |
360 | 360 | $current_user = wp_get_current_user(); |
361 | 361 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | */ |
378 | 378 | private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) { |
379 | 379 | |
380 | - if( empty( $approvedcolumn ) ) { |
|
380 | + if ( empty( $approvedcolumn ) ) { |
|
381 | 381 | $approvedcolumn = self::get_approved_column( $form_id ); |
382 | 382 | } |
383 | 383 | |
@@ -400,12 +400,12 @@ discard block |
||
400 | 400 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
401 | 401 | |
402 | 402 | $new_value = ''; |
403 | - if( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
403 | + if ( GravityView_Entry_Approval_Status::APPROVED === $status ) { |
|
404 | 404 | $new_value = self::get_approved_column_input_label( $form_id, $approvedcolumn ); |
405 | 405 | } |
406 | 406 | |
407 | 407 | //update entry |
408 | - $entry["{$approvedcolumn}"] = $new_value; |
|
408 | + $entry[ "{$approvedcolumn}" ] = $new_value; |
|
409 | 409 | |
410 | 410 | /** |
411 | 411 | * Note: GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves |
@@ -434,12 +434,12 @@ discard block |
||
434 | 434 | // If the user has enabled a different value than the label (for some reason), use it. |
435 | 435 | // This is highly unlikely |
436 | 436 | if ( is_array( $field->choices ) && ! empty( $field->choices ) ) { |
437 | - return isset( $field->choices[0]['value'] ) ? $field->choices[0]['value'] : $field->choices[0]['text']; |
|
437 | + return isset( $field->choices[ 0 ][ 'value' ] ) ? $field->choices[ 0 ][ 'value' ] : $field->choices[ 0 ][ 'text' ]; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | // Otherwise, fall back on the inputs array |
441 | 441 | if ( is_array( $field->inputs ) && ! empty( $field->inputs ) ) { |
442 | - return $field->inputs[0]['label']; |
|
442 | + return $field->inputs[ 0 ][ 'label' ]; |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | return null; |
@@ -460,16 +460,16 @@ discard block |
||
460 | 460 | private static function update_approved_meta( $entry_id, $status, $form_id = 0 ) { |
461 | 461 | |
462 | 462 | if ( ! GravityView_Entry_Approval_Status::is_valid( $status ) ) { |
463 | - do_action('gravityview_log_error', __METHOD__ . ': $is_approved not valid value', $status ); |
|
463 | + do_action( 'gravityview_log_error', __METHOD__ . ': $is_approved not valid value', $status ); |
|
464 | 464 | return; |
465 | 465 | } |
466 | 466 | |
467 | 467 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
468 | 468 | |
469 | 469 | // update entry meta |
470 | - if( function_exists('gform_update_meta') ) { |
|
470 | + if ( function_exists( 'gform_update_meta' ) ) { |
|
471 | 471 | |
472 | - if( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) { |
|
472 | + if ( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) { |
|
473 | 473 | gform_delete_meta( $entry_id, self::meta_key ); |
474 | 474 | } else { |
475 | 475 | gform_update_meta( $entry_id, self::meta_key, $status, $form_id ); |
@@ -492,11 +492,11 @@ discard block |
||
492 | 492 | * @since 1.18 Added "unapproved" |
493 | 493 | * @param int $entry_id ID of the Gravity Forms entry |
494 | 494 | */ |
495 | - do_action( 'gravityview/approve_entries/' . $action , $entry_id ); |
|
495 | + do_action( 'gravityview/approve_entries/' . $action, $entry_id ); |
|
496 | 496 | |
497 | 497 | } else { |
498 | 498 | |
499 | - do_action('gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
499 | + do_action( 'gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
500 | 500 | |
501 | 501 | } |
502 | 502 | } |
@@ -511,11 +511,11 @@ discard block |
||
511 | 511 | */ |
512 | 512 | static public function get_approved_column( $form ) { |
513 | 513 | |
514 | - if( empty( $form ) ) { |
|
514 | + if ( empty( $form ) ) { |
|
515 | 515 | return null; |
516 | 516 | } |
517 | 517 | |
518 | - if( !is_array( $form ) ) { |
|
518 | + if ( ! is_array( $form ) ) { |
|
519 | 519 | $form = GVCommon::get_form( $form ); |
520 | 520 | } |
521 | 521 | |
@@ -525,22 +525,22 @@ discard block |
||
525 | 525 | * @var string $key |
526 | 526 | * @var GF_Field $field |
527 | 527 | */ |
528 | - foreach( $form['fields'] as $key => $field ) { |
|
528 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
529 | 529 | |
530 | 530 | $inputs = $field->get_entry_inputs(); |
531 | 531 | |
532 | - if( !empty( $field->gravityview_approved ) ) { |
|
533 | - if ( ! empty( $inputs ) && !empty( $inputs[0]['id'] ) ) { |
|
534 | - $approved_column_id = $inputs[0]['id']; |
|
532 | + if ( ! empty( $field->gravityview_approved ) ) { |
|
533 | + if ( ! empty( $inputs ) && ! empty( $inputs[ 0 ][ 'id' ] ) ) { |
|
534 | + $approved_column_id = $inputs[ 0 ][ 'id' ]; |
|
535 | 535 | break; |
536 | 536 | } |
537 | 537 | } |
538 | 538 | |
539 | 539 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
540 | - if( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
540 | + if ( 'checkbox' === $field->type && ! empty( $inputs ) ) { |
|
541 | 541 | foreach ( $inputs as $input ) { |
542 | - if ( 'approved' === strtolower( $input['label'] ) ) { |
|
543 | - $approved_column_id = $input['id']; |
|
542 | + if ( 'approved' === strtolower( $input[ 'label' ] ) ) { |
|
543 | + $approved_column_id = $input[ 'id' ]; |
|
544 | 544 | break; |
545 | 545 | } |
546 | 546 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @param int $entry_id ID of the Gravity Forms entry |
372 | 372 | * @param string $status String whether entry is approved or not. `0` for not approved, `Approved` for approved. |
373 | 373 | * @param int $form_id ID of the form of the entry being updated. Improves query performance. |
374 | - * @param string $approvedcolumn Gravity Forms Field ID |
|
374 | + * @param integer $approvedcolumn Gravity Forms Field ID |
|
375 | 375 | * |
376 | 376 | * @return true|WP_Error |
377 | 377 | */ |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * |
425 | 425 | * @since 1.19 |
426 | 426 | * |
427 | - * @param array|int $form Form ID or form array |
|
427 | + * @param integer $form Form ID or form array |
|
428 | 428 | * @param string $approved_column Approved column field ID |
429 | 429 | * |
430 | 430 | * @return string|null |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return void |
97 | 97 | */ |
98 | 98 | public static function connected_form_warning( $form_id = 0 ) { |
99 | - global $pagenow; |
|
99 | + global $pagenow; |
|
100 | 100 | |
101 | 101 | if ( ! is_int( $form_id ) || $pagenow === 'post-new.php' ) { |
102 | 102 | return; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
243 | 243 | 8 => __( 'View submitted.', 'gravityview' ), |
244 | 244 | 9 => sprintf( |
245 | - /* translators: Date and time the View is scheduled to be published */ |
|
245 | + /* translators: Date and time the View is scheduled to be published */ |
|
246 | 246 | __( 'View scheduled for: %1$s.', 'gravityview' ), |
247 | 247 | // translators: Publish box date format, see http://php.net/date |
248 | 248 | date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
@@ -299,7 +299,6 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @deprecated since 1.12 |
301 | 301 | * @see GravityView_Compatibility::get_plugin_status() |
302 | - |
|
303 | 302 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
304 | 303 | */ |
305 | 304 | static function get_plugin_status( $location = '' ) { |
@@ -4,10 +4,10 @@ discard block |
||
4 | 4 | |
5 | 5 | function __construct() { |
6 | 6 | |
7 | - if( ! is_admin() ) { return; } |
|
7 | + if ( ! is_admin() ) { return; } |
|
8 | 8 | |
9 | 9 | // If Gravity Forms isn't active or compatibile, stop loading |
10 | - if( false === GravityView_Compatibility::is_valid() ) { |
|
10 | + if ( false === GravityView_Compatibility::is_valid() ) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-migrate.php' ); |
26 | 26 | |
27 | 27 | // Don't load tooltips if on Gravity Forms, otherwise it overrides translations |
28 | - if( class_exists( 'GFCommon' ) && class_exists( 'GFForms' ) && !GFForms::is_gravity_page() ) { |
|
28 | + if ( class_exists( 'GFCommon' ) && class_exists( 'GFForms' ) && ! GFForms::is_gravity_page() ) { |
|
29 | 29 | require_once( GFCommon::get_base_path() . '/tooltips.php' ); |
30 | 30 | } |
31 | 31 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) ); |
54 | 54 | add_filter( 'bulk_post_updated_messages', array( $this, 'post_updated_messages' ) ); |
55 | 55 | |
56 | - add_filter( 'plugin_action_links_'. plugin_basename( GRAVITYVIEW_FILE ) , array( $this, 'plugin_action_links' ) ); |
|
56 | + add_filter( 'plugin_action_links_' . plugin_basename( GRAVITYVIEW_FILE ), array( $this, 'plugin_action_links' ) ); |
|
57 | 57 | |
58 | 58 | add_action( 'plugins_loaded', array( $this, 'backend_actions' ), 100 ); |
59 | 59 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public static function no_views_text() { |
70 | 70 | |
71 | - if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { |
|
71 | + if ( isset( $_REQUEST[ 'post_status' ] ) && 'trash' === $_REQUEST[ 'post_status' ] ) { |
|
72 | 72 | return __( 'No Views found in Trash', 'gravityview' ); |
73 | - } elseif( ! empty( $_GET['s'] ) ) { |
|
73 | + } elseif ( ! empty( $_GET[ 's' ] ) ) { |
|
74 | 74 | return __( 'No Views found.', 'gravityview' ); |
75 | 75 | } |
76 | 76 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $error .= ' ' . esc_html__( 'or select another form.', 'gravityview' ); |
115 | 115 | } |
116 | 116 | |
117 | - if( $error ) { |
|
117 | + if ( $error ) { |
|
118 | 118 | ?> |
119 | 119 | <div class="wp-dialog notice-warning inline error wp-clearfix"> |
120 | 120 | <?php echo gravityview_get_floaty(); ?> |
@@ -133,22 +133,22 @@ discard block |
||
133 | 133 | public function backend_actions() { |
134 | 134 | |
135 | 135 | /** @define "GRAVITYVIEW_DIR" "../" */ |
136 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.field.type.php' ); |
|
137 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.render.settings.php' ); |
|
138 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class-gravityview-admin-view-item.php' ); |
|
139 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class-gravityview-admin-view-field.php' ); |
|
140 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class-gravityview-admin-view-widget.php' ); |
|
141 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-views.php' ); |
|
142 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-welcome.php' ); |
|
143 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-add-shortcode.php' ); |
|
144 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
136 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class.field.type.php' ); |
|
137 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class.render.settings.php' ); |
|
138 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-admin-view-item.php' ); |
|
139 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-admin-view-field.php' ); |
|
140 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-admin-view-widget.php' ); |
|
141 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-views.php' ); |
|
142 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-welcome.php' ); |
|
143 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-add-shortcode.php' ); |
|
144 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @action `gravityview_include_backend_actions` Triggered after all GravityView admin files are loaded |
148 | 148 | * |
149 | 149 | * Nice place to insert extensions' backend stuff |
150 | 150 | */ |
151 | - do_action('gravityview_include_backend_actions'); |
|
151 | + do_action( 'gravityview_include_backend_actions' ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | |
165 | 165 | $actions = array(); |
166 | 166 | |
167 | - if( GVCommon::has_cap( 'gravityview_view_settings' ) ) { |
|
168 | - $actions[] = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ), esc_html__( 'Settings', 'gravityview' ) ); |
|
167 | + if ( GVCommon::has_cap( 'gravityview_view_settings' ) ) { |
|
168 | + $actions[ ] = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ), esc_html__( 'Settings', 'gravityview' ) ); |
|
169 | 169 | } |
170 | 170 | |
171 | - if( GVCommon::has_cap( 'gravityview_support_port' ) ) { |
|
172 | - $actions[] = '<a href="http://docs.gravityview.co">' . esc_html__( 'Support', 'gravityview' ) . '</a>'; |
|
171 | + if ( GVCommon::has_cap( 'gravityview_support_port' ) ) { |
|
172 | + $actions[ ] = '<a href="http://docs.gravityview.co">' . esc_html__( 'Support', 'gravityview' ) . '</a>'; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | return array_merge( $actions, $links ); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | // By default, there will only be one item being modified. |
198 | 198 | // When in the `bulk_post_updated_messages` filter, there will be passed a number |
199 | 199 | // of modified items that will override this array. |
200 | - $bulk_counts = is_null( $bulk_counts ) ? array( 'updated' => 1 , 'locked' => 1 , 'deleted' => 1 , 'trashed' => 1, 'untrashed' => 1 ) : $bulk_counts; |
|
200 | + $bulk_counts = is_null( $bulk_counts ) ? array( 'updated' => 1, 'locked' => 1, 'deleted' => 1, 'trashed' => 1, 'untrashed' => 1 ) : $bulk_counts; |
|
201 | 201 | |
202 | 202 | // If we're starting fresh, a new form was created. |
203 | 203 | // We should let the user know this is the case. |
@@ -205,60 +205,60 @@ discard block |
||
205 | 205 | |
206 | 206 | $new_form_text = ''; |
207 | 207 | |
208 | - if( !empty( $start_fresh ) ) { |
|
208 | + if ( ! empty( $start_fresh ) ) { |
|
209 | 209 | |
210 | 210 | // Get the form that was created |
211 | 211 | $connected_form = gravityview_get_form_id( $post_id ); |
212 | 212 | |
213 | - if( !empty( $connected_form ) ) { |
|
213 | + if ( ! empty( $connected_form ) ) { |
|
214 | 214 | $form = gravityview_get_form( $connected_form ); |
215 | - $form_name = esc_attr( $form['title'] ); |
|
215 | + $form_name = esc_attr( $form[ 'title' ] ); |
|
216 | 216 | $image = self::get_floaty(); |
217 | - $new_form_text .= '<h3>'.$image.sprintf( __( 'A new form was created for this View: "%s"', 'gravityview' ), $form_name ).'</h3>'; |
|
218 | - $new_form_text .= sprintf( __( '%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
217 | + $new_form_text .= '<h3>' . $image . sprintf( __( 'A new form was created for this View: "%s"', 'gravityview' ), $form_name ) . '</h3>'; |
|
218 | + $new_form_text .= sprintf( __( '%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
219 | 219 | |
220 | 220 | You can %sedit the form%s in Gravity Forms and the updated fields will be available here. Don’t forget to %scustomize the form settings%s. |
221 | - ', 'gravityview' ), '<strong>', '</strong>', '<a href="'.site_url( '?gf_page=preview&id='.$connected_form ).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&id='.$connected_form ).'">', '</a>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&view=settings&id='.$connected_form ).'">', '</a>'); |
|
221 | + ', 'gravityview' ), '<strong>', '</strong>', '<a href="' . site_url( '?gf_page=preview&id=' . $connected_form ) . '">', '</a>', '<code>[gravityform id="' . $connected_form . '" name="' . $form_name . '"]</code>', '<a href="' . admin_url( 'admin.php?page=gf_edit_forms&id=' . $connected_form ) . '">', '</a>', '<a href="' . admin_url( 'admin.php?page=gf_edit_forms&view=settings&id=' . $connected_form ) . '">', '</a>' ); |
|
222 | 222 | $new_form_text = wpautop( $new_form_text ); |
223 | 223 | |
224 | 224 | delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | - $messages['gravityview'] = array( |
|
228 | + $messages[ 'gravityview' ] = array( |
|
229 | 229 | 0 => '', // Unused. Messages start at index 1. |
230 | 230 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
231 | - 1 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
231 | + 1 => sprintf( __( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ), |
|
232 | 232 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
233 | - 2 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
233 | + 2 => sprintf( __( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ), |
|
234 | 234 | 3 => __( 'View deleted.', 'gravityview' ), |
235 | 235 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
236 | - 4 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
236 | + 4 => sprintf( __( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ), |
|
237 | 237 | /* translators: %s: date and time of the revision */ |
238 | - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'View restored to revision from %s', 'gravityview' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
238 | + 5 => isset( $_GET[ 'revision' ] ) ? sprintf( __( 'View restored to revision from %s', 'gravityview' ), wp_post_revision_title( (int)$_GET[ 'revision' ], false ) ) : false, |
|
239 | 239 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
240 | - 6 => sprintf(__( 'View published. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
240 | + 6 => sprintf( __( 'View published. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ) . $new_form_text, |
|
241 | 241 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
242 | - 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
242 | + 7 => sprintf( __( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ) . $new_form_text, |
|
243 | 243 | 8 => __( 'View submitted.', 'gravityview' ), |
244 | 244 | 9 => sprintf( |
245 | 245 | /* translators: Date and time the View is scheduled to be published */ |
246 | 246 | __( 'View scheduled for: %1$s.', 'gravityview' ), |
247 | 247 | // translators: Publish box date format, see http://php.net/date |
248 | - date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
|
248 | + date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
|
249 | 249 | ) . $new_form_text, |
250 | 250 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
251 | - 10 => sprintf(__( 'View draft updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
251 | + 10 => sprintf( __( 'View draft updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ) . $new_form_text, |
|
252 | 252 | |
253 | 253 | /** |
254 | 254 | * These apply to `bulk_post_updated_messages` |
255 | 255 | * @file wp-admin/edit.php |
256 | 256 | */ |
257 | - 'updated' => _n( '%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview' ), |
|
258 | - 'locked' => _n( '%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview' ), |
|
259 | - 'deleted' => _n( '%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview' ), |
|
260 | - 'trashed' => _n( '%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview' ), |
|
261 | - 'untrashed' => _n( '%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview' ), |
|
257 | + 'updated' => _n( '%s View updated.', '%s Views updated.', $bulk_counts[ 'updated' ], 'gravityview' ), |
|
258 | + 'locked' => _n( '%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts[ 'locked' ], 'gravityview' ), |
|
259 | + 'deleted' => _n( '%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts[ 'deleted' ], 'gravityview' ), |
|
260 | + 'trashed' => _n( '%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts[ 'trashed' ], 'gravityview' ), |
|
261 | + 'untrashed' => _n( '%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts[ 'untrashed' ], 'gravityview' ), |
|
262 | 262 | ); |
263 | 263 | |
264 | 264 | return $messages; |
@@ -318,29 +318,29 @@ discard block |
||
318 | 318 | static function is_admin_page( $hook = '', $page = NULL ) { |
319 | 319 | global $current_screen, $plugin_page, $pagenow, $post; |
320 | 320 | |
321 | - if( ! is_admin() ) { return false; } |
|
321 | + if ( ! is_admin() ) { return false; } |
|
322 | 322 | |
323 | 323 | $is_page = false; |
324 | 324 | |
325 | - $is_gv_screen = (!empty($current_screen) && isset($current_screen->post_type) && $current_screen->post_type === 'gravityview'); |
|
325 | + $is_gv_screen = ( ! empty( $current_screen ) && isset( $current_screen->post_type ) && $current_screen->post_type === 'gravityview' ); |
|
326 | 326 | |
327 | - $is_gv_post_type_get = (isset($_GET['post_type']) && $_GET['post_type'] === 'gravityview'); |
|
327 | + $is_gv_post_type_get = ( isset( $_GET[ 'post_type' ] ) && $_GET[ 'post_type' ] === 'gravityview' ); |
|
328 | 328 | |
329 | - $is_gv_settings_get = isset( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings'; |
|
329 | + $is_gv_settings_get = isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] === 'gravityview_settings'; |
|
330 | 330 | |
331 | - if( empty( $post ) && $pagenow === 'post.php' && !empty( $_GET['post'] ) ) { |
|
332 | - $gv_post = get_post( intval( $_GET['post'] ) ); |
|
333 | - $is_gv_post_type = (!empty($gv_post) && !empty($gv_post->post_type) && $gv_post->post_type === 'gravityview'); |
|
331 | + if ( empty( $post ) && $pagenow === 'post.php' && ! empty( $_GET[ 'post' ] ) ) { |
|
332 | + $gv_post = get_post( intval( $_GET[ 'post' ] ) ); |
|
333 | + $is_gv_post_type = ( ! empty( $gv_post ) && ! empty( $gv_post->post_type ) && $gv_post->post_type === 'gravityview' ); |
|
334 | 334 | } else { |
335 | - $is_gv_post_type = (!empty($post) && !empty($post->post_type) && $post->post_type === 'gravityview'); |
|
335 | + $is_gv_post_type = ( ! empty( $post ) && ! empty( $post->post_type ) && $post->post_type === 'gravityview' ); |
|
336 | 336 | } |
337 | 337 | |
338 | - if( $is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get ) { |
|
338 | + if ( $is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get ) { |
|
339 | 339 | |
340 | 340 | // $_GET `post_type` variable |
341 | - if(in_array($pagenow, array( 'post.php' , 'post-new.php' )) ) { |
|
341 | + if ( in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) { |
|
342 | 342 | $is_page = 'single'; |
343 | - } else if ( in_array( $plugin_page, array( 'gravityview_settings', 'gravityview_page_gravityview_settings' ) ) || ( !empty( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings' ) ) { |
|
343 | + } else if ( in_array( $plugin_page, array( 'gravityview_settings', 'gravityview_page_gravityview_settings' ) ) || ( ! empty( $_GET[ 'page' ] ) && $_GET[ 'page' ] === 'gravityview_settings' ) ) { |
|
344 | 344 | $is_page = 'settings'; |
345 | 345 | } else { |
346 | 346 | $is_page = 'views'; |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $is_page = apply_filters( 'gravityview_is_admin_page', $is_page, $hook ); |
356 | 356 | |
357 | 357 | // If the current page is the same as the compared page |
358 | - if( !empty( $page ) ) { |
|
358 | + if ( ! empty( $page ) ) { |
|
359 | 359 | return $is_page === $page; |
360 | 360 | } |
361 | 361 | |
@@ -376,6 +376,6 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @return bool|string|void If `false`, not a GravityView page. `true` if $page is passed and is the same as current page. Otherwise, the name of the page (`single`, `settings`, or `views`) |
378 | 378 | */ |
379 | -function gravityview_is_admin_page($hook = '', $page = NULL) { |
|
379 | +function gravityview_is_admin_page( $hook = '', $page = NULL ) { |
|
380 | 380 | return GravityView_Admin::is_admin_page( $hook, $page ); |
381 | 381 | } |
@@ -11,35 +11,35 @@ discard block |
||
11 | 11 | |
12 | 12 | function __construct() { |
13 | 13 | |
14 | - $this->widget_description = __('Links to multiple pages of results.', 'gravityview' ); |
|
14 | + $this->widget_description = __( 'Links to multiple pages of results.', 'gravityview' ); |
|
15 | 15 | |
16 | 16 | $default_values = array( 'header' => 1, 'footer' => 1 ); |
17 | 17 | $settings = array( 'show_all' => array( |
18 | 18 | 'type' => 'checkbox', |
19 | 19 | 'label' => __( 'Show each page number', 'gravityview' ), |
20 | - 'desc' => __('Show every page number instead of summary (eg: 1 2 3 ... 8 »)', 'gravityview'), |
|
20 | + 'desc' => __( 'Show every page number instead of summary (eg: 1 2 3 ... 8 »)', 'gravityview' ), |
|
21 | 21 | 'value' => false |
22 | - )); |
|
23 | - parent::__construct( __( 'Page Links', 'gravityview' ) , 'page_links', $default_values, $settings ); |
|
22 | + ) ); |
|
23 | + parent::__construct( __( 'Page Links', 'gravityview' ), 'page_links', $default_values, $settings ); |
|
24 | 24 | |
25 | 25 | } |
26 | 26 | |
27 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
27 | + public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
28 | 28 | $gravityview_view = GravityView_View::getInstance(); |
29 | 29 | |
30 | - if( !$this->pre_render_frontend() ) { |
|
30 | + if ( ! $this->pre_render_frontend() ) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
34 | 34 | $atts = shortcode_atts( array( |
35 | 35 | 'page_size' => rgar( $gravityview_view->paging, 'page_size' ), |
36 | 36 | 'total' => $gravityview_view->total_entries, |
37 | - 'show_all' => !empty( $this->settings['show_all']['default'] ), |
|
38 | - 'current' => (int) rgar( $_GET, 'pagenum', 1 ), |
|
37 | + 'show_all' => ! empty( $this->settings[ 'show_all' ][ 'default' ] ), |
|
38 | + 'current' => (int)rgar( $_GET, 'pagenum', 1 ), |
|
39 | 39 | ), $widget_args, 'gravityview_widget_page_links' ); |
40 | 40 | |
41 | 41 | $page_link_args = array( |
42 | - 'base' => add_query_arg('pagenum','%#%', gv_directory_link() ), |
|
42 | + 'base' => add_query_arg( 'pagenum', '%#%', gv_directory_link() ), |
|
43 | 43 | 'format' => '&pagenum=%#%', |
44 | 44 | 'add_args' => array(), // |
45 | 45 | 'prev_text' => '«', |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | 'type' => 'list', |
48 | 48 | 'end_size' => 1, |
49 | 49 | 'mid_size' => 2, |
50 | - 'total' => empty( $atts['page_size'] ) ? 0 : ceil( $atts['total'] / $atts['page_size'] ), |
|
51 | - 'current' => $atts['current'], |
|
52 | - 'show_all' => !empty( $atts['show_all'] ), // to be available at backoffice |
|
50 | + 'total' => empty( $atts[ 'page_size' ] ) ? 0 : ceil( $atts[ 'total' ] / $atts[ 'page_size' ] ), |
|
51 | + 'current' => $atts[ 'current' ], |
|
52 | + 'show_all' => ! empty( $atts[ 'show_all' ] ), // to be available at backoffice |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | /** |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | * @since 1.1.4 |
58 | 58 | * @param array $page_link_args Array of arguments for the `paginate_links()` function. [Read more about `paginate_links()`](http://developer.wordpress.org/reference/functions/paginate_links/) |
59 | 59 | */ |
60 | - $page_link_args = apply_filters('gravityview_page_links_args', $page_link_args ); |
|
60 | + $page_link_args = apply_filters( 'gravityview_page_links_args', $page_link_args ); |
|
61 | 61 | |
62 | 62 | $page_links = paginate_links( $page_link_args ); |
63 | 63 | |
64 | - if( !empty( $page_links )) { |
|
65 | - $class = !empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
64 | + if ( ! empty( $page_links ) ) { |
|
65 | + $class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
66 | 66 | $class = gravityview_sanitize_html_class( 'gv-widget-page-links ' . $class ); |
67 | - echo '<div class="'.$class.'">'. $page_links .'</div>'; |
|
67 | + echo '<div class="' . $class . '">' . $page_links . '</div>'; |
|
68 | 68 | } else { |
69 | 69 | do_action( 'gravityview_log_debug', 'GravityView_Widget_Page_Links[render_frontend] No page links; paginate_links() returned empty response.' ); |
70 | 70 | } |
@@ -102,7 +102,7 @@ |
||
102 | 102 | $field_data = array( |
103 | 103 | 'label' => rgar( $edit_field, 'custom_label' ), |
104 | 104 | 'customLabel' => rgar( $edit_field, 'custom_label' ), |
105 | - 'content' => rgar( $edit_field, 'content' ), |
|
105 | + 'content' => rgar( $edit_field, 'content' ), |
|
106 | 106 | ); |
107 | 107 | |
108 | 108 | // Replace merge tags in the content |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
42 | 42 | |
43 | - unset ( $field_options['search_filter'], $field_options['show_as_link'] ); |
|
43 | + unset ( $field_options[ 'search_filter' ], $field_options[ 'show_as_link' ] ); |
|
44 | 44 | |
45 | 45 | $new_fields = array( |
46 | 46 | 'content' => array( |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | ), |
61 | 61 | ); |
62 | 62 | |
63 | - if( 'edit' === $context ) { |
|
64 | - unset( $field_options['custom_label'], $field_options['show_label'], $field_options['allow_edit_cap'], $new_fields['wpautop'] ); |
|
63 | + if ( 'edit' === $context ) { |
|
64 | + unset( $field_options[ 'custom_label' ], $field_options[ 'show_label' ], $field_options[ 'allow_edit_cap' ], $new_fields[ 'wpautop' ] ); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | return $new_fields + $field_options; |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | |
96 | 96 | // Loop through the configured Edit Entry fields and add Custom Content fields if there are any |
97 | 97 | // TODO: Make this available to other custom GV field types |
98 | - foreach ( (array) $edit_fields as $edit_field ) { |
|
98 | + foreach ( (array)$edit_fields as $edit_field ) { |
|
99 | 99 | |
100 | - if( 'custom' === rgar( $edit_field, 'id') ) { |
|
100 | + if ( 'custom' === rgar( $edit_field, 'id' ) ) { |
|
101 | 101 | |
102 | 102 | $field_data = array( |
103 | 103 | 'label' => rgar( $edit_field, 'custom_label' ), |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $field_data[ $key ] = GravityView_Merge_Tags::replace_variables( $field_datum, $form, $entry, false, false ); |
111 | 111 | } |
112 | 112 | |
113 | - $field_data['cssClass'] = rgar( $edit_field, 'custom_class' ); |
|
113 | + $field_data[ 'cssClass' ] = rgar( $edit_field, 'custom_class' ); |
|
114 | 114 | |
115 | - $new_fields[] = new GF_Field_HTML( $field_data ); |
|
115 | + $new_fields[ ] = new GF_Field_HTML( $field_data ); |
|
116 | 116 | |
117 | 117 | } else { |
118 | - if( isset( $fields[ $i ] ) ) { |
|
119 | - $new_fields[] = $fields[ $i ]; |
|
118 | + if ( isset( $fields[ $i ] ) ) { |
|
119 | + $new_fields[ ] = $fields[ $i ]; |
|
120 | 120 | } |
121 | 121 | $i++; |
122 | 122 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * Return array of fields' id and label, for a given Form ID |
218 | 218 | * |
219 | 219 | * @access public |
220 | - * @param string|array $form_id (default: '') or $form object |
|
220 | + * @param string|array $form (default: '') or $form object |
|
221 | 221 | * @param bool $add_default_properties |
222 | 222 | * @param bool $include_parent_field |
223 | 223 | * @return array |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | * |
883 | 883 | * @param array $form Gravity Forms form array |
884 | 884 | * @param string $field_id ID of the field. If an input, full input ID (like `1.3`) |
885 | - * @param string|array $field_value Raw value of the field. |
|
885 | + * @param string $field_value Raw value of the field. |
|
886 | 886 | * @return string |
887 | 887 | */ |
888 | 888 | public static function get_field_label( $form = array(), $field_id = '', $field_value = '' ) { |
@@ -1514,6 +1514,7 @@ discard block |
||
1514 | 1514 | * @param string $notice text/HTML of notice |
1515 | 1515 | * @param string $class CSS class for notice (`updated` or `error`) |
1516 | 1516 | * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
1517 | + * @param integer $object_id |
|
1517 | 1518 | * |
1518 | 1519 | * @return string |
1519 | 1520 | */ |
@@ -1557,9 +1558,9 @@ discard block |
||
1557 | 1558 | * @param string $message Message body (required) |
1558 | 1559 | * @param string $from_name Displayed name of the sender |
1559 | 1560 | * @param string $message_format If "html", sent text as `text/html`. Otherwise, `text/plain`. Default: "html". |
1560 | - * @param string|array $attachments Optional. Files to attach. {@see wp_mail()} for usage. Default: "". |
|
1561 | + * @param string $attachments Optional. Files to attach. {@see wp_mail()} for usage. Default: "". |
|
1561 | 1562 | * @param array|false $entry Gravity Forms entry array, related to the email. Default: false. |
1562 | - * @param array|false $notification Gravity Forms notification that triggered the email. {@see GFCommon::send_notification}. Default:false. |
|
1563 | + * @param boolean $notification Gravity Forms notification that triggered the email. {@see GFCommon::send_notification}. Default:false. |
|
1563 | 1564 | */ |
1564 | 1565 | public static function send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '', $entry = false, $notification = false ) { |
1565 | 1566 |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
309 | - * @hack |
|
310 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
311 | - */ |
|
309 | + * @hack |
|
310 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
311 | + */ |
|
312 | 312 | if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
313 | - continue; |
|
314 | - } |
|
313 | + continue; |
|
314 | + } |
|
315 | 315 | $fields["{$input['id']}"] = array( |
316 | 316 | 'label' => rgar( $input, 'label' ), |
317 | 317 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | } elseif ( 'delete' === GFForms::get( 'action' ) ) { |
489 | 489 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
490 | 490 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
491 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
491 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
492 | 492 | $criteria['context_view_id'] = null; |
493 | 493 | } |
494 | 494 | |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | ), |
1252 | 1252 | ); |
1253 | 1253 | |
1254 | - $fields = $date_created + $fields; |
|
1254 | + $fields = $date_created + $fields; |
|
1255 | 1255 | |
1256 | 1256 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1257 | 1257 | |
@@ -1263,13 +1263,13 @@ discard block |
||
1263 | 1263 | } |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - /** |
|
1267 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1268 | - * @since 1.12 |
|
1269 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
1270 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
1271 | - */ |
|
1272 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1266 | + /** |
|
1267 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1268 | + * @since 1.12 |
|
1269 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
1270 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
1271 | + */ |
|
1272 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1273 | 1273 | |
1274 | 1274 | return $fields; |
1275 | 1275 | } |
@@ -1561,26 +1561,26 @@ discard block |
||
1561 | 1561 | } |
1562 | 1562 | |
1563 | 1563 | |
1564 | - /** |
|
1565 | - * Display updated/error notice |
|
1566 | - * |
|
1567 | - * @since 1.19.2 Added $cap and $object_id parameters |
|
1568 | - * |
|
1569 | - * @param string $notice text/HTML of notice |
|
1570 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
1571 | - * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
1572 | - * |
|
1573 | - * @return string |
|
1574 | - */ |
|
1575 | - public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
1576 | - |
|
1577 | - // If $cap is defined, only show notice if user has capability |
|
1578 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1579 | - return ''; |
|
1580 | - } |
|
1581 | - |
|
1582 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1583 | - } |
|
1564 | + /** |
|
1565 | + * Display updated/error notice |
|
1566 | + * |
|
1567 | + * @since 1.19.2 Added $cap and $object_id parameters |
|
1568 | + * |
|
1569 | + * @param string $notice text/HTML of notice |
|
1570 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
1571 | + * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
1572 | + * |
|
1573 | + * @return string |
|
1574 | + */ |
|
1575 | + public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
1576 | + |
|
1577 | + // If $cap is defined, only show notice if user has capability |
|
1578 | + if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1579 | + return ''; |
|
1580 | + } |
|
1581 | + |
|
1582 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1583 | + } |
|
1584 | 1584 | |
1585 | 1585 | /** |
1586 | 1586 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | |
327 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
327 | + if( GFCommon::is_product_field( $field['type'] ) ) { |
|
328 | 328 | $has_product_fields = true; |
329 | 329 | } |
330 | 330 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | $fields = array(); |
386 | 386 | |
387 | - foreach ( $extra_fields as $key => $field ){ |
|
387 | + foreach ( $extra_fields as $key => $field ) { |
|
388 | 388 | if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
389 | 389 | $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
390 | 390 | } |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | $form = GFAPI::get_form( $form ); |
979 | 979 | } |
980 | 980 | |
981 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
981 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
982 | 982 | return GFFormsModel::get_field( $form, $field_id ); |
983 | 983 | } else { |
984 | 984 | return null; |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | $shortcodes = array(); |
1026 | 1026 | |
1027 | 1027 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
1028 | - if ( empty( $matches ) ){ |
|
1028 | + if ( empty( $matches ) ) { |
|
1029 | 1029 | return false; |
1030 | 1030 | } |
1031 | 1031 |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | |
127 | 127 | $form = false; |
128 | 128 | |
129 | - if( $entry ) { |
|
130 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
129 | + if ( $entry ) { |
|
130 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | return $form; |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | |
194 | 194 | $has_transaction_data = rgar( $entry, $meta, false ); |
195 | 195 | |
196 | - if( ! empty( $has_transaction_data ) ) { |
|
196 | + if ( ! empty( $has_transaction_data ) ) { |
|
197 | 197 | break; |
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | - return (bool) $has_transaction_data; |
|
201 | + return (bool)$has_transaction_data; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
238 | 238 | |
239 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
239 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
240 | 240 | |
241 | 241 | return $result; |
242 | 242 | } |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
255 | 255 | */ |
256 | - public static function get_forms( $active = true, $trash = false ) { |
|
256 | + public static function get_forms( $active = true, $trash = false ) { |
|
257 | 257 | $forms = array(); |
258 | 258 | if ( class_exists( 'GFAPI' ) ) { |
259 | - if( 'any' === $active ) { |
|
259 | + if ( 'any' === $active ) { |
|
260 | 260 | $active_forms = GFAPI::get_forms( true, $trash ); |
261 | 261 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
262 | 262 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | $has_post_fields = false; |
288 | 288 | |
289 | 289 | if ( $form ) { |
290 | - foreach ( $form['fields'] as $field ) { |
|
291 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
292 | - $fields["{$field['id']}"] = array( |
|
290 | + foreach ( $form[ 'fields' ] as $field ) { |
|
291 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
292 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
293 | 293 | 'label' => rgar( $field, 'label' ), |
294 | 294 | 'parent' => null, |
295 | 295 | 'type' => rgar( $field, 'type' ), |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | ); |
299 | 299 | } |
300 | 300 | |
301 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
302 | - foreach ( $field['inputs'] as $input ) { |
|
301 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
302 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
303 | 303 | |
304 | - if( ! empty( $input['isHidden'] ) ) { |
|
304 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
305 | 305 | continue; |
306 | 306 | } |
307 | 307 | |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | * @hack |
310 | 310 | * In case of email/email confirmation, the input for email has the same id as the parent field |
311 | 311 | */ |
312 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
312 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
313 | 313 | continue; |
314 | 314 | } |
315 | - $fields["{$input['id']}"] = array( |
|
315 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
316 | 316 | 'label' => rgar( $input, 'label' ), |
317 | 317 | 'customLabel' => rgar( $input, 'customLabel' ), |
318 | 318 | 'parent' => $field, |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | |
327 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
327 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
328 | 328 | $has_product_fields = true; |
329 | 329 | } |
330 | 330 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @since 1.7 |
339 | 339 | */ |
340 | 340 | if ( $has_post_fields ) { |
341 | - $fields['post_id'] = array( |
|
341 | + $fields[ 'post_id' ] = array( |
|
342 | 342 | 'label' => __( 'Post ID', 'gravityview' ), |
343 | 343 | 'type' => 'post_id', |
344 | 344 | ); |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | foreach ( $payment_fields as $payment_field ) { |
352 | 352 | |
353 | 353 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
354 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
354 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
355 | 355 | continue; |
356 | 356 | } |
357 | 357 | |
358 | - $fields["{$payment_field->name}"] = array( |
|
358 | + $fields[ "{$payment_field->name}" ] = array( |
|
359 | 359 | 'label' => $payment_field->label, |
360 | 360 | 'desc' => $payment_field->description, |
361 | 361 | 'type' => $payment_field->name, |
@@ -387,9 +387,9 @@ discard block |
||
387 | 387 | |
388 | 388 | $fields = array(); |
389 | 389 | |
390 | - foreach ( $extra_fields as $key => $field ){ |
|
391 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
392 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
390 | + foreach ( $extra_fields as $key => $field ) { |
|
391 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
392 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
@@ -429,32 +429,32 @@ discard block |
||
429 | 429 | 'search_criteria' => null, |
430 | 430 | 'sorting' => null, |
431 | 431 | 'paging' => null, |
432 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
432 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
433 | 433 | ); |
434 | 434 | |
435 | 435 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
436 | 436 | |
437 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
438 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
437 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
438 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
439 | 439 | |
440 | 440 | if ( ! is_array( $filter ) ) { |
441 | 441 | continue; |
442 | 442 | } |
443 | 443 | |
444 | 444 | // By default, we want searches to be wildcard for each field. |
445 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
445 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
446 | 446 | |
447 | 447 | /** |
448 | 448 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
449 | 449 | * @param string $operator Existing search operator |
450 | 450 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
451 | 451 | */ |
452 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
452 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | // don't send just the [mode] without any field filter. |
456 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
457 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
456 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
457 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | } |
@@ -465,36 +465,36 @@ discard block |
||
465 | 465 | * Prepare date formats to be in Gravity Forms DB format; |
466 | 466 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
467 | 467 | */ |
468 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
468 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
469 | 469 | |
470 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
470 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
471 | 471 | |
472 | 472 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
473 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
473 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
474 | 474 | |
475 | 475 | if ( $date ) { |
476 | 476 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
477 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
477 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
478 | 478 | } else { |
479 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
479 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
480 | 480 | |
481 | 481 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
482 | - unset( $criteria['search_criteria'][ $key ] ); |
|
482 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
487 | 487 | |
488 | 488 | // Calculate the context view id and send it to the advanced filter |
489 | - if( GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
490 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
489 | + if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
490 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
491 | 491 | } elseif ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
492 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
492 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
493 | 493 | } elseif ( 'delete' === GFForms::get( 'action' ) ) { |
494 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
495 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
494 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
495 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
496 | 496 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
497 | - $criteria['context_view_id'] = null; |
|
497 | + $criteria[ 'context_view_id' ] = null; |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /** |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * @param array $form_ids Forms to search |
504 | 504 | * @param int $view_id ID of the view being used to search |
505 | 505 | */ |
506 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
506 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
507 | 507 | |
508 | 508 | return (array)$criteria; |
509 | 509 | } |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | /** Reduce # of database calls */ |
534 | 534 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
535 | 535 | |
536 | - if ( ! empty( $criteria['cache'] ) ) { |
|
536 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
537 | 537 | |
538 | 538 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
539 | 539 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | |
542 | 542 | // Still update the total count when using cached results |
543 | 543 | if ( ! is_null( $total ) ) { |
544 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
544 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | $return = $entries; |
@@ -561,9 +561,9 @@ discard block |
||
561 | 561 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
562 | 562 | |
563 | 563 | // No entries returned from gravityview_before_get_entries |
564 | - if( is_null( $entries ) ) { |
|
564 | + if ( is_null( $entries ) ) { |
|
565 | 565 | |
566 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
566 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
567 | 567 | |
568 | 568 | if ( is_wp_error( $entries ) ) { |
569 | 569 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | } |
573 | 573 | } |
574 | 574 | |
575 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
575 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
576 | 576 | |
577 | 577 | // Cache results |
578 | 578 | $Cache->set( $entries, 'entries' ); |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | */ |
678 | 678 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
679 | 679 | |
680 | - if( $check_entry_display ) { |
|
680 | + if ( $check_entry_display ) { |
|
681 | 681 | // Is the entry allowed |
682 | 682 | $entry = self::check_entry_display( $entry ); |
683 | 683 | } |
@@ -710,12 +710,12 @@ discard block |
||
710 | 710 | |
711 | 711 | $value = false; |
712 | 712 | |
713 | - if( 'context' === $val1 ) { |
|
713 | + if ( 'context' === $val1 ) { |
|
714 | 714 | |
715 | 715 | $matching_contexts = array( $val2 ); |
716 | 716 | |
717 | 717 | // We allow for non-standard contexts. |
718 | - switch( $val2 ) { |
|
718 | + switch ( $val2 ) { |
|
719 | 719 | // Check for either single or edit |
720 | 720 | case 'singular': |
721 | 721 | $matching_contexts = array( 'single', 'edit' ); |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | return false; |
777 | 777 | } |
778 | 778 | |
779 | - if ( empty( $entry['form_id'] ) ) { |
|
779 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
780 | 780 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
781 | 781 | return false; |
782 | 782 | } |
@@ -784,26 +784,26 @@ discard block |
||
784 | 784 | $criteria = self::calculate_get_entries_criteria(); |
785 | 785 | |
786 | 786 | // Make sure the current View is connected to the same form as the Entry |
787 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
788 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
787 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
788 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
789 | 789 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
790 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
791 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
790 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
791 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
792 | 792 | return false; |
793 | 793 | } |
794 | 794 | } |
795 | 795 | |
796 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
796 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
797 | 797 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
798 | 798 | return $entry; |
799 | 799 | } |
800 | 800 | |
801 | - $search_criteria = $criteria['search_criteria']; |
|
801 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
802 | 802 | unset( $criteria ); |
803 | 803 | |
804 | 804 | // check entry status |
805 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
806 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
805 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
806 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
807 | 807 | return false; |
808 | 808 | } |
809 | 809 | |
@@ -811,41 +811,41 @@ discard block |
||
811 | 811 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
812 | 812 | |
813 | 813 | // field_filters |
814 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
814 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
815 | 815 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
816 | 816 | return $entry; |
817 | 817 | } |
818 | 818 | |
819 | - $filters = $search_criteria['field_filters']; |
|
819 | + $filters = $search_criteria[ 'field_filters' ]; |
|
820 | 820 | unset( $search_criteria ); |
821 | 821 | |
822 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
823 | - unset( $filters['mode'] ); |
|
822 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
823 | + unset( $filters[ 'mode' ] ); |
|
824 | 824 | |
825 | - $form = self::get_form( $entry['form_id'] ); |
|
825 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
826 | 826 | |
827 | 827 | foreach ( $filters as $filter ) { |
828 | 828 | |
829 | - if ( ! isset( $filter['key'] ) ) { |
|
829 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
830 | 830 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Filter key not set', $filter ); |
831 | 831 | continue; |
832 | 832 | } |
833 | 833 | |
834 | - $k = $filter['key']; |
|
834 | + $k = $filter[ 'key' ]; |
|
835 | 835 | |
836 | 836 | if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
837 | 837 | $field_value = $entry[ $k ]; |
838 | 838 | $field = null; |
839 | 839 | } else { |
840 | 840 | $field = self::get_field( $form, $k ); |
841 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
841 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
842 | 842 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
843 | 843 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? rgar( $field_value, $k ) : $field_value; |
844 | 844 | } |
845 | 845 | |
846 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
846 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
847 | 847 | |
848 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
848 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
849 | 849 | |
850 | 850 | // verify if we are already free to go! |
851 | 851 | if ( ! $is_value_match && 'all' === $mode ) { |
@@ -903,18 +903,18 @@ discard block |
||
903 | 903 | * Gravity Forms code to adjust date to locally-configured Time Zone |
904 | 904 | * @see GFCommon::format_date() for original code |
905 | 905 | */ |
906 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
906 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
907 | 907 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
908 | 908 | |
909 | - $format = rgar( $atts, 'format' ); |
|
910 | - $is_human = ! empty( $atts['human'] ); |
|
911 | - $is_diff = ! empty( $atts['diff'] ); |
|
912 | - $is_raw = ! empty( $atts['raw'] ); |
|
913 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
914 | - $include_time = ! empty( $atts['time'] ); |
|
909 | + $format = rgar( $atts, 'format' ); |
|
910 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
911 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
912 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
913 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
914 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
915 | 915 | |
916 | 916 | // If we're using time diff, we want to have a different default format |
917 | - if( empty( $format ) ) { |
|
917 | + if ( empty( $format ) ) { |
|
918 | 918 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
919 | 919 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
920 | 920 | } |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | // If raw was specified, don't modify the stored value |
923 | 923 | if ( $is_raw ) { |
924 | 924 | $formatted_date = $date_string; |
925 | - } elseif( $is_timestamp ) { |
|
925 | + } elseif ( $is_timestamp ) { |
|
926 | 926 | $formatted_date = $date_local_timestamp; |
927 | 927 | } elseif ( $is_diff ) { |
928 | 928 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | |
957 | 957 | $label = rgar( $field, 'label' ); |
958 | 958 | |
959 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
959 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
960 | 960 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
961 | 961 | } |
962 | 962 | |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | $form = GFAPI::get_form( $form ); |
985 | 985 | } |
986 | 986 | |
987 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
987 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
988 | 988 | return GFFormsModel::get_field( $form, $field_id ); |
989 | 989 | } else { |
990 | 990 | return null; |
@@ -1031,19 +1031,19 @@ discard block |
||
1031 | 1031 | $shortcodes = array(); |
1032 | 1032 | |
1033 | 1033 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
1034 | - if ( empty( $matches ) ){ |
|
1034 | + if ( empty( $matches ) ) { |
|
1035 | 1035 | return false; |
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | foreach ( $matches as $shortcode ) { |
1039 | - if ( $tag === $shortcode[2] ) { |
|
1039 | + if ( $tag === $shortcode[ 2 ] ) { |
|
1040 | 1040 | |
1041 | 1041 | // Changed this to $shortcode instead of true so we get the parsed atts. |
1042 | - $shortcodes[] = $shortcode; |
|
1042 | + $shortcodes[ ] = $shortcode; |
|
1043 | 1043 | |
1044 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
1045 | - foreach( $results as $result ) { |
|
1046 | - $shortcodes[] = $result; |
|
1044 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
1045 | + foreach ( $results as $result ) { |
|
1046 | + $shortcodes[ ] = $result; |
|
1047 | 1047 | } |
1048 | 1048 | } |
1049 | 1049 | } |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | public static function get_directory_fields( $post_id, $apply_filter = true ) { |
1188 | 1188 | $fields = get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
1189 | 1189 | |
1190 | - if( $apply_filter ) { |
|
1190 | + if ( $apply_filter ) { |
|
1191 | 1191 | /** |
1192 | 1192 | * @filter `gravityview/configuration/fields` Filter the View fields' configuration array |
1193 | 1193 | * @since 1.6.5 |
@@ -1210,7 +1210,7 @@ discard block |
||
1210 | 1210 | * @return string html |
1211 | 1211 | */ |
1212 | 1212 | public static function get_sortable_fields( $formid, $current = '' ) { |
1213 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1213 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1214 | 1214 | |
1215 | 1215 | if ( empty( $formid ) ) { |
1216 | 1216 | return $output; |
@@ -1223,11 +1223,11 @@ discard block |
||
1223 | 1223 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1224 | 1224 | |
1225 | 1225 | foreach ( $fields as $id => $field ) { |
1226 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1226 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1227 | 1227 | continue; |
1228 | 1228 | } |
1229 | 1229 | |
1230 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1230 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1231 | 1231 | } |
1232 | 1232 | } |
1233 | 1233 | |
@@ -1262,9 +1262,9 @@ discard block |
||
1262 | 1262 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1263 | 1263 | |
1264 | 1264 | // TODO: Convert to using array_filter |
1265 | - foreach( $fields as $id => $field ) { |
|
1265 | + foreach ( $fields as $id => $field ) { |
|
1266 | 1266 | |
1267 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1267 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1268 | 1268 | unset( $fields[ $id ] ); |
1269 | 1269 | } |
1270 | 1270 | } |
@@ -1305,14 +1305,14 @@ discard block |
||
1305 | 1305 | * @param int|array $field field key or field array |
1306 | 1306 | * @return boolean |
1307 | 1307 | */ |
1308 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1308 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1309 | 1309 | |
1310 | 1310 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1311 | 1311 | $form = self::get_form( $form ); |
1312 | 1312 | } |
1313 | 1313 | |
1314 | 1314 | // If entry meta, it's a string. Otherwise, numeric |
1315 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1315 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1316 | 1316 | $type = $field; |
1317 | 1317 | } else { |
1318 | 1318 | $type = self::get_field_type( $form, $field ); |
@@ -1326,9 +1326,9 @@ discard block |
||
1326 | 1326 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1327 | 1327 | |
1328 | 1328 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1329 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1330 | - if( true === $gv_field->is_numeric ) { |
|
1331 | - $numeric_types[] = $gv_field->is_numeric; |
|
1329 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1330 | + if ( true === $gv_field->is_numeric ) { |
|
1331 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1332 | 1332 | } |
1333 | 1333 | } |
1334 | 1334 | |
@@ -1478,18 +1478,18 @@ discard block |
||
1478 | 1478 | $final_atts = array_filter( $final_atts ); |
1479 | 1479 | |
1480 | 1480 | // If the href wasn't passed as an attribute, use the value passed to the function |
1481 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1482 | - $final_atts['href'] = $href; |
|
1481 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1482 | + $final_atts[ 'href' ] = $href; |
|
1483 | 1483 | } |
1484 | 1484 | |
1485 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1485 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1486 | 1486 | |
1487 | 1487 | /** |
1488 | 1488 | * Fix potential security issue with target=_blank |
1489 | 1489 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
1490 | 1490 | */ |
1491 | - if( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
1492 | - $final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1491 | + if ( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
1492 | + $final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1493 | 1493 | } |
1494 | 1494 | |
1495 | 1495 | // Sort the attributes alphabetically, to help testing |
@@ -1501,7 +1501,7 @@ discard block |
||
1501 | 1501 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1502 | 1502 | } |
1503 | 1503 | |
1504 | - if( '' !== $output ) { |
|
1504 | + if ( '' !== $output ) { |
|
1505 | 1505 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1506 | 1506 | } |
1507 | 1507 | |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1529 | 1529 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1530 | 1530 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
1531 | - $merged[] = $value; |
|
1531 | + $merged[ ] = $value; |
|
1532 | 1532 | } else { |
1533 | 1533 | $merged[ $key ] = $value; |
1534 | 1534 | } |
@@ -1561,7 +1561,7 @@ discard block |
||
1561 | 1561 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1562 | 1562 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1563 | 1563 | */ |
1564 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1564 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1565 | 1565 | |
1566 | 1566 | return get_users( $get_users_settings ); |
1567 | 1567 | } |
@@ -1581,11 +1581,11 @@ discard block |
||
1581 | 1581 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
1582 | 1582 | |
1583 | 1583 | // If $cap is defined, only show notice if user has capability |
1584 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1584 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1585 | 1585 | return ''; |
1586 | 1586 | } |
1587 | 1587 | |
1588 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1588 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1589 | 1589 | } |
1590 | 1590 | |
1591 | 1591 | /** |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | $this->label = esc_attr__( 'Approve Entries', 'gravityview' ); |
24 | 24 | |
25 | - $this->description = esc_attr__( 'Approve and reject entries from the View.', 'gravityview' ); |
|
25 | + $this->description = esc_attr__( 'Approve and reject entries from the View.', 'gravityview' ); |
|
26 | 26 | |
27 | 27 | $this->add_hooks(); |
28 | 28 | |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | */ |
45 | 45 | function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
46 | 46 | |
47 | - unset( $field_options['only_loggedin'] ); |
|
47 | + unset( $field_options[ 'only_loggedin' ] ); |
|
48 | 48 | |
49 | - unset( $field_options['new_window'] ); |
|
49 | + unset( $field_options[ 'new_window' ] ); |
|
50 | 50 | |
51 | - unset( $field_options['show_as_link'] ); |
|
51 | + unset( $field_options[ 'show_as_link' ] ); |
|
52 | 52 | |
53 | 53 | return $field_options; |
54 | 54 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | add_action( 'gravityview/field/approval/load_scripts', array( $this, 'enqueue_and_localize_script' ) ); |
70 | 70 | |
71 | - add_action( 'gravityview_datatables_scripts_styles', array( $this, 'enqueue_and_localize_script' ) ); |
|
71 | + add_action( 'gravityview_datatables_scripts_styles', array( $this, 'enqueue_and_localize_script' ) ); |
|
72 | 72 | |
73 | 73 | add_filter( 'gravityview_get_entries', array( $this, 'modify_search_parameters' ), 1000 ); |
74 | 74 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function maybe_prevent_field_render( $html, $args ) { |
89 | 89 | |
90 | 90 | // If the field is `entry_approval` type but the user doesn't have the moderate entries cap, don't render. |
91 | - if( $this->name === rgar( $args['field'], 'id' ) && ! GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
91 | + if ( $this->name === rgar( $args[ 'field' ], 'id' ) && ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
92 | 92 | return ''; |
93 | 93 | } |
94 | 94 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function modify_search_parameters( $parameters ) { |
106 | 106 | |
107 | - if( $this->name === rgars( $parameters, 'sorting/key' ) ) { |
|
108 | - $parameters['sorting']['key'] = 'is_approved'; |
|
107 | + if ( $this->name === rgars( $parameters, 'sorting/key' ) ) { |
|
108 | + $parameters[ 'sorting' ][ 'key' ] = 'is_approved'; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | return $parameters; |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | function register_scripts_and_styles() { |
122 | 122 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
123 | 123 | |
124 | - wp_register_script( 'gravityview-field-approval', GRAVITYVIEW_URL . 'assets/js/field-approval'.$script_debug.'.js', array( 'jquery' ), GravityView_Plugin::version, true ); |
|
124 | + wp_register_script( 'gravityview-field-approval', GRAVITYVIEW_URL . 'assets/js/field-approval' . $script_debug . '.js', array( 'jquery' ), GravityView_Plugin::version, true ); |
|
125 | 125 | |
126 | 126 | $style_path = GRAVITYVIEW_DIR . 'templates/css/field-approval.css'; |
127 | 127 | |
128 | - if( class_exists( 'GravityView_View' ) ) { |
|
128 | + if ( class_exists( 'GravityView_View' ) ) { |
|
129 | 129 | /** |
130 | 130 | * Override CSS file by placing in your theme's /gravityview/css/ sub-directory. |
131 | 131 | */ |
132 | 132 | $style_path = GravityView_View::getInstance()->locate_template( 'css/field-approval.css', false ); |
133 | 133 | } |
134 | 134 | |
135 | - $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) ); |
|
135 | + $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) ); |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * @filter `gravityview/field/approval/css_url` URL to the Approval field CSS file. |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | $style_url = apply_filters( 'gravityview/field/approval/css_url', $style_url ); |
143 | 143 | |
144 | - if( ! empty( $style_url ) ) { |
|
144 | + if ( ! empty( $style_url ) ) { |
|
145 | 145 | wp_register_style( 'gravityview-field-approval', $style_url, array( 'dashicons' ), GravityView_Plugin::version, 'screen' ); |
146 | 146 | } |
147 | 147 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | public function enqueue_and_localize_script() { |
157 | 157 | |
158 | 158 | // The script is already registered and enqueued |
159 | - if( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { |
|
159 | + if ( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | |
167 | 167 | wp_localize_script( 'gravityview-field-approval', 'gvApproval', array( |
168 | 168 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
169 | - 'nonce' => wp_create_nonce('gravityview_entry_approval'), |
|
169 | + 'nonce' => wp_create_nonce( 'gravityview_entry_approval' ), |
|
170 | 170 | 'status' => GravityView_Entry_Approval_Status::get_all(), |
171 | - )); |
|
171 | + ) ); |
|
172 | 172 | |
173 | 173 | } |
174 | 174 | |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function filter_gravityview_entry_default_field( $entry_default_fields, $form, $context ) { |
187 | 187 | |
188 | - if ( ! isset( $entry_default_fields["{$this->name}"] ) && 'edit' !== $context ) { |
|
189 | - $entry_default_fields["{$this->name}"] = array( |
|
188 | + if ( ! isset( $entry_default_fields[ "{$this->name}" ] ) && 'edit' !== $context ) { |
|
189 | + $entry_default_fields[ "{$this->name}" ] = array( |
|
190 | 190 | 'label' => $this->label, |
191 | 191 | 'desc' => $this->description, |
192 | 192 | 'type' => $this->name, |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function get_instance() { |
87 | 87 | |
88 | - if( empty( self::$instance ) ) { |
|
88 | + if ( empty( self::$instance ) ) { |
|
89 | 89 | self::$instance = new self; |
90 | 90 | } |
91 | 91 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | |
119 | 119 | $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS ); |
120 | 120 | |
121 | - if( $with_values ) { |
|
121 | + if ( $with_values ) { |
|
122 | 122 | $operators_with_values = array(); |
123 | - foreach( $operators as $key ) { |
|
123 | + foreach ( $operators as $key ) { |
|
124 | 124 | $operators_with_values[ $key ] = ''; |
125 | 125 | } |
126 | 126 | return $operators_with_values; |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | */ |
138 | 138 | function set_operation( $operation = '' ) { |
139 | 139 | |
140 | - if( empty( $operation ) ) { |
|
140 | + if ( empty( $operation ) ) { |
|
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
144 | 144 | $operators = $this->get_operators( false ); |
145 | 145 | |
146 | - if( !in_array( $operation, $operators ) ) { |
|
147 | - do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation ); |
|
146 | + if ( ! in_array( $operation, $operators ) ) { |
|
147 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Attempted to add invalid operation type.', $operation ); |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | */ |
165 | 165 | private function setup_operation_and_comparison() { |
166 | 166 | |
167 | - foreach( $this->atts as $key => $value ) { |
|
167 | + foreach ( $this->atts as $key => $value ) { |
|
168 | 168 | |
169 | 169 | $valid = $this->set_operation( $key ); |
170 | 170 | |
171 | - if( $valid ) { |
|
171 | + if ( $valid ) { |
|
172 | 172 | $this->comparison = $value; |
173 | 173 | return true; |
174 | 174 | } |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | return null; |
192 | 192 | } |
193 | 193 | |
194 | - if( empty( $atts ) ) { |
|
195 | - do_action( 'gravityview_log_error', __METHOD__.' $atts are empty.', $atts ); |
|
194 | + if ( empty( $atts ) ) { |
|
195 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts are empty.', $atts ); |
|
196 | 196 | return null; |
197 | 197 | } |
198 | 198 | |
@@ -203,16 +203,16 @@ discard block |
||
203 | 203 | $this->parse_atts(); |
204 | 204 | |
205 | 205 | // We need an "if" |
206 | - if( false === $this->if ) { |
|
207 | - do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->passed_atts ); |
|
206 | + if ( false === $this->if ) { |
|
207 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts->if is empty.', $this->passed_atts ); |
|
208 | 208 | return null; |
209 | 209 | } |
210 | 210 | |
211 | 211 | $setup = $this->setup_operation_and_comparison(); |
212 | 212 | |
213 | 213 | // We need an operation and comparison value |
214 | - if( ! $setup ) { |
|
215 | - do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts ); |
|
214 | + if ( ! $setup ) { |
|
215 | + do_action( 'gravityview_log_error', __METHOD__ . ' No valid operators were passed.', $this->atts ); |
|
216 | 216 | return null; |
217 | 217 | } |
218 | 218 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | private function get_output() { |
247 | 247 | |
248 | - if( $this->is_match ) { |
|
248 | + if ( $this->is_match ) { |
|
249 | 249 | $output = $this->content; |
250 | 250 | } else { |
251 | 251 | $output = $this->else_content; |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | * @param string $output HTML/text output |
260 | 260 | * @param GVLogic_Shortcode $this This class |
261 | 261 | */ |
262 | - $output = apply_filters('gravityview/gvlogic/output', $output, $this ); |
|
262 | + $output = apply_filters( 'gravityview/gvlogic/output', $output, $this ); |
|
263 | 263 | |
264 | - do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output ); |
|
264 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Output: ', $output ); |
|
265 | 265 | |
266 | 266 | return $output; |
267 | 267 | } |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | |
278 | 278 | $content = explode( '[else]', $this->passed_content ); |
279 | 279 | |
280 | - $this->content = $content[0]; |
|
280 | + $this->content = $content[ 0 ]; |
|
281 | 281 | |
282 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL; |
|
282 | + $else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL; |
|
283 | 283 | |
284 | - $this->else_content = isset( $content[1] ) ? $content[1] : $else_attr; |
|
284 | + $this->else_content = isset( $content[ 1 ] ) ? $content[ 1 ] : $else_attr; |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | $this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts; |
305 | 305 | |
306 | 306 | // Strip whitespace if it's not default false |
307 | - $this->if = ( isset( $this->atts['if'] ) && is_string( $this->atts['if'] ) ) ? trim( $this->atts['if'] ) : false; |
|
307 | + $this->if = ( isset( $this->atts[ 'if' ] ) && is_string( $this->atts[ 'if' ] ) ) ? trim( $this->atts[ 'if' ] ) : false; |
|
308 | 308 | |
309 | 309 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison() |
310 | - unset( $this->atts['if'] ); |
|
310 | + unset( $this->atts[ 'if' ] ); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 |
@@ -232,7 +232,7 @@ |
||
232 | 232 | * Does the if and the comparison match? |
233 | 233 | * @uses GVCommon::matches_operation |
234 | 234 | * |
235 | - * @return boolean True: yep; false: nope |
|
235 | + * @return boolean|null True: yep; false: nope |
|
236 | 236 | */ |
237 | 237 | private function set_is_match() { |
238 | 238 | $this->is_match = GVCommon::matches_operation( $this->if, $this->comparison, $this->operation ); |
@@ -2,8 +2,9 @@ discard block |
||
2 | 2 | namespace GV; |
3 | 3 | |
4 | 4 | /** If this file is called directly, abort. */ |
5 | -if ( ! defined( 'GRAVITYVIEW_DIR' ) ) |
|
5 | +if ( ! defined( 'GRAVITYVIEW_DIR' ) ) { |
|
6 | 6 | die(); |
7 | +} |
|
7 | 8 | |
8 | 9 | /** |
9 | 10 | * The core GravityView API. |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | * @return \GV\Core The global instance of GravityView Core. |
46 | 47 | */ |
47 | 48 | public static function get() { |
48 | - if ( ! self::$__instance instanceof self ) |
|
49 | - self::$__instance = new self; |
|
49 | + if ( ! self::$__instance instanceof self ) { |
|
50 | + self::$__instance = new self; |
|
51 | + } |
|
50 | 52 | return self::$__instance; |
51 | 53 | } |
52 | 54 |