Version Description
- Initial Release
=
Download this release
Release Info
Developer | algoritmika |
Plugin | Booster for WooCommerce |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- includes/admin/settings/class-wc-settings-jetpack.php +101 -0
- includes/class-wcj-call-for-price.php +157 -0
- includes/class-wcj-currencies.php +475 -0
- includes/class-wcj-old-slugs.php +161 -0
- includes/class-wcj-price-labels.php +267 -0
- includes/class-wcj-product-info.php +131 -0
- includes/class-wcj-sorting.php +277 -0
- readme.txt +50 -0
- woocommerce-jetpack.php +216 -0
includes/admin/settings/class-wc-settings-jetpack.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce Jetpack Settings
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
7 |
+
|
8 |
+
if ( ! class_exists( 'WC_Settings_Jetpack' ) ) :
|
9 |
+
|
10 |
+
/**
|
11 |
+
* WC_Settings_Jetpack
|
12 |
+
*/
|
13 |
+
class WC_Settings_Jetpack extends WC_Settings_Page {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Constructor.
|
17 |
+
*/
|
18 |
+
public function __construct() {
|
19 |
+
$this->id = 'jetpack';
|
20 |
+
$this->label = __( 'Jetpack', 'woojetpack' );
|
21 |
+
|
22 |
+
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
23 |
+
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
|
24 |
+
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
|
25 |
+
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get sections
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function get_sections() {
|
34 |
+
|
35 |
+
return apply_filters( 'wcj_settings_sections', array(
|
36 |
+
'' => __( 'Dashboard', 'woojetpack' ),
|
37 |
+
) );
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Output the settings
|
42 |
+
*/
|
43 |
+
public function output() {
|
44 |
+
|
45 |
+
global $current_section;
|
46 |
+
|
47 |
+
$settings = $this->get_settings( $current_section );
|
48 |
+
|
49 |
+
WC_Admin_Settings::output_fields( $settings );
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Save settings
|
54 |
+
*/
|
55 |
+
public function save() {
|
56 |
+
|
57 |
+
global $current_section;
|
58 |
+
|
59 |
+
$settings = $this->get_settings( $current_section );
|
60 |
+
WC_Admin_Settings::save_fields( $settings );
|
61 |
+
|
62 |
+
echo apply_filters('get_wc_jetpack_plus_message', '', 'global' );
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Get settings array
|
67 |
+
*
|
68 |
+
* @return array
|
69 |
+
*/
|
70 |
+
public function get_settings( $current_section = '' ) {
|
71 |
+
|
72 |
+
if ( $current_section != '' ) {
|
73 |
+
|
74 |
+
return apply_filters('wcj_settings_' . $current_section, array() );
|
75 |
+
}
|
76 |
+
else {
|
77 |
+
|
78 |
+
$settings[] = array( 'title' => __( 'Features', 'woojetpack' ), 'type' => 'title', 'desc' => $desc, 'id' => 'wcj_options' );
|
79 |
+
|
80 |
+
$settings = apply_filters( 'wcj_features_status', $settings );
|
81 |
+
|
82 |
+
/*$statuses = array();
|
83 |
+
$statuses[] = include_once( 'class-wcj-price-labels.php' );
|
84 |
+
$statuses[] = include_once( 'includes/class-wcj-call-for-price.php' );
|
85 |
+
$statuses[] = include_once( 'includes/class-wcj-currencies.php' );
|
86 |
+
$statuses[] = include_once( 'includes/class-wcj-sorting.php' );
|
87 |
+
$statuses[] = include_once( 'includes/class-wcj-old-slugs.php' );
|
88 |
+
$statuses[] = include_once( 'includes/class-wcj-product-info.php' );
|
89 |
+
foreach ( $statuses as $section )
|
90 |
+
$settings[] = $section->get_statuses()[1];*/
|
91 |
+
|
92 |
+
$settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_options' );
|
93 |
+
|
94 |
+
return $settings;//apply_filters('wcj_general_settings', $settings );
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
endif;
|
100 |
+
|
101 |
+
return new WC_Settings_Jetpack();
|
includes/class-wcj-call-for-price.php
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce Jetpack Call for Price
|
4 |
+
*
|
5 |
+
* The WooCommerce Jetpack Call for Price class.
|
6 |
+
*
|
7 |
+
* @class WCJ_Call_For_Price
|
8 |
+
* @category Class
|
9 |
+
* @author Algoritmika Ltd.
|
10 |
+
*/
|
11 |
+
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
13 |
+
|
14 |
+
if ( ! class_exists( 'WCJ_Call_For_Price' ) ) :
|
15 |
+
|
16 |
+
class WCJ_Call_For_Price {
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
|
20 |
+
// Defaults
|
21 |
+
$this->default_empty_price_text = '<strong>Call for price</strong>';
|
22 |
+
|
23 |
+
// HOOKS
|
24 |
+
// Main hooks
|
25 |
+
// Empty Price hooks
|
26 |
+
if ( get_option( 'wcj_call_for_price_enabled' ) == 'yes' ) {
|
27 |
+
|
28 |
+
add_filter( 'woocommerce_empty_price_html', array( $this, 'on_empty_price' ), 100 );
|
29 |
+
add_filter( 'woocommerce_sale_flash', array( $this, 'hide_sales_flash' ), 100, 2 );
|
30 |
+
}
|
31 |
+
|
32 |
+
// Settings hooks
|
33 |
+
add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
|
34 |
+
add_filter( 'wcj_settings_call_for_price', array( $this, 'get_settings' ), 100 );
|
35 |
+
add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* add_enabled_option.
|
40 |
+
*/
|
41 |
+
public function add_enabled_option( $settings ) {
|
42 |
+
|
43 |
+
$all_settings = $this->get_settings();
|
44 |
+
$settings[] = $all_settings[1];
|
45 |
+
|
46 |
+
return $settings;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* hide_sales_flash.
|
51 |
+
*/
|
52 |
+
public function hide_sales_flash( $post, $product ) {
|
53 |
+
|
54 |
+
if ( get_option('wcj_call_for_price_hide_sale_sign') === true ) {
|
55 |
+
|
56 |
+
$current_product = get_product( $product->ID );
|
57 |
+
if ( $current_product->get_price() == '' ) return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
return '<span class="onsale">' . __( 'Sale!', 'woocommerce' ) . '</span>';
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* on_empty_price.
|
65 |
+
*/
|
66 |
+
public function on_empty_price( $price ) {
|
67 |
+
|
68 |
+
if ( ( get_option('wcj_call_for_price_show_on_single') == 'yes' ) && is_single() ) return $this->default_empty_price_text;
|
69 |
+
if ( ( get_option('wcj_call_for_price_show_on_archive') == 'yes' ) && is_archive() ) return $this->default_empty_price_text;
|
70 |
+
if ( ( get_option('wcj_call_for_price_show_on_home') == 'yes' ) && is_front_page() ) return $this->default_empty_price_text;
|
71 |
+
|
72 |
+
// No changes
|
73 |
+
return $price;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* get_settings.
|
78 |
+
*/
|
79 |
+
function get_settings() {
|
80 |
+
|
81 |
+
$settings = array(
|
82 |
+
|
83 |
+
array( 'title' => __( 'Call for Price Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => 'Leave price empty when adding or editing products. Then set the options here.', 'id' => 'wcj_call_for_price_options' ),
|
84 |
+
|
85 |
+
array(
|
86 |
+
'title' => __( 'Call for Price', 'woocommerce-jetpack' ),
|
87 |
+
'desc' => __( 'Enable the Call for Price feature', 'woocommerce-jetpack' ),
|
88 |
+
'desc_tip' => __( 'Create any custom price label for all products with empty price.', 'woocommerce-jetpack' ),
|
89 |
+
'id' => 'wcj_call_for_price_enabled',
|
90 |
+
'default' => 'yes',
|
91 |
+
'type' => 'checkbox',
|
92 |
+
),
|
93 |
+
|
94 |
+
array(
|
95 |
+
'title' => __( 'Text to Show', 'woocommerce-jetpack' ),
|
96 |
+
'desc_tip' => __( 'This sets the html to output on empty price.', 'woocommerce-jetpack' ),
|
97 |
+
'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
|
98 |
+
'id' => 'wcj_call_for_price_text',
|
99 |
+
'default' => $this->default_empty_price_text,
|
100 |
+
'type' => 'textarea',
|
101 |
+
'css' => 'width:50%;min-width:300px;',
|
102 |
+
'custom_attributes'
|
103 |
+
=> apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
|
104 |
+
),
|
105 |
+
|
106 |
+
array(
|
107 |
+
'title' => __( 'Show on Single Product', 'woocommerce-jetpack' ),
|
108 |
+
'desc' => __( 'Check to show on single products page', 'woocommerce-jetpack' ),
|
109 |
+
'id' => 'wcj_call_for_price_show_on_single',
|
110 |
+
'default' => 'yes',
|
111 |
+
'type' => 'checkbox',
|
112 |
+
),
|
113 |
+
|
114 |
+
array(
|
115 |
+
'title' => __( 'Show on Products Archive', 'woocommerce-jetpack' ),
|
116 |
+
'desc' => __( 'Check to show on products archive page', 'woocommerce-jetpack' ),
|
117 |
+
'id' => 'wcj_call_for_price_show_on_archive',
|
118 |
+
'default' => 'yes',
|
119 |
+
'type' => 'checkbox',
|
120 |
+
),
|
121 |
+
|
122 |
+
array(
|
123 |
+
'title' => __( 'Show on Home Page', 'woocommerce-jetpack' ),
|
124 |
+
'desc' => __( 'Check to show on home page', 'woocommerce-jetpack' ),
|
125 |
+
'id' => 'wcj_call_for_price_show_on_home',
|
126 |
+
'default' => 'yes',
|
127 |
+
'type' => 'checkbox',
|
128 |
+
),
|
129 |
+
|
130 |
+
array(
|
131 |
+
'title' => __( 'Hide Sale! Tag', 'woocommerce-jetpack' ),
|
132 |
+
'desc' => __( 'Hide the tag', 'woocommerce-jetpack' ),
|
133 |
+
'id' => 'wcj_call_for_price_hide_sale_sign',
|
134 |
+
'default' => 'yes',
|
135 |
+
'type' => 'checkbox',
|
136 |
+
),
|
137 |
+
|
138 |
+
array( 'type' => 'sectionend', 'id' => 'wcj_call_for_price_options' ),
|
139 |
+
);
|
140 |
+
|
141 |
+
return $settings;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* settings_section.
|
146 |
+
*/
|
147 |
+
function settings_section( $sections ) {
|
148 |
+
|
149 |
+
$sections['call_for_price'] = 'Call for Price';
|
150 |
+
|
151 |
+
return $sections;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
endif;
|
156 |
+
|
157 |
+
return new WCJ_Call_For_Price();
|
includes/class-wcj-currencies.php
ADDED
@@ -0,0 +1,475 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce Jetpack currencies
|
4 |
+
*
|
5 |
+
* The WooCommerce Jetpack currencies class stores currencies data.
|
6 |
+
*
|
7 |
+
* @class WCJ_Currencies
|
8 |
+
* @version 1.0.0
|
9 |
+
* @package WooJetpack/Classes
|
10 |
+
* @category Class
|
11 |
+
* @author Algoritmika Ltd.
|
12 |
+
*/
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
14 |
+
|
15 |
+
if ( ! class_exists( 'WCJ_Currencies' ) ) :
|
16 |
+
|
17 |
+
class WCJ_Currencies {
|
18 |
+
|
19 |
+
public function __construct() {
|
20 |
+
|
21 |
+
$this->currencies_list = array(
|
22 |
+
"AFN" => "Afghan afghani",
|
23 |
+
"ALL" => "Albanian lek",
|
24 |
+
"DZD" => "Algerian dinar",
|
25 |
+
"AOA" => "Angolan kwanza",
|
26 |
+
"ARS" => "Argentine peso",
|
27 |
+
"AMD" => "Armenian dram",
|
28 |
+
"AWG" => "Aruban florin",
|
29 |
+
"AUD" => "Australian dollar",
|
30 |
+
"AZN" => "Azerbaijani manat",
|
31 |
+
"BSD" => "Bahamian dollar",
|
32 |
+
"BHD" => "Bahraini dinar",
|
33 |
+
"BDT" => "Bangladeshi taka",
|
34 |
+
"BBD" => "Barbadian dollar",
|
35 |
+
"BYR" => "Belarusian ruble",
|
36 |
+
"BZD" => "Belize dollar",
|
37 |
+
"BTN" => "Bhutanese ngultrum",
|
38 |
+
"BOB" => "Bolivian boliviano",
|
39 |
+
"BAM" => "Bosnia and Herzegovina konvertibilna marka",
|
40 |
+
"BWP" => "Botswana pula",
|
41 |
+
"BRL" => "Brazilian real",
|
42 |
+
"GBP" => "British pound",
|
43 |
+
"BND" => "Brunei dollar",
|
44 |
+
"BGN" => "Bulgarian lev",
|
45 |
+
"BIF" => "Burundi franc",
|
46 |
+
"KYD" => "Cayman Islands dollar",
|
47 |
+
"KHR" => "Cambodian riel",
|
48 |
+
"CAD" => "Canadian dollar",
|
49 |
+
"CVE" => "Cape Verdean escudo",
|
50 |
+
"XAF" => "Central African CFA franc",
|
51 |
+
"GQE" => "Central African CFA franc",
|
52 |
+
"XPF" => "CFP franc",
|
53 |
+
"CLP" => "Chilean peso",
|
54 |
+
"CNY" => "Chinese renminbi",
|
55 |
+
"COP" => "Colombian peso",
|
56 |
+
"KMF" => "Comorian franc",
|
57 |
+
"CDF" => "Congolese franc",
|
58 |
+
"CRC" => "Costa Rican colon",
|
59 |
+
"HRK" => "Croatian kuna",
|
60 |
+
"CUC" => "Cuban peso",
|
61 |
+
"CZK" => "Czech koruna",
|
62 |
+
"DKK" => "Danish krone",
|
63 |
+
"DJF" => "Djiboutian franc",
|
64 |
+
"DOP" => "Dominican peso",
|
65 |
+
"XCD" => "East Caribbean dollar",
|
66 |
+
"EGP" => "Egyptian pound",
|
67 |
+
"ERN" => "Eritrean nakfa",
|
68 |
+
"EEK" => "Estonian kroon",
|
69 |
+
"ETB" => "Ethiopian birr",
|
70 |
+
"EUR" => "European euro",
|
71 |
+
"FKP" => "Falkland Islands pound",
|
72 |
+
"FJD" => "Fijian dollar",
|
73 |
+
"GMD" => "Gambian dalasi",
|
74 |
+
"GEL" => "Georgian lari",
|
75 |
+
"GHS" => "Ghanaian cedi",
|
76 |
+
"GIP" => "Gibraltar pound",
|
77 |
+
"GTQ" => "Guatemalan quetzal",
|
78 |
+
"GNF" => "Guinean franc",
|
79 |
+
"GYD" => "Guyanese dollar",
|
80 |
+
"HTG" => "Haitian gourde",
|
81 |
+
"HNL" => "Honduran lempira",
|
82 |
+
"HKD" => "Hong Kong dollar",
|
83 |
+
"HUF" => "Hungarian forint",
|
84 |
+
"ISK" => "Icelandic króna",
|
85 |
+
"INR" => "Indian rupee",
|
86 |
+
"IDR" => "Indonesian rupiah",
|
87 |
+
"IRR" => "Iranian rial",
|
88 |
+
"IQD" => "Iraqi dinar",
|
89 |
+
"ILS" => "Israeli new sheqel",
|
90 |
+
"YER" => "Yemeni rial",
|
91 |
+
"JMD" => "Jamaican dollar",
|
92 |
+
"JPY" => "Japanese yen",
|
93 |
+
"JOD" => "Jordanian dinar",
|
94 |
+
"KZT" => "Kazakhstani tenge",
|
95 |
+
"KES" => "Kenyan shilling",
|
96 |
+
"KGS" => "Kyrgyzstani som",
|
97 |
+
"KWD" => "Kuwaiti dinar",
|
98 |
+
"LAK" => "Lao kip",
|
99 |
+
"LVL" => "Latvian lats",
|
100 |
+
"LBP" => "Lebanese lira",
|
101 |
+
"LSL" => "Lesotho loti",
|
102 |
+
"LRD" => "Liberian dollar",
|
103 |
+
"LYD" => "Libyan dinar",
|
104 |
+
"LTL" => "Lithuanian litas",
|
105 |
+
"MOP" => "Macanese pataca",
|
106 |
+
"MKD" => "Macedonian denar",
|
107 |
+
"MGA" => "Malagasy ariary",
|
108 |
+
"MYR" => "Malaysian ringgit",
|
109 |
+
"MWK" => "Malawian kwacha",
|
110 |
+
"MVR" => "Maldivian rufiyaa",
|
111 |
+
"MRO" => "Mauritanian ouguiya",
|
112 |
+
"MUR" => "Mauritian rupee",
|
113 |
+
"MXN" => "Mexican peso",
|
114 |
+
"MMK" => "Myanma kyat",
|
115 |
+
"MDL" => "Moldovan leu",
|
116 |
+
"MNT" => "Mongolian tugrik",
|
117 |
+
"MAD" => "Moroccan dirham",
|
118 |
+
"MZM" => "Mozambican metical",
|
119 |
+
"NAD" => "Namibian dollar",
|
120 |
+
"NPR" => "Nepalese rupee",
|
121 |
+
"ANG" => "Netherlands Antillean gulden",
|
122 |
+
"TWD" => "New Taiwan dollar",
|
123 |
+
"NZD" => "New Zealand dollar",
|
124 |
+
"NIO" => "Nicaraguan cordoba",
|
125 |
+
"NGN" => "Nigerian naira",
|
126 |
+
"KPW" => "North Korean won",
|
127 |
+
"NOK" => "Norwegian krone",
|
128 |
+
"OMR" => "Omani rial",
|
129 |
+
"TOP" => "Paanga",
|
130 |
+
"PKR" => "Pakistani rupee",
|
131 |
+
"PAB" => "Panamanian balboa",
|
132 |
+
"PGK" => "Papua New Guinean kina",
|
133 |
+
"PYG" => "Paraguayan guarani",
|
134 |
+
"PEN" => "Peruvian nuevo sol",
|
135 |
+
"PHP" => "Philippine peso",
|
136 |
+
"PLN" => "Polish zloty",
|
137 |
+
"QAR" => "Qatari riyal",
|
138 |
+
"RON" => "Romanian leu",
|
139 |
+
"RUB" => "Russian ruble",
|
140 |
+
"RWF" => "Rwandan franc",
|
141 |
+
"SHP" => "Saint Helena pound",
|
142 |
+
"WST" => "Samoan tala",
|
143 |
+
"STD" => "Sao Tome and Principe dobra",
|
144 |
+
"SAR" => "Saudi riyal",
|
145 |
+
"SCR" => "Seychellois rupee",
|
146 |
+
"RSD" => "Serbian dinar",
|
147 |
+
"SLL" => "Sierra Leonean leone",
|
148 |
+
"SGD" => "Singapore dollar",
|
149 |
+
"SYP" => "Syrian pound",
|
150 |
+
"SKK" => "Slovak koruna",
|
151 |
+
"SBD" => "Solomon Islands dollar",
|
152 |
+
"SOS" => "Somali shilling",
|
153 |
+
"ZAR" => "South African rand",
|
154 |
+
"KRW" => "South Korean won",
|
155 |
+
"XDR" => "Special Drawing Rights",
|
156 |
+
"LKR" => "Sri Lankan rupee",
|
157 |
+
"SDG" => "Sudanese pound",
|
158 |
+
"SRD" => "Surinamese dollar",
|
159 |
+
"SZL" => "Swazi lilangeni",
|
160 |
+
"SEK" => "Swedish krona",
|
161 |
+
"CHF" => "Swiss franc",
|
162 |
+
"TJS" => "Tajikistani somoni",
|
163 |
+
"TZS" => "Tanzanian shilling",
|
164 |
+
"THB" => "Thai baht",
|
165 |
+
"TTD" => "Trinidad and Tobago dollar",
|
166 |
+
"TND" => "Tunisian dinar",
|
167 |
+
"TRY" => "Turkish new lira",
|
168 |
+
"TMM" => "Turkmen manat",
|
169 |
+
"AED" => "UAE dirham",
|
170 |
+
"UGX" => "Ugandan shilling",
|
171 |
+
"UAH" => "Ukrainian hryvnia",
|
172 |
+
"USD" => "United States dollar",
|
173 |
+
"UYU" => "Uruguayan peso",
|
174 |
+
"UZS" => "Uzbekistani som",
|
175 |
+
"VUV" => "Vanuatu vatu",
|
176 |
+
"VEB" => "Venezuelan bolivar",
|
177 |
+
"VND" => "Vietnamese dong",
|
178 |
+
"XOF" => "West African CFA franc",
|
179 |
+
"ZMK" => "Zambian kwacha",
|
180 |
+
"ZWD" => "Zimbabwean dollar",
|
181 |
+
|
182 |
+
"RMB" => "Chinese Yuan",
|
183 |
+
);
|
184 |
+
|
185 |
+
$this->currencies_symbols_list = array(
|
186 |
+
"AFN" => "AFN",
|
187 |
+
"ALL" => "ALL",
|
188 |
+
"DZD" => "DZD",
|
189 |
+
"AOA" => "AOA",
|
190 |
+
"ARS" => "ARS",
|
191 |
+
"AMD" => "AMD",
|
192 |
+
"AWG" => "AWG",
|
193 |
+
"AUD" => "$",
|
194 |
+
"AZN" => "AZN",
|
195 |
+
"BSD" => "BSD",
|
196 |
+
"BHD" => "BHD",
|
197 |
+
"BDT" => "BDT",
|
198 |
+
"BBD" => "BBD",
|
199 |
+
"BYR" => "BYR",
|
200 |
+
"BZD" => "BZD",
|
201 |
+
"BTN" => "BTN",
|
202 |
+
"BOB" => "BOB",
|
203 |
+
"BAM" => "BAM",
|
204 |
+
"BWP" => "BWP",
|
205 |
+
"BRL" => "R$",
|
206 |
+
"GBP" => "£",
|
207 |
+
"BND" => "BND",
|
208 |
+
"BGN" => "BGN",
|
209 |
+
"BIF" => "BIF",
|
210 |
+
"KYD" => "KYD",
|
211 |
+
"KHR" => "KHR",
|
212 |
+
"CAD" => "CAD",
|
213 |
+
"CVE" => "CVE",
|
214 |
+
"XAF" => "XAF",
|
215 |
+
"GQE" => "GQE",
|
216 |
+
"XPF" => "XPF",
|
217 |
+
"CLP" => "CLP",
|
218 |
+
"CNY" => "¥",
|
219 |
+
"COP" => "COP",
|
220 |
+
"KMF" => "KMF",
|
221 |
+
"CDF" => "CDF",
|
222 |
+
"CRC" => "CRC",
|
223 |
+
"HRK" => "HRK",
|
224 |
+
"CUC" => "CUC",
|
225 |
+
"CZK" => "Kč",
|
226 |
+
"DKK" => "kr",
|
227 |
+
"DJF" => "DJF",
|
228 |
+
"DOP" => "DOP",
|
229 |
+
"XCD" => "XCD",
|
230 |
+
"EGP" => "EGP",
|
231 |
+
"ERN" => "ERN",
|
232 |
+
"EEK" => "EEK",
|
233 |
+
"ETB" => "ETB",
|
234 |
+
"EUR" => "€",
|
235 |
+
"FKP" => "FKP",
|
236 |
+
"FJD" => "FJD",
|
237 |
+
"GMD" => "GMD",
|
238 |
+
"GEL" => "GEL",
|
239 |
+
"GHS" => "GHS",
|
240 |
+
"GIP" => "GIP",
|
241 |
+
"GTQ" => "GTQ",
|
242 |
+
"GNF" => "GNF",
|
243 |
+
"GYD" => "GYD",
|
244 |
+
"HTG" => "HTG",
|
245 |
+
"HNL" => "HNL",
|
246 |
+
"HKD" => "$",
|
247 |
+
"HUF" => "Ft",
|
248 |
+
"ISK" => "ISK",
|
249 |
+
"INR" => "₹",
|
250 |
+
"IDR" => "Rp",
|
251 |
+
"IRR" => "IRR",
|
252 |
+
"IQD" => "IQD",
|
253 |
+
"ILS" => "₪",
|
254 |
+
"YER" => "YER",
|
255 |
+
"JMD" => "JMD",
|
256 |
+
"JPY" => "¥",
|
257 |
+
"JOD" => "JOD",
|
258 |
+
"KZT" => "KZT",
|
259 |
+
"KES" => "KES",
|
260 |
+
"KGS" => "KGS",
|
261 |
+
"KWD" => "KWD",
|
262 |
+
"LAK" => "LAK",
|
263 |
+
"LVL" => "LVL",
|
264 |
+
"LBP" => "LBP",
|
265 |
+
"LSL" => "LSL",
|
266 |
+
"LRD" => "LRD",
|
267 |
+
"LYD" => "LYD",
|
268 |
+
"LTL" => "LTL",
|
269 |
+
"MOP" => "MOP",
|
270 |
+
"MKD" => "MKD",
|
271 |
+
"MGA" => "MGA",
|
272 |
+
"MYR" => "RM",
|
273 |
+
"MWK" => "MWK",
|
274 |
+
"MVR" => "MVR",
|
275 |
+
"MRO" => "MRO",
|
276 |
+
"MUR" => "MUR",
|
277 |
+
"MXN" => "$",
|
278 |
+
"MMK" => "MMK",
|
279 |
+
"MDL" => "MDL",
|
280 |
+
"MNT" => "MNT",
|
281 |
+
"MAD" => "MAD",
|
282 |
+
"MZM" => "MZM",
|
283 |
+
"NAD" => "NAD",
|
284 |
+
"NPR" => "NPR",
|
285 |
+
"ANG" => "ANG",
|
286 |
+
"TWD" => "NT$",
|
287 |
+
"NZD" => "$",
|
288 |
+
"NIO" => "NIO",
|
289 |
+
"NGN" => "NGN",
|
290 |
+
"KPW" => "KPW",
|
291 |
+
"NOK" => "kr",
|
292 |
+
"OMR" => "OMR",
|
293 |
+
"TOP" => "TOP",
|
294 |
+
"PKR" => "PKR",
|
295 |
+
"PAB" => "PAB",
|
296 |
+
"PGK" => "PGK",
|
297 |
+
"PYG" => "PYG",
|
298 |
+
"PEN" => "PEN",
|
299 |
+
"PHP" => "₱",
|
300 |
+
"PLN" => "zł",
|
301 |
+
"QAR" => "QAR",
|
302 |
+
"RON" => "lei",
|
303 |
+
"RUB" => "RUB",
|
304 |
+
"RWF" => "RWF",
|
305 |
+
"SHP" => "SHP",
|
306 |
+
"WST" => "WST",
|
307 |
+
"STD" => "STD",
|
308 |
+
"SAR" => "SAR",
|
309 |
+
"SCR" => "SCR",
|
310 |
+
"RSD" => "RSD",
|
311 |
+
"SLL" => "SLL",
|
312 |
+
"SGD" => "$",
|
313 |
+
"SYP" => "SYP",
|
314 |
+
"SKK" => "SKK",
|
315 |
+
"SBD" => "SBD",
|
316 |
+
"SOS" => "SOS",
|
317 |
+
"ZAR" => "R",
|
318 |
+
"KRW" => "₩",
|
319 |
+
"XDR" => "XDR",
|
320 |
+
"LKR" => "LKR",
|
321 |
+
"SDG" => "SDG",
|
322 |
+
"SRD" => "SRD",
|
323 |
+
"SZL" => "SZL",
|
324 |
+
"SEK" => "kr",
|
325 |
+
"CHF" => "CHF",
|
326 |
+
"TJS" => "TJS",
|
327 |
+
"TZS" => "TZS",
|
328 |
+
"THB" => "฿",
|
329 |
+
"TTD" => "TTD",
|
330 |
+
"TND" => "TND",
|
331 |
+
"TRY" => "TL",
|
332 |
+
"TMM" => "TMM",
|
333 |
+
"AED" => "AED",
|
334 |
+
"UGX" => "UGX",
|
335 |
+
"UAH" => "UAH",
|
336 |
+
"USD" => "$",
|
337 |
+
"UYU" => "UYU",
|
338 |
+
"UZS" => "UZS",
|
339 |
+
"VUV" => "VUV",
|
340 |
+
"VEB" => "VEB",
|
341 |
+
"VND" => "VND",
|
342 |
+
"XOF" => "XOF",
|
343 |
+
"ZMK" => "ZMK",
|
344 |
+
"ZWD" => "ZWD",
|
345 |
+
|
346 |
+
"RMB" => "¥",
|
347 |
+
);
|
348 |
+
|
349 |
+
//$this->items = array();
|
350 |
+
|
351 |
+
// Hooks
|
352 |
+
if ( get_option( 'wcj_currency_enabled' ) == 'yes') {
|
353 |
+
|
354 |
+
// Main hooks
|
355 |
+
add_filter( 'woocommerce_currencies', array($this, 'add_all_currencies'), 100 );
|
356 |
+
add_filter( 'woocommerce_currency_symbol', array($this, 'add_currency_symbol'), 100, 2 );
|
357 |
+
|
358 |
+
// Settings
|
359 |
+
add_filter( 'woocommerce_general_settings', array( $this, 'add_edit_currency_symbol_field' ), 100 );
|
360 |
+
}
|
361 |
+
|
362 |
+
// Settings
|
363 |
+
add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
|
364 |
+
add_filter( 'wcj_settings_currencies', array( $this, 'get_settings' ), 100 );
|
365 |
+
|
366 |
+
add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* add_enabled_option.
|
371 |
+
*/
|
372 |
+
public function add_enabled_option( $settings ) {
|
373 |
+
|
374 |
+
$all_settings = $this->get_settings();
|
375 |
+
$settings[] = $all_settings[1];
|
376 |
+
|
377 |
+
return $settings;
|
378 |
+
}
|
379 |
+
|
380 |
+
function add_edit_currency_symbol_field( $settings ) {
|
381 |
+
|
382 |
+
$updated_settings = array();
|
383 |
+
|
384 |
+
foreach ( $settings as $section ) {
|
385 |
+
|
386 |
+
if ( isset( $section['id'] ) && 'woocommerce_currency_pos' == $section['id'] ) {
|
387 |
+
|
388 |
+
$updated_settings[] = array(
|
389 |
+
'name' => __( 'Currency Symbol', 'woojetpack' ), //TODO name or title?????
|
390 |
+
'desc_tip' => __( 'This sets the currency symbol.', 'woojetpack' ),
|
391 |
+
'id' => 'wcj_currency_' . get_woocommerce_currency(),
|
392 |
+
'type' => 'text',
|
393 |
+
'default' => get_woocommerce_currency_symbol(),
|
394 |
+
'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
|
395 |
+
'css' => 'width: 50px;',
|
396 |
+
'custom_attributes' => array( 'readonly' => 'readonly' ),
|
397 |
+
);
|
398 |
+
}
|
399 |
+
|
400 |
+
$updated_settings[] = $section;
|
401 |
+
}
|
402 |
+
|
403 |
+
return $updated_settings;
|
404 |
+
}
|
405 |
+
|
406 |
+
function get_settings() {
|
407 |
+
|
408 |
+
$settings = array(
|
409 |
+
|
410 |
+
array( 'title' => __( 'Currencies Options', 'woojetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_currency_options' ),
|
411 |
+
|
412 |
+
array(
|
413 |
+
'title' => __( 'Currencies', 'woojetpack' ),
|
414 |
+
'desc' => __( 'Enable the Currencies feature', 'woojetpack' ),
|
415 |
+
'desc_tip' => __( 'Add all world currencies, change currency symbol.', 'woojetpack' ),
|
416 |
+
'id' => 'wcj_currency_enabled',
|
417 |
+
'default' => 'yes',
|
418 |
+
'type' => 'checkbox'
|
419 |
+
),
|
420 |
+
|
421 |
+
array( 'type' => 'sectionend', 'id' => 'wcj_currency_options' ),
|
422 |
+
|
423 |
+
array( 'title' => __( 'Currency Symbol Options', 'woojetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_all_currencies_list_options' ),
|
424 |
+
);
|
425 |
+
|
426 |
+
foreach ($this->currencies_list as $currency_id => $currency_name)
|
427 |
+
$settings[] = array(
|
428 |
+
'title' => __( $currency_name, 'woocommerce' ),
|
429 |
+
'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ),
|
430 |
+
'id' => 'wcj_currency_' . $currency_id,
|
431 |
+
'default' => $this->currencies_symbols_list[ $currency_id ],
|
432 |
+
'type' => 'text',
|
433 |
+
'custom_attributes'
|
434 |
+
=> apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
|
435 |
+
);
|
436 |
+
|
437 |
+
$settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_all_currencies_list_options' );
|
438 |
+
|
439 |
+
return $settings;
|
440 |
+
}
|
441 |
+
|
442 |
+
function settings_section( $sections ) {
|
443 |
+
|
444 |
+
$sections['currencies'] = 'Currencies';
|
445 |
+
|
446 |
+
return $sections;
|
447 |
+
}
|
448 |
+
|
449 |
+
function add_all_currencies( $currencies ) {
|
450 |
+
|
451 |
+
foreach ($this->currencies_list as $currency_id => $currency_name)
|
452 |
+
$currencies[$currency_id] = __( $currency_name, 'woocommerce' );
|
453 |
+
|
454 |
+
asort ($currencies);
|
455 |
+
|
456 |
+
return $currencies;
|
457 |
+
}
|
458 |
+
|
459 |
+
function add_currency_symbol( $currency_symbol, $currency ) {
|
460 |
+
|
461 |
+
return $this->currencies_symbols_list[$currency]; //default value?
|
462 |
+
}
|
463 |
+
|
464 |
+
/*public function check_wooallcurpro_fields($input) {
|
465 |
+
|
466 |
+
foreach ($this->currencies_list as $currency_id => $currency_name)
|
467 |
+
$res[$currency_id] = str_replace('"', '\'', $input[$currency_id]);
|
468 |
+
|
469 |
+
return $res;
|
470 |
+
}*/
|
471 |
+
}
|
472 |
+
|
473 |
+
endif;
|
474 |
+
|
475 |
+
return new WCJ_Currencies();
|
includes/class-wcj-old-slugs.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce Jetpack Old Product Slugs
|
4 |
+
*
|
5 |
+
* The WooCommerce Jetpack Old Product Slugs class.
|
6 |
+
*
|
7 |
+
* @class WCJ_Old_Slugs
|
8 |
+
* @version 1.0.0
|
9 |
+
* @package WC_Jetpack/Classes
|
10 |
+
* @category Class
|
11 |
+
* @author Algoritmika Ltd.
|
12 |
+
*/
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
14 |
+
|
15 |
+
if ( ! class_exists( 'WCJ_Old_Slugs' ) ) :
|
16 |
+
|
17 |
+
class WCJ_Old_Slugs {
|
18 |
+
|
19 |
+
public function __construct() {
|
20 |
+
|
21 |
+
// HOOKS
|
22 |
+
|
23 |
+
// Main hooks
|
24 |
+
if ( get_option( 'wcj_old_slugs_enabled' ) == 'yes' ) {
|
25 |
+
if ( is_admin() ) {
|
26 |
+
add_action('admin_menu', array($this, 'add_old_slugs_tool'), 999);
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
// Settings hooks
|
31 |
+
add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) ); // Add section to WooCommerce > Settings > Jetpack
|
32 |
+
add_filter( 'wcj_settings_old_slugs', array( $this, 'get_settings' ), 100 ); // Add the settings
|
33 |
+
add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 ); // Add Enable option to Jetpack Settings Dashboard
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* add_enabled_option.
|
38 |
+
*/
|
39 |
+
public function add_enabled_option( $settings ) {
|
40 |
+
|
41 |
+
$all_settings = $this->get_settings();
|
42 |
+
$settings[] = $all_settings[1];
|
43 |
+
|
44 |
+
return $settings;
|
45 |
+
}
|
46 |
+
|
47 |
+
/*
|
48 |
+
* Add the settings.
|
49 |
+
*/
|
50 |
+
function get_settings() {
|
51 |
+
|
52 |
+
$settings = array(
|
53 |
+
array( 'title' => __( 'Old Slugs Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_old_slugs_options' ),
|
54 |
+
|
55 |
+
array(
|
56 |
+
'title' => __( 'Old Slugs', 'woocommerce-jetpack' ),
|
57 |
+
'desc' => __( 'Enable the Remove Old Product Slugs feature', 'woocommerce-jetpack' ),
|
58 |
+
'desc_tip' => __( 'Remove old product slugs. Tool is accessible through <a href="/wp-admin/admin.php?page=woocommerce-jetpack-old-slugs">WooCommerce > Remove Old Slugs</a>.', 'woocommerce-jetpack' ),
|
59 |
+
'id' => 'wcj_old_slugs_enabled',
|
60 |
+
'default' => 'yes',
|
61 |
+
'type' => 'checkbox'
|
62 |
+
),
|
63 |
+
|
64 |
+
array( 'type' => 'sectionend', 'id' => 'wcj_old_slugs_options' ),
|
65 |
+
);
|
66 |
+
|
67 |
+
return $settings;
|
68 |
+
}
|
69 |
+
|
70 |
+
/*
|
71 |
+
* Add settings section to WooCommerce > Settings > Jetpack.
|
72 |
+
*/
|
73 |
+
function settings_section( $sections ) {
|
74 |
+
|
75 |
+
$sections['old_slugs'] = 'Old Slugs';
|
76 |
+
|
77 |
+
return $sections;
|
78 |
+
}
|
79 |
+
|
80 |
+
public function add_old_slugs_tool() {
|
81 |
+
|
82 |
+
add_submenu_page( 'woocommerce', 'Jetpack - Remove Old Slugs', 'Remove Old Slugs', 'manage_options', 'woocommerce-jetpack-old-slugs', array( $this, 'create_old_slugs_tool' ) );
|
83 |
+
}
|
84 |
+
|
85 |
+
public function create_old_slugs_tool() {
|
86 |
+
|
87 |
+
global $wpdb;
|
88 |
+
$all_old_slugs = $wpdb->get_results( "SELECT * FROM wp_postmeta WHERE meta_key = '_wp_old_slug' ORDER BY post_id" );
|
89 |
+
$num_old_slugs = count( $all_old_slugs );
|
90 |
+
if ( $num_old_slugs > 0 ) {
|
91 |
+
|
92 |
+
$posts_ids = array(
|
93 |
+
'products' => array(),
|
94 |
+
'none_products' => array(),
|
95 |
+
);
|
96 |
+
$old_slugs_list = '<ol>';
|
97 |
+
$old_slugs_list_products = '<ol>';
|
98 |
+
foreach ( $all_old_slugs as $old_slug_object ) {
|
99 |
+
$slug_post_type = get_post_type( $old_slug_object->post_id );
|
100 |
+
$current_slug = get_post( $old_slug_object->post_id )->post_name;
|
101 |
+
if ( $slug_post_type == 'product' ) {
|
102 |
+
$old_slugs_list_products .= '<li><strong>' . $old_slug_object->meta_value . '</strong> (<em>post title:</em> ' . get_the_title( $old_slug_object->post_id ) . ', <em>post id:</em> '. $old_slug_object->post_id . ', <em>current slug:</em> ' . $current_slug . ')</li>';
|
103 |
+
$posts_ids['products'][] = $old_slug_object->post_id;
|
104 |
+
}
|
105 |
+
else {
|
106 |
+
$old_slugs_list .= '<li><strong>' . $old_slug_object->meta_value . '</strong> (<em>post title:</em> ' . get_the_title( $old_slug_object->post_id ) . ', <em>post id:</em> '.$old_slug_object->post_id . ', <em>post type:</em> ' . $slug_post_type . ', <em>current slug:</em> ' . $current_slug . ' )</li>';
|
107 |
+
$posts_ids['none_products'][] = $old_slug_object->post_id;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
$old_slugs_list .= '</ol>';
|
111 |
+
$old_slugs_list_products .= '</ol>';
|
112 |
+
|
113 |
+
if ( ( isset( $_POST['remove_old_products_slugs'] ) ) || ( isset( $_POST['remove_old_none_products_slugs'] ) ) ) {
|
114 |
+
|
115 |
+
//print_r( $posts_ids );
|
116 |
+
if ( isset( $_POST['remove_old_products_slugs'] ) ) $post_ids_to_delete = join( ',', $posts_ids['products'] );
|
117 |
+
else if ( isset( $_POST['remove_old_none_products_slugs'] ) ) $post_ids_to_delete = join( ',', $posts_ids['none_products'] );
|
118 |
+
|
119 |
+
$the_delete_query = "DELETE FROM wp_postmeta WHERE meta_key = '_wp_old_slug' AND post_id IN ($post_ids_to_delete)";
|
120 |
+
|
121 |
+
$delete_result = $wpdb->get_results( $the_delete_query );
|
122 |
+
//echo "<pre>$the_delete_query</pre>";
|
123 |
+
|
124 |
+
$recheck_result = $wpdb->get_results("SELECT * FROM wp_postmeta WHERE meta_key = '_wp_old_slug'");
|
125 |
+
$recheck_result_count = count( $recheck_result );
|
126 |
+
$remove_result_html = '<div class="updated"><p><strong>Removing old slugs from database finished! ' . ($num_old_slugs-$recheck_result_count) . ' old slug(s) deleted. Please <a href="">refresh</a> the page.</strong></p></div>';
|
127 |
+
}
|
128 |
+
}
|
129 |
+
?>
|
130 |
+
<div>
|
131 |
+
<h2>WooCommerce Jetpack - Remove Old Product Slugs</h2>
|
132 |
+
<p>Tool removes old slugs/permalinks from database.</p>
|
133 |
+
<?php echo $remove_result_html; ?>
|
134 |
+
<?php
|
135 |
+
$num_old_slugs_products = count( $posts_ids['products'] );
|
136 |
+
if ( $num_old_slugs_products > 0 ) { ?>
|
137 |
+
<h3>Old products slugs found: <?php echo $num_old_slugs_products; ?></h3>
|
138 |
+
<p><?php echo $old_slugs_list_products; ?></p>
|
139 |
+
<form method="post" action="">
|
140 |
+
<input type="submit" name="remove_old_products_slugs" value="Remove All Old Product Slugs"/>
|
141 |
+
</form>
|
142 |
+
<?php }
|
143 |
+
$num_old_slugs_none_products = count( $posts_ids['none_products'] );
|
144 |
+
if ( $num_old_slugs_none_products > 0 ) { ?>
|
145 |
+
<h3>None-products slugs found: <?php echo $num_old_slugs_none_products; ?></h3>
|
146 |
+
<p><?php echo $old_slugs_list; ?></p>
|
147 |
+
<form method="post" action="">
|
148 |
+
<input type="submit" name="remove_old_none_products_slugs" value="Remove All Old None-Product Slugs"/>
|
149 |
+
</form>
|
150 |
+
<?php }
|
151 |
+
if ( $num_old_slugs == 0 ) { ?>
|
152 |
+
<div class="updated"><p><strong>No old slugs found.</strong></p></div>
|
153 |
+
<?php } ?>
|
154 |
+
</div>
|
155 |
+
<?php
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
endif;
|
160 |
+
|
161 |
+
return new WCJ_Old_Slugs();
|
includes/class-wcj-price-labels.php
ADDED
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce Jetpack Price Labels
|
4 |
+
*
|
5 |
+
* The WooCommerce Jetpack Price Labels class.
|
6 |
+
*
|
7 |
+
* @class WCJ_Price_Labels
|
8 |
+
* @category Class
|
9 |
+
* @author Algoritmika Ltd.
|
10 |
+
*/
|
11 |
+
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
13 |
+
|
14 |
+
if ( ! class_exists( 'WCJ_Price_Labels' ) ) :
|
15 |
+
|
16 |
+
class WCJ_Price_Labels {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Constructor.
|
20 |
+
*/
|
21 |
+
public function __construct() {
|
22 |
+
|
23 |
+
// HOOKS
|
24 |
+
// Main hooks
|
25 |
+
// Custom Price Labels hooks
|
26 |
+
add_action( 'add_meta_boxes', array( $this, 'add_price_label_meta_box' ) );
|
27 |
+
// Custom Price Labels - cart item price hooks
|
28 |
+
//add_filter( 'woocommerce_cart_item_price_html', array( $this, 'custom_price' ), 999, 2 ); // depreciated?
|
29 |
+
//add_filter( 'woocommerce_cart_item_price', array( $this, 'custom_price' ), 999, 2 );
|
30 |
+
// Custom Price Labels - price hooks
|
31 |
+
add_filter( 'woocommerce_empty_price_html', array( $this, 'custom_price' ), 100, 2 );
|
32 |
+
add_filter( 'woocommerce_free_price_html', array( $this, 'custom_price' ), 100, 2 );
|
33 |
+
add_filter( 'woocommerce_free_sale_price_html', array( $this, 'custom_price' ), 100, 2 );
|
34 |
+
add_filter( 'woocommerce_price_html', array( $this, 'custom_price' ), 100, 2 );
|
35 |
+
add_filter( 'woocommerce_sale_price_html', array( $this, 'custom_price' ), 100, 2 );
|
36 |
+
// Custom Price Labels - price hooks
|
37 |
+
add_filter( 'woocommerce_grouped_price_html', array( $this, 'custom_price' ), 100, 2 );
|
38 |
+
// Custom Price Labels - price hooks
|
39 |
+
add_filter( 'woocommerce_variable_empty_price_html', array( $this, 'custom_price' ), 100, 2 );
|
40 |
+
add_filter( 'woocommerce_variable_free_price_html', array( $this, 'custom_price' ), 100, 2 );
|
41 |
+
add_filter( 'woocommerce_variable_free_sale_price_html', array( $this, 'custom_price' ), 100, 2 );
|
42 |
+
add_filter( 'woocommerce_variable_price_html', array( $this, 'custom_price' ), 100, 2 );
|
43 |
+
add_filter( 'woocommerce_variable_sale_price_html', array( $this, 'custom_price' ), 100, 2 );
|
44 |
+
// Custom Price Labels - price hooks
|
45 |
+
add_filter( 'woocommerce_variation_empty_price_html', array( $this, 'custom_price' ), 100, 2 );
|
46 |
+
add_filter( 'woocommerce_variation_free_price_html', array( $this, 'custom_price' ), 100, 2 );
|
47 |
+
//woocommerce_variation_option_name
|
48 |
+
add_filter( 'woocommerce_variation_price_html', array( $this, 'custom_price' ), 100, 2 );
|
49 |
+
add_filter( 'woocommerce_variation_sale_price_html', array( $this, 'custom_price' ), 100, 2 );
|
50 |
+
// Custom Price Labels - save post hook
|
51 |
+
add_action( 'save_post', array( $this, 'save_custom_price_labels' ), 999, 2 );
|
52 |
+
|
53 |
+
// Settings hooks
|
54 |
+
add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
|
55 |
+
add_filter( 'wcj_settings_price_labels', array( $this, 'get_settings' ), 100 );
|
56 |
+
add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
|
57 |
+
|
58 |
+
// Custom Price Labels - fields array
|
59 |
+
$this->custom_tab_group_name = 'wcj_price_labels';// for compatibility with Custom Price Label Pro plugin should use 'simple_is_custom_pricing_label'
|
60 |
+
$this->custom_tab_sections = array ( '_instead', '_before', '_between', '_after', );
|
61 |
+
$this->custom_tab_sections_titles = array (
|
62 |
+
'_instead' => 'Instead of the price',// for compatibility with Custom Price Label Pro plugin should use ''
|
63 |
+
'_before' => 'Before the price',
|
64 |
+
'_between' => 'Between the regular and sale price',
|
65 |
+
'_after' => 'After the price',
|
66 |
+
);
|
67 |
+
$this->custom_tab_section_variations = array ( '_text', '_enabled', '_home', '_products', '_single', );
|
68 |
+
$this->custom_tab_section_variations_titles = array (
|
69 |
+
'_text' => 'The label',
|
70 |
+
'_enabled' => 'Enable',// for compatibility with Custom Price Label Pro plugin should use ''
|
71 |
+
'_home' => 'Hide on home page',
|
72 |
+
'_products' => 'Hide on products page',
|
73 |
+
'_single' => 'Hide on single',
|
74 |
+
);
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* add_enabled_option.
|
79 |
+
*/
|
80 |
+
public function add_enabled_option( $settings ) {
|
81 |
+
|
82 |
+
$all_settings = $this->get_settings();
|
83 |
+
$settings[] = $all_settings[1];
|
84 |
+
|
85 |
+
return $settings;
|
86 |
+
}
|
87 |
+
|
88 |
+
public function save_custom_price_labels( $post_id, $post ) {
|
89 |
+
|
90 |
+
//$product = get_product( $post );TODO - do I need it?
|
91 |
+
|
92 |
+
foreach ( $this->custom_tab_sections as $custom_tab_section ) {
|
93 |
+
|
94 |
+
foreach ( $this->custom_tab_section_variations as $custom_tab_section_variation ) {
|
95 |
+
|
96 |
+
//$option_name = $this->custom_tab_group_name;
|
97 |
+
$option_name = $this->custom_tab_group_name . $custom_tab_section . $custom_tab_section_variation;
|
98 |
+
|
99 |
+
if ( $custom_tab_section_variation == '_text' ) {
|
100 |
+
//$option_name .= $custom_tab_section_variation . $custom_tab_section;
|
101 |
+
if ( isset( $_POST[ $option_name ] ) ) update_post_meta( $post_id, '_' . $option_name, $_POST[ $option_name ] );
|
102 |
+
}
|
103 |
+
else {
|
104 |
+
//$option_name .= $custom_tab_section . $custom_tab_section_variation;
|
105 |
+
if ( isset( $_POST[ $option_name ] ) ) update_post_meta( $post_id, '_' . $option_name, $_POST[ $option_name ] );
|
106 |
+
else update_post_meta( $post_id, '_' . $option_name, 'off' );
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
public function add_price_label_meta_box() {
|
113 |
+
|
114 |
+
add_meta_box( 'wc-jetpack-price-labels', 'Custom Price Labels', array($this, 'wcj_price_label'), 'product', 'normal', 'high' );
|
115 |
+
}
|
116 |
+
|
117 |
+
/*
|
118 |
+
* back end
|
119 |
+
*/
|
120 |
+
public function wcj_price_label() {
|
121 |
+
|
122 |
+
$current_post_id = get_the_ID();
|
123 |
+
|
124 |
+
foreach ( $this->custom_tab_sections as $custom_tab_section ) {
|
125 |
+
|
126 |
+
if ( $custom_tab_section == '_before' ) $disabled_if_no_plus = apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_below' );
|
127 |
+
else $disabled_if_no_plus = '';
|
128 |
+
|
129 |
+
echo '<p>' . $disabled_if_no_plus . '<ul><strong>' . $this->custom_tab_sections_titles[ $custom_tab_section ] . '</strong>';
|
130 |
+
|
131 |
+
foreach ( $this->custom_tab_section_variations as $custom_tab_section_variation ) {
|
132 |
+
|
133 |
+
//$option_name = $this->custom_tab_group_name;
|
134 |
+
$option_name = $this->custom_tab_group_name . $custom_tab_section . $custom_tab_section_variation;
|
135 |
+
|
136 |
+
if ( $custom_tab_section_variation == '_text' ) {
|
137 |
+
|
138 |
+
//$option_name .= $custom_tab_section_variation . $custom_tab_section;
|
139 |
+
|
140 |
+
if ( $custom_tab_section != '_instead' ) $disabled_if_no_plus = apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly_string' );
|
141 |
+
else $disabled_if_no_plus = '';
|
142 |
+
//if ( $disabled_if_no_plus != '' ) $disabled_if_no_plus = 'readonly';
|
143 |
+
|
144 |
+
$label_text = get_post_meta($current_post_id, '_' . $option_name, true );
|
145 |
+
$label_text = str_replace ( '"', '"', $label_text );
|
146 |
+
|
147 |
+
echo '<li>' . $this->custom_tab_section_variations_titles[ $custom_tab_section_variation ] . ' <input style="width:50%;min-width:300px;" type="text" ' . $disabled_if_no_plus . ' name="' . $option_name . '" id="' . $option_name . '" value="' . $label_text . '" /></li>';
|
148 |
+
|
149 |
+
}
|
150 |
+
else {
|
151 |
+
|
152 |
+
//$option_name .= $custom_tab_section . $custom_tab_section_variation;
|
153 |
+
|
154 |
+
if ( $custom_tab_section != '_instead' ) $disabled_if_no_plus = apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled_string' );
|
155 |
+
else $disabled_if_no_plus = '';
|
156 |
+
//if ( $disabled_if_no_plus != '' ) $disabled_if_no_plus = 'disabled';
|
157 |
+
|
158 |
+
echo '<li><input class="checkbox" type="checkbox" ' . $disabled_if_no_plus . ' name="' . $option_name . '" id="' . $option_name . '" ' .
|
159 |
+
checked( get_post_meta($current_post_id, '_' . $option_name, true), 'on', false ) . ' /> ' . $this->custom_tab_section_variations_titles[ $custom_tab_section_variation ] . '</li>';
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
echo '</ul></p>';
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
public function customize_price( $price, $custom_tab_section, $custom_label ) {
|
168 |
+
|
169 |
+
switch ( $custom_tab_section ) {
|
170 |
+
|
171 |
+
case '_instead':
|
172 |
+
$price = $custom_label;
|
173 |
+
break;
|
174 |
+
|
175 |
+
case '_before':
|
176 |
+
$price = apply_filter( 'wcjpc_filter', $price, $custom_label . $price );
|
177 |
+
break;
|
178 |
+
|
179 |
+
case '_between':
|
180 |
+
$price = apply_filter( 'wcjpc_filter', $price, str_replace( '</del> <ins>', '</del>' . $custom_label . '<ins>', $price ) );
|
181 |
+
break;
|
182 |
+
|
183 |
+
case '_after':
|
184 |
+
$price = apply_filter( 'wcjpc_filter', $price, $price . $custom_label );
|
185 |
+
break;
|
186 |
+
}
|
187 |
+
|
188 |
+
return $price;
|
189 |
+
}
|
190 |
+
|
191 |
+
/*
|
192 |
+
* front end
|
193 |
+
*/
|
194 |
+
public function custom_price( $price, $product ) {
|
195 |
+
|
196 |
+
foreach ( $this->custom_tab_sections as $custom_tab_section ) {
|
197 |
+
|
198 |
+
$labels_array = array();
|
199 |
+
|
200 |
+
foreach ( $this->custom_tab_section_variations as $custom_tab_section_variation ) {
|
201 |
+
|
202 |
+
//$option_name = $this->custom_tab_group_name;
|
203 |
+
$option_name = $this->custom_tab_group_name . $custom_tab_section . $custom_tab_section_variation;
|
204 |
+
$labels_array[ 'variation' . $custom_tab_section_variation ] = get_post_meta($product->post->ID, '_' . $option_name, true );
|
205 |
+
|
206 |
+
/*if ( $custom_tab_section_variation == '_text' ) {
|
207 |
+
|
208 |
+
//$option_name .= $custom_tab_section_variation . $custom_tab_section;
|
209 |
+
$labels_array[ 'variation' . $custom_tab_section_variation ] = get_post_meta($product->post->ID, '_' . $option_name, true );
|
210 |
+
}
|
211 |
+
else {
|
212 |
+
|
213 |
+
//$option_name .= $custom_tab_section . $custom_tab_section_variation;
|
214 |
+
$labels_array[ 'variation' . $custom_tab_section_variation ] = get_post_meta($product->post->ID, '_' . $option_name, true);
|
215 |
+
}*/
|
216 |
+
|
217 |
+
//$price .= print_r( $labels_array );
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
|
222 |
+
if ( $labels_array[ 'variation_enabled' ] == 'on' ) {
|
223 |
+
|
224 |
+
if ( ( ( $labels_array['variation_home'] == 'off' ) && ( is_front_page() ) ) ||
|
225 |
+
( ( $labels_array['variation_products'] == 'off' ) && ( is_archive() ) ) ||
|
226 |
+
( ( $labels_array['variation_single'] == 'off' ) && ( is_single() ) ) )
|
227 |
+
$price = $this->customize_price( $price, $custom_tab_section, $labels_array['variation_text'] );
|
228 |
+
}
|
229 |
+
|
230 |
+
//unset( $labels_array );
|
231 |
+
}
|
232 |
+
|
233 |
+
return $price;
|
234 |
+
}
|
235 |
+
|
236 |
+
function get_settings() {
|
237 |
+
|
238 |
+
$settings = array(
|
239 |
+
|
240 |
+
array( 'title' => __( 'Custom Price Labels Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_price_labels_options' ),
|
241 |
+
|
242 |
+
array(
|
243 |
+
'title' => __( 'Custom Price Labels', 'woojetpack' ),
|
244 |
+
'desc' => __( 'Enable the Custom Price Labels feature', 'woojetpack' ),
|
245 |
+
'desc_tip' => __( 'Create any custom price label for any product.', 'woojetpack' ),
|
246 |
+
'id' => 'wcj_price_labels_enabled',
|
247 |
+
'default' => 'yes',
|
248 |
+
'type' => 'checkbox',
|
249 |
+
),
|
250 |
+
|
251 |
+
array( 'type' => 'sectionend', 'id' => 'wcj_price_labels_options' ),
|
252 |
+
);
|
253 |
+
|
254 |
+
return $settings;
|
255 |
+
}
|
256 |
+
|
257 |
+
function settings_section( $sections ) {
|
258 |
+
|
259 |
+
$sections['price_labels'] = 'Custom Price Labels';
|
260 |
+
|
261 |
+
return $sections;
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
endif;
|
266 |
+
|
267 |
+
return new WCJ_Price_Labels();
|
includes/class-wcj-product-info.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce Jetpack Product Info
|
4 |
+
*
|
5 |
+
* The WooCommerce Jetpack Product Info class.
|
6 |
+
*
|
7 |
+
* @class WCJ_Product_Info
|
8 |
+
* @version 1.0.0
|
9 |
+
* @package WooJetpack/Classes
|
10 |
+
* @category Class
|
11 |
+
* @author Algoritmika Ltd.
|
12 |
+
*/
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
14 |
+
|
15 |
+
if ( ! class_exists( 'WCJ_Product_Info' ) ) :
|
16 |
+
|
17 |
+
class WCJ_Product_Info {
|
18 |
+
|
19 |
+
public function __construct() {
|
20 |
+
|
21 |
+
//HOOKS
|
22 |
+
|
23 |
+
// Main hooks
|
24 |
+
if ( get_option( 'wcj_product_info_enabled' ) == 'yes' ) {
|
25 |
+
|
26 |
+
add_action( 'woocommerce_single_product_summary', array( $this, 'print_total_sales' ), 999);
|
27 |
+
//add_action( 'woocommerce_after_single_product', array( $this, 'print_total_sales' ) );
|
28 |
+
}
|
29 |
+
|
30 |
+
// Settings hooks
|
31 |
+
add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
|
32 |
+
add_filter( 'wcj_settings_product_info', array( $this, 'get_settings' ), 100 );
|
33 |
+
add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* add_enabled_option.
|
38 |
+
*/
|
39 |
+
public function add_enabled_option( $settings ) {
|
40 |
+
|
41 |
+
$all_settings = $this->get_settings();
|
42 |
+
$settings[] = $all_settings[1];
|
43 |
+
|
44 |
+
return $settings;
|
45 |
+
}
|
46 |
+
|
47 |
+
function print_total_sales() {
|
48 |
+
|
49 |
+
echo str_replace( '[TOTALSALES]', get_post_custom( get_the_ID() )['total_sales'][0], get_option( 'wcj_product_info_total_sales_text' ) );
|
50 |
+
}
|
51 |
+
|
52 |
+
function get_settings() {
|
53 |
+
|
54 |
+
$settings = array(
|
55 |
+
|
56 |
+
array( 'title' => __( 'Product Info Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_info_options' ),
|
57 |
+
|
58 |
+
array(
|
59 |
+
'title' => __( 'Product Info', 'woojetpack' ),
|
60 |
+
'desc' => __( 'Enable the Product Info feature', 'woojetpack' ),
|
61 |
+
'desc_tip' => __( 'Display total product sales etc.', 'woojetpack' ),
|
62 |
+
'id' => 'wcj_product_info_enabled',
|
63 |
+
'default' => 'yes',
|
64 |
+
'type' => 'checkbox'
|
65 |
+
),
|
66 |
+
|
67 |
+
array( 'type' => 'sectionend', 'id' => 'wcj_product_info_options' ),
|
68 |
+
|
69 |
+
|
70 |
+
array( 'title' => __( 'Total Sales Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_info_total_sales_options' ),
|
71 |
+
|
72 |
+
array(
|
73 |
+
'title' => __( 'Enable', 'woojetpack' ),
|
74 |
+
'desc' => __( 'Enable Total Sales', 'woojetpack' ),
|
75 |
+
//'desc_tip'=> __( 'Display total product sales etc.', 'woojetpack' ),
|
76 |
+
'id' => 'wcj_product_info_total_sales_enabled',
|
77 |
+
'default' => 'no',
|
78 |
+
'type' => 'checkbox'
|
79 |
+
),
|
80 |
+
|
81 |
+
array(
|
82 |
+
'title' => __( 'Text to Show', 'woocommerce-jetpack' ),
|
83 |
+
'desc_tip' => __( 'This sets the text to output for total sales. Default is "Total Sales: [TOTALSALES]"', 'woocommerce-jetpack' ),
|
84 |
+
'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
|
85 |
+
'id' => 'wcj_product_info_total_sales_text',
|
86 |
+
'default' => __( 'Total Sales: [TOTALSALES]', 'woocommerce-jetpack' ),
|
87 |
+
'type' => 'textarea',
|
88 |
+
'css' => 'width:50%;min-width:300px;',
|
89 |
+
'custom_attributes'
|
90 |
+
=> apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
|
91 |
+
),
|
92 |
+
|
93 |
+
array( 'type' => 'sectionend', 'id' => 'wcj_product_info_total_sales_options' ),
|
94 |
+
|
95 |
+
/*array(
|
96 |
+
'title' => __( 'Show on Single Product', 'woocommerce-jetpack' ),
|
97 |
+
//'desc_tip'=> __( 'Check to show single products page', 'woocommerce-jetpack' ),
|
98 |
+
'id' => 'wcj_product_info_show_on_single',
|
99 |
+
'default' => 'yes',
|
100 |
+
'type' => 'checkbox',
|
101 |
+
),
|
102 |
+
|
103 |
+
array(
|
104 |
+
'title' => __( 'Show on Products Archive', 'woocommerce-jetpack' ),
|
105 |
+
'id' => 'wcj_product_info_show_on_archive',
|
106 |
+
'default' => 'yes',
|
107 |
+
'type' => 'checkbox',
|
108 |
+
),
|
109 |
+
|
110 |
+
array(
|
111 |
+
'title' => __( 'Show on Home Page', 'woocommerce-jetpack' ),
|
112 |
+
'id' => 'wcj_product_info_show_on_home',
|
113 |
+
'default' => 'yes',
|
114 |
+
'type' => 'checkbox',
|
115 |
+
),*/
|
116 |
+
);
|
117 |
+
|
118 |
+
return $settings;
|
119 |
+
}
|
120 |
+
|
121 |
+
function settings_section( $sections ) {
|
122 |
+
|
123 |
+
$sections['product_info'] = 'Product Info';
|
124 |
+
|
125 |
+
return $sections;
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
endif;
|
130 |
+
|
131 |
+
return new WCJ_Product_Info();
|
includes/class-wcj-sorting.php
ADDED
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce Jetpack Sorting
|
4 |
+
*
|
5 |
+
* The WooCommerce Jetpack Sorting class.
|
6 |
+
*
|
7 |
+
* @class WCJ_Sorting
|
8 |
+
* @version 1.0.0
|
9 |
+
* @category Class
|
10 |
+
* @author Algoritmika Ltd.
|
11 |
+
*/
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
13 |
+
|
14 |
+
if ( ! class_exists( 'WCJ_Sorting' ) ) :
|
15 |
+
|
16 |
+
class WCJ_Sorting {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* WCJ_Sorting Constructor.
|
20 |
+
* @access public
|
21 |
+
*/
|
22 |
+
public function __construct() {
|
23 |
+
|
24 |
+
// HOOKS
|
25 |
+
|
26 |
+
// Main hooks
|
27 |
+
if ( get_option( 'wcj_sorting_enabled' ) == 'yes' ) {
|
28 |
+
|
29 |
+
add_filter( 'woocommerce_get_catalog_ordering_args', array( $this, 'custom_woocommerce_get_catalog_ordering_args' ), 100 ); // Sorting
|
30 |
+
add_filter( 'woocommerce_catalog_orderby', array( $this, 'custom_woocommerce_catalog_orderby' ), 100 ); // Front end
|
31 |
+
add_filter( 'woocommerce_default_catalog_orderby_options', array( $this, 'custom_woocommerce_catalog_orderby' ), 100 ); // Back end (default sorting)
|
32 |
+
add_action( 'init', array( $this, 'custom_init' ), 100 ); // Remove sorting
|
33 |
+
}
|
34 |
+
|
35 |
+
// Settings hooks
|
36 |
+
add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) ); // Add section to WooCommerce > Settings > Jetpack
|
37 |
+
add_filter( 'wcj_settings_sorting', array( $this, 'get_settings' ), 100 ); // Add the settings
|
38 |
+
if ( get_option( 'wcj_sorting_enabled' ) == 'yes' )
|
39 |
+
add_filter( 'woocommerce_product_settings', array( $this, 'add_remove_sorting_checkbox' ), 100 ); // Add 'Remove All Sorting' checkbox to WooCommerce > Settings > Products
|
40 |
+
add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 ); // Add Enable option to Jetpack Settings Dashboard
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* add_enabled_option.
|
45 |
+
*/
|
46 |
+
public function add_enabled_option( $settings ) {
|
47 |
+
|
48 |
+
$all_settings = $this->get_settings();
|
49 |
+
$settings[] = $all_settings[1];
|
50 |
+
|
51 |
+
return $settings;
|
52 |
+
}
|
53 |
+
|
54 |
+
/*
|
55 |
+
* Add Remove All Sorting checkbox to WooCommerce > Settings > Products.
|
56 |
+
*/
|
57 |
+
function add_remove_sorting_checkbox( $settings ) {
|
58 |
+
|
59 |
+
$updated_settings = array();
|
60 |
+
|
61 |
+
foreach ( $settings as $section ) {
|
62 |
+
|
63 |
+
if ( isset( $section['id'] ) && 'woocommerce_cart_redirect_after_add' == $section['id'] ) {
|
64 |
+
|
65 |
+
$updated_settings[] = array(
|
66 |
+
'title' => __( 'Remove All Sorting', 'woocommerce-jetpack' ),
|
67 |
+
'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
|
68 |
+
'id' => 'wcj_sorting_remove_all_enabled',
|
69 |
+
'type' => 'checkbox',
|
70 |
+
'default' => 'no',
|
71 |
+
'desc' => __( 'Completely remove sorting from the shop front end', 'woocommerce-jetpack' ),
|
72 |
+
'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
|
73 |
+
);
|
74 |
+
}
|
75 |
+
|
76 |
+
$updated_settings[] = $section;
|
77 |
+
}
|
78 |
+
|
79 |
+
return $updated_settings;
|
80 |
+
}
|
81 |
+
|
82 |
+
/*
|
83 |
+
* Custom Init - remove all sorting action
|
84 |
+
*/
|
85 |
+
function custom_init() {
|
86 |
+
|
87 |
+
if ( get_option( 'wcj_sorting_remove_all_enabled' ) )
|
88 |
+
do_action( 'wcj_sorting_remove_action' );
|
89 |
+
}
|
90 |
+
|
91 |
+
/*
|
92 |
+
* Add new sorting options to Front End and to Back End (in WooCommerce > Settings > Products > Default Product Sorting).
|
93 |
+
*/
|
94 |
+
function custom_woocommerce_catalog_orderby( $sortby ) {
|
95 |
+
|
96 |
+
if ( get_option( 'wcj_sorting_by_name_asc_enabled' ) == 'yes' )
|
97 |
+
$sortby['title_asc'] = get_option( 'wcj_sorting_by_name_asc_text' );
|
98 |
+
|
99 |
+
if ( get_option( 'wcj_sorting_by_name_desc_enabled' ) == 'yes' )
|
100 |
+
$sortby['title_desc'] = get_option( 'wcj_sorting_by_name_desc_text' );
|
101 |
+
|
102 |
+
if ( get_option( 'wcj_sorting_by_sku_asc_enabled' ) == 'yes' )
|
103 |
+
$sortby['sku_asc'] = get_option( 'wcj_sorting_by_sku_asc_text' );
|
104 |
+
|
105 |
+
if ( 'yes' == get_option( 'wcj_sorting_by_sku_desc_enabled' ) )
|
106 |
+
$sortby['sku_desc'] = get_option( 'wcj_sorting_by_sku_desc_text' );
|
107 |
+
|
108 |
+
return $sortby;
|
109 |
+
}
|
110 |
+
|
111 |
+
/*
|
112 |
+
* Add new sorting options to WooCommerce sorting.
|
113 |
+
*/
|
114 |
+
function custom_woocommerce_get_catalog_ordering_args( $args ) {
|
115 |
+
|
116 |
+
global $woocommerce;
|
117 |
+
// Get ordering from query string unless defined
|
118 |
+
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
|
119 |
+
// Get order + orderby args from string
|
120 |
+
$orderby_value = explode( '-', $orderby_value );
|
121 |
+
$orderby = esc_attr( $orderby_value[0] );
|
122 |
+
|
123 |
+
switch ( $orderby ) :
|
124 |
+
case 'title_asc' :
|
125 |
+
$args['orderby'] = 'title';
|
126 |
+
$args['order'] = 'asc';
|
127 |
+
$args['meta_key'] = '';
|
128 |
+
break;
|
129 |
+
case 'title_desc' :
|
130 |
+
$args['orderby'] = 'title';
|
131 |
+
$args['order'] = 'desc';
|
132 |
+
$args['meta_key'] = '';
|
133 |
+
break;
|
134 |
+
case 'sku_asc' :
|
135 |
+
$args['orderby'] = 'meta_value';
|
136 |
+
$args['order'] = 'asc';
|
137 |
+
$args['meta_key'] = '_sku';
|
138 |
+
break;
|
139 |
+
case 'sku_desc' :
|
140 |
+
$args['orderby'] = 'meta_value';
|
141 |
+
$args['order'] = 'desc';
|
142 |
+
$args['meta_key'] = '_sku';
|
143 |
+
break;
|
144 |
+
endswitch;
|
145 |
+
|
146 |
+
return $args;
|
147 |
+
}
|
148 |
+
|
149 |
+
/*
|
150 |
+
* Add the settings.
|
151 |
+
*/
|
152 |
+
function get_settings() {
|
153 |
+
|
154 |
+
$settings = array(
|
155 |
+
|
156 |
+
array( 'title' => __( 'Sorting Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_sorting_options' ),
|
157 |
+
|
158 |
+
array(
|
159 |
+
'title' => __( 'Sorting', 'woocommerce-jetpack' ),
|
160 |
+
'desc' => __( 'Enable the Sorting feature', 'woocommerce-jetpack' ),
|
161 |
+
'desc_tip' => __( 'Add more sorting options or remove all sorting including default.', 'woocommerce-jetpack' ),
|
162 |
+
'id' => 'wcj_sorting_enabled',
|
163 |
+
'default' => 'yes',
|
164 |
+
'type' => 'checkbox'
|
165 |
+
),
|
166 |
+
|
167 |
+
array( 'type' => 'sectionend', 'id' => 'wcj_sorting_options' ),
|
168 |
+
|
169 |
+
array( 'title' => __( 'Remove All Sorting', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_remove_all_sorting_options' ),
|
170 |
+
|
171 |
+
array(
|
172 |
+
'title' => __( 'Remove All Sorting', 'woocommerce-jetpack' ),
|
173 |
+
'desc' => __( 'Remove all sorting (including WooCommerce default)', 'woocommerce-jetpack' ),
|
174 |
+
'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
|
175 |
+
'id' => 'wcj_sorting_remove_all_enabled',
|
176 |
+
'default' => 'no',
|
177 |
+
'type' => 'checkbox',
|
178 |
+
'custom_attributes'
|
179 |
+
=> apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
|
180 |
+
),
|
181 |
+
|
182 |
+
array( 'type' => 'sectionend', 'id' => 'wcj_remove_all_sorting_options' ),
|
183 |
+
|
184 |
+
array( 'title' => __( 'Add More Sorting', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_more_sorting_options' ),
|
185 |
+
|
186 |
+
array(
|
187 |
+
'title' => __( 'Sort by Name - Asc', 'woocommerce-jetpack' ),
|
188 |
+
'desc' => __( 'Text visible at front end', 'woocommerce-jetpack' ),
|
189 |
+
'id' => 'wcj_sorting_by_name_asc_text',
|
190 |
+
'default' => 'Sort: A to Z',
|
191 |
+
'type' => 'text',
|
192 |
+
'css' => 'min-width:300px;',
|
193 |
+
),
|
194 |
+
|
195 |
+
array(
|
196 |
+
'title' => __( 'Sort by Name - Asc', 'woocommerce-jetpack' ),
|
197 |
+
'desc' => __( 'Enable', 'woocommerce-jetpack' ),
|
198 |
+
'desc_tip' => __( 'Check to enable.', 'woocommerce-jetpack' ),
|
199 |
+
'id' => 'wcj_sorting_by_name_asc_enabled',
|
200 |
+
'default' => 'yes',
|
201 |
+
'type' => 'checkbox',
|
202 |
+
),
|
203 |
+
|
204 |
+
array(
|
205 |
+
'title' => __( 'Sort by Name - Desc', 'woocommerce-jetpack' ),
|
206 |
+
'desc' => __( 'Text visible at front end', 'woocommerce-jetpack' ),
|
207 |
+
'id' => 'wcj_sorting_by_name_desc_text',
|
208 |
+
'default' => 'Sort: Z to A',
|
209 |
+
'type' => 'text',
|
210 |
+
'css' => 'min-width:300px;',
|
211 |
+
),
|
212 |
+
|
213 |
+
array(
|
214 |
+
'title' => __( 'Sort by Name - Desc', 'woocommerce-jetpack' ),
|
215 |
+
'desc' => __( 'Enable', 'woocommerce-jetpack' ),
|
216 |
+
'desc_tip' => __( 'Check to enable.', 'woocommerce-jetpack' ),
|
217 |
+
'id' => 'wcj_sorting_by_name_desc_enabled',
|
218 |
+
'default' => 'yes',
|
219 |
+
'type' => 'checkbox',
|
220 |
+
),
|
221 |
+
|
222 |
+
array(
|
223 |
+
'title' => __( 'Sort by SKU - Asc', 'woocommerce-jetpack' ),
|
224 |
+
'desc' => __( 'Text visible at front end', 'woocommerce-jetpack' ),
|
225 |
+
'id' => 'wcj_sorting_by_sku_asc_text',
|
226 |
+
'default' => 'Sort: SKU (asc)',
|
227 |
+
'type' => 'text',
|
228 |
+
'css' => 'min-width:300px;',
|
229 |
+
),
|
230 |
+
|
231 |
+
array(
|
232 |
+
'title' => __( 'Sort by SKU - Asc', 'woocommerce-jetpack' ),
|
233 |
+
'desc' => __( 'Enable', 'woocommerce-jetpack' ),
|
234 |
+
'desc_tip' => __( 'Check to enable.', 'woocommerce-jetpack' ),
|
235 |
+
'id' => 'wcj_sorting_by_sku_asc_enabled',
|
236 |
+
'default' => 'yes',
|
237 |
+
'type' => 'checkbox',
|
238 |
+
),
|
239 |
+
|
240 |
+
array(
|
241 |
+
'title' => __( 'Sort by SKU - Desc', 'woocommerce-jetpack' ),
|
242 |
+
'desc' => __( 'Text visible at front end', 'woocommerce-jetpack' ),
|
243 |
+
'id' => 'wcj_sorting_by_sku_desc_text',
|
244 |
+
'default' => 'Sort: SKU (desc)',
|
245 |
+
'type' => 'text',
|
246 |
+
'css' => 'min-width:300px;',
|
247 |
+
),
|
248 |
+
|
249 |
+
array(
|
250 |
+
'title' => __( 'Sort by SKU - Desc', 'woocommerce-jetpack' ),
|
251 |
+
'desc' => __( 'Enable', 'woocommerce-jetpack' ),
|
252 |
+
'desc_tip' => __( 'Check to enable.', 'woocommerce-jetpack' ),
|
253 |
+
'id' => 'wcj_sorting_by_sku_desc_enabled',
|
254 |
+
'default' => 'yes',
|
255 |
+
'type' => 'checkbox',
|
256 |
+
),
|
257 |
+
|
258 |
+
array( 'type' => 'sectionend', 'id' => 'wcj_more_sorting_options' ),
|
259 |
+
);
|
260 |
+
|
261 |
+
return $settings;
|
262 |
+
}
|
263 |
+
|
264 |
+
/*
|
265 |
+
* Add settings section to WooCommerce > Settings > Jetpack.
|
266 |
+
*/
|
267 |
+
function settings_section( $sections ) {
|
268 |
+
|
269 |
+
$sections['sorting'] = 'Sorting';
|
270 |
+
|
271 |
+
return $sections;
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
endif;
|
276 |
+
|
277 |
+
return new WCJ_Sorting();
|
readme.txt
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WooCommerce Jetpack ===
|
2 |
+
Contributors: algoritmika
|
3 |
+
Donate link: http://algoritmika.com/donate/
|
4 |
+
Tags: woocommerce,jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs
|
5 |
+
Requires at least: 3.9
|
6 |
+
Tested up to: 3.9
|
7 |
+
Stable tag: 1.0.0
|
8 |
+
License: GNU General Public License v3.0
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
+
|
11 |
+
Supercharge your WordPress WooCommerce site with these awesome powerful features.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
WooCommerce Jetpack is a WordPress plugin that supercharges your WooCommerce site with awesome powerful features.
|
16 |
+
Features are absolutely required for anyone using excellent WooCommerce platform.
|
17 |
+
Features include: custom price labels, call for price, all currencies etc.
|
18 |
+
|
19 |
+
= Feedback =
|
20 |
+
* We are open to your suggestions and feedback - Thank you for using or trying out one of our plugins!
|
21 |
+
* Drop us a line at [www.algoritmika.com](http://woojetpack.com/contact-us/)
|
22 |
+
|
23 |
+
= More =
|
24 |
+
* Vist the [WooCommerce Jetpack plugin page](http://woojetpack.com/)
|
25 |
+
|
26 |
+
== Installation ==
|
27 |
+
|
28 |
+
1. Upload the entire 'woocommerce-jetpack' folder to the '/wp-content/plugins/' directory
|
29 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
30 |
+
3. Go to WooCommerce > Settings > Jetpack.
|
31 |
+
|
32 |
+
== Frequently Asked Questions ==
|
33 |
+
|
34 |
+
= How to unlock those some features settings that are locked? =
|
35 |
+
|
36 |
+
To unlock all WooCommerce Jetpack features, please install additional <a href="http://woojetpack.com/plus/">WooCommerce Jetpack Plus</a> plugin.
|
37 |
+
|
38 |
+
== Screenshots ==
|
39 |
+
|
40 |
+
1. Plugin admin area.
|
41 |
+
|
42 |
+
== Changelog ==
|
43 |
+
|
44 |
+
= 1.0.0 =
|
45 |
+
* Initial Release
|
46 |
+
|
47 |
+
== Upgrade Notice ==
|
48 |
+
|
49 |
+
= 1.0.0 =
|
50 |
+
This version was created on 2014.06.01
|
woocommerce-jetpack.php
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: WooCommerce Jetpack
|
4 |
+
Plugin URI: http://woojetpack.com
|
5 |
+
Description: Supercharge your WooCommerce site with these awesome powerful features.
|
6 |
+
Version: 1.0.0
|
7 |
+
Author: Algoritmika Ltd.
|
8 |
+
Author URI: http://www.algoritmika.com
|
9 |
+
Copyright: © 2014 Algoritmika Ltd.
|
10 |
+
License: GNU General Public License v3.0
|
11 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
12 |
+
*/
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
14 |
+
|
15 |
+
if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) return; // Check if WooCommerce is active
|
16 |
+
|
17 |
+
if ( ! class_exists( 'WC_Jetpack' ) ) :
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Main WC_Jetpack Class
|
21 |
+
*
|
22 |
+
* @class WC_Jetpack
|
23 |
+
*/
|
24 |
+
final class WC_Jetpack {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @var WC_Jetpack The single instance of the class
|
28 |
+
*/
|
29 |
+
protected static $_instance = null;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Main WC_Jetpack Instance
|
33 |
+
*
|
34 |
+
* Ensures only one instance of WC_Jetpack is loaded or can be loaded.
|
35 |
+
*
|
36 |
+
* @static
|
37 |
+
* @see WJ()
|
38 |
+
* @return WC_Jetpack - Main instance
|
39 |
+
*/
|
40 |
+
public static function instance() {
|
41 |
+
if ( is_null( self::$_instance ) ) {
|
42 |
+
self::$_instance = new self();
|
43 |
+
}
|
44 |
+
return self::$_instance;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Cloning is forbidden.
|
49 |
+
*
|
50 |
+
public function __clone() {
|
51 |
+
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woocommerce-jetpack' ), '3.9.1' );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Unserializing instances of this class is forbidden.
|
56 |
+
*
|
57 |
+
public function __wakeup() {
|
58 |
+
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woocommerce-jetpack' ), '3.9.1' );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* WC_Jetpack Constructor.
|
63 |
+
* @access public
|
64 |
+
*/
|
65 |
+
public function __construct() {
|
66 |
+
|
67 |
+
// Include required files
|
68 |
+
$this->includes();
|
69 |
+
|
70 |
+
// HOOKS
|
71 |
+
//register_activation_hook( __FILE__, array( $this, 'install' ) );
|
72 |
+
// add_action( 'admin_init', array( $this, 'install' ) );
|
73 |
+
add_action( 'init', array( $this, 'init' ), 0 );
|
74 |
+
|
75 |
+
add_filter( 'wcjpc_filter', array( $this, 'wcjpc' ), 100 );
|
76 |
+
|
77 |
+
// Settings
|
78 |
+
if ( is_admin() ) {
|
79 |
+
|
80 |
+
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_wcj_settings_tab' ) );
|
81 |
+
add_filter( 'get_wc_jetpack_plus_message', array( $this, 'display_get_wcj_plus_message' ), 100, 2 );
|
82 |
+
}
|
83 |
+
|
84 |
+
// Loaded action
|
85 |
+
do_action( 'wcj_loaded' );
|
86 |
+
}
|
87 |
+
|
88 |
+
public function wcjpc( $value ) {
|
89 |
+
return $value;
|
90 |
+
}
|
91 |
+
|
92 |
+
public function display_get_wcj_plus_message( $value, $message_type ) {
|
93 |
+
|
94 |
+
switch ( $message_type ) {
|
95 |
+
|
96 |
+
case 'global':
|
97 |
+
return
|
98 |
+
__( '<div class="updated">
|
99 |
+
<p class="main"><strong>Install WooCommerce Jetpack Plus to unlock all features</strong></p>
|
100 |
+
<span>Some settings fields are locked and you will need <a href="http://woojetpack.com/plus/">WooCommerce Jetpack Plus</a> to modify all locked fields.</span>
|
101 |
+
<p><a href="http://woojetpack.com/plus/" target="_blank" class="button button-primary">Buy now just for $9</a> <a href="http://woojetpack.com" target="_blank" class="button">Visit woojetpack.com</a></p>
|
102 |
+
</div>' );
|
103 |
+
|
104 |
+
case 'desc':
|
105 |
+
return __( 'Get <a href="http://woojetpack.com/plus/" target="_blank">WooCommerce Jetpack Plus</a> to change value.', 'woocommerce-jetpack' );
|
106 |
+
|
107 |
+
case 'desc_below':
|
108 |
+
return __( 'Get <a href="http://woojetpack.com/plus/" target="_blank">WooCommerce Jetpack Plus</a> to change values below.', 'woocommerce-jetpack' );
|
109 |
+
|
110 |
+
case 'desc_no_link':
|
111 |
+
return __( 'Get WooCommerce Jetpack Plus to change value.', 'woojetpack' );
|
112 |
+
|
113 |
+
case 'readonly':
|
114 |
+
return array( 'readonly' => 'readonly' );
|
115 |
+
|
116 |
+
case 'disabled':
|
117 |
+
return array( 'disabled' => 'disabled' );
|
118 |
+
|
119 |
+
case 'readonly_string':
|
120 |
+
return __( 'readonly', 'woojetpack' );
|
121 |
+
|
122 |
+
case 'disabled_string':
|
123 |
+
return __( 'disabled', 'woojetpack' );
|
124 |
+
}
|
125 |
+
|
126 |
+
return $value;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Add options.
|
131 |
+
*
|
132 |
+
function install() {
|
133 |
+
|
134 |
+
$settings = array();
|
135 |
+
$settings[] = include( 'includes/class-wcj-currencies.php' );
|
136 |
+
$settings[] = include( 'includes/class-wcj-price-labels.php' );
|
137 |
+
$settings[] = include( 'includes/class-wcj-sorting.php' );
|
138 |
+
$settings[] = include( 'includes/class-wcj-product-info.php' );
|
139 |
+
|
140 |
+
foreach ( $settings as $section ) {
|
141 |
+
foreach ( $section->get_settings() as $value ) {
|
142 |
+
if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
|
143 |
+
$autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true;
|
144 |
+
add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Include required core files used in admin and on the frontend.
|
152 |
+
*/
|
153 |
+
private function includes() {
|
154 |
+
|
155 |
+
$settings = array();
|
156 |
+
|
157 |
+
$settings[] = include_once( 'includes/class-wcj-price-labels.php' );
|
158 |
+
$settings[] = include_once( 'includes/class-wcj-call-for-price.php' );
|
159 |
+
$settings[] = include_once( 'includes/class-wcj-currencies.php' );
|
160 |
+
$settings[] = include_once( 'includes/class-wcj-sorting.php' );
|
161 |
+
$settings[] = include_once( 'includes/class-wcj-old-slugs.php' );
|
162 |
+
//$settings[] = include_once( 'includes/class-wcj-product-info.php' );
|
163 |
+
|
164 |
+
// Add options
|
165 |
+
if ( is_admin() ) {
|
166 |
+
foreach ( $settings as $section ) {
|
167 |
+
foreach ( $section->get_settings() as $value ) {
|
168 |
+
if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
|
169 |
+
$autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true;
|
170 |
+
add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
|
171 |
+
}
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Add Jetpack settings tab to WooCommerce settings.
|
179 |
+
*/
|
180 |
+
public function add_wcj_settings_tab( $settings ) {
|
181 |
+
|
182 |
+
$settings[] = include( 'includes/admin/settings/class-wc-settings-jetpack.php' );
|
183 |
+
|
184 |
+
return $settings;
|
185 |
+
}
|
186 |
+
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Init WC_Jetpack when WordPress initialises.
|
190 |
+
*/
|
191 |
+
public function init() {
|
192 |
+
|
193 |
+
// Before init action
|
194 |
+
do_action( 'before_wcj_init' );
|
195 |
+
|
196 |
+
// Set up localisation
|
197 |
+
//$this->load_plugin_textdomain();
|
198 |
+
|
199 |
+
// Init action
|
200 |
+
do_action( 'wcj_init' );
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
endif;
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Returns the main instance of WC_Jetpack to prevent the need to use globals.
|
208 |
+
*
|
209 |
+
* @return WC_Jetpack
|
210 |
+
*/
|
211 |
+
function WCJ() {
|
212 |
+
|
213 |
+
return WC_Jetpack::instance();
|
214 |
+
}
|
215 |
+
|
216 |
+
WCJ();
|