WooCommerce Customizer - Version 1.0

Version Description

  • Initial release
Download this release

Release Info

Developer maxrice
Plugin Icon WooCommerce Customizer
Version 1.0
Comparing to
See all releases

Version 1.0

admin/class-wc-customizer-admin.php ADDED
@@ -0,0 +1,527 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Customizer Admin Class
4
+ *
5
+ * Loads / Saves admin settings page
6
+ *
7
+ *
8
+ * @package WooCommerce Customizer
9
+ * @subpackage WC_Customizer_Admin
10
+ * @category Class
11
+ * @author Max Rice
12
+ * @since 1.0
13
+ */
14
+
15
+ class WC_Customizer_Admin {
16
+
17
+ /** @var array tab IDs / titles admin page */
18
+ public static $tabs;
19
+
20
+ /** @var string sub-menu page hook suffix */
21
+ public static $page;
22
+
23
+
24
+ /**
25
+ * Init Admin class
26
+ *
27
+ * @access public
28
+ * @since 1.0
29
+ * @return void
30
+ */
31
+ public static function init() {
32
+
33
+ self::$tabs = array( 'shop_loop' => __( 'Shop Loop', WC_Customizer::$text_domain ),
34
+ 'product_page' => __( 'Product Page', WC_Customizer::$text_domain ),
35
+ 'checkout' => __( 'Checkout', WC_Customizer::$text_domain ),
36
+ 'misc' => __( 'Misc', WC_Customizer::$text_domain )
37
+ );
38
+
39
+ // Load necessary admin styles / scripts
40
+ add_action( 'admin_enqueue_scripts', __CLASS__ . '::load_styles_scripts' );
41
+
42
+ // Add 'Customizer' link under WooCommerce menu
43
+ add_action( 'admin_menu', __CLASS__ . '::add_menu_link' );
44
+
45
+ }
46
+
47
+ /**
48
+ * Load admin styles and scripts, only on our page
49
+ *
50
+ * @access public
51
+ * @since 1.0
52
+ * @param $hook_suffix
53
+ * @return void
54
+ */
55
+ public static function load_styles_scripts( $hook_suffix ) {
56
+ global $woocommerce;
57
+
58
+ // only load on our settings page
59
+ if ( $hook_suffix != self::$page )
60
+ return;
61
+
62
+ // WooCommerce styles
63
+ wp_enqueue_style( 'woocommerce_admin_styles', $woocommerce->plugin_url() . '/assets/css/admin.css' );
64
+
65
+ // WooCommerce Admin JS for tool tips
66
+ wp_enqueue_script( 'woocommerce_admin', $woocommerce->plugin_url() . '/assets/js/admin/woocommerce_admin.min.js', array( 'jquery', 'jquery-ui-widget', 'jquery-ui-core' ), $woocommerce->version );
67
+
68
+ }
69
+
70
+ /**
71
+ * Add 'Customizer' menu link under 'WooCommerce' top level menu
72
+ *
73
+ * @access public
74
+ * @since 1.0
75
+ * @return void
76
+ */
77
+ public static function add_menu_link() {
78
+
79
+ self::$page = add_submenu_page( 'woocommerce',
80
+ __( 'WooCommerce Customizer', WC_Customizer::$text_domain ),
81
+ __( 'Customizer', WC_Customizer::$text_domain ),
82
+ 'manage_woocommerce',
83
+ 'woocommerce_customizer',
84
+ __CLASS__ . '::display_settings_page'
85
+ );
86
+
87
+ }
88
+
89
+ /**
90
+ * Show Customizer settings page content for all tabs.
91
+ *
92
+ * @access public
93
+ * @since 1.0
94
+ * @return void
95
+ */
96
+ public static function display_settings_page() {
97
+
98
+ if ( false === ( $current_tab = self::get_current_tab() ) )
99
+ return;
100
+ ?>
101
+ <div class="wrap woocommerce">
102
+ <form method="post" id="mainform" action="" enctype="multipart/form-data">
103
+ <div class="icon32 icon32-woocommerce-settings" id="icon-woocommerce"><br /></div>
104
+ <h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
105
+ <?php
106
+
107
+ foreach ( self::$tabs as $tab_id => $tab_title ) :
108
+
109
+ $class = ( $tab_id == $current_tab ) ? 'nav-tab nav-tab-active' : 'nav-tab';
110
+ $url = add_query_arg( 'tab', $tab_id, admin_url( 'admin.php?page=woocommerce_customizer&tab=' ) );
111
+
112
+ printf( '<a href="%s" class="%s">%s</a>', $url, $class, $tab_title );
113
+
114
+ endforeach;
115
+
116
+ ?> </h2> <?php
117
+
118
+ wp_nonce_field( 'wc-customizer-settings', '_wpnonce', true, true );
119
+
120
+ //check post & verify nonce
121
+ if ( ! empty( $_POST ) ) {
122
+
123
+ if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'wc-customizer-settings' ) )
124
+ wp_die( __( 'Action failed. Please refresh the page and retry.', WC_Customizer::$text_domain ) );
125
+
126
+ self::save_fields( self::load_fields(), $current_tab );
127
+
128
+ // Redirect to settings
129
+ wp_redirect( add_query_arg( 'saved', 'true' ) );
130
+ exit;
131
+
132
+ }
133
+
134
+ // show error / success message
135
+ if ( ! empty( $_GET['saved'] ) )
136
+ echo '<div id="message" class="updated fade"><p><strong>' . __( 'Your customizations have been saved.', WC_Customizer::$text_domain ) . '</strong></p></div>';
137
+
138
+
139
+ self::output_fields( self::load_fields(), $current_tab );
140
+
141
+ ?>
142
+ <p class="submit">
143
+ <input name="save" class="button-primary" type="submit" value="<?php _e( 'Save Customizations', WC_Customizer::$text_domain ); ?>" />
144
+ </p>
145
+ </form>
146
+ </div>
147
+ <?php
148
+ }
149
+
150
+ /**
151
+ * Output fields to page
152
+ *
153
+ * @access public
154
+ * @since 1.0
155
+ * @param array $fields
156
+ * @param string $tab current tab slug
157
+ * @return void
158
+ */
159
+ public static function output_fields( $fields, $tab ) {
160
+ global $woocommerce;
161
+
162
+ // only use fields for current tab
163
+ $fields = $fields[$tab];
164
+
165
+ $customizations = maybe_unserialize( get_option( WC_Customizer::$option_name ) );
166
+
167
+ foreach ( $fields as $field ) :
168
+
169
+ if ( ! isset( $field['type'] ) ) continue;
170
+ if ( ! isset( $field['filter_id'] ) ) $field['filter_id'] = '';
171
+ if ( ! isset( $field['name'] ) ) $field['name'] = '';
172
+ if ( ! isset( $field['class'] ) ) $field['class'] = '';
173
+ if ( ! isset( $field['css'] ) ) $field['css'] = '';
174
+ if ( ! isset( $field['std'] ) ) $field['std'] = '';
175
+ if ( ! isset( $field['desc'] ) ) $field['desc'] = '';
176
+ if ( ! isset( $field['desc_tip'] ) ) $field['desc_tip'] = false;
177
+
178
+ if ( $field['desc_tip'] === true ) {
179
+ $description = '<img class="help_tip" data-tip="' . esc_attr( $field['desc'] ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" />';
180
+ } elseif ( $field['desc_tip'] ) {
181
+ $description = '<img class="help_tip" data-tip="' . esc_attr( $field['desc_tip'] ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" />';
182
+ } else {
183
+ $description = '<span class="description">' . $field['desc'] . '</span>';
184
+ }
185
+
186
+ switch ( $field['type'] ) :
187
+
188
+ case 'title':
189
+ if ( isset( $field['name'] ) && $field['name'] ) echo '<h3>' . $field['name'] . '</h3>';
190
+ if ( isset( $field['desc'] ) && $field['desc'] ) echo wpautop( wptexturize( $field['desc'] ) );
191
+ echo '<table class="form-table">' . "\n\n";
192
+ break;
193
+
194
+ case 'sectionend':
195
+ echo '</table>';
196
+ break;
197
+
198
+ case 'text':
199
+ ?>
200
+ <tr valign="top">
201
+ <th scope="row" class="titledesc">
202
+ <label for="<?php echo esc_attr( $field['filter_id'] ); ?>"><?php echo $field['name']; ?></label>
203
+ </th>
204
+ <td class="forminp">
205
+ <input name="<?php echo esc_attr( $field['filter_id'] ); ?>" id="<?php echo esc_attr( $field['filter_id'] ); ?>" type="<?php echo esc_attr( $field['type'] ); ?>" style="<?php echo esc_attr( $field['css'] ); ?>" value="<?php if ( isset( $customizations[$field['filter_id']] ) && ! empty( $customizations[$field['filter_id']] ) ) {
206
+ echo esc_attr( stripslashes( $customizations[$field['filter_id']] ) );
207
+ } else {
208
+ echo esc_attr( $field['std'] );
209
+ } ?>" /> <?php echo $description; ?></td>
210
+ </tr><?php
211
+ break;
212
+
213
+ default:
214
+ break;
215
+
216
+ endswitch;
217
+
218
+ endforeach;
219
+ }
220
+
221
+ /**
222
+ * Save admin fields into serialized option
223
+ *
224
+ * @access public
225
+ * @since 1.0
226
+ * @param array $fields
227
+ * @param string $tab current tab slug
228
+ * @return bool
229
+ */
230
+ public static function save_fields( $fields, $tab ) {
231
+
232
+ // only use fields for current tab
233
+ $fields = $fields[$tab];
234
+
235
+ $customizations = maybe_unserialize( get_option( WC_Customizer::$option_name ) );
236
+
237
+ foreach ( $fields as $field ) :
238
+
239
+ if ( ! isset( $field['filter_id'] ) )
240
+ continue;
241
+
242
+ if ( isset( $field['filter_id'] ) && ! empty( $_POST[$field['filter_id']] ) ) {
243
+
244
+ $customizations[$field['filter_id']] = woocommerce_clean( $_POST[$field['filter_id']] );
245
+
246
+ } elseif ( isset( $field['filter_id'] ) ) {
247
+
248
+ unset( $customizations[$field['filter_id']] );
249
+
250
+ }
251
+
252
+ endforeach;
253
+
254
+ update_option( WC_Customizer::$option_name, $customizations );
255
+
256
+ return true;
257
+ }
258
+
259
+ /**
260
+ * Return admin fields in proper format for outputting / saving
261
+ *
262
+ * @access private
263
+ * @since 1.0
264
+ * @return array
265
+ */
266
+ private static function load_fields() {
267
+
268
+ return array(
269
+
270
+ 'shop_loop' =>
271
+
272
+ array(
273
+
274
+ array(
275
+ 'name' => __( 'Add to Cart Button Text', WC_Customizer::$text_domain ),
276
+ 'type' => 'title'
277
+ ),
278
+
279
+ array(
280
+ 'filter_id' => 'add_to_cart_text',
281
+ 'name' => __( 'Simple Product', WC_Customizer::$text_domain ),
282
+ 'desc_tip' => __( 'Changes the add to cart button text for simple products on all loop pages', WC_Customizer::$text_domain ),
283
+ 'type' => 'text'
284
+ ),
285
+
286
+ array(
287
+ 'filter_id' => 'variable_add_to_cart_text',
288
+ 'name' => __( 'Variable Product', WC_Customizer::$text_domain ),
289
+ 'desc_tip' => __( 'Changes the add to cart button text for variable products on all loop pages', WC_Customizer::$text_domain ),
290
+ 'type' => 'text'
291
+ ),
292
+
293
+ array(
294
+ 'filter_id' => 'grouped_add_to_cart_text',
295
+ 'name' => __( 'Grouped Product', WC_Customizer::$text_domain ),
296
+ 'desc_tip' => __( 'Changes the add to cart button text for grouped products on all loop pages', WC_Customizer::$text_domain ),
297
+ 'type' => 'text'
298
+ ),
299
+
300
+ array(
301
+ 'filter_id' => 'external_add_to_cart_text',
302
+ 'name' => __( 'External Product', WC_Customizer::$text_domain ),
303
+ 'desc_tip' => __( 'Changes the add to cart button text for external products on all loop pages', WC_Customizer::$text_domain ),
304
+ 'type' => 'text'
305
+ ),
306
+
307
+ array(
308
+ 'filter_id' => 'out_of_stock_add_to_cart_text',
309
+ 'name' => __( 'Out of Stock Product', WC_Customizer::$text_domain ),
310
+ 'desc_tip' => __( 'Changes the add to cart button text for out of stock products on all loop pages', WC_Customizer::$text_domain ),
311
+ 'type' => 'text'
312
+ ),
313
+
314
+ array( 'type' => 'sectionend' ),
315
+
316
+ array(
317
+ 'name' => __( 'Layout', WC_Customizer::$text_domain ),
318
+ 'type' => 'title'
319
+ ),
320
+
321
+ array(
322
+ 'filter_id' => 'loop_shop_per_page',
323
+ 'name' => __( 'Products displayed per page', WC_Customizer::$text_domain ),
324
+ 'desc_tip' => __( 'Changes the number of products displayed per page', WC_Customizer::$text_domain ),
325
+ 'type' => 'text'
326
+ ),
327
+
328
+ array(
329
+ 'filter_id' => 'loop_shop_columns',
330
+ 'name' => __( 'Product columns displayed per page', WC_Customizer::$text_domain ),
331
+ 'desc_tip' => __( 'Changes the number of columns displayed per page', WC_Customizer::$text_domain ),
332
+ 'type' => 'text'
333
+ ),
334
+
335
+ array(
336
+ 'filter_id' => 'woocommerce_product_thumbnails_columns',
337
+ 'name' => __( 'Product thumbnail columns displayed', WC_Customizer::$text_domain ),
338
+ 'desc_tip' => __( 'Changes the number of product thumbnail columns displayed', WC_Customizer::$text_domain ),
339
+ 'type' => 'text'
340
+ ),
341
+
342
+ array( 'type' => 'sectionend' )
343
+
344
+ ),
345
+
346
+ 'product_page' =>
347
+
348
+ array(
349
+ // tab title customization coming in wc 1.7
350
+ /*array(
351
+ 'name' => __( 'Tab Titles', WC_Customizer::$text_domain ),
352
+ 'type' => 'title'
353
+ ),
354
+
355
+ array(
356
+ 'filter_id' => 'woocommerce_product_description_tab_title',
357
+ 'name' => __( 'Product Description', WC_Customizer::$text_domain ),
358
+ 'desc_tip' => __( 'Changes the Production Description tab title', WC_Customizer::$text_domain ),
359
+ 'type' => 'text'
360
+ ),
361
+
362
+ array(
363
+ 'filter_id' => 'woocommerce_product_additional_information_tab_title',
364
+ 'name' => __( 'Additional Information', WC_Customizer::$text_domain ),
365
+ 'desc_tip' => __( 'Changes the Additional Information tab title', WC_Customizer::$text_domain ),
366
+ 'type' => 'text'
367
+ ),
368
+
369
+ array(
370
+ 'filter_id' => 'woocommerce_reviews_tab_title',
371
+ 'name' => __( 'Reviews', WC_Customizer::$text_domain ),
372
+ 'desc_tip' => __( 'Changes the Reviews tab title', WC_Customizer::$text_domain ),
373
+ 'type' => 'text'
374
+ ),
375
+
376
+ array( 'type' => 'sectionend' ),*/
377
+
378
+ array(
379
+ 'name' => __( 'Tab Headings', WC_Customizer::$text_domain ),
380
+ 'type' => 'title'
381
+ ),
382
+
383
+ array(
384
+ 'filter_id' => 'woocommerce_product_description_heading',
385
+ 'name' => __( 'Product Description', WC_Customizer::$text_domain ),
386
+ 'desc_tip' => __( 'Changes the Product Description tab heading', WC_Customizer::$text_domain ),
387
+ 'type' => 'text'
388
+ ),
389
+
390
+ array(
391
+ 'filter_id' => 'woocommerce_product_additional_information_heading',
392
+ 'name' => __( 'Additional Information', WC_Customizer::$text_domain ),
393
+ 'desc_tip' => __( 'Changes the Additional Information tab heading', WC_Customizer::$text_domain ),
394
+ 'type' => 'text'
395
+ ),
396
+
397
+ array( 'type' => 'sectionend' ),
398
+
399
+ array(
400
+ 'name' => __( 'Add to Cart Button Text', WC_Customizer::$text_domain ),
401
+ 'type' => 'title'
402
+ ),
403
+
404
+ array(
405
+ 'filter_id' => 'single_add_to_cart_text',
406
+ 'name' => __( 'All Product Types', WC_Customizer::$text_domain ),
407
+ 'desc_tip' => __( 'Changes the Add to Cart button text on the single product page for all product type', WC_Customizer::$text_domain ),
408
+ 'type' => 'text'
409
+ ),
410
+
411
+ array( 'type' => 'sectionend' )
412
+ ),
413
+
414
+ 'checkout' =>
415
+
416
+ array(
417
+
418
+ array(
419
+ 'name' => __( 'Messages', WC_Customizer::$text_domain ),
420
+ 'type' => 'title'
421
+ ),
422
+
423
+ array(
424
+ 'filter_id' => 'woocommerce_checkout_must_be_logged_in_message',
425
+ 'name' => __( 'Must be logged in text', WC_Customizer::$text_domain ),
426
+ 'desc_tip' => __( 'Changes the message displayed when a customer must be logged in to checkout', WC_Customizer::$text_domain ),
427
+ 'type' => 'text'
428
+ ),
429
+
430
+ array(
431
+ 'filter_id' => 'woocommerce_checkout_coupon_message',
432
+ 'name' => __( 'Coupon text', WC_Customizer::$text_domain ),
433
+ 'desc_tip' => __( 'Changes the message displayed if the coupon form is enabled on checkout', WC_Customizer::$text_domain ),
434
+ 'type' => 'text'
435
+ ),
436
+
437
+ array(
438
+ 'filter_id' => 'woocommerce_checkout_login_message',
439
+ 'name' => __( 'Login text', WC_Customizer::$text_domain ),
440
+ 'desc_tip' => __( 'Changes the message displayed if customers can login at checkout', WC_Customizer::$text_domain ),
441
+ 'type' => 'text'
442
+ ),
443
+
444
+ array( 'type' => 'sectionend' ),
445
+
446
+ array(
447
+ 'name' => __( 'Button Text', WC_Customizer::$text_domain ),
448
+ 'type' => 'title'
449
+ ),
450
+
451
+ array(
452
+ 'filter_id' => 'woocommerce_order_button_text',
453
+ 'name' => __( 'Submit Order button', WC_Customizer::$text_domain ),
454
+ 'desc_tip' => __( 'Changes the Place Order button text on checkout', WC_Customizer::$text_domain ),
455
+ 'type' => 'text'
456
+ ),
457
+
458
+ array( 'type' => 'sectionend' )
459
+
460
+ ),
461
+
462
+ 'misc' =>
463
+
464
+ array(
465
+
466
+ array(
467
+ 'name' => __( 'Tax', WC_Customizer::$text_domain ),
468
+ 'type' => 'title'
469
+ ),
470
+
471
+ array(
472
+ 'filter_id' => 'woocommerce_countries_tax_or_vat',
473
+ 'name' => __( 'Tax Label', WC_Customizer::$text_domain ),
474
+ 'desc_tip' => __( 'Changes the Taxes label. Defaults to Tax for USA, VAT for European countries', WC_Customizer::$text_domain ),
475
+ 'type' => 'text'
476
+ ),
477
+
478
+ array(
479
+ 'filter_id' => 'woocommerce_countries_inc_tax_or_vat',
480
+ 'name' => __( 'Including Tax Label', WC_Customizer::$text_domain ),
481
+ 'desc_tip' => __( 'Changes the Including Taxes label. Defaults to Inc. tax for USA, Inc. VAT for European countries', WC_Customizer::$text_domain ),
482
+ 'type' => 'text'
483
+ ),
484
+
485
+ array(
486
+ 'filter_id' => 'woocommerce_countries_ex_tax_or_vat',
487
+ 'name' => __( 'Excluding Tax Label', WC_Customizer::$text_domain ),
488
+ 'desc_tip' => __( 'Changes the Excluding Taxes label. Defaults to Exc. tax for USA, Exc. VAT for European countries', WC_Customizer::$text_domain ),
489
+ 'type' => 'text'
490
+ ),
491
+
492
+ array( 'type' => 'sectionend' )
493
+
494
+ )
495
+
496
+ );
497
+ }
498
+
499
+ /**
500
+ * Get current tab slug
501
+ *
502
+ * @access private
503
+ * @since 1.0
504
+ * @return string slug of current tab
505
+ */
506
+ private static function get_current_tab() {
507
+
508
+ if ( empty( $_GET['tab'] ) ) {
509
+ // default to the first tab
510
+ reset( self::$tabs );
511
+ return key( self::$tabs );
512
+
513
+ } elseif ( array_key_exists( $_GET['tab'], self::$tabs ) ) {
514
+
515
+ return urldecode( $_GET['tab'] );
516
+
517
+ } else {
518
+
519
+ return false;
520
+ }
521
+ }
522
+
523
+ } // end class
524
+
525
+ WC_Customizer_Admin::init();
526
+
527
+ // end file
readme.txt ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WooCommerce Customizer ===
2
+ Contributors: maxrice
3
+ Donate link: http://www.maxrice.com
4
+ Tags: woocommerce
5
+ Requires at least: 3.3
6
+ Tested up to: 3.4.2
7
+ Stable tag: 1.0
8
+ License: GPLv3 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
+
11
+ Helps you customize WooCommerce without writing any code!
12
+
13
+ == Description ==
14
+
15
+ WooCommerce includes a lot of filters so you can customize button text, labels, and more -- but you have to write PHP
16
+ code to use them. This plugin provides a settings page where you can add your customizations and save them without
17
+ needing to write any code or modify any templates, which is helpful for quick change testing.
18
+
19
+ Here's the list of customizations you can make:
20
+
21
+ * Add to Cart button text for all product types (within the shop loop and on a single product page)
22
+ * The number of products displayed per page
23
+ * Heading text for the 'Product Description' and 'Additional Information' tab.
24
+ * Checkout page coupon / login text
25
+ * Checkout page 'Submit Order' button text
26
+ * Tax Label text
27
+
28
+ == Installation ==
29
+
30
+ 1. Upload `woocommerce-customizer` folder to the `/wp-content/plugins/` directory
31
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
32
+ 3. Go to 'Customizer' under the WooCommerce menu
33
+ 4. Start customizing!
34
+
35
+ == Frequently Asked Questions ==
36
+
37
+ = Why can't I customize xyz? =
38
+
39
+ Most likely because a filter does not yet exist within WooCommerce, or a filter does exist but is too complicated to be of use with this plugin.
40
+
41
+ = I found a bug! What do I do? =
42
+
43
+ Please submit an issue on [Github](https://github.com/maxrice/woocommerce-customizer/) along with a description of the problem so I can fix it :)
44
+
45
+ = Can I contribute to the plugin? =
46
+
47
+ Yes! Fork the plugin on [Github](https://github.com/maxrice/woocommerce-customizer/) and send a pull request.
48
+
49
+ == Screenshots ==
50
+
51
+ 1. Settings Page
52
+ 2. Customizations galore!
53
+
54
+ == Changelog ==
55
+
56
+ = 1.0 =
57
+ * Initial release
woocommerce-customizer.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: WooCommerce Customizer
4
+ * Plugin URI: http://www.maxrice.com/wordpress/woocommerce-customizer/
5
+ * Description: Helps you customize WooCommerce without writing any code
6
+ * Version: 1.0.0
7
+ * Author: Max Rice
8
+ * Author URI: http://www.maxrice.com
9
+ *
10
+ *
11
+ * Copyright: © 2012 Max Rice (max@maxrice.com)
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 Customizer
17
+ * @author Max Rice
18
+ * @since 1.0
19
+ */
20
+
21
+ /**
22
+ * Plugin Setup
23
+ *
24
+ * @since 1.0
25
+ */
26
+
27
+ // Check if WooCommerce is active
28
+ if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) )
29
+ return;
30
+
31
+
32
+ /**
33
+ * Main Class
34
+ *
35
+ * @since 1.0
36
+ */
37
+ class WC_Customizer {
38
+
39
+ /** @var string option db prefix */
40
+ public static $option_name = 'wc_customizer_active_customizations';
41
+
42
+ /** @var string text domain */
43
+ public static $text_domain = 'wc_customizer';
44
+
45
+ /** @var plugin path */
46
+ public static $plugin_path;
47
+
48
+ /** @var plugin url */
49
+ public static $plugin_url;
50
+
51
+ /** @var active filters */
52
+ public static $filters;
53
+
54
+ /**
55
+ * Init plugin
56
+ *
57
+ * @access public
58
+ * @since 1.0
59
+ * @return void
60
+ */
61
+ public static function init() {
62
+
63
+ self::$plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) );
64
+ self::$plugin_url = plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) );
65
+
66
+ if ( is_admin() ) {
67
+
68
+ self::admin_includes();
69
+
70
+ // add a 'Start Customizing' link to the plugin action links
71
+ // remember, __FILE__ derefs symlinks :(
72
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), __CLASS__ . '::plugin_manage_link' );
73
+
74
+ }
75
+
76
+ // load filter 'tags' and values
77
+ self::$filters = maybe_unserialize( get_option( self::$option_name ) );
78
+
79
+ // only add filters if some exist
80
+ if ( self::$filters ) {
81
+
82
+ foreach ( self::$filters as $filter_name => $filter_value ) {
83
+ add_filter( $filter_name, __CLASS__ . '::customize' );
84
+ }
85
+
86
+ //for use some day, in a galaxy far, far away, when PHP 5.3+ has greater WP adoption
87
+ //add_filter( $filter_name, function() use ( $filter_value ) { return $filter_value; } );
88
+ }
89
+
90
+ }
91
+
92
+
93
+ /**
94
+ * Add hook to selected filters
95
+ *
96
+ * @access public
97
+ * @since 1.0
98
+ * @return string $filter_value value to use for selected hook
99
+ */
100
+ public static function customize() {
101
+ $current_filter = current_filter();
102
+
103
+ foreach ( self::$filters as $filter_name => $filter_value ) {
104
+ if ( $filter_name == $current_filter )
105
+ return $filter_value;
106
+ }
107
+
108
+ }
109
+
110
+ /**
111
+ * Return the plugin action links. This will only be called if the plugin
112
+ * is active.
113
+ *
114
+ * @access public
115
+ * @since 1.0
116
+ * @param array $actions associative array of action names to anchor tags
117
+ * @return array associative array of plugin action links
118
+ */
119
+ public static function plugin_manage_link( $actions ) {
120
+ // add the link to the front of the actions list
121
+ return ( array_merge( array( 'start_customizing' => sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=woocommerce_customizer' ), __( 'Start Customizing', self::$text_domain ) ) ),
122
+ $actions )
123
+ );
124
+ }
125
+
126
+ /**
127
+ * Include admin class
128
+ *
129
+ * @access private
130
+ * @since 1.0
131
+ * @return void
132
+ */
133
+ private static function admin_includes() {
134
+
135
+ require_once( 'admin/class-wc-customizer-admin.php' );
136
+ }
137
+
138
+
139
+ } // end class
140
+
141
+ WC_Customizer::init();
142
+
143
+ //end file