WooCommerce Products Per Page - Version 1.2.6

Version Description

  • 06/02/2018 =

  • [Critical] - Fix bug that displays 0 products on shop page on WC 3.3.1

Download this release

Release Info

Developer sormano
Plugin Icon 128x128 WooCommerce Products Per Page
Version 1.2.6
Comparing to
See all releases

Code changes from version 1.2.5 to 1.2.6

includes/class-wppp-front-end.php CHANGED
@@ -35,10 +35,7 @@ class WPPP_Front_End {
35
  add_filter( 'loop_shop_columns', array( $this, 'loop_shop_columns' ), 100 );
36
 
37
  // Custom number of products per page
38
- add_filter( 'loop_shop_per_page', array( $this, 'loop_shop_per_page' ), 100 );
39
-
40
- // Get the right amount of products from the DB
41
- add_action( 'woocommerce_product_query', array( $this, 'woocommerce_product_query' ), 2, 50 );
42
 
43
  // Check if ppp form is fired
44
  add_action( 'init', array( $this, 'products_per_page_action' ) );
@@ -91,7 +88,7 @@ class WPPP_Front_End {
91
 
92
  foreach( $products_per_page_options as $key => $value ) :
93
 
94
- ?><option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, $this->loop_shop_per_page() ); ?>><?php
95
  $ppp_text = apply_filters( 'wppp_ppp_text', __( '%s products per page', 'woocommerce-products-per-page' ), $value );
96
  esc_html( printf( $ppp_text, $value == -1 ? __( 'All', 'woocommerce-products-per-page' ) : $value ) ); // Set to 'All' when value is -1
97
  ?></option><?php
@@ -154,18 +151,20 @@ class WPPP_Front_End {
154
  *
155
  * @return int Products per page.
156
  */
157
- public function loop_shop_per_page() {
158
 
159
  if ( isset( $_REQUEST['wppp_ppp'] ) ) :
160
- return intval( $_REQUEST['wppp_ppp'] );
161
  elseif ( isset( $_REQUEST['ppp'] ) ) :
162
- return intval( $_REQUEST['ppp'] );
163
  elseif ( isset( $_COOKIE['woocommerce_products_per_page'] ) ) :
164
- return $_COOKIE['woocommerce_products_per_page'];
165
  else :
166
- return intval( get_option( 'wppp_default_ppp', '12' ) );
167
  endif;
168
 
 
 
169
  }
170
 
171
 
35
  add_filter( 'loop_shop_columns', array( $this, 'loop_shop_columns' ), 100 );
36
 
37
  // Custom number of products per page
38
+ add_filter( 'loop_shop_per_page', array( $this, 'loop_shop_per_page' ), 100, 1 );
 
 
 
39
 
40
  // Check if ppp form is fired
41
  add_action( 'init', array( $this, 'products_per_page_action' ) );
88
 
89
  foreach( $products_per_page_options as $key => $value ) :
90
 
91
+ ?><option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, $this->loop_shop_per_page( 12 ) ); ?>><?php
92
  $ppp_text = apply_filters( 'wppp_ppp_text', __( '%s products per page', 'woocommerce-products-per-page' ), $value );
93
  esc_html( printf( $ppp_text, $value == -1 ? __( 'All', 'woocommerce-products-per-page' ) : $value ) ); // Set to 'All' when value is -1
94
  ?></option><?php
151
  *
152
  * @return int Products per page.
153
  */
154
+ public function loop_shop_per_page( $per_page ) {
155
 
156
  if ( isset( $_REQUEST['wppp_ppp'] ) ) :
157
+ $per_page = intval( $_REQUEST['wppp_ppp'] );
158
  elseif ( isset( $_REQUEST['ppp'] ) ) :
159
+ $per_page = intval( $_REQUEST['ppp'] );
160
  elseif ( isset( $_COOKIE['woocommerce_products_per_page'] ) ) :
161
+ $per_page = $_COOKIE['woocommerce_products_per_page'];
162
  else :
163
+ $per_page = intval( get_option( 'wppp_default_ppp', '12' ) );
164
  endif;
165
 
166
+ return $per_page;
167
+
168
  }
169
 
170
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: sormano
3
  Tags: woocommerce, products per page, woocommerce products, woocommerce products per page, products, per page
4
  Requires at least: 4.0.0
5
- Tested up to: 4.9
6
- Stable tag: 1.2.5
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -69,6 +69,10 @@ Feel free to open a support thread if you need any further help. Please do note
69
 
70
  == Changelog ==
71
 
 
 
 
 
72
  = 1.2.5 - 20/11/2017 =
73
 
74
  * [Fix] - Accidentally overwrote the changes of 1.2.3 in version 1.2.4, this re-applies those changes. Sorry for the inconvenience.
2
  Contributors: sormano
3
  Tags: woocommerce, products per page, woocommerce products, woocommerce products per page, products, per page
4
  Requires at least: 4.0.0
5
+ Tested up to: 4.9.4
6
+ Stable tag: 1.2.6
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
69
 
70
  == Changelog ==
71
 
72
+ = 1.2.6 - 06/02/2018 =
73
+
74
+ * [Critical] - Fix bug that displays 0 products on shop page on WC 3.3.1
75
+
76
  = 1.2.5 - 20/11/2017 =
77
 
78
  * [Fix] - Accidentally overwrote the changes of 1.2.3 in version 1.2.4, this re-applies those changes. Sorry for the inconvenience.
woocommerce-products-per-page.php CHANGED
@@ -3,9 +3,12 @@
3
  * Plugin Name: Woocommerce Products Per Page
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-products-per-page/
5
  * Description: Integrate a 'products per page' dropdown on your WooCommerce website! Set-up in <strong>seconds</strong>!
6
- * Version: 1.2.5
7
  * Author: Jeroen Sormani
8
  * Author URI: http://jeroensormani.com
 
 
 
9
 
10
  * Copyright Jeroen Sormani
11
  *
@@ -47,7 +50,7 @@ class Woocommerce_Products_Per_Page {
47
  * @since 1.2.0
48
  * @var string $version Plugin version number.
49
  */
50
- public $version = '1.2.5';
51
 
52
 
53
  /**
@@ -67,15 +70,11 @@ class Woocommerce_Products_Per_Page {
67
  */
68
  public function __construct() {
69
 
70
- if ( ! function_exists( 'is_plugin_active_for_network' ) ) :
71
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
72
- endif;
73
-
74
- if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) :
75
- if ( ! is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) :
76
- return;
77
- endif;
78
- endif;
79
 
80
  $this->init();
81
 
@@ -217,7 +216,7 @@ class Woocommerce_Products_Per_Page {
217
 
218
  if ( $file == plugin_basename( __FILE__ ) ) :
219
  $links = array_merge( array(
220
- '<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=products&section=display#s2id_wppp_dropdown_location' ) ) . '">' . __( 'Settings', 'woocommerce-products-per-page' ) . '</a>'
221
  ), $links );
222
  endif;
223
 
3
  * Plugin Name: Woocommerce Products Per Page
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-products-per-page/
5
  * Description: Integrate a 'products per page' dropdown on your WooCommerce website! Set-up in <strong>seconds</strong>!
6
+ * Version: 1.2.6
7
  * Author: Jeroen Sormani
8
  * Author URI: http://jeroensormani.com
9
+ *
10
+ * WC requires at least: 3.1.0
11
+ * WC tested up to: 3.3.0
12
 
13
  * Copyright Jeroen Sormani
14
  *
50
  * @since 1.2.0
51
  * @var string $version Plugin version number.
52
  */
53
+ public $version = '1.2.6';
54
 
55
 
56
  /**
70
  */
71
  public function __construct() {
72
 
73
+ // Check if WooCommerce is active
74
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
75
+ if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) && ! function_exists( 'WC' ) ) {
76
+ return;
77
+ }
 
 
 
 
78
 
79
  $this->init();
80
 
216
 
217
  if ( $file == plugin_basename( __FILE__ ) ) :
218
  $links = array_merge( array(
219
+ '<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=products&section=display#s2id_wppp_dropdown_location' ) ) . '">' . __( 'Settings', 'woocommerce-products-per-page' ) . '</a>'
220
  ), $links );
221
  endif;
222