Version Description
- Enhancement - Compatibility version: Wordpress 6.0 and WooCommerce 6.7
- Enhancement - POST META FILTERING ADD-ON
- Enhancement - Hierarchical view for taxonomies list
- Fix - Color/Image select with polylang
- Fix - Additional tables generation for some site
- Fix - Currency exchange compatibility
- Fix - Module for Divi theme
- Fix - Style of admin elements
Download this release
Release Info
Developer | RazyRx |
Plugin | Advanced AJAX Product Filters |
Version | 1.6.3 |
Comparing to | |
See all releases |
Code changes from version 1.6.2 to 1.6.3
- addons/additional_tables/additional_tables.php +109 -62
- addons/custom_postmeta/additional_tables.php +453 -0
- addons/custom_postmeta/custom_postmeta.php +51 -0
- addons/custom_postmeta/postmeta.php +451 -0
- assets/admin/js/admin.js +36 -688
- assets/admin/js/single_filter_edit.js +23 -14
- berocket/includes/updater.php +47 -31
- includes/currency-exchange.php +25 -0
- includes/custom_post.php +6 -78
- includes/divi/modules/filternext/filternext.php +0 -4
- includes/filters/get_terms.php +4 -0
- includes/functions.php +10 -1
- includes/new_widget.php +1 -3
- includes/template_styles_preview.php +2 -2
- includes/url-parse.php +38 -29
- includes/widget_functions.php +80 -50
- libraries/link_parser.php +1 -1
- main.php +6 -14
- readme.txt +16 -2
- template_styles/color.php +2 -2
- templates/color_ajax.php +4 -4
- templates/filter_post_simple.php +0 -140
- templates/filters_group_simple.php +0 -132
- templates/include_exclude_list.php +1 -1
- templates/single_filter/single_settings_elements.php +3 -2
- woocommerce-filters.php +3 -3
addons/additional_tables/additional_tables.php
CHANGED
@@ -3,63 +3,95 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
|
|
3 |
public $addon_file = __FILE__;
|
4 |
public $plugin_name = 'ajax_filters';
|
5 |
public $php_file_name = 'add_table';
|
6 |
-
public $
|
7 |
-
public $
|
8 |
-
1 => array(
|
9 |
-
'percentage' => 4
|
10 |
-
),
|
11 |
-
2 => array(
|
12 |
-
'percentage' => 13
|
13 |
-
),
|
14 |
-
3 => array(
|
15 |
-
'percentage' => 70
|
16 |
-
),
|
17 |
-
4 => array(
|
18 |
-
'percentage' => 3
|
19 |
-
),
|
20 |
-
5 => array(
|
21 |
-
'percentage' => 10
|
22 |
-
),
|
23 |
-
6 => array(
|
24 |
-
'percentage' => 0
|
25 |
-
),
|
26 |
-
);
|
27 |
function __construct() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
parent::__construct();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
$active_addons = apply_filters('berocket_addons_active_'.$this->plugin_name, array());
|
30 |
$create_position = $this->get_current_create_position();
|
|
|
31 |
if( in_array($this->addon_file, $active_addons) ) {
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
33 |
add_action( "braapf_additional_table_cron", array( $this, 'cron' ), 10 );
|
34 |
-
|
35 |
$create_position = $this->get_current_create_position();
|
36 |
-
if( $create_position
|
37 |
add_action('admin_init', array($this, 'activate_hooks'));
|
38 |
}
|
39 |
add_action( "admin_footer", array( $this, 'destroy_table_wc_regeneration' ) );
|
40 |
add_action( 'br-filters/addon/add-table/destroy', array($this, 'destroy_table') );
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
}
|
47 |
} else {
|
|
|
|
|
48 |
delete_option('BeRocket_aapf_additional_tables_addon_position');
|
49 |
delete_option('BeRocket_aapf_additional_tables_addon_position_data');
|
50 |
if( ! empty($create_position) ) {
|
51 |
$this->deactivate();
|
52 |
}
|
53 |
}
|
|
|
54 |
}
|
55 |
function get_charset_collate() {
|
56 |
global $wpdb;
|
57 |
-
|
58 |
if( ! empty($result) && ! empty($result->Collation) ) {
|
59 |
$collate = 'DEFAULT CHARACTER SET ' . $wpdb->charset . ' COLLATE ' . $result->Collation;
|
60 |
} else {
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
63 |
return $collate;
|
64 |
}
|
65 |
function cron() {
|
@@ -74,7 +106,7 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
|
|
74 |
$this->activate(-1, true);
|
75 |
$end_time = time();
|
76 |
$create_position = $this->get_current_create_position();
|
77 |
-
} while( $time_limit > ($end_time - $start_time) && $create_position
|
78 |
}
|
79 |
function init_activate() {
|
80 |
$this->activate();
|
@@ -88,16 +120,24 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
|
|
88 |
}
|
89 |
function check_init() {
|
90 |
$create_position = get_option('BeRocket_aapf_additional_tables_addon_position');
|
91 |
-
if( $create_position
|
92 |
parent::check_init();
|
93 |
}
|
94 |
}
|
95 |
function get_current_create_position() {
|
96 |
-
|
|
|
|
|
|
|
|
|
97 |
}
|
98 |
function set_current_create_position($position) {
|
99 |
update_option('BeRocket_aapf_additional_tables_addon_position', $position);
|
100 |
}
|
|
|
|
|
|
|
|
|
101 |
function get_current_create_position_data() {
|
102 |
return get_option('BeRocket_aapf_additional_tables_addon_position_data');
|
103 |
}
|
@@ -111,38 +151,41 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
|
|
111 |
if( $current_position == -1 ) {
|
112 |
$current_position = $this->get_current_create_position();
|
113 |
}
|
114 |
-
if( empty($current_position)
|
115 |
-
$this->
|
116 |
-
|
117 |
-
$this->insert_table_braapf_product_stock_status_parent();
|
118 |
-
} elseif( $current_position == 3 && $brajax ) {
|
119 |
-
$this->insert_table_braapf_product_variation_attributes();
|
120 |
-
} elseif( $current_position == 4 && $brajax ) {
|
121 |
-
$this->insert_table_braapf_variable_attributes();
|
122 |
-
} elseif( $current_position == 5 ) {
|
123 |
-
if( class_exists('berocket_information_notices') ) {
|
124 |
-
new berocket_information_notices(array(
|
125 |
-
'name' => $this->plugin_name.'_additional_table_status_end',
|
126 |
-
'html' => '<strong>BeRocket AJAX Product Filters</strong> '.__('Additional tables was succesfully generated. They will be used automatically when needed.', 'BeRocket_AJAX_domain'),
|
127 |
-
'righthtml' => '<a class="berocket_no_thanks">Got it</a>',
|
128 |
-
'rightwidth' => 50,
|
129 |
-
'nothankswidth' => 50,
|
130 |
-
'contentwidth' => 400,
|
131 |
-
'subscribe' => false,
|
132 |
-
'height' => 50,
|
133 |
-
));
|
134 |
}
|
135 |
-
|
136 |
-
|
137 |
-
$
|
138 |
-
|
139 |
-
|
140 |
-
update_option( 'br_filters_options', $options );
|
141 |
-
}
|
142 |
-
if( empty($current_position) || $current_position < 5 ) {
|
143 |
wp_schedule_single_event(time(), 'braapf_additional_table_cron');
|
144 |
}
|
145 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
function activate_hooks() {
|
147 |
if( function_exists('wc_update_product_lookup_tables_is_running') && ! wc_update_product_lookup_tables_is_running() ) {
|
148 |
//Notices
|
@@ -239,13 +282,16 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
|
|
239 |
$position_data = $this->get_current_create_position_data();
|
240 |
$position_status = br_get_value_from_array($position_data, 'status', 0);
|
241 |
$global_status = 0;
|
|
|
242 |
foreach($this->position_data as $position_i => $position_data_arr) {
|
243 |
if( $position_i < $current_position ) {
|
244 |
$global_status += $position_data_arr['percentage'];
|
245 |
} elseif( $position_i == $current_position ) {
|
246 |
$global_status += ( $position_data_arr['percentage'] / 100 * $position_status );
|
247 |
}
|
|
|
248 |
}
|
|
|
249 |
$global_status = intval($global_status);
|
250 |
return $global_status;
|
251 |
}
|
@@ -637,6 +683,7 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
|
|
637 |
'status' => 0,
|
638 |
'run' => false,
|
639 |
));
|
|
|
640 |
}
|
641 |
function destroy_table_wc_regeneration() {
|
642 |
if ( apply_filters( 'br-filters/addon/add-table/wc-regenerate-destroy', function_exists('wc_update_product_lookup_tables_is_running') && wc_update_product_lookup_tables_is_running() ) ) {
|
3 |
public $addon_file = __FILE__;
|
4 |
public $plugin_name = 'ajax_filters';
|
5 |
public $php_file_name = 'add_table';
|
6 |
+
public $position_data;
|
7 |
+
public $run_additional_tables = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
function __construct() {
|
9 |
+
$this->position_data = array(
|
10 |
+
0 => array(
|
11 |
+
'percentage' => 0,
|
12 |
+
'execute' => array($this, 'increment_create_position'),
|
13 |
+
'ajax_only' => false
|
14 |
+
),
|
15 |
+
1 => array(
|
16 |
+
'percentage' => 4,
|
17 |
+
'execute' => array($this, 'create_all_tables'),
|
18 |
+
'ajax_only' => true
|
19 |
+
),
|
20 |
+
2 => array(
|
21 |
+
'percentage' => 13,
|
22 |
+
'execute' => array($this, 'insert_table_braapf_product_stock_status_parent'),
|
23 |
+
'ajax_only' => true
|
24 |
+
),
|
25 |
+
3 => array(
|
26 |
+
'percentage' => 70,
|
27 |
+
'execute' => array($this, 'insert_table_braapf_product_variation_attributes'),
|
28 |
+
'ajax_only' => true
|
29 |
+
),
|
30 |
+
4 => array(
|
31 |
+
'percentage' => 3,
|
32 |
+
'execute' => array($this, 'insert_table_braapf_variable_attributes'),
|
33 |
+
'ajax_only' => true
|
34 |
+
),
|
35 |
+
);
|
36 |
parent::__construct();
|
37 |
+
add_action('init', array($this, 'init_tables'), 3);
|
38 |
+
add_action('admin_footer', array($this, 'init_tables'), 3);
|
39 |
+
}
|
40 |
+
function init_tables() {
|
41 |
+
if( $this->run_additional_tables ) {
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
$this->run_additional_tables = true;
|
45 |
$active_addons = apply_filters('berocket_addons_active_'.$this->plugin_name, array());
|
46 |
$create_position = $this->get_current_create_position();
|
47 |
+
$status = 'start';
|
48 |
if( in_array($this->addon_file, $active_addons) ) {
|
49 |
+
$this->position_data = apply_filters('BeRocket_aapf_variations_tables_addon_position_data', $this->position_data, $this);
|
50 |
+
if( strpos($create_position, 'ended') !== FALSE && $create_position != $this->get_end_position() ) {
|
51 |
+
$this->destroy_table();
|
52 |
+
$create_position = false;
|
53 |
+
}
|
54 |
+
if( strpos($create_position, 'ended') === FALSE ) {
|
55 |
add_action( "braapf_additional_table_cron", array( $this, 'cron' ), 10 );
|
56 |
+
$this->init_activate();
|
57 |
$create_position = $this->get_current_create_position();
|
58 |
+
if( strpos($create_position, 'ended') === FALSE ) {
|
59 |
add_action('admin_init', array($this, 'activate_hooks'));
|
60 |
}
|
61 |
add_action( "admin_footer", array( $this, 'destroy_table_wc_regeneration' ) );
|
62 |
add_action( 'br-filters/addon/add-table/destroy', array($this, 'destroy_table') );
|
63 |
+
$status = 'generating';
|
64 |
+
} else {
|
65 |
+
$status = 'ready';
|
66 |
+
if(is_admin()) {
|
67 |
+
if( ! empty($create_position) ) {
|
68 |
+
add_action( "admin_footer", array( $this, 'destroy_table_wc_regeneration' ) );
|
69 |
+
add_action( 'br-filters/addon/add-table/destroy', array($this, 'destroy_table') );
|
70 |
+
}
|
71 |
}
|
72 |
}
|
73 |
} else {
|
74 |
+
$create_position = $this->get_current_create_position();
|
75 |
+
$status = 'remove';
|
76 |
delete_option('BeRocket_aapf_additional_tables_addon_position');
|
77 |
delete_option('BeRocket_aapf_additional_tables_addon_position_data');
|
78 |
if( ! empty($create_position) ) {
|
79 |
$this->deactivate();
|
80 |
}
|
81 |
}
|
82 |
+
do_action('BeRocket_aapf_variations_tables_addon_status', $status, $create_position, $this);
|
83 |
}
|
84 |
function get_charset_collate() {
|
85 |
global $wpdb;
|
86 |
+
/*$result = $wpdb->get_row("SHOW TABLE STATUS where name like '{$wpdb->posts}'");
|
87 |
if( ! empty($result) && ! empty($result->Collation) ) {
|
88 |
$collate = 'DEFAULT CHARACTER SET ' . $wpdb->charset . ' COLLATE ' . $result->Collation;
|
89 |
} else {
|
90 |
+
}*/
|
91 |
+
$collate = '';
|
92 |
+
if ( $wpdb->has_cap( 'collation' ) ) {
|
93 |
+
$collate = $wpdb->get_charset_collate();
|
94 |
+
}
|
95 |
return $collate;
|
96 |
}
|
97 |
function cron() {
|
106 |
$this->activate(-1, true);
|
107 |
$end_time = time();
|
108 |
$create_position = $this->get_current_create_position();
|
109 |
+
} while( $time_limit > ($end_time - $start_time) && strpos($create_position, 'ended') === FALSE && strpos($create_position, 'final') === FALSE );
|
110 |
}
|
111 |
function init_activate() {
|
112 |
$this->activate();
|
120 |
}
|
121 |
function check_init() {
|
122 |
$create_position = get_option('BeRocket_aapf_additional_tables_addon_position');
|
123 |
+
if( strpos($create_position, 'ended') !== FALSE ) {
|
124 |
parent::check_init();
|
125 |
}
|
126 |
}
|
127 |
function get_current_create_position() {
|
128 |
+
$current_position = get_option('BeRocket_aapf_additional_tables_addon_position');
|
129 |
+
if( empty($current_position) ) {
|
130 |
+
$current_position = 1;
|
131 |
+
}
|
132 |
+
return $current_position;
|
133 |
}
|
134 |
function set_current_create_position($position) {
|
135 |
update_option('BeRocket_aapf_additional_tables_addon_position', $position);
|
136 |
}
|
137 |
+
function increment_create_position() {
|
138 |
+
$current_position = $this->get_current_create_position();
|
139 |
+
$this->set_current_create_position($current_position+1);
|
140 |
+
}
|
141 |
function get_current_create_position_data() {
|
142 |
return get_option('BeRocket_aapf_additional_tables_addon_position_data');
|
143 |
}
|
151 |
if( $current_position == -1 ) {
|
152 |
$current_position = $this->get_current_create_position();
|
153 |
}
|
154 |
+
if( ! empty($this->position_data[$current_position]) ) {
|
155 |
+
if( empty($this->position_data[$current_position]['ajax_only']) || $brajax ) {
|
156 |
+
call_user_func($this->position_data[$current_position]['execute'], $current_position, $this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
+
} else {
|
159 |
+
$this->set_current_create_position('final');
|
160 |
+
$this->table_generation_end();
|
161 |
+
}
|
162 |
+
if( empty($current_position) || empty($this->position_data[$current_position]) || empty($this->position_data[$current_position]['end_pos']) ) {
|
|
|
|
|
|
|
163 |
wp_schedule_single_event(time(), 'braapf_additional_table_cron');
|
164 |
}
|
165 |
}
|
166 |
+
function get_end_position() {
|
167 |
+
return apply_filters('braapf_additional_table_ended_position', 'ended');
|
168 |
+
}
|
169 |
+
function table_generation_end() {
|
170 |
+
if( class_exists('berocket_information_notices') ) {
|
171 |
+
new berocket_information_notices(array(
|
172 |
+
'name' => $this->plugin_name.'_additional_table_status_end',
|
173 |
+
'html' => '<strong>BeRocket AJAX Product Filters</strong> '.__('Additional tables was succesfully generated. They will be used automatically when needed.', 'BeRocket_AJAX_domain'),
|
174 |
+
'righthtml' => '<a class="berocket_no_thanks">Got it</a>',
|
175 |
+
'rightwidth' => 50,
|
176 |
+
'nothankswidth' => 50,
|
177 |
+
'contentwidth' => 400,
|
178 |
+
'subscribe' => false,
|
179 |
+
'height' => 50,
|
180 |
+
));
|
181 |
+
}
|
182 |
+
$this->set_current_create_position($this->get_end_position());
|
183 |
+
wp_clear_scheduled_hook('braapf_additional_table_cron');
|
184 |
+
$BeRocket_AAPF = BeRocket_AAPF::getInstance();
|
185 |
+
$options = $BeRocket_AAPF->get_option();
|
186 |
+
$options['purge_cache_time'] = time();
|
187 |
+
update_option( 'br_filters_options', $options );
|
188 |
+
}
|
189 |
function activate_hooks() {
|
190 |
if( function_exists('wc_update_product_lookup_tables_is_running') && ! wc_update_product_lookup_tables_is_running() ) {
|
191 |
//Notices
|
282 |
$position_data = $this->get_current_create_position_data();
|
283 |
$position_status = br_get_value_from_array($position_data, 'status', 0);
|
284 |
$global_status = 0;
|
285 |
+
$global_status_full = 0;
|
286 |
foreach($this->position_data as $position_i => $position_data_arr) {
|
287 |
if( $position_i < $current_position ) {
|
288 |
$global_status += $position_data_arr['percentage'];
|
289 |
} elseif( $position_i == $current_position ) {
|
290 |
$global_status += ( $position_data_arr['percentage'] / 100 * $position_status );
|
291 |
}
|
292 |
+
$global_status_full += $position_data_arr['percentage'];;
|
293 |
}
|
294 |
+
$global_status = (100 / $global_status_full) * $global_status;
|
295 |
$global_status = intval($global_status);
|
296 |
return $global_status;
|
297 |
}
|
683 |
'status' => 0,
|
684 |
'run' => false,
|
685 |
));
|
686 |
+
do_action('BeRocket_aapf_variations_tables_addon_destroy_table', $this);
|
687 |
}
|
688 |
function destroy_table_wc_regeneration() {
|
689 |
if ( apply_filters( 'br-filters/addon/add-table/wc-regenerate-destroy', function_exists('wc_update_product_lookup_tables_is_running') && wc_update_product_lookup_tables_is_running() ) ) {
|
addons/custom_postmeta/additional_tables.php
ADDED
@@ -0,0 +1,453 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if( ! class_exists('BeRocket_aapf_variations_tables_postmeta_addon') ) {
|
3 |
+
class BeRocket_aapf_variations_tables_postmeta_addon {
|
4 |
+
public $additional_table_class = false;
|
5 |
+
public $position_update = 1;
|
6 |
+
public $required_update = false;
|
7 |
+
public $position_last = 1;
|
8 |
+
public $post_clauses_number = 1;
|
9 |
+
function __construct() {
|
10 |
+
//Generate tables
|
11 |
+
add_action('BeRocket_aapf_variations_tables_addon_destroy_table', array($this, 'destroy_table'));
|
12 |
+
add_filter('BeRocket_aapf_variations_tables_addon_position_data', array($this, 'position_data'), 100000, 2);
|
13 |
+
add_action('updated_post_meta', array($this, 'save_filter'), 10, 4);
|
14 |
+
add_action('added_post_meta', array($this, 'save_filter'), 10, 4);
|
15 |
+
add_action('deleted_post_meta', array($this, 'save_filter'), 10, 4);
|
16 |
+
add_action('braapf_additional_table_ended_position', array($this, 'add_end_string'), 100);
|
17 |
+
//Replace
|
18 |
+
add_action('BeRocket_aapf_variations_tables_addon_status', array($this, 'addon_active'), 10, 3);
|
19 |
+
add_action( 'admin_footer', array($this, 'admin_footer') );
|
20 |
+
}
|
21 |
+
function addon_active($status, $create_position, $instance) {
|
22 |
+
if( is_admin() && $status == 'ready' ) {
|
23 |
+
if( strpos($create_position, 'cpm') === FALSE ) {
|
24 |
+
$this->destroy_table();
|
25 |
+
$instance->set_current_create_position();
|
26 |
+
$status = 'start';
|
27 |
+
}
|
28 |
+
}
|
29 |
+
if($status == 'ready') {
|
30 |
+
add_filter('berocket_aapf_postmeta_main_query', array($this, 'postmeta_main_query'));
|
31 |
+
add_filter('berocket_aapf_recount_postmeta_query', array($this, 'recount_postmeta_query'), 10, 3);
|
32 |
+
add_filter('bapf_uparse_generate_meta_query_postmeta_meta_query_use', array($this, 'disable'), 10, 1);
|
33 |
+
add_filter('bapf_uparse_generate_custom_query_each', array($this, 'custom_query_each'), 10000, 4);
|
34 |
+
add_filter('bapf_uparse_generate_posts_in_each', array($this, 'posts_in'), 10000, 4);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
function disable() {
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
function add_end_string($ended) {
|
41 |
+
$ended = $ended . ' cpm ';
|
42 |
+
return $ended;
|
43 |
+
}
|
44 |
+
function destroy_table() {
|
45 |
+
global $wpdb;
|
46 |
+
$tables_drop = array(
|
47 |
+
'braapf_custom_post_meta',
|
48 |
+
'braapf_product_post_meta'
|
49 |
+
);
|
50 |
+
foreach($tables_drop as $table_drop) {
|
51 |
+
$table_name = $wpdb->prefix . $table_drop;
|
52 |
+
$sql = "DROP TABLE IF EXISTS {$table_name};";
|
53 |
+
$wpdb->query($sql);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
function position_data($position_data, $instance) {
|
57 |
+
$this->position_last = count($position_data);
|
58 |
+
$position_data[] = array(
|
59 |
+
'percentage' => 4,
|
60 |
+
'execute' => array($this, 'create_table'),
|
61 |
+
'ajax_only' => true
|
62 |
+
);
|
63 |
+
$this->additional_table_class = $instance;
|
64 |
+
$this->position_update = count($position_data);
|
65 |
+
$position_data[] = array(
|
66 |
+
'percentage' => 15,
|
67 |
+
'execute' => array($this, 'create_post_meta'),
|
68 |
+
'ajax_only' => true
|
69 |
+
);
|
70 |
+
$position_data[] = array(
|
71 |
+
'percentage' => 120,
|
72 |
+
'execute' => array($this, 'generate_post_meta'),
|
73 |
+
'ajax_only' => true
|
74 |
+
);
|
75 |
+
$this->is_required_update();
|
76 |
+
return $position_data;
|
77 |
+
}
|
78 |
+
function create_table($current_position, $instance) {
|
79 |
+
$run_data = $instance->get_current_create_position_data();
|
80 |
+
if( ! empty($run_data) && ! empty($run_data['run']) ) {
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
$instance->set_current_create_position_data(array(
|
84 |
+
'status' => 0,
|
85 |
+
'run' => true,
|
86 |
+
));
|
87 |
+
global $wpdb;
|
88 |
+
$charset_collate = $this->get_charset_collate();
|
89 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
90 |
+
//braapf_custom_post_meta table
|
91 |
+
$table_name = $wpdb->prefix . 'braapf_custom_post_meta';
|
92 |
+
$sql = "DROP TABLE IF EXISTS {$table_name};";
|
93 |
+
$wpdb->query($sql);
|
94 |
+
$sql = "CREATE TABLE $table_name (
|
95 |
+
meta_id bigint(20) NOT NULL AUTO_INCREMENT,
|
96 |
+
meta varchar(120) NOT NULL,
|
97 |
+
slug varchar(120) NOT NULL,
|
98 |
+
count bigint(20) DEFAULT '1',
|
99 |
+
name text NOT NULL,
|
100 |
+
INDEX meta_id (meta_id),
|
101 |
+
INDEX meta (meta),
|
102 |
+
INDEX slug (slug),
|
103 |
+
INDEX metaslug (meta, slug),
|
104 |
+
UNIQUE uniqueid (meta, slug)
|
105 |
+
) $charset_collate;";
|
106 |
+
$query_status = dbDelta( $sql );
|
107 |
+
$instance->save_query_error($sql, $query_status);
|
108 |
+
//braapf_product_post_meta table
|
109 |
+
$table_name = $wpdb->prefix . 'braapf_product_post_meta';
|
110 |
+
$sql = "DROP TABLE IF EXISTS {$table_name};";
|
111 |
+
$wpdb->query($sql);
|
112 |
+
$sql = "CREATE TABLE $table_name (
|
113 |
+
meta_id bigint(20) NOT NULL,
|
114 |
+
product_id bigint(20) NOT NULL,
|
115 |
+
INDEX meta_id (meta_id),
|
116 |
+
INDEX product_id (product_id),
|
117 |
+
INDEX metaslug (meta_id, product_id),
|
118 |
+
UNIQUE uniqueid (meta_id, product_id)
|
119 |
+
) $charset_collate;";
|
120 |
+
$query_status = dbDelta( $sql );
|
121 |
+
$instance->save_query_error($sql, $query_status);
|
122 |
+
//get_current post meta
|
123 |
+
$BeRocket_AAPF_single_filter = BeRocket_AAPF_single_filter::getInstance();
|
124 |
+
$filters = $BeRocket_AAPF_single_filter->get_custom_posts();
|
125 |
+
$postmeta = array();
|
126 |
+
foreach($filters as $filter) {
|
127 |
+
$filter_option = $BeRocket_AAPF_single_filter->get_option($filter);
|
128 |
+
if( ! empty($filter_option['filter_type']) && $filter_option['filter_type'] == 'custom_postmeta' && ! empty($filter_option['custom_postmeta']) ) {
|
129 |
+
$postmeta[] = $filter_option['custom_postmeta'];
|
130 |
+
}
|
131 |
+
}
|
132 |
+
update_option('berocket_aapf_custom_post_meta', $postmeta);
|
133 |
+
$instance->set_current_create_position_data(array(
|
134 |
+
'status' => 0,
|
135 |
+
'run' => false,
|
136 |
+
));
|
137 |
+
if( count($postmeta) == 0 ) {
|
138 |
+
$instance->set_current_create_position($current_position+3);
|
139 |
+
} else {
|
140 |
+
$instance->increment_create_position();
|
141 |
+
}
|
142 |
+
}
|
143 |
+
function create_post_meta($current_position, $instance) {
|
144 |
+
$run_data = $instance->get_current_create_position_data();
|
145 |
+
if( empty($run_data) || ! empty($run_data['run']) ) {
|
146 |
+
return false;
|
147 |
+
}
|
148 |
+
$run_data['run'] = true;
|
149 |
+
$instance->set_current_create_position_data($run_data);
|
150 |
+
global $wpdb;
|
151 |
+
$postmeta = get_option('berocket_aapf_custom_post_meta');
|
152 |
+
if( is_array($postmeta) && count($postmeta) > 0 ) {
|
153 |
+
foreach($postmeta as $postmeta_single) {
|
154 |
+
$this->regenerate_values_single_post_meta($postmeta_single);
|
155 |
+
}
|
156 |
+
}
|
157 |
+
$sql = "SELECT MIN({$wpdb->postmeta}.meta_id) as min, MAX({$wpdb->postmeta}.meta_id) as max FROM {$wpdb->postmeta}";
|
158 |
+
$postmeta_data = $wpdb->get_row($sql);
|
159 |
+
if( ! empty($postmeta_data) && isset($postmeta_data->min) && isset($postmeta_data->max) ) {
|
160 |
+
$instance->set_current_create_position_data(array(
|
161 |
+
'status' => 0,
|
162 |
+
'run' => false,
|
163 |
+
'start_id' => $postmeta_data->min,
|
164 |
+
'min_id' => $postmeta_data->min,
|
165 |
+
'max_id' => $postmeta_data->max
|
166 |
+
));
|
167 |
+
$instance->increment_create_position();
|
168 |
+
} else {
|
169 |
+
$instance->set_current_create_position_data(array(
|
170 |
+
'status' => 0,
|
171 |
+
'run' => false,
|
172 |
+
));
|
173 |
+
$instance->set_current_create_position($current_position+2);
|
174 |
+
}
|
175 |
+
}
|
176 |
+
function generate_post_meta($current_position = false, $instance = false) {
|
177 |
+
$run_data = $instance->get_current_create_position_data();
|
178 |
+
if( empty($run_data) || ! empty($run_data['run']) ) {
|
179 |
+
return false;
|
180 |
+
}
|
181 |
+
$run_data['run'] = true;
|
182 |
+
$instance->set_current_create_position_data($run_data);
|
183 |
+
$start_id = intval($run_data['start_id']);
|
184 |
+
$min_id = intval($run_data['min_id']);
|
185 |
+
$max_id = intval($run_data['max_id']);
|
186 |
+
$end_id = $start_id + apply_filters('berocket_insert_table_braapf_product_variation_post_meta_end', 1000);
|
187 |
+
$postmeta = get_option('berocket_aapf_custom_post_meta');
|
188 |
+
if( is_array($postmeta) && count($postmeta) > 0 ) {
|
189 |
+
global $wpdb;
|
190 |
+
$table_name = $wpdb->prefix . 'braapf_product_post_meta';
|
191 |
+
$sql_select = "SELECT postmeta.post_id as id, postmeta.meta_key AS name, postmeta.meta_value as val
|
192 |
+
FROM {$wpdb->postmeta} as postmeta
|
193 |
+
JOIN {$wpdb->posts} as posts ON posts.ID = postmeta.post_id
|
194 |
+
WHERE postmeta.meta_key IN ('".implode("','", $postmeta)."') AND posts.post_type = 'product' AND postmeta.meta_value != ''
|
195 |
+
AND postmeta.meta_id >= {$start_id} AND postmeta.meta_id < {$end_id}
|
196 |
+
GROUP BY postmeta.meta_key, postmeta.meta_value, postmeta.post_id";
|
197 |
+
$result = $wpdb->get_results($sql_select);
|
198 |
+
$product_metas = array();
|
199 |
+
foreach($result as $post_meta_val) {
|
200 |
+
$name = $this->sanitize_name($post_meta_val->name);
|
201 |
+
$val = $this->sanitize_name($post_meta_val->val);
|
202 |
+
if( ! isset($product_metas[$name]) ) {
|
203 |
+
$product_metas[$name] = array();
|
204 |
+
}
|
205 |
+
if( ! isset($product_metas[$name][$val]) ) {
|
206 |
+
$product_metas[$name][$val] = array();
|
207 |
+
}
|
208 |
+
$product_metas[$name][$val][] = $post_meta_val->id;
|
209 |
+
}
|
210 |
+
$table_name_meta = $wpdb->prefix . 'braapf_custom_post_meta';
|
211 |
+
$product_meta_insert = array();
|
212 |
+
foreach($product_metas as $name => $products_meta) {
|
213 |
+
$get_meta_id = "SELECT meta_id, slug FROM {$table_name_meta} WHERE meta = '{$name}' AND slug IN ('" . implode("','", array_keys($products_meta)) . "')";
|
214 |
+
$result = $wpdb->get_results($get_meta_id);
|
215 |
+
$post_meta_slug_id = array();
|
216 |
+
foreach($result as $post_meta_ids) {
|
217 |
+
$post_meta_slug_id[$post_meta_ids->slug] = $post_meta_ids->meta_id;
|
218 |
+
}
|
219 |
+
foreach($products_meta as $meta_val => $products_list) {
|
220 |
+
foreach($products_list as $product_id) {
|
221 |
+
if( ! empty($post_meta_slug_id[$meta_val]) ) {
|
222 |
+
$product_meta_insert[] = $wpdb->prepare("(%s, %s)", $post_meta_slug_id[$meta_val], $product_id);
|
223 |
+
}
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
if( count($product_meta_insert) > 0 ) {
|
228 |
+
$include_sql = "INSERT IGNORE INTO {$table_name} VALUES ".implode(',', $product_meta_insert).';';
|
229 |
+
$query_status = $wpdb->query($include_sql);
|
230 |
+
}
|
231 |
+
}
|
232 |
+
$status = max(0, min(100, (($end_id - $min_id) / (($max_id - $min_id) == 0 ? 1 : ($max_id - $min_id)) * 100)));
|
233 |
+
if( is_array($postmeta) && count($postmeta) > 0 && $end_id <= $max_id ) {
|
234 |
+
$instance->set_current_create_position_data(array(
|
235 |
+
'status' => $status,
|
236 |
+
'run' => false,
|
237 |
+
'start_id' => $end_id,
|
238 |
+
'min_id' => $min_id,
|
239 |
+
'max_id' => $max_id
|
240 |
+
));
|
241 |
+
} else {
|
242 |
+
update_option('berocket_cpm_update_required', true);
|
243 |
+
$instance->set_current_create_position_data(array(
|
244 |
+
'status' => 0,
|
245 |
+
'run' => false,
|
246 |
+
));
|
247 |
+
$instance->increment_create_position();
|
248 |
+
}
|
249 |
+
}
|
250 |
+
function regenerate_values_single_post_meta($post_meta) {
|
251 |
+
global $wpdb;
|
252 |
+
$table_name = $wpdb->prefix . 'braapf_custom_post_meta';
|
253 |
+
$sql_select = $wpdb->prepare("SELECT meta_value FROM {$wpdb->postmeta}
|
254 |
+
JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id
|
255 |
+
WHERE meta_key LIKE %s AND {$wpdb->posts}.post_type = 'product' AND meta_value != ''
|
256 |
+
GROUP BY meta_value", $post_meta);
|
257 |
+
$result = $wpdb->get_results($sql_select);
|
258 |
+
$terms = array();
|
259 |
+
$exist_terms = array();
|
260 |
+
$meta = $post_meta;
|
261 |
+
$meta = $this->sanitize_name($meta);
|
262 |
+
foreach($result as $meta_single) {
|
263 |
+
$name = $meta_single->meta_value;
|
264 |
+
$slug = $this->sanitize_name($name);
|
265 |
+
$terms[] = $wpdb->prepare("(%s,%s,%s)", $meta, $slug, $name);
|
266 |
+
$exist_terms[] = $slug;
|
267 |
+
}
|
268 |
+
$sql_remove = $wpdb->prepare("DELETE FROM {$table_name} WHERE meta LIKE %s AND slug NOT IN('". implode("','", $exist_terms) . "');", $meta);
|
269 |
+
$wpdb->query($sql_remove);
|
270 |
+
$insert_sql = "INSERT IGNORE INTO {$table_name}(meta, slug, name) VALUES ". implode(',', $terms) . ';';
|
271 |
+
$wpdb->query($insert_sql);
|
272 |
+
}
|
273 |
+
function sanitize_name($name) {
|
274 |
+
$name = sanitize_title($name);
|
275 |
+
$name = mb_substr($name, 0, 100);
|
276 |
+
return $name;
|
277 |
+
}
|
278 |
+
function get_charset_collate() {
|
279 |
+
global $wpdb;
|
280 |
+
$result = $wpdb->get_row("SHOW TABLE STATUS where name like '{$wpdb->posts}'");
|
281 |
+
if( ! empty($result) && ! empty($result->Collation) ) {
|
282 |
+
$collate = 'DEFAULT CHARACTER SET ' . $wpdb->charset . ' COLLATE ' . $result->Collation;
|
283 |
+
} else {
|
284 |
+
$collate = $wpdb->get_charset_collate();
|
285 |
+
}
|
286 |
+
return $collate;
|
287 |
+
}
|
288 |
+
function save_filter($meta_id, $object_id, $meta_key, $meta_value) {
|
289 |
+
$postmeta = get_option('berocket_aapf_custom_post_meta');
|
290 |
+
if( $meta_key == 'br_product_filter' && ! empty($meta_value) && ! empty($meta_value['filter_type']) && $meta_value['filter_type'] == 'custom_postmeta' && ! empty($meta_value['custom_postmeta']) ) {
|
291 |
+
if( ! in_array($meta_value['custom_postmeta'], $postmeta) ) {
|
292 |
+
$postmeta[] = $meta_value['custom_postmeta'];
|
293 |
+
$postmeta = array_unique($postmeta);
|
294 |
+
update_option('berocket_aapf_custom_post_meta', $postmeta);
|
295 |
+
$this->required_update = true;
|
296 |
+
$this->is_required_update();
|
297 |
+
}
|
298 |
+
}
|
299 |
+
if( in_array($meta_key, $postmeta) ) {
|
300 |
+
if( get_post_type($object_id) == 'product' ) {
|
301 |
+
$this->update_post_meta_product($meta_key, $object_id);
|
302 |
+
update_option('berocket_cpm_update_required', true);
|
303 |
+
}
|
304 |
+
}
|
305 |
+
}
|
306 |
+
function update_post_meta_product($meta_key, $product_id) {
|
307 |
+
global $wpdb;
|
308 |
+
$sanitize_meta_key = $this->sanitize_name($meta_key);
|
309 |
+
$sql_select = "SELECT postmeta.meta_value as val
|
310 |
+
FROM {$wpdb->postmeta} as postmeta
|
311 |
+
WHERE postmeta.meta_key = '{$meta_key}' AND postmeta.post_id = '{$product_id}' AND postmeta.meta_value != ''
|
312 |
+
GROUP BY postmeta.meta_key, postmeta.meta_value, postmeta.post_id";
|
313 |
+
$result = $wpdb->get_col($sql_select);
|
314 |
+
$values = array();
|
315 |
+
if( is_array($result) && count($result) > 0 ) {
|
316 |
+
foreach($result as &$result_val) {
|
317 |
+
$values[$this->sanitize_name($result_val)] = $result_val;
|
318 |
+
}
|
319 |
+
$table_name_meta = $wpdb->prefix . 'braapf_custom_post_meta';
|
320 |
+
$get_meta_id = "SELECT meta_id, slug FROM {$table_name_meta} WHERE meta = '{$sanitize_meta_key}' AND slug IN ('" . implode("','", array_keys($values)) . "')";
|
321 |
+
$meta_result = $wpdb->get_results($get_meta_id);
|
322 |
+
|
323 |
+
$not_exist_meta = $values;
|
324 |
+
if( is_array($result) && count($result) > 0 ) {
|
325 |
+
foreach($meta_result as $meta_value) {
|
326 |
+
if( isset($not_exist_meta[$meta_value->slug]) ) {
|
327 |
+
unset($not_exist_meta[$meta_value->slug]);
|
328 |
+
}
|
329 |
+
}
|
330 |
+
}
|
331 |
+
if( count($not_exist_meta) > 0 ) {
|
332 |
+
$terms = array();
|
333 |
+
foreach($not_exist_meta as $meta_slug => $meta_name) {
|
334 |
+
$terms[] = $wpdb->prepare('(%s, %s, %s)', $sanitize_meta_key, $meta_slug, $meta_name);
|
335 |
+
}
|
336 |
+
$insert_sql = "INSERT IGNORE INTO {$table_name_meta}(meta, slug, name) VALUES ". implode(',', $terms) . ';';
|
337 |
+
$wpdb->query($insert_sql);
|
338 |
+
$meta_result = $wpdb->get_results($get_meta_id);
|
339 |
+
}
|
340 |
+
$product_meta_insert = array();
|
341 |
+
if( is_array($meta_result) && count($meta_result) > 0 ) {
|
342 |
+
foreach($meta_result as $meta_val) {
|
343 |
+
$product_meta_insert[] = $wpdb->prepare('(%s, %s)', $meta_val->meta_id, $product_id);
|
344 |
+
}
|
345 |
+
}
|
346 |
+
$table_name = $wpdb->prefix . 'braapf_product_post_meta';
|
347 |
+
$remove_sql = "DELETE FROM {$table_name} WHERE product_id = {$product_id} and meta_id IN (SELECT meta_id FROM {$table_name_meta} WHERE meta = '{$sanitize_meta_key}')";
|
348 |
+
$wpdb->query($remove_sql);
|
349 |
+
if( count($product_meta_insert) > 0 ) {
|
350 |
+
$include_sql = "INSERT IGNORE INTO {$table_name} VALUES ".implode(',', $product_meta_insert).';';
|
351 |
+
$query_status = $wpdb->query($include_sql);
|
352 |
+
}
|
353 |
+
}
|
354 |
+
}
|
355 |
+
function is_required_update() {
|
356 |
+
if( $this->required_update && ! empty($this->additional_table_class) ) {
|
357 |
+
$this->additional_table_class->set_current_create_position_data(array(
|
358 |
+
'status' => 0,
|
359 |
+
'run' => false,
|
360 |
+
));
|
361 |
+
$this->additional_table_class->set_current_create_position($this->position_update);
|
362 |
+
}
|
363 |
+
}
|
364 |
+
function postmeta_main_query($query) {
|
365 |
+
if( ! is_admin() ) {
|
366 |
+
global $wpdb;
|
367 |
+
$table_name_meta = $wpdb->prefix . 'braapf_custom_post_meta';
|
368 |
+
$query = "SELECT meta_id, slug as meta_slug, name as meta_value, count FROM {$table_name_meta}
|
369 |
+
WHERE meta LIKE %s ORDER BY meta_id";
|
370 |
+
}
|
371 |
+
return $query;
|
372 |
+
}
|
373 |
+
function recount_postmeta_query($query, $taxonomy_data, $postmeta) {
|
374 |
+
if( ! is_admin() ) {
|
375 |
+
global $wpdb;
|
376 |
+
$table_name_meta = $wpdb->prefix . 'braapf_custom_post_meta';
|
377 |
+
$table_name = $wpdb->prefix . 'braapf_product_post_meta';
|
378 |
+
$query['select']['elements'] = array(
|
379 |
+
'meta_id' => 'brpm_meta.meta_id as meta_id',
|
380 |
+
'meta_value' => 'brpm_meta.slug as meta_value',
|
381 |
+
'meta_name' => 'brpm_meta.name as meta_name',
|
382 |
+
'count' => "count(DISTINCT {$wpdb->posts}.ID) as count"
|
383 |
+
);
|
384 |
+
$query['join']['brpm_recount'] = "RIGHT JOIN {$table_name} as brpm_recount ON {$wpdb->posts}.ID = brpm_recount.product_id";
|
385 |
+
$query['join']['brpm_meta'] = "JOIN {$table_name_meta} as brpm_meta ON brpm_recount.meta_id = brpm_meta.meta_id";
|
386 |
+
$query['group'] = 'GROUP BY brpm_recount.meta_id';
|
387 |
+
$query['where']['brpm_recount'] = $wpdb->prepare('AND brpm_meta.meta = %s', $postmeta);
|
388 |
+
$query['order'] = " ORDER BY meta_id";
|
389 |
+
}
|
390 |
+
return $query;
|
391 |
+
}
|
392 |
+
function is_single_filter_and($filter) {
|
393 |
+
return ! empty($filter['val_ids']) && is_array($filter['val_ids']) && count($filter['val_ids']) > 1
|
394 |
+
&& ! empty($filter['val_arr']['op']) && $filter['val_arr']['op'] == 'AND';
|
395 |
+
}
|
396 |
+
function posts_in($result, $instance, $filter, $data) {
|
397 |
+
if( $result === NULL && ! empty($filter['type']) && $filter['type'] == 'custom_postmeta'
|
398 |
+
&& $this->is_single_filter_and($filter) ) {
|
399 |
+
global $wpdb;
|
400 |
+
$val_ids = $filter['val_ids'];
|
401 |
+
$table_name = $wpdb->prefix . 'braapf_product_post_meta';
|
402 |
+
$select_posts = "SELECT product_id, count(product_id) as count FROM {$table_name}
|
403 |
+
WHERE meta_id IN ('" . implode("','", $val_ids) . "')
|
404 |
+
GROUP By product_id
|
405 |
+
HAVING count = " . count($val_ids);
|
406 |
+
$post_ids = $wpdb->get_col($select_posts);
|
407 |
+
if( empty($post_ids) ) {
|
408 |
+
$post_ids = array('0');
|
409 |
+
}
|
410 |
+
$result = $filter;
|
411 |
+
$result['posts_in'] = $post_ids;
|
412 |
+
}
|
413 |
+
return $result;
|
414 |
+
}
|
415 |
+
function custom_query_each($result, $instance, $filter, $data) {
|
416 |
+
if( $result === NULL && ! empty($filter['type']) && $filter['type'] == 'custom_postmeta'
|
417 |
+
&& ! $this->is_single_filter_and($filter) ) {
|
418 |
+
$result = $filter;
|
419 |
+
$result['custom_query'] = array($this, 'post_clauses');
|
420 |
+
$result['custom_query_line'] = 'sale:'.$filter['val'];
|
421 |
+
}
|
422 |
+
return $result;
|
423 |
+
}
|
424 |
+
function post_clauses($args, $filter) {
|
425 |
+
global $wpdb;
|
426 |
+
$table_name_custom = 'brpm_filter_' . $this->post_clauses_number;
|
427 |
+
$this->post_clauses_number = $this->post_clauses_number + 1;
|
428 |
+
$table_name = $wpdb->prefix . 'braapf_product_post_meta';
|
429 |
+
$taxonomy = substr($filter['taxonomy'],4);
|
430 |
+
$val_ids = $filter['val_ids'];
|
431 |
+
$args['join'] .= " JOIN {$table_name} as {$table_name_custom} ON {$wpdb->posts}.ID = {$table_name_custom}.product_id ";
|
432 |
+
$args['where'] .= " AND {$table_name_custom}.meta_id IN ('" . implode("','", $val_ids) . "')";
|
433 |
+
return $args;
|
434 |
+
}
|
435 |
+
function admin_footer() {
|
436 |
+
$update = get_option('berocket_cpm_update_required');
|
437 |
+
if( ! empty($update) ) {
|
438 |
+
global $wpdb;
|
439 |
+
$table_name_meta = $wpdb->prefix . 'braapf_custom_post_meta';
|
440 |
+
$table_name = $wpdb->prefix . 'braapf_product_post_meta';
|
441 |
+
$query = "UPDATE {$table_name_meta} as setable
|
442 |
+
LEFT JOIN (
|
443 |
+
SELECT meta_id, count(product_id) as count
|
444 |
+
FROM {$table_name}
|
445 |
+
GROUP BY meta_id
|
446 |
+
) as getable ON setable.meta_id= getable.meta_id
|
447 |
+
SET setable.count = getable.count";
|
448 |
+
$wpdb->query($query);
|
449 |
+
delete_option('berocket_cpm_update_required');
|
450 |
+
}
|
451 |
+
}
|
452 |
+
}
|
453 |
+
}
|
addons/custom_postmeta/custom_postmeta.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class BeRocket_aapf_add_custom_postmeta extends BeRocket_framework_addon_lib {
|
3 |
+
public $addon_file = __FILE__;
|
4 |
+
public $plugin_name = 'ajax_filters';
|
5 |
+
public $php_file_name = 'postmeta';
|
6 |
+
function __construct() {
|
7 |
+
parent::__construct();
|
8 |
+
$active_addons = apply_filters('berocket_addons_active_'.$this->plugin_name, array());
|
9 |
+
$tables_active = false;
|
10 |
+
if( in_array($this->addon_file, $active_addons) ) {
|
11 |
+
foreach($active_addons as $active_addon) {
|
12 |
+
if( strpos($active_addon, 'additional_tables') !== FALSE ) {
|
13 |
+
$tables_active = true;
|
14 |
+
include_once('additional_tables.php');
|
15 |
+
new BeRocket_aapf_variations_tables_postmeta_addon();
|
16 |
+
}
|
17 |
+
}
|
18 |
+
}
|
19 |
+
if( $tables_active ) {
|
20 |
+
include_once('additional_tables.php');
|
21 |
+
new BeRocket_aapf_variations_tables_postmeta_addon();
|
22 |
+
} elseif( is_admin() ) {
|
23 |
+
$this->deactivate();
|
24 |
+
}
|
25 |
+
}
|
26 |
+
function get_addon_data() {
|
27 |
+
$data = parent::get_addon_data();
|
28 |
+
return array_merge($data, array(
|
29 |
+
'addon_name' => __('Custom Post Meta Filtering (BETA)', 'BeRocket_AJAX_domain'),
|
30 |
+
'tooltip' => __('Option to filter products by custom post meta fields. Can slow down filtering.', 'BeRocket_AJAX_domain')
|
31 |
+
));
|
32 |
+
}
|
33 |
+
function deactivate() {
|
34 |
+
$current_position = get_option('BeRocket_aapf_additional_tables_addon_position');
|
35 |
+
if( ! empty($current_position) && strpos($current_position, 'cpm') !== FALSE ) {
|
36 |
+
$current_position = str_replace(' cpm ', '', $current_position);
|
37 |
+
update_option('BeRocket_aapf_additional_tables_addon_position', $current_position);
|
38 |
+
}
|
39 |
+
global $wpdb;
|
40 |
+
$tables_drop = array(
|
41 |
+
'braapf_custom_post_meta',
|
42 |
+
'braapf_product_post_meta'
|
43 |
+
);
|
44 |
+
foreach($tables_drop as $table_drop) {
|
45 |
+
$table_name = $wpdb->prefix . $table_drop;
|
46 |
+
$sql = "DROP TABLE IF EXISTS {$table_name};";
|
47 |
+
$wpdb->query($sql);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
}
|
51 |
+
new BeRocket_aapf_add_custom_postmeta();
|
addons/custom_postmeta/postmeta.php
ADDED
@@ -0,0 +1,451 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class BeRocket_aapf_add_postmeta_filters {
|
3 |
+
function __construct() {
|
4 |
+
add_filter('berocket_filter_filter_type_array', array($this, 'filter_type'), 10000, 1);
|
5 |
+
add_action('braapf_single_filter_filter_type', array($this, 'filter_type_additional'), 10000, 2);
|
6 |
+
add_filter('berocket_aapf_get_terms_args', array($this, 'get_terms_args'), 10000, 3);
|
7 |
+
add_filter('berocket_aapf_get_terms_filter_before', array($this, 'get_terms'), 10000, 3);
|
8 |
+
add_filter('bapf_uparse_func_check_attribute_name', array($this, 'check_attribute_name'), 10000, 3);
|
9 |
+
add_filter('bapf_uparse_get_terms', array($this, 'uparse_get_terms'), 10000, 3);
|
10 |
+
add_filter('bapf_uparse_generate_meta_query_each', array($this, 'generate_meta_query'), 10000, 4);
|
11 |
+
add_filter('braapf_generate_taxonomy_name_for_select', array($this, 'taxonomy_name_for_select'), 10000, 2);
|
12 |
+
add_filter('braapf_get_data_taxonomy_from_post_before', array($this, 'taxonomy_from_post_before'), 10000, 2);
|
13 |
+
add_filter('bapf_uparse_paid_attr_slider_apply', array($this, 'attr_slider_apply'), 10000, 6);
|
14 |
+
add_filter('bapf_uparse_paid_attr_slider_taxonomy', array($this, 'attr_slider_taxonomy'), 10000, 2);
|
15 |
+
add_filter('bapf_uparse_add_terms_to_data_each_terms', array($this, 'uparse_terms'), 100, 4);
|
16 |
+
add_filter('bapf_uparse_func_check_attribute_values_terms', array($this, 'ids_slug'), 100, 6);
|
17 |
+
//Color save
|
18 |
+
add_filter('berocket_filter_br_widget_color_types', array($this, 'widget_color_types'));
|
19 |
+
add_filter('bapf_widget_func_color_listener_save', array($this, 'color_listener_save'), 10, 4);
|
20 |
+
add_filter('berocket_filter_br_widget_color_name', array($this, 'color_listener_attribute'), 10, 4);
|
21 |
+
add_filter('berocket_aapf_color_term_select_metadata', array($this, 'select_metadata'), 10, 3);
|
22 |
+
}
|
23 |
+
function filter_type($filter_type) {
|
24 |
+
$filter_type = berocket_insert_to_array(
|
25 |
+
$filter_type,
|
26 |
+
'custom_taxonomy',
|
27 |
+
array(
|
28 |
+
'custom_postmeta' => array(
|
29 |
+
'name' => __('Custom Post Meta', 'BeRocket_AJAX_domain'),
|
30 |
+
'sameas' => 'custom_postmeta',
|
31 |
+
'optionsameas' => 'custom_taxonomy',
|
32 |
+
'templates' => array('checkbox', 'slider', 'new_slider', 'select', 'datepicker'),
|
33 |
+
'specific' => array('', 'color', 'image')
|
34 |
+
),
|
35 |
+
)
|
36 |
+
);
|
37 |
+
return $filter_type;
|
38 |
+
}
|
39 |
+
function filter_type_additional($settings_name, $braapf_filter_settings) {
|
40 |
+
$custom_postmeta_list = $this->get_custom_postmeta();
|
41 |
+
$custom_postmeta = br_get_value_from_array($braapf_filter_settings, 'custom_postmeta', '');
|
42 |
+
echo '<div class="braapf_custom_postmeta braapf_half_select_full">';
|
43 |
+
echo '<label for="braapf_custom_postmeta">' . __('Custom Post Meta', 'BeRocket_AJAX_domain') . '</label>';
|
44 |
+
echo '<select id="braapf_custom_postmeta" name="'.$settings_name.'[custom_postmeta]">';
|
45 |
+
foreach( $custom_postmeta_list as $opt => $postmeta_list ) {
|
46 |
+
echo '<optgroup label="'.$this->get_opt_name($opt).'">';
|
47 |
+
foreach ( $postmeta_list as $value => $data ) {
|
48 |
+
echo '<option';
|
49 |
+
foreach($data as $data_key => $data_val) {
|
50 |
+
if( $data_val !== "" ) {
|
51 |
+
echo ' data-'.$data_key.'="'.$data_val.'"';
|
52 |
+
}
|
53 |
+
}
|
54 |
+
echo ( $custom_postmeta == $value ? ' selected' : '' ) . ' value="' . $value . '">' . $data['name'] . '</option>';
|
55 |
+
}
|
56 |
+
echo '</optgroup>';
|
57 |
+
}
|
58 |
+
echo '</select>';
|
59 |
+
echo '</div>';
|
60 |
+
?>
|
61 |
+
<script>
|
62 |
+
berocket_show_element('.braapf_custom_postmeta', '{#braapf_filter_type} == "custom_postmeta"');
|
63 |
+
jQuery(document).on('braapf_get_current_taxonomy_name', function() {
|
64 |
+
berocket_show_element_hooked_data.push('#braapf_custom_postmeta');
|
65 |
+
});
|
66 |
+
</script>
|
67 |
+
<?php
|
68 |
+
}
|
69 |
+
function get_custom_postmeta() {
|
70 |
+
global $wpdb;
|
71 |
+
$data = array();
|
72 |
+
$acf = array();
|
73 |
+
$remove_meta = array();
|
74 |
+
if( function_exists('acf_get_field_groups') ) {
|
75 |
+
$field_groups = acf_get_field_groups( array(
|
76 |
+
'post_type' => 'product',
|
77 |
+
) );
|
78 |
+
if ( is_array( $field_groups ) ) {
|
79 |
+
foreach ( $field_groups as $group ) {
|
80 |
+
$fields = acf_get_fields($group);
|
81 |
+
if( is_array($fields) ) {
|
82 |
+
foreach($fields as $field) {
|
83 |
+
$acf[$field['name']] = array(
|
84 |
+
'name' => $field['label'],
|
85 |
+
'hierarchical' => 0
|
86 |
+
);
|
87 |
+
$remove_meta[] = $field['name'];
|
88 |
+
$remove_meta[] = '_'.$field['name'];
|
89 |
+
}
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
if( count($acf) > 0 ) {
|
95 |
+
$data['acf'] = $acf;
|
96 |
+
}
|
97 |
+
$postmetas = $wpdb->get_col( "SELECT {$wpdb->postmeta}.meta_key
|
98 |
+
FROM {$wpdb->postmeta}
|
99 |
+
JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id
|
100 |
+
WHERE {$wpdb->posts}.post_type = 'product'
|
101 |
+
GROUP BY {$wpdb->postmeta}.meta_key");
|
102 |
+
if( is_array($postmetas) && count($postmetas) > 0 && count($remove_meta) > 0 ) {
|
103 |
+
$postmetas = array_diff($postmetas, $remove_meta);
|
104 |
+
}
|
105 |
+
if( is_array($postmetas) && count($postmetas) > 0 ) {
|
106 |
+
$data['postmeta'] = array();
|
107 |
+
foreach($postmetas as $postmeta) {
|
108 |
+
$data['postmeta'][$postmeta] = array(
|
109 |
+
'name' => $postmeta,
|
110 |
+
'hierarchical' => 0
|
111 |
+
);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
return $data;
|
115 |
+
}
|
116 |
+
function get_opt_name($opt) {
|
117 |
+
$opt_names = array(
|
118 |
+
'acf' => __('Advanced Custom Fields', 'BeRocket_AJAX_domain'),
|
119 |
+
'postmeta' => __('Post Meta', 'BeRocket_AJAX_domain'),
|
120 |
+
);
|
121 |
+
if(isset($opt_names[$opt])) {
|
122 |
+
return $opt_names[$opt];
|
123 |
+
} else {
|
124 |
+
return $opt;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
function get_terms_args($get_terms_args, $instance, $args) {
|
128 |
+
if( $instance['filter_type'] == 'custom_postmeta' ) {
|
129 |
+
$get_terms_args['custom_postmeta'] = true;
|
130 |
+
$get_terms_args['taxonomy'] = $instance['custom_postmeta'];
|
131 |
+
}
|
132 |
+
return $get_terms_args;
|
133 |
+
}
|
134 |
+
function get_terms($terms, $args, $additional) {
|
135 |
+
if( ! empty($args['custom_postmeta']) ) {
|
136 |
+
if( ! empty($additional) && ! empty($additional['disable_recount']) ) {
|
137 |
+
$terms = $this->get_postmeta($args['taxonomy']);
|
138 |
+
} else {
|
139 |
+
$terms = $this->get_postmeta_recount($args['taxonomy'], $args, $additional);
|
140 |
+
}
|
141 |
+
$terms = $this->modify_get_terms($terms, $args);
|
142 |
+
}
|
143 |
+
return $terms;
|
144 |
+
}
|
145 |
+
function build_terms_list($post_metas, $name, $exclude_same = true) {
|
146 |
+
$BeRocket_AAPF = BeRocket_AAPF::getInstance();
|
147 |
+
$options = $BeRocket_AAPF->get_option();
|
148 |
+
$post_meta_terms = array();
|
149 |
+
$slugs = array();
|
150 |
+
if( is_array($post_metas) ) {
|
151 |
+
foreach($post_metas as $post_meta) {
|
152 |
+
$meta_name = ( property_exists($post_meta, 'meta_name') ? $post_meta->meta_name : $this->style_name($post_meta->meta_value) );
|
153 |
+
$meta_slug = $this->style_slug($post_meta->meta_value);
|
154 |
+
$meta_id = ( property_exists($post_meta, 'meta_id') ? intval($post_meta->meta_id) : $meta_slug );
|
155 |
+
if( ! in_array($meta_slug, $slugs) || ! $exclude_same ) {
|
156 |
+
$slugs[] = $meta_slug;
|
157 |
+
$meta_count = intval($post_meta->count);
|
158 |
+
array_push( $post_meta_terms, (object) array(
|
159 |
+
'term_id' => $meta_id,
|
160 |
+
'term_taxonomy_id' => $meta_id,
|
161 |
+
'name' => $meta_name,
|
162 |
+
'slug' => $meta_slug,
|
163 |
+
'value' => ( empty($options['slug_urls']) ? $meta_id : $meta_slug ),
|
164 |
+
'taxonomy' => 'cpm_'.$name,
|
165 |
+
'count' => $meta_count,
|
166 |
+
'meta_value' => $post_meta->meta_value,
|
167 |
+
'custom_postmeta' => true,
|
168 |
+
'depth' => 0
|
169 |
+
) );
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
return $post_meta_terms;
|
174 |
+
}
|
175 |
+
function get_postmeta_recount($name, $args, $additional) {
|
176 |
+
$post_metas = $this->query_recount($name, $args, $additional);
|
177 |
+
return $this->build_terms_list($post_metas, $name);
|
178 |
+
}
|
179 |
+
function get_postmeta($name, $exclude_same = true) {
|
180 |
+
global $wpdb;
|
181 |
+
$query = $this->get_main_query();
|
182 |
+
$query = $wpdb->prepare($query, $name);
|
183 |
+
$post_metas = $wpdb->get_results($query);
|
184 |
+
return $this->build_terms_list($post_metas, $name, $exclude_same);
|
185 |
+
}
|
186 |
+
function get_main_query() {
|
187 |
+
global $wpdb;
|
188 |
+
return apply_filters('berocket_aapf_postmeta_main_query', "SELECT meta_value, count(meta_value) as count FROM {$wpdb->postmeta}
|
189 |
+
JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id
|
190 |
+
WHERE meta_key LIKE %s AND {$wpdb->posts}.post_type = 'product'
|
191 |
+
GROUP BY meta_value ORDER BY meta_value");
|
192 |
+
}
|
193 |
+
function query_recount($postmeta, $args = array(), $additional = array()) {
|
194 |
+
global $wpdb;
|
195 |
+
$options = BeRocket_AAPF::get_aapf_option();
|
196 |
+
$use_filters = braapf_filters_must_be_recounted();
|
197 |
+
//NEED TO CHECK
|
198 |
+
$taxonomy_data = BeRocket_AAPF_faster_attribute_recount::get_query_for_calculate(array(
|
199 |
+
'use_filters' => $use_filters,
|
200 |
+
'taxonomy_remove' => (empty($additional['operator']) || strtoupper($additional['operator']) == 'OR' ? 'cpm_'.$postmeta : FALSE),
|
201 |
+
'add_tax_query' => ( empty($additional['additional_tax_query']) ? array() : $additional['additional_tax_query'] ),
|
202 |
+
'taxonomy_data' => $additional
|
203 |
+
));
|
204 |
+
$query = $taxonomy_data['query'];
|
205 |
+
$query['select']['elements'] = array(
|
206 |
+
'meta_value' => "brpm_recount.meta_value",
|
207 |
+
'meta_count' => "count(DISTINCT {$wpdb->posts}.ID) as count"
|
208 |
+
);
|
209 |
+
$query['join']['brpm_recount'] = "RIGHT JOIN {$wpdb->postmeta} as brpm_recount ON {$wpdb->posts}.ID = brpm_recount.post_id";
|
210 |
+
$query['group'] = 'GROUP BY brpm_recount.meta_value';
|
211 |
+
$query['where']['brpm_recount'] = $wpdb->prepare('AND brpm_recount.meta_key = %s AND brpm_recount.meta_value != ""', $postmeta);
|
212 |
+
$query['order'] = " ORDER BY meta_value";
|
213 |
+
$query = apply_filters('berocket_aapf_recount_postmeta_query', $query, $taxonomy_data, $postmeta);
|
214 |
+
$query['select']['elements']= implode(', ', $query['select']['elements']);
|
215 |
+
$query['select'] = implode(' ', $query['select']);
|
216 |
+
$query['join'] = implode(' ', $query['join']);
|
217 |
+
$query['where'] = implode(' ', $query['where']);
|
218 |
+
$query['join'] .= " LEFT JOIN {$wpdb->wc_product_meta_lookup} as wc_product_meta_lookup ON {$wpdb->posts}.ID = wc_product_meta_lookup.product_id ";
|
219 |
+
$query = apply_filters('woocommerce_get_filtered_term_product_counts_query', $query);
|
220 |
+
if( $use_filters ) {
|
221 |
+
$query = apply_filters( 'berocket_posts_clauses_recount', $query );
|
222 |
+
}
|
223 |
+
$query_imploded = implode( ' ', $query );
|
224 |
+
$use_price_cache = apply_filters('berocket_recount_price_cache_use', false);
|
225 |
+
if($use_price_cache) {
|
226 |
+
$result = br_get_cache(apply_filters('berocket_recount_cache_key', md5(json_encode($query_imploded)), $taxonomy_data), 'berocket_recount');
|
227 |
+
}
|
228 |
+
if( empty($result) ) {
|
229 |
+
$result = $wpdb->get_results( $query_imploded );
|
230 |
+
if($use_price_cache) {
|
231 |
+
br_set_cache(md5(json_encode($query_imploded)), $result, 'berocket_recount', DAY_IN_SECONDS);
|
232 |
+
}
|
233 |
+
}
|
234 |
+
BeRocket_AAPF_faster_attribute_recount::restore_url_data_after_recount();
|
235 |
+
if( empty($result) || count($result) == 0 ) {
|
236 |
+
return FALSE;
|
237 |
+
} else {
|
238 |
+
return (array)$result;
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
function modify_get_terms($terms, $args) {
|
243 |
+
if(! empty($args['include']) || ! empty($args['exclude']) ) {
|
244 |
+
if( ! empty($args['include']) && ! is_array($args['include']) ) {
|
245 |
+
if( is_string($args['include']) ) {
|
246 |
+
$args['include'] = explode(',', $args['include']);
|
247 |
+
} else {
|
248 |
+
$args['include'] = array();
|
249 |
+
}
|
250 |
+
}
|
251 |
+
if( ! empty($args['exclude']) && ! is_array($args['exclude']) ) {
|
252 |
+
if( is_string($args['exclude']) ) {
|
253 |
+
$args['exclude'] = explode(',', $args['exclude']);
|
254 |
+
} else {
|
255 |
+
$args['exclude'] = array();
|
256 |
+
}
|
257 |
+
}
|
258 |
+
$new_terms = array();
|
259 |
+
foreach($terms as $term) {
|
260 |
+
if(
|
261 |
+
( empty($args['include']) || in_array($term->term_id, $args['include']) )
|
262 |
+
&& ( empty($args['exclude']) || ! in_array($term->term_id, $args['exclude']) )
|
263 |
+
) {
|
264 |
+
$new_terms[] = $term;
|
265 |
+
}
|
266 |
+
}
|
267 |
+
$terms = $new_terms;
|
268 |
+
}
|
269 |
+
if( ! empty($args['orderby']) ) {
|
270 |
+
$order_term = array();
|
271 |
+
foreach($terms as $term) {
|
272 |
+
$order_term[] = $term->name;
|
273 |
+
}
|
274 |
+
$sort = ( $args['orderby'] == 'name' ? SORT_STRING : SORT_NUMERIC );
|
275 |
+
array_multisort($order_term, $terms, $sort);
|
276 |
+
}
|
277 |
+
if( ! empty($args['order']) && $args['order'] == 'DESC' ) {
|
278 |
+
$terms = array_reverse($terms);
|
279 |
+
}
|
280 |
+
return $terms;
|
281 |
+
}
|
282 |
+
function uparse_get_terms($terms, $instance, $args) {
|
283 |
+
if( ! empty($args['taxonomy']) && substr($args['taxonomy'], 0, 4) == 'cpm_' ) {
|
284 |
+
$terms = $this->get_postmeta(substr($args['taxonomy'],4));
|
285 |
+
}
|
286 |
+
return $terms;
|
287 |
+
}
|
288 |
+
function style_name($text) {
|
289 |
+
$text = str_replace(array('_'), array(' '), $text);
|
290 |
+
$text = trim($text);
|
291 |
+
$text = ucfirst($text);
|
292 |
+
return $text;
|
293 |
+
}
|
294 |
+
function style_slug($text) {
|
295 |
+
$text = sanitize_title($text);
|
296 |
+
return $text;
|
297 |
+
}
|
298 |
+
function convert_to_postval($taxonomy, $slug) {
|
299 |
+
$post_metas = $this->get_postmeta($taxonomy, false);
|
300 |
+
$lines = array();
|
301 |
+
foreach($post_metas as $post_meta) {
|
302 |
+
if( $post_meta->value == $slug ) {
|
303 |
+
$lines[] = $post_meta->meta_value;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
return $lines;
|
307 |
+
}
|
308 |
+
function check_attribute_name($result, $instance, $attribute_name) {
|
309 |
+
if( ! empty($attribute_name) && substr($attribute_name, 0, 4) == 'cpm_' ) {
|
310 |
+
$result = array(
|
311 |
+
'taxonomy' => $attribute_name,
|
312 |
+
'type' => 'custom_postmeta'
|
313 |
+
);
|
314 |
+
}
|
315 |
+
return $result;
|
316 |
+
}
|
317 |
+
function generate_meta_query($result, $instance, $filter, $data) {
|
318 |
+
if( apply_filters('bapf_uparse_generate_meta_query_postmeta_meta_query_use', ($result === NULL && ! empty($filter['type']) && $filter['type'] == 'custom_postmeta'), $result, $instance, $filter, $data) ) {
|
319 |
+
$taxonomy = substr($filter['taxonomy'],4);
|
320 |
+
$lines = array();
|
321 |
+
foreach($filter['val_ids'] as $val_id => $val) {
|
322 |
+
$lines = array_merge($lines, $this->convert_to_postval($taxonomy, $val_id));
|
323 |
+
}
|
324 |
+
if( ! empty($lines) ) {
|
325 |
+
$operator = ( (! empty($filter['val_arr']['op']) && $filter['val_arr']['op'] == 'AND') ? 'AND' : 'OR' );
|
326 |
+
$meta_query = array('relation' => $operator);
|
327 |
+
foreach($lines as $line) {
|
328 |
+
$meta_query[] = array(
|
329 |
+
'key' => $taxonomy,
|
330 |
+
'value' => $line
|
331 |
+
);
|
332 |
+
}
|
333 |
+
$result = $filter;
|
334 |
+
$result['meta_query'] = $meta_query;
|
335 |
+
}
|
336 |
+
}
|
337 |
+
return $result;
|
338 |
+
}
|
339 |
+
function taxonomy_name_for_select($args, $br_product_filter) {
|
340 |
+
if( ! empty($br_product_filter) && ! empty($br_product_filter['filter_type']) && $br_product_filter['filter_type'] == 'custom_postmeta' && ! empty($br_product_filter['custom_postmeta']) ) {
|
341 |
+
$args['taxonomy'] = sanitize_text_field($br_product_filter['custom_postmeta']);
|
342 |
+
$args['custom_postmeta'] = true;
|
343 |
+
}
|
344 |
+
return $args;
|
345 |
+
}
|
346 |
+
function taxonomy_from_post_before($result, $post_data) {
|
347 |
+
if( $post_data['filter_type'] == 'custom_postmeta' ) {
|
348 |
+
$result = 'cpm_'.sanitize_text_field($post_data['custom_postmeta']);
|
349 |
+
}
|
350 |
+
return $result;
|
351 |
+
}
|
352 |
+
function attr_slider_apply($is_slider, $result, $instance, $values_line, $taxonomy, $filter) {
|
353 |
+
return $is_slider || ( $result['operator'] == 'SLIDER' && in_array($filter['type'], array('custom_postmeta')) );
|
354 |
+
}
|
355 |
+
function attr_slider_taxonomy($taxonomy, $filter) {
|
356 |
+
if( $filter['type'] == 'custom_postmeta' ) {
|
357 |
+
$taxonomy = substr($taxonomy, 4);
|
358 |
+
}
|
359 |
+
return $taxonomy;
|
360 |
+
}
|
361 |
+
function widget_color_types($types) {
|
362 |
+
$types[] = 'custom_postmeta';
|
363 |
+
return $types;
|
364 |
+
}
|
365 |
+
function color_listener_save($prevent_save, $br_product_filter, $type, $color_values) {
|
366 |
+
if( ! empty($br_product_filter) && ! empty($br_product_filter['filter_type']) && $br_product_filter['filter_type'] == 'custom_postmeta' ) {
|
367 |
+
global $wpdb;
|
368 |
+
$this->create_data_table();
|
369 |
+
$postname = sanitize_text_field($_POST['tax_color_name']);
|
370 |
+
foreach( $color_values as $key => $value ) {
|
371 |
+
if( $type == 'color' ) {
|
372 |
+
foreach($value as $term_key => $term_val) {
|
373 |
+
if( !empty($term_val) ) {
|
374 |
+
$sql = $wpdb->prepare("INSERT IGNORE INTO {$wpdb->prefix}berocket_postmeta_data (postmeta, metaval, name, value) VALUES(%s, %s, %s, %s) ON DUPLICATE KEY UPDATE value=%s", $postname, $term_key, $key, $term_val, $term_val);
|
375 |
+
"INSERT IGNORE INTO {$wpdb->prefix}berocket_postmeta_data (postmeta, metaval, name, value) VALUES('{$postname}', '{$term_key}', '{$key}', '{$term_val}') ON DUPLICATE KEY UPDATE value='{$term_val}'";
|
376 |
+
$wpdb->query($sql);
|
377 |
+
} else {
|
378 |
+
$sql = $wpdb->prepare("DELETE FROM {$wpdb->prefix}berocket_postmeta_data WHERE postmeta = %s AND metaval = %s AND name = %s;", $postname, $term_key, $key);
|
379 |
+
$wpdb->query($sql);
|
380 |
+
}
|
381 |
+
}
|
382 |
+
} else {
|
383 |
+
$sql = $wpdb->prepare("INSERT IGNORE INTO {$wpdb->prefix}berocket_postmeta_data (postmeta, metaval, name, value) VALUES(%s, %s, %s, %s) ON DUPLICATE KEY UPDATE value=%s", $postname, $key, $type, $value, $value);
|
384 |
+
$wpdb->query($sql);
|
385 |
+
}
|
386 |
+
}
|
387 |
+
return false;
|
388 |
+
}
|
389 |
+
return $prevent_save;
|
390 |
+
}
|
391 |
+
function color_listener_attribute($attribute, $instance, $post_id, $post) {
|
392 |
+
if( $instance['filter_type'] == 'custom_postmeta' ) {
|
393 |
+
$attribute = $instance['custom_postmeta'];
|
394 |
+
}
|
395 |
+
return $attribute;
|
396 |
+
}
|
397 |
+
function select_metadata($value, $term, $type) {
|
398 |
+
if( property_exists($term, 'custom_postmeta') && $term->custom_postmeta ) {
|
399 |
+
global $wpdb;
|
400 |
+
$postmeta = substr($term->taxonomy, 4);
|
401 |
+
$metaval = $term->slug;
|
402 |
+
$sql = $wpdb->prepare("SELECT value FROM {$wpdb->prefix}berocket_postmeta_data WHERE postmeta = %s AND metaval = %s AND name = %s;", $postmeta, $metaval, $type);
|
403 |
+
$value2 = $wpdb->get_var($sql);
|
404 |
+
if( ! empty($value2) ) {
|
405 |
+
$value = array($value2);
|
406 |
+
}
|
407 |
+
}
|
408 |
+
return $value;
|
409 |
+
}
|
410 |
+
function create_data_table() {
|
411 |
+
global $wpdb;
|
412 |
+
$table_name = $wpdb->prefix . 'berocket_postmeta_data';
|
413 |
+
$charset_collate = '';
|
414 |
+
if ( ! empty ( $wpdb->charset ) ) {
|
415 |
+
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
|
416 |
+
}
|
417 |
+
if ( ! empty ( $wpdb->collate ) ) {
|
418 |
+
$charset_collate .= " COLLATE {$wpdb->collate}";
|
419 |
+
}
|
420 |
+
|
421 |
+
$sql = "CREATE TABLE {$table_name} (
|
422 |
+
postmeta varchar(110),
|
423 |
+
metaval varchar(110) NOT NULL default 0,
|
424 |
+
name varchar(25) DEFAULT NULL,
|
425 |
+
value longtext DEFAULT NULL,
|
426 |
+
INDEX postmeta (postmeta),
|
427 |
+
INDEX metaval (metaval),
|
428 |
+
UNIQUE KEY meta_id (postmeta, metaval, name)
|
429 |
+
) {$charset_collate};";
|
430 |
+
|
431 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
432 |
+
dbDelta( $sql );
|
433 |
+
}
|
434 |
+
function uparse_terms($result, $instance, $filter, $data) {
|
435 |
+
if( $result === null && isset($filter['type']) && $filter['type'] == 'custom_postmeta' ) {
|
436 |
+
$result = $this->get_postmeta(substr($filter['taxonomy'],4));
|
437 |
+
}
|
438 |
+
return $result;
|
439 |
+
}
|
440 |
+
public function ids_slug($result, $instance, $values_line, $taxonomy, $filter, $args) {
|
441 |
+
if( $result === null && isset($filter['type']) && $filter['type'] == 'custom_postmeta' ) {
|
442 |
+
$terms = $this->get_postmeta(substr($filter['taxonomy'],4));
|
443 |
+
$result = array();
|
444 |
+
foreach($terms as $term) {
|
445 |
+
$result[$term->term_id] = $term->slug;
|
446 |
+
}
|
447 |
+
}
|
448 |
+
return $result;
|
449 |
+
}
|
450 |
+
}
|
451 |
+
new BeRocket_aapf_add_postmeta_filters();
|
assets/admin/js/admin.js
CHANGED
@@ -102,465 +102,9 @@ var berocket_admin_filter_types_by_attr = {
|
|
102 |
event.preventDefault();
|
103 |
event.stopPropagation();
|
104 |
});
|
105 |
-
$('.get_shortcode').click( function ( event ) {
|
106 |
-
event.preventDefault();
|
107 |
-
$form = $(this).parents('form');
|
108 |
-
var params = $( '.br_colorpicker_field_input, .berocket_image_value' );
|
109 |
-
var attr = $( '#berocket_sc_attribute' );
|
110 |
-
var type = $( '#berocket_sc_type' );
|
111 |
-
if ( params.length > 0 ) {
|
112 |
-
params = params.serialize();
|
113 |
-
params = params+'&action=aapf_color_set&type='+type.val()+'&tax_color_name='+attr.val();
|
114 |
-
$.post(ajaxurl, params, function (data) {});
|
115 |
-
}
|
116 |
-
create_shortcode( $form );
|
117 |
-
});
|
118 |
$(document).on('change', '.berocket_aapf_widget_sc, .berocket_aapf_style_sb_sc, .berocket_aapf_sb_attributes_sc, .berocket_aapf_childs_sc, .berocket_aapf_include_list_sc', function() {
|
119 |
$(this).data('sc_change', '1');
|
120 |
});
|
121 |
-
function create_shortcode( $form ) {
|
122 |
-
var shortcode = {
|
123 |
-
key: [],
|
124 |
-
value: [],
|
125 |
-
};
|
126 |
-
var widget_type = $form.find('.berocket_aapf_widget_admin_widget_type_select').val();
|
127 |
-
$form.find('.berocket_aapf_widget_sc').each( function ( i, o ) {
|
128 |
-
if( $(o).data('sc_change') ) {
|
129 |
-
if ( $(o).is('[type=checkbox]') ) {
|
130 |
-
if( shortcode.key.indexOf( $(o).data('sc') ) == -1 ) {
|
131 |
-
shortcode.key.push($(o).data('sc'));
|
132 |
-
if ( $(o).prop('checked') ) {
|
133 |
-
shortcode.value.push($(o).val());
|
134 |
-
} else {
|
135 |
-
shortcode.value.push('');
|
136 |
-
}
|
137 |
-
} else {
|
138 |
-
index = shortcode.key.indexOf( $(o).data('sc') );
|
139 |
-
if ( $(o).prop('checked') ) {
|
140 |
-
if ( ! Array.isArray( shortcode.value[index] ) ) {
|
141 |
-
firstvalue = shortcode.value[index];
|
142 |
-
shortcode.value[index] = [];
|
143 |
-
if( firstvalue != '' ) {
|
144 |
-
shortcode.value[index].push(firstvalue);
|
145 |
-
}
|
146 |
-
}
|
147 |
-
shortcode.value[index].push($(o).val());
|
148 |
-
}
|
149 |
-
}
|
150 |
-
} else if ( $(o).is('[type=radio]') ) {
|
151 |
-
if ( $(o).prop('checked') ) {
|
152 |
-
shortcode.key.push($(o).data('sc'));
|
153 |
-
shortcode.value.push($(o).val());
|
154 |
-
}
|
155 |
-
} else {
|
156 |
-
if( shortcode.key.indexOf( $(o).data('sc') ) == -1 ) {
|
157 |
-
shortcode.key.push($(o).data('sc'));
|
158 |
-
shortcode.value.push($(o).val());
|
159 |
-
} else {
|
160 |
-
if( $(o).val() != '' ) {
|
161 |
-
index = shortcode.key.indexOf( $(o).data('sc') );
|
162 |
-
if ( ! Array.isArray( shortcode.value[index] ) ) {
|
163 |
-
firstvalue = shortcode.value[index];
|
164 |
-
shortcode.value[index] = [];
|
165 |
-
if( firstvalue != '' ) {
|
166 |
-
shortcode.value[index].push(firstvalue);
|
167 |
-
}
|
168 |
-
}
|
169 |
-
shortcode.value[index].push($(o).val());
|
170 |
-
}
|
171 |
-
}
|
172 |
-
}
|
173 |
-
}
|
174 |
-
});
|
175 |
-
if( widget_type == 'search_box' ) {
|
176 |
-
var search_box_count = $form.find('.br_search_box_count').val();
|
177 |
-
var search_box_style = {};
|
178 |
-
var search_box_style_exist = false;
|
179 |
-
$form.find('.berocket_aapf_style_sb_sc').each( function ( i, o ) {
|
180 |
-
if( $(o).data('sc_change') ) {
|
181 |
-
search_box_style[$(o).data('sc')] = $(o).val();
|
182 |
-
search_box_style_exist = true;
|
183 |
-
}
|
184 |
-
});
|
185 |
-
if( search_box_style_exist ) {
|
186 |
-
shortcode.key.push('search_box_style');
|
187 |
-
shortcode.value.push(JSON.stringify(search_box_style));
|
188 |
-
}
|
189 |
-
|
190 |
-
var search_box_attributes = {};
|
191 |
-
var search_box_attributes_exist = false;
|
192 |
-
for( var i = 1; i <= search_box_count; i++ ) {
|
193 |
-
var $attribute_block = $form.find('.berocket_search_box_attribute_'+i);
|
194 |
-
|
195 |
-
var current_attr = {};
|
196 |
-
var current_attr_exist = false;
|
197 |
-
$attribute_block.find('.berocket_aapf_sb_attributes_sc').each( function ( i, o ) {
|
198 |
-
if( $(o).data('sc_change') ) {
|
199 |
-
current_attr[$(o).data('sc')] = $(o).val();
|
200 |
-
current_attr_exist = true;
|
201 |
-
}
|
202 |
-
});
|
203 |
-
if( current_attr_exist ) {
|
204 |
-
search_box_attributes[i] = current_attr;
|
205 |
-
search_box_attributes_exist = true;
|
206 |
-
}
|
207 |
-
}
|
208 |
-
if( search_box_attributes_exist ) {
|
209 |
-
shortcode.key.push('search_box_attributes');
|
210 |
-
shortcode.value.push(JSON.stringify(search_box_attributes));
|
211 |
-
}
|
212 |
-
}
|
213 |
-
var child_type = $form.find('.berocket_aapf_widget_child_parent_select').val();
|
214 |
-
if( widget_type == 'filter' && child_type == 'depth' ) {
|
215 |
-
var child_count = $form.find('.br_onew_child_count_select').val();
|
216 |
-
|
217 |
-
var child_onew_childs = {};
|
218 |
-
var child_onew_childs_exist = false;
|
219 |
-
for( var i = 1; i <= child_count; i++ ) {
|
220 |
-
var $child_block = $form.find('.child_onew_childs_'+i);
|
221 |
-
|
222 |
-
var current_child = {};
|
223 |
-
var current_child_exist = false;
|
224 |
-
$child_block.find('.berocket_aapf_childs_sc').each( function ( i, o ) {
|
225 |
-
if( $(o).data('sc_change') ) {
|
226 |
-
current_child[$(o).data('sc')] = $(o).val();
|
227 |
-
current_child_exist = true;
|
228 |
-
}
|
229 |
-
});
|
230 |
-
if( current_child_exist ) {
|
231 |
-
child_onew_childs[i] = current_child;
|
232 |
-
child_onew_childs_exist = true;
|
233 |
-
}
|
234 |
-
}
|
235 |
-
if( child_onew_childs_exist ) {
|
236 |
-
shortcode.key.push('child_onew_childs');
|
237 |
-
shortcode.value.push(JSON.stringify(child_onew_childs));
|
238 |
-
}
|
239 |
-
}
|
240 |
-
var br_filters = '[br_filters';
|
241 |
-
for( var i = 0; i < shortcode.key.length; i++ ) {
|
242 |
-
br_filters += ' '+shortcode.key[i]+'=\'';
|
243 |
-
if ( Array.isArray( shortcode.value[i] ) ) {
|
244 |
-
for( var j = 0; j < shortcode.value[i].length; j++ ) {
|
245 |
-
if ( j != 0 ) {
|
246 |
-
br_filters += '|';
|
247 |
-
}
|
248 |
-
br_filters += shortcode.value[i][j];
|
249 |
-
}
|
250 |
-
} else {
|
251 |
-
br_filters += shortcode.value[i];
|
252 |
-
}
|
253 |
-
br_filters += '\'';
|
254 |
-
}
|
255 |
-
br_filters += ']';
|
256 |
-
window.prompt('Shortcode',br_filters);
|
257 |
-
}
|
258 |
-
|
259 |
-
function berocket_aapf_show_hide($block, is_hide) {
|
260 |
-
if( is_hide ) {
|
261 |
-
$block.hide(0);
|
262 |
-
} else {
|
263 |
-
$block.show(0);
|
264 |
-
}
|
265 |
-
}
|
266 |
-
function berocket_aapf_hide_blocks ( $parent, args ) {
|
267 |
-
if( args.changed != undefined ) {
|
268 |
-
changed = args.changed;
|
269 |
-
} else {
|
270 |
-
changed = 'none';
|
271 |
-
}
|
272 |
-
product_cat_current = $('.berocket_aapf_product_sub_cat_current_input', $parent).prop('checked');
|
273 |
-
filter_type = $('.berocket_aapf_widget_admin_filter_type_select', $parent).val();
|
274 |
-
filter_type_data = $('.berocket_aapf_widget_admin_filter_type_select', $parent).find('option:selected').data();
|
275 |
-
attribute = $('.berocket_aapf_widget_admin_filter_type_attribute_select', $parent).val();
|
276 |
-
custom_taxonomy = $('.berocket_aapf_widget_admin_filter_type_custom_taxonomy_select', $parent).val();
|
277 |
-
|
278 |
-
berocket_aapf_show_hide( $('.berocket_aapf_widget_admin_filter_type_', $parent),
|
279 |
-
true );
|
280 |
-
if ( $('.berocket_aapf_widget_admin_filter_type_'+filter_type, $parent).hasClass('berocket_aapf_widget_admin_filter_type_'+filter_type) ) {
|
281 |
-
$('.berocket_aapf_widget_admin_filter_type_'+filter_type, $parent).show();
|
282 |
-
}
|
283 |
-
if( filter_type_data.sameas ) {
|
284 |
-
filter_type = filter_type_data.sameas;
|
285 |
-
if( filter_type_data.attribute ) {
|
286 |
-
if( filter_type_data.sameas == 'custom_taxonomy' ) {
|
287 |
-
custom_taxonomy = filter_type_data.attribute;
|
288 |
-
} else if( filter_type_data.sameas == 'attribute' ) {
|
289 |
-
attribute = filter_type_data.attribute;
|
290 |
-
}
|
291 |
-
}
|
292 |
-
}
|
293 |
-
|
294 |
-
if ( changed != 'type' && changed != 'child_parent' ) {
|
295 |
-
var select_options = '';
|
296 |
-
var select_options_variants = [];
|
297 |
-
if ( filter_type == 'price' ) {
|
298 |
-
select_options_variants = berocket_admin_filter_types.price;
|
299 |
-
} else if ( filter_type == 'tag' ) {
|
300 |
-
select_options_variants = berocket_admin_filter_types.tag;
|
301 |
-
} else if ( filter_type == 'product_cat' || ( filter_type == 'custom_taxonomy' && ( custom_taxonomy == 'product_tag' || custom_taxonomy == 'product_cat' ) ) ) {
|
302 |
-
select_options_variants = berocket_admin_filter_types.product_cat;
|
303 |
-
} else if ( filter_type == '_sale' || filter_type == '_stock_status' || filter_type == '_rating' ) {
|
304 |
-
select_options_variants = berocket_admin_filter_types.sale;
|
305 |
-
} else if ( filter_type == 'custom_taxonomy' ) {
|
306 |
-
select_options_variants = berocket_admin_filter_types.custom_taxonomy;
|
307 |
-
} else if ( filter_type == 'attribute' ) {
|
308 |
-
if ( attribute == 'price' ) {
|
309 |
-
select_options_variants = berocket_admin_filter_types.price;
|
310 |
-
} else {
|
311 |
-
select_options_variants = berocket_admin_filter_types.attribute;
|
312 |
-
}
|
313 |
-
} else if ( filter_type == 'filter_by' ) {
|
314 |
-
select_options_variants = berocket_admin_filter_types.filter_by;
|
315 |
-
}
|
316 |
-
select_options_variants.forEach(function(element) {
|
317 |
-
select_options = select_options + berocket_admin_filter_types_by_attr[element];
|
318 |
-
});
|
319 |
-
$('.berocket_aapf_widget_admin_type_select', $parent).html(select_options);
|
320 |
-
$('.berocket_aapf_widget_admin_type_select', $parent).data('sc_change', '1');
|
321 |
-
}
|
322 |
-
type = $('.berocket_aapf_widget_admin_type_select', $parent).val();
|
323 |
-
child_parent = $('.berocket_aapf_widget_child_parent_select', $parent).val();
|
324 |
-
|
325 |
-
berocket_aapf_show_hide( $('.berocket_aapf_widget_admin_operator_select', $parent).parent(),
|
326 |
-
( ( filter_type == 'attribute'
|
327 |
-
&& ( attribute == 'price' ) )
|
328 |
-
|| type == 'slider'
|
329 |
-
|| filter_type == 'date'
|
330 |
-
|| filter_type == '_sale'
|
331 |
-
|| filter_type == '_rating' ) );
|
332 |
-
berocket_aapf_show_hide( $('.br_aapf_child_parent_selector', $parent),
|
333 |
-
( ( filter_type == 'attribute'
|
334 |
-
&& attribute == 'price' )
|
335 |
-
|| filter_type == 'product_cat'
|
336 |
-
|| filter_type == '_stock_status'
|
337 |
-
|| filter_type == 'tag'
|
338 |
-
|| type == 'slider'
|
339 |
-
|| filter_type == 'date'
|
340 |
-
|| filter_type == '_sale'
|
341 |
-
|| filter_type == '_rating' ) );
|
342 |
-
berocket_aapf_show_hide( $('.berocket_ranges_block', $parent),
|
343 |
-
( filter_type != 'attribute'
|
344 |
-
|| attribute != 'price'
|
345 |
-
|| type != 'ranges' ) );
|
346 |
-
berocket_aapf_show_hide( $('.berocket_aapf_widget_admin_values_per_row', $parent).parent(),
|
347 |
-
( ( filter_type == 'attribute'
|
348 |
-
&& ( attribute == 'price' || attribute == 'product_cat' ) )
|
349 |
-
|| type == 'slider'
|
350 |
-
|| type == 'select'
|
351 |
-
|| type == 'tag_cloud'
|
352 |
-
|| filter_type == 'product_cat'
|
353 |
-
|| filter_type == 'custom_taxonomy' && custom_taxonomy == 'product_cat' ) );
|
354 |
-
berocket_aapf_show_hide( $('.berocket_aapf_widget_admin_non_price_tag_cloud', $parent),
|
355 |
-
( filter_type == 'date'
|
356 |
-
|| ( filter_type != 'date'
|
357 |
-
&& ( type == 'tag_cloud'
|
358 |
-
|| type == 'slider' ) ) ) );
|
359 |
-
berocket_aapf_show_hide( $('.berocket_aapf_widget_admin_non_price_tag_cloud_select', $parent),
|
360 |
-
( filter_type == 'date'
|
361 |
-
|| ( filter_type != 'date'
|
362 |
-
&& ( type == 'tag_cloud'
|
363 |
-
|| type == 'slider'
|
364 |
-
|| type == 'select' ) ) ) );
|
365 |
-
berocket_aapf_show_hide( $('.berocket_aapf_widget_admin_ranges_hide', $parent),
|
366 |
-
( type == 'ranges' ) );
|
367 |
-
berocket_aapf_show_hide( $('.berocket_aapf_widget_admin_price_attribute', $parent),
|
368 |
-
( filter_type != 'attribute'
|
369 |
-
|| attribute != 'price'
|
370 |
-
|| type != 'slider' ) );
|
371 |
-
berocket_aapf_show_hide( $('.berocket_aapf_advanced_color_pick_settings', $parent),
|
372 |
-
( type != 'color' && type != 'image' ) );
|
373 |
-
berocket_aapf_show_hide( $('.berocket_aapf_product_sub_cat_current', $parent),
|
374 |
-
( filter_type != 'product_cat' ) );
|
375 |
-
berocket_aapf_show_hide( $('.berocket_aapf_product_sub_cat_div', $parent),
|
376 |
-
( filter_type != 'product_cat' || product_cat_current ) );
|
377 |
-
berocket_aapf_show_hide( $('.berocket_aapf_widget_admin_tag_cloud_block', $parent),
|
378 |
-
( type != 'tag_cloud' ) );
|
379 |
-
berocket_aapf_show_hide( $('.berocket_aapf_icons_select_block', $parent),
|
380 |
-
( type == 'select' ) );
|
381 |
-
berocket_aapf_show_hide( $('.berocket_aapf_widget_child_parent_depth_block', $parent),
|
382 |
-
( child_parent != 'child' ) );
|
383 |
-
berocket_aapf_show_hide( $('.berocket_aapf_widget_child_parent_one_widget', $parent),
|
384 |
-
( child_parent != 'depth' ) );
|
385 |
-
berocket_aapf_show_hide( $('.berocket_aapf_order_values_by', $parent),
|
386 |
-
( filter_type == '_stock_status'
|
387 |
-
|| filter_type == 'attribute' && attribute == 'price'
|
388 |
-
|| filter_type == 'date'
|
389 |
-
|| filter_type == '_sale'
|
390 |
-
|| filter_type == '_rating' ) );
|
391 |
-
berocket_aapf_show_hide( $('.berocket_aapf_order_values_type', $parent),
|
392 |
-
( ( filter_type != 'attribute'
|
393 |
-
&& filter_type != 'custom_taxonomy' )
|
394 |
-
|| type == 'ranges')
|
395 |
-
&& filter_type != 'tag'
|
396 |
-
&& filter_type != '_rating' );
|
397 |
-
berocket_aapf_show_hide( $('.berocket_attributes_slider_data', $parent),
|
398 |
-
! ( ( (filter_type == 'attribute' && attribute != 'price' )
|
399 |
-
|| filter_type == 'custom_taxonomy' )
|
400 |
-
&& type == 'slider' ) );
|
401 |
-
berocket_aapf_show_hide( $('.berocket_attributes_checkbox_radio_data', $parent),
|
402 |
-
! ( ( filter_type == 'attribute' || filter_type == 'custom_taxonomy' )
|
403 |
-
&& ( type == 'checkbox' || type == 'radio' || type == 'color' || type == 'image' ) ) );
|
404 |
-
berocket_aapf_show_hide( $('.berocket_attributes_number_style_data', $parent),
|
405 |
-
! ( ( filter_type == 'attribute'
|
406 |
-
|| filter_type == 'custom_taxonomy' )
|
407 |
-
&& type == 'slider' ) );
|
408 |
-
berocket_aapf_show_hide( $('.br_type_select_block', $parent),
|
409 |
-
( filter_type == 'date' ) );
|
410 |
-
berocket_aapf_show_hide( $('.berocket_options_for_select', $parent),
|
411 |
-
( ( filter_type != 'attribute'
|
412 |
-
&& filter_type != 'custom_taxonomy'
|
413 |
-
&& filter_type != 'product_cat'
|
414 |
-
&& filter_type != 'tag' )
|
415 |
-
|| type != 'select' ) );
|
416 |
-
berocket_aapf_show_hide( $('.br_aapf_date_style_select', $parent),
|
417 |
-
( filter_type != 'date' ) );
|
418 |
-
if ( type == 'color' || type == 'image' ) {
|
419 |
-
var tax_color_name;
|
420 |
-
if ( filter_type == 'attribute' ) {
|
421 |
-
tax_color_name = attribute;
|
422 |
-
} else if ( filter_type == 'custom_taxonomy' ) {
|
423 |
-
tax_color_name = custom_taxonomy;
|
424 |
-
} else if( filter_type == 'tag' ) {
|
425 |
-
tax_color_name = 'product_tag';
|
426 |
-
} else if( filter_type == 'product_cat' ) {
|
427 |
-
tax_color_name = 'product_cat';
|
428 |
-
}
|
429 |
-
var data = {
|
430 |
-
'action': 'berocket_aapf_color_listener',
|
431 |
-
'tax_color_name': tax_color_name,
|
432 |
-
'type': type
|
433 |
-
};
|
434 |
-
$.post(ajaxurl, data, function(data) {
|
435 |
-
$('.berocket_widget_color_pick', $parent).html(data);
|
436 |
-
$('.berocket_aapf_advanced_color_pick_settings', $parent).show(0);
|
437 |
-
});
|
438 |
-
} else {
|
439 |
-
$('.berocket_widget_color_pick', $parent).text("");
|
440 |
-
}
|
441 |
-
if( args.changed == 'filter_type' || args.changed == 'attribute' || args.changed == 'custom_taxonomy' || args.changed == 'type' ) {
|
442 |
-
var taxonomy_name = false;
|
443 |
-
if( filter_type == 'product_cat' ) {
|
444 |
-
taxonomy_name = 'product_cat';
|
445 |
-
} else if( filter_type == 'tag' ) {
|
446 |
-
taxonomy_name = 'product_tag';
|
447 |
-
} else if( filter_type == 'attribute' && attribute != 'price' ) {
|
448 |
-
taxonomy_name = attribute;
|
449 |
-
} else if ( filter_type == 'custom_taxonomy' ) {
|
450 |
-
taxonomy_name = custom_taxonomy;
|
451 |
-
}
|
452 |
-
var exclude_include_name = $('.include_exclude_list', $parent).data('name');
|
453 |
-
if( taxonomy_name === false ) {
|
454 |
-
$('.include_exclude_list', $parent).text("");
|
455 |
-
$('.include_exclude_select', $parent).hide();
|
456 |
-
} else {
|
457 |
-
if( $('.include_exclude_list', $parent).length ) {
|
458 |
-
$('.include_exclude_select', $parent).show();
|
459 |
-
var data = {
|
460 |
-
'action': 'br_include_exclude_list',
|
461 |
-
'taxonomy_name': taxonomy_name,
|
462 |
-
};
|
463 |
-
$.post(ajaxurl, data, function(data) {
|
464 |
-
if( data ) {
|
465 |
-
var replace_str = /%field_name%/g;
|
466 |
-
data = data.replace(replace_str, exclude_include_name);
|
467 |
-
$('.include_exclude_list', $parent).html(data);
|
468 |
-
} else {
|
469 |
-
$('.include_exclude_list', $parent).text("");
|
470 |
-
}
|
471 |
-
});
|
472 |
-
}
|
473 |
-
}
|
474 |
-
} else {
|
475 |
-
$('.include_exclude_list', $parent).text("");
|
476 |
-
$('.include_exclude_select', $parent).hide();
|
477 |
-
}
|
478 |
-
brjsf($('.berocket_aapf_widget_admin_type_select', $parent));
|
479 |
-
}
|
480 |
-
$(document).on('change', '.berocket_aapf_widget_admin_filter_type_select', function () {
|
481 |
-
$parent = $(this).parents('.customize-control.customize-control-widget_form.widget-rendered');
|
482 |
-
if( $parent.length == 0 ) {
|
483 |
-
$parent = $(this).parents('form');
|
484 |
-
}
|
485 |
-
berocket_aapf_hide_blocks ( $parent, { changed:'filter_type' } );
|
486 |
-
});
|
487 |
-
|
488 |
-
$(document).on('change', '.berocket_aapf_widget_admin_filter_type_attribute_select', function () {
|
489 |
-
$parent = $(this).parents('.customize-control.customize-control-widget_form.widget-rendered');
|
490 |
-
if( $parent.length == 0 ) {
|
491 |
-
$parent = $(this).parents('form');
|
492 |
-
}
|
493 |
-
berocket_aapf_hide_blocks ( $parent, { changed:'attribute' } );
|
494 |
-
});
|
495 |
-
|
496 |
-
$(document).on('change', '.berocket_aapf_widget_admin_type_select', function () {
|
497 |
-
$parent = $(this).parents('.customize-control.customize-control-widget_form.widget-rendered');
|
498 |
-
if( $parent.length == 0 ) {
|
499 |
-
$parent = $(this).parents('form');
|
500 |
-
}
|
501 |
-
berocket_aapf_hide_blocks ( $parent, { changed:'type' } );
|
502 |
-
});
|
503 |
-
|
504 |
-
$(document).on('change', '.berocket_aapf_widget_admin_filter_type_custom_taxonomy_select', function () {
|
505 |
-
$parent = $(this).parents('.customize-control.customize-control-widget_form.widget-rendered');
|
506 |
-
if( $parent.length == 0 ) {
|
507 |
-
$parent = $(this).parents('form');
|
508 |
-
}
|
509 |
-
berocket_aapf_hide_blocks ( $parent, { changed:'custom_taxonomy' } );
|
510 |
-
});
|
511 |
-
|
512 |
-
$(document).on('change', '.berocket_aapf_widget_child_parent_select', function () {
|
513 |
-
$parent = $(this).parents('.customize-control.customize-control-widget_form.widget-rendered');
|
514 |
-
if( $parent.length == 0 ) {
|
515 |
-
$parent = $(this).parents('form');
|
516 |
-
}
|
517 |
-
berocket_aapf_hide_blocks ( $parent, { changed:'child_parent' } );
|
518 |
-
});
|
519 |
-
|
520 |
-
$(document).on('change', '.berocket_aapf_product_sub_cat_current_input', function () {
|
521 |
-
$parent = $(this).parents('.customize-control.customize-control-widget_form.widget-rendered');
|
522 |
-
if( $parent.length == 0 ) {
|
523 |
-
$parent = $(this).parents('form');
|
524 |
-
}
|
525 |
-
berocket_aapf_hide_blocks ( $parent, { changed:'product_cat_current' } );
|
526 |
-
});
|
527 |
-
|
528 |
-
$(document).on('change', '.berocket_aapf_checked_show_next', function () {
|
529 |
-
if($(this).find('input[type=checkbox]').attr('checked') == 'checked') {
|
530 |
-
$(this).next().show(0);
|
531 |
-
} else {
|
532 |
-
$(this).next().hide(0);
|
533 |
-
}
|
534 |
-
});
|
535 |
-
|
536 |
-
$(document).on('change', '.include_exclude_select select', function() {
|
537 |
-
if( $(this).val() ) {
|
538 |
-
$('.include_exclude_list').show();
|
539 |
-
} else {
|
540 |
-
$('.include_exclude_list').hide();
|
541 |
-
}
|
542 |
-
});
|
543 |
-
|
544 |
-
$(document).on('click', '.berocket_aapf_advanced_settings_pointer', function (event) {
|
545 |
-
event.preventDefault();
|
546 |
-
$next = $(this).parent().next();
|
547 |
-
if ( $next.is(':visible') ) {
|
548 |
-
$next.slideUp(300);
|
549 |
-
} else {
|
550 |
-
$next.slideDown(300);
|
551 |
-
}
|
552 |
-
});
|
553 |
-
|
554 |
-
$(document).on('click', '.berocket_aapf_output_limitations_pointer', function (event) {
|
555 |
-
event.preventDefault();
|
556 |
-
$next = $(this).parent().next();
|
557 |
-
if ( $next.is(':visible') ) {
|
558 |
-
$next.slideUp(300);
|
559 |
-
} else {
|
560 |
-
$next.slideDown(300);
|
561 |
-
}
|
562 |
-
});
|
563 |
-
|
564 |
$('.br_colorpicker_field').each(function (i,o){
|
565 |
if( typeof($(o).colpick) != 'undefined' ) {
|
566 |
$(o).css('backgroundColor', '#'+$(o).data('color'));
|
@@ -590,184 +134,16 @@ var berocket_admin_filter_types_by_attr = {
|
|
590 |
$table.find('select').val("");
|
591 |
$table.find('input[type=text]').val("");
|
592 |
});
|
593 |
-
|
594 |
-
$('.filter_settings_tabs').on('click', 'a', function (event) {
|
595 |
-
if( ! $(this).is('.link-tab') ) {
|
596 |
-
event.preventDefault();
|
597 |
-
$('#br_opened_tab').val( $(this).attr('href').replace('#', '') );
|
598 |
-
$id = $(this).attr('href');
|
599 |
-
$('.tab-item.current').removeClass('current');
|
600 |
-
$($id).addClass('current');
|
601 |
-
|
602 |
-
$('.filter_settings_tabs .nav-tab').removeClass('nav-tab-active');
|
603 |
-
$(this).addClass('nav-tab-active');
|
604 |
-
}
|
605 |
-
});
|
606 |
-
|
607 |
-
$(document).on('change', '.berocket_aapf_widget_admin_widget_type_select', function () {
|
608 |
-
$parent = $(this).parents('form');
|
609 |
-
if ( $(this).val() == 'filter' ) {
|
610 |
-
$('.berocket_aapf_admin_filter_widget_content', $parent).show();
|
611 |
-
$('.berocket_aapf_admin_widget_selected_area', $parent).hide();
|
612 |
-
$('.berocket_aapf_admin_search_box', $parent).hide();
|
613 |
-
$('.berocket_product_category_value_limit, .berocket_widget_output_limitation_block', $parent).show();
|
614 |
-
$('.berocket_widget_reset_button_block', $parent).hide();
|
615 |
-
} else if( $(this).val() == 'update_button' ) {
|
616 |
-
$('.berocket_aapf_admin_filter_widget_content', $parent).hide();
|
617 |
-
$('.berocket_aapf_admin_widget_selected_area', $parent).hide();
|
618 |
-
$('.berocket_aapf_admin_search_box', $parent).hide();
|
619 |
-
$('.berocket_product_category_value_limit, .berocket_widget_output_limitation_block', $parent).hide();
|
620 |
-
$('.berocket_widget_reset_button_block', $parent).hide();
|
621 |
-
} else if( $(this).val() == 'reset_button' ) {
|
622 |
-
$('.berocket_aapf_admin_filter_widget_content', $parent).hide();
|
623 |
-
$('.berocket_aapf_admin_widget_selected_area', $parent).hide();
|
624 |
-
$('.berocket_aapf_admin_search_box', $parent).hide();
|
625 |
-
$('.berocket_product_category_value_limit, .berocket_widget_output_limitation_block', $parent).hide();
|
626 |
-
$('.berocket_widget_reset_button_block', $parent).show();
|
627 |
-
} else if( $(this).val() == 'selected_area' ) {
|
628 |
-
$('.berocket_aapf_admin_filter_widget_content', $parent).hide();
|
629 |
-
$('.berocket_aapf_admin_search_box', $parent).hide();
|
630 |
-
$('.berocket_aapf_admin_widget_selected_area', $parent).show();
|
631 |
-
$('.berocket_product_category_value_limit, .berocket_widget_output_limitation_block', $parent).hide();
|
632 |
-
$('.berocket_widget_reset_button_block', $parent).hide();
|
633 |
-
} else if( $(this).val() == 'search_box' ) {
|
634 |
-
$('.berocket_aapf_admin_filter_widget_content', $parent).hide();
|
635 |
-
$('.berocket_aapf_admin_widget_selected_area', $parent).hide();
|
636 |
-
$('.berocket_aapf_admin_search_box', $parent).show();
|
637 |
-
$('.berocket_product_category_value_limit, .berocket_widget_output_limitation_block', $parent).hide();
|
638 |
-
$('.berocket_widget_reset_button_block', $parent).hide();
|
639 |
-
}
|
640 |
-
});
|
641 |
-
$(document).on('change', '.berocket_scroll_shop_top', function () {
|
642 |
-
if ( $(this).prop('checked') ) {
|
643 |
-
$(this).parent().next().show();
|
644 |
-
} else {
|
645 |
-
$(this).parent().next().hide();
|
646 |
-
}
|
647 |
-
});
|
648 |
-
$(document).on('click', '.berocket_aapf_font_awesome_icon_select',function(event) {
|
649 |
-
event.preventDefault();
|
650 |
-
$(this).next('.berocket_aapf_select_icon').show();
|
651 |
-
});
|
652 |
-
$(document).on('click', '.berocket_aapf_select_icon',function(event) {
|
653 |
-
event.preventDefault();
|
654 |
-
$(this).hide();
|
655 |
-
});
|
656 |
-
$(document).on('click', '.berocket_aapf_select_icon div p i.fa',function(event) {
|
657 |
-
event.preventDefault();
|
658 |
-
$(this).parents('.berocket_aapf_select_icon').hide();
|
659 |
-
});
|
660 |
-
$(document).on('click', '.berocket_aapf_select_icon div',function(event) {
|
661 |
-
event.preventDefault();
|
662 |
-
event.stopPropagation()
|
663 |
-
});
|
664 |
-
$(document).on('click', '.berocket_aapf_select_icon label',function(event) {
|
665 |
-
event.preventDefault();
|
666 |
-
$(this).parents('.berocket_aapf_select_icon').prevAll(".berocket_aapf_icon_text_value").val($(this).find('span').data('value'));
|
667 |
-
$(this).parents('.berocket_aapf_select_icon').prevAll(".berocket_aapf_selected_icon_show").html('<i class="fa '+$(this).find('span').data('value')+'"></i>');
|
668 |
-
$(this).parents('.berocket_aapf_select_icon').hide();
|
669 |
-
});
|
670 |
-
$(document).on('click', '.berocket_aapf_upload_icon', function(e) {
|
671 |
-
e.preventDefault();
|
672 |
-
$p = $(this);
|
673 |
-
var custom_uploader = wp.media({
|
674 |
-
title: 'Select custom Icon',
|
675 |
-
button: {
|
676 |
-
text: 'Set Icon'
|
677 |
-
},
|
678 |
-
multiple: false
|
679 |
-
}).on('select', function() {
|
680 |
-
var attachment = custom_uploader.state().get('selection').first().toJSON();
|
681 |
-
$p.prevAll(".berocket_aapf_selected_icon_show").html('<i class="fa"><image src="'+attachment.url+'" alt=""></i>');
|
682 |
-
$p.prevAll(".berocket_aapf_icon_text_value").val(attachment.url);
|
683 |
-
}).open();
|
684 |
-
});
|
685 |
-
$(document).on('click', '.berocket_aapf_remove_icon',function(event) {
|
686 |
-
event.preventDefault();
|
687 |
-
$(this).prevAll(".berocket_aapf_icon_text_value").val("");
|
688 |
-
$(this).prevAll(".berocket_aapf_selected_icon_show").html("");
|
689 |
-
});
|
690 |
br_widget_set();
|
691 |
-
$(document).on( 'change', '.br_theme_set_select', function(event) {
|
692 |
-
var $parent = $(this).parents('.br_checkbox_radio_settings');
|
693 |
-
var $data = $(this).find('option:selected').data();
|
694 |
-
var $color = '000000';
|
695 |
-
if( ! $data['border_color'] ) {
|
696 |
-
$color = '000000';
|
697 |
-
} else {
|
698 |
-
$color = $data['border_color'];
|
699 |
-
}
|
700 |
-
$parent.find('.br_border_color_set').prev().css('backgroundColor', '#' + $color).colpickSetColor('#' + $color);
|
701 |
-
$parent.find('.br_border_color_set').val( $data['border_color'] );
|
702 |
-
if( ! $data['font_color'] ) {
|
703 |
-
$color = '000000';
|
704 |
-
} else {
|
705 |
-
$color = $data['font_color'];
|
706 |
-
}
|
707 |
-
$parent.find('.br_font_color_set').prev().css('backgroundColor', '#' + $color).colpickSetColor('#' + $color);
|
708 |
-
$parent.find('.br_font_color_set').val( $data['font_color'] );
|
709 |
-
if( ! $data['background'] ) {
|
710 |
-
$color = '000000';
|
711 |
-
} else {
|
712 |
-
$color = $data['background'];
|
713 |
-
}
|
714 |
-
$parent.find('.br_background_set').prev().css('backgroundColor', '#' + $color).colpickSetColor('#' + $color);
|
715 |
-
$parent.find('.br_background_set').val( $data['background'] );
|
716 |
-
$parent.find('.br_border_width_set').val( $data['border_width'] );
|
717 |
-
$parent.find('.br_border_radius_set').val( $data['border_radius'] );
|
718 |
-
$parent.find('.br_size_set').val( $data['size'] );
|
719 |
-
$parent.find('.br_icon_set').val( $data['icon'] );
|
720 |
-
});
|
721 |
-
$(document).on( 'change', '.br_checkbox_radio_settings input, .br_checkbox_radio_settings select', function(event) {
|
722 |
-
if( ! $(this).is( '.br_theme_set_select' ) ) {
|
723 |
-
$(this).parents('.br_checkbox_radio_settings').find('.br_theme_set_select').val('');
|
724 |
-
}
|
725 |
-
});
|
726 |
$(document).on('click', '.berocket_remove_ranges',function(event) {
|
727 |
event.preventDefault();
|
728 |
$(this).parents('.berocket_ranges').remove();
|
729 |
});
|
730 |
-
$(document).on('change', '.br_onew_child_count_select', function() {
|
731 |
-
var child_count = $(this).val();
|
732 |
-
$('.child_onew_childs_settings').hide();
|
733 |
-
$parents = $(this).parents('.berocket_aapf_widget_child_parent_one_widget');
|
734 |
-
for( var i = 1; i <= child_count; i++, $parents ) {
|
735 |
-
$('.child_onew_childs_'+i).show();
|
736 |
-
}
|
737 |
-
});
|
738 |
-
$(document).on('change', '.br_search_box_count', function() {
|
739 |
-
var $parent = $(this).parents('.berocket_aapf_admin_search_box');
|
740 |
-
for(i = 1; i < 11; i++ ) {
|
741 |
-
if( i <= $(this).val() ) {
|
742 |
-
$parent.find('.berocket_search_box_attribute_'+i).show();
|
743 |
-
} else {
|
744 |
-
$parent.find('.berocket_search_box_attribute_'+i).hide();
|
745 |
-
}
|
746 |
-
}
|
747 |
-
});
|
748 |
-
$(document).on('change', '.br_search_box_attribute_type', function() {
|
749 |
-
var $parent = $(this).parents('.br_search_box_attribute_block');
|
750 |
-
$parent.find('.br_search_box_attribute_attribute_block').hide();
|
751 |
-
$parent.find('.br_search_box_attribute_custom_taxonomy_block').hide();
|
752 |
-
if( $(this).val() == 'attribute' ) {
|
753 |
-
$parent.find('.br_search_box_attribute_attribute_block').show();
|
754 |
-
} else if( $(this).val() == 'custom_taxonomy' ) {
|
755 |
-
$parent.find('.br_search_box_attribute_custom_taxonomy_block').show();
|
756 |
-
}
|
757 |
-
});
|
758 |
$(document).on('change', '.berocket_search_link_select', function() {
|
759 |
var $parent = $(this).parents('.berocket_aapf_admin_search_box');
|
760 |
$parent.find('.berocket_search_link').hide();
|
761 |
$parent.find('.berocket_search_link_'+$(this).val()).show();
|
762 |
});
|
763 |
-
$(document).on('change', '.berocket_attributes_number_style', function() {
|
764 |
-
var $parent = $(this).parents('.berocket_attributes_number_style_data');
|
765 |
-
if( $(this).prop('checked') ) {
|
766 |
-
$parent.find('.berocket_attributes_number_styles').show();
|
767 |
-
} else {
|
768 |
-
$parent.find('.berocket_attributes_number_styles').hide();
|
769 |
-
}
|
770 |
-
});
|
771 |
$(document).on('change', '.berocket_seo_friendly_urls', berocket_change_seo_friendly_urls);
|
772 |
$(document).on('change', '.berocket_nice_url', berocket_change_seo_friendly_urls);
|
773 |
$(document).on('change', '.berocket_seo_meta_title', berocket_change_seo_meta_title);
|
@@ -842,54 +218,49 @@ function br_widget_set() {
|
|
842 |
br_widget_setted = false;
|
843 |
}, 400);
|
844 |
}
|
845 |
-
var br_saved_timeout;
|
846 |
-
var br_savin_ajax = false;
|
847 |
(function ($){
|
848 |
$(document).ready( function () {
|
849 |
-
$(document).on('click', '.
|
850 |
event.preventDefault();
|
851 |
-
|
852 |
-
form_data = 'action=aapf_generate_new_filter&'+form_data;
|
853 |
-
$.post(ajaxurl, form_data, function (data) {
|
854 |
-
if( data != 'error' ) {
|
855 |
-
location.href = data;
|
856 |
-
}
|
857 |
-
});
|
858 |
});
|
859 |
-
|
860 |
-
$(document).on('click', '.berocket_create_new', function(event) {
|
861 |
event.preventDefault();
|
862 |
-
|
863 |
-
$(this).parents('.widget-inside, .berocket_simple_filter_creation').append(jQuery('<div class="berocket_aapf_disable_widget"><i class="fa fa-spinner fa-spin"></i></div>'));
|
864 |
-
var data = $(this).data();
|
865 |
-
$.post(ajaxurl, data, function(html) {
|
866 |
-
var parent = $this.parents('form').first();
|
867 |
-
if( $this.parents('.widget').length ) {
|
868 |
-
parent = $this.parents('.widget').first();
|
869 |
-
}
|
870 |
-
parent.css('position', 'relative');
|
871 |
-
parent.append($(html));
|
872 |
-
$this.parents('.widget-inside, .berocket_simple_filter_creation').find('.berocket_aapf_disable_widget .fa-spinner').remove();
|
873 |
-
berocket_add_submit_function_to_element();
|
874 |
-
});
|
875 |
});
|
876 |
-
function
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
889 |
event.preventDefault();
|
890 |
-
|
891 |
-
$(this).
|
892 |
-
berocket_remove_disable_widget($widget);
|
893 |
});
|
894 |
$(document).on('change', '.berocket_new_widget_selectbox', function() {
|
895 |
var edit = $(this).find('option:selected').data('edit');
|
@@ -899,30 +270,7 @@ var br_savin_ajax = false;
|
|
899 |
$(this).next('.berocket_aapf_edit_post_link').hide();
|
900 |
}
|
901 |
});
|
902 |
-
});
|
903 |
-
})(jQuery);
|
904 |
-
function berocket_remove_disable_widget($element) {
|
905 |
-
while( $element.find('.berocket_simple_filter_creation').length < $element.find('.berocket_aapf_disable_widget').length ) {
|
906 |
-
$element.find('.berocket_aapf_disable_widget').last().remove();
|
907 |
-
}
|
908 |
-
}
|
909 |
-
function berocket_semple_creation_single_return($this, data) {
|
910 |
-
var $widget = $this.parent();
|
911 |
-
jQuery('.berocket_new_widget_selectbox.single').append('<option data-name="'+data.name2+'" data-edit="'+data.edit+'" value="'+data.value+'">'+data.name+'</option>');
|
912 |
-
$widget.find('.berocket_new_widget_selectbox.single').val(data.value).trigger('change');
|
913 |
-
$this.remove();
|
914 |
-
berocket_remove_disable_widget($widget);
|
915 |
-
}
|
916 |
-
function berocket_semple_creation_group_return($this, data) {
|
917 |
-
var $widget = $this.parent();
|
918 |
-
jQuery('.berocket_new_widget_selectbox.group').append('<option data-edit="'+data.edit+'" value="'+data.value+'">'+data.name+'</option>');
|
919 |
-
$widget.find('.berocket_new_widget_selectbox.group').val(data.value).trigger('change');
|
920 |
-
$this.remove();
|
921 |
-
berocket_remove_disable_widget($widget);
|
922 |
-
}
|
923 |
//Filters Group
|
924 |
-
(function ($){
|
925 |
-
$(document).ready( function () {
|
926 |
jQuery(document).on('click', '.berocket_add_filter_to_group', function(event) {
|
927 |
event.preventDefault();
|
928 |
if( ! jQuery('.berocket_filter_added_'+jQuery('.berocket_filter_list').val()).length ) {
|
102 |
event.preventDefault();
|
103 |
event.stopPropagation();
|
104 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
$(document).on('change', '.berocket_aapf_widget_sc, .berocket_aapf_style_sb_sc, .berocket_aapf_sb_attributes_sc, .berocket_aapf_childs_sc, .berocket_aapf_include_list_sc', function() {
|
106 |
$(this).data('sc_change', '1');
|
107 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
$('.br_colorpicker_field').each(function (i,o){
|
109 |
if( typeof($(o).colpick) != 'undefined' ) {
|
110 |
$(o).css('backgroundColor', '#'+$(o).data('color'));
|
134 |
$table.find('select').val("");
|
135 |
$table.find('input[type=text]').val("");
|
136 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
br_widget_set();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
$(document).on('click', '.berocket_remove_ranges',function(event) {
|
139 |
event.preventDefault();
|
140 |
$(this).parents('.berocket_ranges').remove();
|
141 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
$(document).on('change', '.berocket_search_link_select', function() {
|
143 |
var $parent = $(this).parents('.berocket_aapf_admin_search_box');
|
144 |
$parent.find('.berocket_search_link').hide();
|
145 |
$parent.find('.berocket_search_link_'+$(this).val()).show();
|
146 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
$(document).on('change', '.berocket_seo_friendly_urls', berocket_change_seo_friendly_urls);
|
148 |
$(document).on('change', '.berocket_nice_url', berocket_change_seo_friendly_urls);
|
149 |
$(document).on('change', '.berocket_seo_meta_title', berocket_change_seo_meta_title);
|
218 |
br_widget_setted = false;
|
219 |
}, 400);
|
220 |
}
|
|
|
|
|
221 |
(function ($){
|
222 |
$(document).ready( function () {
|
223 |
+
$(document).on('click', '.berocket_aapf_font_awesome_icon_select',function(event) {
|
224 |
event.preventDefault();
|
225 |
+
$(this).next('.berocket_aapf_select_icon').show();
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
});
|
227 |
+
$(document).on('click', '.berocket_aapf_select_icon',function(event) {
|
|
|
228 |
event.preventDefault();
|
229 |
+
$(this).hide();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
});
|
231 |
+
$(document).on('click', '.berocket_aapf_select_icon div p i.fa',function(event) {
|
232 |
+
event.preventDefault();
|
233 |
+
$(this).parents('.berocket_aapf_select_icon').hide();
|
234 |
+
});
|
235 |
+
$(document).on('click', '.berocket_aapf_select_icon div',function(event) {
|
236 |
+
event.preventDefault();
|
237 |
+
event.stopPropagation()
|
238 |
+
});
|
239 |
+
$(document).on('click', '.berocket_aapf_select_icon label',function(event) {
|
240 |
+
event.preventDefault();
|
241 |
+
$(this).parents('.berocket_aapf_select_icon').prevAll(".berocket_aapf_icon_text_value").val($(this).find('span').data('value'));
|
242 |
+
$(this).parents('.berocket_aapf_select_icon').prevAll(".berocket_aapf_selected_icon_show").html('<i class="fa '+$(this).find('span').data('value')+'"></i>');
|
243 |
+
$(this).parents('.berocket_aapf_select_icon').hide();
|
244 |
+
});
|
245 |
+
$(document).on('click', '.berocket_aapf_upload_icon', function(e) {
|
246 |
+
e.preventDefault();
|
247 |
+
$p = $(this);
|
248 |
+
var custom_uploader = wp.media({
|
249 |
+
title: 'Select custom Icon',
|
250 |
+
button: {
|
251 |
+
text: 'Set Icon'
|
252 |
+
},
|
253 |
+
multiple: false
|
254 |
+
}).on('select', function() {
|
255 |
+
var attachment = custom_uploader.state().get('selection').first().toJSON();
|
256 |
+
$p.prevAll(".berocket_aapf_selected_icon_show").html('<i class="fa"><image src="'+attachment.url+'" alt=""></i>');
|
257 |
+
$p.prevAll(".berocket_aapf_icon_text_value").val(attachment.url);
|
258 |
+
}).open();
|
259 |
+
});
|
260 |
+
$(document).on('click', '.berocket_aapf_remove_icon',function(event) {
|
261 |
event.preventDefault();
|
262 |
+
$(this).prevAll(".berocket_aapf_icon_text_value").val("");
|
263 |
+
$(this).prevAll(".berocket_aapf_selected_icon_show").html("");
|
|
|
264 |
});
|
265 |
$(document).on('change', '.berocket_new_widget_selectbox', function() {
|
266 |
var edit = $(this).find('option:selected').data('edit');
|
270 |
$(this).next('.berocket_aapf_edit_post_link').hide();
|
271 |
}
|
272 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
//Filters Group
|
|
|
|
|
274 |
jQuery(document).on('click', '.berocket_add_filter_to_group', function(event) {
|
275 |
event.preventDefault();
|
276 |
if( ! jQuery('.berocket_filter_added_'+jQuery('.berocket_filter_list').val()).length ) {
|
assets/admin/js/single_filter_edit.js
CHANGED
@@ -24,7 +24,10 @@ braapf_checked_style_parent;
|
|
24 |
}
|
25 |
function braapf_all_sameas_get(sameas) {
|
26 |
var elements = [];
|
27 |
-
$('#braapf_filter_type').find('option[data-
|
|
|
|
|
|
|
28 |
elements.push($(this).val());
|
29 |
});
|
30 |
return elements;
|
@@ -116,6 +119,7 @@ braapf_checked_style_parent;
|
|
116 |
berocket_show_element_hooked_data.push('#braapf_attribute');
|
117 |
berocket_show_element_hooked_data.push('#braapf_custom_taxonomy');
|
118 |
berocket_show_element_hooked_data.push('#braapf_filter_type');
|
|
|
119 |
var taxonomy_name = false;
|
120 |
var filter_type = $('#braapf_filter_type option:selected');
|
121 |
if( filter_type.val() == filter_type.data('sameas') ) {
|
@@ -129,23 +133,27 @@ braapf_checked_style_parent;
|
|
129 |
}
|
130 |
return taxonomy_name;
|
131 |
}
|
|
|
132 |
braapf_load_color_image_pick = function() {
|
133 |
var taxonomy_name = braapf_get_current_taxonomy_name();
|
134 |
var specific = braapf_current_specific();
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
|
|
|
|
148 |
}
|
|
|
149 |
}
|
150 |
braapf_current_taxonomy_hierarchical = function () {
|
151 |
var taxonoy_name = braapf_get_current_taxonomy_name();
|
@@ -294,6 +302,7 @@ braapf_checked_style_parent;
|
|
294 |
berocket_show_element('.braapf_order_values_by, .braapf_order_values_type, .braapf_parent_product_cat', '{#braapf_filter_type} == !braapf_all_sameas_custom_taxonomy! || {#braapf_filter_type} == !braapf_all_sameas_attribute!');
|
295 |
//REQUIRED
|
296 |
berocket_show_element('.brsbs_required', '{.braapf_widget_type input[type=radio]} == "filter" && (({#braapf_filter_type} == "price" && (!braapf_current_template! == "select" || !braapf_current_template! == "checkbox")) || !braapf_current_specific! == "color" || !braapf_current_specific! == "image" || ( ({#braapf_filter_type} == !braapf_all_sameas_custom_taxonomy! || {#braapf_filter_type} == !braapf_all_sameas_attribute!) && !braapf_current_template! == "datepicker" ) )');
|
|
|
297 |
berocket_show_element('.braapf_widget_color_pick', '!braapf_load_color_image_pick! == true');
|
298 |
//ADDITIONAL
|
299 |
berocket_show_element('.brsbs_additional', '!braapf_any_style_checked! == true');
|
24 |
}
|
25 |
function braapf_all_sameas_get(sameas) {
|
26 |
var elements = [];
|
27 |
+
$('#braapf_filter_type').find('option[data-optionsameas="'+sameas+'"]').each(function(){
|
28 |
+
elements.push($(this).val());
|
29 |
+
});
|
30 |
+
$('#braapf_filter_type').find('option[data-sameas="'+sameas+'"]').not('option[data-optionsameas="'+sameas+'"]').each(function(){
|
31 |
elements.push($(this).val());
|
32 |
});
|
33 |
return elements;
|
119 |
berocket_show_element_hooked_data.push('#braapf_attribute');
|
120 |
berocket_show_element_hooked_data.push('#braapf_custom_taxonomy');
|
121 |
berocket_show_element_hooked_data.push('#braapf_filter_type');
|
122 |
+
jQuery(document).trigger('braapf_get_current_taxonomy_name');
|
123 |
var taxonomy_name = false;
|
124 |
var filter_type = $('#braapf_filter_type option:selected');
|
125 |
if( filter_type.val() == filter_type.data('sameas') ) {
|
133 |
}
|
134 |
return taxonomy_name;
|
135 |
}
|
136 |
+
//COLOR/IMAGE SELECT
|
137 |
braapf_load_color_image_pick = function() {
|
138 |
var taxonomy_name = braapf_get_current_taxonomy_name();
|
139 |
var specific = braapf_current_specific();
|
140 |
+
var filtertype = jQuery('.braapf_filter_type_data *').serialize();
|
141 |
+
filtertype = 'type='+specific+'&'+filtertype;
|
142 |
+
var old_filtertype = $('.braapf_widget_color_pick').data('filtertype');
|
143 |
+
if( filtertype != old_filtertype ) {
|
144 |
+
$('.braapf_widget_color_pick').data('filtertype', filtertype);
|
145 |
+
var data = 'action=berocket_aapf_color_listener&tax_color_name='+taxonomy_name+'&type='+specific+'&'+filtertype;
|
146 |
+
if ( specific == 'color' || specific == 'image' ) {
|
147 |
+
$.post(ajaxurl, data, function(data) {
|
148 |
+
$('.braapf_widget_color_pick').html(data);
|
149 |
+
});
|
150 |
+
return true;
|
151 |
+
} else {
|
152 |
+
$('.braapf_widget_color_pick').text("");
|
153 |
+
return false;
|
154 |
+
}
|
155 |
}
|
156 |
+
return ( specific == 'color' || specific == 'image' );
|
157 |
}
|
158 |
braapf_current_taxonomy_hierarchical = function () {
|
159 |
var taxonoy_name = braapf_get_current_taxonomy_name();
|
302 |
berocket_show_element('.braapf_order_values_by, .braapf_order_values_type, .braapf_parent_product_cat', '{#braapf_filter_type} == !braapf_all_sameas_custom_taxonomy! || {#braapf_filter_type} == !braapf_all_sameas_attribute!');
|
303 |
//REQUIRED
|
304 |
berocket_show_element('.brsbs_required', '{.braapf_widget_type input[type=radio]} == "filter" && (({#braapf_filter_type} == "price" && (!braapf_current_template! == "select" || !braapf_current_template! == "checkbox")) || !braapf_current_specific! == "color" || !braapf_current_specific! == "image" || ( ({#braapf_filter_type} == !braapf_all_sameas_custom_taxonomy! || {#braapf_filter_type} == !braapf_all_sameas_attribute!) && !braapf_current_template! == "datepicker" ) )');
|
305 |
+
$('.braapf_widget_color_pick').data('filtertype', jQuery('.braapf_filter_type_data *').serialize());
|
306 |
berocket_show_element('.braapf_widget_color_pick', '!braapf_load_color_image_pick! == true');
|
307 |
//ADDITIONAL
|
308 |
berocket_show_element('.brsbs_additional', '!braapf_any_style_checked! == true');
|
berocket/includes/updater.php
CHANGED
@@ -215,24 +215,26 @@ if ( ! class_exists( 'BeRocket_updater' ) ) {
|
|
215 |
}
|
216 |
}
|
217 |
|
218 |
-
public static function
|
219 |
-
if ( ! empty( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'berocket_account' ) {
|
220 |
-
return $notices;
|
221 |
-
}
|
222 |
$active_plugin = get_option( 'berocket_key_activated_plugins' );
|
223 |
$active_site_plugin = get_site_option( 'berocket_key_activated_plugins' );
|
224 |
-
|
225 |
if ( ! is_array( $active_plugin ) ) {
|
226 |
$active_plugin = array();
|
227 |
}
|
228 |
-
|
229 |
if ( ! is_array( $active_site_plugin ) ) {
|
230 |
$active_site_plugin = array();
|
231 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
$not_activated_notices = array();
|
234 |
foreach ( self::$plugin_info as $plugin ) {
|
235 |
-
if (
|
236 |
$version_capability = br_get_value_from_array($plugin, array('version_capability'), 15);
|
237 |
if ( $version_capability > 5 && ! in_array($version_capability, array(15, 3, 17)) ) {
|
238 |
$meta_data = '?utm_source=paid_plugin&utm_medium=notice&utm_campaign='.$plugin['plugin_name'];
|
@@ -817,34 +819,37 @@ if ( ! class_exists( 'BeRocket_updater' ) ) {
|
|
817 |
$plugin = wp_unslash( $_REQUEST[ 'plugin' ] );
|
818 |
|
819 |
if ( in_array( $plugin, self::$slugs ) ) {
|
820 |
-
remove_action( 'install_plugins_pre_plugin-information', 'install_plugin_information' );
|
821 |
-
remove_action( 'install_plugins_pre_plugin-information', 'install_plugin_information' );
|
822 |
|
823 |
$plugin_id = array_search( $plugin, self::$slugs );
|
824 |
-
$
|
825 |
-
|
826 |
-
if ( $
|
827 |
-
|
828 |
-
$
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
)
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
|
|
|
|
|
|
|
|
|
|
843 |
}
|
844 |
-
}
|
845 |
|
846 |
-
|
847 |
-
|
|
|
848 |
}
|
849 |
}
|
850 |
|
@@ -1086,6 +1091,17 @@ if ( ! class_exists( 'BeRocket_updater' ) ) {
|
|
1086 |
}
|
1087 |
return $options;
|
1088 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1089 |
}
|
1090 |
|
1091 |
BeRocket_updater::init();
|
215 |
}
|
216 |
}
|
217 |
|
218 |
+
public static function is_plugin_paid_active($plugin_id) {
|
|
|
|
|
|
|
219 |
$active_plugin = get_option( 'berocket_key_activated_plugins' );
|
220 |
$active_site_plugin = get_site_option( 'berocket_key_activated_plugins' );
|
|
|
221 |
if ( ! is_array( $active_plugin ) ) {
|
222 |
$active_plugin = array();
|
223 |
}
|
|
|
224 |
if ( ! is_array( $active_site_plugin ) ) {
|
225 |
$active_site_plugin = array();
|
226 |
}
|
227 |
+
return ! empty( $active_plugin[ $plugin_id ] ) || ! empty( $active_site_plugin[ $plugin_id ] );
|
228 |
+
}
|
229 |
+
|
230 |
+
public static function berocket_display_additional_notices( $notices ) {
|
231 |
+
if ( ! empty( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'berocket_account' ) {
|
232 |
+
return $notices;
|
233 |
+
}
|
234 |
|
235 |
$not_activated_notices = array();
|
236 |
foreach ( self::$plugin_info as $plugin ) {
|
237 |
+
if ( ! self::is_plugin_paid_active($plugin[ 'id' ]) ) {
|
238 |
$version_capability = br_get_value_from_array($plugin, array('version_capability'), 15);
|
239 |
if ( $version_capability > 5 && ! in_array($version_capability, array(15, 3, 17)) ) {
|
240 |
$meta_data = '?utm_source=paid_plugin&utm_medium=notice&utm_campaign='.$plugin['plugin_name'];
|
819 |
$plugin = wp_unslash( $_REQUEST[ 'plugin' ] );
|
820 |
|
821 |
if ( in_array( $plugin, self::$slugs ) ) {
|
|
|
|
|
822 |
|
823 |
$plugin_id = array_search( $plugin, self::$slugs );
|
824 |
+
$plugin_data = self::get_plugin_data($plugin_id);
|
825 |
+
$version_capability = br_get_value_from_array($plugin_data, array('version_capability'), 15);
|
826 |
+
if( self::is_plugin_paid_active($plugin_id) || ($version_capability > 5 && ! in_array($version_capability, array(15, 3, 17))) ) {
|
827 |
+
remove_action( 'install_plugins_pre_plugin-information', 'install_plugin_information' );
|
828 |
+
$plugin_info = get_transient( 'brplugin_info_' . $plugin_id );
|
829 |
+
|
830 |
+
if ( $plugin_info == false ) {
|
831 |
+
$url = BeRocket_update_path . 'main/update_info/' . $plugin_id;
|
832 |
+
$site_url = get_site_url();
|
833 |
+
$response = wp_remote_post( $url, array(
|
834 |
+
'body' => array(
|
835 |
+
'url' => $site_url
|
836 |
+
),
|
837 |
+
'method' => 'POST',
|
838 |
+
'timeout' => 30,
|
839 |
+
'redirection' => 5,
|
840 |
+
'blocking' => true,
|
841 |
+
'sslverify' => false
|
842 |
+
) );
|
843 |
+
|
844 |
+
if ( ! is_wp_error( $response ) ) {
|
845 |
+
$plugin_info = wp_remote_retrieve_body( $response );
|
846 |
+
set_transient( 'brplugin_info_' . $plugin_id, $plugin_info, 600 );
|
847 |
+
}
|
848 |
}
|
|
|
849 |
|
850 |
+
echo $plugin_info;
|
851 |
+
die;
|
852 |
+
}
|
853 |
}
|
854 |
}
|
855 |
|
1091 |
}
|
1092 |
return $options;
|
1093 |
}
|
1094 |
+
public static function get_plugin_data($plugin_id) {
|
1095 |
+
$data = array();
|
1096 |
+
if( is_array(self::$plugin_info) ) {
|
1097 |
+
foreach(self::$plugin_info as $plugin) {
|
1098 |
+
if( $plugin['id'] == $plugin_id ) {
|
1099 |
+
return $plugin;
|
1100 |
+
}
|
1101 |
+
}
|
1102 |
+
}
|
1103 |
+
return $data;
|
1104 |
+
}
|
1105 |
}
|
1106 |
|
1107 |
BeRocket_updater::init();
|
includes/currency-exchange.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if( ! class_exists('BeRocket_AAPF_currency_exchange') ) {
|
3 |
+
class BeRocket_AAPF_currency_exchange {
|
4 |
+
function __construct() {
|
5 |
+
add_filter('bapf_uparse_price_for_filtering_convert', array($this, 'convert_price'));
|
6 |
+
}
|
7 |
+
function convert_price($price) {
|
8 |
+
global $woocommerce_wpml;
|
9 |
+
if( ! empty($woocommerce_wpml) && is_object($woocommerce_wpml)
|
10 |
+
&& property_exists($woocommerce_wpml, 'multi_currency') && is_object($woocommerce_wpml->multi_currency)
|
11 |
+
&& property_exists($woocommerce_wpml->multi_currency, 'prices') && is_object($woocommerce_wpml->multi_currency->prices)
|
12 |
+
&& method_exists($woocommerce_wpml->multi_currency->prices, 'unconvert_price_amount') ) {
|
13 |
+
$price = $woocommerce_wpml->multi_currency->prices->unconvert_price_amount($price);
|
14 |
+
}
|
15 |
+
if( function_exists('wmc_get_default_price') ) {
|
16 |
+
$price = wmc_get_default_price($price);
|
17 |
+
}
|
18 |
+
if( class_exists('BeRocket_AAPF_compat_WCPBC') ) {
|
19 |
+
$price = BeRocket_AAPF_compat_WCPBC::to_base_rate($price);
|
20 |
+
}
|
21 |
+
return $price;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
new BeRocket_AAPF_currency_exchange();
|
25 |
+
}
|
includes/custom_post.php
CHANGED
@@ -206,8 +206,6 @@ class BeRocket_AAPF_single_filter extends BeRocket_custom_post_class {
|
|
206 |
}
|
207 |
add_action('admin_head', array($this, 'admin_head'), 20);
|
208 |
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 20);
|
209 |
-
add_filter('berocket_aapf_load_simple_filter_creation_single', array($this, 'load_simple_filter_creation'));
|
210 |
-
add_filter('berocket_aapf_save_simple_filter_creation_single', array($this, 'save_simple_filter_creation'));
|
211 |
add_filter( 'berocket_admin_filter_types_by_attr', array($this, 'admin_filter_types_by_attr'), 10, 2 );
|
212 |
}
|
213 |
public function admin_enqueue_scripts() {
|
@@ -220,23 +218,6 @@ class BeRocket_AAPF_single_filter extends BeRocket_custom_post_class {
|
|
220 |
}
|
221 |
}
|
222 |
}
|
223 |
-
public function load_simple_filter_creation($html) {
|
224 |
-
$html = '<form data-function="berocket_semple_creation_single_return" method="POST" action="'.admin_url('admin-ajax.php').'" class="berocket_simple_filter_creation">';
|
225 |
-
$html .= '<input type="hidden" name="action" value="berocket_aapf_save_simple_filter_creation">';
|
226 |
-
$html .= '<input type="hidden" name="type" value="single">';
|
227 |
-
$instance = $this->get_option(0);
|
228 |
-
$post_name = $this->post_name;
|
229 |
-
include_once(AAPF_TEMPLATE_PATH . 'single_filter/single_settings_elements.php');
|
230 |
-
ob_start();
|
231 |
-
include AAPF_TEMPLATE_PATH . "filter_post_simple.php";
|
232 |
-
$html .= ob_get_clean();
|
233 |
-
$html .= '<div style="clear:both;height:50px;"></div><div class="berocket_simple_creation_buttons">';
|
234 |
-
$html .= '<button class="button button-primary">Create</button>';
|
235 |
-
$html .= '<button class="button berocket_simple_close" type="button">Close</button>';
|
236 |
-
$html .= '</div>';
|
237 |
-
$html .= '</form>';
|
238 |
-
return $html;
|
239 |
-
}
|
240 |
function admin_filter_types_by_attr($vars, $type = 'main') {
|
241 |
list($berocket_admin_filter_types, $berocket_admin_filter_types_by_attr) = $vars;
|
242 |
if( $type == 'simple' ) {
|
@@ -255,33 +236,6 @@ class BeRocket_AAPF_single_filter extends BeRocket_custom_post_class {
|
|
255 |
}
|
256 |
return array($berocket_admin_filter_types, $berocket_admin_filter_types_by_attr);
|
257 |
}
|
258 |
-
public function save_simple_filter_creation($data) {
|
259 |
-
$post_data = $_POST[$this->post_name];
|
260 |
-
$title = $post_data['filter_title'] = $_POST['title'];
|
261 |
-
$post_data = berocket_sanitize_array($post_data);
|
262 |
-
$post_data['widget_type'] = 'filter';
|
263 |
-
$convert_to_styles = array(
|
264 |
-
'checkbox' => array(
|
265 |
-
'style' => 'checkbox'
|
266 |
-
),
|
267 |
-
'radio' => array(
|
268 |
-
'style' => 'checkbox',
|
269 |
-
'single_selection' => '1'
|
270 |
-
),
|
271 |
-
'select' => array(
|
272 |
-
'style' => 'select',
|
273 |
-
'single_selection' => '1'
|
274 |
-
),
|
275 |
-
'slider' => array(
|
276 |
-
'style' => 'slider'
|
277 |
-
),
|
278 |
-
);
|
279 |
-
if( ! empty($post_data['type']) && ! empty($convert_to_styles[$post_data['type']]) ) {
|
280 |
-
$post_data = array_merge($post_data, $convert_to_styles[$post_data['type']]);
|
281 |
-
}
|
282 |
-
$post_id = $this->create_new_post(array('post_title' => $title), $post_data);
|
283 |
-
return array('value' => $post_id, 'name' => $title.' (ID:'.$post_id.')', 'name2' => $title, 'edit' => get_edit_post_link($post_id));
|
284 |
-
}
|
285 |
public function admin_head() {
|
286 |
$screen = get_current_screen();
|
287 |
if( berocket_isset($screen, 'id') == 'widgets' ) {
|
@@ -584,9 +538,11 @@ class BeRocket_AAPF_single_filter extends BeRocket_custom_post_class {
|
|
584 |
}
|
585 |
}
|
586 |
}
|
587 |
-
if( ! empty($_POST['br_widget_color']) and (
|
588 |
$instance['use_value_with_color'] = ! empty($instance['use_value_with_color']);
|
589 |
-
if( $
|
|
|
|
|
590 |
$_POST['tax_color_name'] = 'product_tag';
|
591 |
} elseif( $instance['filter_type'] == 'product_cat' ) {
|
592 |
$_POST['tax_color_name'] = 'product_cat';
|
@@ -597,14 +553,10 @@ class BeRocket_AAPF_single_filter extends BeRocket_custom_post_class {
|
|
597 |
$style = $instance['style'];
|
598 |
$all_styles = get_option('BeRocket_AAPF_getall_Template_Styles');
|
599 |
if( is_array($all_styles) && isset($all_styles[$style]) && ! empty($all_styles[$style]['specific']) ) {
|
600 |
-
$
|
601 |
-
$_POST['tax_color_set'] = $_POST['br_widget_color'];
|
602 |
-
BeRocket_AAPF_Widget_functions::color_listener();
|
603 |
}
|
604 |
} elseif( ! empty($instance['type']) && in_array($instance['type'], array('color', 'image')) ) {
|
605 |
-
$_POST['
|
606 |
-
$_POST['tax_color_set'] = $_POST['br_widget_color'];
|
607 |
-
BeRocket_AAPF_Widget_functions::color_listener();
|
608 |
}
|
609 |
}
|
610 |
$setup_wizard = get_option('berocket_aapf_filters_setup_wizard_list');
|
@@ -689,30 +641,6 @@ class BeRocket_AAPF_group_filters extends BeRocket_custom_post_class {
|
|
689 |
$this->add_meta_box('information_faq', __( 'Information', 'BeRocket_AJAX_domain' ), false, 'side');
|
690 |
parent::__construct();
|
691 |
add_shortcode( 'br_filters_group', array( $this, 'shortcode' ) );
|
692 |
-
add_filter('berocket_aapf_load_simple_filter_creation_group', array($this, 'load_simple_filter_creation'));
|
693 |
-
add_filter('berocket_aapf_save_simple_filter_creation_group', array($this, 'save_simple_filter_creation'));
|
694 |
-
}
|
695 |
-
public function load_simple_filter_creation($html) {
|
696 |
-
$html = '<form data-function="berocket_semple_creation_group_return" method="POST" action="'.admin_url('admin-ajax.php').'" class="berocket_simple_filter_creation">';
|
697 |
-
$html .= '<input type="hidden" name="action" value="berocket_aapf_save_simple_filter_creation">';
|
698 |
-
$html .= '<input type="hidden" name="type" value="group">';
|
699 |
-
$instance = $this->get_option(0);
|
700 |
-
$post_name = $this->post_name;
|
701 |
-
ob_start();
|
702 |
-
include AAPF_TEMPLATE_PATH . "filters_group_simple.php";
|
703 |
-
$html .= ob_get_clean();
|
704 |
-
$html .= '<div style="clear:both;height:50px;"></div><div class="berocket_simple_creation_buttons">';
|
705 |
-
$html .= '<button class="button button-primary">Create</button>';
|
706 |
-
$html .= '<button class="button berocket_simple_close" type="button">Close</button>';
|
707 |
-
$html .= '</div>';
|
708 |
-
$html .= '</form>';
|
709 |
-
return $html;
|
710 |
-
}
|
711 |
-
public function save_simple_filter_creation($data) {
|
712 |
-
$title = $_POST['title'];
|
713 |
-
$post_data = berocket_sanitize_array($_POST[$this->post_name]);
|
714 |
-
$post_id = $this->create_new_post(array('post_title' => $title), $post_data);
|
715 |
-
return array('value' => $post_id, 'name' => $title.' (ID:'.$post_id.')', 'name2' => $title, 'edit' => get_edit_post_link($post_id));
|
716 |
}
|
717 |
public function init_conditions() {
|
718 |
$this->conditions = new BeRocket_conditions_AAPF($this->post_name.'[data]', $this->hook_name, array(
|
206 |
}
|
207 |
add_action('admin_head', array($this, 'admin_head'), 20);
|
208 |
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 20);
|
|
|
|
|
209 |
add_filter( 'berocket_admin_filter_types_by_attr', array($this, 'admin_filter_types_by_attr'), 10, 2 );
|
210 |
}
|
211 |
public function admin_enqueue_scripts() {
|
218 |
}
|
219 |
}
|
220 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
function admin_filter_types_by_attr($vars, $type = 'main') {
|
222 |
list($berocket_admin_filter_types, $berocket_admin_filter_types_by_attr) = $vars;
|
223 |
if( $type == 'simple' ) {
|
236 |
}
|
237 |
return array($berocket_admin_filter_types, $berocket_admin_filter_types_by_attr);
|
238 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
public function admin_head() {
|
240 |
$screen = get_current_screen();
|
241 |
if( berocket_isset($screen, 'id') == 'widgets' ) {
|
538 |
}
|
539 |
}
|
540 |
}
|
541 |
+
if( ! empty($_POST['br_widget_color']) and in_array($instance['filter_type'], apply_filters('berocket_filter_br_widget_color_types', array('attribute', 'custom_taxonomy', 'tag', 'product_cat'))) ) {
|
542 |
$instance['use_value_with_color'] = ! empty($instance['use_value_with_color']);
|
543 |
+
if( ( $attribute_temp = apply_filters('berocket_filter_br_widget_color_name', null, $instance, $post_id, $post) ) !== null ) {
|
544 |
+
$_POST['tax_color_name'] = $attribute_temp;
|
545 |
+
} elseif( $instance['filter_type'] == 'tag' ) {
|
546 |
$_POST['tax_color_name'] = 'product_tag';
|
547 |
} elseif( $instance['filter_type'] == 'product_cat' ) {
|
548 |
$_POST['tax_color_name'] = 'product_cat';
|
553 |
$style = $instance['style'];
|
554 |
$all_styles = get_option('BeRocket_AAPF_getall_Template_Styles');
|
555 |
if( is_array($all_styles) && isset($all_styles[$style]) && ! empty($all_styles[$style]['specific']) ) {
|
556 |
+
BeRocket_AAPF_Widget_functions::color_image_save($instance, $all_styles[$style]['specific'], $_POST['br_widget_color']);
|
|
|
|
|
557 |
}
|
558 |
} elseif( ! empty($instance['type']) && in_array($instance['type'], array('color', 'image')) ) {
|
559 |
+
BeRocket_AAPF_Widget_functions::color_image_save($instance, $_POST['br_widget_color'], $_POST['br_widget_color']);
|
|
|
|
|
560 |
}
|
561 |
}
|
562 |
$setup_wizard = get_option('berocket_aapf_filters_setup_wizard_list');
|
641 |
$this->add_meta_box('information_faq', __( 'Information', 'BeRocket_AJAX_domain' ), false, 'side');
|
642 |
parent::__construct();
|
643 |
add_shortcode( 'br_filters_group', array( $this, 'shortcode' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
644 |
}
|
645 |
public function init_conditions() {
|
646 |
$this->conditions = new BeRocket_conditions_AAPF($this->post_name.'[data]', $this->hook_name, array(
|
includes/divi/modules/filternext/filternext.php
CHANGED
@@ -25,10 +25,6 @@ class ET_Builder_Module_braapf_filter_next extends ET_Builder_Module {
|
|
25 |
add_filter('berocket_aapf_wcshortcode_is_filtering', array($this, 'enable_filtering'));
|
26 |
return '';
|
27 |
}
|
28 |
-
|
29 |
-
protected function _add_additional_border_fields() {
|
30 |
-
$this->advanced_options["border"]['css'] = array();
|
31 |
-
}
|
32 |
function enable_filtering($enabled) {
|
33 |
remove_filter('berocket_aapf_wcshortcode_is_filtering', array($this, 'enable_filtering'));
|
34 |
return true;
|
25 |
add_filter('berocket_aapf_wcshortcode_is_filtering', array($this, 'enable_filtering'));
|
26 |
return '';
|
27 |
}
|
|
|
|
|
|
|
|
|
28 |
function enable_filtering($enabled) {
|
29 |
remove_filter('berocket_aapf_wcshortcode_is_filtering', array($this, 'enable_filtering'));
|
30 |
return true;
|
includes/filters/get_terms.php
CHANGED
@@ -48,6 +48,10 @@ class BeRocket_AAPF_get_terms {
|
|
48 |
'disable_recount' => false,
|
49 |
'disable_hide_empty' => false,
|
50 |
), $additional), $args);
|
|
|
|
|
|
|
|
|
51 |
if( empty($args['taxonomy']) || is_array($args['taxonomy']) ) {
|
52 |
return get_terms($args);
|
53 |
}
|
48 |
'disable_recount' => false,
|
49 |
'disable_hide_empty' => false,
|
50 |
), $additional), $args);
|
51 |
+
$terms = apply_filters('berocket_aapf_get_terms_filter_before', false, $args, $additional);
|
52 |
+
if( $terms !== false ) {
|
53 |
+
return $terms;
|
54 |
+
}
|
55 |
if( empty($args['taxonomy']) || is_array($args['taxonomy']) ) {
|
56 |
return get_terms($args);
|
57 |
}
|
includes/functions.php
CHANGED
@@ -1444,7 +1444,7 @@ if( ! function_exists('br_get_taxonomy_hierarchy') ) {
|
|
1444 |
$hierarchy_data['child'][$parent_list_id] = $parent_list_array;
|
1445 |
}
|
1446 |
}
|
1447 |
-
update_option( apply_filters('br_aapf_md5_cache_text', 'br_get_taxonomy_hierarchy_'.$args['taxonomy']), $hierarchy_data );
|
1448 |
}
|
1449 |
if( is_array($hierarchy_data) && isset($hierarchy_data[$args['return']]) ) {
|
1450 |
return $hierarchy_data[$args['return']];
|
@@ -1813,3 +1813,12 @@ if( ! function_exists('braapf_get_data_taxonomy_from_post') ) {
|
|
1813 |
return $attribute;
|
1814 |
}
|
1815 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1444 |
$hierarchy_data['child'][$parent_list_id] = $parent_list_array;
|
1445 |
}
|
1446 |
}
|
1447 |
+
update_option( apply_filters('br_aapf_md5_cache_text', 'br_get_taxonomy_hierarchy_'.$args['taxonomy']), $hierarchy_data, false );
|
1448 |
}
|
1449 |
if( is_array($hierarchy_data) && isset($hierarchy_data[$args['return']]) ) {
|
1450 |
return $hierarchy_data[$args['return']];
|
1813 |
return $attribute;
|
1814 |
}
|
1815 |
}
|
1816 |
+
if( ! function_exists('berocket_term_get_metadata') ) {
|
1817 |
+
function berocket_term_get_metadata($term, $color_name) {
|
1818 |
+
$color_meta = apply_filters('berocket_aapf_color_term_select_metadata', false, $term, $color_name);
|
1819 |
+
if( $color_meta === false ) {
|
1820 |
+
$color_meta = get_metadata('berocket_term', $term->term_id, $color_name);
|
1821 |
+
}
|
1822 |
+
return $color_meta;
|
1823 |
+
}
|
1824 |
+
}
|
includes/new_widget.php
CHANGED
@@ -140,7 +140,6 @@ class BeRocket_new_AAPF_Widget extends WP_Widget
|
|
140 |
?>
|
141 |
<a target="_blank" class="berocket_aapf_edit_post_link" href="<?php echo $edit_link_current; ?>"<?php if( empty($edit_link_current) ) echo ' style="display: none;"'; ?>><?php _e('Edit', 'BeRocket_AJAX_domain'); ?></a>
|
142 |
</p>
|
143 |
-
<a class="button berocket_create_new" data-type="group" data-action="berocket_aapf_load_simple_filter_creation" href="#"><?php _e('Create Group', 'BeRocket_AJAX_domain'); ?></a>
|
144 |
<?php
|
145 |
}
|
146 |
}
|
@@ -225,7 +224,7 @@ class BeRocket_new_AAPF_Widget_single extends WP_Widget
|
|
225 |
}
|
226 |
$additional_class_esc = implode(' ', $additional_class);
|
227 |
$additional_class_esc = esc_html($additional_class_esc);
|
228 |
-
echo '<div class="' . $additional_class_esc . '" data-id="' . esc_html($filter_id) . '">';
|
229 |
} else {
|
230 |
$additional_class_esc = implode(' ', $additional_class);
|
231 |
$additional_class_esc = esc_html($additional_class_esc);
|
@@ -320,7 +319,6 @@ class BeRocket_new_AAPF_Widget_single extends WP_Widget
|
|
320 |
?>
|
321 |
<a target="_blank" class="berocket_aapf_edit_post_link" href="<?php echo $edit_link_current; ?>"<?php if( empty($edit_link_current) ) echo ' style="display: none;"'; ?>><?php _e('Edit', 'BeRocket_AJAX_domain'); ?></a>
|
322 |
</p>
|
323 |
-
<a class="button berocket_create_new" data-type="single" data-action="berocket_aapf_load_simple_filter_creation" href="#"><?php _e('Create Filter', 'BeRocket_AJAX_domain'); ?></a>
|
324 |
<?php
|
325 |
}
|
326 |
}
|
140 |
?>
|
141 |
<a target="_blank" class="berocket_aapf_edit_post_link" href="<?php echo $edit_link_current; ?>"<?php if( empty($edit_link_current) ) echo ' style="display: none;"'; ?>><?php _e('Edit', 'BeRocket_AJAX_domain'); ?></a>
|
142 |
</p>
|
|
|
143 |
<?php
|
144 |
}
|
145 |
}
|
224 |
}
|
225 |
$additional_class_esc = implode(' ', $additional_class);
|
226 |
$additional_class_esc = esc_html($additional_class_esc);
|
227 |
+
echo '<div class="' . $additional_class_esc . '" data-id="' . esc_html($filter_id) . '" style="'.htmlentities(br_get_value_from_array($args, 'inline_style')).'"'.htmlentities(br_get_value_from_array($args, 'additional_data_inline')).'>';
|
228 |
} else {
|
229 |
$additional_class_esc = implode(' ', $additional_class);
|
230 |
$additional_class_esc = esc_html($additional_class_esc);
|
319 |
?>
|
320 |
<a target="_blank" class="berocket_aapf_edit_post_link" href="<?php echo $edit_link_current; ?>"<?php if( empty($edit_link_current) ) echo ' style="display: none;"'; ?>><?php _e('Edit', 'BeRocket_AJAX_domain'); ?></a>
|
321 |
</p>
|
|
|
322 |
<?php
|
323 |
}
|
324 |
}
|
includes/template_styles_preview.php
CHANGED
@@ -60,7 +60,7 @@ if( ! class_exists('BeRocket_AAPF_styles_preview_color') ) {
|
|
60 |
}
|
61 |
function template_single_item($template, $term, $i, $berocket_query_var_title) {
|
62 |
$template = parent::template_single_item($template, $term, $i, $berocket_query_var_title);
|
63 |
-
$berocket_term =
|
64 |
$meta_color = br_get_value_from_array($berocket_term, 0, '');
|
65 |
$meta_color = str_replace('#', '', $meta_color);
|
66 |
$template['content']['checkbox'] = BeRocket_AAPF_dynamic_data_template::create_element_arrays($template['content']['checkbox'], array('attributes', 'style'));
|
@@ -127,7 +127,7 @@ if( ! class_exists('BeRocket_AAPF_styles_preview_image') ) {
|
|
127 |
}
|
128 |
function template_single_item($template, $term, $i, $berocket_query_var_title) {
|
129 |
$template = parent::template_single_item($template, $term, $i, $berocket_query_var_title);
|
130 |
-
$berocket_term =
|
131 |
$meta_image = br_get_value_from_array($berocket_term, 0, '');
|
132 |
$template['content']['checkbox'] = BeRocket_AAPF_dynamic_data_template::create_element_arrays($template['content']['checkbox'], array('attributes', 'style'));
|
133 |
$template['content']['checkbox']['attributes']['style']['display'] = 'display:none;';
|
60 |
}
|
61 |
function template_single_item($template, $term, $i, $berocket_query_var_title) {
|
62 |
$template = parent::template_single_item($template, $term, $i, $berocket_query_var_title);
|
63 |
+
$berocket_term = berocket_term_get_metadata($term, 'color');
|
64 |
$meta_color = br_get_value_from_array($berocket_term, 0, '');
|
65 |
$meta_color = str_replace('#', '', $meta_color);
|
66 |
$template['content']['checkbox'] = BeRocket_AAPF_dynamic_data_template::create_element_arrays($template['content']['checkbox'], array('attributes', 'style'));
|
127 |
}
|
128 |
function template_single_item($template, $term, $i, $berocket_query_var_title) {
|
129 |
$template = parent::template_single_item($template, $term, $i, $berocket_query_var_title);
|
130 |
+
$berocket_term = berocket_term_get_metadata($term, 'image');
|
131 |
$meta_image = br_get_value_from_array($berocket_term, 0, '');
|
132 |
$template['content']['checkbox'] = BeRocket_AAPF_dynamic_data_template::create_element_arrays($template['content']['checkbox'], array('attributes', 'style'));
|
133 |
$template['content']['checkbox']['attributes']['style']['display'] = 'display:none;';
|
includes/url-parse.php
CHANGED
@@ -465,7 +465,6 @@ if( ! class_exists('BeRocket_url_parse_page') ) {
|
|
465 |
$data = $this->generate_posts_not_in($data);
|
466 |
$data = $this->generate_custom_query($data);
|
467 |
$data = $this->data_generate_global_filtering($data);
|
468 |
-
|
469 |
$data = apply_filters('bapf_uparse_parse_line_modify', $data, $link);
|
470 |
if( BeRocket_AAPF::$debug_mode ) {
|
471 |
if( empty(BeRocket_AAPF::$error_log['url_parse_data']) || ! is_array(BeRocket_AAPF::$error_log['url_parse_data']) ) {
|
@@ -1304,39 +1303,49 @@ if( ! class_exists('BeRocket_url_parse_page') ) {
|
|
1304 |
$result = $terms;
|
1305 |
}
|
1306 |
if(! empty($args['fields'])) {
|
1307 |
-
$
|
1308 |
-
foreach($result as $term) {
|
1309 |
-
switch($args['fields']) {
|
1310 |
-
case 'ids':
|
1311 |
-
$terms[] = $term->term_id;
|
1312 |
-
break;
|
1313 |
-
case 'names':
|
1314 |
-
$terms[] = $term->name;
|
1315 |
-
break;
|
1316 |
-
case 'count':
|
1317 |
-
$terms[] = $term->count;
|
1318 |
-
break;
|
1319 |
-
case 'id=>parent':
|
1320 |
-
$terms[$term->term_id] = $term->parent;
|
1321 |
-
break;
|
1322 |
-
case 'id=>slug':
|
1323 |
-
$terms[$term->term_id] = $term->slug;
|
1324 |
-
break;
|
1325 |
-
case 'id=>name':
|
1326 |
-
$terms[$term->term_id] = $term->name;
|
1327 |
-
break;
|
1328 |
-
default:
|
1329 |
-
$terms[] = $term;
|
1330 |
-
}
|
1331 |
-
}
|
1332 |
-
$result = $terms;
|
1333 |
}
|
1334 |
return $result;
|
1335 |
}
|
1336 |
}
|
1337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1338 |
return $terms;
|
1339 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1340 |
public function func_get_terms_slug_id($taxonomy) {
|
1341 |
$terms_data = br_get_cache($taxonomy, 'bapf_uparse_get_terms');
|
1342 |
$md5 = $this->get_taxonomy_md5();
|
@@ -1392,4 +1401,4 @@ if( ! class_exists('BeRocket_url_parse_page') ) {
|
|
1392 |
}
|
1393 |
}
|
1394 |
new BeRocket_url_parse_page();
|
1395 |
-
}
|
465 |
$data = $this->generate_posts_not_in($data);
|
466 |
$data = $this->generate_custom_query($data);
|
467 |
$data = $this->data_generate_global_filtering($data);
|
|
|
468 |
$data = apply_filters('bapf_uparse_parse_line_modify', $data, $link);
|
469 |
if( BeRocket_AAPF::$debug_mode ) {
|
470 |
if( empty(BeRocket_AAPF::$error_log['url_parse_data']) || ! is_array(BeRocket_AAPF::$error_log['url_parse_data']) ) {
|
1303 |
$result = $terms;
|
1304 |
}
|
1305 |
if(! empty($args['fields'])) {
|
1306 |
+
$result = $this->get_correct_field($result, $args['fields']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1307 |
}
|
1308 |
return $result;
|
1309 |
}
|
1310 |
}
|
1311 |
+
if( ! empty($args['fields']) ) {
|
1312 |
+
$fields = $args['fields'];
|
1313 |
+
unset($args['fields']);
|
1314 |
+
}
|
1315 |
+
$terms = berocket_aapf_get_terms( $args, array('hierarchical' => true, 'disable_recount' => true, 'disable_hide_empty' => true) );
|
1316 |
+
if( isset($fields) ) {
|
1317 |
+
$terms = $this->get_correct_field($terms, $fields);
|
1318 |
+
}
|
1319 |
return $terms;
|
1320 |
}
|
1321 |
+
public function get_correct_field($terms, $field) {
|
1322 |
+
$result = array();
|
1323 |
+
foreach($terms as $term) {
|
1324 |
+
switch($field) {
|
1325 |
+
case 'ids':
|
1326 |
+
$result[] = $term->term_id;
|
1327 |
+
break;
|
1328 |
+
case 'names':
|
1329 |
+
$result[] = $term->name;
|
1330 |
+
break;
|
1331 |
+
case 'count':
|
1332 |
+
$result[] = $term->count;
|
1333 |
+
break;
|
1334 |
+
case 'id=>parent':
|
1335 |
+
$result[$term->term_id] = $term->parent;
|
1336 |
+
break;
|
1337 |
+
case 'id=>slug':
|
1338 |
+
$result[$term->term_id] = $term->slug;
|
1339 |
+
break;
|
1340 |
+
case 'id=>name':
|
1341 |
+
$result[$term->term_id] = $term->name;
|
1342 |
+
break;
|
1343 |
+
default:
|
1344 |
+
$result[] = $term;
|
1345 |
+
}
|
1346 |
+
}
|
1347 |
+
return $result;
|
1348 |
+
}
|
1349 |
public function func_get_terms_slug_id($taxonomy) {
|
1350 |
$terms_data = br_get_cache($taxonomy, 'bapf_uparse_get_terms');
|
1351 |
$md5 = $this->get_taxonomy_md5();
|
1401 |
}
|
1402 |
}
|
1403 |
new BeRocket_url_parse_page();
|
1404 |
+
}
|
includes/widget_functions.php
CHANGED
@@ -5,6 +5,7 @@ class BeRocket_AAPF_Widget_functions {
|
|
5 |
function __construct() {
|
6 |
add_filter('berocket_query_var_title_before_widget', array($this, 'apply_price_slider'), 10, 5);
|
7 |
add_filter('berocket_aapf_is_filtered_page_check', array($this, 'is_filtered_page_check'), 10, 1);
|
|
|
8 |
}
|
9 |
function is_filtered_page_check($filtered) {
|
10 |
if( ! empty($_GET['s']) ) {
|
@@ -12,6 +13,23 @@ class BeRocket_AAPF_Widget_functions {
|
|
12 |
}
|
13 |
return $filtered;
|
14 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
public static function br_widget_ajax_set() {
|
16 |
if ( ( is_plugin_active( 'woocommerce/woocommerce.php' ) || is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) && br_get_woocommerce_version() >= 2.1 ) {
|
17 |
add_action( 'wp_ajax_berocket_aapf_color_listener', array( __CLASS__, 'color_listener' ) );
|
@@ -139,60 +157,16 @@ class BeRocket_AAPF_Widget_functions {
|
|
139 |
}
|
140 |
|
141 |
public static function color_listener() {
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
if( isset( $_POST ['tax_color_set'] ) ) {
|
146 |
-
if ( current_user_can( 'manage_woocommerce' ) ) {
|
147 |
-
foreach( $_POST['tax_color_set'] as $key => $value ) {
|
148 |
-
if( $_POST['type'] == 'color' ) {
|
149 |
-
foreach($value as $term_key => $term_val) {
|
150 |
-
if( !empty($term_val) ) {
|
151 |
-
update_metadata( 'berocket_term', $term_key, $key, $term_val );
|
152 |
-
} else {
|
153 |
-
delete_metadata( 'berocket_term', $term_key, $key );
|
154 |
-
}
|
155 |
-
}
|
156 |
-
} else {
|
157 |
-
update_metadata( 'berocket_term', $key, $_POST['type'], $value );
|
158 |
-
}
|
159 |
-
}
|
160 |
-
unset( $_POST['tax_color_set'] );
|
161 |
-
}
|
162 |
-
} else {
|
163 |
-
self::color_list_view( $_POST['type'], $_POST['tax_color_name'], true );
|
164 |
-
wp_die();
|
165 |
-
}
|
166 |
-
}
|
167 |
-
|
168 |
-
public static function color_list_view( $type, $taxonomy_name, $load_script = false ) {
|
169 |
-
$terms = berocket_aapf_get_terms( array( 'taxonomy' => $taxonomy_name, 'hide_empty' => false ), array('hierarchical' => true, 'disable_recount' => true, 'disable_hide_empty' => true) );
|
170 |
-
$set_query_var_color = array();
|
171 |
-
$set_query_var_color['terms'] = $terms;
|
172 |
-
$set_query_var_color['type'] = $type;
|
173 |
-
$set_query_var_color['load_script'] = $load_script;
|
174 |
-
set_query_var( 'berocket_query_var_color', $set_query_var_color );
|
175 |
-
br_get_template_part( 'color_ajax' );
|
176 |
}
|
177 |
|
178 |
public static function ajax_include_exclude_list() {
|
179 |
-
|
180 |
-
|
181 |
-
}
|
182 |
wp_die();
|
183 |
}
|
184 |
-
|
185 |
-
public static function include_exclude_terms_list($taxonomy_name = false, $selected = array() ) {
|
186 |
-
$terms = berocket_aapf_get_terms( array( 'taxonomy' => $taxonomy_name, 'hide_empty' => false ), array('hierarchical' => true, 'disable_recount' => true, 'disable_hide_empty' => true) );
|
187 |
-
$set_query_var_exclude_list = array();
|
188 |
-
$set_query_var_exclude_list['taxonomy'] = $taxonomy_name;
|
189 |
-
$set_query_var_exclude_list['terms'] = $terms;
|
190 |
-
$set_query_var_exclude_list['selected'] = $selected;
|
191 |
-
set_query_var( 'berocket_var_exclude_list', $set_query_var_exclude_list );
|
192 |
-
ob_start();
|
193 |
-
br_get_template_part( 'include_exclude_list' );
|
194 |
-
return ob_get_clean();
|
195 |
-
}
|
196 |
|
197 |
public static function get_product_categories( $current_product_cat = '', $parent = 0, $data = array(), $depth = 0, $max_count = 9, $follow_hierarchy = false ) {
|
198 |
return br_get_sub_categories( $parent, 'id', array( 'return' => 'hierarchy_objects', 'max_depth' => $max_count ) );
|
@@ -429,7 +403,8 @@ class BeRocket_AAPF_Widget_functions {
|
|
429 |
|
430 |
if( count($terms) ) {
|
431 |
$terms_first = reset($terms);
|
432 |
-
$
|
|
|
433 |
foreach ( $terms as $term ) {
|
434 |
$sort_array[] = array_search($term->term_id, $terms2);
|
435 |
if ( ! empty($term->child) ) {
|
@@ -483,5 +458,60 @@ class BeRocket_AAPF_Widget_functions {
|
|
483 |
|
484 |
return apply_filters( 'berocket_aapf_hide_out_of_stock_items', $hide );
|
485 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
}
|
487 |
new BeRocket_AAPF_Widget_functions();
|
5 |
function __construct() {
|
6 |
add_filter('berocket_query_var_title_before_widget', array($this, 'apply_price_slider'), 10, 5);
|
7 |
add_filter('berocket_aapf_is_filtered_page_check', array($this, 'is_filtered_page_check'), 10, 1);
|
8 |
+
add_filter('braapf_generate_taxonomy_name_for_select', array($this, 'correct_taxonomy'), 10, 2);
|
9 |
}
|
10 |
function is_filtered_page_check($filtered) {
|
11 |
if( ! empty($_GET['s']) ) {
|
13 |
}
|
14 |
return $filtered;
|
15 |
}
|
16 |
+
function correct_taxonomy($args, $br_product_filter) {
|
17 |
+
if( ! empty($br_product_filter) && ! empty($br_product_filter['filter_type']) ) {
|
18 |
+
switch($br_product_filter['filter_type']) {
|
19 |
+
case 'tag':
|
20 |
+
$args['taxonomy'] = 'product_tag';
|
21 |
+
break;
|
22 |
+
case '_rating':
|
23 |
+
$args['taxonomy'] = 'product_visibility';
|
24 |
+
$args['slug'] = array('rated-1', 'rated-2', 'rated-3', 'rated-4', 'rated-5');
|
25 |
+
break;
|
26 |
+
case 'tag':
|
27 |
+
$args['taxonomy'] = 'product_tag';
|
28 |
+
break;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
return $args;
|
32 |
+
}
|
33 |
public static function br_widget_ajax_set() {
|
34 |
if ( ( is_plugin_active( 'woocommerce/woocommerce.php' ) || is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) && br_get_woocommerce_version() >= 2.1 ) {
|
35 |
add_action( 'wp_ajax_berocket_aapf_color_listener', array( __CLASS__, 'color_listener' ) );
|
157 |
}
|
158 |
|
159 |
public static function color_listener() {
|
160 |
+
$br_product_filter = (empty($_POST['br_product_filter']) ? array() : $_POST['br_product_filter']);
|
161 |
+
echo self::color_image_view($br_product_filter, $_POST['type'], true);
|
162 |
+
wp_die();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
|
165 |
public static function ajax_include_exclude_list() {
|
166 |
+
$br_product_filter = (empty($_POST['br_product_filter']) ? array() : $_POST['br_product_filter']);
|
167 |
+
echo self::include_exclude_view($br_product_filter);
|
|
|
168 |
wp_die();
|
169 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
public static function get_product_categories( $current_product_cat = '', $parent = 0, $data = array(), $depth = 0, $max_count = 9, $follow_hierarchy = false ) {
|
172 |
return br_get_sub_categories( $parent, 'id', array( 'return' => 'hierarchy_objects', 'max_depth' => $max_count ) );
|
403 |
|
404 |
if( count($terms) ) {
|
405 |
$terms_first = reset($terms);
|
406 |
+
$get_terms_args['taxonomy'] = $terms_first->taxonomy;
|
407 |
+
$terms2 = berocket_aapf_get_terms( $get_terms_args );
|
408 |
foreach ( $terms as $term ) {
|
409 |
$sort_array[] = array_search($term->term_id, $terms2);
|
410 |
if ( ! empty($term->child) ) {
|
458 |
|
459 |
return apply_filters( 'berocket_aapf_hide_out_of_stock_items', $hide );
|
460 |
}
|
461 |
+
public static function color_image_view($br_filter, $type, $load_script = false) {
|
462 |
+
$terms = self::get_terms_for_filter($br_filter);
|
463 |
+
$set_query_var_color = array();
|
464 |
+
$set_query_var_color['terms'] = $terms;
|
465 |
+
$set_query_var_color['type'] = $type;
|
466 |
+
$set_query_var_color['load_script'] = $load_script;
|
467 |
+
set_query_var( 'berocket_query_var_color', $set_query_var_color );
|
468 |
+
ob_start();
|
469 |
+
br_get_template_part( 'color_ajax' );
|
470 |
+
return ob_get_clean();
|
471 |
+
}
|
472 |
+
public static function color_image_save($br_filter, $type, $color_values) {
|
473 |
+
if( isset( $color_values ) ) {
|
474 |
+
if ( current_user_can( 'manage_woocommerce' ) ) {
|
475 |
+
if( apply_filters('bapf_widget_func_color_listener_save', true, $br_filter, $type, $color_values) ) {
|
476 |
+
foreach( $color_values as $key => $value ) {
|
477 |
+
if( $type == 'color' ) {
|
478 |
+
foreach($value as $term_key => $term_val) {
|
479 |
+
if( !empty($term_val) ) {
|
480 |
+
update_metadata( 'berocket_term', $term_key, $key, $term_val );
|
481 |
+
} else {
|
482 |
+
delete_metadata( 'berocket_term', $term_key, $key );
|
483 |
+
}
|
484 |
+
}
|
485 |
+
} else {
|
486 |
+
update_metadata( 'berocket_term', $key, $type, $value );
|
487 |
+
}
|
488 |
+
}
|
489 |
+
}
|
490 |
+
}
|
491 |
+
}
|
492 |
+
}
|
493 |
+
public static function include_exclude_view($br_filter, $selected = array()) {
|
494 |
+
$terms = self::get_terms_for_filter($br_filter);
|
495 |
+
$set_query_var_exclude_list = array();
|
496 |
+
$set_query_var_exclude_list['terms'] = $terms;
|
497 |
+
$set_query_var_exclude_list['selected'] = $selected;
|
498 |
+
set_query_var( 'berocket_var_exclude_list', $set_query_var_exclude_list );
|
499 |
+
ob_start();
|
500 |
+
br_get_template_part( 'include_exclude_list' );
|
501 |
+
return ob_get_clean();
|
502 |
+
}
|
503 |
+
public static function get_terms_for_filter($br_filter) {
|
504 |
+
$args = self::get_current_terms_args($br_filter);
|
505 |
+
$terms = berocket_aapf_get_terms( $args, array('hierarchical' => true, 'disable_recount' => true, 'disable_hide_empty' => true) );
|
506 |
+
return $terms;
|
507 |
+
}
|
508 |
+
public static function get_current_terms_args($br_filter) {
|
509 |
+
$taxonomy = braapf_get_data_taxonomy_from_post($br_filter);
|
510 |
+
$args = array(
|
511 |
+
'taxonomy' => $taxonomy,
|
512 |
+
'hide_empty' => false
|
513 |
+
);
|
514 |
+
return apply_filters('braapf_generate_taxonomy_name_for_select', $args, $br_filter);
|
515 |
+
}
|
516 |
}
|
517 |
new BeRocket_AAPF_Widget_functions();
|
libraries/link_parser.php
CHANGED
@@ -52,6 +52,6 @@ class BeRocket_AAPF_link_parser {
|
|
52 |
} elseif ( array_key_exists($taxonomy, $this->taxonomy_changer) ) {
|
53 |
return $this->taxonomy_changer[$taxonomy]['taxonomy'];
|
54 |
}
|
55 |
-
return false;
|
56 |
}
|
57 |
}
|
52 |
} elseif ( array_key_exists($taxonomy, $this->taxonomy_changer) ) {
|
53 |
return $this->taxonomy_changer[$taxonomy]['taxonomy'];
|
54 |
}
|
55 |
+
return apply_filters('bapf_link_parser_check_taxonomy', false, $taxonomy);
|
56 |
}
|
57 |
}
|
main.php
CHANGED
@@ -1614,8 +1614,6 @@ jQuery(document).on('change', '.berocket_disable_ajax_loading', berocket_disable
|
|
1614 |
add_action( 'setup_theme', array( $this, 'WPML_fix' ) );
|
1615 |
add_action( "wp_ajax_aapf_color_set", array ( 'BeRocket_AAPF_Widget_functions', 'color_listener' ) );
|
1616 |
BeRocket_AAPF_Widget_functions::br_widget_ajax_set();
|
1617 |
-
add_action( "wp_ajax_berocket_aapf_load_simple_filter_creation", array ( $this, 'load_simple_filter_creation' ) );
|
1618 |
-
add_action( "wp_ajax_berocket_aapf_save_simple_filter_creation", array ( $this, 'save_simple_filter_creation' ) );
|
1619 |
}
|
1620 |
function not_ajax_functions() {
|
1621 |
$shortcode_types = array(
|
@@ -1654,18 +1652,6 @@ jQuery(document).on('change', '.berocket_disable_ajax_loading', berocket_disable
|
|
1654 |
}
|
1655 |
return $out;
|
1656 |
}
|
1657 |
-
function load_simple_filter_creation() {
|
1658 |
-
$type = sanitize_title($_POST['type']);
|
1659 |
-
$html = apply_filters('berocket_aapf_load_simple_filter_creation_'.$type, '');
|
1660 |
-
echo $html;
|
1661 |
-
wp_die();
|
1662 |
-
}
|
1663 |
-
function save_simple_filter_creation() {
|
1664 |
-
$type = sanitize_title($_POST['type']);
|
1665 |
-
$data = apply_filters('berocket_aapf_save_simple_filter_creation_'.$type, array());
|
1666 |
-
echo json_encode($data);
|
1667 |
-
wp_die();
|
1668 |
-
}
|
1669 |
public function widgets_init() {
|
1670 |
register_widget("BeRocket_new_AAPF_Widget");
|
1671 |
register_widget("BeRocket_new_AAPF_Widget_single");
|
@@ -2492,6 +2478,12 @@ jQuery(document).on('change', '.berocket_disable_ajax_loading', berocket_disable
|
|
2492 |
update_option( 'br_filters_options', $options );
|
2493 |
delete_option('BeRocket_aapf_additional_tables_addon_position');
|
2494 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2495 |
}
|
2496 |
public function save_settings_callback( $settings ) {
|
2497 |
$options = $this->get_option();
|
1614 |
add_action( 'setup_theme', array( $this, 'WPML_fix' ) );
|
1615 |
add_action( "wp_ajax_aapf_color_set", array ( 'BeRocket_AAPF_Widget_functions', 'color_listener' ) );
|
1616 |
BeRocket_AAPF_Widget_functions::br_widget_ajax_set();
|
|
|
|
|
1617 |
}
|
1618 |
function not_ajax_functions() {
|
1619 |
$shortcode_types = array(
|
1652 |
}
|
1653 |
return $out;
|
1654 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1655 |
public function widgets_init() {
|
1656 |
register_widget("BeRocket_new_AAPF_Widget");
|
1657 |
register_widget("BeRocket_new_AAPF_Widget_single");
|
2478 |
update_option( 'br_filters_options', $options );
|
2479 |
delete_option('BeRocket_aapf_additional_tables_addon_position');
|
2480 |
}
|
2481 |
+
if( $previous !== '0' && ( version_compare($previous, '1.6.3', '<') || (version_compare($previous, '2.0', '>') && version_compare($previous, '3.1.3', '<') ) ) ) {
|
2482 |
+
$current_position = get_option('BeRocket_aapf_additional_tables_addon_position');
|
2483 |
+
if( ! empty($current_position) && $current_position >= 6 ) {
|
2484 |
+
update_option('BeRocket_aapf_additional_tables_addon_position', 'ended');
|
2485 |
+
}
|
2486 |
+
}
|
2487 |
}
|
2488 |
public function save_settings_callback( $settings ) {
|
2489 |
$options = $this->get_option();
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Contributors: dholovnia, berocket
|
|
4 |
Donate link: https://berocket.com/product/woocommerce-ajax-products-filter?utm_source=wordpress_org&utm_medium=donate&utm_campaign=ajax_filters
|
5 |
Tags: filters, product filters, ajax product filters, ajax filter, ajax filter widget, color filter, size filter, product onsale filter, product preview, product category filter, product reset filter, product sort by filter, stock filter, product tag filter, price range filter, price box filter, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce products filter, woocommerce ajax product filters, widget, plugin, woocommerce item filters, filters plugin, ajax filters plugin, filter woocommerce products, filter woocommerce products plugin, wc filters, wc filters products, wc products filters, wc ajax products filters, wc product filters, wc advanced product filters, woocommerce layered nav, woocommerce layered navigation, ajax filtered nav, ajax filtered navigation, price filter, ajax price filter, woocommerce product sorting, sidebar filter, sidebar ajax filter, taxonomy filter, category filter, attribute filter, attributes filter, woocommerce product sort, ajax products filter plugin for woocommerce, rocket, berocket, berocket woocommerce ajax products filter
|
6 |
Requires at least: 5.0
|
7 |
-
Tested up to:
|
8 |
-
Stable tag: 1.6.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -15,6 +15,10 @@ WooCommerce AJAX Product Filters - Advanced product filtering ability for your W
|
|
15 |
|
16 |
WooCommerce AJAX Product Filters - Advanced product filtering ability for your WooCommerce shop. Add unlimited filters with one widget.
|
17 |
|
|
|
|
|
|
|
|
|
18 |
= New Feature in version 1.5 =
|
19 |
|
20 |
✅ New styles for filters: Checkbox, Select, Slider, Color, Image
|
@@ -185,6 +189,16 @@ You can try this plugin's admin side [here](https://berocket.com/product/woocomm
|
|
185 |
|
186 |
== Changelog ==
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
= 1.6.2 =
|
189 |
* Enhancement - Compatibility version: WooCommerce 6.4
|
190 |
* Enhancement - Hierarchical view for color/image pick
|
4 |
Donate link: https://berocket.com/product/woocommerce-ajax-products-filter?utm_source=wordpress_org&utm_medium=donate&utm_campaign=ajax_filters
|
5 |
Tags: filters, product filters, ajax product filters, ajax filter, ajax filter widget, color filter, size filter, product onsale filter, product preview, product category filter, product reset filter, product sort by filter, stock filter, product tag filter, price range filter, price box filter, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce products filter, woocommerce ajax product filters, widget, plugin, woocommerce item filters, filters plugin, ajax filters plugin, filter woocommerce products, filter woocommerce products plugin, wc filters, wc filters products, wc products filters, wc ajax products filters, wc product filters, wc advanced product filters, woocommerce layered nav, woocommerce layered navigation, ajax filtered nav, ajax filtered navigation, price filter, ajax price filter, woocommerce product sorting, sidebar filter, sidebar ajax filter, taxonomy filter, category filter, attribute filter, attributes filter, woocommerce product sort, ajax products filter plugin for woocommerce, rocket, berocket, berocket woocommerce ajax products filter
|
6 |
Requires at least: 5.0
|
7 |
+
Tested up to: 6.0
|
8 |
+
Stable tag: 1.6.3
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
15 |
|
16 |
WooCommerce AJAX Product Filters - Advanced product filtering ability for your WooCommerce shop. Add unlimited filters with one widget.
|
17 |
|
18 |
+
= New Feature in version 1.6.3 =
|
19 |
+
|
20 |
+
✅ Filter by Post Meta (Custom meta field)
|
21 |
+
|
22 |
= New Feature in version 1.5 =
|
23 |
|
24 |
✅ New styles for filters: Checkbox, Select, Slider, Color, Image
|
189 |
|
190 |
== Changelog ==
|
191 |
|
192 |
+
= 1.6.3 =
|
193 |
+
* Enhancement - Compatibility version: Wordpress 6.0 and WooCommerce 6.7
|
194 |
+
* Enhancement - POST META FILTERING ADD-ON
|
195 |
+
* Enhancement - Hierarchical view for taxonomies list
|
196 |
+
* Fix - Color/Image select with polylang
|
197 |
+
* Fix - Additional tables generation for some site
|
198 |
+
* Fix - Currency exchange compatibility
|
199 |
+
* Fix - Module for Divi theme
|
200 |
+
* Fix - Style of admin elements
|
201 |
+
|
202 |
= 1.6.2 =
|
203 |
* Enhancement - Compatibility version: WooCommerce 6.4
|
204 |
* Enhancement - Hierarchical view for color/image pick
|
template_styles/color.php
CHANGED
@@ -22,7 +22,7 @@ if( ! class_exists('BeRocket_AAPF_Template_Style_color') ) {
|
|
22 |
return $template_content;
|
23 |
}
|
24 |
function template_single_item($template, $term, $i, $berocket_query_var_title) {
|
25 |
-
$berocket_term =
|
26 |
$meta_color = br_get_value_from_array($berocket_term, 0, '');
|
27 |
$meta_color = str_replace('#', '', $meta_color);
|
28 |
$meta_color = esc_attr($meta_color);
|
@@ -101,7 +101,7 @@ if( ! class_exists('BeRocket_AAPF_Template_Style_image') ) {
|
|
101 |
return $template_content;
|
102 |
}
|
103 |
function template_single_item($template, $term, $i, $berocket_query_var_title) {
|
104 |
-
$berocket_term =
|
105 |
$meta_image = br_get_value_from_array($berocket_term, 0, '');
|
106 |
$meta_image = esc_attr($meta_image);
|
107 |
$template['content']['checkbox'] = BeRocket_AAPF_dynamic_data_template::create_element_arrays($template['content']['checkbox'], array('attributes', 'style'));
|
22 |
return $template_content;
|
23 |
}
|
24 |
function template_single_item($template, $term, $i, $berocket_query_var_title) {
|
25 |
+
$berocket_term = berocket_term_get_metadata($term, 'color');
|
26 |
$meta_color = br_get_value_from_array($berocket_term, 0, '');
|
27 |
$meta_color = str_replace('#', '', $meta_color);
|
28 |
$meta_color = esc_attr($meta_color);
|
101 |
return $template_content;
|
102 |
}
|
103 |
function template_single_item($template, $term, $i, $berocket_query_var_title) {
|
104 |
+
$berocket_term = berocket_term_get_metadata($term, 'image');
|
105 |
$meta_image = br_get_value_from_array($berocket_term, 0, '');
|
106 |
$meta_image = esc_attr($meta_image);
|
107 |
$template['content']['checkbox'] = BeRocket_AAPF_dynamic_data_template::create_element_arrays($template['content']['checkbox'], array('attributes', 'style'));
|
templates/color_ajax.php
CHANGED
@@ -6,15 +6,15 @@
|
|
6 |
if( $type == 'color' ) {?>
|
7 |
<table>
|
8 |
<?php
|
9 |
-
foreach( $terms as $term ) {
|
10 |
$color_term_selector = apply_filters('berocket_aapf_color_term_select_line', '', $term);
|
11 |
if( ! empty($color_term_selector) ) {
|
12 |
echo $color_term_selector;
|
13 |
continue;
|
14 |
}
|
15 |
-
$color_term_selector = '<tr class="element-depth-'
|
16 |
$color_term_selector .= '<td>'.berocket_isset($term, 'name').'</td>';
|
17 |
-
$color_meta =
|
18 |
$color_term_selector .= '<td class="br_colorpicker_field" data-color="' . br_get_value_from_array($color_meta, 0, 'ffffff') . '">
|
19 |
</td>
|
20 |
<input class="br_colorpicker_field_input" type="hidden" value="' . br_get_value_from_array($color_meta, 0) . '"
|
@@ -64,7 +64,7 @@
|
|
64 |
} elseif( $type == 'image' ) {
|
65 |
?>
|
66 |
<table>
|
67 |
-
<?php foreach( $terms as $term ) { $color_meta =
|
68 |
<tr>
|
69 |
<td class="br_aapf_settings_fa"><?php echo '<strong>' . $term->name . '</strong> ' . br_fontawesome_image("br_widget_color[".$term->term_id."]", br_get_value_from_array($color_meta, 0)); ?></td>
|
70 |
</tr>
|
6 |
if( $type == 'color' ) {?>
|
7 |
<table>
|
8 |
<?php
|
9 |
+
foreach( $terms as $term ) {
|
10 |
$color_term_selector = apply_filters('berocket_aapf_color_term_select_line', '', $term);
|
11 |
if( ! empty($color_term_selector) ) {
|
12 |
echo $color_term_selector;
|
13 |
continue;
|
14 |
}
|
15 |
+
$color_term_selector = '<tr class="element-depth-'.(empty($term->depth) ? '0' : $term->depth).'">';
|
16 |
$color_term_selector .= '<td>'.berocket_isset($term, 'name').'</td>';
|
17 |
+
$color_meta = berocket_term_get_metadata($term, 'color');
|
18 |
$color_term_selector .= '<td class="br_colorpicker_field" data-color="' . br_get_value_from_array($color_meta, 0, 'ffffff') . '">
|
19 |
</td>
|
20 |
<input class="br_colorpicker_field_input" type="hidden" value="' . br_get_value_from_array($color_meta, 0) . '"
|
64 |
} elseif( $type == 'image' ) {
|
65 |
?>
|
66 |
<table>
|
67 |
+
<?php foreach( $terms as $term ) { $color_meta = berocket_term_get_metadata($term, $type); ?>
|
68 |
<tr>
|
69 |
<td class="br_aapf_settings_fa"><?php echo '<strong>' . $term->name . '</strong> ' . br_fontawesome_image("br_widget_color[".$term->term_id."]", br_get_value_from_array($color_meta, 0)); ?></td>
|
70 |
</tr>
|
templates/filter_post_simple.php
DELETED
@@ -1,140 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
$attributes = br_aapf_get_attributes();
|
3 |
-
$categories = BeRocket_AAPF_Widget_functions::get_product_categories( '' );
|
4 |
-
$categories = BeRocket_AAPF_Widget_functions::set_terms_on_same_level( $categories );
|
5 |
-
$tags = get_terms( 'product_tag' );
|
6 |
-
$custom_taxonomies = get_object_taxonomies( 'product' );
|
7 |
-
$custom_taxonomies = array_combine($custom_taxonomies, $custom_taxonomies);
|
8 |
-
?>
|
9 |
-
<div class="widget-liquid-right tab-item current">
|
10 |
-
<div>
|
11 |
-
<label class="br_admin_center"><?php _e('Title', 'BeRocket_AJAX_domain'); ?></label>
|
12 |
-
<input class="br_admin_full_size" name="title" value="">
|
13 |
-
</div>
|
14 |
-
<?php if( empty($instance['filter_type']) ) $instance['filter_type'] = ''; ?>
|
15 |
-
<div class="berocket_aapf_admin_filter_widget_content" <?php if ( $instance['widget_type'] == 'update_button' or $instance['widget_type'] == 'reset_button' or $instance['widget_type'] == 'selected_area' or $instance['widget_type'] == 'search_box' ) echo 'style="display: none;"'; ?>>
|
16 |
-
<div class="berocketwizard_attribute">
|
17 |
-
<div class="br_admin_half_size_left">
|
18 |
-
<label class="br_admin_center"><?php _e('Filter By', 'BeRocket_AJAX_domain') ?></label>
|
19 |
-
<select id="<?php echo 'filter_type'; ?>" name="<?php echo $post_name.'[filter_type]'; ?>" class="berocket_aapf_widget_admin_filter_type_select br_select_menu_left">
|
20 |
-
<?php
|
21 |
-
$filter_type_array = braapf_single_filter_edit_elements::get_all_filter_type_array(array());
|
22 |
-
if( ! array_key_exists($instance['filter_type'], $filter_type_array) ) {
|
23 |
-
foreach($filter_type_array as $filter_type_key => $filter_type_val) {
|
24 |
-
$instance['filter_type'] = $filter_type_key;
|
25 |
-
break;
|
26 |
-
}
|
27 |
-
}
|
28 |
-
foreach($filter_type_array as $filter_type_key => $filter_type_val) {
|
29 |
-
echo '<option';
|
30 |
-
foreach($filter_type_val as $data_key => $data_val) {
|
31 |
-
if( ! empty($data_val) ) {
|
32 |
-
echo ' data-'.$data_key.'="'.$data_val.'"';
|
33 |
-
}
|
34 |
-
}
|
35 |
-
echo ' value="'.$filter_type_key.'"'.($instance['filter_type'] == $filter_type_key ? ' selected' : '').'>'.$filter_type_val['name'].'</option>';
|
36 |
-
if( $instance['filter_type'] == $filter_type_key ) {
|
37 |
-
$sameas = $filter_type_val;
|
38 |
-
}
|
39 |
-
}
|
40 |
-
?>
|
41 |
-
</select>
|
42 |
-
</div>
|
43 |
-
<div class="br_admin_half_size_right berocket_aapf_widget_admin_filter_type_ berocket_aapf_widget_admin_filter_type_attribute" <?php if ( $instance['filter_type'] and $instance['filter_type'] != 'attribute') echo 'style="display: none;"'; ?>>
|
44 |
-
<label class="br_admin_center"><?php _e('Attribute', 'BeRocket_AJAX_domain') ?></label>
|
45 |
-
<select id="<?php echo 'attribute'; ?>" name="<?php echo $post_name.'[attribute]'; ?>" class="berocket_aapf_widget_admin_filter_type_attribute_select br_select_menu_right">
|
46 |
-
<?php foreach ( $attributes as $k => $v ) { ?>
|
47 |
-
<option <?php if ( $instance['attribute'] == $k ) echo 'selected'; ?> value="<?php echo $k ?>"><?php echo $v ?></option>
|
48 |
-
<?php } ?>
|
49 |
-
</select>
|
50 |
-
</div>
|
51 |
-
<div class="br_admin_half_size_right berocket_aapf_widget_admin_filter_type_ berocket_aapf_widget_admin_filter_type_custom_taxonomy" <?php if ( $instance['filter_type'] != 'custom_taxonomy') echo 'style="display: none;"'; ?>>
|
52 |
-
<label class="br_admin_center"><?php _e('Custom Taxonomies', 'BeRocket_AJAX_domain') ?></label>
|
53 |
-
<select id="<?php echo 'custom_taxonomy'; ?>" name="<?php echo $post_name.'[custom_taxonomy]'; ?>" class="berocket_aapf_widget_admin_filter_type_custom_taxonomy_select br_select_menu_right">
|
54 |
-
<?php foreach( $custom_taxonomies as $k => $v ){ ?>
|
55 |
-
<option <?php if ( $instance['custom_taxonomy'] == $k ) echo 'selected'; ?> value="<?php echo $k ?>"><?php echo $v ?></option>
|
56 |
-
<?php } ?>
|
57 |
-
</select>
|
58 |
-
</div>
|
59 |
-
<div style="clear:both;"></div>
|
60 |
-
</div>
|
61 |
-
<?php
|
62 |
-
if( ! empty($sameas) ) {
|
63 |
-
$instance['filter_type'] = $sameas['sameas'];
|
64 |
-
if( ! empty($sameas['attribute']) ) {
|
65 |
-
if( $sameas['sameas'] == 'custom_taxonomy' ) {
|
66 |
-
$instance['custom_taxonomy'] = $sameas['attribute'];
|
67 |
-
} elseif( $sameas['sameas'] == 'attribute' ) {
|
68 |
-
$instance['attribute'] = $sameas['attribute'];
|
69 |
-
}
|
70 |
-
}
|
71 |
-
}
|
72 |
-
?>
|
73 |
-
<div class="br_clearfix"></div>
|
74 |
-
<div class="br_admin_half_size_left br_type_select_block"<?php if( $instance['filter_type'] == 'date' ) echo 'style="display: none;"'; ?>>
|
75 |
-
<label class="br_admin_center"><?php _e('Type', 'BeRocket_AJAX_domain') ?></label>
|
76 |
-
<?php
|
77 |
-
list($berocket_admin_filter_types, $berocket_admin_filter_types_by_attr) = berocket_aapf_get_filter_types('simple');
|
78 |
-
$select_options_variants = array();
|
79 |
-
if ( $instance['filter_type'] == 'tag' ) {
|
80 |
-
$select_options_variants = $berocket_admin_filter_types['tag'];
|
81 |
-
} else if ( $instance['filter_type'] == 'product_cat' || ( $instance['filter_type'] == 'custom_taxonomy' && ( $instance['custom_taxonomy'] == 'product_tag' || $instance['custom_taxonomy'] == 'product_cat' ) ) ) {
|
82 |
-
$select_options_variants = $berocket_admin_filter_types['product_cat'];
|
83 |
-
} else if ( $instance['filter_type'] == '_sale' || $instance['filter_type'] == '_stock_status' || $instance['filter_type'] == '_rating' ) {
|
84 |
-
$select_options_variants = $berocket_admin_filter_types['sale'];
|
85 |
-
} else if ( $instance['filter_type'] == 'custom_taxonomy' ) {
|
86 |
-
$select_options_variants = $berocket_admin_filter_types['custom_taxonomy'];
|
87 |
-
} else if ( $instance['filter_type'] == 'attribute' ) {
|
88 |
-
if ( $instance['attribute'] == 'price' ) {
|
89 |
-
$select_options_variants = $berocket_admin_filter_types['price'];
|
90 |
-
} else {
|
91 |
-
$select_options_variants = $berocket_admin_filter_types['attribute'];
|
92 |
-
}
|
93 |
-
} else if ( $instance['filter_type'] == 'filter_by' ) {
|
94 |
-
$select_options_variants = $berocket_admin_filter_types['filter_by'];
|
95 |
-
}
|
96 |
-
?>
|
97 |
-
<select id="<?php echo 'type'; ?>" name="<?php echo $post_name.'[type]'; ?>" class="berocket_aapf_widget_admin_type_select br_select_menu_left">
|
98 |
-
<?php
|
99 |
-
$selected = false;
|
100 |
-
$first = false;
|
101 |
-
foreach($select_options_variants as $select_options_variant) {
|
102 |
-
if( ! empty($berocket_admin_filter_types_by_attr[$select_options_variant]) ) {
|
103 |
-
echo '<option value="' . $berocket_admin_filter_types_by_attr[$select_options_variant]['value'] . '"'
|
104 |
-
. ($instance['type'] == $berocket_admin_filter_types_by_attr[$select_options_variant]['value'] ? ' selected' : '')
|
105 |
-
. '>' . $berocket_admin_filter_types_by_attr[$select_options_variant]['text'] . '</option>';
|
106 |
-
if( $instance['type'] == $berocket_admin_filter_types_by_attr[$select_options_variant]['value'] ) {
|
107 |
-
$selected = true;
|
108 |
-
}
|
109 |
-
if( $first === false ) {
|
110 |
-
$first = $berocket_admin_filter_types_by_attr[$select_options_variant]['value'];
|
111 |
-
}
|
112 |
-
}
|
113 |
-
}
|
114 |
-
if( ! $selected ) {
|
115 |
-
$instance['type'] = $first;
|
116 |
-
}
|
117 |
-
?>
|
118 |
-
</select>
|
119 |
-
</div>
|
120 |
-
<div class="br_admin_half_size_right" <?php if ( ( ! $instance['filter_type'] or $instance['filter_type'] == 'attribute' ) and $instance['attribute'] == 'price' or $instance['type'] == 'slider' or $instance['filter_type'] == 'date' or $instance['filter_type'] == '_sale' or $instance['filter_type'] == '_rating' ) echo " style='display: none;'"; ?> >
|
121 |
-
<label class="br_admin_center"><?php _e('Operator', 'BeRocket_AJAX_domain') ?></label>
|
122 |
-
<select id="<?php echo 'operator'; ?>" name="<?php echo $post_name.'[operator]'; ?>" class="berocket_aapf_widget_admin_operator_select br_select_menu_left">
|
123 |
-
<option <?php if ( $instance['operator'] == 'AND' ) echo 'selected'; ?> value="AND">AND</option>
|
124 |
-
<option <?php if ( $instance['operator'] == 'OR' ) echo 'selected'; ?> value="OR">OR</option>
|
125 |
-
</select>
|
126 |
-
</div>
|
127 |
-
</div>
|
128 |
-
<div style="clear:both;"></div>
|
129 |
-
<p>
|
130 |
-
<?php
|
131 |
-
_e('Need more options? Create it on ', 'BeRocket_AJAX_domain');
|
132 |
-
echo '<a href="' . admin_url('edit.php?post_type=br_product_filter') . '">' . __('Manage filters', 'BeRocket_AJAX_domain') . '</a>';
|
133 |
-
_e(' page', 'BeRocket_AJAX_domain');
|
134 |
-
?>
|
135 |
-
</p>
|
136 |
-
<script>
|
137 |
-
if( typeof(br_widget_set) == 'function' )
|
138 |
-
br_widget_set();
|
139 |
-
</script>
|
140 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/filters_group_simple.php
DELETED
@@ -1,132 +0,0 @@
|
|
1 |
-
<div>
|
2 |
-
<label class="br_admin_center"><?php _e('Title', 'BeRocket_AJAX_domain'); ?></label>
|
3 |
-
<input class="br_admin_full_size" name="title" value="">
|
4 |
-
</div>
|
5 |
-
<div class="berocket_filter_groups">
|
6 |
-
<h3><?php _e('Filters In Group', 'BeRocket_AJAX_domain'); ?></h3>
|
7 |
-
<?php
|
8 |
-
$query = new WP_Query(array('post_type' => 'br_product_filter', 'nopaging' => true));
|
9 |
-
if ( $query->have_posts() ) {
|
10 |
-
echo '<select class="berocket_filter_list berocket_new_widget_selectbox single">';
|
11 |
-
while ( $query->have_posts() ) {
|
12 |
-
$query->the_post();
|
13 |
-
echo '<option data-name="' . get_the_title() . '" value="' . get_the_id() . '">' . get_the_title() . ' (ID:' . get_the_id() . ')</option>';
|
14 |
-
}
|
15 |
-
echo '</select>';
|
16 |
-
echo ' <a class="button berocket_add_filter_to_group" href="#add_filter">' . __('Add filter', 'BeRocket_AJAX_domain') . '</a>';
|
17 |
-
echo '<a class="button berocket_create_new" data-type="single" data-action="berocket_aapf_load_simple_filter_creation" href="#">' . __('Create Filter', 'BeRocket_AJAX_domain') . '</a>';
|
18 |
-
wp_reset_postdata();
|
19 |
-
}
|
20 |
-
?>
|
21 |
-
<ul class="berocket_filter_added_list" data-name="<?php echo $post_name; ?>[filters][]" data-url="<?php echo admin_url('post.php');?>">
|
22 |
-
<?php
|
23 |
-
if( isset($filters['filters']) && is_array($filters['filters']) ) {
|
24 |
-
foreach($filters['filters'] as $filter) {
|
25 |
-
$filter_id = $filter;
|
26 |
-
$filter_post = get_post($filter_id);
|
27 |
-
if( ! empty($filter_post) ) {
|
28 |
-
echo '<li class="berocket_filter_added_' . $filter_id . '"><fa class="fa fa-bars"></fa>
|
29 |
-
<input type="hidden" name="'.$post_name.'[filters][]" value="' . $filter_id . '">
|
30 |
-
' . $filter_post->post_title . ' <small>ID:' . $filter_id . '</small>
|
31 |
-
<i class="fa fa-times"></i>
|
32 |
-
<a class="berocket_edit_filter" target="_blank" href="' . admin_url('post.php?post='.$filter_id.'&action=edit') . '">' . __('Edit', 'BeRocket_AJAX_domain') . '</a>
|
33 |
-
</li>';
|
34 |
-
}
|
35 |
-
}
|
36 |
-
}
|
37 |
-
?>
|
38 |
-
</ul>
|
39 |
-
</div>
|
40 |
-
<p>
|
41 |
-
<?php
|
42 |
-
_e('Need more options? Create it on ', 'BeRocket_AJAX_domain');
|
43 |
-
echo '<a href="' . admin_url('edit.php?post_type=br_filters_group') . '">' . __('Manage groups', 'BeRocket_AJAX_domain') . '</a>';
|
44 |
-
_e(' page', 'BeRocket_AJAX_domain');
|
45 |
-
?>
|
46 |
-
</p>
|
47 |
-
<script>
|
48 |
-
jQuery('.berocket_add_filter_to_group').on('click', function(event) {
|
49 |
-
event.preventDefault();
|
50 |
-
var $parent = jQuery(this).parents('form').first();
|
51 |
-
if( ! jQuery('.berocket_filter_added_'+jQuery('.berocket_filter_list', $parent).val(), $parent).length ) {
|
52 |
-
var html = '<li class="berocket_filter_added_'+jQuery('.berocket_filter_list', $parent).val()+'"><i class="fa fa-bars"></i> ';
|
53 |
-
html += '<input type="hidden" name="'+jQuery('.berocket_filter_added_list', $parent).data('name')+'" value="'+jQuery('.berocket_filter_list', $parent).val()+'">';
|
54 |
-
html += jQuery('.berocket_filter_list', $parent).find(':selected').data('name');
|
55 |
-
html += ' <small>ID:'+jQuery('.berocket_filter_list', $parent).val()+'</small>';
|
56 |
-
html += '<i class="fa fa-times"></i>';
|
57 |
-
html += ' <a class="berocket_edit_filter" target="_blank" href="'+jQuery('.berocket_filter_added_list').data('url')+'?post='+jQuery('.berocket_filter_list').val()+'&action=edit"><?php _e('Edit', 'BeRocket_AJAX_domain'); ?></a>';
|
58 |
-
html += '</li>';
|
59 |
-
jQuery('.berocket_filter_added_list', $parent).append(jQuery(html));
|
60 |
-
} else {
|
61 |
-
jQuery('.berocket_filter_added_'+jQuery('.berocket_filter_list').val(), $parent).css('background-color', '#ee3333').clearQueue().animate({backgroundColor:'#eeeeee'}, 1000);
|
62 |
-
}
|
63 |
-
});
|
64 |
-
jQuery(document).on('click', '.berocket_filter_added_list .fa-times', function(event) {
|
65 |
-
jQuery(this).parents('li').first().remove();
|
66 |
-
});
|
67 |
-
jQuery(document).ready(function() {
|
68 |
-
if(typeof(jQuery( ".berocket_filter_added_list" ).sortable) == 'function') {
|
69 |
-
jQuery( ".berocket_filter_added_list" ).sortable({axis:"y", handle:".fa-bars", placeholder: "berocket_sortable_space"});
|
70 |
-
}
|
71 |
-
});
|
72 |
-
</script>
|
73 |
-
<style>
|
74 |
-
.berocket_filter_added_list li {
|
75 |
-
font-size: 1em;
|
76 |
-
border: 2px solid rgb(153, 153, 153);
|
77 |
-
background-color: rgb(238, 238, 238);
|
78 |
-
padding: 5px;
|
79 |
-
line-height: 1em;
|
80 |
-
}
|
81 |
-
.berocket_filter_added_list li .fa-bars {
|
82 |
-
margin-right: 0.5em;
|
83 |
-
cursor: move;
|
84 |
-
}
|
85 |
-
.berocket_filter_added_list small {
|
86 |
-
font-size: 0.8em;
|
87 |
-
line-height: 1.25em;
|
88 |
-
vertical-align: middle;
|
89 |
-
}
|
90 |
-
.berocket_filter_added_list li .fa-times {
|
91 |
-
margin-left: 0.5em;
|
92 |
-
cursor: pointer;
|
93 |
-
float: right;
|
94 |
-
}
|
95 |
-
.berocket_filter_added_list li .fa-times:hover {
|
96 |
-
color: black;
|
97 |
-
}
|
98 |
-
.berocket_filter_added_list .berocket_edit_filter {
|
99 |
-
vertical-align: middle;
|
100 |
-
font-size: 1em;
|
101 |
-
float: right;
|
102 |
-
line-height: 1em;
|
103 |
-
height: 1em;
|
104 |
-
display: inline-block;
|
105 |
-
}
|
106 |
-
.berocket_filter_added_list .berocket_sortable_space {
|
107 |
-
border: 2px dashed #aaa;
|
108 |
-
background: white;
|
109 |
-
font-size: 1em;
|
110 |
-
height: 1.1em;
|
111 |
-
box-sizing: content-box;
|
112 |
-
padding: 5px;
|
113 |
-
}
|
114 |
-
.berocket_filter_groups {
|
115 |
-
margin-top: 20px;
|
116 |
-
}
|
117 |
-
.berocket_filter_added_list .berocket_hidden_clickable_options {
|
118 |
-
font-size: 12px;
|
119 |
-
float: right;
|
120 |
-
margin-right: 10px;
|
121 |
-
display: none;
|
122 |
-
}
|
123 |
-
.berocket_hidden_clickable_options input{
|
124 |
-
width: 100px;
|
125 |
-
}
|
126 |
-
.berocket_filter_added_list.berocket_hidden_clickable_enabled .berocket_hidden_clickable_options {
|
127 |
-
display: inline-block;
|
128 |
-
}
|
129 |
-
.berocket_filter_list {
|
130 |
-
width: 100%;
|
131 |
-
}
|
132 |
-
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/include_exclude_list.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
<div>
|
5 |
<?php if ( is_array(berocket_isset($terms)) ) { ?>
|
6 |
<?php foreach( $terms as $term ) { ?>
|
7 |
-
<div class="element-depth-<?php echo $term->depth; ?>">
|
8 |
<label>
|
9 |
<input type="checkbox" value="<?php echo berocket_isset($term, 'term_id'); ?>" name="%field_name%[]"<?php if( in_array( $term->term_id, $selected ) ) echo ' checked'; ?>>
|
10 |
<?php echo berocket_isset($term, 'name') ?>
|
4 |
<div>
|
5 |
<?php if ( is_array(berocket_isset($terms)) ) { ?>
|
6 |
<?php foreach( $terms as $term ) { ?>
|
7 |
+
<div class="element-depth-<?php echo (empty($term->depth) ? '0' : $term->depth); ?>">
|
8 |
<label>
|
9 |
<input type="checkbox" value="<?php echo berocket_isset($term, 'term_id'); ?>" name="%field_name%[]"<?php if( in_array( $term->term_id, $selected ) ) echo ' checked'; ?>>
|
10 |
<?php echo berocket_isset($term, 'name') ?>
|
templates/single_filter/single_settings_elements.php
CHANGED
@@ -38,7 +38,7 @@ if( ! class_exists('braapf_single_filter_edit_elements') ) {
|
|
38 |
}
|
39 |
//Attribute setup elements
|
40 |
static function filter_type($settings_name, $braapf_filter_settings) {
|
41 |
-
echo '<div class="braapf_attribute_setup_flex">';
|
42 |
//FILTER TYPE
|
43 |
$filter_type_array = self::get_all_filter_type_array($braapf_filter_settings);
|
44 |
$filter_type = br_get_value_from_array($braapf_filter_settings, 'filter_type', 'price');
|
@@ -83,6 +83,7 @@ if( ! class_exists('braapf_single_filter_edit_elements') ) {
|
|
83 |
}
|
84 |
echo '</select>';
|
85 |
echo '</div>';
|
|
|
86 |
//CUSTOM TAXONOMY
|
87 |
$custom_taxonomies_list = self::get_custom_taxonomies();
|
88 |
$custom_taxonomy = br_get_value_from_array($braapf_filter_settings, 'custom_taxonomy', '');
|
@@ -268,7 +269,7 @@ if( ! class_exists('braapf_single_filter_edit_elements') ) {
|
|
268 |
$style_setting = br_get_value_from_array($braapf_filter_settings, 'style', '');
|
269 |
echo '<div class="braapf_attribute_setup_flex">';
|
270 |
echo '<div class="braapf_widget_color_pick braapf_full_select_full">';
|
271 |
-
BeRocket_AAPF_Widget_functions::
|
272 |
echo '</div>';
|
273 |
echo '</div>';
|
274 |
}
|
38 |
}
|
39 |
//Attribute setup elements
|
40 |
static function filter_type($settings_name, $braapf_filter_settings) {
|
41 |
+
echo '<div class="braapf_attribute_setup_flex braapf_filter_type_data">';
|
42 |
//FILTER TYPE
|
43 |
$filter_type_array = self::get_all_filter_type_array($braapf_filter_settings);
|
44 |
$filter_type = br_get_value_from_array($braapf_filter_settings, 'filter_type', 'price');
|
83 |
}
|
84 |
echo '</select>';
|
85 |
echo '</div>';
|
86 |
+
do_action('braapf_single_filter_filter_type', $settings_name, $braapf_filter_settings);
|
87 |
//CUSTOM TAXONOMY
|
88 |
$custom_taxonomies_list = self::get_custom_taxonomies();
|
89 |
$custom_taxonomy = br_get_value_from_array($braapf_filter_settings, 'custom_taxonomy', '');
|
269 |
$style_setting = br_get_value_from_array($braapf_filter_settings, 'style', '');
|
270 |
echo '<div class="braapf_attribute_setup_flex">';
|
271 |
echo '<div class="braapf_widget_color_pick braapf_full_select_full">';
|
272 |
+
echo BeRocket_AAPF_Widget_functions::color_image_view( $braapf_filter_settings, br_get_value_from_array($styles, array($style_setting, 'specific'), ''), true);
|
273 |
echo '</div>';
|
274 |
echo '</div>';
|
275 |
}
|
woocommerce-filters.php
CHANGED
@@ -3,14 +3,14 @@
|
|
3 |
* Plugin Name: Advanced AJAX Product Filters for WooCommerce
|
4 |
* Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-filters/?utm_source=free_plugin&utm_medium=plugins&utm_campaign=ajax_filters
|
5 |
* Description: Unlimited AJAX products filters to make your shop perfect
|
6 |
-
* Version: 1.6.
|
7 |
* Author: BeRocket
|
8 |
* Requires at least: 5.0
|
9 |
* Author URI: https://berocket.com?utm_source=free_plugin&utm_medium=plugins&utm_campaign=ajax_filters
|
10 |
* Text Domain: BeRocket_AJAX_domain
|
11 |
* Domain Path: /languages/
|
12 |
-
* WC tested up to: 6.
|
13 |
*/
|
14 |
-
define( "BeRocket_AJAX_filters_version", '1.6.
|
15 |
define( "BeRocket_AJAX_filters_file", __FILE__ );
|
16 |
include_once('main.php');
|
3 |
* Plugin Name: Advanced AJAX Product Filters for WooCommerce
|
4 |
* Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-filters/?utm_source=free_plugin&utm_medium=plugins&utm_campaign=ajax_filters
|
5 |
* Description: Unlimited AJAX products filters to make your shop perfect
|
6 |
+
* Version: 1.6.3
|
7 |
* Author: BeRocket
|
8 |
* Requires at least: 5.0
|
9 |
* Author URI: https://berocket.com?utm_source=free_plugin&utm_medium=plugins&utm_campaign=ajax_filters
|
10 |
* Text Domain: BeRocket_AJAX_domain
|
11 |
* Domain Path: /languages/
|
12 |
+
* WC tested up to: 6.7
|
13 |
*/
|
14 |
+
define( "BeRocket_AJAX_filters_version", '1.6.3' );
|
15 |
define( "BeRocket_AJAX_filters_file", __FILE__ );
|
16 |
include_once('main.php');
|