Advanced AJAX Product Filters - Version 1.4

Version Description

  • Enhancement - Additional table for taxonomies (Product categories work faster with it)
  • Enhancement - Additional table for variable products
  • Enhancement - Better Compatibility with BodyCommerce
  • Enhancement - Better Compatibility with WooJetPack product visibility by user role option
  • Enhancement - "Hide out of stock variable" option also remove variable products, that do not have variation with selected attributes
  • Fix - Generating Additional tables on large amount of data
Download this release

Release Info

Developer RazyRx
Plugin Icon wp plugin Advanced AJAX Product Filters
Version 1.4
Comparing to
See all releases

Code changes from version 1.3.7 to 1.4

addons/additional_tables/add_table.php CHANGED
@@ -7,6 +7,8 @@ class BeRocket_aapf_variations_tables {
7
  add_action( 'woocommerce_product_set_stock_status', array($this, 'set_stock_status'), 10, 3 );
8
  add_action( 'delete_post', array($this, 'delete_post'), 10, 1 );
9
  add_action( 'woocommerce_after_product_object_save', array($this, 'variation_object_save'), 10, 1 );
 
 
10
  }
11
  function wcvariation_filtering_main_query($query, $input, $terms, $limits) {
12
  $current_terms = array(0);
@@ -41,11 +43,35 @@ class BeRocket_aapf_variations_tables {
41
  return $query;
42
  }
43
  function wcvariation_filtering_total_query($query, $input, $terms, $limits) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  global $wpdb;
45
  $query_custom = array(
46
  'select' => "SELECT {$wpdb->prefix}braapf_product_stock_status_parent.post_id as id, IF({$wpdb->prefix}braapf_product_stock_status_parent.stock_status = 1, 0, 1) as out_of_stock_init",
47
  'from' => "FROM {$wpdb->prefix}braapf_product_stock_status_parent",
48
  );
 
 
 
 
 
 
 
 
49
  if ( ! empty($_POST['price_ranges']) || ! empty($_POST['price']) ) {
50
  $query_custom['join'] = "JOIN {$wpdb->prefix}wc_product_meta_lookup as wc_product_meta_lookup ON wc_product_meta_lookup.product_id = {$wpdb->prefix}braapf_product_stock_status_parent.post_id";
51
  $query_custom['where_open'] = 'WHERE';
@@ -86,6 +112,8 @@ class BeRocket_aapf_variations_tables {
86
  $wpdb->query($sql);
87
  $sql = "DELETE FROM {$wpdb->prefix}braapf_product_variation_attributes WHERE parent_id={$product_id};";
88
  $wpdb->query($sql);
 
 
89
  }
90
  function set_stock_status($product_id, $stock_status, $product) {
91
  global $wpdb;
@@ -136,6 +164,78 @@ class BeRocket_aapf_variations_tables {
136
  }
137
  }
138
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
  }
141
  new BeRocket_aapf_variations_tables();
7
  add_action( 'woocommerce_product_set_stock_status', array($this, 'set_stock_status'), 10, 3 );
8
  add_action( 'delete_post', array($this, 'delete_post'), 10, 1 );
9
  add_action( 'woocommerce_after_product_object_save', array($this, 'variation_object_save'), 10, 1 );
10
+ //hierarhical recount custom table
11
+ add_action('berocket_aapf_recount_terms_initialized', array($this, 'recount_terms_initialized'), 10, 1);
12
  }
13
  function wcvariation_filtering_main_query($query, $input, $terms, $limits) {
14
  $current_terms = array(0);
43
  return $query;
44
  }
45
  function wcvariation_filtering_total_query($query, $input, $terms, $limits) {
46
+ $current_attributes = array();
47
+ if( is_array($terms) && count($terms) ) {
48
+ foreach($terms as $term) {
49
+ if( substr( $term[0], 0, 3 ) == 'pa_' ) {
50
+ $current_attributes[] = sanitize_title($term[0]);
51
+ }
52
+ }
53
+ }
54
+ if( is_array($limits) && count($limits) ) {
55
+ foreach($limits as $attr => $term_ids) {
56
+ if( substr( $attr, 0, 3 ) == 'pa_' ) {
57
+ $current_attributes[] = sanitize_title($attr);
58
+ }
59
+ }
60
+ }
61
+ $current_attributes = array_unique($current_attributes);
62
  global $wpdb;
63
  $query_custom = array(
64
  'select' => "SELECT {$wpdb->prefix}braapf_product_stock_status_parent.post_id as id, IF({$wpdb->prefix}braapf_product_stock_status_parent.stock_status = 1, 0, 1) as out_of_stock_init",
65
  'from' => "FROM {$wpdb->prefix}braapf_product_stock_status_parent",
66
  );
67
+ $query['subquery']['subquery_2'] = array(
68
+ 'select' => 'SELECT post_id as ID, COUNT(post_id) as max_meta_count',
69
+ 'from' => "FROM {$wpdb->prefix}braapf_variation_attributes",
70
+ 'where' => "WHERE taxonomy IN ('".implode("','", $current_attributes)."')",
71
+ 'group' => 'GROUP BY post_id',
72
+ );
73
+ $query['subquery']['join_close_1'] = ') as max_filtered_post ON max_filtered_post.ID = filtered_post.ID';
74
+ $query['subquery']['select'] = 'SELECT filtered_post.*, max_filtered_post.max_meta_count, IF(max_filtered_post.max_meta_count != filtered_post.meta_count OR stock_table.out_of_stock_init = 1, 1, 0) as out_of_stock';
75
  if ( ! empty($_POST['price_ranges']) || ! empty($_POST['price']) ) {
76
  $query_custom['join'] = "JOIN {$wpdb->prefix}wc_product_meta_lookup as wc_product_meta_lookup ON wc_product_meta_lookup.product_id = {$wpdb->prefix}braapf_product_stock_status_parent.post_id";
77
  $query_custom['where_open'] = 'WHERE';
112
  $wpdb->query($sql);
113
  $sql = "DELETE FROM {$wpdb->prefix}braapf_product_variation_attributes WHERE parent_id={$product_id};";
114
  $wpdb->query($sql);
115
+ $sql = "DELETE FROM {$wpdb->prefix}braapf_variation_attributes WHERE post_id={$product_id};";
116
+ $wpdb->query($sql);
117
  }
118
  function set_stock_status($product_id, $stock_status, $product) {
119
  global $wpdb;
164
  }
165
  }
166
  }
167
+ if( $product->get_type() == 'variable' ) {
168
+ foreach ( $product->get_children() as $child_id ) {
169
+ $variation = wc_get_product( $child_id );
170
+ if ( ! $variation || ! $variation->exists() || $variation->get_type() != 'variation' ) {
171
+ continue;
172
+ }
173
+ $this->variation_object_save($variation);
174
+ }
175
+ global $wpdb;
176
+ $product_id = $product->get_id();
177
+ $sql = "DELETE FROM {$wpdb->prefix}braapf_variation_attributes WHERE post_id={$product_id};";
178
+ $wpdb->query($sql);
179
+ $sql = "INSERT INTO {$wpdb->prefix}braapf_variation_attributes
180
+ SELECT parent_id as post_id, meta_key as taxonomy
181
+ FROM {$wpdb->prefix}braapf_product_variation_attributes
182
+ WHERE parent_id={$product_id}
183
+ GROUP BY meta_key, parent_id";
184
+ $wpdb->query($sql);
185
+ }
186
+ }
187
+ function recount_terms_initialized($recount_object) {
188
+ remove_filter('berocket_aapf_recount_terms_query', array($recount_object, 'child_include'), 50, 3);
189
+ add_filter('berocket_aapf_recount_terms_query', array($this, 'child_include'), 50, 3);
190
+ }
191
+ function child_include($query, $taxonomy_data, $terms) {
192
+ global $wpdb;
193
+ extract($taxonomy_data);
194
+ if( $include_child ) {
195
+ $taxonomy_object = get_taxonomy($taxonomy);
196
+ if( ! empty($taxonomy_object->hierarchical) ) {
197
+ $this->set_hierarhical_data_to_table($taxonomy);
198
+ $table_name = $wpdb->prefix . 'braapf_term_taxonomy_hierarchical';
199
+ $join_query = "INNER JOIN (SELECT object_id,term_taxonomy.term_taxonomy_id as term_taxonomy_id, term_order FROM {$wpdb->term_relationships}
200
+ JOIN $table_name as term_taxonomy
201
+ ON {$wpdb->term_relationships}.term_taxonomy_id = term_taxonomy.term_taxonomy_child_id ) as term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id";
202
+ $query['join']['term_relationships'] = $join_query;
203
+ }
204
+ }
205
+ return $query;
206
+ }
207
+ function set_hierarhical_data_to_table($taxonomy) {
208
+ global $wpdb;
209
+ $newmd5 = $wpdb->get_var(
210
+ $wpdb->prepare(
211
+ "SELECT MD5(GROUP_CONCAT(CONCAT(tt.term_taxonomy_id, tt.term_id, tt.parent, tt.count))) FROM $wpdb->term_taxonomy AS tt
212
+ WHERE tt.taxonomy IN (%s)",
213
+ $taxonomy
214
+ )
215
+ );
216
+ $newmd5 = apply_filters('BRaapf_cache_check_md5', $newmd5, 'br_generate_child_relation', $taxonomy);
217
+ $md5 = get_option(apply_filters('br_aapf_md5_cache_text', 'br_custom_table_hierarhical_'.$taxonomy));
218
+ if($md5 != $newmd5) {
219
+ $table_name = $wpdb->prefix . 'braapf_term_taxonomy_hierarchical';
220
+ $wpdb->query("DELETE FROM $table_name WHERE taxonomy = '$taxonomy';");
221
+ $hierarchy = br_get_taxonomy_hierarchy(array('taxonomy' => $taxonomy, 'return' => 'child'));
222
+ $join_query = "INSERT INTO $table_name
223
+ SELECT tt1.term_taxonomy_id as term_taxonomy_id, tt1.term_id as term_id,
224
+ tt2.term_taxonomy_id as term_taxonomy_child_id, tt2.term_id as term_child_id,
225
+ tt1.taxonomy as taxonomy
226
+ FROM {$wpdb->term_taxonomy} as tt1
227
+ JOIN {$wpdb->term_taxonomy} as tt2 ON (";
228
+ $join_list = array();
229
+ foreach($hierarchy as $term_id => $term_child) {
230
+ $join_list[] = "(tt1.term_id = '{$term_id}' AND tt2.term_id IN('".implode("','", $term_child)."'))";
231
+ }
232
+ $join_query .= implode('
233
+ OR
234
+ ', $join_list);
235
+ $join_query .= ")";
236
+ $wpdb->query($join_query);
237
+ update_option(apply_filters('br_aapf_md5_cache_text', 'br_custom_table_hierarhical_'.$taxonomy), $newmd5);
238
+ }
239
  }
240
  }
241
  new BeRocket_aapf_variations_tables();
addons/additional_tables/additional_tables.php CHANGED
@@ -3,16 +3,47 @@ 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
  function __construct() {
7
  parent::__construct();
8
  $active_addons = apply_filters('berocket_addons_active_'.$this->plugin_name, array());
9
- $created_table = get_option('BeRocket_aapf_variations_tables_addon_ready');
10
  if( in_array($this->addon_file, $active_addons) ) {
11
- if( empty($created_table) ) {
12
  $this->activate();
 
13
  }
14
  } else {
15
- if( ! empty($created_table) ) {
16
  $this->deactivate();
17
  }
18
  }
@@ -20,17 +51,135 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
20
  function get_addon_data() {
21
  $data = parent::get_addon_data();
22
  return array_merge($data, array(
23
- 'addon_name' => __('Variations Tables (BETA)', 'BeRocket_AJAX_domain'),
24
- 'tooltip' => __('Create 2 additional table to speed up functions for variation filtering', 'BeRocket_AJAX_domain'),
25
  ));
26
  }
27
- function activate() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  global $wpdb;
29
  $charset_collate = $wpdb->get_charset_collate();
30
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
31
-
32
- //* Create dayli table
33
  $table_name = $wpdb->prefix . 'braapf_product_stock_status_parent';
 
 
34
  $sql = "CREATE TABLE $table_name (
35
  post_id BIGINT NOT NULL,
36
  parent_id BIGINT NOT NULL,
@@ -39,12 +188,45 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
39
  INDEX stock_status (stock_status)
40
  ) $charset_collate;";
41
  dbDelta( $sql );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  $sql = "INSERT INTO {$table_name}
43
  SELECT {$wpdb->posts}.ID as post_id, {$wpdb->posts}.post_parent as parent_id, IF({$wpdb->prefix}wc_product_meta_lookup.stock_status = 'instock', 1, 0) as stock_status FROM {$wpdb->prefix}wc_product_meta_lookup
44
- JOIN {$wpdb->posts} ON {$wpdb->prefix}wc_product_meta_lookup.product_id = {$wpdb->posts}.ID";
 
45
  $wpdb->query($sql);
46
- //* Create Table
 
 
 
 
 
 
 
 
 
 
 
 
47
  $table_name = $wpdb->prefix . 'braapf_product_variation_attributes';
 
 
48
  $sql = "CREATE TABLE $table_name (
49
  post_id BIGINT NOT NULL,
50
  parent_id BIGINT NOT NULL,
@@ -55,24 +237,122 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
55
  INDEX meta_value_id (meta_value_id)
56
  ) $charset_collate;";
57
  dbDelta( $sql );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  $sql = "INSERT INTO {$table_name}
59
  SELECT {$wpdb->postmeta}.post_id as post_id, {$wpdb->posts}.post_parent as parent_id, {$wpdb->term_taxonomy}.taxonomy as meta_key, {$wpdb->terms}.term_id as meta_value_id FROM {$wpdb->postmeta}
60
  JOIN {$wpdb->term_taxonomy} ON CONCAT('attribute_', {$wpdb->term_taxonomy}.taxonomy) = {$wpdb->postmeta}.meta_key
61
  JOIN {$wpdb->terms} ON {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id AND {$wpdb->postmeta}.meta_value = {$wpdb->terms}.slug
62
  JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID
63
- WHERE {$wpdb->postmeta}.meta_key LIKE 'attribute_pa_%'";
 
64
  $wpdb->query($sql);
65
- update_option('BeRocket_aapf_variations_tables_addon_ready', true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
- function deactivate() {
68
  global $wpdb;
69
- $table_name = $wpdb->prefix . 'braapf_product_stock_status_parent';
 
 
70
  $sql = "DROP TABLE IF EXISTS {$table_name};";
71
  $wpdb->query($sql);
72
- $table_name = $wpdb->prefix . 'braapf_product_variation_attributes';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  $sql = "DROP TABLE IF EXISTS {$table_name};";
74
  $wpdb->query($sql);
75
- update_option('BeRocket_aapf_variations_tables_addon_ready', false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
  }
78
  new BeRocket_aapf_variations_tables_addon();
3
  public $addon_file = __FILE__;
4
  public $plugin_name = 'ajax_filters';
5
  public $php_file_name = 'add_table';
6
+ public $last_postion = 9;
7
+ public $position_data = array(
8
+ 1 => array(
9
+ 'percentage' => 0
10
+ ),
11
+ 2 => array(
12
+ 'percentage' => 7
13
+ ),
14
+ 3 => array(
15
+ 'percentage' => 0
16
+ ),
17
+ 4 => array(
18
+ 'percentage' => 90
19
+ ),
20
+ 5 => array(
21
+ 'percentage' => 0
22
+ ),
23
+ 6 => array(
24
+ 'percentage' => 2
25
+ ),
26
+ 7 => array(
27
+ 'percentage' => 0
28
+ ),
29
+ 8 => array(
30
+ 'percentage' => 1
31
+ ),
32
+ 9 => array(
33
+ 'percentage' => 0
34
+ ),
35
+ );
36
  function __construct() {
37
  parent::__construct();
38
  $active_addons = apply_filters('berocket_addons_active_'.$this->plugin_name, array());
39
+ $create_position = $this->get_current_create_position();
40
  if( in_array($this->addon_file, $active_addons) ) {
41
+ if( $create_position < $this->last_postion ) {
42
  $this->activate();
43
+ $this->activate_hooks();
44
  }
45
  } else {
46
+ if( ! empty($create_position) ) {
47
  $this->deactivate();
48
  }
49
  }
51
  function get_addon_data() {
52
  $data = parent::get_addon_data();
53
  return array_merge($data, array(
54
+ 'addon_name' => __('Additional Tables (BETA)', 'BeRocket_AJAX_domain'),
55
+ 'tooltip' => __('Create 4 additional tables.<ul><li>Table to speed up hierarchical taxonomies recount: <strong>Product categories</strong>, <strong>Brands</strong> etc</li><li>3 tables to speed up functions for variation filtering</li></ul>', 'BeRocket_AJAX_domain'),
56
  ));
57
  }
58
+ function check_init() {
59
+ $create_position = get_option('BeRocket_aapf_additional_tables_addon_position');
60
+ if( $create_position >= $this->last_postion ) {
61
+ parent::check_init();
62
+ }
63
+ }
64
+ function get_current_create_position() {
65
+ return get_option('BeRocket_aapf_additional_tables_addon_position');
66
+ }
67
+ function set_current_create_position($position) {
68
+ update_option('BeRocket_aapf_additional_tables_addon_position', $position);
69
+ }
70
+ function get_current_create_position_data() {
71
+ return get_option('BeRocket_aapf_additional_tables_addon_position_data');
72
+ }
73
+ function set_current_create_position_data($data) {
74
+ update_option('BeRocket_aapf_additional_tables_addon_position_data', $data);
75
+ }
76
+ function activate($current_position = -1) {
77
+ if( $current_position == -1 ) {
78
+ $current_position = $this->get_current_create_position();
79
+ }
80
+ if( empty($current_position) ) {
81
+ $this->create_table_braapf_product_stock_status_parent();
82
+ } elseif( $current_position == 3 ) {
83
+ $this->create_table_braapf_product_variation_attributes();
84
+ } elseif( $current_position == 5 ) {
85
+ $this->create_table_braapf_variation_attributes();
86
+ } elseif( $current_position == 7 ) {
87
+ $this->create_table_braapf_term_taxonomy_hierarchical();
88
+ } elseif( $current_position == 8 ) {
89
+ new berocket_information_notices(array(
90
+ 'name' => $this->plugin_name.'_additional_table_status_end',
91
+ 'html' => '<strong>BeRocket AJAX Product Filters</strong> '.__('Additional tables was succesfully generated. They will be used automatically when needed.', 'BeRocket_AJAX_domain'),
92
+ 'righthtml' => '<a class="berocket_no_thanks">Got it</a>',
93
+ 'rightwidth' => 50,
94
+ 'nothankswidth' => 50,
95
+ 'contentwidth' => 400,
96
+ 'subscribe' => false,
97
+ 'height' => 50,
98
+ ));
99
+ $this->set_current_create_position(9);
100
+ }
101
+ }
102
+ function activate_hooks() {
103
+ add_action('berocket_create_table_braapf_product_stock_status_parent', array($this, 'insert_table_braapf_product_stock_status_parent'), 10, 3);
104
+ add_action('berocket_create_table_braapf_product_variation_attributes', array($this, 'insert_table_braapf_product_variation_attributes'), 10, 3);
105
+ add_action('berocket_create_table_braapf_variation_attributes', array($this, 'insert_table_braapf_variation_attributes'), 10);
106
+ //Notices
107
+ add_filter('berocket_display_additional_notices', array($this, 'status_notice'));
108
+ add_action( "wp_ajax_braapf_additional_table_status", array( $this, 'get_global_status_ajax' ) );
109
+ add_action( "wp_footer", array( $this, 'script_update' ) );
110
+ add_action( "admin_footer", array( $this, 'script_update' ) );
111
+ }
112
+ function status_notice($notices) {
113
+ $current_status = $this->get_current_global_status();
114
+ $notices[] = array(
115
+ 'start' => 0,
116
+ 'end' => 0,
117
+ 'name' => $this->plugin_name.'_additional_table_status',
118
+ 'html' => '<strong>BeRocket AJAX Product Filters</strong> '.sprintf(__('Additional tables are generating. They will be used after generation is completed. Current status is <strong><span class="braapf_additional_table_status">%d</span>%%</strong>', 'BeRocket_AJAX_domain'), $current_status),
119
+ 'righthtml' => '',
120
+ 'rightwidth' => 0,
121
+ 'nothankswidth' => 0,
122
+ 'contentwidth' => 1600,
123
+ 'subscribe' => false,
124
+ 'priority' => 10,
125
+ 'height' => 70,
126
+ 'repeat' => false,
127
+ 'repeatcount' => 1,
128
+ 'image' => array(
129
+ 'local' => '',
130
+ 'width' => 0,
131
+ 'height' => 0,
132
+ 'scale' => 1,
133
+ )
134
+ );
135
+ return $notices;
136
+ }
137
+ function script_update() {
138
+ echo '<script>
139
+ if( jQuery(".braapf_additional_table_status").length ) {
140
+ var braapf_additional_table_status = setInterval(function() {
141
+ jQuery.get(ajaxurl, {action:"braapf_additional_table_status"}, function(data) {
142
+ data = parseInt(data);
143
+ jQuery(".braapf_additional_table_status").text(data);
144
+ if( data >= 100 ) {
145
+ clearInterval(braapf_additional_table_status);
146
+ }
147
+ }).error(function() {
148
+ clearInterval(braapf_additional_table_status);
149
+ jQuery(".braapf_additional_table_status").parents(".berocket_admin_notice").remove();
150
+ });
151
+ }, 4000);
152
+ }
153
+ </script>';
154
+ }
155
+ function get_global_status_ajax() {
156
+ echo $this->get_current_global_status();
157
+ wp_die();
158
+ }
159
+ function get_current_global_status($current_position = -1) {
160
+ if( $current_position == -1 ) {
161
+ $current_position = $this->get_current_create_position();
162
+ }
163
+ $position_data = $this->get_current_create_position_data();
164
+ $position_status = br_get_value_from_array($position_data, 'status', 0);
165
+ $global_status = 0;
166
+ foreach($this->position_data as $position_i => $position_data_arr) {
167
+ if( $position_i < $current_position ) {
168
+ $global_status += $position_data_arr['percentage'];
169
+ } elseif( $position_i == $current_position ) {
170
+ $global_status += ( $position_data_arr['percentage'] / 100 * $position_status );
171
+ }
172
+ }
173
+ $global_status = intval($global_status);
174
+ return $global_status;
175
+ }
176
+ function create_table_braapf_product_stock_status_parent() {
177
  global $wpdb;
178
  $charset_collate = $wpdb->get_charset_collate();
179
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
 
 
180
  $table_name = $wpdb->prefix . 'braapf_product_stock_status_parent';
181
+ $sql = "DROP TABLE IF EXISTS {$table_name};";
182
+ $wpdb->query($sql);
183
  $sql = "CREATE TABLE $table_name (
184
  post_id BIGINT NOT NULL,
185
  parent_id BIGINT NOT NULL,
188
  INDEX stock_status (stock_status)
189
  ) $charset_collate;";
190
  dbDelta( $sql );
191
+ $sql = "SELECT MIN({$wpdb->prefix}wc_product_meta_lookup.product_id) as min, MAX({$wpdb->prefix}wc_product_meta_lookup.product_id) as max FROM {$wpdb->prefix}wc_product_meta_lookup";
192
+ $product_data = $wpdb->get_row($sql);
193
+ $this->set_current_create_position_data(array('status' => 0));
194
+ if( ! empty($product_data) && ! empty($product_data->min) && ! empty($product_data->max) ) {
195
+ $this->set_current_create_position(2);
196
+ $this->activate();
197
+ wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_product_stock_status_parent', array($product_data->min, $product_data->min, $product_data->max) );
198
+ } else {
199
+ $this->set_current_create_position(3);
200
+ $this->activate();
201
+ }
202
+ }
203
+ function insert_table_braapf_product_stock_status_parent($start_id, $min_id, $max_id) {
204
+ $end_id = $start_id + 50000;
205
+ global $wpdb;
206
+ $table_name = $wpdb->prefix . 'braapf_product_stock_status_parent';
207
+ $charset_collate = $wpdb->get_charset_collate();
208
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
209
  $sql = "INSERT INTO {$table_name}
210
  SELECT {$wpdb->posts}.ID as post_id, {$wpdb->posts}.post_parent as parent_id, IF({$wpdb->prefix}wc_product_meta_lookup.stock_status = 'instock', 1, 0) as stock_status FROM {$wpdb->prefix}wc_product_meta_lookup
211
+ JOIN {$wpdb->posts} ON {$wpdb->prefix}wc_product_meta_lookup.product_id = {$wpdb->posts}.ID
212
+ WHERE {$wpdb->prefix}wc_product_meta_lookup.product_id >= {$start_id} AND {$wpdb->prefix}wc_product_meta_lookup.product_id < {$end_id}";
213
  $wpdb->query($sql);
214
+ $status = max(0, min(100, (($end_id - $min_id) / ($max_id - $min_id) * 100)));
215
+ $this->set_current_create_position_data(array('status' => $status));
216
+ if( $end_id <= $max_id ) {
217
+ wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_product_stock_status_parent', array($end_id, $min_id, $max_id) );
218
+ } else {
219
+ $this->set_current_create_position(3);
220
+ $this->activate();
221
+ }
222
+ }
223
+ function create_table_braapf_product_variation_attributes() {
224
+ global $wpdb;
225
+ $charset_collate = $wpdb->get_charset_collate();
226
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
227
  $table_name = $wpdb->prefix . 'braapf_product_variation_attributes';
228
+ $sql = "DROP TABLE IF EXISTS {$table_name};";
229
+ $wpdb->query($sql);
230
  $sql = "CREATE TABLE $table_name (
231
  post_id BIGINT NOT NULL,
232
  parent_id BIGINT NOT NULL,
237
  INDEX meta_value_id (meta_value_id)
238
  ) $charset_collate;";
239
  dbDelta( $sql );
240
+ $sql = "SELECT MIN({$wpdb->postmeta}.meta_id) as min, MAX({$wpdb->postmeta}.meta_id) as max FROM {$wpdb->postmeta}";
241
+ $postmeta_data = $wpdb->get_row($sql);
242
+ $this->set_current_create_position_data(array('status' => 0));
243
+ if( ! empty($postmeta_data) && ! empty($postmeta_data->min) && ! empty($postmeta_data->max) ) {
244
+ $this->set_current_create_position(4);
245
+ $this->activate();
246
+ wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_product_variation_attributes', array($postmeta_data->min, $postmeta_data->min, $postmeta_data->max) );
247
+ } else {
248
+ $this->set_current_create_position(5);
249
+ $this->activate();
250
+ }
251
+ }
252
+ function insert_table_braapf_product_variation_attributes($start_id, $min_id, $max_id) {
253
+ $end_id = $start_id + 50000;
254
+ global $wpdb;
255
+ $table_name = $wpdb->prefix . 'braapf_product_variation_attributes';
256
+ $charset_collate = $wpdb->get_charset_collate();
257
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
258
  $sql = "INSERT INTO {$table_name}
259
  SELECT {$wpdb->postmeta}.post_id as post_id, {$wpdb->posts}.post_parent as parent_id, {$wpdb->term_taxonomy}.taxonomy as meta_key, {$wpdb->terms}.term_id as meta_value_id FROM {$wpdb->postmeta}
260
  JOIN {$wpdb->term_taxonomy} ON CONCAT('attribute_', {$wpdb->term_taxonomy}.taxonomy) = {$wpdb->postmeta}.meta_key
261
  JOIN {$wpdb->terms} ON {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id AND {$wpdb->postmeta}.meta_value = {$wpdb->terms}.slug
262
  JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID
263
+ WHERE {$wpdb->postmeta}.meta_id >= {$start_id} AND {$wpdb->postmeta}.meta_id < {$end_id}
264
+ AND {$wpdb->postmeta}.meta_key LIKE 'attribute_pa_%'";
265
  $wpdb->query($sql);
266
+ $sql = "INSERT INTO {$table_name}
267
+ SELECT {$wpdb->posts}.ID as post_id, {$wpdb->posts}.post_parent as parent_id, {$wpdb->term_taxonomy}.taxonomy as meta_key, {$wpdb->term_taxonomy}.term_id as meta_value_id
268
+ FROM {$wpdb->postmeta}
269
+ JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID
270
+ JOIN {$wpdb->term_relationships} ON {$wpdb->posts}.post_parent = {$wpdb->term_relationships}.object_id
271
+ JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id
272
+ AND CONCAT('attribute_', {$wpdb->term_taxonomy}.taxonomy) = {$wpdb->postmeta}.meta_key
273
+ WHERE {$wpdb->postmeta}.meta_id >= {$start_id} AND {$wpdb->postmeta}.meta_id < {$end_id}
274
+ AND {$wpdb->postmeta}.meta_key LIKE 'attribute_pa_%' AND {$wpdb->postmeta}.meta_value = ''";
275
+ $wpdb->query($sql);
276
+ $status = max(0, min(100, (($end_id - $min_id) / ($max_id - $min_id) * 100)));
277
+ $this->set_current_create_position_data(array('status' => $status));
278
+ if( $end_id <= $max_id ) {
279
+ wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_product_variation_attributes', array($end_id, $min_id, $max_id) );
280
+ } else {
281
+ $this->set_current_create_position(5);
282
+ $this->activate();
283
+ }
284
  }
285
+ function create_table_braapf_variation_attributes() {
286
  global $wpdb;
287
+ $charset_collate = $wpdb->get_charset_collate();
288
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
289
+ $table_name = $wpdb->prefix . 'braapf_variation_attributes';
290
  $sql = "DROP TABLE IF EXISTS {$table_name};";
291
  $wpdb->query($sql);
292
+ $sql = "CREATE TABLE $table_name (
293
+ post_id BIGINT(20) NOT NULL,
294
+ taxonomy varchar(32) NOT NULL,
295
+ INDEX post_id (post_id),
296
+ INDEX taxonomy (taxonomy)
297
+ ) $charset_collate;";
298
+ dbDelta( $sql );
299
+ $this->set_current_create_position_data(array('status' => 0));
300
+ $this->set_current_create_position(6);
301
+ $this->activate();
302
+ wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_variation_attributes' );
303
+ }
304
+ function insert_table_braapf_variation_attributes() {
305
+ global $wpdb;
306
+ $table_name = $wpdb->prefix . 'braapf_variation_attributes';
307
+ $charset_collate = $wpdb->get_charset_collate();
308
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
309
+ $sql = "INSERT INTO {$table_name}
310
+ SELECT parent_id as post_id, meta_key as taxonomy
311
+ FROM {$wpdb->prefix}braapf_product_variation_attributes
312
+ GROUP BY meta_key, parent_id";
313
+ $wpdb->query($sql);
314
+ $this->set_current_create_position_data(array('status' => 100));
315
+ $this->set_current_create_position(7);
316
+ $this->activate();
317
+ }
318
+ function create_table_braapf_term_taxonomy_hierarchical() {
319
+ global $wpdb;
320
+ $charset_collate = $wpdb->get_charset_collate();
321
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
322
+ $table_name = $wpdb->prefix . 'braapf_term_taxonomy_hierarchical';
323
  $sql = "DROP TABLE IF EXISTS {$table_name};";
324
  $wpdb->query($sql);
325
+ $sql = "CREATE TABLE $table_name (
326
+ term_taxonomy_id BIGINT(20) NOT NULL,
327
+ term_id BIGINT(20) NOT NULL,
328
+ term_taxonomy_child_id BIGINT(20) NOT NULL,
329
+ term_child_id BIGINT(20) NOT NULL,
330
+ taxonomy varchar(32) NOT NULL,
331
+ INDEX term_taxonomy_id (term_taxonomy_id),
332
+ INDEX term_taxonomy_child_id (term_taxonomy_child_id),
333
+ INDEX child_parent_id (term_taxonomy_id, term_taxonomy_child_id)
334
+ ) $charset_collate;";
335
+ dbDelta( $sql );
336
+ $this->set_current_create_position(8);
337
+ }
338
+ function deactivate() {
339
+ global $wpdb;
340
+ wp_unschedule_hook('berocket_create_table_braapf_product_stock_status_parent');
341
+ wp_unschedule_hook('berocket_create_table_braapf_product_variation_attributes');
342
+ wp_unschedule_hook('berocket_create_table_braapf_variation_attributes');
343
+ $tables_drop = array(
344
+ 'braapf_product_stock_status_parent',
345
+ 'braapf_product_variation_attributes',
346
+ 'braapf_variation_attributes',
347
+ 'braapf_term_taxonomy_hierarchical'
348
+ );
349
+ foreach($tables_drop as $table_drop) {
350
+ $table_name = $wpdb->prefix . $table_drop;
351
+ $sql = "DROP TABLE IF EXISTS {$table_name};";
352
+ $wpdb->query($sql);
353
+ }
354
+ $wpdb->query("DELETE FROM {$wpdb->prefix}options WHERE option_name LIKE '%br_custom_table_hierarhical_%';");
355
+ $this->set_current_create_position(false);
356
  }
357
  }
358
  new BeRocket_aapf_variations_tables_addon();
berocket/framework.php CHANGED
@@ -27,6 +27,7 @@ if( ! class_exists( 'BeRocket_Framework' ) ) {
27
  require_once( plugin_dir_path( __FILE__ ) . 'includes/updater.php');
28
  require_once( plugin_dir_path( __FILE__ ) . 'includes/widget.php');
29
  require_once( plugin_dir_path( __FILE__ ) . 'includes/admin_notices.php');
 
30
  require_once( plugin_dir_path( __FILE__ ) . 'includes/custom_post.php');
31
  require_once( plugin_dir_path( __FILE__ ) . 'includes/conditions.php');
32
  require_once( plugin_dir_path( __FILE__ ) . 'includes/plugin-variation.php');
@@ -34,7 +35,7 @@ if( ! class_exists( 'BeRocket_Framework' ) ) {
34
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
35
  load_plugin_textdomain('BeRocket_domain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
36
  class BeRocket_Framework {
37
- public static $framework_version = '2.5.5';
38
  public static $settings_name = '';
39
  public $addons;
40
  public $libraries;
27
  require_once( plugin_dir_path( __FILE__ ) . 'includes/updater.php');
28
  require_once( plugin_dir_path( __FILE__ ) . 'includes/widget.php');
29
  require_once( plugin_dir_path( __FILE__ ) . 'includes/admin_notices.php');
30
+ require_once( plugin_dir_path( __FILE__ ) . 'includes/information_notices.php');
31
  require_once( plugin_dir_path( __FILE__ ) . 'includes/custom_post.php');
32
  require_once( plugin_dir_path( __FILE__ ) . 'includes/conditions.php');
33
  require_once( plugin_dir_path( __FILE__ ) . 'includes/plugin-variation.php');
35
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
36
  load_plugin_textdomain('BeRocket_domain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
37
  class BeRocket_Framework {
38
+ public static $framework_version = '2.5.5.2';
39
  public static $settings_name = '';
40
  public $addons;
41
  public $libraries;
berocket/framework_version.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- $framework_version_current = '2.5.5';
3
  if( version_compare($framework_version_current, $framework_version, '>') ) {
4
  $framework_version = $framework_version_current;
5
  $framework_dir = __DIR__;
1
  <?php
2
+ $framework_version_current = '2.5.5.2';
3
  if( version_compare($framework_version_current, $framework_version, '>') ) {
4
  $framework_version = $framework_version_current;
5
  $framework_dir = __DIR__;
berocket/includes/information_notices.php ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*new berocket_information_notices(array(
3
+ 'start' => 1497880000, // timestamp when notice start
4
+ 'end' => 1497885000, // timestamp when notice end
5
+ 'name' => 'name', //notice name must be unique for this time period
6
+ 'html' => '', //text or html code as content of notice
7
+ 'righthtml' => '<a class="berocket_no_thanks">No thanks</a>', //content in the right block, this is default value. This html code must be added to all notices
8
+ 'rightwidth' => 80, //width of right content is static and will be as this value. berocket_no_thanks block is 60px and 20px is additional
9
+ 'nothankswidth' => 60, //berocket_no_thanks width. set to 0 if block doesn't uses. Or set to any other value if uses other text inside berocket_no_thanks
10
+ 'contentwidth' => 400, //width that uses for mediaquery is image_width + contentwidth + rightwidth
11
+ 'subscribe' => false, //add subscribe form to the righthtml
12
+ 'priority' => 20, //priority of notice. 1-5 is main priority and displays on settings page always
13
+ 'height' => 50, //height of notice. image will be scaled
14
+ 'repeat' => false, //repeat notice after some time. time can use any values that accept function strtotime
15
+ 'repeatcount' => 1, //repeat count. how many times notice will be displayed after close
16
+ 'image' => array(
17
+ 'global' => 'http://berocket.com/images/logo-2.png', //image URL from other site. Image will be copied to uploads folder if it possible
18
+ //'local' => 'http://wordpress-site.com/wp-content/uploads/logo-2.png', //notice will be used this image directly
19
+ ),
20
+ ));*/
21
+ //delete_option('berocket_information_notices'); //remove all notice information
22
+ //delete_option('berocket_last_close_notices_time'); //remove wait time before next notice
23
+ //delete_option('berocket_admin_notices_rate_stars');
24
+ if( ! class_exists( 'berocket_information_notices' ) ) {
25
+ /**
26
+ * Class berocket_admin_notices
27
+ */
28
+
29
+ class berocket_information_notices {
30
+ public static $notice_index = 10000;
31
+ public static $default_notice_options = array(
32
+ 'name' => 'sale',
33
+ 'html' => '',
34
+ 'righthtml' => '<a class="berocket_no_thanks">No thanks</a>',
35
+ 'rightwidth' => 80,
36
+ 'nothankswidth' => 60,
37
+ 'contentwidth' => 400,
38
+ 'closed' => '0',
39
+ 'priority' => 20,
40
+ 'height' => 50,
41
+ 'image' => array(
42
+ 'global' => 'http://berocket.com/images/logo-2.png'
43
+ ),
44
+ );
45
+ function __construct($options = array()) {
46
+ if( ! is_admin() ) return;
47
+ $options = array_merge(self::$default_notice_options, $options);
48
+ self::set_notice_by_path($options);
49
+ }
50
+ public static function set_notice_by_path($options, $replace = false, $find_names = false) {
51
+ $notices = get_option('berocket_information_notices');
52
+ if( ! is_array($notices) ) {
53
+ $notices = array();
54
+ }
55
+ if( empty($options['image']) || (empty($options['image']['local']) && empty($options['image']['global'])) ) {
56
+ $options['image'] = array('width' => 0, 'height' => 0, 'scale' => 0);
57
+ } else {
58
+ $file_exist = false;
59
+ if( ! $file_exist ) {
60
+ if( ! empty($options['image']['local']) ) {
61
+ $img_local = $options['image']['local'];
62
+ $img_local = str_replace(site_url('/'), '', $img_local);
63
+ $img_local = ABSPATH . $img_local;
64
+ $file_exist = ( file_exists($img_local) );
65
+ } else {
66
+ $file_exist = false;
67
+ }
68
+ }
69
+ if( $file_exist ) {
70
+ $check_size = true;
71
+ if( isset($current_notice['image']['local']) && $current_notice['image']['local'] == $options['image']['local'] ) {
72
+ if( isset($current_notice['image']['width']) && isset($current_notice['image']['height']) ) {
73
+ $options['image']['width'] = $current_notice['image']['width'];
74
+ $options['image']['height'] = $current_notice['image']['height'];
75
+ $check_size = false;
76
+ }
77
+ }
78
+ if( $check_size ) {
79
+ $image_size = @ getimagesize($options['image']['local']);
80
+ if( ! empty($image_size[0]) && ! empty($image_size[1]) ) {
81
+ $options['image']['width'] = $image_size[0];
82
+ $options['image']['height'] = $image_size[1];
83
+ } else {
84
+ $options['image']['width'] = $options['height'];
85
+ $options['image']['height'] = $options['height'];
86
+ }
87
+ }
88
+ $options['image']['scale'] = $options['height'] / $options['image']['height'];
89
+ } else {
90
+ $options['image'] = array('width' => 0, 'height' => 0, 'scale' => 0);
91
+ }
92
+ }
93
+ $notices[$options['name']] = $options;
94
+ update_option('berocket_information_notices', $notices);
95
+ return true;
96
+ }
97
+ public static function get_notices() {
98
+ $notices = get_option('berocket_information_notices');
99
+ return $notices;
100
+ }
101
+ public static function display_notice() {
102
+ $notices = self::get_notices();
103
+ if( is_array($notices) && count($notices) > 0 ) {
104
+ foreach($notices as $notice) {
105
+ if( is_array($notice) ) {
106
+ self::echo_notice($notice);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ public static function echo_notice($notice) {
112
+ $notice = array_merge(self::$default_notice_options, $notice);
113
+ $settings_page = apply_filters('is_berocket_settings_page', false);
114
+ self::$notice_index++;
115
+ $notice_data = array(
116
+ 'name' => $notice['name'],
117
+ );
118
+ if( ! empty($notice['subscribe']) ) {
119
+ $user_email = wp_get_current_user();
120
+ if( isset($user_email->user_email) ) {
121
+ $user_email = $user_email->user_email;
122
+ } else {
123
+ $user_email = '';
124
+ }
125
+ $notice['righthtml'] =
126
+ '<form class="berocket_subscribe_form" method="POST" action="' . admin_url( 'admin-ajax.php' ) . '">
127
+ <input type="hidden" name="berocket_action" value="berocket_subscribe_email">
128
+ <input class="berocket_subscribe_email" type="email" name="email" value="' . $user_email . '">
129
+ <input type="submit" class="button-primary button berocket_notice_submit" value="Subscribe">
130
+ </form>' . $notice['righthtml'];
131
+ $notice['rightwidth'] += 300;
132
+ }
133
+ echo '
134
+ <div class="notice berocket_admin_notice berocket_admin_notice_', self::$notice_index, '" data-notice=\'', json_encode($notice_data), '\'>',
135
+ ( empty($notice['image']['local']) ? '' : '<img class="berocket_notice_img" src="' . $notice['image']['local'] . '">' ),
136
+ ( empty($notice['righthtml']) ? '' :
137
+ '<div class="berocket_notice_right_content">
138
+ <div class="berocket_notice_content">' . $notice['righthtml'] . '</div>
139
+ <div class="berocket_notice_after_content"></div>
140
+ </div>' ),
141
+ '<div class="berocket_notice_content_wrap">
142
+ <div class="berocket_notice_content">', $notice['html'], '</div>
143
+ <div class="berocket_notice_after_content"></div>
144
+ </div></div>';
145
+ echo '<style>
146
+ .berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' {
147
+ height: ', $notice['height'], 'px;
148
+ padding: 0;
149
+ min-width: ', max($notice['image']['width'] * $notice['image']['scale'], $notice['rightwidth']), 'px;
150
+ border-left: 0 none;
151
+ border-radius: 3px;
152
+ overflow: hidden;
153
+ box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.2);
154
+ }
155
+ .berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' .berocket_notice_img {
156
+ height: ', $notice['height'], 'px;
157
+ width: ', ($notice['image']['width'] * $notice['image']['scale']), 'px;
158
+ float: left;
159
+ }
160
+ .berocket_admin_notice .berocket_notice_content_wrap {
161
+ margin-left: ', ($notice['image']['width'] * $notice['image']['scale'] + 5), 'px;
162
+ margin-right: ', ($notice['rightwidth'] <= 20 ? 0 : $notice['rightwidth'] + 15), 'px;
163
+ box-sizing: border-box;
164
+ height: ', $notice['height'], 'px;
165
+ overflow: auto;
166
+ overflow-x: hidden;
167
+ overflow-y: auto;
168
+ font-size: 16px;
169
+ line-height: 1em;
170
+ text-align: center;
171
+ }
172
+ .berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' .berocket_notice_right_content {',
173
+ ( $notice['rightwidth'] <= 20 ? ' display: none' :
174
+ 'height: ' . $notice['height'] . 'px;
175
+ float: right;
176
+ width: ' . $notice['rightwidth'] . 'px;
177
+ -webkit-box-shadow: box-shadow: -1px 0 0 0 rgba(0, 0, 0, 0.1);
178
+ box-shadow: -1px 0 0 0 rgba(0, 0, 0, 0.1);
179
+ padding-left: 10px;' ),
180
+ '}
181
+ .berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' .berocket_no_thanks {
182
+ cursor: pointer;
183
+ color: #0073aa;
184
+ opacity: 0.5;
185
+ display: inline-block;
186
+ }
187
+ @media screen and (min-width: 783px) and (max-width: ', round($notice['image']['width'] * $notice['image']['scale'] + $notice['rightwidth'] + $notice['contentwidth'] + 10 + 200), 'px) {
188
+ div.berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' .berocket_notice_content_wrap {
189
+ font-size: 14px;
190
+ }
191
+ div.berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' .berocket_button {
192
+ padding: 4px 15px;
193
+ }
194
+ }
195
+ @media screen and (max-width: 782px) {
196
+ div.berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' .berocket_notice_content_wrap {
197
+ margin-left: 0;
198
+ margin-right: 0;
199
+ clear: both;
200
+ height: initial;
201
+ }
202
+ div.berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' .berocket_notice_content {
203
+ line-height: 2.5em;
204
+ }
205
+ div.berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' .berocket_notice_content .berocket_button {
206
+ line-height: 1em;
207
+ }
208
+ div.berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' {
209
+ height: initial;
210
+ text-align: center;
211
+ padding: 20px;
212
+ }
213
+ .berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' .berocket_notice_img {
214
+ float: none;
215
+ display: inline-block;
216
+ }
217
+ div.berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' .berocket_notice_right_content {
218
+ display: block;
219
+ float: none;
220
+ clear: both;
221
+ width: 100%;
222
+ -webkit-box-shadow: none;
223
+ box-shadow: none;
224
+ padding: 0;
225
+ }
226
+ }
227
+ </style>
228
+ <script>
229
+ jQuery(document).ready(function() {
230
+ jQuery(document).on("click", ".berocket_admin_notice.berocket_admin_notice_', self::$notice_index, ' .berocket_no_thanks", function(event){
231
+ event.preventDefault();
232
+ var notice = jQuery(this).parents(".berocket_admin_notice.berocket_admin_notice_', self::$notice_index, '").data("notice");
233
+ jQuery.post(ajaxurl, {action:"berocket_information_close_notice", notice:notice}, function(data){});
234
+ jQuery(this).parents(".berocket_admin_notice.berocket_admin_notice_', self::$notice_index, '").hide();
235
+ });
236
+ });';
237
+ echo '</script>';
238
+ berocket_admin_notices::echo_styles();
239
+ berocket_admin_notices::echo_jquery_functions();
240
+ }
241
+ public static function close_notice($notice = FALSE) {
242
+ if( ( $notice == FALSE || ! is_array($notice) ) && ! empty($_POST['notice']) ) {
243
+ $notice = sanitize_textarea_field($_POST['notice']);
244
+ }
245
+ $notices = self::get_notices();
246
+ if( empty($notice) || empty($notice['name']) ) {
247
+ $notices = array();
248
+ } elseif( isset($notices[$notice['name']]) ) {
249
+ unset($notices[$notice['name']]);
250
+ }
251
+ update_option('berocket_information_notices', $notices);
252
+ wp_die();
253
+ }
254
+ }
255
+ add_action( 'admin_notices', array('berocket_information_notices', 'display_notice') );
256
+ add_action( 'wp_ajax_berocket_information_close_notice', array('berocket_information_notices', 'close_notice') );
257
+ }
258
+ ?>
berocket/libraries/addons/addons.php CHANGED
@@ -29,9 +29,10 @@ if( ! class_exists('BeRocket_framework_addons') ) {
29
  ), 10, 2 );
30
  }
31
  function load_addons() {
 
32
  if( ! empty($this->options['addons']) && is_array($this->options['addons']) ) {
33
  foreach($this->options['addons'] as $addon) {
34
- if( file_exists($this->info['plugin_dir'].'/addons'.$addon) ) {
35
  include_once($this->info['plugin_dir'].'/addons'.$addon);
36
  }
37
  }
29
  ), 10, 2 );
30
  }
31
  function load_addons() {
32
+ $addons_exist = $this->get_addons();
33
  if( ! empty($this->options['addons']) && is_array($this->options['addons']) ) {
34
  foreach($this->options['addons'] as $addon) {
35
+ if( ! empty($addon) && in_array($addon, $addons_exist) && file_exists($this->info['plugin_dir'].'/addons'.$addon) ) {
36
  include_once($this->info['plugin_dir'].'/addons'.$addon);
37
  }
38
  }
includes/addons/woocommerce-variation.php CHANGED
@@ -137,7 +137,7 @@ class BeRocket_AAPF_compat_woocommerce_variation {
137
  BeRocket_AAPF::$error_log['_addons_variations_query'][] = array(
138
  'query' => $query,
139
  'result' => $out_of_stock_variable,
140
- 'terms' => wc_get_product_visibility_term_ids()
141
  );
142
  }
143
  $post_not_in = array();
@@ -197,21 +197,23 @@ class BeRocket_AAPF_compat_woocommerce_variation {
197
  }
198
  }
199
  }
200
- $taxonomy_terms = wp_list_pluck($terms, 'term_id');
201
  $limit_post__not_in = array();
202
- foreach($taxonomy_terms as $taxonomy_term_id) {
203
- $new_post_limits[$taxonomy] = array($taxonomy_term_id);
204
- $limit_post__not_in[$taxonomy_term_id] = apply_filters('berocket_add_out_of_stock_variable', array(), $new_post_terms, $new_post_limits);
205
  }
206
 
207
  if( is_array($limit_post__not_in) && count($limit_post__not_in) ) {
208
  $limit_post__not_in_where_array = array();
209
  $limit_post__term_id_without_product = array();
210
  foreach($limit_post__not_in as $terms_id => $limit_post) {
 
 
 
211
  if( is_array($limit_post) && count($limit_post) ) {
212
- $limit_post__not_in_where_array[$terms_id] = "({$wpdb->posts}.ID NOT IN (\"" . implode('","', $limit_post) . "\") AND term_relationships.term_taxonomy_id = {$terms_id})";
213
  } else {
214
- $limit_post__term_id_without_product[] = $terms_id;
215
  }
216
  }
217
  if( count($limit_post__term_id_without_product) ) {
@@ -220,7 +222,9 @@ class BeRocket_AAPF_compat_woocommerce_variation {
220
  $limit_post__not_in_where = implode(' OR ', $limit_post__not_in_where_array);
221
  }
222
  if( empty($br_options['out_of_stock_variable_single']) && ! empty($limit_post__not_in_where) ) {
223
- $query['where']['post__not_in'] = "AND ({$limit_post__not_in_where})";
 
 
224
  }
225
  $this->limit_post__not_in_where_array = $limit_post__not_in_where_array;
226
  }
137
  BeRocket_AAPF::$error_log['_addons_variations_query'][] = array(
138
  'query' => $query,
139
  'result' => $out_of_stock_variable,
140
+ 'terms' => $terms
141
  );
142
  }
143
  $post_not_in = array();
197
  }
198
  }
199
  }
 
200
  $limit_post__not_in = array();
201
+ foreach($terms as $term_data) {
202
+ $new_post_limits[$taxonomy] = array($term_data->term_id);
203
+ $limit_post__not_in[$term_data->term_taxonomy_id] = apply_filters('berocket_add_out_of_stock_variable', array(), $new_post_terms, $new_post_limits);
204
  }
205
 
206
  if( is_array($limit_post__not_in) && count($limit_post__not_in) ) {
207
  $limit_post__not_in_where_array = array();
208
  $limit_post__term_id_without_product = array();
209
  foreach($limit_post__not_in as $terms_id => $limit_post) {
210
+ $wp_term = get_term($terms_id);
211
+ if( empty($wp_term) || is_wp_error($wp_term) ) continue;
212
+ $wp_terms_id = $wp_term->term_taxonomy_id;
213
  if( is_array($limit_post) && count($limit_post) ) {
214
+ $limit_post__not_in_where_array[$wp_terms_id] = "({$wpdb->posts}.ID NOT IN (\"" . implode('","', $limit_post) . "\") AND term_relationships.term_taxonomy_id = {$wp_terms_id})";
215
  } else {
216
+ $limit_post__term_id_without_product[] = $wp_terms_id;
217
  }
218
  }
219
  if( count($limit_post__term_id_without_product) ) {
222
  $limit_post__not_in_where = implode(' OR ', $limit_post__not_in_where_array);
223
  }
224
  if( empty($br_options['out_of_stock_variable_single']) && ! empty($limit_post__not_in_where) ) {
225
+ $query['where'] = berocket_insert_to_array($query['where'], 'post__not_in', array(
226
+ 'post__not_in_variation' => " AND ({$limit_post__not_in_where})"
227
+ ));
228
  }
229
  $this->limit_post__not_in_where_array = $limit_post__not_in_where_array;
230
  }
includes/compatibility/bodycommerce.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! function_exists('berocket_aapf_bodycommerce_archive_module_args') ) {
3
+ add_filter('db_archive_module_args', 'berocket_aapf_bodycommerce_archive_module_args');
4
+ function berocket_aapf_bodycommerce_archive_module_args( $new_args ) {
5
+ if ( function_exists('br_aapf_args_parser') ) {
6
+ //global $wp_query, $wp_rewrite;
7
+ $br_options = apply_filters( 'berocket_aapf_listener_br_options', BeRocket_AAPF::get_aapf_option() );
8
+
9
+ $add_to_args = array();
10
+ if ( ! empty($_POST['limits']) && is_array($_POST['limits']) ) {
11
+ foreach ( $_POST['limits'] as $post_key => $t ) {
12
+ if( $t[0] == '_date' ) {
13
+ $from = $t[1];
14
+ $to = $t[2];
15
+ $from = substr($from, 0, 2).'/'.substr($from, 2, 2).'/'.substr($from, 4, 4);
16
+ $to = substr($to, 0, 2).'/'.substr($to, 2, 2).'/'.substr($to, 4, 4);
17
+ $from = date('Y-m-d 00:00:00', strtotime($from));
18
+ $to = date('Y-m-d 23:59:59', strtotime($to));
19
+ $add_to_args['date_query'] = array(
20
+ 'after' => $from,
21
+ 'before' => $to,
22
+ );
23
+ unset($_POST['limits'][$post_key]);
24
+ }
25
+ }
26
+ }
27
+ $BeRocket_AAPF = BeRocket_AAPF::getInstance();
28
+ if ( ! empty($_POST['terms']) && is_array($_POST['terms']) ) {
29
+ $stop_sale = false;
30
+ $check_sale = $check_notsale = 0;
31
+ foreach ( $_POST['terms'] as $post_key => $t ) {
32
+ if( $t[0] == 'price' ) {
33
+ if( preg_match( "~\*~", $t[1] ) ) {
34
+ if( ! isset( $_POST['price_ranges'] ) ) {
35
+ $_POST['price_ranges'] = array();
36
+ }
37
+ $_POST['price_ranges'][] = $t[1];
38
+ unset( $_POST['terms'][$post_key] );
39
+ }
40
+ } elseif( $t[0] == '_sale' ) {
41
+ // if both used do nothing
42
+ if ( $t[0] == '_sale' and $t[3] == 'sale' ) {
43
+ $check_sale++;
44
+ }
45
+ if ( $t[0] == '_sale' and $t[3] == 'notsale' ) {
46
+ $check_notsale++;
47
+ }
48
+ unset($_POST['terms'][$post_key]);
49
+ } elseif( $t[0] == '_rating' ) {
50
+ $_POST['terms'][$post_key][0] = 'product_visibility';
51
+ }
52
+ }
53
+ if ( ! empty($br_options['slug_urls']) ) {
54
+ foreach ( $_POST['terms'] as $post_key => $t ) {
55
+ if( $t[0] == '_stock_status' ) {
56
+ $_stock_status = array( 'instock' => 1, 'outofstock' => 2);
57
+ $_POST['terms'][$post_key][1] = (isset($_stock_status[$t[1]]) ? $_stock_status[$t[1]] : $_stock_status['instock']);
58
+ } else {
59
+ $t[1] = get_term_by( 'slug', $t[3], $t[0] );
60
+ $t[1] = $t[1]->term_id;
61
+ $_POST['terms'][$post_key] = $t;
62
+ }
63
+ }
64
+ }
65
+
66
+ if ( ! ($check_sale and $check_notsale) ) {
67
+ if ( $check_sale ) {
68
+ $add_to_args['post__in'] = array_merge( array( 0 ), wc_get_product_ids_on_sale() );
69
+ } elseif( $check_notsale ) {
70
+ $add_to_args['post__in'] = array_merge( array( 0 ), $BeRocket_AAPF->wc_get_product_ids_not_on_sale() );
71
+ }
72
+ }
73
+ }
74
+
75
+ $woocommerce_hide_out_of_stock_items = BeRocket_AAPF_Widget::woocommerce_hide_out_of_stock_items();
76
+
77
+ $meta_query = $BeRocket_AAPF->remove_out_of_stock( array() , true, $woocommerce_hide_out_of_stock_items != 'yes' );
78
+
79
+ $args = apply_filters( 'berocket_aapf_listener_wp_query_args', array() );
80
+ foreach($add_to_args as $arg_name => $add_arg) {
81
+ $args[$arg_name] = $add_arg;
82
+ }
83
+ if( ! empty($_POST['limits']) ) {
84
+ $args = apply_filters('berocket_aapf_convert_limits_to_tax_query', $args, $_POST['limits']);
85
+ }
86
+ if( ! isset($args['post__in']) ) {
87
+ $args['post__in'] = array();
88
+ }
89
+ if( $woocommerce_hide_out_of_stock_items == 'yes' ) {
90
+ $args['post__in'] = $BeRocket_AAPF->remove_out_of_stock( $args['post__in'] );
91
+ }
92
+ if( ! br_woocommerce_version_check() ) {
93
+ $args['post__in'] = $BeRocket_AAPF->remove_hidden( $args['post__in'] );
94
+ }
95
+ $args['meta_query'] = $meta_query;
96
+
97
+ if( ! empty($_POST['limits']) ) {
98
+ $args = apply_filters('berocket_aapf_convert_limits_to_tax_query', $args, $_POST['limits']);
99
+ }
100
+ if( isset($_POST['price']) && is_array($_POST['price']) ) {
101
+ $_POST['price'] = apply_filters('berocket_min_max_filter', $_POST['price']);
102
+ }
103
+ $min = isset( $_POST['price'][0] ) ? floatval( $_POST['price'][0] ) : 0;
104
+ $max = isset( $_POST['price'][1] ) ? floatval( $_POST['price'][1] ) : 9999999999;
105
+
106
+ $args['meta_query'][] = array(
107
+ 'key' => apply_filters('berocket_price_filter_meta_key', '_price', 'widget_2847'),
108
+ 'value' => array( $min, $max ),
109
+ 'compare' => 'BETWEEN',
110
+ 'type' => 'DECIMAL',
111
+ 'price_filter' => true,
112
+ );
113
+ /*$args['post_status'] = 'publish';
114
+ if ( is_user_logged_in() ) {
115
+ $args['post_status'] .= '|private';
116
+ }*/
117
+ $args['post_type'] = 'product';
118
+ //$default_posts_per_page = get_option( 'posts_per_page' );
119
+ //$args['posts_per_page'] = apply_filters( 'loop_shop_per_page', $default_posts_per_page );
120
+
121
+ if ( ! empty($_POST['price_ranges']) && is_array($_POST['price_ranges']) ) {
122
+ $price_range_query = array( 'relation' => 'OR' );
123
+ foreach ( $_POST['price_ranges'] as $range ) {
124
+ $range = explode( '*', $range );
125
+ $price_range_query[] = array( 'key' => apply_filters('berocket_price_filter_meta_key', '_price', 'widget_2867'), 'compare' => 'BETWEEN', 'type' => 'NUMERIC', 'value' => array( ($range[0] - 1), $range[1] ) );
126
+ }
127
+ $args['meta_query'][] = $price_range_query;
128
+ }
129
+
130
+ if( isset($_POST['product_taxonomy']) && $_POST['product_taxonomy'] != '-1' && strpos( $_POST['product_taxonomy'], '|' ) !== FALSE ) {
131
+ $product_taxonomy = explode( '|', $_POST['product_taxonomy'] );
132
+ $args['taxonomy'] = $product_taxonomy[0];
133
+ $args['term'] = $product_taxonomy[1];
134
+ }
135
+ if( isset($_POST['s']) && strlen($_POST['s']) > 0 ) {
136
+ $args['s'] = $_POST['s'];
137
+ }
138
+
139
+ /*if( function_exists('wc_get_product_visibility_term_ids') ) {
140
+ $product_visibility_term_ids = wc_get_product_visibility_term_ids();
141
+
142
+ $args['tax_query'][] = array(
143
+ 'taxonomy' => 'product_visibility',
144
+ 'field' => 'term_taxonomy_id',
145
+ 'terms' => array($product_visibility_term_ids['exclude-from-catalog']),
146
+ 'operator' => 'NOT IN'
147
+ );
148
+ }*/
149
+ /*
150
+ $args = array_merge($args, WC()->query->get_catalog_ordering_args());
151
+
152
+ $wp_query = new WP_Query( $args );
153
+
154
+ // here we get max products to know if current page is not too big
155
+ $is_using_permalinks = $wp_rewrite->using_permalinks();
156
+ if ( empty( $_POST['location'] ) and ! empty ( $_GET['location'] ) ) {
157
+ $_POST['location'] = $_GET['location'];
158
+ } else {
159
+ $_POST['location'] = 0;
160
+ }
161
+ if ( $is_using_permalinks and preg_match( "~/page/([0-9]+)~", $_POST['location'], $mathces ) or preg_match( "~paged?=([0-9]+)~", $_POST['location'], $mathces ) ) {
162
+ $args['paged'] = min( $mathces[1], $wp_query->max_num_pages );
163
+ }
164
+ */
165
+
166
+ $new_args = $new_args + $args;
167
+ }
168
+
169
+ return $new_args;
170
+ }
171
+ }
includes/compatibility/woojetpack.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! class_exists('BeRocket_AAPF_compat_woojetpack') ) {
4
+
5
+ class BeRocket_AAPF_compat_woojetpack {
6
+ function __construct() {
7
+ add_filter('berocket_aapf_get_attribute_values_post__not_in_outside', array($this, 'product_by_user_role'));
8
+ }
9
+ function product_by_user_role( $query_args ) {
10
+ if ( ! function_exists('wcj_get_current_user_all_roles') ) return $query_args;
11
+
12
+ $option_to_check = wcj_get_current_user_all_roles();
13
+ $post__not_in = ( isset( $query_args['post__not_in'] ) ? $query_args['post__not_in'] : array() );
14
+ $args = $query_args;
15
+ $args['fields'] = 'ids';
16
+ $args['posts_per_page'] = -1;
17
+ $args['post_type'] = 'product';
18
+ $loop = new WP_Query( $args );
19
+ foreach ( $loop->posts as $product_id ) {
20
+ if ( ! $this->is_product_visible( $product_id, $option_to_check, 'product_by_user_role' ) ) {
21
+ $post__not_in[] = $product_id;
22
+ }
23
+ }
24
+
25
+ return $post__not_in;
26
+ }
27
+
28
+ function is_product_visible( $product_id, $option_to_check, $id ) {
29
+ if ( ! function_exists('wcj_maybe_get_product_id_wpml') ) return true;
30
+
31
+ if ( 'invisible' != apply_filters( 'booster_option', 'visible', get_option( 'wcj_' . $id . '_visibility_method', 'visible' ) ) ) {
32
+ $visible = get_post_meta( wcj_maybe_get_product_id_wpml( $product_id ), '_' . 'wcj_' . $id . '_visible', true );
33
+ if ( ! empty( $visible ) && is_array( $visible ) ) {
34
+ if ( is_array( $option_to_check ) ) {
35
+ $the_intersect = array_intersect( $visible, $option_to_check );
36
+ if ( empty( $the_intersect ) ) {
37
+ return false;
38
+ }
39
+ } else {
40
+ if ( ! in_array( $option_to_check, $visible ) ) {
41
+ return false;
42
+ }
43
+ }
44
+ }
45
+ }
46
+ if ( 'visible' != apply_filters( 'booster_option', 'visible', get_option( 'wcj_' . $id . '_visibility_method', 'visible' ) ) ) {
47
+ $invisible = get_post_meta( wcj_maybe_get_product_id_wpml( $product_id ), '_' . 'wcj_' . $id . '_invisible', true );
48
+ if ( ! empty( $invisible ) && is_array( $invisible ) ) {
49
+ if ( is_array( $option_to_check ) ) {
50
+ $the_intersect = array_intersect( $invisible, $option_to_check );
51
+ if ( ! empty( $the_intersect ) ) {
52
+ return false;
53
+ }
54
+ } else {
55
+ if ( in_array( $option_to_check, $invisible ) ) {
56
+ return false;
57
+ }
58
+ }
59
+ }
60
+ }
61
+ return true;
62
+ }
63
+ }
64
+ new BeRocket_AAPF_compat_woojetpack();
65
+ }
includes/display_filter.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class BeRocket_AAPF_display_filters_additional_type {
3
+ public static $type_slug;
4
+ public static $type_name;
5
+ public static $custom_type_list = array();
6
+ public static $needed_options = array();
7
+ function __construct() {
8
+ if( ! empty(static::$type_slug) && empty(self::$custom_type_list[static::$type_slug]) ) {
9
+ self::$custom_type_list[static::$type_slug] = $this;
10
+ $this->init();
11
+ }
12
+ }
13
+ function init() {
14
+ add_filter('berocket_aapf_display_filter_custom_type', array($this, 'custom_type'), 10, 3);
15
+ add_filter('berocket_aapf_display_filter_type_list', array($this, 'type_list'));
16
+ }
17
+ function type_list($list) {
18
+ $list[static::$type_slug] = static::$type_name;
19
+ return $list;
20
+ }
21
+ function custom_type($html, $type, $additional = array()) {
22
+ if( $type == static::$type_slug ) {
23
+ $additional['options'] = $this->check_input_options($additional['options']);
24
+ $html = $this->return_html($html, $additional);
25
+ }
26
+ return $html;
27
+ }
28
+ public function check_input_options(&$options = array()) {
29
+ if( ! is_array($options) ) {
30
+ $options = array();
31
+ }
32
+ $options = array_merge(static::$needed_options, $options);
33
+ return $options;
34
+ }
35
+ public static function return_html($html, $additional) {
36
+ return $html;
37
+ }
38
+ public static function get_option() {
39
+ $BeRocket_AAPF = BeRocket_AAPF::getInstance();
40
+ return $BeRocket_AAPF->get_option();
41
+ }
42
+ }
includes/display_filter/reset_button.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class BeRocket_AAPF_display_filters_reset_button_type extends BeRocket_AAPF_display_filters_additional_type {
3
+ public static $type_slug = 'reset_button';
4
+ public static $type_name;
5
+ public static $needed_options = array(
6
+ 'title' => 'Reset Filters',
7
+ 'is_hide_mobile' => false
8
+ );
9
+ function init() {
10
+ static::$type_name = __('Reset Products button', 'BeRocket_AJAX_domain');
11
+ parent::init();
12
+ }
13
+ public static function return_html($html, $additional) {
14
+ extract($additional['options']);
15
+ $br_options = self::get_option();
16
+ $set_query_var_title = array(
17
+ 'title' => $additional['options']['title'],
18
+ 'uo' => br_aapf_converter_styles( (empty($br_options['styles']) ? NULL : $br_options['styles']) ),
19
+ 'is_hide_mobile' => ( empty($additional['options']['is_hide_mobile']) ? '' : $additional['options']['is_hide_mobile'] )
20
+ );
21
+ set_query_var( 'berocket_query_var_title', $set_query_var_title );
22
+ ob_start();
23
+ br_get_template_part( 'widget_reset_button' );
24
+ return ob_get_clean();
25
+ }
26
+ }
27
+ new BeRocket_AAPF_display_filters_reset_button_type();
includes/display_filter/selected_area.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class BeRocket_AAPF_display_filters_selected_area_type extends BeRocket_AAPF_display_filters_additional_type {
3
+ public static $type_slug = 'selected_area';
4
+ public static $type_name;
5
+ public static $needed_options = array(
6
+ 'title' => '',
7
+ 'scroll_theme' => 'dark',
8
+ 'is_hide_mobile' => false,
9
+ 'selected_area_show' => '0',
10
+ 'hide_selected_arrow' => '0',
11
+ 'selected_is_hide' => '0',
12
+ );
13
+ function init() {
14
+ static::$type_name = __('Selected Filters area', 'BeRocket_AJAX_domain');
15
+ parent::init();
16
+ }
17
+ public static function return_html($html, $additional) {
18
+ $br_options = self::get_option();
19
+ $style = br_get_value_from_array($additional, array('args', 'widget_inline_style'));
20
+ $set_query_var_title = array(
21
+ 'title' => $additional['options']['title'],
22
+ 'uo' => br_aapf_converter_styles( (empty($br_options['styles']) ? NULL : $br_options['styles']) ),
23
+ 'is_hide_mobile' => ( empty($additional['options']['is_hide_mobile']) ? '' : $additional['options']['is_hide_mobile'] ),
24
+ 'selected_area_show' => $additional['options']['selected_area_show'],
25
+ 'hide_selected_arrow' => $additional['options']['hide_selected_arrow'],
26
+ 'selected_is_hide' => $additional['options']['selected_is_hide'],
27
+ 'style' => $style,
28
+ );
29
+ set_query_var( 'berocket_query_var_title', $set_query_var_title );
30
+ ob_start();
31
+ br_get_template_part( 'widget_selected_area' );
32
+ return ob_get_clean();
33
+ }
34
+ }
35
+ new BeRocket_AAPF_display_filters_selected_area_type();
includes/display_filter/update_button.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class BeRocket_AAPF_display_filters_update_button_type extends BeRocket_AAPF_display_filters_additional_type {
3
+ public static $type_slug = 'update_button';
4
+ public static $type_name;
5
+ public static $needed_options = array(
6
+ 'title' => 'Update',
7
+ 'is_hide_mobile' => false
8
+ );
9
+ function init() {
10
+ static::$type_name = __('Update Products button', 'BeRocket_AJAX_domain');
11
+ parent::init();
12
+ }
13
+ public static function return_html($html, $additional) {
14
+ $br_options = self::get_option();
15
+ $set_query_var_title = array(
16
+ 'title' => $additional['options']['title'],
17
+ 'uo' => br_aapf_converter_styles( (empty($br_options['styles']) ? NULL : $br_options['styles']) ),
18
+ 'is_hide_mobile' => ( empty($additional['options']['is_hide_mobile']) ? '' : $additional['options']['is_hide_mobile'] )
19
+ );
20
+ set_query_var( 'berocket_query_var_title', $set_query_var_title );
21
+ ob_start();
22
+ br_get_template_part( 'widget_update_button' );
23
+ return ob_get_clean();
24
+ }
25
+ }
26
+ new BeRocket_AAPF_display_filters_update_button_type();
27
+
includes/faster_recount.php CHANGED
@@ -11,13 +11,12 @@ class BeRocket_AAPF_faster_attribute_recount {
11
  add_filter('berocket_aapf_recount_terms_query', array($this, 'stock_status_query'), 20, 3);
12
  //Sale Status custom recount
13
  add_filter('berocket_aapf_recount_terms_query', array($this, 'onsale_query'), 20, 3);
 
 
 
 
14
  }
15
  function recount_terms($terms = FALSE, $taxonomy_data = array()) {
16
- if( BeRocket_AAPF::$debug_mode ) {
17
- if( empty(BeRocket_AAPF::$error_log['faster_recount_sql']) || ! is_array(BeRocket_AAPF::$error_log['faster_recount_sql']) ) {
18
- BeRocket_AAPF::$error_log['faster_recount_sql'] = array();
19
- }
20
- }
21
  $taxonomy_data = apply_filters('berocket_recount_taxonomy_data', array_merge(array(
22
  'taxonomy' => '',
23
  'operator' => 'OR',
@@ -28,6 +27,18 @@ class BeRocket_AAPF_faster_attribute_recount {
28
  'post__in' => array(),
29
  'include_child' => TRUE
30
  ), $taxonomy_data), $terms);
 
 
 
 
 
 
 
 
 
 
 
 
31
  extract($taxonomy_data);
32
  global $wpdb;
33
  if( $terms === FALSE ) {
11
  add_filter('berocket_aapf_recount_terms_query', array($this, 'stock_status_query'), 20, 3);
12
  //Sale Status custom recount
13
  add_filter('berocket_aapf_recount_terms_query', array($this, 'onsale_query'), 20, 3);
14
+ add_action('plugins_loaded', array($this, 'plugins_loaded'));
15
+ }
16
+ function plugins_loaded() {
17
+ do_action('berocket_aapf_recount_terms_initialized', $this);
18
  }
19
  function recount_terms($terms = FALSE, $taxonomy_data = array()) {
 
 
 
 
 
20
  $taxonomy_data = apply_filters('berocket_recount_taxonomy_data', array_merge(array(
21
  'taxonomy' => '',
22
  'operator' => 'OR',
27
  'post__in' => array(),
28
  'include_child' => TRUE
29
  ), $taxonomy_data), $terms);
30
+ global $braapf_recount_taxonomy_data;
31
+ $braapf_recount_taxonomy_data = $taxonomy_data;
32
+ $result = $this->recount_terms_without_prepare($terms, $taxonomy_data);
33
+ $braapf_recount_taxonomy_data = FALSE;
34
+ return $result;
35
+ }
36
+ function recount_terms_without_prepare($terms = FALSE, $taxonomy_data = array()) {
37
+ if( BeRocket_AAPF::$debug_mode ) {
38
+ if( empty(BeRocket_AAPF::$error_log['faster_recount_sql']) || ! is_array(BeRocket_AAPF::$error_log['faster_recount_sql']) ) {
39
+ BeRocket_AAPF::$error_log['faster_recount_sql'] = array();
40
+ }
41
+ }
42
  extract($taxonomy_data);
43
  global $wpdb;
44
  if( $terms === FALSE ) {
includes/functions.php CHANGED
@@ -531,7 +531,9 @@ if( ! function_exists( 'br_aapf_args_converter' ) ) {
531
  $filters = explode( "|", $_GET['filters'] );
532
  } elseif( $_GET['filters' ]) {
533
  $filters[0] = $_GET['filters'];
534
- }
 
 
535
  foreach ( $filters as $filter ) {
536
  if( isset($min) ) {
537
  unset($min);
@@ -554,36 +556,6 @@ if( ! function_exists( 'br_aapf_args_converter' ) ) {
554
  } elseif ( preg_match( "~\-~", $value ) ) {
555
  $value = explode( "-", $value );
556
  if( ! empty($br_options['slug_urls']) && $attribute != '_stock_status' && $attribute != '_sale' ) {
557
- /*for( $i = 0; $i < count($value); $i++ ) {
558
- $value[$i] = urldecode( $value[$i] );
559
- while( 1 ) {
560
- if ( ! term_exists( $value[$i], $attribute ) && ! term_exists( $value[$i], 'pa_'.$attribute ) ) {
561
- if( $i + 1 < count($value) )
562
- {
563
- $value[$i] = $value[$i].'-'.urldecode( $value[$i+1] );
564
- unset( $value[$i+1] );
565
- $value = array_values ( $value );
566
- } else {
567
- break;
568
- }
569
- } else {
570
- $test_value = $value[$i].'-'.urldecode( $value[$i+1] );
571
- if ( ! term_exists( $test_value, $attribute ) && ! term_exists( $test_value, 'pa_'.$attribute ) ) {
572
- break;
573
- } else {
574
- if( $i + 1 < count($value) )
575
- {
576
- $value[$i] = $value[$i].'-'.urldecode( $value[$i+1] );
577
- unset( $value[$i+1] );
578
- $value = array_values ( $value );
579
- } else {
580
- break;
581
- }
582
- }
583
- }
584
- }
585
- }*/
586
-
587
  $values = array();
588
  for ( $i = 0; $i < count( $value) ; $i++ ) {
589
  $values[ $i ] = urldecode( $value[ $i ] );
@@ -626,6 +598,8 @@ if( ! function_exists( 'br_aapf_args_converter' ) ) {
626
  list( $attribute, $value ) = explode( "-", $filter, 2 );
627
  }
628
 
 
 
629
  if ( $attribute == 'price' ) {
630
  if ( isset( $min ) && isset( $max ) ) {
631
  $_POST['price'] = apply_filters('berocket_min_max_filter', array( $min, $max ));
@@ -2227,103 +2201,135 @@ if ( ! function_exists( 'br_filters_query' ) ) {
2227
  }
2228
 
2229
  if( ! function_exists('berocket_add_filter_to_link') ) {
2230
- add_filter('berocket_add_filter_to_link', 'berocket_add_filter_to_link', 100, 2);
2231
- function berocket_add_filter_to_link($current_url = FALSE, $args = array()) {
2232
- $args = array_merge(array(
2233
- 'attribute' => '',
2234
- 'values' => array(),
2235
- 'operator' => 'OR',
2236
- 'remove_attribute' => FALSE,
2237
- 'slider' => FALSE
2238
- ), $args);
2239
- extract($args);
2240
- if( ! is_array($values) ) {
2241
- $values = array($values);
 
 
2242
  }
 
2243
  $options = BeRocket_AAPF::get_aapf_option();
2244
 
2245
- if( $current_url === FALSE ) {
2246
- $current_url = "//" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
2247
- $filters = (empty($_GET['filters']) ? '' : $_GET['filters']);
2248
  } else {
2249
- parse_str(parse_url($current_url, PHP_URL_QUERY), $filters);
2250
- $filters = br_get_value_from_array($filters, 'filters');
2251
  }
2252
- $current_url = remove_query_arg('filters', $current_url);
2253
- if( strpos($current_url, '?') === FALSE ) {
2254
- $url_string = $current_url;
 
2255
  $query_string = '';
2256
  } else {
2257
- list($url_string, $query_string) = explode('?', $current_url);
2258
  }
2259
- list($url_string, $query_string, $filters) = apply_filters( 'berocket_add_filter_to_link_explode', array($url_string, $query_string, $filters) );
2260
- if( empty($options['seo_uri_decode']) ) {
2261
- $filters = urlencode($filters);
2262
- $filters = str_replace('+', urlencode('+'), $filters);
2263
- $filters = urldecode($filters);
 
 
 
 
 
 
2264
  }
2265
- if( substr($attribute, 0, 3) == 'pa_' ) {
2266
- $attribute = substr($attribute, 3);
 
2267
  }
2268
- if( strpos('|'.$filters, '|'.$attribute.'[') === FALSE ) {
2269
- $filters = ( empty($filters) ? '' : $filters.'|' ).$attribute.'['.implode(($slider ? '_' : ($operator == 'OR' ? '-' : '+')), $values).']';
2270
- $filter_array = explode('|', $filters);
 
2271
  } else {
2272
- $filter_array = explode('|', $filters);
2273
- foreach($filter_array as $filter_str_i => $filter_str) {
2274
- if( strpos($filter_str, $attribute.'[') !== FALSE ) {
 
 
2275
  $filter_str = str_replace($attribute.'[', '', $filter_str);
2276
  $filter_str = str_replace(']', '', $filter_str);
2277
- $filter_values = array();
2278
- if( $slider ) {
2279
- $implode = '_';
2280
  $filter_str = '';
2281
- } elseif( strpos($filter_str, '+') !== FALSE ) {
 
 
 
2282
  $implode = '+';
2283
- } elseif( strpos($filter_str, '-') !== FALSE ) {
2284
  $implode = '-';
2285
- } elseif( strpos($filter_str, '_') !== FALSE ) {
2286
- $implode = ($operator == 'OR' ? '-' : '+');
2287
  $filter_str = '';
2288
  } else {
2289
- $implode = ($operator == 'OR' ? '-' : '+');
2290
  }
2291
- if( ! empty($filter_str) ) {
2292
- $filter_values = explode($implode, $filter_str);
 
 
2293
  }
2294
- foreach($values as $value) {
2295
- if( ($search_i = array_search($value, $filter_values) ) === FALSE ) {
2296
- if( $remove_attribute ) {
2297
- $filter_values = array($value);
 
2298
  } else {
2299
  $filter_values[] = $value;
2300
  }
2301
  } else {
2302
- unset($filter_values[$search_i]);
2303
  }
2304
  }
2305
- if( count($filter_values) ) {
2306
- $filter_str = $attribute.'['.implode($implode, $filter_values).']';
2307
- $filter_array[$filter_str_i] = $filter_str;
 
2308
  } else {
2309
- unset($filter_array[$filter_str_i]);
2310
  }
 
2311
  break;
2312
  }
2313
  }
2314
  }
 
2315
  $implode = '|';
2316
- list($filter_array, $implode) = apply_filters('berocket_add_filter_to_link_filters_str', array($filter_array, $implode));
2317
- $filters = implode($implode, $filter_array);
2318
- list($url_string, $query_string, $filters) = apply_filters( 'berocket_add_filter_to_link_implode', array($url_string, $query_string, $filters) );
2319
- if( ! empty($query_string) ) {
 
 
 
 
 
 
 
 
 
2320
  $url_string .= '?' . $query_string;
2321
  }
2322
- if( ! empty($filters) ) {
2323
- $url_string = add_query_arg('filters', $filters, $url_string);
 
2324
  }
2325
- $filters = $url_string;
2326
- return $filters;
2327
  }
2328
  }
2329
 
531
  $filters = explode( "|", $_GET['filters'] );
532
  } elseif( $_GET['filters' ]) {
533
  $filters[0] = $_GET['filters'];
534
+ }
535
+
536
+ global $br_url_parser_middle_result;
537
  foreach ( $filters as $filter ) {
538
  if( isset($min) ) {
539
  unset($min);
556
  } elseif ( preg_match( "~\-~", $value ) ) {
557
  $value = explode( "-", $value );
558
  if( ! empty($br_options['slug_urls']) && $attribute != '_stock_status' && $attribute != '_sale' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559
  $values = array();
560
  for ( $i = 0; $i < count( $value) ; $i++ ) {
561
  $values[ $i ] = urldecode( $value[ $i ] );
598
  list( $attribute, $value ) = explode( "-", $filter, 2 );
599
  }
600
 
601
+ $br_url_parser_middle_result[ $attribute ] = $value;
602
+
603
  if ( $attribute == 'price' ) {
604
  if ( isset( $min ) && isset( $max ) ) {
605
  $_POST['price'] = apply_filters('berocket_min_max_filter', array( $min, $max ));
2201
  }
2202
 
2203
  if( ! function_exists('berocket_add_filter_to_link') ) {
2204
+ add_filter( 'berocket_add_filter_to_link', 'berocket_add_filter_to_link', 100, 2 );
2205
+ function berocket_add_filter_to_link( $current_url = false, $args = array() ) {
2206
+ $args = array_merge( array(
2207
+ 'attribute' => '',
2208
+ 'values' => array(),
2209
+ 'operator' => 'OR',
2210
+ 'remove_attribute' => false,
2211
+ 'slider' => false
2212
+ ), $args );
2213
+
2214
+ extract( $args );
2215
+
2216
+ if ( ! is_array( $values ) ) {
2217
+ $values = array( $values );
2218
  }
2219
+
2220
  $options = BeRocket_AAPF::get_aapf_option();
2221
 
2222
+ if ( $current_url === false ) {
2223
+ $current_url = "//" . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
2224
+ $filters = ( empty( $_GET[ 'filters' ] ) ? '' : $_GET[ 'filters' ] );
2225
  } else {
2226
+ parse_str( parse_url( $current_url, PHP_URL_QUERY ), $filters );
2227
+ $filters = br_get_value_from_array( $filters, 'filters' );
2228
  }
2229
+
2230
+ $current_url = remove_query_arg( 'filters', $current_url );
2231
+ if ( strpos( $current_url, '?' ) === false ) {
2232
+ $url_string = $current_url;
2233
  $query_string = '';
2234
  } else {
2235
+ list( $url_string, $query_string ) = explode( '?', $current_url );
2236
  }
2237
+
2238
+ list( $url_string, $query_string, $filters ) = apply_filters( 'berocket_add_filter_to_link_explode', array(
2239
+ $url_string,
2240
+ $query_string,
2241
+ $filters
2242
+ ) );
2243
+
2244
+ if ( empty( $options[ 'seo_uri_decode' ] ) ) {
2245
+ $filters = urlencode( $filters );
2246
+ $filters = str_replace( '+', urlencode( '+' ), $filters );
2247
+ $filters = urldecode( $filters );
2248
  }
2249
+
2250
+ if ( substr( $attribute, 0, 3 ) == 'pa_' ) {
2251
+ $attribute = substr( $attribute, 3 );
2252
  }
2253
+
2254
+ if ( strpos( '|' . $filters, '|' . $attribute . '[' ) === false ) {
2255
+ $filters = ( empty( $filters ) ? '' : $filters . '|' ) . $attribute . '[' . implode( ( $slider ? '_' : ( $operator == 'OR' ? '-' : '+' ) ), $values ) . ']';
2256
+ $filter_array = explode( '|', $filters );
2257
  } else {
2258
+ $filter_array = explode( '|', $filters );
2259
+ global $br_url_parser_middle_result;
2260
+
2261
+ foreach ( $filter_array as $filter_str_i => $filter_str ) {
2262
+ if ( strpos( $filter_str, $attribute . '[' ) !== false ) {
2263
  $filter_str = str_replace($attribute.'[', '', $filter_str);
2264
  $filter_str = str_replace(']', '', $filter_str);
2265
+ if ( $slider ) {
2266
+ $implode = '_';
 
2267
  $filter_str = '';
2268
+ } elseif ( $attribute == 'price' ) {
2269
+ $implode = '-';
2270
+ $filter_str = '';
2271
+ } elseif ( strpos( $filter_str, '+' ) !== false ) {
2272
  $implode = '+';
2273
+ } elseif ( strpos( $filter_str, '-' ) !== false ) {
2274
  $implode = '-';
2275
+ } elseif ( strpos( $filter_str, '_' ) !== false ) {
2276
+ $implode = ( $operator == 'OR' ? '-' : '+' );
2277
  $filter_str = '';
2278
  } else {
2279
+ $implode = ( $operator == 'OR' ? '-' : '+' );
2280
  }
2281
+
2282
+ $filter_values = $br_url_parser_middle_result[$attribute];
2283
+ if ( ! empty( $filter_str ) and ! $filter_values ) {
2284
+ $filter_values = explode( $implode, $filter_str );
2285
  }
2286
+
2287
+ foreach ( $values as $value ) {
2288
+ if ( ( $search_i = array_search( $value, $filter_values ) ) === false ) {
2289
+ if ( $remove_attribute ) {
2290
+ $filter_values = array( $value );
2291
  } else {
2292
  $filter_values[] = $value;
2293
  }
2294
  } else {
2295
+ unset( $filter_values[ $search_i ] );
2296
  }
2297
  }
2298
+
2299
+ if ( count( $filter_values ) ) {
2300
+ $filter_str = $attribute . '[' . implode( $implode, $filter_values ) . ']';
2301
+ $filter_array[ $filter_str_i ] = $filter_str;
2302
  } else {
2303
+ unset( $filter_array[ $filter_str_i ] );
2304
  }
2305
+
2306
  break;
2307
  }
2308
  }
2309
  }
2310
+
2311
  $implode = '|';
2312
+ list( $filter_array, $implode ) = apply_filters( 'berocket_add_filter_to_link_filters_str', array(
2313
+ $filter_array,
2314
+ $implode
2315
+ ) );
2316
+
2317
+ $filters = implode( $implode, $filter_array );
2318
+ list( $url_string, $query_string, $filters ) = apply_filters( 'berocket_add_filter_to_link_implode', array(
2319
+ $url_string,
2320
+ $query_string,
2321
+ $filters
2322
+ ) );
2323
+
2324
+ if ( ! empty( $query_string ) ) {
2325
  $url_string .= '?' . $query_string;
2326
  }
2327
+
2328
+ if ( ! empty( $filters ) ) {
2329
+ $url_string = add_query_arg( 'filters', $filters, $url_string );
2330
  }
2331
+
2332
+ return $url_string;
2333
  }
2334
  }
2335
 
includes/widget.php CHANGED
@@ -260,12 +260,9 @@ class BeRocket_AAPF_Widget extends WP_Widget {
260
  if( ! $selected ) {
261
  $instance['type'] = $first;
262
  }
263
- $widget_type_array = apply_filters( 'berocket_widget_widget_type_array', array(
264
  'filter' => __('Filter', 'BeRocket_AJAX_domain'),
265
- 'update_button' => __('Update Products button', 'BeRocket_AJAX_domain'),
266
- 'reset_button' => __('Reset Products button', 'BeRocket_AJAX_domain'),
267
- 'selected_area' => __('Selected Filters area', 'BeRocket_AJAX_domain'),
268
- ) );
269
  if( ! array_key_exists($instance['widget_type'], $widget_type_array) ) {
270
  foreach($widget_type_array as $widget_type_id => $widget_type_name) {
271
  $instance['widget_type'] = $widget_type_id;
@@ -481,56 +478,13 @@ class BeRocket_AAPF_Widget extends WP_Widget {
481
  }
482
  if( apply_filters( 'berocket_aapf_widget_display_custom_filter', false, berocket_isset($widget_type), $instance, $args, $this ) ) return '';
483
 
484
- if ( ! empty($widget_type) && $widget_type == 'update_button' ) {
485
- $set_query_var_title = array(
486
- 'title' => apply_filters( 'berocket_aapf_widget_title', $title ),
487
- 'uo' => br_aapf_converter_styles( (empty($br_options['styles']) ? NULL : $br_options['styles']) ),
488
- 'is_hide_mobile' => ( empty($is_hide_mobile) ? '' : $is_hide_mobile )
489
- );
490
- set_query_var( 'berocket_query_var_title', $set_query_var_title );
491
- echo $before_widget;
492
- br_get_template_part( 'widget_update_button' );
493
- echo $after_widget;
494
- $widget_error_log['return'] = 'update_button';
495
- BeRocket_AAPF::$error_log['6_widgets'][] = $widget_error_log;
496
- $this->restore_wp_the_query($br_wc_query, $wp_the_query, $wp_query, $wc_query, $old_the_query, $old_query);
497
- return '';
498
- }
499
-
500
- if ( ! empty($widget_type) && $widget_type == 'reset_button' ) {
501
- $set_query_var_title = array(
502
- 'title' => apply_filters( 'berocket_aapf_widget_title', $title ),
503
- 'uo' => br_aapf_converter_styles( (empty($br_options['styles']) ? NULL : $br_options['styles']) ),
504
- 'is_hide_mobile' => ( empty($is_hide_mobile) ? '' : $is_hide_mobile )
505
- );
506
- set_query_var( 'berocket_query_var_title', $set_query_var_title );
507
- echo $before_widget;
508
- br_get_template_part( 'widget_reset_button' );
509
- echo $after_widget;
510
- $widget_error_log['return'] = 'reset_button';
511
- BeRocket_AAPF::$error_log['6_widgets'][] = $widget_error_log;
512
- $this->restore_wp_the_query($br_wc_query, $wp_the_query, $wp_query, $wc_query, $old_the_query, $old_query);
513
- return '';
514
- }
515
-
516
- if ( ! empty($widget_type) && $widget_type == 'selected_area' ) {
517
- if ( empty($scroll_theme) ) {
518
- $scroll_theme = 'dark';
519
  }
520
- $set_query_var_title = array(
521
- 'title' => apply_filters( 'berocket_aapf_widget_title', $title ),
522
- 'uo' => br_aapf_converter_styles( (empty($br_options['styles']) ? NULL : $br_options['styles']) ),
523
- 'is_hide_mobile' => ( empty($is_hide_mobile) ? '' : $is_hide_mobile ),
524
- 'selected_area_show' => $selected_area_show,
525
- 'hide_selected_arrow' => $hide_selected_arrow,
526
- 'selected_is_hide' => $selected_is_hide,
527
- );
528
- set_query_var( 'berocket_query_var_title', $set_query_var_title );
529
- echo $before_widget;
530
- br_get_template_part( 'widget_selected_area' );
531
- echo $after_widget;
532
-
533
- $widget_error_log['return'] = 'selected_area';
534
  BeRocket_AAPF::$error_log['6_widgets'][] = $widget_error_log;
535
  $this->restore_wp_the_query($br_wc_query, $wp_the_query, $wp_query, $wc_query, $old_the_query, $old_query);
536
  return '';
@@ -646,7 +600,10 @@ class BeRocket_AAPF_Widget extends WP_Widget {
646
  $terms_unsort = self::set_terms_on_same_level( $terms_unsort, array(), ($type != 'checkbox' && $type != 'radio') );
647
  $terms = BeRocket_AAPF_Widget::get_attribute_values( $attribute, 'id', ( empty($br_options['show_all_values']) ), ( ! empty($br_options['recount_products']) ), $terms_unsort, ( isset($cat_value_limit) ? $cat_value_limit : null ), $operator );
648
  if ( isset( $depth_count ) ) {
649
- $old_terms = $terms;
 
 
 
650
  $terms = array();
651
 
652
  foreach( $terms_unsort as $term_unsort ) {
@@ -770,11 +727,35 @@ class BeRocket_AAPF_Widget extends WP_Widget {
770
  $terms = BeRocket_AAPF_Widget::get_attribute_values( $custom_taxonomy, 'id', ( empty($br_options['show_all_values']) ), ( ! empty($br_options['recount_products']) ), $terms, ( isset($cat_value_limit) ? $cat_value_limit : null ), $operator );
771
  }
772
  if ( $order_values_by != 'Default' || in_array($custom_taxonomy, array('berocket_brand', 'product_cat')) ) {
773
- self::sort_terms( $terms, array(
774
- "order_values_by" => $order_values_by,
775
- "attribute" => $custom_taxonomy,
776
- "order_values_type"=> (empty($order_values_type) || $order_values_type == 'asc' ? SORT_ASC : SORT_DESC)
777
- ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
778
  }
779
  if ( ! br_is_filtered() && $child_parent != 'parent' && $child_parent != 'child' ) {
780
  br_set_cache( $custom_taxonomy . $order_values_by, $terms, $filter_type . $wp_check_product_cat, BeRocket_AJAX_cache_expire );
@@ -1272,6 +1253,26 @@ class BeRocket_AAPF_Widget extends WP_Widget {
1272
  $query[ 'where' ] .= "wp_price_check.meta_key = '".apply_filters('berocket_price_filter_meta_key', '_price', 'widget_1243')."' AND wp_price_check.meta_value > ''";
1273
  }
1274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1275
  $query_string = implode( ' ', $query );
1276
 
1277
  $query_string = $wpdb->get_row( $query_string );
@@ -1312,20 +1313,35 @@ class BeRocket_AAPF_Widget extends WP_Widget {
1312
  if( empty($post__not_in) || ! is_array($post__not_in) || count($post__not_in) == 0 ) {
1313
  $post__not_in = false;
1314
  }
1315
- if( $product_cat || $hide_empty) {
 
 
 
 
1316
  $terms = apply_filters('berocket_aapf_recount_terms_apply', $terms, array(
1317
  'taxonomy' => $taxonomy,
1318
  'operator' => $operator,
1319
  'use_filters' => FALSE,
1320
- 'post__not_in' => $post__not_in,
1321
- 'post__in' => $post__in
1322
  ));
1323
  } elseif(empty($terms)) {
1324
- $terms = get_terms(array('taxonomy' => $taxonomy, 'hide_empty' => true));
1325
- }
1326
- foreach($terms as $term_id => $term) {
1327
- if( $term->count == 0 ) {
1328
- unset($terms[$term_id]);
 
 
 
 
 
 
 
 
 
 
 
1329
  }
1330
  }
1331
  if (
@@ -1339,79 +1355,13 @@ class BeRocket_AAPF_Widget extends WP_Widget {
1339
  'taxonomy' => $taxonomy,
1340
  'operator' => $operator,
1341
  'use_filters' => TRUE,
1342
- 'post__not_in' => $post__not_in,
1343
- 'post__in' => $post__in
1344
  ));
1345
  }
1346
  return $terms;
1347
  }
1348
 
1349
- public static function product_cat_recount_with_child_pid( $terms, $re, &$new_re, $parent_products = array() ) {
1350
- foreach ( $terms as &$term ) {
1351
- $term_products = array();
1352
-
1353
- if ( ! empty($re[ $term->term_id ]->PID ) ) {
1354
- $term_products = array_unique(explode( ',', $re[ $term->term_id ]->PID ));
1355
-
1356
- if ( ! empty($term_products) ) {
1357
-
1358
- $parent_products = array_unique( (array) array_merge( $term_products, $parent_products ) );
1359
- }
1360
- }
1361
-
1362
- if ( ! empty( $term->child ) ) {
1363
- if ( ! isset( $re[ $term->term_id ] ) ) {
1364
- $re[ $term->term_id ] = $terms[ $term->term_id ];
1365
- }
1366
- $new_re[ $term->term_id ] = $re[ $term->term_id ];
1367
-
1368
- $re[ $term->term_id ]->PID = self::product_cat_recount_with_child_pid( $term->child, $re, $new_re, $term_products );
1369
- unset($re[ $term->term_id ]->child);
1370
- $re[ $term->term_id ]->count = count( $re[ $term->term_id ]->PID );
1371
-
1372
- $new_re[ $term->term_id ] = $re[ $term->term_id ];
1373
-
1374
- $parent_products = array_unique( (array) array_merge( $re[ $term->term_id ]->PID, $parent_products ) );
1375
- } else if ( isset( $re[ $term->term_id ] ) ) {
1376
- $re[ $term->term_id ]->PID = $term_products;
1377
- $re[ $term->term_id ]->count = count( $term_products );
1378
- $new_re[ $term->term_id ] = $re[ $term->term_id ];
1379
- }
1380
- }
1381
-
1382
- return $parent_products;
1383
- }
1384
-
1385
- //FIXME: do we still need it?
1386
- public static function product_cat_recount_with_child($terms, &$re) {
1387
- $global_count = 0;
1388
-
1389
- foreach($terms as &$term) {
1390
- $products = array();
1391
- if ( $re[$term->term_id]->PID ) {
1392
- $products = explode( ',', $re[ $term->term_id ]->PID );
1393
- }
1394
-
1395
- if ( $product_ids ) {
1396
- $products = array_merge( $product_ids, $products );
1397
- }
1398
-
1399
- $count = $re[$term->term_id]->count;
1400
- if( isset($re[$term->term_id]) and $term->parent ) {
1401
- $count = (int) count( array_unique( $products ) );
1402
- }
1403
-
1404
- if( !empty($term->child) ) {
1405
- $count += self::product_cat_recount_with_child($term->child, $re, array_unique( $products ) );
1406
- if( isset($re[$term->term_id]) ) {
1407
- $re[$term->term_id]->count = $count;
1408
- }
1409
- }
1410
- $global_count += $count;
1411
- }
1412
- return $global_count;
1413
- }
1414
-
1415
  public static function sort_child_parent_hierarchy($terms) {
1416
  $terms_sort = array();
1417
  $new_terms = $terms;
260
  if( ! $selected ) {
261
  $instance['type'] = $first;
262
  }
263
+ $widget_type_array = apply_filters( 'berocket_widget_widget_type_array', apply_filters( 'berocket_aapf_display_filter_type_list', array(
264
  'filter' => __('Filter', 'BeRocket_AJAX_domain'),
265
+ ) ) );
 
 
 
266
  if( ! array_key_exists($instance['widget_type'], $widget_type_array) ) {
267
  foreach($widget_type_array as $widget_type_id => $widget_type_name) {
268
  $instance['widget_type'] = $widget_type_id;
478
  }
479
  if( apply_filters( 'berocket_aapf_widget_display_custom_filter', false, berocket_isset($widget_type), $instance, $args, $this ) ) return '';
480
 
481
+ if( ! empty($widget_type) && $custom_type_html = apply_filters('berocket_aapf_display_filter_custom_type', '', $widget_type, array('options' => $instance, 'args' => $args)) ) {
482
+ if( $custom_type_html !== TRUE ) {
483
+ echo $before_widget;
484
+ echo $custom_type_html;
485
+ echo $after_widget;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  }
487
+ $widget_error_log['return'] = $widget_type;
 
 
 
 
 
 
 
 
 
 
 
 
 
488
  BeRocket_AAPF::$error_log['6_widgets'][] = $widget_error_log;
489
  $this->restore_wp_the_query($br_wc_query, $wp_the_query, $wp_query, $wc_query, $old_the_query, $old_query);
490
  return '';
600
  $terms_unsort = self::set_terms_on_same_level( $terms_unsort, array(), ($type != 'checkbox' && $type != 'radio') );
601
  $terms = BeRocket_AAPF_Widget::get_attribute_values( $attribute, 'id', ( empty($br_options['show_all_values']) ), ( ! empty($br_options['recount_products']) ), $terms_unsort, ( isset($cat_value_limit) ? $cat_value_limit : null ), $operator );
602
  if ( isset( $depth_count ) ) {
603
+ $old_terms = array();
604
+ foreach($terms as $term_data) {
605
+ $old_terms[$term_data->term_id] = $term_data;
606
+ }
607
  $terms = array();
608
 
609
  foreach( $terms_unsort as $term_unsort ) {
727
  $terms = BeRocket_AAPF_Widget::get_attribute_values( $custom_taxonomy, 'id', ( empty($br_options['show_all_values']) ), ( ! empty($br_options['recount_products']) ), $terms, ( isset($cat_value_limit) ? $cat_value_limit : null ), $operator );
728
  }
729
  if ( $order_values_by != 'Default' || in_array($custom_taxonomy, array('berocket_brand', 'product_cat')) ) {
730
+ if( $custom_taxonomy == 'product_cat' ) {
731
+ $terms_unsort = br_get_cat_hierarchy(array(), 0, 0 );
732
+ self::sort_terms( $terms_unsort, array(
733
+ "order_values_by" => $order_values_by,
734
+ "attribute" => $custom_taxonomy,
735
+ "order_values_type"=> (empty($order_values_type) || $order_values_type == 'asc' ? SORT_ASC : SORT_DESC)
736
+ ) );
737
+
738
+ $terms_unsort = self::set_terms_on_same_level( $terms_unsort, array(), ($type != 'checkbox' && $type != 'radio') );
739
+ if ( isset( $depth_count ) ) {
740
+ $old_terms = array();
741
+ foreach($terms as $term_data) {
742
+ $old_terms[$term_data->term_id] = $term_data;
743
+ }
744
+ $terms = array();
745
+
746
+ foreach( $terms_unsort as $term_unsort ) {
747
+ if ( ! empty( $old_terms[ $term_unsort->term_id ] ) ) {
748
+ $terms[ $term_unsort->term_id ] = $old_terms[ $term_unsort->term_id ];
749
+ }
750
+ }
751
+ }
752
+ } else {
753
+ self::sort_terms( $terms, array(
754
+ "order_values_by" => $order_values_by,
755
+ "attribute" => $custom_taxonomy,
756
+ "order_values_type"=> (empty($order_values_type) || $order_values_type == 'asc' ? SORT_ASC : SORT_DESC)
757
+ ) );
758
+ }
759
  }
760
  if ( ! br_is_filtered() && $child_parent != 'parent' && $child_parent != 'child' ) {
761
  br_set_cache( $custom_taxonomy . $order_values_by, $terms, $filter_type . $wp_check_product_cat, BeRocket_AJAX_cache_expire );
1253
  $query[ 'where' ] .= "wp_price_check.meta_key = '".apply_filters('berocket_price_filter_meta_key', '_price', 'widget_1243')."' AND wp_price_check.meta_value > ''";
1254
  }
1255
 
1256
+ if ( $post__not_in = apply_filters('berocket_aapf_get_attribute_values_post__not_in_outside', false) ) {
1257
+ if ( $query[ 'where' ] ) {
1258
+ $query[ 'where' ] .= " AND ";
1259
+ } else {
1260
+ $query[ 'where' ] = " WHERE ";
1261
+ }
1262
+
1263
+ $query[ 'where' ] .= "$wpdb->posts.ID NOT IN(" . implode( ',', $post__not_in ) . ")";
1264
+ }
1265
+ if ( $post__in = apply_filters('berocket_aapf_get_attribute_values_post__in_outside', false) ) {
1266
+ if ( $query[ 'where' ] ) {
1267
+ $query[ 'where' ] .= " AND ";
1268
+ } else {
1269
+ $query[ 'where' ] = " WHERE ";
1270
+ }
1271
+
1272
+ $query[ 'where' ] .= "$wpdb->posts.ID IN(" . implode( ',', $post__not_in ) . ")";
1273
+ }
1274
+
1275
+
1276
  $query_string = implode( ' ', $query );
1277
 
1278
  $query_string = $wpdb->get_row( $query_string );
1313
  if( empty($post__not_in) || ! is_array($post__not_in) || count($post__not_in) == 0 ) {
1314
  $post__not_in = false;
1315
  }
1316
+ global $braapf_not_filtered_data;
1317
+ if( isset($braapf_not_filtered_data['post__not_in']) ) {
1318
+ $post__not_in = $braapf_not_filtered_data['post__not_in'];
1319
+ }
1320
+ if( $hide_empty ) {
1321
  $terms = apply_filters('berocket_aapf_recount_terms_apply', $terms, array(
1322
  'taxonomy' => $taxonomy,
1323
  'operator' => $operator,
1324
  'use_filters' => FALSE,
1325
+ 'post__not_in' => apply_filters('berocket_aapf_get_attribute_values_post__not_in_outside', $post__not_in),
1326
+ 'post__in' => apply_filters('berocket_aapf_get_attribute_values_post__in_outside', $post__in)
1327
  ));
1328
  } elseif(empty($terms)) {
1329
+ $terms = get_terms( array(
1330
+ 'taxonomy' => $taxonomy,
1331
+ 'hide_empty' => true,
1332
+ 'hierarchical' => true,
1333
+ 'post__not_in' => apply_filters('berocket_aapf_get_attribute_values_post__not_in_outside', false),
1334
+ 'post__in' => apply_filters('berocket_aapf_get_attribute_values_post__in_outside', false)
1335
+ ) );
1336
+ }
1337
+ if( empty($terms) || ! is_array($terms) ) {
1338
+ $terms = array();
1339
+ }
1340
+ if( $hide_empty ) {
1341
+ foreach($terms as $term_id => $term) {
1342
+ if( $term->count == 0 ) {
1343
+ unset($terms[$term_id]);
1344
+ }
1345
  }
1346
  }
1347
  if (
1355
  'taxonomy' => $taxonomy,
1356
  'operator' => $operator,
1357
  'use_filters' => TRUE,
1358
+ 'post__not_in' => apply_filters('berocket_aapf_get_attribute_values_post__not_in_outside', $post__not_in),
1359
+ 'post__in' => apply_filters('berocket_aapf_get_attribute_values_post__in_outside', $post__in)
1360
  ));
1361
  }
1362
  return $terms;
1363
  }
1364
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1365
  public static function sort_child_parent_hierarchy($terms) {
1366
  $terms_sort = array();
1367
  $new_terms = $terms;
js/admin.js CHANGED
@@ -706,8 +706,10 @@ var berocket_admin_filter_types_by_attr = {
706
  $(document).on('change', '.berocket_seo_friendly_urls', berocket_change_seo_friendly_urls);
707
  $(document).on('change', '.berocket_nice_url', berocket_change_seo_friendly_urls);
708
  $(document).on('change', '.berocket_seo_meta_title', berocket_change_seo_meta_title);
 
709
  berocket_change_seo_friendly_urls();
710
  berocket_change_seo_meta_title();
 
711
  })
712
  })(jQuery);
713
  function berocket_change_seo_friendly_urls() {
@@ -739,6 +741,15 @@ function berocket_change_seo_meta_title() {
739
  jQuery('.berocket_seo_meta_title_elements').hide();
740
  }
741
  }
 
 
 
 
 
 
 
 
 
742
  var br_widget_setted = false;
743
  function br_widget_set() {
744
  if ( br_widget_setted !== false ) {
706
  $(document).on('change', '.berocket_seo_friendly_urls', berocket_change_seo_friendly_urls);
707
  $(document).on('change', '.berocket_nice_url', berocket_change_seo_friendly_urls);
708
  $(document).on('change', '.berocket_seo_meta_title', berocket_change_seo_meta_title);
709
+ $(document).on('change', '.berocket_use_links_filters', berocket_change_use_links_filters);
710
  berocket_change_seo_friendly_urls();
711
  berocket_change_seo_meta_title();
712
+ berocket_change_use_links_filters();
713
  })
714
  })(jQuery);
715
  function berocket_change_seo_friendly_urls() {
741
  jQuery('.berocket_seo_meta_title_elements').hide();
742
  }
743
  }
744
+ function berocket_change_use_links_filters() {
745
+ if( jQuery('.berocket_use_links_filters').prop('checked') ) {
746
+ jQuery('.berocket_use_noindex').show();
747
+ jQuery('.berocket_use_nofollow').show();
748
+ } else {
749
+ jQuery('.berocket_use_noindex').hide();
750
+ jQuery('.berocket_use_nofollow').hide();
751
+ }
752
+ }
753
  var br_widget_setted = false;
754
  function br_widget_set() {
755
  if ( br_widget_setted !== false ) {
main.php CHANGED
@@ -147,6 +147,7 @@ class BeRocket_AAPF extends BeRocket_Framework {
147
  'after_update' => '',
148
  ),
149
  'custom_css' => '',
 
150
  'br_opened_tab' => 'general',
151
  'tags_custom' => '1',
152
  'ajax_site' => '',
@@ -158,6 +159,9 @@ class BeRocket_AAPF extends BeRocket_Framework {
158
  'ajax_request_load_style' => 'jquery',
159
  'fontawesome_frontend_disable' => '',
160
  'fontawesome_frontend_version' => '',
 
 
 
161
  );
162
  $this->values = array(
163
  'settings_name' => 'br_filters_options',
@@ -285,6 +289,13 @@ class BeRocket_AAPF extends BeRocket_Framework {
285
  add_filter('BRaapf_cache_check_md5', array($this, 'BRaapf_cache_check_md5'));
286
  }
287
  }
 
 
 
 
 
 
 
288
  function init_validation() {
289
  return parent::init_validation() && ( ( is_plugin_active( 'woocommerce/woocommerce.php' ) || is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) &&
290
  br_get_woocommerce_version() >= 2.1 );
@@ -342,6 +353,12 @@ class BeRocket_AAPF extends BeRocket_Framework {
342
  if( class_exists('WCPBC_Pricing_Zones') ) {
343
  include_once(plugin_dir_path( __FILE__ ) . "includes/compatibility/price-based-on-country.php");
344
  }
 
 
 
 
 
 
345
  }
346
  public function register_admin_scripts(){
347
  wp_enqueue_script( 'brjsf-ui');
@@ -1663,6 +1680,11 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1663
  $new_query_vars['nopaging'] = true;
1664
  $new_query_vars['fields'] = 'ids';
1665
  $query = new WP_Query( $new_query_vars );
 
 
 
 
 
1666
  global $br_shortcode_query;
1667
  $br_shortcode_query = $query;
1668
  global $wp_query;
@@ -1777,6 +1799,11 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1777
  if( ( apply_filters( 'berocket_aapf_is_filtered_page_check', ! empty($_GET['filters']), 'apply_user_filters', $query ) )
1778
  && ( ( isset($query->query_vars['wc_query']) && $query->query_vars['wc_query'] == 'product_query' ) || ( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'product' ) ) ) {
1779
  $args = $this->get_filter_args($query);
 
 
 
 
 
1780
  $args_fields = array( 'meta_key', 'tax_query', 'fields', 'where', 'join', 'meta_query', 'date_query' );
1781
  foreach ( $args_fields as $args_field ) {
1782
  if ( ! empty($args[ $args_field ]) ) {
@@ -2623,6 +2650,16 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
2623
  ),
2624
  ));
2625
  }
 
 
 
 
 
 
 
 
 
 
2626
  }
2627
  public function save_settings_callback( $settings ) {
2628
  $options = $this->get_option();
147
  'after_update' => '',
148
  ),
149
  'custom_css' => '',
150
+ 'user_custom_css' => '',
151
  'br_opened_tab' => 'general',
152
  'tags_custom' => '1',
153
  'ajax_site' => '',
159
  'ajax_request_load_style' => 'jquery',
160
  'fontawesome_frontend_disable' => '',
161
  'fontawesome_frontend_version' => '',
162
+ 'addons' => array(
163
+ '/additional_tables/additional_tables.php'
164
+ )
165
  );
166
  $this->values = array(
167
  'settings_name' => 'br_filters_options',
289
  add_filter('BRaapf_cache_check_md5', array($this, 'BRaapf_cache_check_md5'));
290
  }
291
  }
292
+ function include_once_files() {
293
+ parent::include_once_files();
294
+ foreach (glob(__DIR__ . "/includes/display_filter/*.php") as $filename)
295
+ {
296
+ include_once($filename);
297
+ }
298
+ }
299
  function init_validation() {
300
  return parent::init_validation() && ( ( is_plugin_active( 'woocommerce/woocommerce.php' ) || is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) &&
301
  br_get_woocommerce_version() >= 2.1 );
353
  if( class_exists('WCPBC_Pricing_Zones') ) {
354
  include_once(plugin_dir_path( __FILE__ ) . "includes/compatibility/price-based-on-country.php");
355
  }
356
+ if( defined( 'DE_DB_WOO_VERSION' ) ) {
357
+ include(plugin_dir_path( __FILE__ ) . "includes/compatibility/bodycommerce.php");
358
+ }
359
+ if( defined( 'WCJ_PLUGIN_FILE' ) ) {
360
+ include(plugin_dir_path( __FILE__ ) . "includes/compatibility/woojetpack.php");
361
+ }
362
  }
363
  public function register_admin_scripts(){
364
  wp_enqueue_script( 'brjsf-ui');
1680
  $new_query_vars['nopaging'] = true;
1681
  $new_query_vars['fields'] = 'ids';
1682
  $query = new WP_Query( $new_query_vars );
1683
+ global $braapf_not_filtered_data;
1684
+ $braapf_not_filtered_data = array(
1685
+ 'post__not_in' => $query->get( 'post__not_in' ),
1686
+ 'post__in' => $query->get( 'post__in' ),
1687
+ );
1688
  global $br_shortcode_query;
1689
  $br_shortcode_query = $query;
1690
  global $wp_query;
1799
  if( ( apply_filters( 'berocket_aapf_is_filtered_page_check', ! empty($_GET['filters']), 'apply_user_filters', $query ) )
1800
  && ( ( isset($query->query_vars['wc_query']) && $query->query_vars['wc_query'] == 'product_query' ) || ( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'product' ) ) ) {
1801
  $args = $this->get_filter_args($query);
1802
+ global $braapf_not_filtered_data;
1803
+ $braapf_not_filtered_data = array(
1804
+ 'post__not_in' => $query->get( 'post__not_in' ),
1805
+ 'post__in' => $query->get( 'post__in' ),
1806
+ );
1807
  $args_fields = array( 'meta_key', 'tax_query', 'fields', 'where', 'join', 'meta_query', 'date_query' );
1808
  foreach ( $args_fields as $args_field ) {
1809
  if ( ! empty($args[ $args_field ]) ) {
2650
  ),
2651
  ));
2652
  }
2653
+ if( $previous !== '0' && ( version_compare($previous, '1.3.7.1', '<') || (version_compare($previous, '2.0', '>') && version_compare($previous, '2.3.1.1', '<') ) ) ) {
2654
+ $options = $this->get_option();
2655
+ if( ! is_array($options['addons']) ) {
2656
+ $options['addons'] = array();
2657
+ }
2658
+ if( ! in_array('/additional_tables/additional_tables.php', $options['addons']) ) {
2659
+ $options['addons'][] = '/additional_tables/additional_tables.php';
2660
+ }
2661
+ update_option( 'br_filters_options', $options );
2662
+ }
2663
  }
2664
  public function save_settings_callback( $settings ) {
2665
  $options = $this->get_option();
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://berocket.com/product/woocommerce-ajax-products-filter?utm_s
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: 4.0
7
  Tested up to: 5.2.3
8
- Stable tag: 1.3.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -184,6 +184,14 @@ You can try this plugin's admin side [here](https://berocket.com/product/woocomm
184
 
185
  == Changelog ==
186
 
 
 
 
 
 
 
 
 
187
  = 1.3.7 =
188
  * Critical Update! Sanitize all settings. Can break some custom CSS/JavaScript.
189
  * Fix - Show notification about security problem
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: 4.0
7
  Tested up to: 5.2.3
8
+ Stable tag: 1.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
184
 
185
  == Changelog ==
186
 
187
+ = 1.4 =
188
+ * Enhancement - Additional table for taxonomies (Product categories work faster with it)
189
+ * Enhancement - Additional table for variable products
190
+ * Enhancement - Better Compatibility with BodyCommerce
191
+ * Enhancement - Better Compatibility with WooJetPack product visibility by user role option
192
+ * Enhancement - "Hide out of stock variable" option also remove variable products, that do not have variation with selected attributes
193
+ * Fix - Generating Additional tables on large amount of data
194
+
195
  = 1.3.7 =
196
  * Critical Update! Sanitize all settings. Can break some custom CSS/JavaScript.
197
  * Fix - Show notification about security problem
templates/checkbox.php CHANGED
@@ -82,7 +82,7 @@ if ( ! empty($terms) ):
82
  <?php
83
  echo apply_filters( 'berocket_check_radio_color_filter_term_text', ( ( ! empty($icon_before_value) ? ( ( substr( $icon_before_value, 0, 3) == 'fa-' ) ? '<i class="fa '.$icon_before_value.'"></i>' : '<i class="fa"><img class="berocket_widget_icon" src="'.$icon_before_value.'" alt=""></i>' ) : '' ) .
84
  apply_filters('berocket_radio_filter_term_name', berocket_isset($term, 'name'), $term) .
85
- ( ! empty($icon_after_value) ? ( ( substr( $icon_after_value, 0, 3) == 'fa-' ) ? '<i class="fa '.$icon_after_value.'"></i>' : '<i class="fa"><img class="berocket_widget_icon" src="'.$icon_after_value.'" alt=""></i>' ) : '' ) ), $term, $operator, FALSE );
86
  ?>
87
  </label>
88
  <?php if( ! empty($hide_child_attributes) ) { ?>
82
  <?php
83
  echo apply_filters( 'berocket_check_radio_color_filter_term_text', ( ( ! empty($icon_before_value) ? ( ( substr( $icon_before_value, 0, 3) == 'fa-' ) ? '<i class="fa '.$icon_before_value.'"></i>' : '<i class="fa"><img class="berocket_widget_icon" src="'.$icon_before_value.'" alt=""></i>' ) : '' ) .
84
  apply_filters('berocket_radio_filter_term_name', berocket_isset($term, 'name'), $term) .
85
+ ( ! empty($icon_after_value) ? ( ( substr( $icon_after_value, 0, 3) == 'fa-' ) ? '<i class="fa '.$icon_after_value.'"></i>' : '<i class="fa"><img class="berocket_widget_icon" src="'.$icon_after_value.'" alt=""></i>' ) : '' ) ), $term, $operator, ( ! empty( $disable_multiple_ranges ) ? $term->slug : false ) );
86
  ?>
87
  </label>
88
  <?php if( ! empty($hide_child_attributes) ) { ?>
templates/filter_post.php CHANGED
@@ -12,12 +12,9 @@ $custom_taxonomies = array_combine($custom_taxonomies, $custom_taxonomies);
12
  <label class="br_admin_center"><?php _e('Widget Type', 'BeRocket_AJAX_domain') ?></label>
13
  <select id="<?php echo 'widget_type'; ?>" name="<?php echo $post_name.'[widget_type]'; ?>" class="berocket_aapf_widget_admin_widget_type_select br_select_menu_left">
14
  <?php
15
- $widget_type_array = apply_filters( 'berocket_widget_widget_type_array', array(
16
  'filter' => __('Filter', 'BeRocket_AJAX_domain'),
17
- 'update_button' => __('Update Products button', 'BeRocket_AJAX_domain'),
18
- 'reset_button' => __('Reset Products button', 'BeRocket_AJAX_domain'),
19
- 'selected_area' => __('Selected Filters area', 'BeRocket_AJAX_domain'),
20
- ) );
21
  $set_widget_type = false;
22
  if( ! array_key_exists($instance['widget_type'], $widget_type_array) ) {
23
  $set_widget_type = true;
@@ -127,13 +124,13 @@ $custom_taxonomies = array_combine($custom_taxonomies, $custom_taxonomies);
127
  'filter_by' => array('checkbox','radio','select','color','image'),
128
  );
129
  $berocket_admin_filter_types_by_attr = array(
130
- 'checkbox' => array('value' => 'checkbox', 'text' => 'Checkbox'),
131
- 'radio' => array('value' => 'radio', 'text' => 'Radio'),
132
- 'select' => array('value' => 'select', 'text' => 'Select'),
133
- 'color' => array('value' => 'color', 'text' => 'Color'),
134
- 'image' => array('value' => 'image', 'text' => 'Image'),
135
- 'slider' => array('value' => 'slider', 'text' => 'Slider'),
136
- 'tag_cloud' => array('value' => 'tag_cloud', 'text' => 'Tag cloud'),
137
  );
138
  list($berocket_admin_filter_types, $berocket_admin_filter_types_by_attr) = apply_filters( 'berocket_admin_filter_types_by_attr', array($berocket_admin_filter_types, $berocket_admin_filter_types_by_attr) );
139
 
12
  <label class="br_admin_center"><?php _e('Widget Type', 'BeRocket_AJAX_domain') ?></label>
13
  <select id="<?php echo 'widget_type'; ?>" name="<?php echo $post_name.'[widget_type]'; ?>" class="berocket_aapf_widget_admin_widget_type_select br_select_menu_left">
14
  <?php
15
+ $widget_type_array = apply_filters( 'berocket_widget_widget_type_array', apply_filters( 'berocket_aapf_display_filter_type_list', array(
16
  'filter' => __('Filter', 'BeRocket_AJAX_domain'),
17
+ ) ) );
 
 
 
18
  $set_widget_type = false;
19
  if( ! array_key_exists($instance['widget_type'], $widget_type_array) ) {
20
  $set_widget_type = true;
124
  'filter_by' => array('checkbox','radio','select','color','image'),
125
  );
126
  $berocket_admin_filter_types_by_attr = array(
127
+ 'checkbox' => array('value' => 'checkbox', 'text' => __('Checkbox', 'BeRocket_AJAX_domain')),
128
+ 'radio' => array('value' => 'radio', 'text' => __('Radio', 'BeRocket_AJAX_domain')),
129
+ 'select' => array('value' => 'select', 'text' => __('Select', 'BeRocket_AJAX_domain')),
130
+ 'color' => array('value' => 'color', 'text' => __('Color', 'BeRocket_AJAX_domain')),
131
+ 'image' => array('value' => 'image', 'text' => __('Image', 'BeRocket_AJAX_domain')),
132
+ 'slider' => array('value' => 'slider', 'text' => __('Slider', 'BeRocket_AJAX_domain')),
133
+ 'tag_cloud' => array('value' => 'tag_cloud', 'text' => __('Tag cloud', 'BeRocket_AJAX_domain')),
134
  );
135
  list($berocket_admin_filter_types, $berocket_admin_filter_types_by_attr) = apply_filters( 'berocket_admin_filter_types_by_attr', array($berocket_admin_filter_types, $berocket_admin_filter_types_by_attr) );
136
 
templates/widget_selected_area.php CHANGED
@@ -8,5 +8,5 @@
8
  <h3 class="widget-title berocket_aapf_widget-title" style="<?php echo br_get_value_from_array($uo, array('style', 'title')) ?>"><span><?php echo berocket_isset($title) ?></span></h3>
9
  </div>
10
  <?php } ?>
11
- <div class="berocket_aapf_widget berocket_aapf_widget_selected_area <?php echo ( ! empty($selected_area_show) ? 'berocket_aapf_widget_selected_area_text' : 'berocket_aapf_widget_selected_area_hide' ); ?><?php if ( ! empty($is_hide_mobile) && ! empty($is_hooked) ) echo ' berocket_aapf_hide_mobile' ?>" <?php echo ( ! empty($selected_is_hide) ? 'style="display:none;"' : 'style="display:block;"' ) ?>></div>
12
  </div>
8
  <h3 class="widget-title berocket_aapf_widget-title" style="<?php echo br_get_value_from_array($uo, array('style', 'title')) ?>"><span><?php echo berocket_isset($title) ?></span></h3>
9
  </div>
10
  <?php } ?>
11
+ <div class="berocket_aapf_widget berocket_aapf_widget_selected_area <?php echo ( ! empty($selected_area_show) ? 'berocket_aapf_widget_selected_area_text' : 'berocket_aapf_widget_selected_area_hide' ); ?><?php if ( ! empty($is_hide_mobile) && ! empty($is_hooked) ) echo ' berocket_aapf_hide_mobile' ?>" style="<?php echo ( ! empty($selected_is_hide) ? 'display:none;' : 'display:block;' ).berocket_isset($style); ?>"></div>
12
  </div>
uninstall.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fired when the plugin is uninstalled.
4
+ *
5
+ * When populating this file, consider the following flow
6
+ * of control:
7
+ *
8
+ * - This method should be static
9
+ * - Check if the $_REQUEST content actually is the plugin name
10
+ * - Run an admin referrer check to make sure it goes through authentication
11
+ * - Verify the output of $_GET makes sense
12
+ * - Repeat with other user roles. Best directly by using the links/query string parameters.
13
+ * - Repeat things for multisite. Once for a single site in the network, once sitewide.
14
+ *
15
+ * This file may be updated more in future version of the Boilerplate; however, this is the
16
+ * general skeleton and outline for how the file should work.
17
+ *
18
+ * For more information, see the following discussion:
19
+ * https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
20
+ *
21
+ * @link http://example.com
22
+ * @since 1.0.0
23
+ *
24
+ * @package Plugin_Name
25
+ */
26
+ // If uninstall not called from WordPress, then exit.
27
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
28
+ exit;
29
+ }
30
+ global $wpdb;
31
+ //Delete Variations table
32
+ $table_name = $wpdb->prefix . 'braapf_product_stock_status_parent';
33
+ $sql = "DROP TABLE IF EXISTS {$table_name};";
34
+ $wpdb->query($sql);
35
+ $table_name = $wpdb->prefix . 'braapf_product_variation_attributes';
36
+ $sql = "DROP TABLE IF EXISTS {$table_name};";
37
+ $wpdb->query($sql);
38
+ delete_option('BeRocket_aapf_variations_tables_addon_ready');
39
+ //Delete Hierarchical table
40
+ $table_name = $wpdb->prefix . 'braapf_term_taxonomy_hierarchical';
41
+ $sql = "DROP TABLE IF EXISTS {$table_name};";
42
+ $wpdb->query($sql);
43
+ delete_option('BeRocket_aapf_hierarchical_tables_addon_ready');
44
+ if ( defined( 'BR_AAPF_REMOVE_ALL_DATA' ) && true === BR_AAPF_REMOVE_ALL_DATA ) {
45
+
46
+ }
woocommerce-filters.php CHANGED
@@ -3,7 +3,7 @@
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.3.7
7
  * Author: BeRocket
8
  * Requires at least: 4.0
9
  * Author URI: https://berocket.com?utm_source=free_plugin&utm_medium=plugins&utm_campaign=ajax_filters
@@ -11,6 +11,6 @@
11
  * Domain Path: /languages/
12
  * WC tested up to: 3.7.0
13
  */
14
- define( "BeRocket_AJAX_filters_version", '1.3.7' );
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.4
7
  * Author: BeRocket
8
  * Requires at least: 4.0
9
  * Author URI: https://berocket.com?utm_source=free_plugin&utm_medium=plugins&utm_campaign=ajax_filters
11
  * Domain Path: /languages/
12
  * WC tested up to: 3.7.0
13
  */
14
+ define( "BeRocket_AJAX_filters_version", '1.4' );
15
  define( "BeRocket_AJAX_filters_file", __FILE__ );
16
  include_once('main.php');