@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | die; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -if( ! class_exists( '\GV\Gamajo_Template_Loader' ) ) { |
|
| 19 | +if ( ! class_exists( '\GV\Gamajo_Template_Loader' ) ) { |
|
| 20 | 20 | require( GRAVITYVIEW_DIR . 'future/lib/class-gamajo-template-loader.php' ); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | 'atts' => NULL, |
| 158 | 158 | ) ); |
| 159 | 159 | |
| 160 | - foreach ($atts as $key => $value) { |
|
| 161 | - if( is_null( $value ) ) { |
|
| 160 | + foreach ( $atts as $key => $value ) { |
|
| 161 | + if ( is_null( $value ) ) { |
|
| 162 | 162 | continue; |
| 163 | 163 | } |
| 164 | 164 | $this->{$key} = $value; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | static function getInstance( $passed_post = NULL ) { |
| 190 | 190 | |
| 191 | - if( empty( self::$instance ) ) { |
|
| 191 | + if ( empty( self::$instance ) ) { |
|
| 192 | 192 | self::$instance = new self( $passed_post ); |
| 193 | 193 | } |
| 194 | 194 | |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function getCurrentField( $key = NULL ) { |
| 203 | 203 | |
| 204 | - if( !empty( $key ) ) { |
|
| 205 | - if( isset( $this->_current_field[ $key ] ) ) { |
|
| 204 | + if ( ! empty( $key ) ) { |
|
| 205 | + if ( isset( $this->_current_field[ $key ] ) ) { |
|
| 206 | 206 | return $this->_current_field[ $key ]; |
| 207 | 207 | } |
| 208 | 208 | return NULL; |
@@ -213,16 +213,16 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | public function setCurrentFieldSetting( $key, $value ) { |
| 215 | 215 | |
| 216 | - if( !empty( $this->_current_field ) ) { |
|
| 217 | - $this->_current_field['field_settings'][ $key ] = $value; |
|
| 216 | + if ( ! empty( $this->_current_field ) ) { |
|
| 217 | + $this->_current_field[ 'field_settings' ][ $key ] = $value; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | public function getCurrentFieldSetting( $key ) { |
| 223 | - $settings = $this->getCurrentField('field_settings'); |
|
| 223 | + $settings = $this->getCurrentField( 'field_settings' ); |
|
| 224 | 224 | |
| 225 | - if( $settings && !empty( $settings[ $key ] ) ) { |
|
| 225 | + if ( $settings && ! empty( $settings[ $key ] ) ) { |
|
| 226 | 226 | return $settings[ $key ]; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | public function getAtts( $key = NULL ) { |
| 255 | 255 | |
| 256 | - if( !empty( $key ) ) { |
|
| 257 | - if( isset( $this->atts[ $key ] ) ) { |
|
| 256 | + if ( ! empty( $key ) ) { |
|
| 257 | + if ( isset( $this->atts[ $key ] ) ) { |
|
| 258 | 258 | return $this->atts[ $key ]; |
| 259 | 259 | } |
| 260 | 260 | return NULL; |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | $fields = empty( $this->fields ) ? NULL : $this->fields; |
| 322 | 322 | |
| 323 | - if( $fields && !empty( $key ) ) { |
|
| 323 | + if ( $fields && ! empty( $key ) ) { |
|
| 324 | 324 | $fields = isset( $fields[ $key ] ) ? $fields[ $key ] : NULL; |
| 325 | 325 | } |
| 326 | 326 | |
@@ -338,18 +338,18 @@ discard block |
||
| 338 | 338 | */ |
| 339 | 339 | public function getContextFields( $context = '' ) { |
| 340 | 340 | |
| 341 | - if( '' === $context ) { |
|
| 341 | + if ( '' === $context ) { |
|
| 342 | 342 | $context = $this->getContext(); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | $fields = $this->getFields(); |
| 346 | 346 | |
| 347 | - foreach ( (array) $fields as $key => $context_fields ) { |
|
| 347 | + foreach ( (array)$fields as $key => $context_fields ) { |
|
| 348 | 348 | |
| 349 | 349 | // Formatted as `{context}_{template id}-{zone name}`, so we want just the $context to match against |
| 350 | 350 | $matches = explode( '_', $key ); |
| 351 | 351 | |
| 352 | - if( isset( $matches[0] ) && $matches[0] === $context ) { |
|
| 352 | + if ( isset( $matches[ 0 ] ) && $matches[ 0 ] === $context ) { |
|
| 353 | 353 | return $context_fields; |
| 354 | 354 | } |
| 355 | 355 | } |
@@ -370,8 +370,8 @@ discard block |
||
| 370 | 370 | */ |
| 371 | 371 | public function getField( $key ) { |
| 372 | 372 | |
| 373 | - if( !empty( $key ) ) { |
|
| 374 | - if( isset( $this->fields[ $key ] ) ) { |
|
| 373 | + if ( ! empty( $key ) ) { |
|
| 374 | + if ( isset( $this->fields[ $key ] ) ) { |
|
| 375 | 375 | return $this->fields[ $key ]; |
| 376 | 376 | } |
| 377 | 377 | } |
@@ -477,8 +477,8 @@ discard block |
||
| 477 | 477 | public function getPaginationCounts() { |
| 478 | 478 | |
| 479 | 479 | $paging = $this->getPaging(); |
| 480 | - $offset = $paging['offset']; |
|
| 481 | - $page_size = $paging['page_size']; |
|
| 480 | + $offset = $paging[ 'offset' ]; |
|
| 481 | + $page_size = $paging[ 'page_size' ]; |
|
| 482 | 482 | $total = $this->getTotalEntries(); |
| 483 | 483 | |
| 484 | 484 | if ( empty( $total ) ) { |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | */ |
| 500 | 500 | list( $first, $last, $total ) = apply_filters( 'gravityview_pagination_counts', array( $first, $last, $total ) ); |
| 501 | 501 | |
| 502 | - return array( 'first' => (int) $first, 'last' => (int) $last, 'total' => (int) $total ); |
|
| 502 | + return array( 'first' => (int)$first, 'last' => (int)$last, 'total' => (int)$total ); |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | /** |
@@ -595,16 +595,16 @@ discard block |
||
| 595 | 595 | */ |
| 596 | 596 | public function getCurrentEntry() { |
| 597 | 597 | |
| 598 | - if( in_array( $this->getContext(), array( 'edit', 'single') ) ) { |
|
| 598 | + if ( in_array( $this->getContext(), array( 'edit', 'single' ) ) ) { |
|
| 599 | 599 | $entries = $this->getEntries(); |
| 600 | - $entry = $entries[0]; |
|
| 600 | + $entry = $entries[ 0 ]; |
|
| 601 | 601 | } else { |
| 602 | 602 | $entry = $this->_current_entry; |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | /** @since 1.16 Fixes DataTables empty entry issue */ |
| 606 | - if ( empty( $entry ) && ! empty( $this->_current_field['entry'] ) ) { |
|
| 607 | - $entry = $this->_current_field['entry']; |
|
| 606 | + if ( empty( $entry ) && ! empty( $this->_current_field[ 'entry' ] ) ) { |
|
| 607 | + $entry = $this->_current_field[ 'entry' ]; |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | return $entry; |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | public function renderZone( $zone = '', $atts = array(), $echo = true ) { |
| 645 | 645 | |
| 646 | 646 | if ( empty( $zone ) ) { |
| 647 | - gravityview()->log->error( 'No zone defined.'); |
|
| 647 | + gravityview()->log->error( 'No zone defined.' ); |
|
| 648 | 648 | return NULL; |
| 649 | 649 | } |
| 650 | 650 | |
@@ -653,16 +653,16 @@ discard block |
||
| 653 | 653 | 'context' => $this->getContext(), |
| 654 | 654 | 'entry' => $this->getCurrentEntry(), |
| 655 | 655 | 'form' => $this->getForm(), |
| 656 | - 'hide_empty' => $this->getAtts('hide_empty'), |
|
| 656 | + 'hide_empty' => $this->getAtts( 'hide_empty' ), |
|
| 657 | 657 | ); |
| 658 | 658 | |
| 659 | 659 | $final_atts = wp_parse_args( $atts, $defaults ); |
| 660 | 660 | |
| 661 | 661 | $output = ''; |
| 662 | 662 | |
| 663 | - $final_atts['zone_id'] = "{$final_atts['context']}_{$final_atts['slug']}-{$zone}"; |
|
| 663 | + $final_atts[ 'zone_id' ] = "{$final_atts[ 'context' ]}_{$final_atts[ 'slug' ]}-{$zone}"; |
|
| 664 | 664 | |
| 665 | - $fields = $this->getField( $final_atts['zone_id'] ); |
|
| 665 | + $fields = $this->getField( $final_atts[ 'zone_id' ] ); |
|
| 666 | 666 | |
| 667 | 667 | // Backward compatibility |
| 668 | 668 | if ( 'table' === $this->getTemplatePartSlug() ) { |
@@ -672,19 +672,19 @@ discard block |
||
| 672 | 672 | * @param \GravityView_View $this |
| 673 | 673 | * @deprecated Use `gravityview/template/table/fields` |
| 674 | 674 | */ |
| 675 | - $fields = apply_filters("gravityview_table_cells", $fields, $this ); |
|
| 675 | + $fields = apply_filters( "gravityview_table_cells", $fields, $this ); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | if ( empty( $fields ) ) { |
| 679 | 679 | |
| 680 | - gravityview()->log->error( 'Empty zone configuration for {zone_id}.', array( 'zone_id' => $final_atts['zone_id'] ) ); |
|
| 680 | + gravityview()->log->error( 'Empty zone configuration for {zone_id}.', array( 'zone_id' => $final_atts[ 'zone_id' ] ) ); |
|
| 681 | 681 | |
| 682 | 682 | return NULL; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | $field_output = ''; |
| 686 | 686 | foreach ( $fields as $field ) { |
| 687 | - $final_atts['field'] = $field; |
|
| 687 | + $final_atts[ 'field' ] = $field; |
|
| 688 | 688 | |
| 689 | 689 | $field_output .= gravityview_field_output( $final_atts ); |
| 690 | 690 | } |
@@ -701,17 +701,17 @@ discard block |
||
| 701 | 701 | return NULL; |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 705 | - $output .= '<div class="'.gravityview_sanitize_html_class( $final_atts['wrapper_class'] ).'">'; |
|
| 704 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
| 705 | + $output .= '<div class="' . gravityview_sanitize_html_class( $final_atts[ 'wrapper_class' ] ) . '">'; |
|
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | $output .= $field_output; |
| 709 | 709 | |
| 710 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 710 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
| 711 | 711 | $output .= '</div>'; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - if( $echo ) { |
|
| 714 | + if ( $echo ) { |
|
| 715 | 715 | echo $output; |
| 716 | 716 | } |
| 717 | 717 | |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | */ |
| 730 | 730 | function locate_template( $template_names, $load = false, $require_once = true ) { |
| 731 | 731 | |
| 732 | - if( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
| 732 | + if ( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
| 733 | 733 | |
| 734 | 734 | $located = $this->located_templates[ $template_names ]; |
| 735 | 735 | |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | // Set $load to always false so we handle it here. |
| 739 | 739 | $located = parent::locate_template( $template_names, false, $require_once ); |
| 740 | 740 | |
| 741 | - if( is_string( $template_names ) ) { |
|
| 741 | + if ( is_string( $template_names ) ) { |
|
| 742 | 742 | $this->located_templates[ $template_names ] = $located; |
| 743 | 743 | } |
| 744 | 744 | } |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | * @return mixed|null The stored data. |
| 757 | 757 | */ |
| 758 | 758 | public function __get( $name ) { |
| 759 | - if( isset( $this->{$name} ) ) { |
|
| 759 | + if ( isset( $this->{$name} ) ) { |
|
| 760 | 760 | return $this->{$name}; |
| 761 | 761 | } else { |
| 762 | 762 | return NULL; |
@@ -785,17 +785,17 @@ discard block |
||
| 785 | 785 | $additional = array(); |
| 786 | 786 | |
| 787 | 787 | // form-19-table-body.php |
| 788 | - $additional[] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
| 788 | + $additional[ ] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
| 789 | 789 | |
| 790 | - if( $view_id = $this->getViewId() ) { |
|
| 790 | + if ( $view_id = $this->getViewId() ) { |
|
| 791 | 791 | // view-3-table-body.php |
| 792 | - $additional[] = sprintf( 'view-%d-%s-%s.php', $view_id, $slug, $name ); |
|
| 792 | + $additional[ ] = sprintf( 'view-%d-%s-%s.php', $view_id, $slug, $name ); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | - if( $this->getPostId() ) { |
|
| 795 | + if ( $this->getPostId() ) { |
|
| 796 | 796 | |
| 797 | 797 | // page-19-table-body.php |
| 798 | - $additional[] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
| 798 | + $additional[ ] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | // Combine with existing table-body.php and table.php |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | |
| 818 | 818 | gravityview()->log->debug( 'Rendering Template File: {path}', array( 'path' => $template_file ) ); |
| 819 | 819 | |
| 820 | - if( !empty( $template_file) ) { |
|
| 820 | + if ( ! empty( $template_file ) ) { |
|
| 821 | 821 | |
| 822 | 822 | if ( $require_once ) { |
| 823 | 823 | require_once( $template_file ); |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | |
| 893 | 893 | // Prevent being called twice |
| 894 | 894 | if ( did_action( "gravityview/widgets/$zone/{$view->ID}/rendered" ) ) { |
| 895 | - gravityview()->log->debug( 'Not rendering {zone}; already rendered', array( 'zone' => $zone.'_'.$view->ID.'_widgets' ) ); |
|
| 895 | + gravityview()->log->debug( 'Not rendering {zone}; already rendered', array( 'zone' => $zone . '_' . $view->ID . '_widgets' ) ); |
|
| 896 | 896 | return; |
| 897 | 897 | } |
| 898 | 898 | |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | * @param string $zone Current widget zone, either `header` or `footer` |
| 915 | 915 | * @param array $widgets Array of widget configurations for the current zone, as set by `gravityview_get_current_view_data()['widgets']` |
| 916 | 916 | */ |
| 917 | - $css_class = apply_filters('gravityview/widgets/wrapper_css_class', $default_css_class, $zone, $widgets->as_configuration() ); |
|
| 917 | + $css_class = apply_filters( 'gravityview/widgets/wrapper_css_class', $default_css_class, $zone, $widgets->as_configuration() ); |
|
| 918 | 918 | |
| 919 | 919 | $css_class = gravityview_sanitize_html_class( $css_class ); |
| 920 | 920 | |
@@ -922,15 +922,15 @@ discard block |
||
| 922 | 922 | ?> |
| 923 | 923 | <div class="<?php echo $css_class; ?>"> |
| 924 | 924 | <?php |
| 925 | - foreach( $rows as $row ) { |
|
| 926 | - foreach( $row as $col => $areas ) { |
|
| 925 | + foreach ( $rows as $row ) { |
|
| 926 | + foreach ( $row as $col => $areas ) { |
|
| 927 | 927 | $column = ( $col == '2-2' ) ? '1-2 gv-right' : "$col gv-left"; |
| 928 | 928 | ?> |
| 929 | 929 | <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
| 930 | 930 | <?php |
| 931 | 931 | if ( ! empty( $areas ) ) { |
| 932 | 932 | foreach ( $areas as $area ) { |
| 933 | - foreach ( $widgets->by_position( $zone . '_' . $area['areaid'] )->all() as $widget ) { |
|
| 933 | + foreach ( $widgets->by_position( $zone . '_' . $area[ 'areaid' ] )->all() as $widget ) { |
|
| 934 | 934 | do_action( sprintf( 'gravityview/widgets/%s/render', $widget->get_widget_id() ), $widget->configuration->all(), null, $view_id_or_context ); |
| 935 | 935 | } |
| 936 | 936 | } |