@@ -795,6 +795,7 @@ |
||
| 795 | 795 | * Retrieve the entries for the current view and request. |
| 796 | 796 | * |
| 797 | 797 | * @param \GV\Request The request. Unused for now. |
| 798 | + * @param Request $request |
|
| 798 | 799 | * |
| 799 | 800 | * @return \GV\Entry_Collection The entries. |
| 800 | 801 | */ |
@@ -20,16 +20,16 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | function gravityview_register_gravityview_widgets() { |
| 22 | 22 | |
| 23 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' ); |
|
| 23 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget.php' ); |
|
| 24 | 24 | |
| 25 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget-pagination-info.php' ); |
|
| 26 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget-page-links.php' ); |
|
| 27 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget-page-size.php' ); |
|
| 28 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget-custom-content.php' ); |
|
| 29 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/search-widget/class-search-widget.php' ); |
|
| 25 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget-pagination-info.php' ); |
|
| 26 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget-page-links.php' ); |
|
| 27 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget-page-size.php' ); |
|
| 28 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget-custom-content.php' ); |
|
| 29 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/search-widget/class-search-widget.php' ); |
|
| 30 | 30 | |
| 31 | - if( class_exists('GFPolls') ) { |
|
| 32 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/poll/class-gravityview-widget-poll.php' ); |
|
| 31 | + if ( class_exists( 'GFPolls' ) ) { |
|
| 32 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/poll/class-gravityview-widget-poll.php' ); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Render the page size widget |
| 77 | - * |
|
| 77 | + * |
|
| 78 | 78 | * @param array $widget_args The Widget shortcode args. |
| 79 | 79 | * @param string $content The content. |
| 80 | 80 | * @param string|\GV\Template_Context $context The context, if available. |
@@ -115,14 +115,14 @@ discard block |
||
| 115 | 115 | <?php } ?> |
| 116 | 116 | </select> |
| 117 | 117 | <input type="submit" value="Submit" style="visibility: hidden; position: absolute;" /><?php |
| 118 | - if( ! empty( $_GET ) ) { |
|
| 119 | - $get = $_GET; |
|
| 120 | - unset( $get['page_size'] ); |
|
| 121 | - foreach ( $get as $key => $value ) { |
|
| 122 | - printf( '<input type="hidden" name="%s" value="%s" />', esc_attr( $key ), esc_attr( $value ) ); |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - ?> |
|
| 118 | + if( ! empty( $_GET ) ) { |
|
| 119 | + $get = $_GET; |
|
| 120 | + unset( $get['page_size'] ); |
|
| 121 | + foreach ( $get as $key => $value ) { |
|
| 122 | + printf( '<input type="hidden" name="%s" value="%s" />', esc_attr( $key ), esc_attr( $value ) ); |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + ?> |
|
| 126 | 126 | </div> |
| 127 | 127 | </form> |
| 128 | 128 | </div> |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $default_size = 25; |
| 46 | 46 | |
| 47 | 47 | if ( $context instanceof \GV\Template_Context ) { |
| 48 | - $default_size = (int) $context->view->settings->get( 'page_size' ); |
|
| 48 | + $default_size = (int)$context->view->settings->get( 'page_size' ); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $sizes = array( 10, 25, $default_size, 50, 100 ); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $page_sizes = array(); |
| 58 | 58 | foreach ( $sizes as $size ) { |
| 59 | - $page_sizes [] = array( |
|
| 59 | + $page_sizes [ ] = array( |
|
| 60 | 60 | 'value' => $size, |
| 61 | 61 | 'text' => $size |
| 62 | 62 | ); |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function render_frontend( $widget_args, $content = '', $context = null ) { |
| 83 | 83 | |
| 84 | - if( ! $this->pre_render_frontend() ) { |
|
| 84 | + if ( ! $this->pre_render_frontend() ) { |
|
| 85 | 85 | return; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - $page_size = (int) \GV\Utils::_GET( 'page_size', $context->view->settings->get( 'page_size' ) ); |
|
| 88 | + $page_size = (int)\GV\Utils::_GET( 'page_size', $context->view->settings->get( 'page_size' ) ); |
|
| 89 | 89 | |
| 90 | 90 | $settings = shortcode_atts( array( |
| 91 | 91 | 'label' => __( 'Page Size', 'gravityview' ), |
@@ -104,20 +104,20 @@ discard block |
||
| 104 | 104 | <div class="gv-widget-page-size"> |
| 105 | 105 | <form method="get" action="<?php echo esc_url( add_query_arg( array() ) ); ?>" onchange="this.submit();"> |
| 106 | 106 | <div> |
| 107 | - <?php if( ! empty( $settings['label'] ) ) { ?> |
|
| 108 | - <label for="gv-page_size"><?php echo esc_html( $settings['label'] ); ?></label> |
|
| 107 | + <?php if ( ! empty( $settings[ 'label' ] ) ) { ?> |
|
| 108 | + <label for="gv-page_size"><?php echo esc_html( $settings[ 'label' ] ); ?></label> |
|
| 109 | 109 | <?php } ?> |
| 110 | 110 | <select name="page_size" id="gv-page_size"> |
| 111 | - <option value=""><?php echo esc_html( $settings['default_choice_text'] ); ?></option> |
|
| 111 | + <option value=""><?php echo esc_html( $settings[ 'default_choice_text' ] ); ?></option> |
|
| 112 | 112 | <?php |
| 113 | - foreach ( $settings['choices'] as $choice ) { ?> |
|
| 114 | - <option value='<?php echo esc_attr( $choice['value'] ); ?>'<?php gv_selected( esc_attr( $choice['value'] ), esc_attr( $page_size ), true ); ?>><?php echo esc_html( $choice['text'] ); ?></option> |
|
| 113 | + foreach ( $settings[ 'choices' ] as $choice ) { ?> |
|
| 114 | + <option value='<?php echo esc_attr( $choice[ 'value' ] ); ?>'<?php gv_selected( esc_attr( $choice[ 'value' ] ), esc_attr( $page_size ), true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option> |
|
| 115 | 115 | <?php } ?> |
| 116 | 116 | </select> |
| 117 | 117 | <input type="submit" value="Submit" style="visibility: hidden; position: absolute;" /><?php |
| 118 | - if( ! empty( $_GET ) ) { |
|
| 118 | + if ( ! empty( $_GET ) ) { |
|
| 119 | 119 | $get = $_GET; |
| 120 | - unset( $get['page_size'] ); |
|
| 120 | + unset( $get[ 'page_size' ] ); |
|
| 121 | 121 | foreach ( $get as $key => $value ) { |
| 122 | 122 | printf( '<input type="hidden" name="%s" value="%s" />', esc_attr( $key ), esc_attr( $value ) ); |
| 123 | 123 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // Already overridden |
| 153 | - if ( (int) $page_size === (int) $view->settings->get( 'page_size' ) ) { |
|
| 153 | + if ( (int)$page_size === (int)$view->settings->get( 'page_size' ) ) { |
|
| 154 | 154 | return; |
| 155 | 155 | } |
| 156 | 156 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | 'view' => $view, |
| 159 | 159 | ) ); |
| 160 | 160 | |
| 161 | - if ( ! in_array( (int) $page_size, wp_list_pluck( self::get_page_sizes( $context ), 'value' ), true ) ) { |
|
| 161 | + if ( ! in_array( (int)$page_size, wp_list_pluck( self::get_page_sizes( $context ), 'value' ), true ) ) { |
|
| 162 | 162 | gravityview()->log->warning( 'The passed page size is not allowed: {page_size}. Not modifying result.', array( 'page_size' => $page_size ) ); |
| 163 | 163 | return; |
| 164 | 164 | } |