WooCommerce Product Archive Customiser - Version 1.0.0

Version Description

  • 28/04/2016 =
  • New - All settings have been moved to the Customizer. Old settings should be automatically imported.
  • Tweak - Complete code tidy / removal of unused assets.
  • Tweak - Removed 'products per page' dropdown feature. There are various plugins on .org that do this, install one :)
Download this release

Release Info

Developer jameskoster
Plugin Icon wp plugin WooCommerce Product Archive Customiser
Version 1.0.0
Comparing to
See all releases

Code changes from version 0.5.1 to 1.0.0

archive-customiser.php DELETED
@@ -1,383 +0,0 @@
1
- <?php
2
- /*
3
- Plugin Name: WooCommerce Product Archive Customiser
4
- Plugin URI: http://jameskoster.co.uk/tag/product-archive-customiser/
5
- Version: 0.5.1
6
- Description: Allows you to customise WooCommerce product archives. Change the number of product columns and the number of products displayed per page. Toggle the display of core elements and enable some that are not included in WooCommerce core such as stock levels and product categories.
7
- Author: jameskoster
8
- Tested up to: 3.9.1
9
- Author URI: http://jameskoster.co.uk
10
- Text Domain: woocommerce-product-archive-customiser
11
- Domain Path: /languages/
12
-
13
- License: GNU General Public License v3.0
14
- License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
- */
16
-
17
- /**
18
- * Check if WooCommerce is active
19
- **/
20
- if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
21
-
22
- /**
23
- * Localisation
24
- **/
25
- load_plugin_textdomain( 'woocommerce-product-archive-customiser', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
26
-
27
- /**
28
- * PAC class
29
- **/
30
- if ( ! class_exists( 'WC_pac' ) ) {
31
-
32
- class WC_pac {
33
-
34
- public function __construct() {
35
- add_action( 'wp_enqueue_scripts', array( $this, 'wc_pac_styles' ) );
36
-
37
- // Init settings
38
- $this->settings = array(
39
- array(
40
- 'name' => __( 'Product Archives', 'woocommerce-product-archive-customiser' ),
41
- 'desc' => __( 'Toggle the display of various components on product archives and change product layout.', 'woocommerce-product-archive-customiser' ),
42
- 'type' => 'title',
43
- 'id' => 'wc_pac_options'
44
- ),
45
- array(
46
- 'title' => __( 'Product Columns', 'woocommerce-product-archive-customiser' ),
47
- 'desc' => __( 'The number of columns that products are arranged in to on archives', 'woocommerce-product-archive-customiser' ),
48
- 'id' => 'wc_pac_columns',
49
- 'default' => '4',
50
- 'type' => 'select',
51
- 'options' => array(
52
- '2' => __( '2', 'woocommerce-product-archive-customiser' ),
53
- '3' => __( '3', 'woocommerce-product-archive-customiser' ),
54
- '4' => __( '4', 'woocommerce-product-archive-customiser' ),
55
- '5' => __( '5', 'woocommerce-product-archive-customiser' )
56
- )
57
- ),
58
- array(
59
- 'title' => __( 'Products per page', 'woocommerce-product-archive-customiser' ),
60
- 'desc' => __( 'The number of products displayed per page', 'woocommerce-product-archive-customiser' ),
61
- 'id' => 'wc_pac_products_per_page',
62
- 'default' => '10',
63
- 'type' => 'number',
64
- ),
65
- array(
66
- 'name' => __( 'Display', 'woocommerce-product-archive-customiser' ),
67
- 'desc' => __( 'Product Count', 'woocommerce-product-archive-customiser' ),
68
- 'id' => 'wc_pac_product_count',
69
- 'type' => 'checkbox',
70
- 'default' => 'yes'
71
- ),
72
- array(
73
- 'desc' => __( 'Per Page Dropdown', 'woocommerce-product-archive-customiser' ),
74
- 'id' => 'wc_pac_product_perpage',
75
- 'type' => 'checkbox',
76
- 'default' => 'no'
77
- ),
78
- array(
79
- 'desc' => __( 'Product Sorting', 'woocommerce-product-archive-customiser' ),
80
- 'id' => 'wc_pac_product_sorting',
81
- 'type' => 'checkbox',
82
- 'default' => 'yes'
83
- ),
84
- array(
85
- 'desc' => __( 'Sale Flashes', 'woocommerce-product-archive-customiser' ),
86
- 'id' => 'wc_pac_sale_flash',
87
- 'type' => 'checkbox',
88
- 'default' => 'yes'
89
- ),
90
- array(
91
- 'desc' => __( 'Add to cart buttons', 'woocommerce-product-archive-customiser' ),
92
- 'id' => 'wc_pac_add_to_cart',
93
- 'type' => 'checkbox',
94
- 'default' => 'yes'
95
- ),
96
- array(
97
- 'desc' => __( 'Thumbnails', 'woocommerce-product-archive-customiser' ),
98
- 'id' => 'wc_pac_thumbnail',
99
- 'type' => 'checkbox',
100
- 'default' => 'yes'
101
- ),
102
- array(
103
- 'desc' => __( 'Prices', 'woocommerce-product-archive-customiser' ),
104
- 'id' => 'wc_pac_price',
105
- 'type' => 'checkbox',
106
- 'default' => 'yes'
107
- ),
108
- array(
109
- 'desc' => __( 'Ratings', 'woocommerce-product-archive-customiser' ),
110
- 'id' => 'wc_pac_rating',
111
- 'type' => 'checkbox',
112
- 'default' => 'yes'
113
- ),
114
- array(
115
- 'desc' => __( 'Product categories', 'woocommerce-product-archive-customiser' ),
116
- 'id' => 'wc_pac_categories',
117
- 'type' => 'checkbox',
118
- 'default' => 'no'
119
- ),
120
- array(
121
- 'desc' => __( 'Stock', 'woocommerce-product-archive-customiser' ),
122
- 'id' => 'wc_pac_stock',
123
- 'type' => 'checkbox',
124
- 'default' => 'no'
125
- ),
126
- array(
127
- 'desc' => __( '"New" badges', 'woocommerce-product-archive-customiser' ),
128
- 'id' => 'wc_pac_new_badge',
129
- 'type' => 'checkbox',
130
- 'default' => 'no'
131
- ),
132
- array(
133
- 'desc' => __( 'Display the "New" badge for how many days?', 'woocommerce-product-archive-customiser' ),
134
- 'id' => 'wc_pac_newness',
135
- 'type' => 'number',
136
- 'default' => '30'
137
- ),
138
- array( 'type' => 'sectionend', 'id' => 'wc_pac_options' ),
139
- );
140
-
141
-
142
- // Default options
143
- add_option( 'wc_pac_columns', '4' );
144
- add_option( 'wc_pac_products_per_page', '10' );
145
- add_option( 'wc_pac_product_perpage', 'no' );
146
- add_option( 'wc_pac_product_count', 'yes' );
147
- add_option( 'wc_pac_product_sorting', 'yes' );
148
- add_option( 'wc_pac_sale_flash', 'yes' );
149
- add_option( 'wc_pac_add_to_cart', 'yes' );
150
- add_option( 'wc_pac_thumbnail', 'yes' );
151
- add_option( 'wc_pac_price', 'yes' );
152
- add_option( 'wc_pac_rating', 'yes' );
153
- add_option( 'wc_pac_new_badge', 'no' );
154
- add_option( 'wc_pac_categories', 'no' );
155
- add_option( 'wc_pac_stock', 'no' );
156
- add_option( 'wc_pac_newness', '30' );
157
-
158
-
159
- // Admin
160
- add_action( 'woocommerce_settings_catalog_options_after', array( $this, 'admin_settings' ), 20 );
161
- add_action( 'woocommerce_update_options_catalog', array( $this, 'save_admin_settings' ) ); // < 2.1
162
- add_action( 'woocommerce_update_options_products', array( $this, 'save_admin_settings' ) ); // 2.1 +
163
- add_action( 'admin_enqueue_scripts', array( $this, 'wc_pac_admin_scripts' ) );
164
- add_action( 'init', array( $this, 'wc_pac_fire_customisations' ) );
165
- add_action( 'wp', array( $this, 'wc_pac_columns' ) ); // This doesn't work when hooked into init :(
166
-
167
- }
168
-
169
-
170
- /*-----------------------------------------------------------------------------------*/
171
- /* Class Functions */
172
- /*-----------------------------------------------------------------------------------*/
173
-
174
- // Load the settings
175
- function admin_settings() {
176
- woocommerce_admin_fields( $this->settings );
177
- }
178
-
179
-
180
- // Save the settings
181
- function save_admin_settings() {
182
- woocommerce_update_options( $this->settings );
183
- }
184
-
185
- // Admin scripts
186
- function wc_pac_admin_scripts() {
187
- $screen = get_current_screen();
188
- $wc_screen_id = strtolower( __( 'WooCommerce', 'woocommerce' ) );
189
-
190
- // WooCommerce admin pages
191
- if ( in_array( $screen->id, apply_filters( 'woocommerce_screen_ids', array( 'toplevel_page_' . $wc_screen_id, $wc_screen_id . '_page_woocommerce_settings' ) ) ) ) {
192
-
193
- wp_enqueue_script( 'wc-pac-script', plugins_url( '/assets/js/script.min.js', __FILE__ ) );
194
-
195
- }
196
- }
197
-
198
- // Setup styles
199
- function wc_pac_styles() {
200
- wp_enqueue_style( 'pac-styles', plugins_url( '/assets/css/pac.css', __FILE__ ) );
201
- wp_enqueue_style( 'pac-layout-styles', plugins_url( '/assets/css/layout.css', __FILE__ ), '', '', 'only screen and (min-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', $breakpoint = '768px' ) . ')' );
202
- }
203
-
204
- // Fire customisations!
205
- function wc_pac_fire_customisations() {
206
-
207
- // Products per page
208
- add_filter( 'loop_shop_per_page', array( $this, 'woocommerce_pac_products_per_page' ), 20 );
209
-
210
- // Per Page Dropdown
211
- if ( get_option( 'wc_pac_product_perpage' ) == 'yes' ) {
212
- add_action( 'woocommerce_before_shop_loop', array( $this, 'woocommerce_pac_show_product_perpage' ), 30 );
213
- }
214
-
215
- // Sale flash
216
- if ( get_option( 'wc_pac_sale_flash' ) == 'no' ) {
217
- remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
218
- }
219
-
220
- // Result Count
221
- if ( get_option( 'wc_pac_product_count' ) == 'no' ) {
222
- remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
223
- }
224
-
225
- // Product Ordering
226
- if ( get_option( 'wc_pac_product_sorting' ) == 'no' ) {
227
- remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
228
- }
229
-
230
- // Add to cart button
231
- if ( get_option( 'wc_pac_add_to_cart' ) == 'no' ) {
232
- remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
233
- }
234
-
235
- // Thumbnail
236
- if ( get_option( 'wc_pac_thumbnail' ) == 'no' ) {
237
- remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
238
- }
239
-
240
- // Price
241
- if ( get_option( 'wc_pac_price' ) == 'no' ) {
242
- remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
243
- }
244
-
245
- // Rating
246
- if ( get_option( 'wc_pac_rating' ) == 'no' ) {
247
- remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
248
- }
249
-
250
- // New Badge
251
- if ( get_option( 'wc_pac_new_badge' ) == 'yes' ) {
252
- add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'woocommerce_pac_show_product_loop_new_badge' ), 30 );
253
- }
254
-
255
- // Stock
256
- if ( get_option( 'wc_pac_stock' ) == 'yes' ) {
257
- add_action( 'woocommerce_after_shop_loop_item', array( $this, 'woocommerce_pac_show_product_stock' ), 30 );
258
- }
259
-
260
- // Categories
261
- if ( get_option( 'wc_pac_categories' ) == 'yes' ) {
262
- add_action( 'woocommerce_after_shop_loop_item', array( $this, 'woocommerce_pac_show_product_categories' ), 30 );
263
- }
264
- }
265
-
266
- // Product columns
267
- function wc_pac_columns() {
268
- // Product columns
269
- if ( is_shop() || is_product_category() || is_product_tag() ) {
270
- add_filter( 'body_class', array( $this, 'woocommerce_pac_columns' ) );
271
- add_filter( 'loop_shop_columns', array( $this, 'woocommerce_pac_products_row' ) );
272
- }
273
- }
274
-
275
-
276
- /*-----------------------------------------------------------------------------------*/
277
- /* Frontend Functions */
278
- /*-----------------------------------------------------------------------------------*/
279
-
280
- // Products per page
281
- function woocommerce_pac_products_per_page() {
282
- $per_page = get_option( 'wc_pac_products_per_page' );
283
- if ( isset( $_COOKIE['per_page'] ) ) {
284
- $per_page = $_COOKIE['per_page'];
285
- }
286
- if ( isset( $_POST['per_page'] ) ) {
287
- setcookie( 'per_page', $_POST['per_page'], time()+1209600, '/' );
288
- $per_page = $_POST['per_page'];
289
- }
290
- return $per_page;
291
- }
292
-
293
- // Per Page Dropdown
294
- function woocommerce_pac_show_product_perpage() {
295
- $per_page = get_option( 'wc_pac_products_per_page' );
296
-
297
- if ( isset( $_REQUEST['per_page'] ) ) {
298
- $woo_per_page = $_REQUEST['per_page'];
299
- } elseif ( ! isset( $_REQUEST['per_page'] ) && isset( $_COOKIE['per_page'] ) ) {
300
- $woo_per_page = $_COOKIE['per_page'];
301
- } else {
302
- $woo_per_page = $per_page;
303
- }
304
-
305
- // set action URL
306
- if ( is_shop() ) {
307
- $url = get_permalink( wc_get_page_id( 'shop' ) );
308
- } elseif ( is_product_category() ) {
309
- global $wp_query;
310
- $cat = $wp_query->get_queried_object();
311
- $url = get_term_link( $cat );
312
- } elseif ( is_product_tag() ) {
313
- global $wp_query;
314
- $tag = $wp_query->get_queried_object();
315
- $url = get_term_link( $tag );
316
- }
317
-
318
- // add querystring to URL if set
319
- if ( $_SERVER['QUERY_STRING'] != '' ) {
320
- $url .= '?' . $_SERVER['QUERY_STRING'];
321
- }
322
-
323
- ?>
324
- <form class="woocommerce-ordering" method="post" action="<?php echo $url; ?>">
325
- <select name="per_page" class="per_page" onchange="this.form.submit()">
326
- <?php
327
- $x = 1;
328
- while ( $x <= 5 ) {
329
- $value = $per_page * $x;
330
- $selected = selected( $woo_per_page, $value, false );
331
- $label = __( "{$value} per page", 'woocommerce-product-archive-customiser' );
332
- echo "<option value='{$value}' {$selected}>{$label}</option>";
333
- $x++;
334
- }
335
- ?>
336
- </select>
337
- </form>
338
- <?php
339
- }
340
-
341
- // Product columns
342
- function woocommerce_pac_columns( $classes ) {
343
- $columns = get_option( 'wc_pac_columns' );
344
- $classes[] = 'product-columns-' . $columns;
345
- return $classes;
346
- }
347
-
348
- function woocommerce_pac_products_row() {
349
- $columns = get_option( 'wc_pac_columns' );
350
- return $columns;
351
- }
352
-
353
- // Display the new badge
354
- function woocommerce_pac_show_product_loop_new_badge() {
355
- $postdate = get_the_time( 'Y-m-d' ); // Post date
356
- $postdatestamp = strtotime( $postdate ); // Timestamped post date
357
- $newness = get_option( 'wc_pac_newness' ); // Newness in days as defined by option
358
-
359
- if ( ( time() - ( 60 * 60 * 24 * $newness ) ) < $postdatestamp ) { // If the product was published within the newness time frame display the new badge
360
- echo '<p class="wc-new-badge"><span>' . __( 'New', 'woocommerce-product-archive-customiser' ) . '</span></p>';
361
- }
362
- }
363
-
364
- function woocommerce_pac_show_product_categories() {
365
- global $post;
366
- $terms_as_links = get_the_term_list( $post->ID, 'product_cat', '', ', ', '' );
367
- echo '<p class="categories"><small>' . $terms_as_links . '</small></p>';
368
- }
369
-
370
- function woocommerce_pac_show_product_stock() {
371
- global $product;
372
- $stock = $product->get_total_stock();
373
- if ( ! $product->is_in_stock() ) {
374
- echo '<p class="stock out-of-stock"><small>' . __( 'Out of stock', 'woocommerce' ) . '</small></p>';
375
- } elseif ( $stock > 1 ) {
376
- echo '<p class="stock in-stock"><small>' . sprintf( __( '%s in stock', 'woocommerce' ), $stock ) . '</small></p>';
377
- }
378
- }
379
- }
380
-
381
- $WC_pac = new WC_pac();
382
- }
383
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/script.js DELETED
@@ -1,13 +0,0 @@
1
- (function ($) {
2
-
3
- jQuery( document ).ready( function( $ ) {
4
- jQuery( 'input#wc_pac_new_badge' ).change( function() {
5
- if ( jQuery( this ).is( ':checked' ) ) {
6
- jQuery( 'input#wc_pac_new_badge' ).parents( ':eq(3)' ).next().show();
7
- } else {
8
- jQuery( 'input#wc_pac_new_badge' ).parents( ':eq(3)' ).next().hide();
9
- }
10
- }).change();
11
- });
12
-
13
- }(jQuery));
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/script.min.js DELETED
@@ -1 +0,0 @@
1
- (function(e){jQuery(document).ready(function(e){jQuery("input#wc_pac_new_badge").change(function(){jQuery(this).is(":checked")?jQuery("input#wc_pac_new_badge").parents(":eq(3)").next().show():jQuery("input#wc_pac_new_badge").parents(":eq(3)").next().hide()}).change()})})(jQuery);
 
languages/woocommerce-product-archive-customiser.pot CHANGED
@@ -1,124 +1,106 @@
1
- # Copyright (C) 2014-2016
2
- # This file is distributed under the same license as the package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: \n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/woocommerce-product-archive-customiser\n"
7
- "POT-Creation-Date: 2014-05-15 10:36:50+00:00\n"
8
- "PO-Revision-Date: 2016-03-13 22:00+0100\n"
9
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
10
- "Language-Team: LANGUAGE <LL@li.org>\n"
11
- "Language: \n"
12
  "MIME-Version: 1.0\n"
13
  "Content-Type: text/plain; charset=UTF-8\n"
14
  "Content-Transfer-Encoding: 8bit\n"
 
 
 
15
 
16
- #: archive-customiser.php:40
17
  msgid "Product Archives"
18
  msgstr ""
19
 
20
- #: archive-customiser.php:41
21
- msgid ""
22
- "Toggle the display of various components on product archives and change "
23
- "product layout."
24
- msgstr ""
25
-
26
- #: archive-customiser.php:46
27
- msgid "Product Columns"
28
- msgstr ""
29
-
30
- #: archive-customiser.php:47
31
- msgid "The number of columns that products are arranged in to on archives"
32
- msgstr ""
33
-
34
- #: archive-customiser.php:52
35
- msgid "2"
36
  msgstr ""
37
 
38
- #: archive-customiser.php:53
39
- msgid "3"
40
- msgstr ""
41
-
42
- #: archive-customiser.php:54
43
- msgid "4"
44
- msgstr ""
45
-
46
- #: archive-customiser.php:55
47
- msgid "5"
48
  msgstr ""
49
 
50
- #: archive-customiser.php:59
51
- msgid "Products per page"
52
  msgstr ""
53
 
54
- #: archive-customiser.php:60
55
- msgid "The number of products displayed per page"
56
  msgstr ""
57
 
58
- #: archive-customiser.php:66
59
- msgid "Display"
60
  msgstr ""
61
 
62
- #: archive-customiser.php:67
63
- msgid "Product Count"
64
  msgstr ""
65
 
66
- #: archive-customiser.php:73
67
- msgid "Per Page Dropdown"
68
  msgstr ""
69
 
70
- #: archive-customiser.php:79
71
- msgid "Product Sorting"
72
  msgstr ""
73
 
74
- #: archive-customiser.php:85
75
- msgid "Sale Flashes"
76
  msgstr ""
77
 
78
- #: archive-customiser.php:91
79
- msgid "Add to cart buttons"
80
  msgstr ""
81
 
82
- #: archive-customiser.php:97
83
- msgid "Thumbnails"
84
  msgstr ""
85
 
86
- #: archive-customiser.php:103
87
- msgid "Prices"
88
  msgstr ""
89
 
90
- #: archive-customiser.php:109
91
- msgid "Ratings"
92
  msgstr ""
93
 
94
- #: archive-customiser.php:115
95
- msgid "Product categories"
96
  msgstr ""
97
 
98
- #: archive-customiser.php:121
99
- msgid "Stock"
100
  msgstr ""
101
 
102
- #: archive-customiser.php:127
103
- msgid "\"New\" badges"
104
  msgstr ""
105
 
106
- #: archive-customiser.php:133
107
- msgid "Display the \"New\" badge for how many days?"
108
  msgstr ""
109
 
110
- #: archive-customiser.php:188
111
- msgid "WooCommerce"
112
  msgstr ""
113
 
114
- #: archive-customiser.php:360
115
- msgid "New"
 
 
 
 
116
  msgstr ""
117
 
118
- #: archive-customiser.php:374
119
- msgid "Out of stock"
120
  msgstr ""
121
 
122
- #: archive-customiser.php:376
123
- msgid "%d in stock"
124
  msgstr ""
1
+ # Copyright (C) 2016 WooCommerce Product Archive Customiser
2
+ # This file is distributed under the same license as the WooCommerce Product Archive Customiser package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WooCommerce Product Archive Customiser 1.0.0\n"
6
+ "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woocommerce-"
7
+ "product-archive-customiser\n"
8
+ "POT-Creation-Date: 2016-04-28 12:29:00+00:00\n"
 
 
 
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
16
+ #: woocommerce-product-archive-customiser.php:211
17
  msgid "Product Archives"
18
  msgstr ""
19
 
20
+ #: woocommerce-product-archive-customiser.php:225
21
+ msgid "Product columns"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  msgstr ""
23
 
24
+ #: woocommerce-product-archive-customiser.php:247
25
+ msgid "Products per page"
 
 
 
 
 
 
 
 
26
  msgstr ""
27
 
28
+ #: woocommerce-product-archive-customiser.php:288
29
+ msgid "Display product count"
30
  msgstr ""
31
 
32
+ #: woocommerce-product-archive-customiser.php:304
33
+ msgid "Display product sorting"
34
  msgstr ""
35
 
36
+ #: woocommerce-product-archive-customiser.php:320
37
+ msgid "Display sale flashes"
38
  msgstr ""
39
 
40
+ #: woocommerce-product-archive-customiser.php:336
41
+ msgid "Display add to cart buttons"
42
  msgstr ""
43
 
44
+ #: woocommerce-product-archive-customiser.php:352
45
+ msgid "Display product image"
46
  msgstr ""
47
 
48
+ #: woocommerce-product-archive-customiser.php:368
49
+ msgid "Display prices"
50
  msgstr ""
51
 
52
+ #: woocommerce-product-archive-customiser.php:384
53
+ msgid "Display ratings"
54
  msgstr ""
55
 
56
+ #: woocommerce-product-archive-customiser.php:400
57
+ msgid "Display new badge"
58
  msgstr ""
59
 
60
+ #: woocommerce-product-archive-customiser.php:416
61
+ msgid "Display the \"New\" badge for how many days"
62
  msgstr ""
63
 
64
+ #: woocommerce-product-archive-customiser.php:439
65
+ msgid "Display categories"
66
  msgstr ""
67
 
68
+ #: woocommerce-product-archive-customiser.php:455
69
+ msgid "Display stock"
70
  msgstr ""
71
 
72
+ #: woocommerce-product-archive-customiser.php:632
73
+ msgid "New"
74
  msgstr ""
75
 
76
+ #: woocommerce-product-archive-customiser.php:656
77
+ msgid "Out of stock"
78
  msgstr ""
79
 
80
+ #: woocommerce-product-archive-customiser.php:658
81
+ msgid "%s in stock"
82
  msgstr ""
83
 
84
+ #. Plugin Name of the plugin/theme
85
+ msgid "WooCommerce Product Archive Customiser"
86
  msgstr ""
87
 
88
+ #. Plugin URI of the plugin/theme
89
+ msgid "http://jameskoster.co.uk/tag/product-archive-customiser/"
90
  msgstr ""
91
 
92
+ #. Description of the plugin/theme
93
+ msgid ""
94
+ "Allows you to customise WooCommerce product archives. Change the number of "
95
+ "product columns and the number of products displayed per page. Toggle the "
96
+ "display of core elements and enable some that are not included in "
97
+ "WooCommerce core such as stock levels and product categories."
98
  msgstr ""
99
 
100
+ #. Author of the plugin/theme
101
+ msgid "jameskoster"
102
  msgstr ""
103
 
104
+ #. Author URI of the plugin/theme
105
+ msgid "http://jameskoster.co.uk"
106
  msgstr ""
readme.txt CHANGED
@@ -1,76 +1,81 @@
1
- === WooCommerce Product Archive Customiser ===
2
- Contributors: jameskoster
3
- Tags: woocommerce, ecommerce, products
4
- Requires at least: 3.5
5
- Tested up to: 4.1
6
- Stable tag: 0.5.1
7
- License: GPLv2 or later
8
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
-
10
- Customise the appearance of product archives in WooCommerce.
11
-
12
- == Description ==
13
-
14
- Allows you to customise WooCommerce product archives. Change the number of product columns and the number of products displayed per page. Toggle the display of core elements and enable some that are not included in WooCommerce core such as stock levels and product categories.
15
-
16
- Please feel free to contribute on <a href="https://github.com/jameskoster/woocommerce-product-archive-customiser">github</a>.
17
-
18
- == Installation ==
19
-
20
- 1. Upload `woocommerce-product-archive-customiser` to the `/wp-content/plugins/` directory
21
- 2. Activate the plugin through the 'Plugins' menu in WordPress
22
- 3. Configure the options on the Products tab of the WooCommerce settings screen.
23
- 3. Done!
24
-
25
- == Frequently Asked Questions ==
26
-
27
- = One / Some of the options don't work. What gives? =
28
-
29
- If your theme has been integrated with WooCommerce it is possibly already adding or removing some of the archive compontents. If so the plugin options may be overwritten by the theme regardless of the settings you choose.
30
-
31
- = The categories / new badge / stock don't look very good. Help! =
32
- It's possible you will need to add a little css to your theme / child theme to tidy up these elements.
33
-
34
- = I want to style the "new" badge, stock notices and categories myself, how do I remove the default styles? =
35
-
36
- There are only a couple of styles applied to these components. Although not best practise it's probably safe to just overwrite these with your own css. However, if you want to do it properly (and cut out a http request), add the following code to the functions.php file in your theme / child theme to dequeue the css:
37
-
38
- `
39
- add_action( 'wp_enqueue_scripts', 'remove_pac_styles', 30 );
40
- function remove_pac_styles() {
41
- wp_dequeue_style( 'pac-styles' );
42
- }
43
- `
44
-
45
- == Screenshots ==
46
-
47
- 1. The Product Archive Customiser Settings.
48
- 2. An example product archive with everything enabled.
49
-
50
- == Changelog ==
51
-
52
- = 0.5.1 - 13/03/2016 =
53
- * Tweat - Change formating of "in stock" message to use php formatting instead of concatenation.
54
-
55
- = 0.5.0 - 30/01/2015 =
56
- * Tweak - CSS classes for new badge / categories moved to parent element. Props emirpprime
57
- * Tweak - Fixed potential 'page not found' errors when using the products per page selector feature. Props billras
58
-
59
- = 0.4.0 - 13/06/2014 =
60
- * Fix - Rating option
61
- * Localization - Added .pot.
62
-
63
- = 0.3.0 - 04/02/2014 =
64
- * WooCommerce 2.1 compatibility.
65
- * Fixed a notice when using the products per page selector feature.
66
-
67
- = 0.2.0 - 28/11/2013 =
68
- * Added option for user to choose how many products to display per page. Kudos @spmlucas.
69
-
70
- = 0.1.1 - 10/06/2013 =
71
- * Product column settings now affect product categories & tags
72
- * Product categories display inline for better theme compatibility
73
- * Stripped object pass by reference
74
-
75
- = 0.1 =
 
 
 
 
 
76
  Initial release.
1
+ === WooCommerce Product Archive Customiser ===
2
+ Contributors: jameskoster
3
+ Tags: woocommerce, ecommerce, products
4
+ Requires at least: 4.4
5
+ Tested up to: 4.5.1
6
+ Stable tag: 1.0.0
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Customise the appearance of product archives in WooCommerce.
11
+
12
+ == Description ==
13
+
14
+ Allows you to customise WooCommerce product archives. Change the number of product columns and the number of products displayed per page. Toggle the display of core elements and enable some that are not included in WooCommerce core such as stock levels and product categories.
15
+
16
+ Please feel free to contribute on <a href="https://github.com/jameskoster/woocommerce-product-archive-customiser">github</a>.
17
+
18
+ == Installation ==
19
+
20
+ 1. Upload `woocommerce-product-archive-customiser` to the `/wp-content/plugins/` directory
21
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
22
+ 3. Configure the options in the 'Product Archives' section of the WordPress Customizer.
23
+ 3. Done!
24
+
25
+ == Frequently Asked Questions ==
26
+
27
+ = One / Some of the options don't work. What gives? =
28
+
29
+ If your theme has been integrated with WooCommerce it is possibly already adding or removing some of the archive compontents. If so the plugin options may be overwritten by the theme regardless of the settings you choose.
30
+
31
+ = The categories / new badge / stock don't look very good. Help! =
32
+ It's possible you will need to add a little css to your theme / child theme to tidy up these elements.
33
+
34
+ = I want to style the "new" badge, stock notices and categories myself, how do I remove the default styles? =
35
+
36
+ There are only a couple of styles applied to these components. Although not best practise it's probably safe to just overwrite these with your own css. However, if you want to do it properly (and cut out a http request), add the following code to the functions.php file in your theme / child theme to dequeue the css:
37
+
38
+ `
39
+ add_action( 'wp_enqueue_scripts', 'remove_pac_styles', 30 );
40
+ function remove_pac_styles() {
41
+ wp_dequeue_style( 'pac-styles' );
42
+ }
43
+ `
44
+
45
+ == Screenshots ==
46
+
47
+ 1. The Product Archive Customiser Settings.
48
+ 2. An example product archive with everything enabled.
49
+
50
+ == Changelog ==
51
+
52
+ = 1.0.0 - 28/04/2016 =
53
+ * New - All settings have been moved to the Customizer. Old settings should be automatically imported.
54
+ * Tweak - Complete code tidy / removal of unused assets.
55
+ * Tweak - Removed 'products per page' dropdown feature. There are various plugins on .org that do this, install one :)
56
+
57
+ = 0.5.1 - 13/03/2016 =
58
+ * Tweak - Change formatting of "in stock" message to use php formatting instead of concatenation.
59
+
60
+ = 0.5.0 - 30/01/2015 =
61
+ * Tweak - CSS classes for new badge / categories moved to parent element. Props emirpprime
62
+ * Tweak - Fixed potential 'page not found' errors when using the products per page selector feature. Props billras
63
+
64
+ = 0.4.0 - 13/06/2014 =
65
+ * Fix - Rating option
66
+ * Localization - Added .pot.
67
+
68
+ = 0.3.0 - 04/02/2014 =
69
+ * WooCommerce 2.1 compatibility.
70
+ * Fixed a notice when using the products per page selector feature.
71
+
72
+ = 0.2.0 - 28/11/2013 =
73
+ * Added option for user to choose how many products to display per page. Kudos @spmlucas.
74
+
75
+ = 0.1.1 - 10/06/2013 =
76
+ * Product column settings now affect product categories & tags
77
+ * Product categories display inline for better theme compatibility
78
+ * Stripped object pass by reference
79
+
80
+ = 0.1 =
81
  Initial release.
woocommerce-product-archive-customiser.php ADDED
@@ -0,0 +1,665 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: WooCommerce Product Archive Customiser
4
+ * Plugin URI: http://jameskoster.co.uk/tag/product-archive-customiser/
5
+ * Version: 1.0.0
6
+ * Description: Allows you to customise WooCommerce product archives. Change the number of product columns and the number of products displayed per page. Toggle the display of core elements and enable some that are not included in WooCommerce core such as stock levels and product categories.
7
+ * Author: jameskoster
8
+ * Tested up to: 4.5.1
9
+ * Author URI: http://jameskoster.co.uk
10
+ * Text Domain: woocommerce-product-archive-customiser
11
+ * Domain Path: /languages/
12
+
13
+ * License: GNU General Public License v3.0
14
+ * License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
+ *
16
+ * @package woocommerce_product_archive_customiser
17
+ */
18
+
19
+ /**
20
+ * Check if WooCommerce is active
21
+ **/
22
+ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
23
+
24
+ /**
25
+ * Localisation
26
+ */
27
+ load_plugin_textdomain( 'woocommerce-product-archive-customiser', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
28
+
29
+ /**
30
+ * PAC class
31
+ */
32
+ if ( ! class_exists( 'WC_pac' ) ) {
33
+
34
+ /**
35
+ * The Product Archive Customiser class
36
+ */
37
+ final class WC_pac {
38
+
39
+ /**
40
+ * The version number.
41
+ *
42
+ * @var string
43
+ * @access public
44
+ */
45
+ public $version;
46
+
47
+ /**
48
+ * The constructor!
49
+ */
50
+ public function __construct() {
51
+ $this->version = '1.0.0';
52
+
53
+ add_action( 'wp_enqueue_scripts', array( $this, 'wc_pac_styles' ) );
54
+ add_action( 'init', array( $this, 'wc_pac_setup' ) );
55
+ add_action( 'wp', array( $this, 'wc_pac_fire_customisations' ) );
56
+ add_action( 'wp', array( $this, 'wc_pac_columns' ) );
57
+
58
+ // Upgrade script.
59
+ if ( '1.0.0' === $this->version ) {
60
+ add_action( 'plugins_loaded', array( $this, 'update_settings' ) );
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Checks if any settings from <1.0.0 exist.
66
+ * If they do, run the importer and delete the old settings.
67
+ *
68
+ * @return void
69
+ */
70
+ public function update_settings() {
71
+ $old_setting = get_option( 'wc_pac_columns' );
72
+
73
+ if ( $old_setting ) {
74
+ $this->import_existing_settings();
75
+ $this->unset_old_settings();
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Import existing settings
81
+ *
82
+ * @return void
83
+ */
84
+ public function import_existing_settings() {
85
+ $old_columns = get_option( 'wc_pac_columns' );
86
+ $old_products_per_page = get_option( 'wc_pac_products_per_page' );
87
+ $old_product_count = get_option( 'wc_pac_product_count' );
88
+ $old_product_sorting = get_option( 'wc_pac_product_sorting' );
89
+ $old_sale_flash = get_option( 'wc_pac_sale_flash' );
90
+ $old_add_to_cart = get_option( 'wc_pac_add_to_cart' );
91
+ $old_thumbnail = get_option( 'wc_pac_thumbnail' );
92
+ $old_price = get_option( 'wc_pac_price' );
93
+ $old_ratings = get_option( 'wc_pac_rating' );
94
+ $old_new_badge = get_option( 'wc_pac_new_badge' );
95
+ $old_categories = get_option( 'wc_pac_categories' );
96
+ $old_stock = get_option( 'wc_pac_stock' );
97
+ $old_newness = get_option( 'wc_pac_newness' );
98
+
99
+ if ( $old_columns ) {
100
+ set_theme_mod( 'wc_pac_columns', $old_columns );
101
+ }
102
+
103
+ if ( $old_products_per_page ) {
104
+ set_theme_mod( 'wc_pac_products_per_page', $old_products_per_page );
105
+ }
106
+
107
+ if ( 'yes' === $old_product_count ) {
108
+ set_theme_mod( 'wc_pac_product_count', true );
109
+ } else {
110
+ set_theme_mod( 'wc_pac_product_count', false );
111
+ }
112
+
113
+ if ( 'yes' === $old_product_sorting ) {
114
+ set_theme_mod( 'wc_pac_product_sorting', true );
115
+ } else {
116
+ set_theme_mod( 'wc_pac_product_sorting', false );
117
+ }
118
+
119
+ if ( 'yes' === $old_sale_flash ) {
120
+ set_theme_mod( 'wc_pac_sale_flash', true );
121
+ } else {
122
+ set_theme_mod( 'wc_pac_sale_flash', false );
123
+ }
124
+
125
+ if ( 'yes' === $old_add_to_cart ) {
126
+ set_theme_mod( 'wc_pac_add_to_cart', true );
127
+ } else {
128
+ set_theme_mod( 'wc_pac_add_to_cart', false );
129
+ }
130
+
131
+ if ( 'yes' === $old_thumbnail ) {
132
+ set_theme_mod( 'wc_pac_thumbnail', true );
133
+ } else {
134
+ set_theme_mod( 'wc_pac_thumbnail', false );
135
+ }
136
+
137
+ if ( 'yes' === $old_price ) {
138
+ set_theme_mod( 'wc_pac_price', true );
139
+ } else {
140
+ set_theme_mod( 'wc_pac_price', false );
141
+ }
142
+
143
+ if ( 'yes' === $old_ratings ) {
144
+ set_theme_mod( 'wc_pac_rating', true );
145
+ } else {
146
+ set_theme_mod( 'wc_pac_rating', false );
147
+ }
148
+
149
+ if ( 'yes' === $old_new_badge ) {
150
+ set_theme_mod( 'wc_pac_new_badge', true );
151
+ } else {
152
+ set_theme_mod( 'wc_pac_new_badge', false );
153
+ }
154
+
155
+ if ( 'yes' === $old_categories ) {
156
+ set_theme_mod( 'wc_pac_categories', true );
157
+ } else {
158
+ set_theme_mod( 'wc_pac_categories', false );
159
+ }
160
+
161
+ if ( 'yes' === $old_stock ) {
162
+ set_theme_mod( 'wc_pac_stock', true );
163
+ } else {
164
+ set_theme_mod( 'wc_pac_stock', false );
165
+ }
166
+
167
+ if ( $old_newness ) {
168
+ set_theme_mod( 'wc_pac_newness', $old_newness );
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Unset the old settings
174
+ *
175
+ * @return void
176
+ */
177
+ public function unset_old_settings() {
178
+ delete_option( 'wc_pac_columns' );
179
+ delete_option( 'wc_pac_products_per_page' );
180
+ delete_option( 'wc_pac_product_perpage' );
181
+ delete_option( 'wc_pac_product_count' );
182
+ delete_option( 'wc_pac_product_sorting' );
183
+ delete_option( 'wc_pac_sale_flash' );
184
+ delete_option( 'wc_pac_add_to_cart' );
185
+ delete_option( 'wc_pac_thumbnail' );
186
+ delete_option( 'wc_pac_price' );
187
+ delete_option( 'wc_pac_rating' );
188
+ delete_option( 'wc_pac_new_badge' );
189
+ delete_option( 'wc_pac_categories' );
190
+ delete_option( 'wc_pac_stock' );
191
+ delete_option( 'wc_pac_newness' );
192
+ }
193
+
194
+ /**
195
+ * Product Archive Customiser setup
196
+ *
197
+ * @return void
198
+ */
199
+ public function wc_pac_setup() {
200
+ add_action( 'customize_register', array( $this, 'wc_pac_customize_register' ) );
201
+ }
202
+
203
+ /**
204
+ * Add settings to the Customizer
205
+ *
206
+ * @param array $wp_customize the Customiser settings object.
207
+ * @return void
208
+ */
209
+ public function wc_pac_customize_register( $wp_customize ) {
210
+ $wp_customize->add_section( 'wc_pac' , array(
211
+ 'title' => __( 'Product Archives', 'woocommerce-product-archive-customiser' ),
212
+ 'priority' => 30,
213
+ ) );
214
+
215
+ /**
216
+ * Product Columns
217
+ */
218
+ $wp_customize->add_setting( 'wc_pac_columns' , array(
219
+ 'default' => '4',
220
+ 'transport' => 'refresh',
221
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_choices' ),
222
+ ) );
223
+
224
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_columns', array(
225
+ 'label' => __( 'Product columns', 'woocommerce-product-archive-customiser' ),
226
+ 'section' => 'wc_pac',
227
+ 'settings' => 'wc_pac_columns',
228
+ 'type' => 'select',
229
+ 'choices' => array(
230
+ '2' => '2',
231
+ '3' => '3',
232
+ '4' => '4',
233
+ '5' => '5',
234
+ ),
235
+ ) ) );
236
+
237
+ /**
238
+ * Products Per Page
239
+ */
240
+ $wp_customize->add_setting( 'wc_pac_products_per_page' , array(
241
+ 'default' => '10',
242
+ 'transport' => 'refresh',
243
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_choices' ),
244
+ ) );
245
+
246
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_products_per_page', array(
247
+ 'label' => __( 'Products per page', 'woocommerce-product-archive-customiser' ),
248
+ 'section' => 'wc_pac',
249
+ 'settings' => 'wc_pac_products_per_page',
250
+ 'type' => 'select',
251
+ 'choices' => array(
252
+ '2' => '2',
253
+ '3' => '3',
254
+ '4' => '4',
255
+ '5' => '5',
256
+ '6' => '6',
257
+ '7' => '7',
258
+ '8' => '8',
259
+ '9' => '9',
260
+ '10' => '10',
261
+ '11' => '11',
262
+ '12' => '12',
263
+ '13' => '13',
264
+ '14' => '14',
265
+ '15' => '15',
266
+ '16' => '16',
267
+ '17' => '17',
268
+ '18' => '18',
269
+ '19' => '19',
270
+ '20' => '20',
271
+ '21' => '21',
272
+ '22' => '22',
273
+ '23' => '23',
274
+ '24' => '24',
275
+ ),
276
+ ) ) );
277
+
278
+ /**
279
+ * Display - product count
280
+ */
281
+ $wp_customize->add_setting( 'wc_pac_product_count' , array(
282
+ 'default' => true,
283
+ 'transport' => 'refresh',
284
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_checkbox' ),
285
+ ) );
286
+
287
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_product_count', array(
288
+ 'label' => __( 'Display product count', 'woocommerce-product-archive-customiser' ),
289
+ 'section' => 'wc_pac',
290
+ 'settings' => 'wc_pac_product_count',
291
+ 'type' => 'checkbox',
292
+ ) ) );
293
+
294
+ /**
295
+ * Display - product sorting
296
+ */
297
+ $wp_customize->add_setting( 'wc_pac_product_sorting' , array(
298
+ 'default' => true,
299
+ 'transport' => 'refresh',
300
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_checkbox' ),
301
+ ) );
302
+
303
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_product_sorting', array(
304
+ 'label' => __( 'Display product sorting', 'woocommerce-product-archive-customiser' ),
305
+ 'section' => 'wc_pac',
306
+ 'settings' => 'wc_pac_product_sorting',
307
+ 'type' => 'checkbox',
308
+ ) ) );
309
+
310
+ /**
311
+ * Display - product sale flashes
312
+ */
313
+ $wp_customize->add_setting( 'wc_pac_sale_flash' , array(
314
+ 'default' => true,
315
+ 'transport' => 'refresh',
316
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_checkbox' ),
317
+ ) );
318
+
319
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_sale_flash', array(
320
+ 'label' => __( 'Display sale flashes', 'woocommerce-product-archive-customiser' ),
321
+ 'section' => 'wc_pac',
322
+ 'settings' => 'wc_pac_sale_flash',
323
+ 'type' => 'checkbox',
324
+ ) ) );
325
+
326
+ /**
327
+ * Display - add to cart buttons
328
+ */
329
+ $wp_customize->add_setting( 'wc_pac_add_to_cart' , array(
330
+ 'default' => true,
331
+ 'transport' => 'refresh',
332
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_checkbox' ),
333
+ ) );
334
+
335
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_add_to_cart', array(
336
+ 'label' => __( 'Display add to cart buttons', 'woocommerce-product-archive-customiser' ),
337
+ 'section' => 'wc_pac',
338
+ 'settings' => 'wc_pac_add_to_cart',
339
+ 'type' => 'checkbox',
340
+ ) ) );
341
+
342
+ /**
343
+ * Display - product image
344
+ */
345
+ $wp_customize->add_setting( 'wc_pac_thumbnail' , array(
346
+ 'default' => true,
347
+ 'transport' => 'refresh',
348
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_checkbox' ),
349
+ ) );
350
+
351
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_thumbnail', array(
352
+ 'label' => __( 'Display product image', 'woocommerce-product-archive-customiser' ),
353
+ 'section' => 'wc_pac',
354
+ 'settings' => 'wc_pac_thumbnail',
355
+ 'type' => 'checkbox',
356
+ ) ) );
357
+
358
+ /**
359
+ * Display - price
360
+ */
361
+ $wp_customize->add_setting( 'wc_pac_price' , array(
362
+ 'default' => true,
363
+ 'transport' => 'refresh',
364
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_checkbox' ),
365
+ ) );
366
+
367
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_price', array(
368
+ 'label' => __( 'Display prices', 'woocommerce-product-archive-customiser' ),
369
+ 'section' => 'wc_pac',
370
+ 'settings' => 'wc_pac_price',
371
+ 'type' => 'checkbox',
372
+ ) ) );
373
+
374
+ /**
375
+ * Display - ratings
376
+ */
377
+ $wp_customize->add_setting( 'wc_pac_rating' , array(
378
+ 'default' => true,
379
+ 'transport' => 'refresh',
380
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_checkbox' ),
381
+ ) );
382
+
383
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_rating', array(
384
+ 'label' => __( 'Display ratings', 'woocommerce-product-archive-customiser' ),
385
+ 'section' => 'wc_pac',
386
+ 'settings' => 'wc_pac_rating',
387
+ 'type' => 'checkbox',
388
+ ) ) );
389
+
390
+ /**
391
+ * Display - new badge
392
+ */
393
+ $wp_customize->add_setting( 'wc_pac_new_badge' , array(
394
+ 'default' => false,
395
+ 'transport' => 'refresh',
396
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_checkbox' ),
397
+ ) );
398
+
399
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_new_badge', array(
400
+ 'label' => __( 'Display new badge', 'woocommerce-product-archive-customiser' ),
401
+ 'section' => 'wc_pac',
402
+ 'settings' => 'wc_pac_new_badge',
403
+ 'type' => 'checkbox',
404
+ ) ) );
405
+
406
+ /**
407
+ * Products Per Page
408
+ */
409
+ $wp_customize->add_setting( 'wc_pac_newness' , array(
410
+ 'default' => '7',
411
+ 'transport' => 'refresh',
412
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_choices' ),
413
+ ) );
414
+
415
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_newness', array(
416
+ 'label' => __( 'Display the "New" badge for how many days', 'woocommerce-product-archive-customiser' ),
417
+ 'section' => 'wc_pac',
418
+ 'settings' => 'wc_pac_newness',
419
+ 'type' => 'select',
420
+ 'choices' => array(
421
+ '7' => '7',
422
+ '14' => '14',
423
+ '21' => '21',
424
+ '28' => '28',
425
+ ),
426
+ 'active_callback' => array( $this, 'is_new_badge_enabled' ),
427
+ ) ) );
428
+
429
+ /**
430
+ * Display - categories
431
+ */
432
+ $wp_customize->add_setting( 'wc_pac_categories' , array(
433
+ 'default' => false,
434
+ 'transport' => 'refresh',
435
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_checkbox' ),
436
+ ) );
437
+
438
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_categories', array(
439
+ 'label' => __( 'Display categories', 'woocommerce-product-archive-customiser' ),
440
+ 'section' => 'wc_pac',
441
+ 'settings' => 'wc_pac_categories',
442
+ 'type' => 'checkbox',
443
+ ) ) );
444
+
445
+ /**
446
+ * Display - stock
447
+ */
448
+ $wp_customize->add_setting( 'wc_pac_stock' , array(
449
+ 'default' => false,
450
+ 'transport' => 'refresh',
451
+ 'sanitize_callback' => array( $this, 'wc_pac_sanitize_checkbox' ),
452
+ ) );
453
+
454
+ $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'wc_pac_stock', array(
455
+ 'label' => __( 'Display stock', 'woocommerce-product-archive-customiser' ),
456
+ 'section' => 'wc_pac',
457
+ 'settings' => 'wc_pac_stock',
458
+ 'type' => 'checkbox',
459
+ ) ) );
460
+ }
461
+
462
+ /**
463
+ * Checkbox sanitization callback.
464
+ *
465
+ * Sanitization callback for 'checkbox' type controls. This callback sanitizes `$checked`
466
+ * as a boolean value, either TRUE or FALSE.
467
+ *
468
+ * @param bool $checked Whether the checkbox is checked.
469
+ * @return bool Whether the checkbox is checked.
470
+ */
471
+ public function wc_pac_sanitize_checkbox( $checked ) {
472
+ return ( ( isset( $checked ) && true == $checked ) ? true : false );
473
+ }
474
+
475
+ /**
476
+ * Sanitizes choices (selects / radios)
477
+ * Checks that the input matches one of the available choices
478
+ *
479
+ * @param array $input the available choices.
480
+ * @param array $setting the setting object.
481
+ */
482
+ public function wc_pac_sanitize_choices( $input, $setting ) {
483
+ // Ensure input is a slug.
484
+ $input = sanitize_key( $input );
485
+
486
+ // Get list of choices from the control associated with the setting.
487
+ $choices = $setting->manager->get_control( $setting->id )->choices;
488
+
489
+ // If the input is a valid key, return it; otherwise, return the default.
490
+ return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
491
+ }
492
+
493
+ /**
494
+ * New badge callback
495
+ *
496
+ * @param array $control the Customizer controls.
497
+ * @return bool
498
+ */
499
+ public function is_new_badge_enabled( $control ) {
500
+ return $control->manager->get_setting( 'wc_pac_new_badge' )->value() === true ? true : false;
501
+ }
502
+
503
+ /**
504
+ * Enqueue styles
505
+ *
506
+ * @return void
507
+ */
508
+ function wc_pac_styles() {
509
+ wp_enqueue_style( 'pac-styles', plugins_url( '/assets/css/pac.css', __FILE__ ) );
510
+ wp_enqueue_style( 'pac-layout-styles', plugins_url( '/assets/css/layout.css', __FILE__ ), '', '', 'only screen and (min-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', $breakpoint = '768px' ) . ')' );
511
+ }
512
+
513
+ /**
514
+ * Action our customisations
515
+ *
516
+ * @return void
517
+ */
518
+ function wc_pac_fire_customisations() {
519
+
520
+ // Products per page.
521
+ add_filter( 'loop_shop_per_page', array( $this, 'woocommerce_pac_products_per_page' ), 20 );
522
+
523
+ // Sale flash.
524
+ if ( get_theme_mod( 'wc_pac_sale_flash' ) === false ) {
525
+ remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
526
+ }
527
+
528
+ // Result Count.
529
+ if ( get_theme_mod( 'wc_pac_product_count' ) === false ) {
530
+ remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
531
+ }
532
+
533
+ // Product Ordering.
534
+ if ( get_theme_mod( 'wc_pac_product_sorting' ) === false ) {
535
+ remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
536
+ }
537
+
538
+ // Add to cart button.
539
+ if ( get_theme_mod( 'wc_pac_add_to_cart' ) === false ) {
540
+ remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
541
+ }
542
+
543
+ // Thumbnail.
544
+ if ( get_theme_mod( 'wc_pac_thumbnail' ) === false ) {
545
+ remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
546
+ }
547
+
548
+ // Price.
549
+ if ( get_theme_mod( 'wc_pac_price' ) === false ) {
550
+ remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
551
+ }
552
+
553
+ // Rating.
554
+ if ( get_theme_mod( 'wc_pac_rating' ) === false ) {
555
+ remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
556
+ }
557
+
558
+ // New Badge.
559
+ if ( get_theme_mod( 'wc_pac_new_badge' ) === true ) {
560
+ add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'woocommerce_pac_show_product_loop_new_badge' ), 30 );
561
+ }
562
+
563
+ // Stock.
564
+ if ( get_theme_mod( 'wc_pac_stock' ) === true ) {
565
+ add_action( 'woocommerce_after_shop_loop_item', array( $this, 'woocommerce_pac_show_product_stock' ), 30 );
566
+ }
567
+
568
+ // Categories.
569
+ if ( get_theme_mod( 'wc_pac_categories' ) === true ) {
570
+ add_action( 'woocommerce_after_shop_loop_item', array( $this, 'woocommerce_pac_show_product_categories' ), 30 );
571
+ }
572
+ }
573
+
574
+ /**
575
+ * Set the product columns
576
+ *
577
+ * @return void
578
+ */
579
+ function wc_pac_columns() {
580
+ // Product columns.
581
+ if ( is_shop() || is_product_taxonomy() || is_product_category() || is_product_tag() ) {
582
+ add_filter( 'body_class', array( $this, 'woocommerce_pac_columns' ) );
583
+ add_filter( 'loop_shop_columns', array( $this, 'woocommerce_pac_products_row' ) );
584
+ }
585
+ }
586
+
587
+ /**
588
+ * Get the products per page setting and set a cookie
589
+ *
590
+ * @return string per page cookie
591
+ */
592
+ function woocommerce_pac_products_per_page() {
593
+ $per_page = get_theme_mod( 'wc_pac_products_per_page' );
594
+
595
+ return $per_page;
596
+ }
597
+
598
+ /**
599
+ * Product columns class
600
+ *
601
+ * @param array $classes current body classes.
602
+ * @return array new body classes
603
+ */
604
+ function woocommerce_pac_columns( $classes ) {
605
+ $columns = get_theme_mod( 'wc_pac_columns' );
606
+ $classes[] = 'product-columns-' . $columns;
607
+ return $classes;
608
+ }
609
+
610
+ /**
611
+ * Return the desired products per row
612
+ *
613
+ * @return int product columns
614
+ */
615
+ function woocommerce_pac_products_row() {
616
+ $columns = get_theme_mod( 'wc_pac_columns' );
617
+ return $columns;
618
+ }
619
+
620
+ /**
621
+ * Display the new badge
622
+ *
623
+ * @return void
624
+ */
625
+ function woocommerce_pac_show_product_loop_new_badge() {
626
+ $postdate = get_the_time( 'Y-m-d' ); // Post date.
627
+ $postdatestamp = strtotime( $postdate ); // Timestamped post date.
628
+ $newness = get_theme_mod( 'wc_pac_newness' ); // Newness in days as defined by option.
629
+
630
+ // If the product was published within the newness time frame display the new badge.
631
+ if ( ( time() - ( 60 * 60 * 24 * $newness ) ) < $postdatestamp ) {
632
+ echo '<p class="wc-new-badge"><span>' . esc_attr__( 'New', 'woocommerce-product-archive-customiser' ) . '</span></p>';
633
+ }
634
+ }
635
+
636
+ /**
637
+ * Display the product categories
638
+ *
639
+ * @return void
640
+ */
641
+ function woocommerce_pac_show_product_categories() {
642
+ global $post;
643
+ $terms_as_links = get_the_term_list( $post->ID, 'product_cat', '', ', ', '' );
644
+ echo '<p class="categories"><small>' . wp_kses_post( $terms_as_links ) . '</small></p>';
645
+ }
646
+
647
+ /**
648
+ * Display the product stock
649
+ *
650
+ * @return void
651
+ */
652
+ function woocommerce_pac_show_product_stock() {
653
+ global $product;
654
+ $stock = $product->get_total_stock();
655
+ if ( ! $product->is_in_stock() ) {
656
+ echo '<p class="stock out-of-stock"><small>' . esc_attr__( 'Out of stock', 'woocommerce-product-archive-customiser' ) . '</small></p>';
657
+ } elseif ( $stock > 1 ) {
658
+ echo '<p class="stock in-stock"><small>' . sprintf( esc_attr__( '%s in stock', 'woocommerce-product-archive-customiser' ), esc_attr( $stock ) ) . '</small></p>';
659
+ }
660
+ }
661
+ }
662
+
663
+ $wc_pac = new WC_pac();
664
+ }
665
+ }