@@ -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 ?> |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | private function __construct() {} |
86 | 86 | |
87 | 87 | private function initialize() { |
88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
91 | 91 | |
92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -234,15 +234,15 @@ discard block |
||
234 | 234 | |
235 | 235 | $this->context_view_id = $view_id; |
236 | 236 | |
237 | - } elseif ( isset( $_GET['gvid'] ) && $this->getGvOutputData()->has_multiple_views() ) { |
|
237 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $this->getGvOutputData()->has_multiple_views() ) { |
|
238 | 238 | /** |
239 | 239 | * used on a has_multiple_views context |
240 | 240 | * @see GravityView_API::entry_link |
241 | 241 | * @see GravityView_View_Data::getInstance()->has_multiple_views() |
242 | 242 | */ |
243 | - $this->context_view_id = $_GET['gvid']; |
|
243 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
244 | 244 | |
245 | - } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
245 | + } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
246 | 246 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
247 | 247 | $this->context_view_id = array_pop( $array_keys ); |
248 | 248 | unset( $array_keys ); |
@@ -277,24 +277,24 @@ discard block |
||
277 | 277 | global $wp_rewrite; |
278 | 278 | |
279 | 279 | $is_front_page = ( $query->is_home || $query->is_page ); |
280 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
281 | - $front_page_id = get_option('page_on_front'); |
|
280 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
281 | + $front_page_id = get_option( 'page_on_front' ); |
|
282 | 282 | |
283 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
283 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
284 | 284 | |
285 | 285 | // Force to be an array, potentially a query string ( entry=16 ) |
286 | 286 | $_query = wp_parse_args( $query->query ); |
287 | 287 | |
288 | 288 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
289 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
290 | - unset( $_query['pagename'] ); |
|
289 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
290 | + unset( $_query[ 'pagename' ] ); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | // this is where will break from core wordpress |
294 | 294 | $ignore = array( 'preview', 'page', 'paged', 'cpage' ); |
295 | 295 | $endpoints = rgobj( $wp_rewrite, 'endpoints' ); |
296 | - foreach ( (array) $endpoints as $endpoint ) { |
|
297 | - $ignore[] = $endpoint[1]; |
|
296 | + foreach ( (array)$endpoints as $endpoint ) { |
|
297 | + $ignore[ ] = $endpoint[ 1 ]; |
|
298 | 298 | } |
299 | 299 | unset( $endpoints ); |
300 | 300 | |
@@ -304,21 +304,21 @@ discard block |
||
304 | 304 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
305 | 305 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
306 | 306 | |
307 | - $qv =& $query->query_vars; |
|
307 | + $qv = & $query->query_vars; |
|
308 | 308 | |
309 | 309 | // Prevent redirect when on the single entry endpoint |
310 | - if( self::is_single_entry() ) { |
|
310 | + if ( self::is_single_entry() ) { |
|
311 | 311 | add_filter( 'redirect_canonical', '__return_false' ); |
312 | 312 | } |
313 | 313 | |
314 | 314 | $query->is_page = true; |
315 | 315 | $query->is_home = false; |
316 | - $qv['page_id'] = $front_page_id; |
|
316 | + $qv[ 'page_id' ] = $front_page_id; |
|
317 | 317 | |
318 | 318 | // Correct <!--nextpage--> for page_on_front |
319 | - if ( ! empty( $qv['paged'] ) ) { |
|
320 | - $qv['page'] = $qv['paged']; |
|
321 | - unset( $qv['paged'] ); |
|
319 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
320 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
321 | + unset( $qv[ 'paged' ] ); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | global $post; |
337 | 337 | |
338 | 338 | // If in admin and NOT AJAX request, get outta here. |
339 | - if ( GravityView_Plugin::is_admin() ) { |
|
339 | + if ( GravityView_Plugin::is_admin() ) { |
|
340 | 340 | return; |
341 | 341 | } |
342 | 342 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | |
349 | 349 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
350 | 350 | |
351 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
351 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
352 | 352 | $this->setPostId( $post_id ); |
353 | 353 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
354 | 354 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
386 | 386 | |
387 | - if( 'post' === $search_method ) { |
|
387 | + if ( 'post' === $search_method ) { |
|
388 | 388 | $get = $_POST; |
389 | 389 | } else { |
390 | 390 | $get = $_GET; |
@@ -440,20 +440,20 @@ discard block |
||
440 | 440 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
441 | 441 | * @param array $entry Current entry |
442 | 442 | */ |
443 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
443 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
444 | 444 | |
445 | 445 | if ( ! $apply_outside_loop ) { |
446 | 446 | return $title; |
447 | 447 | } |
448 | 448 | |
449 | 449 | // User reported WooCommerce doesn't pass two args. |
450 | - if ( empty( $passed_post_id ) ) { |
|
450 | + if ( empty( $passed_post_id ) ) { |
|
451 | 451 | return $title; |
452 | 452 | } |
453 | 453 | |
454 | 454 | // Don't modify the title for anything other than the current view/post. |
455 | 455 | // This is true for embedded shortcodes and Views. |
456 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
456 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
457 | 457 | return $title; |
458 | 458 | } |
459 | 459 | |
@@ -463,19 +463,19 @@ discard block |
||
463 | 463 | $view_meta = $this->getGvOutputData()->get_view( $context_view_id ); |
464 | 464 | } else { |
465 | 465 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
466 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
466 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
467 | 467 | $view_meta = $view_data; |
468 | 468 | break; |
469 | 469 | } |
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
473 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
473 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
474 | 474 | |
475 | - $title = $view_meta['atts']['single_title']; |
|
475 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
476 | 476 | |
477 | 477 | // We are allowing HTML in the fields, so no escaping the output |
478 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
478 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
479 | 479 | |
480 | 480 | $title = do_shortcode( $title ); |
481 | 481 | } |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | public function render_view( $passed_args ) { |
577 | 577 | |
578 | 578 | // validate attributes |
579 | - if ( empty( $passed_args['id'] ) ) { |
|
579 | + if ( empty( $passed_args[ 'id' ] ) ) { |
|
580 | 580 | do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args ); |
581 | 581 | return null; |
582 | 582 | } |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | return null; |
599 | 599 | } |
600 | 600 | |
601 | - $view_id = $passed_args['id']; |
|
601 | + $view_id = $passed_args[ 'id' ]; |
|
602 | 602 | |
603 | 603 | $view_data = $this->getGvOutputData()->get_view( $view_id, $passed_args ); |
604 | 604 | |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | $passed_args = array_filter( $passed_args, 'strlen' ); |
612 | 612 | |
613 | 613 | //Override shortcode args over View template settings |
614 | - $atts = wp_parse_args( $passed_args, $view_data['atts'] ); |
|
614 | + $atts = wp_parse_args( $passed_args, $view_data[ 'atts' ] ); |
|
615 | 615 | |
616 | 616 | do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts ); |
617 | 617 | |
@@ -634,14 +634,14 @@ discard block |
||
634 | 634 | * @since 1.15 |
635 | 635 | * @since 1.17.2 Added check for if a user has no caps but is logged in (member of multisite, but not any site). Treat as if logged-out. |
636 | 636 | */ |
637 | - if( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
637 | + if ( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
638 | 638 | |
639 | 639 | do_action( 'gravityview_log_debug', sprintf( '%s Returning: View %d is not visible by current user.', __METHOD__, $view_id ) ); |
640 | 640 | |
641 | 641 | return null; |
642 | 642 | } |
643 | 643 | |
644 | - if( $this->isGravityviewPostType() ) { |
|
644 | + if ( $this->isGravityviewPostType() ) { |
|
645 | 645 | |
646 | 646 | /** |
647 | 647 | * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode? |
@@ -653,9 +653,9 @@ discard block |
||
653 | 653 | */ |
654 | 654 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view_id ); |
655 | 655 | |
656 | - $embed_only = ! empty( $atts['embed_only'] ); |
|
656 | + $embed_only = ! empty( $atts[ 'embed_only' ] ); |
|
657 | 657 | |
658 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
658 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
659 | 659 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
660 | 660 | } |
661 | 661 | } |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | |
671 | 671 | $gravityview_view = new GravityView_View( $view_data ); |
672 | 672 | |
673 | - $post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : $this->getPostId(); |
|
673 | + $post_id = ! empty( $atts[ 'post_id' ] ) ? intval( $atts[ 'post_id' ] ) : $this->getPostId(); |
|
674 | 674 | |
675 | 675 | $gravityview_view->setPostId( $post_id ); |
676 | 676 | |
@@ -680,20 +680,20 @@ discard block |
||
680 | 680 | do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' ); |
681 | 681 | |
682 | 682 | //fetch template and slug |
683 | - $view_slug = apply_filters( 'gravityview_template_slug_'. $view_data['template_id'], 'table', 'directory' ); |
|
683 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'directory' ); |
|
684 | 684 | |
685 | 685 | do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug ); |
686 | 686 | |
687 | 687 | /** |
688 | 688 | * Disable fetching initial entries for views that don't need it (DataTables) |
689 | 689 | */ |
690 | - $get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true ); |
|
690 | + $get_entries = apply_filters( 'gravityview_get_view_entries_' . $view_slug, true ); |
|
691 | 691 | |
692 | 692 | /** |
693 | 693 | * Hide View data until search is performed |
694 | 694 | * @since 1.5.4 |
695 | 695 | */ |
696 | - if ( ! empty( $atts['hide_until_searched'] ) && ! $this->isSearch() ) { |
|
696 | + if ( ! empty( $atts[ 'hide_until_searched' ] ) && ! $this->isSearch() ) { |
|
697 | 697 | $gravityview_view->setHideUntilSearched( true ); |
698 | 698 | $get_entries = false; |
699 | 699 | } |
@@ -701,23 +701,23 @@ discard block |
||
701 | 701 | |
702 | 702 | if ( $get_entries ) { |
703 | 703 | |
704 | - if ( ! empty( $atts['sort_columns'] ) ) { |
|
704 | + if ( ! empty( $atts[ 'sort_columns' ] ) ) { |
|
705 | 705 | // add filter to enable column sorting |
706 | - add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 ); |
|
706 | + add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ), 100, 3 ); |
|
707 | 707 | } |
708 | 708 | |
709 | - $view_entries = self::get_view_entries( $atts, $view_data['form_id'] ); |
|
709 | + $view_entries = self::get_view_entries( $atts, $view_data[ 'form_id' ] ); |
|
710 | 710 | |
711 | - do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) ); |
|
711 | + do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries[ 'count' ], sizeof( $view_entries[ 'entries' ] ) ) ); |
|
712 | 712 | |
713 | 713 | } else { |
714 | 714 | |
715 | 715 | $view_entries = array( 'count' => null, 'entries' => null, 'paging' => null ); |
716 | 716 | |
717 | - do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' ); |
|
717 | + do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false' ); |
|
718 | 718 | } |
719 | 719 | |
720 | - $gravityview_view->setPaging( $view_entries['paging'] ); |
|
720 | + $gravityview_view->setPaging( $view_entries[ 'paging' ] ); |
|
721 | 721 | $gravityview_view->setContext( 'directory' ); |
722 | 722 | $sections = array( 'header', 'body', 'footer' ); |
723 | 723 | |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | * @action `gravityview_render_entry_{View ID}` Before rendering a single entry for a specific View ID |
732 | 732 | * @since 1.17 |
733 | 733 | */ |
734 | - do_action( 'gravityview_render_entry_'.$view_data['id'] ); |
|
734 | + do_action( 'gravityview_render_entry_' . $view_data[ 'id' ] ); |
|
735 | 735 | |
736 | 736 | $entry = $this->getEntry(); |
737 | 737 | |
@@ -758,20 +758,20 @@ discard block |
||
758 | 758 | // We're in single view, but the view being processed is not the same view the single entry belongs to. |
759 | 759 | // important: do not remove this as it prevents fake attempts of displaying entries from other views/forms |
760 | 760 | if ( $this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id() ) { |
761 | - do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id ); |
|
761 | + do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: ' . $view_id ); |
|
762 | 762 | return null; |
763 | 763 | } |
764 | 764 | |
765 | 765 | //fetch template and slug |
766 | - $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data['template_id'], 'table', 'single' ); |
|
766 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'single' ); |
|
767 | 767 | do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug ); |
768 | 768 | |
769 | 769 | //fetch entry detail |
770 | - $view_entries['count'] = 1; |
|
771 | - $view_entries['entries'][] = $entry; |
|
772 | - do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] ); |
|
770 | + $view_entries[ 'count' ] = 1; |
|
771 | + $view_entries[ 'entries' ][ ] = $entry; |
|
772 | + do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries[ 'entries' ] ); |
|
773 | 773 | |
774 | - $back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null; |
|
774 | + $back_link_label = isset( $atts[ 'back_link_label' ] ) ? $atts[ 'back_link_label' ] : null; |
|
775 | 775 | |
776 | 776 | // set back link label |
777 | 777 | $gravityview_view->setBackLinkLabel( $back_link_label ); |
@@ -781,11 +781,11 @@ discard block |
||
781 | 781 | } |
782 | 782 | |
783 | 783 | // add template style |
784 | - self::add_style( $view_data['template_id'] ); |
|
784 | + self::add_style( $view_data[ 'template_id' ] ); |
|
785 | 785 | |
786 | 786 | // Prepare to render view and set vars |
787 | - $gravityview_view->setEntries( $view_entries['entries'] ); |
|
788 | - $gravityview_view->setTotalEntries( $view_entries['count'] ); |
|
787 | + $gravityview_view->setEntries( $view_entries[ 'entries' ] ); |
|
788 | + $gravityview_view->setTotalEntries( $view_entries[ 'count' ] ); |
|
789 | 789 | |
790 | 790 | // If Edit |
791 | 791 | if ( 'edit' === gravityview_get_context() ) { |
@@ -798,11 +798,11 @@ discard block |
||
798 | 798 | |
799 | 799 | } else { |
800 | 800 | // finaly we'll render some html |
801 | - $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data['template_id'] ); |
|
801 | + $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data[ 'template_id' ] ); |
|
802 | 802 | |
803 | 803 | do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections ); |
804 | 804 | foreach ( $sections as $section ) { |
805 | - do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' ); |
|
805 | + do_action( 'gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.' ); |
|
806 | 806 | $gravityview_view->render( $view_slug, $section, false ); |
807 | 807 | } |
808 | 808 | } |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | $datetime_format = 'Y-m-d H:i:s'; |
857 | 857 | $search_is_outside_view_bounds = false; |
858 | 858 | |
859 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
859 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
860 | 860 | |
861 | 861 | $search_date = strtotime( $search_criteria[ $key ] ); |
862 | 862 | |
@@ -884,14 +884,14 @@ discard block |
||
884 | 884 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
885 | 885 | |
886 | 886 | // Then we override the search and re-set the start date |
887 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
887 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
888 | 888 | } |
889 | 889 | } |
890 | 890 | } |
891 | 891 | |
892 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
892 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
893 | 893 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
894 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
894 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
895 | 895 | do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria ); |
896 | 896 | } |
897 | 897 | } |
@@ -910,19 +910,19 @@ discard block |
||
910 | 910 | public static function process_search_only_approved( $args, $search_criteria ) { |
911 | 911 | |
912 | 912 | /** @since 1.19 */ |
913 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
913 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
914 | 914 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries; showing all approval statuses' ); |
915 | 915 | return $search_criteria; |
916 | 916 | } |
917 | 917 | |
918 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
918 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
919 | 919 | |
920 | - $search_criteria['field_filters'][] = array( |
|
920 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
921 | 921 | 'key' => GravityView_Entry_Approval::meta_key, |
922 | 922 | 'value' => GravityView_Entry_Approval_Status::APPROVED |
923 | 923 | ); |
924 | 924 | |
925 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
925 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
926 | 926 | |
927 | 927 | do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria ); |
928 | 928 | } |
@@ -949,18 +949,18 @@ discard block |
||
949 | 949 | */ |
950 | 950 | public static function is_entry_approved( $entry, $args = array() ) { |
951 | 951 | |
952 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
952 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
953 | 953 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
954 | 954 | return true; |
955 | 955 | } |
956 | 956 | |
957 | 957 | /** @since 1.19 */ |
958 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
958 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
959 | 959 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries, so entry is approved for viewing' ); |
960 | 960 | return true; |
961 | 961 | } |
962 | 962 | |
963 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key ); |
|
963 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key ); |
|
964 | 964 | |
965 | 965 | return GravityView_Entry_Approval_Status::is_approved( $is_approved ); |
966 | 966 | } |
@@ -994,26 +994,26 @@ discard block |
||
994 | 994 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria ); |
995 | 995 | |
996 | 996 | // implicity search |
997 | - if ( ! empty( $args['search_value'] ) ) { |
|
997 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
998 | 998 | |
999 | 999 | // Search operator options. Options: `is` or `contains` |
1000 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
1000 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
1001 | 1001 | |
1002 | - $search_criteria['field_filters'][] = array( |
|
1002 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
1003 | 1003 | 'key' => rgget( 'search_field', $args ), // The field ID to search |
1004 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
1004 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
1005 | 1005 | 'operator' => $operator, |
1006 | 1006 | ); |
1007 | 1007 | } |
1008 | 1008 | |
1009 | - if( $search_criteria !== $original_search_criteria ) { |
|
1009 | + if ( $search_criteria !== $original_search_criteria ) { |
|
1010 | 1010 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria ); |
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | // Handle setting date range |
1014 | 1014 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
1015 | 1015 | |
1016 | - if( $search_criteria !== $original_search_criteria ) { |
|
1016 | + if ( $search_criteria !== $original_search_criteria ) { |
|
1017 | 1017 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria ); |
1018 | 1018 | } |
1019 | 1019 | |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
1025 | 1025 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
1026 | 1026 | */ |
1027 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
1027 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
1028 | 1028 | |
1029 | 1029 | return $search_criteria; |
1030 | 1030 | } |
@@ -1070,16 +1070,16 @@ discard block |
||
1070 | 1070 | $search_criteria = self::get_search_criteria( $args, $form_id ); |
1071 | 1071 | |
1072 | 1072 | // Paging & offset |
1073 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : apply_filters( 'gravityview_default_page_size', 25 ); |
|
1073 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : apply_filters( 'gravityview_default_page_size', 25 ); |
|
1074 | 1074 | |
1075 | 1075 | if ( -1 === $page_size ) { |
1076 | 1076 | $page_size = PHP_INT_MAX; |
1077 | 1077 | } |
1078 | 1078 | |
1079 | - if ( isset( $args['offset'] ) ) { |
|
1080 | - $offset = intval( $args['offset'] ); |
|
1079 | + if ( isset( $args[ 'offset' ] ) ) { |
|
1080 | + $offset = intval( $args[ 'offset' ] ); |
|
1081 | 1081 | } else { |
1082 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
1082 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
1083 | 1083 | $offset = ( $curr_page - 1 ) * $page_size; |
1084 | 1084 | } |
1085 | 1085 | |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | 'search_criteria' => $search_criteria, |
1098 | 1098 | 'sorting' => $sorting, |
1099 | 1099 | 'paging' => $paging, |
1100 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
1100 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
1101 | 1101 | ); |
1102 | 1102 | |
1103 | 1103 | /** |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
1123 | 1123 | * @param array $args View configuration args. |
1124 | 1124 | */ |
1125 | - $parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id ); |
|
1125 | + $parameters = apply_filters( 'gravityview_get_entries_' . $args[ 'id' ], $parameters, $args, $form_id ); |
|
1126 | 1126 | |
1127 | 1127 | do_action( 'gravityview_log_debug', __METHOD__ . ': $parameters passed to gravityview_get_entries(): ', $parameters ); |
1128 | 1128 | |
@@ -1162,8 +1162,8 @@ discard block |
||
1162 | 1162 | */ |
1163 | 1163 | public static function updateViewSorting( $args, $form_id ) { |
1164 | 1164 | $sorting = array(); |
1165 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' ); |
|
1166 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' ); |
|
1165 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : rgar( $args, 'sort_field' ); |
|
1166 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : rgar( $args, 'sort_direction' ); |
|
1167 | 1167 | |
1168 | 1168 | $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id ); |
1169 | 1169 | |
@@ -1203,11 +1203,11 @@ discard block |
||
1203 | 1203 | |
1204 | 1204 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
1205 | 1205 | |
1206 | - if( ! $sort_field ) { |
|
1206 | + if ( ! $sort_field ) { |
|
1207 | 1207 | return $sort_field_id; |
1208 | 1208 | } |
1209 | 1209 | |
1210 | - switch ( $sort_field['type'] ) { |
|
1210 | + switch ( $sort_field[ 'type' ] ) { |
|
1211 | 1211 | |
1212 | 1212 | case 'address': |
1213 | 1213 | // Sorting by full address |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | */ |
1225 | 1225 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
1226 | 1226 | |
1227 | - switch( strtolower( $address_part ) ){ |
|
1227 | + switch ( strtolower( $address_part ) ) { |
|
1228 | 1228 | case 'street': |
1229 | 1229 | $sort_field_id .= '.1'; |
1230 | 1230 | break; |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | */ |
1305 | 1305 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
1306 | 1306 | |
1307 | - if ( empty( $single_entry ) ){ |
|
1307 | + if ( empty( $single_entry ) ) { |
|
1308 | 1308 | return false; |
1309 | 1309 | } else { |
1310 | 1310 | return $single_entry; |
@@ -1331,7 +1331,7 @@ discard block |
||
1331 | 1331 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
1332 | 1332 | * @since 1.15 |
1333 | 1333 | */ |
1334 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1334 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1335 | 1335 | continue; |
1336 | 1336 | } |
1337 | 1337 | |
@@ -1340,19 +1340,19 @@ discard block |
||
1340 | 1340 | $css_dependencies = array(); |
1341 | 1341 | |
1342 | 1342 | // If the thickbox is enqueued, add dependencies |
1343 | - if ( ! empty( $data['atts']['lightbox'] ) ) { |
|
1343 | + if ( ! empty( $data[ 'atts' ][ 'lightbox' ] ) ) { |
|
1344 | 1344 | |
1345 | 1345 | /** |
1346 | 1346 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
1347 | 1347 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
1348 | 1348 | */ |
1349 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1349 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1350 | 1350 | |
1351 | 1351 | /** |
1352 | 1352 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
1353 | 1353 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
1354 | 1354 | */ |
1355 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1355 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | /** |
@@ -1360,25 +1360,25 @@ discard block |
||
1360 | 1360 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
1361 | 1361 | * @since 1.15 |
1362 | 1362 | */ |
1363 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
1364 | - $css_dependencies[] = 'dashicons'; |
|
1363 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
1364 | + $css_dependencies[ ] = 'dashicons'; |
|
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
1368 | 1368 | |
1369 | 1369 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
1370 | 1370 | |
1371 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
1371 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true ); |
|
1372 | 1372 | |
1373 | 1373 | wp_enqueue_script( 'gravityview-fe-view' ); |
1374 | 1374 | |
1375 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
1375 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
1376 | 1376 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | $this->enqueue_default_style( $css_dependencies ); |
1380 | 1380 | |
1381 | - self::add_style( $data['template_id'] ); |
|
1381 | + self::add_style( $data[ 'template_id' ] ); |
|
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | if ( 'wp_print_footer_scripts' === current_filter() ) { |
@@ -1440,7 +1440,7 @@ discard block |
||
1440 | 1440 | } elseif ( empty( $template_id ) ) { |
1441 | 1441 | do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' ); |
1442 | 1442 | } else { |
1443 | - do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) ); |
|
1443 | + do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_' . $template_id ) ); |
|
1444 | 1444 | } |
1445 | 1445 | |
1446 | 1446 | } |
@@ -1465,11 +1465,11 @@ discard block |
||
1465 | 1465 | * Not a table-based template; don't add sort icons |
1466 | 1466 | * @since 1.12 |
1467 | 1467 | */ |
1468 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1468 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1469 | 1469 | return $label; |
1470 | 1470 | } |
1471 | 1471 | |
1472 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
1472 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
1473 | 1473 | return $label; |
1474 | 1474 | } |
1475 | 1475 | |
@@ -1477,29 +1477,29 @@ discard block |
||
1477 | 1477 | |
1478 | 1478 | $class = 'gv-sort'; |
1479 | 1479 | |
1480 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
1480 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
1481 | 1481 | |
1482 | 1482 | $sort_args = array( |
1483 | - 'sort' => $field['id'], |
|
1483 | + 'sort' => $field[ 'id' ], |
|
1484 | 1484 | 'dir' => 'asc', |
1485 | 1485 | ); |
1486 | 1486 | |
1487 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
1487 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
1488 | 1488 | //toggle sorting direction. |
1489 | - if ( 'asc' === $sorting['direction'] ) { |
|
1490 | - $sort_args['dir'] = 'desc'; |
|
1489 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
1490 | + $sort_args[ 'dir' ] = 'desc'; |
|
1491 | 1491 | $class .= ' gv-icon-sort-desc'; |
1492 | 1492 | } else { |
1493 | - $sort_args['dir'] = 'asc'; |
|
1493 | + $sort_args[ 'dir' ] = 'asc'; |
|
1494 | 1494 | $class .= ' gv-icon-sort-asc'; |
1495 | 1495 | } |
1496 | 1496 | } else { |
1497 | 1497 | $class .= ' gv-icon-caret-up-down'; |
1498 | 1498 | } |
1499 | 1499 | |
1500 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
1500 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
1501 | 1501 | |
1502 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
1502 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
1503 | 1503 | |
1504 | 1504 | } |
1505 | 1505 | |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | |
1518 | 1518 | $field_type = $field_id; |
1519 | 1519 | |
1520 | - if( is_numeric( $field_id ) ) { |
|
1520 | + if ( is_numeric( $field_id ) ) { |
|
1521 | 1521 | $field = GFFormsModel::get_field( $form, $field_id ); |
1522 | 1522 | $field_type = $field->type; |
1523 | 1523 | } |
@@ -1540,7 +1540,7 @@ discard block |
||
1540 | 1540 | return false; |
1541 | 1541 | } |
1542 | 1542 | |
1543 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1543 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1544 | 1544 | |
1545 | 1545 | } |
1546 | 1546 |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $entry = self::get_entry( $entry_slug, true ); |
126 | 126 | |
127 | - $form = self::get_form( $entry['form_id'] ); |
|
127 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
128 | 128 | |
129 | 129 | return $form; |
130 | 130 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
184 | 184 | |
185 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
185 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
186 | 186 | |
187 | 187 | return $result; |
188 | 188 | } |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
201 | 201 | */ |
202 | - public static function get_forms( $active = true, $trash = false ) { |
|
202 | + public static function get_forms( $active = true, $trash = false ) { |
|
203 | 203 | $forms = array(); |
204 | 204 | if ( class_exists( 'GFAPI' ) ) { |
205 | - if( 'any' === $active ) { |
|
205 | + if ( 'any' === $active ) { |
|
206 | 206 | $active_forms = GFAPI::get_forms( true, $trash ); |
207 | 207 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
208 | 208 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | $has_post_fields = false; |
234 | 234 | |
235 | 235 | if ( $form ) { |
236 | - foreach ( $form['fields'] as $field ) { |
|
237 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
238 | - $fields["{$field['id']}"] = array( |
|
236 | + foreach ( $form[ 'fields' ] as $field ) { |
|
237 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
238 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
239 | 239 | 'label' => rgar( $field, 'label' ), |
240 | 240 | 'parent' => null, |
241 | 241 | 'type' => rgar( $field, 'type' ), |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | ); |
245 | 245 | } |
246 | 246 | |
247 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
248 | - foreach ( $field['inputs'] as $input ) { |
|
247 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
248 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
249 | 249 | |
250 | - if( ! empty( $input['isHidden'] ) ) { |
|
250 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | * @hack |
256 | 256 | * In case of email/email confirmation, the input for email has the same id as the parent field |
257 | 257 | */ |
258 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
258 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
259 | 259 | continue; |
260 | 260 | } |
261 | - $fields["{$input['id']}"] = array( |
|
261 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
262 | 262 | 'label' => rgar( $input, 'label' ), |
263 | 263 | 'customLabel' => rgar( $input, 'customLabel' ), |
264 | 264 | 'parent' => $field, |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | |
273 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
273 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
274 | 274 | $has_product_fields = true; |
275 | 275 | } |
276 | 276 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @since 1.7 |
285 | 285 | */ |
286 | 286 | if ( $has_post_fields ) { |
287 | - $fields['post_id'] = array( |
|
287 | + $fields[ 'post_id' ] = array( |
|
288 | 288 | 'label' => __( 'Post ID', 'gravityview' ), |
289 | 289 | 'type' => 'post_id', |
290 | 290 | ); |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | $payment_fields = GravityView_Fields::get_all( 'pricing' ); |
296 | 296 | |
297 | 297 | foreach ( $payment_fields as $payment_field ) { |
298 | - if( isset( $fields["{$payment_field->name}"] ) ) { |
|
298 | + if ( isset( $fields[ "{$payment_field->name}" ] ) ) { |
|
299 | 299 | continue; |
300 | 300 | } |
301 | - $fields["{$payment_field->name}"] = array( |
|
301 | + $fields[ "{$payment_field->name}" ] = array( |
|
302 | 302 | 'label' => $payment_field->label, |
303 | 303 | 'desc' => $payment_field->description, |
304 | 304 | 'type' => $payment_field->name, |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | |
331 | 331 | $fields = array(); |
332 | 332 | |
333 | - foreach ( $extra_fields as $key => $field ){ |
|
334 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
335 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
333 | + foreach ( $extra_fields as $key => $field ) { |
|
334 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
335 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
@@ -372,32 +372,32 @@ discard block |
||
372 | 372 | 'search_criteria' => null, |
373 | 373 | 'sorting' => null, |
374 | 374 | 'paging' => null, |
375 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
375 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? $passed_criteria[ 'cache' ] : true ), |
|
376 | 376 | ); |
377 | 377 | |
378 | 378 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
379 | 379 | |
380 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
381 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
380 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
381 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
382 | 382 | |
383 | 383 | if ( ! is_array( $filter ) ) { |
384 | 384 | continue; |
385 | 385 | } |
386 | 386 | |
387 | 387 | // By default, we want searches to be wildcard for each field. |
388 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
388 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
389 | 389 | |
390 | 390 | /** |
391 | 391 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
392 | 392 | * @param string $operator Existing search operator |
393 | 393 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
394 | 394 | */ |
395 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
395 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | // don't send just the [mode] without any field filter. |
399 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
400 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
399 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
400 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | } |
@@ -408,21 +408,21 @@ discard block |
||
408 | 408 | * Prepare date formats to be in Gravity Forms DB format; |
409 | 409 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
410 | 410 | */ |
411 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
411 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
412 | 412 | |
413 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
413 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
414 | 414 | |
415 | 415 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
416 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
416 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
417 | 417 | |
418 | 418 | if ( $date ) { |
419 | 419 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
420 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
420 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
421 | 421 | } else { |
422 | 422 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
423 | - unset( $criteria['search_criteria'][ $key ] ); |
|
423 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
424 | 424 | |
425 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
425 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | } |
@@ -430,12 +430,12 @@ discard block |
||
430 | 430 | |
431 | 431 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
432 | 432 | if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
433 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
433 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
434 | 434 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
435 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
436 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
435 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
436 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
437 | 437 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
438 | - $criteria['context_view_id'] = null; |
|
438 | + $criteria[ 'context_view_id' ] = null; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * @param array $form_ids Forms to search |
445 | 445 | * @param int $view_id ID of the view being used to search |
446 | 446 | */ |
447 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
447 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
448 | 448 | |
449 | 449 | return (array)$criteria; |
450 | 450 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | /** Reduce # of database calls */ |
476 | 476 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
477 | 477 | |
478 | - if ( ! empty( $criteria['cache'] ) ) { |
|
478 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
479 | 479 | |
480 | 480 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
481 | 481 | |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | |
484 | 484 | // Still update the total count when using cached results |
485 | 485 | if ( ! is_null( $total ) ) { |
486 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
486 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | $return = $entries; |
@@ -503,9 +503,9 @@ discard block |
||
503 | 503 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
504 | 504 | |
505 | 505 | // No entries returned from gravityview_before_get_entries |
506 | - if( is_null( $entries ) ) { |
|
506 | + if ( is_null( $entries ) ) { |
|
507 | 507 | |
508 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
508 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
509 | 509 | |
510 | 510 | if ( is_wp_error( $entries ) ) { |
511 | 511 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | } |
515 | 515 | } |
516 | 516 | |
517 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
517 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
518 | 518 | |
519 | 519 | // Cache results |
520 | 520 | $Cache->set( $entries, 'entries' ); |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | */ |
620 | 620 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
621 | 621 | |
622 | - if( $check_entry_display ) { |
|
622 | + if ( $check_entry_display ) { |
|
623 | 623 | // Is the entry allowed |
624 | 624 | $entry = self::check_entry_display( $entry ); |
625 | 625 | } |
@@ -652,12 +652,12 @@ discard block |
||
652 | 652 | |
653 | 653 | $value = false; |
654 | 654 | |
655 | - if( 'context' === $val1 ) { |
|
655 | + if ( 'context' === $val1 ) { |
|
656 | 656 | |
657 | 657 | $matching_contexts = array( $val2 ); |
658 | 658 | |
659 | 659 | // We allow for non-standard contexts. |
660 | - switch( $val2 ) { |
|
660 | + switch ( $val2 ) { |
|
661 | 661 | // Check for either single or edit |
662 | 662 | case 'singular': |
663 | 663 | $matching_contexts = array( 'single', 'edit' ); |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | return false; |
718 | 718 | } |
719 | 719 | |
720 | - if ( empty( $entry['form_id'] ) ) { |
|
720 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
721 | 721 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
722 | 722 | return false; |
723 | 723 | } |
@@ -725,26 +725,26 @@ discard block |
||
725 | 725 | $criteria = self::calculate_get_entries_criteria(); |
726 | 726 | |
727 | 727 | // Make sure the current View is connected to the same form as the Entry |
728 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
729 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
728 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
729 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
730 | 730 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
731 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
732 | - 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'] ); |
|
731 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
732 | + 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' ] ); |
|
733 | 733 | return false; |
734 | 734 | } |
735 | 735 | } |
736 | 736 | |
737 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
737 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
738 | 738 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
739 | 739 | return $entry; |
740 | 740 | } |
741 | 741 | |
742 | - $search_criteria = $criteria['search_criteria']; |
|
742 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
743 | 743 | unset( $criteria ); |
744 | 744 | |
745 | 745 | // check entry status |
746 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
747 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
746 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
747 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
748 | 748 | return false; |
749 | 749 | } |
750 | 750 | |
@@ -752,37 +752,37 @@ discard block |
||
752 | 752 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
753 | 753 | |
754 | 754 | // field_filters |
755 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
755 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
756 | 756 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
757 | 757 | return $entry; |
758 | 758 | } |
759 | 759 | |
760 | - $filters = $search_criteria['field_filters']; |
|
760 | + $filters = $search_criteria[ 'field_filters' ]; |
|
761 | 761 | unset( $search_criteria ); |
762 | 762 | |
763 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
764 | - unset( $filters['mode'] ); |
|
763 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
764 | + unset( $filters[ 'mode' ] ); |
|
765 | 765 | |
766 | - $form = self::get_form( $entry['form_id'] ); |
|
766 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
767 | 767 | |
768 | 768 | foreach ( $filters as $filter ) { |
769 | 769 | |
770 | - if ( ! isset( $filter['key'] ) ) { |
|
770 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
771 | 771 | continue; |
772 | 772 | } |
773 | 773 | |
774 | - $k = $filter['key']; |
|
774 | + $k = $filter[ 'key' ]; |
|
775 | 775 | |
776 | 776 | if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
777 | 777 | $field_value = $entry[ $k ]; |
778 | 778 | $field = null; |
779 | 779 | } else { |
780 | 780 | $field = self::get_field( $form, $k ); |
781 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
781 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
782 | 782 | } |
783 | 783 | |
784 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
785 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
784 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
785 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
786 | 786 | |
787 | 787 | // verify if we are already free to go! |
788 | 788 | if ( ! $is_value_match && 'all' === $mode ) { |
@@ -840,18 +840,18 @@ discard block |
||
840 | 840 | * Gravity Forms code to adjust date to locally-configured Time Zone |
841 | 841 | * @see GFCommon::format_date() for original code |
842 | 842 | */ |
843 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
843 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
844 | 844 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
845 | 845 | |
846 | - $format = rgar( $atts, 'format' ); |
|
847 | - $is_human = ! empty( $atts['human'] ); |
|
848 | - $is_diff = ! empty( $atts['diff'] ); |
|
849 | - $is_raw = ! empty( $atts['raw'] ); |
|
850 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
851 | - $include_time = ! empty( $atts['time'] ); |
|
846 | + $format = rgar( $atts, 'format' ); |
|
847 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
848 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
849 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
850 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
851 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
852 | 852 | |
853 | 853 | // If we're using time diff, we want to have a different default format |
854 | - if( empty( $format ) ) { |
|
854 | + if ( empty( $format ) ) { |
|
855 | 855 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
856 | 856 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
857 | 857 | } |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | // If raw was specified, don't modify the stored value |
860 | 860 | if ( $is_raw ) { |
861 | 861 | $formatted_date = $date_string; |
862 | - } elseif( $is_timestamp ) { |
|
862 | + } elseif ( $is_timestamp ) { |
|
863 | 863 | $formatted_date = $date_local_timestamp; |
864 | 864 | } elseif ( $is_diff ) { |
865 | 865 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | |
894 | 894 | $label = rgar( $field, 'label' ); |
895 | 895 | |
896 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
896 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
897 | 897 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
898 | 898 | } |
899 | 899 | |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | * @return GF_Field|null Gravity Forms field object, or NULL: Gravity Forms GFFormsModel does not exist or field at $field_id doesn't exist. |
915 | 915 | */ |
916 | 916 | public static function get_field( $form, $field_id ) { |
917 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
917 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
918 | 918 | return GFFormsModel::get_field( $form, $field_id ); |
919 | 919 | } else { |
920 | 920 | return null; |
@@ -961,19 +961,19 @@ discard block |
||
961 | 961 | $shortcodes = array(); |
962 | 962 | |
963 | 963 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
964 | - if ( empty( $matches ) ){ |
|
964 | + if ( empty( $matches ) ) { |
|
965 | 965 | return false; |
966 | 966 | } |
967 | 967 | |
968 | 968 | foreach ( $matches as $shortcode ) { |
969 | - if ( $tag === $shortcode[2] ) { |
|
969 | + if ( $tag === $shortcode[ 2 ] ) { |
|
970 | 970 | |
971 | 971 | // Changed this to $shortcode instead of true so we get the parsed atts. |
972 | - $shortcodes[] = $shortcode; |
|
972 | + $shortcodes[ ] = $shortcode; |
|
973 | 973 | |
974 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
975 | - foreach( $results as $result ) { |
|
976 | - $shortcodes[] = $result; |
|
974 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
975 | + foreach ( $results as $result ) { |
|
976 | + $shortcodes[ ] = $result; |
|
977 | 977 | } |
978 | 978 | } |
979 | 979 | } |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | public static function get_directory_fields( $post_id, $apply_filter = true ) { |
1118 | 1118 | $fields = get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
1119 | 1119 | |
1120 | - if( $apply_filter ) { |
|
1120 | + if ( $apply_filter ) { |
|
1121 | 1121 | /** |
1122 | 1122 | * @filter `gravityview/configuration/fields` Filter the View fields' configuration array |
1123 | 1123 | * @since 1.6.5 |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | * @return string html |
1141 | 1141 | */ |
1142 | 1142 | public static function get_sortable_fields( $formid, $current = '' ) { |
1143 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1143 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1144 | 1144 | |
1145 | 1145 | if ( empty( $formid ) ) { |
1146 | 1146 | return $output; |
@@ -1153,11 +1153,11 @@ discard block |
||
1153 | 1153 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1154 | 1154 | |
1155 | 1155 | foreach ( $fields as $id => $field ) { |
1156 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1156 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1157 | 1157 | continue; |
1158 | 1158 | } |
1159 | 1159 | |
1160 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1160 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1161 | 1161 | } |
1162 | 1162 | } |
1163 | 1163 | |
@@ -1192,9 +1192,9 @@ discard block |
||
1192 | 1192 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1193 | 1193 | |
1194 | 1194 | // TODO: Convert to using array_filter |
1195 | - foreach( $fields as $id => $field ) { |
|
1195 | + foreach ( $fields as $id => $field ) { |
|
1196 | 1196 | |
1197 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1197 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1198 | 1198 | unset( $fields[ $id ] ); |
1199 | 1199 | } |
1200 | 1200 | } |
@@ -1235,14 +1235,14 @@ discard block |
||
1235 | 1235 | * @param int|array $field field key or field array |
1236 | 1236 | * @return boolean |
1237 | 1237 | */ |
1238 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1238 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1239 | 1239 | |
1240 | 1240 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1241 | 1241 | $form = self::get_form( $form ); |
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | // If entry meta, it's a string. Otherwise, numeric |
1245 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1245 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1246 | 1246 | $type = $field; |
1247 | 1247 | } else { |
1248 | 1248 | $type = self::get_field_type( $form, $field ); |
@@ -1256,9 +1256,9 @@ discard block |
||
1256 | 1256 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1257 | 1257 | |
1258 | 1258 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1259 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1260 | - if( true === $gv_field->is_numeric ) { |
|
1261 | - $numeric_types[] = $gv_field->is_numeric; |
|
1259 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1260 | + if ( true === $gv_field->is_numeric ) { |
|
1261 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1262 | 1262 | } |
1263 | 1263 | } |
1264 | 1264 | |
@@ -1408,18 +1408,18 @@ discard block |
||
1408 | 1408 | $final_atts = array_filter( $final_atts ); |
1409 | 1409 | |
1410 | 1410 | // If the href wasn't passed as an attribute, use the value passed to the function |
1411 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1412 | - $final_atts['href'] = $href; |
|
1411 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1412 | + $final_atts[ 'href' ] = $href; |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1415 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1416 | 1416 | |
1417 | 1417 | /** |
1418 | 1418 | * Fix potential security issue with target=_blank |
1419 | 1419 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
1420 | 1420 | */ |
1421 | - if( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
1422 | - $final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1421 | + if ( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
1422 | + $final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1423 | 1423 | } |
1424 | 1424 | |
1425 | 1425 | // Sort the attributes alphabetically, to help testing |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1432 | 1432 | } |
1433 | 1433 | |
1434 | - if( '' !== $output ) { |
|
1434 | + if ( '' !== $output ) { |
|
1435 | 1435 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1436 | 1436 | } |
1437 | 1437 | |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1459 | 1459 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1460 | 1460 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
1461 | - $merged[] = $value; |
|
1461 | + $merged[ ] = $value; |
|
1462 | 1462 | } else { |
1463 | 1463 | $merged[ $key ] = $value; |
1464 | 1464 | } |
@@ -1491,7 +1491,7 @@ discard block |
||
1491 | 1491 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1492 | 1492 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1493 | 1493 | */ |
1494 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1494 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1495 | 1495 | |
1496 | 1496 | return get_users( $get_users_settings ); |
1497 | 1497 | } |
@@ -1506,7 +1506,7 @@ discard block |
||
1506 | 1506 | * @return string |
1507 | 1507 | */ |
1508 | 1508 | public static function generate_notice( $notice, $class = '' ) { |
1509 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1509 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1510 | 1510 | } |
1511 | 1511 | |
1512 | 1512 | /** |
@@ -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 | } |