Version Description
18/08/2014 * Proper translation for 'All' * Products in admin area aren't influenced anymore * Removed unneeded comments
Download this release
Release Info
Developer | sormano |
Plugin | WooCommerce Products Per Page |
Version | 1.1.1 |
Comparing to | |
See all releases |
Code changes from version 1.1.0.1 to 1.1.1
- includes/class-wppp-dropdown.php +32 -40
- includes/class-wppp-settings.php +57 -80
- languages/{wppp-fa_IR.mo → woocommerce-products-per-page-fa_IR.mo} +0 -0
- languages/{wppp-fa_IR.po → woocommerce-products-per-page-fa_IR.po} +0 -0
- languages/{wppp-fr_FR.mo → woocommerce-products-per-page-fr_FR.mo} +0 -0
- languages/{wppp-fr_FR.po → woocommerce-products-per-page-fr_FR.po} +0 -0
- languages/{wppp-nl_NL.mo → woocommerce-products-per-page-nl_NL.mo} +0 -0
- languages/{wppp-nl_NL.po → woocommerce-products-per-page-nl_NL.po} +0 -0
- readme.txt +8 -3
- woocommerce-products-per-page.php +62 -58
includes/class-wppp-dropdown.php
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
4 |
|
5 |
/**
|
@@ -12,7 +11,8 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
12 |
* @author Jeroen Sormani
|
13 |
*/
|
14 |
class WPPP_Dropdown extends Woocommerce_Products_Per_Page {
|
15 |
-
|
|
|
16 |
/**
|
17 |
* Product per page option array.
|
18 |
*
|
@@ -22,30 +22,28 @@ class WPPP_Dropdown extends Woocommerce_Products_Per_Page {
|
|
22 |
* @var array $product_per_page_options Array of options.
|
23 |
*/
|
24 |
public $products_per_page_options;
|
25 |
-
|
26 |
|
27 |
/**
|
28 |
-
*
|
29 |
*
|
30 |
* @since 1.0.0
|
31 |
-
*
|
32 |
-
* @return void.
|
33 |
*/
|
34 |
public function __construct( $products_per_page_options = null ) {
|
35 |
-
|
36 |
parent::__construct();
|
37 |
-
|
38 |
$this->products_per_page = $this->wppp_prep_ppp( $products_per_page_options );
|
39 |
-
|
40 |
if ( false == $products_per_page_options ) :
|
41 |
$this->products_per_page_options = $this->wppp_prep_ppp( apply_filters( 'wppp_products_per_page', $this->settings['productsPerPage'] ) );
|
42 |
endif;
|
43 |
-
|
44 |
$this->wppp_dropdown();
|
45 |
-
|
46 |
}
|
47 |
-
|
48 |
-
|
49 |
/**
|
50 |
* Products per page dropdown.
|
51 |
*
|
@@ -53,14 +51,12 @@ class WPPP_Dropdown extends Woocommerce_Products_Per_Page {
|
|
53 |
*
|
54 |
* @since 1.0.0
|
55 |
* @deprecated 1.1.0 Use wppp_dropdown() instead (rename).
|
56 |
-
*
|
57 |
-
* @return void.
|
58 |
*/
|
59 |
public function wppp_create_object() {
|
60 |
$this->wppp_dropdown();
|
61 |
}
|
62 |
-
|
63 |
-
|
64 |
/**
|
65 |
* Products per page dropdown.
|
66 |
*
|
@@ -69,13 +65,11 @@ class WPPP_Dropdown extends Woocommerce_Products_Per_Page {
|
|
69 |
* @since 1.1.0
|
70 |
*
|
71 |
* @global object $wp_query.
|
72 |
-
*
|
73 |
-
* @return void.
|
74 |
*/
|
75 |
public function wppp_dropdown() {
|
76 |
|
77 |
global $wp_query;
|
78 |
-
|
79 |
$action = '';
|
80 |
$cat = '';
|
81 |
$cat = $wp_query->get_queried_object();
|
@@ -89,26 +83,26 @@ class WPPP_Dropdown extends Woocommerce_Products_Per_Page {
|
|
89 |
elseif ( isset( $this->settings['behaviour'] ) && true == $this->settings['behaviour'] ) :
|
90 |
$action = 'action="' . get_permalink( woocommerce_get_page_id( 'shop' ) ) . $query_string . '"';
|
91 |
endif;
|
92 |
-
|
93 |
$method = 'post'; // default
|
94 |
if ( isset( $this->settings['method'] ) && $this->settings['method'] == 'get' ) :
|
95 |
$method = 'get';
|
96 |
endif;
|
97 |
-
|
98 |
// Only show on product categories
|
99 |
if ( woocommerce_products_will_display() ) :
|
100 |
?>
|
101 |
-
|
102 |
<form method="<?php echo $method; ?>" <?php echo $action; ?> style='float: right;' class="form-wppp-select products-per-page">
|
103 |
-
|
104 |
<?php do_action( 'wppp_before_dropdown' ); ?>
|
105 |
-
|
106 |
<select name="wppp_ppp" onchange="this.form.submit()" class="select wppp-select">
|
107 |
-
|
108 |
<?php
|
109 |
global $woocommerce;
|
110 |
foreach( $this->products_per_page_options as $key => $value ) :
|
111 |
-
|
112 |
// Get the right match for the selected option
|
113 |
$ppp_session = $woocommerce->session->get( 'products_per_page' );
|
114 |
if( isset( $_POST['wppp_ppp'] ) ) :
|
@@ -120,29 +114,29 @@ class WPPP_Dropdown extends Woocommerce_Products_Per_Page {
|
|
120 |
else :
|
121 |
$selected_match = $this->settings['default_ppp'];
|
122 |
endif;
|
123 |
-
|
124 |
?>
|
125 |
<option value="<?php echo $value; ?>" <?php selected( $value, $selected_match ); ?>>
|
126 |
-
<?php
|
127 |
$ppp_text = apply_filters( 'wppp_ppp_text', __( '%s products per page', 'woocommerce-products-per-page' ), $value );
|
128 |
-
printf( $ppp_text, $value == -1 ? __( 'All', '
|
129 |
?>
|
130 |
</option>
|
131 |
<?php
|
132 |
-
|
133 |
endforeach;
|
134 |
?>
|
135 |
</select>
|
136 |
-
|
137 |
<?php do_action( 'wppp_after_dropdown' ); ?>
|
138 |
-
|
139 |
</form>
|
140 |
<?php
|
141 |
endif;
|
142 |
-
|
143 |
}
|
144 |
-
|
145 |
-
|
146 |
/**
|
147 |
* Prepare dropdown options.
|
148 |
*
|
@@ -155,9 +149,7 @@ class WPPP_Dropdown extends Woocommerce_Products_Per_Page {
|
|
155 |
public function wppp_prep_ppp( $products_per_page ) {
|
156 |
|
157 |
return explode( ' ', $products_per_page );
|
158 |
-
|
159 |
}
|
160 |
-
|
161 |
-
}
|
162 |
|
163 |
-
|
1 |
<?php
|
|
|
2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
3 |
|
4 |
/**
|
11 |
* @author Jeroen Sormani
|
12 |
*/
|
13 |
class WPPP_Dropdown extends Woocommerce_Products_Per_Page {
|
14 |
+
|
15 |
+
|
16 |
/**
|
17 |
* Product per page option array.
|
18 |
*
|
22 |
* @var array $product_per_page_options Array of options.
|
23 |
*/
|
24 |
public $products_per_page_options;
|
25 |
+
|
26 |
|
27 |
/**
|
28 |
+
* Construct.
|
29 |
*
|
30 |
* @since 1.0.0
|
|
|
|
|
31 |
*/
|
32 |
public function __construct( $products_per_page_options = null ) {
|
33 |
+
|
34 |
parent::__construct();
|
35 |
+
|
36 |
$this->products_per_page = $this->wppp_prep_ppp( $products_per_page_options );
|
37 |
+
|
38 |
if ( false == $products_per_page_options ) :
|
39 |
$this->products_per_page_options = $this->wppp_prep_ppp( apply_filters( 'wppp_products_per_page', $this->settings['productsPerPage'] ) );
|
40 |
endif;
|
41 |
+
|
42 |
$this->wppp_dropdown();
|
43 |
+
|
44 |
}
|
45 |
+
|
46 |
+
|
47 |
/**
|
48 |
* Products per page dropdown.
|
49 |
*
|
51 |
*
|
52 |
* @since 1.0.0
|
53 |
* @deprecated 1.1.0 Use wppp_dropdown() instead (rename).
|
|
|
|
|
54 |
*/
|
55 |
public function wppp_create_object() {
|
56 |
$this->wppp_dropdown();
|
57 |
}
|
58 |
+
|
59 |
+
|
60 |
/**
|
61 |
* Products per page dropdown.
|
62 |
*
|
65 |
* @since 1.1.0
|
66 |
*
|
67 |
* @global object $wp_query.
|
|
|
|
|
68 |
*/
|
69 |
public function wppp_dropdown() {
|
70 |
|
71 |
global $wp_query;
|
72 |
+
|
73 |
$action = '';
|
74 |
$cat = '';
|
75 |
$cat = $wp_query->get_queried_object();
|
83 |
elseif ( isset( $this->settings['behaviour'] ) && true == $this->settings['behaviour'] ) :
|
84 |
$action = 'action="' . get_permalink( woocommerce_get_page_id( 'shop' ) ) . $query_string . '"';
|
85 |
endif;
|
86 |
+
|
87 |
$method = 'post'; // default
|
88 |
if ( isset( $this->settings['method'] ) && $this->settings['method'] == 'get' ) :
|
89 |
$method = 'get';
|
90 |
endif;
|
91 |
+
|
92 |
// Only show on product categories
|
93 |
if ( woocommerce_products_will_display() ) :
|
94 |
?>
|
95 |
+
|
96 |
<form method="<?php echo $method; ?>" <?php echo $action; ?> style='float: right;' class="form-wppp-select products-per-page">
|
97 |
+
|
98 |
<?php do_action( 'wppp_before_dropdown' ); ?>
|
99 |
+
|
100 |
<select name="wppp_ppp" onchange="this.form.submit()" class="select wppp-select">
|
101 |
+
|
102 |
<?php
|
103 |
global $woocommerce;
|
104 |
foreach( $this->products_per_page_options as $key => $value ) :
|
105 |
+
|
106 |
// Get the right match for the selected option
|
107 |
$ppp_session = $woocommerce->session->get( 'products_per_page' );
|
108 |
if( isset( $_POST['wppp_ppp'] ) ) :
|
114 |
else :
|
115 |
$selected_match = $this->settings['default_ppp'];
|
116 |
endif;
|
117 |
+
|
118 |
?>
|
119 |
<option value="<?php echo $value; ?>" <?php selected( $value, $selected_match ); ?>>
|
120 |
+
<?php
|
121 |
$ppp_text = apply_filters( 'wppp_ppp_text', __( '%s products per page', 'woocommerce-products-per-page' ), $value );
|
122 |
+
printf( $ppp_text, $value == -1 ? __( 'All', 'woocommerce-products-per-page' ) : $value ); // Set to 'All' when value is -1
|
123 |
?>
|
124 |
</option>
|
125 |
<?php
|
126 |
+
|
127 |
endforeach;
|
128 |
?>
|
129 |
</select>
|
130 |
+
|
131 |
<?php do_action( 'wppp_after_dropdown' ); ?>
|
132 |
+
|
133 |
</form>
|
134 |
<?php
|
135 |
endif;
|
136 |
+
|
137 |
}
|
138 |
+
|
139 |
+
|
140 |
/**
|
141 |
* Prepare dropdown options.
|
142 |
*
|
149 |
public function wppp_prep_ppp( $products_per_page ) {
|
150 |
|
151 |
return explode( ' ', $products_per_page );
|
152 |
+
|
153 |
}
|
|
|
|
|
154 |
|
155 |
+
}
|
includes/class-wppp-settings.php
CHANGED
@@ -13,41 +13,37 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
13 |
|
14 |
class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
15 |
|
16 |
-
|
17 |
/**
|
18 |
-
*
|
19 |
*
|
20 |
* @since 1.0.0
|
21 |
-
*
|
22 |
-
* @return void.
|
23 |
*/
|
24 |
public function __construct() {
|
25 |
-
|
26 |
parent::__construct();
|
27 |
-
|
28 |
}
|
29 |
|
30 |
-
|
31 |
/**
|
32 |
* Register settings.
|
33 |
*
|
34 |
* Register setting, sections and settings fields.
|
35 |
*
|
36 |
* @since 1.0.0
|
37 |
-
*
|
38 |
-
* @return void.
|
39 |
*/
|
40 |
public function wppp_settings_init() {
|
41 |
|
42 |
register_setting( 'wppp_settings', 'wppp_settings' );
|
43 |
-
|
44 |
add_settings_section(
|
45 |
'wppp_settings',
|
46 |
'WooCommerce Products Per Page',
|
47 |
array( $this, 'wppp_section_callback' ),
|
48 |
'wppp_settings'
|
49 |
);
|
50 |
-
|
51 |
|
52 |
add_settings_field(
|
53 |
'wppp_location',
|
@@ -56,15 +52,15 @@ class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
|
56 |
'wppp_settings',
|
57 |
'wppp_settings'
|
58 |
);
|
59 |
-
|
60 |
-
add_settings_field(
|
61 |
-
'wppp_products_per_page_list',
|
62 |
__( 'List of dropdown options', 'woocommerce-products-per-page' ),
|
63 |
array( $this, 'wppp_settings_field_ppp_list' ),
|
64 |
'wppp_settings',
|
65 |
-
'wppp_settings'
|
66 |
);
|
67 |
-
|
68 |
add_settings_field(
|
69 |
'wppp_default_ppp',
|
70 |
__( 'Default products per page', 'woocommerce-products-per-page' ),
|
@@ -72,49 +68,47 @@ class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
|
72 |
'wppp_settings',
|
73 |
'wppp_settings'
|
74 |
);
|
75 |
-
|
76 |
add_settings_field(
|
77 |
-
'wppp_shop_columns',
|
78 |
-
__( 'Shop columns', 'woocommerce-products-per-page' ),
|
79 |
array( $this, 'wppp_settings_field_shop_columns' ),
|
80 |
'wppp_settings',
|
81 |
'wppp_settings'
|
82 |
);
|
83 |
-
|
84 |
add_settings_field(
|
85 |
-
'wppp_ppp_behaviour',
|
86 |
-
__( 'First category page', 'woocommerce-products-per-page' ),
|
87 |
array( $this, 'wppp_settings_field_behaviour' ),
|
88 |
'wppp_settings',
|
89 |
'wppp_settings'
|
90 |
);
|
91 |
-
|
92 |
add_settings_field(
|
93 |
-
'wppp_method',
|
94 |
-
__( 'HTTP method', '
|
95 |
array( $this, 'wppp_settings_field_method' ),
|
96 |
'wppp_settings',
|
97 |
'wppp_settings'
|
98 |
);
|
99 |
-
|
100 |
}
|
101 |
-
|
102 |
-
|
103 |
/**
|
104 |
* Settings page render.
|
105 |
*
|
106 |
* Load settings fields, sections and submit button.
|
107 |
*
|
108 |
* @since 1.0.0
|
109 |
-
*
|
110 |
-
* @return void.
|
111 |
*/
|
112 |
public function wppp_render_settings_page() {
|
113 |
-
|
114 |
?><div class="wrap">
|
115 |
-
|
116 |
<h2><?php _e( 'WooCommerce Products Per Page', 'woocommerce-products-per-page' ); ?></h2>
|
117 |
-
|
118 |
<form method="POST" action="options.php">
|
119 |
<?php
|
120 |
settings_fields( 'wppp_settings' );
|
@@ -122,11 +116,11 @@ class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
|
122 |
submit_button();
|
123 |
?>
|
124 |
</form>
|
125 |
-
|
126 |
</div><?php
|
127 |
-
|
128 |
}
|
129 |
-
|
130 |
|
131 |
/**
|
132 |
* Location setting.
|
@@ -134,57 +128,51 @@ class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
|
134 |
* Settings dropdown to select the location of the dropdown.
|
135 |
*
|
136 |
* @since 1.0.0
|
137 |
-
*
|
138 |
-
* @return void.
|
139 |
*/
|
140 |
public function wppp_settings_field_location() {
|
141 |
-
|
142 |
?><select name="wppp_settings[location]" class="">
|
143 |
<option value="top" <?php selected( $this->settings['location'], 'top' ); ?>> <?php _e( 'Top', 'woocommerce-products-per-page' ); ?></option>
|
144 |
<option value="bottom" <?php selected( $this->settings['location'], 'bottom' ); ?>> <?php _e( 'Bottom', 'woocommerce-products-per-page' ); ?></option>
|
145 |
<option value="topbottom" <?php selected( $this->settings['location'], 'topbottom' ); ?>> <?php _e( 'Top/Bottom', 'woocommerce-products-per-page' ); ?></option>
|
146 |
<option value="none" <?php selected( $this->settings['location'], 'none' ); ?>> <?php _e( 'None', 'woocommerce-products-per-page' ); ?></option>
|
147 |
</select><?php
|
148 |
-
|
149 |
}
|
150 |
-
|
151 |
-
|
152 |
/**
|
153 |
* Dropdown options input.
|
154 |
*
|
155 |
* Settings input to set the options for the dropdown. Seperate with space.
|
156 |
*
|
157 |
* @since 1.0.0
|
158 |
-
*
|
159 |
-
* @return void.
|
160 |
*/
|
161 |
public function wppp_settings_field_ppp_list() {
|
162 |
|
163 |
?><label for="products_per_page">
|
164 |
<input type="text" id="products_per_page" name="wppp_settings[productsPerPage]" value="<?php echo $this->settings['productsPerPage']; ?>">
|
165 |
<?php _e( 'Seperated by spaces <em>(-1 for all products)</em>', 'woocommerce-products-per-page' ); ?></label><?php
|
166 |
-
|
167 |
}
|
168 |
-
|
169 |
-
|
170 |
/**
|
171 |
* Default ppp input.
|
172 |
*
|
173 |
* Settings input to set the default products per page.
|
174 |
*
|
175 |
* @since 1.0.0
|
176 |
-
*
|
177 |
-
* @return void.
|
178 |
*/
|
179 |
public function wppp_settings_field_default_ppp() {
|
180 |
-
|
181 |
?><label for="default_ppp">
|
182 |
<input type="number" id="default_ppp" name="wppp_settings[default_ppp]" value="<?php echo $this->settings['default_ppp']; ?>">
|
183 |
<em><?php _e( '-1 for all products', 'woocommerce-products-per-page' ); ?></em>
|
184 |
</label><?php
|
185 |
-
|
186 |
}
|
187 |
-
|
188 |
|
189 |
/**
|
190 |
* Shop columns input.
|
@@ -192,15 +180,13 @@ class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
|
192 |
* Settings input to set the shop columns per row.
|
193 |
*
|
194 |
* @since 1.0.0
|
195 |
-
*
|
196 |
-
* @return void.
|
197 |
*/
|
198 |
public function wppp_settings_field_shop_columns() {
|
199 |
-
|
200 |
?><label for="shop_columns">
|
201 |
<input type="number" id="shop_columns" name="wppp_settings[shop_columns]" value="<?php echo $this->settings['shop_columns']; ?>">
|
202 |
</label><?php
|
203 |
-
|
204 |
}
|
205 |
|
206 |
|
@@ -210,11 +196,9 @@ class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
|
210 |
* Rendering method for behaviour checkbox.
|
211 |
*
|
212 |
* @since 1.0.0
|
213 |
-
*
|
214 |
-
* @return void.
|
215 |
*/
|
216 |
public function wppp_settings_field_behaviour() {
|
217 |
-
|
218 |
?><label for="behaviour">
|
219 |
<input type="checkbox" id="behaviour" name="wppp_settings[behaviour]" value="1" <?php @checked( $this->settings['behaviour'], 1 ); ?>>
|
220 |
<?php _e( 'When checked and a new number of PPP is selected, the visitor will be send to the first page of the product category', 'woocommerce-products-per-page' ); ?>
|
@@ -243,11 +227,11 @@ class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
|
243 |
content: " ";
|
244 |
position: absolute;
|
245 |
top: -20px;
|
246 |
-
|
247 |
}
|
248 |
-
.tooltip a {
|
249 |
-
color: #f1f1f1;
|
250 |
-
text-decoration: none;
|
251 |
}
|
252 |
.tooltip a:hover {
|
253 |
text-decoration: underline;
|
@@ -255,13 +239,10 @@ class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
|
255 |
*:hover > .tooltip {
|
256 |
display: block;
|
257 |
}
|
258 |
-
</style
|
259 |
-
|
260 |
-
<?php
|
261 |
-
|
262 |
}
|
263 |
-
|
264 |
-
|
265 |
|
266 |
/**
|
267 |
* Method checkbox.
|
@@ -269,11 +250,9 @@ class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
|
269 |
* Rendering method for method checkbox.
|
270 |
*
|
271 |
* @since 1.0.0
|
272 |
-
*
|
273 |
-
* @return void.
|
274 |
*/
|
275 |
public function wppp_settings_field_method() {
|
276 |
-
|
277 |
?><label for="method">
|
278 |
<select name="wppp_settings[method]" class="">
|
279 |
<option value="post" <?php @selected( $this->settings['method'], 'post' ); ?>> <?php _e( 'POST', 'woocommerce-products-per-page' ); ?></option>
|
@@ -281,23 +260,21 @@ class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
|
281 |
</select>
|
282 |
<?php _e( 'GET sends the products per page via the url, POST does this on the background', 'woocommerce-products-per-page' ); ?>
|
283 |
</label><?php
|
284 |
-
|
285 |
}
|
286 |
-
|
287 |
-
|
288 |
/**
|
289 |
* Settings page description.
|
290 |
*
|
291 |
* @since 1.0.0
|
292 |
-
*
|
293 |
-
* @return void.
|
294 |
*/
|
295 |
public function wppp_section_callback() {
|
296 |
-
|
297 |
echo __( 'Configure the WooCommerce Product Per Page settings here.', 'woocommerce-products-per-page' );
|
298 |
-
|
299 |
}
|
300 |
-
|
301 |
}
|
302 |
|
303 |
?>
|
13 |
|
14 |
class WPPP_Settings extends Woocommerce_Products_Per_Page {
|
15 |
|
16 |
+
|
17 |
/**
|
18 |
+
* Construct.
|
19 |
*
|
20 |
* @since 1.0.0
|
|
|
|
|
21 |
*/
|
22 |
public function __construct() {
|
23 |
+
|
24 |
parent::__construct();
|
25 |
+
|
26 |
}
|
27 |
|
28 |
+
|
29 |
/**
|
30 |
* Register settings.
|
31 |
*
|
32 |
* Register setting, sections and settings fields.
|
33 |
*
|
34 |
* @since 1.0.0
|
|
|
|
|
35 |
*/
|
36 |
public function wppp_settings_init() {
|
37 |
|
38 |
register_setting( 'wppp_settings', 'wppp_settings' );
|
39 |
+
|
40 |
add_settings_section(
|
41 |
'wppp_settings',
|
42 |
'WooCommerce Products Per Page',
|
43 |
array( $this, 'wppp_section_callback' ),
|
44 |
'wppp_settings'
|
45 |
);
|
46 |
+
|
47 |
|
48 |
add_settings_field(
|
49 |
'wppp_location',
|
52 |
'wppp_settings',
|
53 |
'wppp_settings'
|
54 |
);
|
55 |
+
|
56 |
+
add_settings_field(
|
57 |
+
'wppp_products_per_page_list',
|
58 |
__( 'List of dropdown options', 'woocommerce-products-per-page' ),
|
59 |
array( $this, 'wppp_settings_field_ppp_list' ),
|
60 |
'wppp_settings',
|
61 |
+
'wppp_settings'
|
62 |
);
|
63 |
+
|
64 |
add_settings_field(
|
65 |
'wppp_default_ppp',
|
66 |
__( 'Default products per page', 'woocommerce-products-per-page' ),
|
68 |
'wppp_settings',
|
69 |
'wppp_settings'
|
70 |
);
|
71 |
+
|
72 |
add_settings_field(
|
73 |
+
'wppp_shop_columns',
|
74 |
+
__( 'Shop columns', 'woocommerce-products-per-page' ),
|
75 |
array( $this, 'wppp_settings_field_shop_columns' ),
|
76 |
'wppp_settings',
|
77 |
'wppp_settings'
|
78 |
);
|
79 |
+
|
80 |
add_settings_field(
|
81 |
+
'wppp_ppp_behaviour',
|
82 |
+
__( 'First category page', 'woocommerce-products-per-page' ),
|
83 |
array( $this, 'wppp_settings_field_behaviour' ),
|
84 |
'wppp_settings',
|
85 |
'wppp_settings'
|
86 |
);
|
87 |
+
|
88 |
add_settings_field(
|
89 |
+
'wppp_method',
|
90 |
+
__( 'HTTP method', 'woocommerce-products-per-page' ),
|
91 |
array( $this, 'wppp_settings_field_method' ),
|
92 |
'wppp_settings',
|
93 |
'wppp_settings'
|
94 |
);
|
95 |
+
|
96 |
}
|
97 |
+
|
98 |
+
|
99 |
/**
|
100 |
* Settings page render.
|
101 |
*
|
102 |
* Load settings fields, sections and submit button.
|
103 |
*
|
104 |
* @since 1.0.0
|
|
|
|
|
105 |
*/
|
106 |
public function wppp_render_settings_page() {
|
107 |
+
|
108 |
?><div class="wrap">
|
109 |
+
|
110 |
<h2><?php _e( 'WooCommerce Products Per Page', 'woocommerce-products-per-page' ); ?></h2>
|
111 |
+
|
112 |
<form method="POST" action="options.php">
|
113 |
<?php
|
114 |
settings_fields( 'wppp_settings' );
|
116 |
submit_button();
|
117 |
?>
|
118 |
</form>
|
119 |
+
|
120 |
</div><?php
|
121 |
+
|
122 |
}
|
123 |
+
|
124 |
|
125 |
/**
|
126 |
* Location setting.
|
128 |
* Settings dropdown to select the location of the dropdown.
|
129 |
*
|
130 |
* @since 1.0.0
|
|
|
|
|
131 |
*/
|
132 |
public function wppp_settings_field_location() {
|
133 |
+
|
134 |
?><select name="wppp_settings[location]" class="">
|
135 |
<option value="top" <?php selected( $this->settings['location'], 'top' ); ?>> <?php _e( 'Top', 'woocommerce-products-per-page' ); ?></option>
|
136 |
<option value="bottom" <?php selected( $this->settings['location'], 'bottom' ); ?>> <?php _e( 'Bottom', 'woocommerce-products-per-page' ); ?></option>
|
137 |
<option value="topbottom" <?php selected( $this->settings['location'], 'topbottom' ); ?>> <?php _e( 'Top/Bottom', 'woocommerce-products-per-page' ); ?></option>
|
138 |
<option value="none" <?php selected( $this->settings['location'], 'none' ); ?>> <?php _e( 'None', 'woocommerce-products-per-page' ); ?></option>
|
139 |
</select><?php
|
140 |
+
|
141 |
}
|
142 |
+
|
143 |
+
|
144 |
/**
|
145 |
* Dropdown options input.
|
146 |
*
|
147 |
* Settings input to set the options for the dropdown. Seperate with space.
|
148 |
*
|
149 |
* @since 1.0.0
|
|
|
|
|
150 |
*/
|
151 |
public function wppp_settings_field_ppp_list() {
|
152 |
|
153 |
?><label for="products_per_page">
|
154 |
<input type="text" id="products_per_page" name="wppp_settings[productsPerPage]" value="<?php echo $this->settings['productsPerPage']; ?>">
|
155 |
<?php _e( 'Seperated by spaces <em>(-1 for all products)</em>', 'woocommerce-products-per-page' ); ?></label><?php
|
156 |
+
|
157 |
}
|
158 |
+
|
159 |
+
|
160 |
/**
|
161 |
* Default ppp input.
|
162 |
*
|
163 |
* Settings input to set the default products per page.
|
164 |
*
|
165 |
* @since 1.0.0
|
|
|
|
|
166 |
*/
|
167 |
public function wppp_settings_field_default_ppp() {
|
168 |
+
|
169 |
?><label for="default_ppp">
|
170 |
<input type="number" id="default_ppp" name="wppp_settings[default_ppp]" value="<?php echo $this->settings['default_ppp']; ?>">
|
171 |
<em><?php _e( '-1 for all products', 'woocommerce-products-per-page' ); ?></em>
|
172 |
</label><?php
|
173 |
+
|
174 |
}
|
175 |
+
|
176 |
|
177 |
/**
|
178 |
* Shop columns input.
|
180 |
* Settings input to set the shop columns per row.
|
181 |
*
|
182 |
* @since 1.0.0
|
|
|
|
|
183 |
*/
|
184 |
public function wppp_settings_field_shop_columns() {
|
185 |
+
|
186 |
?><label for="shop_columns">
|
187 |
<input type="number" id="shop_columns" name="wppp_settings[shop_columns]" value="<?php echo $this->settings['shop_columns']; ?>">
|
188 |
</label><?php
|
189 |
+
|
190 |
}
|
191 |
|
192 |
|
196 |
* Rendering method for behaviour checkbox.
|
197 |
*
|
198 |
* @since 1.0.0
|
|
|
|
|
199 |
*/
|
200 |
public function wppp_settings_field_behaviour() {
|
201 |
+
|
202 |
?><label for="behaviour">
|
203 |
<input type="checkbox" id="behaviour" name="wppp_settings[behaviour]" value="1" <?php @checked( $this->settings['behaviour'], 1 ); ?>>
|
204 |
<?php _e( 'When checked and a new number of PPP is selected, the visitor will be send to the first page of the product category', 'woocommerce-products-per-page' ); ?>
|
227 |
content: " ";
|
228 |
position: absolute;
|
229 |
top: -20px;
|
230 |
+
|
231 |
}
|
232 |
+
.tooltip a {
|
233 |
+
color: #f1f1f1;
|
234 |
+
text-decoration: none;
|
235 |
}
|
236 |
.tooltip a:hover {
|
237 |
text-decoration: underline;
|
239 |
*:hover > .tooltip {
|
240 |
display: block;
|
241 |
}
|
242 |
+
</style><?php
|
243 |
+
|
|
|
|
|
244 |
}
|
245 |
+
|
|
|
246 |
|
247 |
/**
|
248 |
* Method checkbox.
|
250 |
* Rendering method for method checkbox.
|
251 |
*
|
252 |
* @since 1.0.0
|
|
|
|
|
253 |
*/
|
254 |
public function wppp_settings_field_method() {
|
255 |
+
|
256 |
?><label for="method">
|
257 |
<select name="wppp_settings[method]" class="">
|
258 |
<option value="post" <?php @selected( $this->settings['method'], 'post' ); ?>> <?php _e( 'POST', 'woocommerce-products-per-page' ); ?></option>
|
260 |
</select>
|
261 |
<?php _e( 'GET sends the products per page via the url, POST does this on the background', 'woocommerce-products-per-page' ); ?>
|
262 |
</label><?php
|
263 |
+
|
264 |
}
|
265 |
+
|
266 |
+
|
267 |
/**
|
268 |
* Settings page description.
|
269 |
*
|
270 |
* @since 1.0.0
|
|
|
|
|
271 |
*/
|
272 |
public function wppp_section_callback() {
|
273 |
+
|
274 |
echo __( 'Configure the WooCommerce Product Per Page settings here.', 'woocommerce-products-per-page' );
|
275 |
+
|
276 |
}
|
277 |
+
|
278 |
}
|
279 |
|
280 |
?>
|
languages/{wppp-fa_IR.mo → woocommerce-products-per-page-fa_IR.mo}
RENAMED
File without changes
|
languages/{wppp-fa_IR.po → woocommerce-products-per-page-fa_IR.po}
RENAMED
File without changes
|
languages/{wppp-fr_FR.mo → woocommerce-products-per-page-fr_FR.mo}
RENAMED
File without changes
|
languages/{wppp-fr_FR.po → woocommerce-products-per-page-fr_FR.po}
RENAMED
File without changes
|
languages/{wppp-nl_NL.mo → woocommerce-products-per-page-nl_NL.mo}
RENAMED
File without changes
|
languages/{wppp-nl_NL.po → woocommerce-products-per-page-nl_NL.po}
RENAMED
File without changes
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== WooCommerce Products Per Page ===
|
2 |
Contributors: sormano
|
3 |
-
Donate link: http://www.jeroensormani.
|
4 |
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
|
5 |
Requires at least: 3.6.0
|
6 |
-
Tested up to: 3.9.
|
7 |
-
Stable tag: 1.1.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -43,6 +43,11 @@ Options like:
|
|
43 |
|
44 |
== Changelog ==
|
45 |
|
|
|
|
|
|
|
|
|
|
|
46 |
= 1.1.0.1 =
|
47 |
* Removed - Duplicated main file with wrong name
|
48 |
|
1 |
=== WooCommerce Products Per Page ===
|
2 |
Contributors: sormano
|
3 |
+
Donate link: http://www.jeroensormani.com/donate/
|
4 |
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
|
5 |
Requires at least: 3.6.0
|
6 |
+
Tested up to: 3.9.2
|
7 |
+
Stable tag: 1.1.1
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
43 |
|
44 |
== Changelog ==
|
45 |
|
46 |
+
= 1.1.1 = 18/08/2014
|
47 |
+
* Proper translation for 'All'
|
48 |
+
* Products in admin area aren't influenced anymore
|
49 |
+
* Removed unneeded comments
|
50 |
+
|
51 |
= 1.1.0.1 =
|
52 |
* Removed - Duplicated main file with wrong name
|
53 |
|
woocommerce-products-per-page.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?PHP
|
2 |
/*
|
3 |
Plugin Name: Woocommerce Products Per Page
|
4 |
-
Plugin URI: http://www.jeroensormani.
|
5 |
Description: Integrate a 'products per page' dropdown on your WooCommerce website! Set-up in <strong>seconds</strong>!
|
6 |
-
Version: 1.1.
|
7 |
Author: Jeroen Sormani
|
8 |
-
Author URI: http://www.jeroensormani.
|
9 |
|
10 |
* Copyright Jeroen Sormani
|
11 |
*
|
@@ -40,7 +40,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
40 |
*/
|
41 |
|
42 |
class Woocommerce_Products_Per_Page {
|
43 |
-
|
44 |
/**
|
45 |
* Settings from settings page.
|
46 |
*
|
@@ -50,35 +50,39 @@ class Woocommerce_Products_Per_Page {
|
|
50 |
* @var array $settings Contains all the user settings.
|
51 |
*/
|
52 |
public $settings;
|
53 |
-
|
54 |
-
|
55 |
/**
|
56 |
-
*
|
57 |
*
|
58 |
* @since 1.0.0
|
59 |
*
|
60 |
* @return void.
|
61 |
*/
|
62 |
public function __construct() {
|
63 |
-
|
|
|
|
|
|
|
|
|
64 |
if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) :
|
65 |
if ( ! is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) :
|
66 |
return;
|
67 |
endif;
|
68 |
endif;
|
69 |
-
|
70 |
// Initialise settings
|
71 |
$this->wppp_init_settings();
|
72 |
-
|
73 |
// Initialize hooks
|
74 |
$this->wppp_hooks();
|
75 |
-
|
76 |
// Load textdomain
|
77 |
load_plugin_textdomain( 'woocommerce-products-per-page', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
78 |
-
|
79 |
}
|
80 |
-
|
81 |
-
|
82 |
/**
|
83 |
* Add all actions and filters.
|
84 |
*
|
@@ -87,16 +91,16 @@ class Woocommerce_Products_Per_Page {
|
|
87 |
* @return int number of columns.
|
88 |
*/
|
89 |
public function wppp_hooks() {
|
90 |
-
|
91 |
// Add admin settings page
|
92 |
add_action( 'admin_menu', array( $this, 'wppp_settings_page_menu' ) );
|
93 |
-
|
94 |
// Init settings
|
95 |
add_action( 'admin_init', array( $this, 'wppp_init_settings_page' ) );
|
96 |
|
97 |
// Add filter for product columns
|
98 |
add_filter( 'loop_shop_columns', array( $this, 'wppp_loop_shop_columns' ) );
|
99 |
-
|
100 |
// Customer number of products per page
|
101 |
add_filter( 'loop_shop_per_page', array( $this, 'wppp_loop_shop_per_page' ) );
|
102 |
add_filter( 'pre_get_posts', array( $this, 'wppp_pre_get_posts' ), 1, 50 );
|
@@ -108,8 +112,8 @@ class Woocommerce_Products_Per_Page {
|
|
108 |
add_action( 'init', array( $this, 'wppp_submit_check' ) );
|
109 |
|
110 |
}
|
111 |
-
|
112 |
-
|
113 |
/**
|
114 |
* Initialize admin settings page.
|
115 |
*
|
@@ -120,8 +124,8 @@ class Woocommerce_Products_Per_Page {
|
|
120 |
public function wppp_settings_page_menu() {
|
121 |
add_options_page( 'WooCommerce Products Per Page', 'Products Per Page', 'manage_options', 'wppp_settings', array( $this, 'wppp_settings_page' ) );
|
122 |
}
|
123 |
-
|
124 |
-
|
125 |
/**
|
126 |
* Initialize admin settings page.
|
127 |
*
|
@@ -130,13 +134,13 @@ class Woocommerce_Products_Per_Page {
|
|
130 |
* @return void.
|
131 |
*/
|
132 |
public function wppp_settings_page() {
|
133 |
-
|
134 |
global $wppp_settings;
|
135 |
$wppp_settings->wppp_render_settings_page();
|
136 |
-
|
137 |
}
|
138 |
-
|
139 |
-
|
140 |
/**
|
141 |
* Initialize settings.
|
142 |
*
|
@@ -155,7 +159,7 @@ class Woocommerce_Products_Per_Page {
|
|
155 |
$this->settings = get_option( 'wppp_settings' );
|
156 |
|
157 |
}
|
158 |
-
|
159 |
|
160 |
/**
|
161 |
* Default settings
|
@@ -186,10 +190,10 @@ class Woocommerce_Products_Per_Page {
|
|
186 |
) );
|
187 |
|
188 |
return $settings;
|
189 |
-
|
190 |
}
|
191 |
-
|
192 |
-
|
193 |
/**
|
194 |
* Initialise admin settings.
|
195 |
*
|
@@ -200,19 +204,19 @@ class Woocommerce_Products_Per_Page {
|
|
200 |
* @return void.
|
201 |
*/
|
202 |
public function wppp_init_settings_page() {
|
203 |
-
|
204 |
/**
|
205 |
* Settings page class
|
206 |
*/
|
207 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wppp-settings.php';
|
208 |
-
|
209 |
global $wppp_settings;
|
210 |
$wppp_settings = new WPPP_Settings();
|
211 |
$wppp_settings->wppp_settings_init();
|
212 |
-
|
213 |
}
|
214 |
-
|
215 |
-
|
216 |
/**
|
217 |
* Shop columns.
|
218 |
*
|
@@ -229,10 +233,10 @@ class Woocommerce_Products_Per_Page {
|
|
229 |
endif;
|
230 |
|
231 |
return $columns;
|
232 |
-
|
233 |
}
|
234 |
-
|
235 |
-
|
236 |
/**
|
237 |
* Per page hook.
|
238 |
*
|
@@ -255,7 +259,7 @@ class Woocommerce_Products_Per_Page {
|
|
255 |
else :
|
256 |
return $this->settings['default_ppp'];
|
257 |
endif;
|
258 |
-
|
259 |
}
|
260 |
|
261 |
|
@@ -270,15 +274,15 @@ class Woocommerce_Products_Per_Page {
|
|
270 |
*/
|
271 |
public function wppp_pre_get_posts( $q ) {
|
272 |
|
273 |
-
if ( function_exists( 'woocommerce_products_will_display' ) && woocommerce_products_will_display() && $q->is_main_query() ) :
|
274 |
$q->set( 'posts_per_page', $this->wppp_loop_shop_per_page() );
|
275 |
endif;
|
276 |
|
277 |
return $q;
|
278 |
|
279 |
}
|
280 |
-
|
281 |
-
|
282 |
/**
|
283 |
* Add dropdown.
|
284 |
*
|
@@ -289,7 +293,7 @@ class Woocommerce_Products_Per_Page {
|
|
289 |
* @return void.
|
290 |
*/
|
291 |
public function wppp_shop_hooks() {
|
292 |
-
|
293 |
if ( $this->settings['location'] == 'top' ) :
|
294 |
add_action( 'woocommerce_before_shop_loop', array( $this, 'wppp_dropdown' ) );
|
295 |
elseif ( $this->settings['location'] == 'bottom' ) :
|
@@ -298,10 +302,10 @@ class Woocommerce_Products_Per_Page {
|
|
298 |
add_action( 'woocommerce_before_shop_loop', array( $this, 'wppp_dropdown' ) );
|
299 |
add_action( 'woocommerce_after_shop_loop', array( $this, 'wppp_dropdown' ) );
|
300 |
endif;
|
301 |
-
|
302 |
}
|
303 |
-
|
304 |
-
|
305 |
/**
|
306 |
* Products per page dropdown.
|
307 |
*
|
@@ -313,8 +317,8 @@ class Woocommerce_Products_Per_Page {
|
|
313 |
public function wppp_dropdown_object() {
|
314 |
$this->wppp_dropdown();
|
315 |
}
|
316 |
-
|
317 |
-
|
318 |
/**
|
319 |
* Include dropdown.
|
320 |
*
|
@@ -325,16 +329,16 @@ class Woocommerce_Products_Per_Page {
|
|
325 |
* @return void.
|
326 |
*/
|
327 |
public function wppp_dropdown() {
|
328 |
-
|
329 |
/**
|
330 |
* Products per page dropdown
|
331 |
*/
|
332 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wppp-dropdown.php';
|
333 |
new wppp_dropdown();
|
334 |
-
|
335 |
}
|
336 |
-
|
337 |
-
|
338 |
/**
|
339 |
* Initilize session.
|
340 |
*
|
@@ -347,16 +351,16 @@ class Woocommerce_Products_Per_Page {
|
|
347 |
* @return void.
|
348 |
*/
|
349 |
public function wppp_set_customer_session() {
|
350 |
-
|
351 |
global $woocommerce;
|
352 |
|
353 |
if ( $woocommerce->version > '2.1' ) :
|
354 |
$woocommerce->session->set_customer_session_cookie( true );
|
355 |
endif;
|
356 |
-
|
357 |
}
|
358 |
-
|
359 |
-
|
360 |
/**
|
361 |
* Set session.
|
362 |
*
|
@@ -369,7 +373,7 @@ class Woocommerce_Products_Per_Page {
|
|
369 |
* @return void.
|
370 |
*/
|
371 |
public function wppp_submit_check() {
|
372 |
-
|
373 |
global $woocommerce;
|
374 |
|
375 |
if ( isset( $_POST['wppp_ppp'] ) ) :
|
@@ -377,9 +381,9 @@ class Woocommerce_Products_Per_Page {
|
|
377 |
elseif ( isset( $_GET['wppp_ppp'] ) ) :
|
378 |
$woocommerce->session->set( 'products_per_page', $_GET['wppp_ppp'] );
|
379 |
endif;
|
380 |
-
|
381 |
}
|
382 |
-
|
383 |
|
384 |
}
|
385 |
|
1 |
<?PHP
|
2 |
/*
|
3 |
Plugin Name: Woocommerce Products Per Page
|
4 |
+
Plugin URI: http://www.jeroensormani.com/
|
5 |
Description: Integrate a 'products per page' dropdown on your WooCommerce website! Set-up in <strong>seconds</strong>!
|
6 |
+
Version: 1.1.1
|
7 |
Author: Jeroen Sormani
|
8 |
+
Author URI: http://www.jeroensormani.com
|
9 |
|
10 |
* Copyright Jeroen Sormani
|
11 |
*
|
40 |
*/
|
41 |
|
42 |
class Woocommerce_Products_Per_Page {
|
43 |
+
|
44 |
/**
|
45 |
* Settings from settings page.
|
46 |
*
|
50 |
* @var array $settings Contains all the user settings.
|
51 |
*/
|
52 |
public $settings;
|
53 |
+
|
54 |
+
|
55 |
/**
|
56 |
+
* Construct.
|
57 |
*
|
58 |
* @since 1.0.0
|
59 |
*
|
60 |
* @return void.
|
61 |
*/
|
62 |
public function __construct() {
|
63 |
+
|
64 |
+
if ( ! function_exists( 'is_plugin_active_for_network' ) ) :
|
65 |
+
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
66 |
+
endif;
|
67 |
+
|
68 |
if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) :
|
69 |
if ( ! is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) :
|
70 |
return;
|
71 |
endif;
|
72 |
endif;
|
73 |
+
|
74 |
// Initialise settings
|
75 |
$this->wppp_init_settings();
|
76 |
+
|
77 |
// Initialize hooks
|
78 |
$this->wppp_hooks();
|
79 |
+
|
80 |
// Load textdomain
|
81 |
load_plugin_textdomain( 'woocommerce-products-per-page', false, basename( dirname( __FILE__ ) ) . '/languages' );
|
82 |
+
|
83 |
}
|
84 |
+
|
85 |
+
|
86 |
/**
|
87 |
* Add all actions and filters.
|
88 |
*
|
91 |
* @return int number of columns.
|
92 |
*/
|
93 |
public function wppp_hooks() {
|
94 |
+
|
95 |
// Add admin settings page
|
96 |
add_action( 'admin_menu', array( $this, 'wppp_settings_page_menu' ) );
|
97 |
+
|
98 |
// Init settings
|
99 |
add_action( 'admin_init', array( $this, 'wppp_init_settings_page' ) );
|
100 |
|
101 |
// Add filter for product columns
|
102 |
add_filter( 'loop_shop_columns', array( $this, 'wppp_loop_shop_columns' ) );
|
103 |
+
|
104 |
// Customer number of products per page
|
105 |
add_filter( 'loop_shop_per_page', array( $this, 'wppp_loop_shop_per_page' ) );
|
106 |
add_filter( 'pre_get_posts', array( $this, 'wppp_pre_get_posts' ), 1, 50 );
|
112 |
add_action( 'init', array( $this, 'wppp_submit_check' ) );
|
113 |
|
114 |
}
|
115 |
+
|
116 |
+
|
117 |
/**
|
118 |
* Initialize admin settings page.
|
119 |
*
|
124 |
public function wppp_settings_page_menu() {
|
125 |
add_options_page( 'WooCommerce Products Per Page', 'Products Per Page', 'manage_options', 'wppp_settings', array( $this, 'wppp_settings_page' ) );
|
126 |
}
|
127 |
+
|
128 |
+
|
129 |
/**
|
130 |
* Initialize admin settings page.
|
131 |
*
|
134 |
* @return void.
|
135 |
*/
|
136 |
public function wppp_settings_page() {
|
137 |
+
|
138 |
global $wppp_settings;
|
139 |
$wppp_settings->wppp_render_settings_page();
|
140 |
+
|
141 |
}
|
142 |
+
|
143 |
+
|
144 |
/**
|
145 |
* Initialize settings.
|
146 |
*
|
159 |
$this->settings = get_option( 'wppp_settings' );
|
160 |
|
161 |
}
|
162 |
+
|
163 |
|
164 |
/**
|
165 |
* Default settings
|
190 |
) );
|
191 |
|
192 |
return $settings;
|
193 |
+
|
194 |
}
|
195 |
+
|
196 |
+
|
197 |
/**
|
198 |
* Initialise admin settings.
|
199 |
*
|
204 |
* @return void.
|
205 |
*/
|
206 |
public function wppp_init_settings_page() {
|
207 |
+
|
208 |
/**
|
209 |
* Settings page class
|
210 |
*/
|
211 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wppp-settings.php';
|
212 |
+
|
213 |
global $wppp_settings;
|
214 |
$wppp_settings = new WPPP_Settings();
|
215 |
$wppp_settings->wppp_settings_init();
|
216 |
+
|
217 |
}
|
218 |
+
|
219 |
+
|
220 |
/**
|
221 |
* Shop columns.
|
222 |
*
|
233 |
endif;
|
234 |
|
235 |
return $columns;
|
236 |
+
|
237 |
}
|
238 |
+
|
239 |
+
|
240 |
/**
|
241 |
* Per page hook.
|
242 |
*
|
259 |
else :
|
260 |
return $this->settings['default_ppp'];
|
261 |
endif;
|
262 |
+
|
263 |
}
|
264 |
|
265 |
|
274 |
*/
|
275 |
public function wppp_pre_get_posts( $q ) {
|
276 |
|
277 |
+
if ( function_exists( 'woocommerce_products_will_display' ) && woocommerce_products_will_display() && $q->is_main_query() && ! is_admin() ) :
|
278 |
$q->set( 'posts_per_page', $this->wppp_loop_shop_per_page() );
|
279 |
endif;
|
280 |
|
281 |
return $q;
|
282 |
|
283 |
}
|
284 |
+
|
285 |
+
|
286 |
/**
|
287 |
* Add dropdown.
|
288 |
*
|
293 |
* @return void.
|
294 |
*/
|
295 |
public function wppp_shop_hooks() {
|
296 |
+
|
297 |
if ( $this->settings['location'] == 'top' ) :
|
298 |
add_action( 'woocommerce_before_shop_loop', array( $this, 'wppp_dropdown' ) );
|
299 |
elseif ( $this->settings['location'] == 'bottom' ) :
|
302 |
add_action( 'woocommerce_before_shop_loop', array( $this, 'wppp_dropdown' ) );
|
303 |
add_action( 'woocommerce_after_shop_loop', array( $this, 'wppp_dropdown' ) );
|
304 |
endif;
|
305 |
+
|
306 |
}
|
307 |
+
|
308 |
+
|
309 |
/**
|
310 |
* Products per page dropdown.
|
311 |
*
|
317 |
public function wppp_dropdown_object() {
|
318 |
$this->wppp_dropdown();
|
319 |
}
|
320 |
+
|
321 |
+
|
322 |
/**
|
323 |
* Include dropdown.
|
324 |
*
|
329 |
* @return void.
|
330 |
*/
|
331 |
public function wppp_dropdown() {
|
332 |
+
|
333 |
/**
|
334 |
* Products per page dropdown
|
335 |
*/
|
336 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wppp-dropdown.php';
|
337 |
new wppp_dropdown();
|
338 |
+
|
339 |
}
|
340 |
+
|
341 |
+
|
342 |
/**
|
343 |
* Initilize session.
|
344 |
*
|
351 |
* @return void.
|
352 |
*/
|
353 |
public function wppp_set_customer_session() {
|
354 |
+
|
355 |
global $woocommerce;
|
356 |
|
357 |
if ( $woocommerce->version > '2.1' ) :
|
358 |
$woocommerce->session->set_customer_session_cookie( true );
|
359 |
endif;
|
360 |
+
|
361 |
}
|
362 |
+
|
363 |
+
|
364 |
/**
|
365 |
* Set session.
|
366 |
*
|
373 |
* @return void.
|
374 |
*/
|
375 |
public function wppp_submit_check() {
|
376 |
+
|
377 |
global $woocommerce;
|
378 |
|
379 |
if ( isset( $_POST['wppp_ppp'] ) ) :
|
381 |
elseif ( isset( $_GET['wppp_ppp'] ) ) :
|
382 |
$woocommerce->session->set( 'products_per_page', $_GET['wppp_ppp'] );
|
383 |
endif;
|
384 |
+
|
385 |
}
|
386 |
+
|
387 |
|
388 |
}
|
389 |
|