WooCommerce Products Per Page - Version 1.0.1

Version Description

  • Small update for cookies
Download this release

Release Info

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

Code changes from version 1.0.2 to 1.0.1

objects/wppp-dropdown.php CHANGED
@@ -28,12 +28,11 @@ class wppp_dropdown extends woocommerce_products_per_page {
28
  <select name="wppp_ppp" onchange="this.form.submit()" class="select wppp-select">
29
 
30
  <?php
31
- global $woocommerce;
32
  foreach( $this->productsPerPage as $key => $value ) :
33
- $selectedMatch = isset( $_POST["wppp_ppp"] ) ? $_POST["wppp_ppp"] : $woocommerce->session->get( "products_per_page" );
34
  ?>
35
  <option value="<?php echo $value; ?>" <?php selected( $value, $selectedMatch ); ?>>
36
- <?php printf( __( "%s products per page", "wppp" ), $value==-1?__( "All", "wppp" ) : $value ) ?>
37
  </option>
38
  <?php
39
  endforeach;
28
  <select name="wppp_ppp" onchange="this.form.submit()" class="select wppp-select">
29
 
30
  <?php
 
31
  foreach( $this->productsPerPage as $key => $value ) :
32
+ $selectedMatch = isset( $_POST["wppp_ppp"] ) ? $_POST["wppp_ppp"] : $_COOKIE["products_per_page"];
33
  ?>
34
  <option value="<?php echo $value; ?>" <?php selected( $value, $selectedMatch ); ?>>
35
+ <?php printf( __( "%s products per page", "wppp" ), $value==-1?"All" : $value ) ?>
36
  </option>
37
  <?php
38
  endforeach;
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === WooCommerce Products Per Page ===
2
  Contributors: sormano
3
- Tags: Products per page, woocommerce, woocommerce products, woocommerce products per page, woocommerce displayed products, woocommerce quantity products, woocommerce amount of products, woocommerce number of products, woocommerce shown products
4
  Requires at least: 3.0.1
5
  Tested up to: 3.8.1
6
- Stable tag: 1.0.2
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -13,10 +13,11 @@ WooCommerce Products Per Page is a easy-to-setup plugin that integrates a 'produ
13
  WooCommerce Products Per Page dropdown is easy to install and has several other product page configurations. When activated the plugin already works and has multiple settings you can set to your desire.
14
 
15
  Options like:
16
- - Dropdown position (top or bottom, top and bottom)
17
- - List op options products per page to show to your visitors
18
- - Default number of products per page
19
- - Columns per page
 
20
 
21
  **Look at the screenshots!**
22
 
@@ -36,12 +37,6 @@ Options like:
36
 
37
  == Changelog ==
38
 
39
- = 1.0.2 =
40
- * - Added Dutch translation*
41
- * - Added 'None' to the dropdown locations*
42
- * - Now uses WC sessions instead of cookies*
43
- * - Gave higher priority to hook "loop_shop_per_page"*
44
-
45
  = 1.0.1 =
46
  * Small update for cookies
47
 
1
  === WooCommerce Products Per Page ===
2
  Contributors: sormano
3
+ Tags: Products per page, woocommerce, woocommerce products, woocommerce products per page, woocommerce displayed products, woocommerce quantity products, woocommerce amount of products, woocommerce number of products, woocommerce shown products, woocommerce columns
4
  Requires at least: 3.0.1
5
  Tested up to: 3.8.1
6
+ Stable tag: 1.0.1
7
  License: GPLv3 or later
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
13
  WooCommerce Products Per Page dropdown is easy to install and has several other product page configurations. When activated the plugin already works and has multiple settings you can set to your desire.
14
 
15
  Options like:
16
+
17
+ * Dropdown position (top or bottom, top and bottom)
18
+ * List op options products per page to show to your visitors
19
+ * Default number of products per page
20
+ * Columns per page
21
 
22
  **Look at the screenshots!**
23
 
37
 
38
  == Changelog ==
39
 
 
 
 
 
 
 
40
  = 1.0.1 =
41
  * Small update for cookies
42
 
views/options-page.php CHANGED
@@ -32,7 +32,7 @@ class wppp_options extends woocommerce_products_per_page {
32
  // 3. Add settings section
33
  add_settings_section(
34
  "wppp_settings", // ID of section
35
- "WooCommerce Products Per Page", // Page title
36
  array( $this, "wppp_section_callback" ), // Callback for page description
37
  "wppp_settings" // Page to display settings
38
  );
@@ -103,7 +103,6 @@ class wppp_options extends woocommerce_products_per_page {
103
  <option value="top" <?php selected( $this->options["location"], "top" ); ?>><?php _e( "Top", "wppp" ); ?></option>
104
  <option value="bottom" <?php selected( $this->options["location"], "bottom" ); ?>><?php _e( "Bottom", "wppp" ); ?></option>
105
  <option value="topbottom" <?php selected( $this->options["location"], "topbottom" ); ?>><?php _e( "Top/Bottom", "wppp" ); ?></option>
106
- <option value="none" <?php selected( $this->options["location"], "none" ); ?>><?php _e( "None", "wppp" ); ?></option>
107
  </select>
108
  <?php
109
 
@@ -115,7 +114,7 @@ class wppp_options extends woocommerce_products_per_page {
115
  ?>
116
  <label for="productsPerPage">
117
  <input type="text" id="productsPerPage" name="wppp_settings[productsPerPage]" value="<?php echo $this->options["productsPerPage"]; ?>">
118
- <?php _e( "Seperated by spaces <em>(-1 for all products)</em>", "wppp" ); ?></label>
119
  <?php
120
 
121
  }
@@ -145,7 +144,7 @@ class wppp_options extends woocommerce_products_per_page {
145
 
146
  public function wppp_section_callback() {
147
 
148
- echo __( "Configure the WooCommerce Product Per Page settings here.", "wppp" );
149
 
150
  }
151
 
32
  // 3. Add settings section
33
  add_settings_section(
34
  "wppp_settings", // ID of section
35
+ __( "WooCommerce Products Per Page", "wppp" ), // Page title
36
  array( $this, "wppp_section_callback" ), // Callback for page description
37
  "wppp_settings" // Page to display settings
38
  );
103
  <option value="top" <?php selected( $this->options["location"], "top" ); ?>><?php _e( "Top", "wppp" ); ?></option>
104
  <option value="bottom" <?php selected( $this->options["location"], "bottom" ); ?>><?php _e( "Bottom", "wppp" ); ?></option>
105
  <option value="topbottom" <?php selected( $this->options["location"], "topbottom" ); ?>><?php _e( "Top/Bottom", "wppp" ); ?></option>
 
106
  </select>
107
  <?php
108
 
114
  ?>
115
  <label for="productsPerPage">
116
  <input type="text" id="productsPerPage" name="wppp_settings[productsPerPage]" value="<?php echo $this->options["productsPerPage"]; ?>">
117
+ <?php _e( "Seperated by spaces <em>(-1 for all products</em>)", "wppp" ); ?></label>
118
  <?php
119
 
120
  }
144
 
145
  public function wppp_section_callback() {
146
 
147
+ echo __( "Configure the Wordpress Product Per Page settings here.", "wppp" );
148
 
149
  }
150
 
woocommerce-products-per-page.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Woocommerce Products Per Page
4
  Plugin URI: http://www.jeroensormani.nl/
5
  Description: Integrate a 'products per page' dropdown on your WooCommerce website! Set-up in <strong>seconds</strong>!
6
- Version: 1.0.2
7
  Author: Jeroen Sormani
8
  Author URI: http://www.jeroensormani.nl
9
 
@@ -46,13 +46,11 @@ class woocommerce_products_per_page {
46
  add_action( "init", array( $this, "wppp_submit_intercept" ) );
47
 
48
  // Add filter to products per page displayed
49
- add_filter( "loop_shop_per_page", array( $this, "wppp_products_per_page_hook" ), 90 );
50
  // Add filter for product columns
51
  add_filter( "loop_shop_columns", array( $this, "wppp_shop_columns_hook" ) );
52
  // Enqueue some scripts
53
  add_action( "wp_enqueue_scripts", array( $this, "wppp_enqueue_scripts" ) );
54
- // Load textdomain
55
- load_plugin_textdomain( "wppp", false, basename( dirname( __FILE__ ) ) . '/languages' );
56
 
57
  }
58
 
@@ -66,7 +64,7 @@ class woocommerce_products_per_page {
66
  add_action( "woocommerce_before_shop_loop", array( $this, "wppp_dropdown_object" ) );
67
  elseif( $this->options["location"] == "bottom" ) :
68
  add_action( "woocommerce_after_shop_loop", array( $this, "wppp_dropdown_object" ) );
69
- elseif( $this->options["location"] == "topbottom" ):
70
  add_action( "woocommerce_before_shop_loop", array( $this, "wppp_dropdown_object" ) );
71
  add_action( "woocommerce_after_shop_loop", array( $this, "wppp_dropdown_object" ) );
72
  endif;
@@ -80,24 +78,18 @@ class woocommerce_products_per_page {
80
  */
81
  public function wppp_submit_intercept() {
82
 
83
- global $woocommerce;
84
-
85
- if ( isset( $_POST["wppp_ppp"] ) ) {
86
- $woocommerce->session->set( "products_per_page", $_POST["wppp_ppp"] );
87
- $woocommerce->session->set_customer_session_cookie( true );
88
- }
89
 
90
  }
91
 
92
 
93
  public function wppp_products_per_page_hook() {
94
-
95
- global $woocommerce;
96
 
97
  if( isset( $_POST["wppp_ppp"] ) )
98
  return $_POST["wppp_ppp"];
99
- elseif( $woocommerce->session->__isset( "products_per_page" ) )
100
- return $woocommerce->session->__get( "products_per_page" );
101
  else
102
  return $this->options["default_ppp"];
103
 
@@ -139,7 +131,7 @@ class woocommerce_products_per_page {
139
  */
140
  public function wppp_options_page() {
141
 
142
- require_once plugin_dir_path( __FILE__ ) . "views/options-page.php";
143
  new wppp_options();
144
 
145
  }
@@ -151,7 +143,7 @@ class woocommerce_products_per_page {
151
  */
152
  public function wppp_dropdown_object() {
153
 
154
- require_once plugin_dir_path( __FILE__ ) . "objects/wppp-dropdown.php";
155
  new wppp_dropdown();
156
 
157
  }
3
  Plugin Name: Woocommerce Products Per Page
4
  Plugin URI: http://www.jeroensormani.nl/
5
  Description: Integrate a 'products per page' dropdown on your WooCommerce website! Set-up in <strong>seconds</strong>!
6
+ Version: 1.0.1
7
  Author: Jeroen Sormani
8
  Author URI: http://www.jeroensormani.nl
9
 
46
  add_action( "init", array( $this, "wppp_submit_intercept" ) );
47
 
48
  // Add filter to products per page displayed
49
+ add_filter( "loop_shop_per_page", array( $this, "wppp_products_per_page_hook" ) );
50
  // Add filter for product columns
51
  add_filter( "loop_shop_columns", array( $this, "wppp_shop_columns_hook" ) );
52
  // Enqueue some scripts
53
  add_action( "wp_enqueue_scripts", array( $this, "wppp_enqueue_scripts" ) );
 
 
54
 
55
  }
56
 
64
  add_action( "woocommerce_before_shop_loop", array( $this, "wppp_dropdown_object" ) );
65
  elseif( $this->options["location"] == "bottom" ) :
66
  add_action( "woocommerce_after_shop_loop", array( $this, "wppp_dropdown_object" ) );
67
+ else :
68
  add_action( "woocommerce_before_shop_loop", array( $this, "wppp_dropdown_object" ) );
69
  add_action( "woocommerce_after_shop_loop", array( $this, "wppp_dropdown_object" ) );
70
  endif;
78
  */
79
  public function wppp_submit_intercept() {
80
 
81
+ if ( isset( $_POST["wppp_ppp"] ) )
82
+ setcookie( "products_per_page", $_POST["wppp_ppp"], time()+(3600*24*3), "/" );
 
 
 
 
83
 
84
  }
85
 
86
 
87
  public function wppp_products_per_page_hook() {
 
 
88
 
89
  if( isset( $_POST["wppp_ppp"] ) )
90
  return $_POST["wppp_ppp"];
91
+ elseif( isset( $_COOKIE["products_per_page"] ) )
92
+ return $_COOKIE["products_per_page"];
93
  else
94
  return $this->options["default_ppp"];
95
 
131
  */
132
  public function wppp_options_page() {
133
 
134
+ require_once "views/options-page.php";
135
  new wppp_options();
136
 
137
  }
143
  */
144
  public function wppp_dropdown_object() {
145
 
146
+ require_once "objects/wppp-dropdown.php";
147
  new wppp_dropdown();
148
 
149
  }