Advanced AJAX Product Filters - Version 1.3.4

Version Description

  • Enhancement - More correct filters recount
  • Enhancement - More elemnts for translation
  • Fix - Order by element always displayed
  • Fix - Rewrite rules override every load
  • Fix - Some filters products count
Download this release

Release Info

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

Code changes from version 1.3.2.6 to 1.3.4

addons/additional_tables/add_table.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class BeRocket_aapf_variations_tables {
3
+ function __construct() {
4
+ add_filter('berocket_aapf_wcvariation_filtering_total_query', array($this, 'wcvariation_filtering_total_query'), 10, 4);
5
+ add_filter('berocket_aapf_wcvariation_filtering_main_query', array($this, 'wcvariation_filtering_main_query'), 10, 4);
6
+ add_action( 'woocommerce_variation_set_stock_status', array($this, 'set_stock_status'), 10, 3 );
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);
13
+ if( is_array($terms) && count($terms) ) {
14
+ foreach($terms as $term) {
15
+ if( substr( $term[0], 0, 3 ) == 'pa_' ) {
16
+ $current_terms[] = $term[1];
17
+ }
18
+ }
19
+ }
20
+ if( is_array($limits) && count($limits) ) {
21
+ foreach($limits as $attr => $term_ids) {
22
+ if( substr( $attr, 0, 3 ) == 'pa_' ) {
23
+ $current_attributes[] = sanitize_title('attribute_' . $attr);
24
+ foreach($term_ids as $term_id) {
25
+ $term = get_term($term_id);
26
+ if( ! empty($term) && ! is_wp_error($term) ) {
27
+ $current_terms[] = $term->term_id;
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ global $wpdb;
34
+ $table_name = $wpdb->prefix . 'braapf_product_variation_attributes';
35
+ $query = array(
36
+ 'select' => 'SELECT '.$table_name.'.post_id as var_id, '.$table_name.'.parent_id as ID, COUNT('.$table_name.'.post_id) as meta_count',
37
+ 'from' => 'FROM '.$table_name,
38
+ 'where' => 'WHERE '.$table_name.'.meta_value_id IN ('.implode(',', $current_terms).')',
39
+ 'group' => 'GROUP BY '.$table_name.'.post_id'
40
+ );
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';
52
+ if ( ! empty($_POST['price']) ) {
53
+ $min = isset( $_POST['price'][0] ) ? floatval( $_POST['price'][0] ) : 0;
54
+ $max = isset( $_POST['price'][1] ) ? floatval( $_POST['price'][1] ) : 9999999999;
55
+ $query_custom['where_1'] = $wpdb->prepare(
56
+ 'wc_product_meta_lookup.min_price < %f AND wc_product_meta_lookup.max_price > %f ',
57
+ $min,
58
+ $max
59
+ );
60
+ } else {
61
+ $price_ranges = array();
62
+ foreach ( $_POST['price_ranges'] as $range ) {
63
+ $range = explode( '*', $range );
64
+ $min = isset( $range[0] ) ? floatval( ($range[0] - 1) ) : 0;
65
+ $max = isset( $range[1] ) ? floatval( $range[1] ) : 0;
66
+ $price_ranges[] = $wpdb->prepare(
67
+ 'wc_product_meta_lookup.min_price < %f AND wc_product_meta_lookup.max_price > %f ',
68
+ $min,
69
+ $max
70
+ );
71
+ }
72
+ $query_custom['where_1'] = implode(' AND ', $price_ranges);
73
+ }
74
+ }
75
+ $query_custom['group'] = 'GROUP BY id';
76
+ $query['subquery']['subquery_3'] = $query_custom;
77
+ return $query;
78
+ }
79
+ function delete_post($product_id) {
80
+ global $wpdb;
81
+ $sql = "DELETE FROM {$wpdb->prefix}braapf_product_stock_status_parent WHERE post_id={$product_id};";
82
+ $wpdb->query($sql);
83
+ $sql = "DELETE FROM {$wpdb->prefix}braapf_product_stock_status_parent WHERE parent_id={$product_id};";
84
+ $wpdb->query($sql);
85
+ $sql = "DELETE FROM {$wpdb->prefix}braapf_product_variation_attributes WHERE post_id={$product_id};";
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;
92
+ $parent = wp_get_post_parent_id($product_id);
93
+ $stock_status_int = ($stock_status == 'instock' ? 1 : 0);
94
+ $sql = "INSERT INTO {$wpdb->prefix}braapf_product_stock_status_parent (post_id, parent_id, stock_status) VALUES({$product_id}, {$parent}, {$stock_status_int}) ON DUPLICATE KEY UPDATE stock_status={$stock_status_int}";
95
+ $wpdb->query($sql);
96
+
97
+ if ( $product->get_manage_stock() ) {
98
+ $children = $product->get_children();
99
+ if ( $children ) {
100
+ $status = $product->get_stock_status();
101
+ $format = array_fill( 0, count( $children ), '%d' );
102
+ $query_in = '(' . implode( ',', $format ) . ')';
103
+ $managed_children = array_unique( $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_manage_stock' AND meta_value != 'yes' AND post_id IN {$query_in}", $children ) ) );
104
+ foreach ( $managed_children as $managed_child ) {
105
+ $sql = "INSERT INTO {$wpdb->prefix}braapf_product_stock_status_parent (post_id, parent_id, stock_status) VALUES({$managed_child}, {$product_id}, {$stock_status_int}) ON DUPLICATE KEY UPDATE stock_status={$stock_status_int}";
106
+ $wpdb->query($sql);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ function variation_object_save($product) {
112
+ if( $product->get_type() == 'variation' ) {
113
+ global $wpdb;
114
+ $product_id = $product->get_id();
115
+ $parent_id = $product->get_parent_id();
116
+ $product_attributes = $product->get_variation_attributes();
117
+ $parent_product = wc_get_product($parent_id);
118
+ $sql = "DELETE FROM {$wpdb->prefix}braapf_product_variation_attributes WHERE post_id={$product_id};";
119
+ $wpdb->query($sql);
120
+ foreach($product_attributes as $taxonomy => $attributes) {
121
+ $taxonomy = str_replace('attribute_', '', $taxonomy);
122
+ if( empty($attributes) ) {
123
+ $attributes = $parent_product->get_variation_attributes();
124
+ if( isset($attributes[$taxonomy]) ) {
125
+ $attributes = $attributes[$taxonomy];
126
+ } else {
127
+ $attributes = array();
128
+ }
129
+ } elseif( ! is_array($attributes) ) {
130
+ $attributes = array($attributes);
131
+ }
132
+ foreach($attributes as $attribute) {
133
+ $term = get_term_by('slug', $attribute, $taxonomy);
134
+ $sql = "INSERT INTO {$wpdb->prefix}braapf_product_variation_attributes (post_id, parent_id, meta_key, meta_value_id) VALUES({$product_id}, {$parent_id}, '{$taxonomy}', {$term->term_id})";
135
+ $wpdb->query($sql);
136
+ }
137
+ }
138
+ }
139
+ }
140
+ }
141
+ new BeRocket_aapf_variations_tables();
addons/additional_tables/additional_tables.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ 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
+ }
19
+ }
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,
37
+ stock_status TINYINT,
38
+ PRIMARY KEY (post_id),
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,
51
+ meta_key VARCHAR(255) NOT NULL,
52
+ meta_value_id BIGINT NOT NULL,
53
+ INDEX post_id (post_id),
54
+ INDEX meta_key (meta_key),
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();
addons/filtering_conditions/filtering_conditions.php CHANGED
@@ -6,7 +6,7 @@ class BeRocket_aapf_filtering_conditions_addon extends BeRocket_framework_addon_
6
  function get_addon_data() {
7
  $data = parent::get_addon_data();
8
  return array_merge($data, array(
9
- 'addon_name' => 'Filtering Conditions (BETA)'
10
  ));
11
  }
12
  }
6
  function get_addon_data() {
7
  $data = parent::get_addon_data();
8
  return array_merge($data, array(
9
+ 'addon_name' => __('Filtering Conditions (BETA)', 'BeRocket_AJAX_domain')
10
  ));
11
  }
12
  }
addons/separate_link/separate_link.php CHANGED
@@ -6,7 +6,7 @@ class BeRocket_aapf_separate_link_addon extends BeRocket_framework_addon_lib {
6
  function get_addon_data() {
7
  $data = parent::get_addon_data();
8
  return array_merge($data, array(
9
- 'addon_name' => 'Separate Query Vars (BETA)'
10
  ));
11
  }
12
  }
6
  function get_addon_data() {
7
  $data = parent::get_addon_data();
8
  return array_merge($data, array(
9
+ 'addon_name' => __('WooCommerce Like Links (BETA)', 'BeRocket_AJAX_domain')
10
  ));
11
  }
12
  }
addons/separate_link/separate_vars.php CHANGED
@@ -10,7 +10,6 @@ class BeRocket_AAPF_lp_separate_vars extends BeRocket_AAPF_link_parser {
10
  $option = $BeRocket_AAPF->get_option();
11
  add_filter('brfr_data_ajax_filters', array($this, 'brfr_data'), 50, 1);
12
  if( ! empty( $option['use_links_filters'] ) ) {
13
- add_action('plugins_loaded', array($this, 'plugins_loaded'), 50);
14
  add_action( 'current_screen', array( $this, 'register_permalink_option' ), 50 );
15
  }
16
  }
@@ -20,26 +19,10 @@ class BeRocket_AAPF_lp_separate_vars extends BeRocket_AAPF_link_parser {
20
  unset($wp_settings_sections[ 'permalink' ][ 'berocket_permalinks' ]);
21
  }
22
  }
23
- function plugins_loaded() {
24
- global $wp_filter;
25
- if( isset( $wp_filter['berocket_check_radio_color_filter_term_text'] )
26
- && is_a($wp_filter['berocket_check_radio_color_filter_term_text'], 'WP_Hook')
27
- && ! empty($wp_filter['berocket_check_radio_color_filter_term_text']->callbacks[10]) ) {
28
- foreach($wp_filter['berocket_check_radio_color_filter_term_text']->callbacks[10] as $callback) {
29
- if( isset($callback['function'][1]) && is_a($callback['function'][0], 'BeRocket_AAPF_paid') && $callback['function'][1] == 'check_radio_color_filter_term_text' ) {
30
- remove_filter('berocket_check_radio_color_filter_term_text', $callback['function'], 10, 4);
31
- }
32
- }
33
- }
34
- add_filter('berocket_check_radio_color_filter_term_text', array($this, 'check_radio_color_filter_term_text'), 10, 4);
35
- }
36
  function brfr_data($data) {
37
  if( isset($data['SEO']['nice_urls']) ) {
38
  unset($data['SEO']['nice_urls']);
39
  }
40
- if( isset($data['SEO']['canonicalization']) ) {
41
- unset($data['SEO']['canonicalization']);
42
- }
43
  $data['SEO']['default_operator_and'] = array(
44
  "label" => __( 'Default operator for URLs', "BeRocket_AJAX_domain" ),
45
  "name" => "default_operator_and",
@@ -53,51 +36,62 @@ class BeRocket_AAPF_lp_separate_vars extends BeRocket_AAPF_link_parser {
53
  );
54
  return $data;
55
  }
56
- function check_radio_color_filter_term_text($text, $term, $operator, $single) {
57
- $term_taxonomy_echo = berocket_isset($term, 'wpml_taxonomy');
58
- if( empty($term_taxonomy_echo) ) {
59
- $term_taxonomy_echo = berocket_isset($term, 'taxonomy');
60
- }
61
- $text = '<a href="'.$this->berocket_add_filter_to_link($term_taxonomy_echo, berocket_isset($term, ($this->using_slug ? 'slug' : 'term_id')), $operator, $single).'">'.$text.'</a>';
62
- return $text;
63
- }
64
- function berocket_add_filter_to_link($attribute = '', $values = array(), $operator = 'OR', $remove_attribute = FALSE) {
65
  $BeRocket_AAPF = BeRocket_AAPF::getInstance();
66
  $options = $BeRocket_AAPF->get_option();
67
  if( ! is_array($values) ) {
68
  $values = array($values);
69
  }
70
- $current_url = $this->get_query_vars_name_link();
71
- $link_data = $this->get_query_vars_name($current_url);
72
- $taxonomy_value = implode(',', $values);
73
  if( taxonomy_is_product_attribute($attribute) && substr($attribute, 0, 3) == 'pa_' ) {
74
  $attribute = substr($attribute, 3);
75
  }
76
- $get_key = 'pa-'.$attribute;
77
- foreach($link_data['taxonomy'] as $taxonomy) {
78
- if( $taxonomy['taxonomy'] == $attribute ) {
79
- $terms = $taxonomy['data']['terms'] ;
80
- $terms = explode(',', $terms);
81
- foreach($values as $value) {
82
- if( ($position = array_search($value, $terms)) === FALSE ) {
83
- $terms[] = $value;
84
- } else {
85
- unset($terms[$position]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
 
 
87
  }
88
- $taxonomy_value = implode(',', $terms);
89
- $get_key = 'pa-'.$taxonomy['get_key'];
90
  }
91
- }
92
- $new_url = $current_url;
93
- if( empty($taxonomy_value) ) {
94
- $new_url = add_query_arg(array($get_key => null, $get_key.'_operator' => null), $new_url);
95
- } else {
96
- $operator_set = $operator;
97
- if( $operator == (empty($options['default_operator_and']) ? 'OR' : 'AND') ) {
98
- $operator_set = null;
99
  }
100
- $new_url = add_query_arg(array($get_key => $taxonomy_value, $get_key.'_operator' => $operator_set), $new_url);
101
  }
102
  return $new_url;
103
  }
10
  $option = $BeRocket_AAPF->get_option();
11
  add_filter('brfr_data_ajax_filters', array($this, 'brfr_data'), 50, 1);
12
  if( ! empty( $option['use_links_filters'] ) ) {
 
13
  add_action( 'current_screen', array( $this, 'register_permalink_option' ), 50 );
14
  }
15
  }
19
  unset($wp_settings_sections[ 'permalink' ][ 'berocket_permalinks' ]);
20
  }
21
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  function brfr_data($data) {
23
  if( isset($data['SEO']['nice_urls']) ) {
24
  unset($data['SEO']['nice_urls']);
25
  }
 
 
 
26
  $data['SEO']['default_operator_and'] = array(
27
  "label" => __( 'Default operator for URLs', "BeRocket_AJAX_domain" ),
28
  "name" => "default_operator_and",
36
  );
37
  return $data;
38
  }
39
+ function add_filter_to_link($current_url = FALSE, $args = array()) {
40
+ $args = array_merge(array(
41
+ 'attribute' => '',
42
+ 'values' => array(),
43
+ 'operator' => 'OR',
44
+ 'remove_attribute' => FALSE,
45
+ 'slider' => FALSE
46
+ ), $args);
47
+ extract($args);
48
  $BeRocket_AAPF = BeRocket_AAPF::getInstance();
49
  $options = $BeRocket_AAPF->get_option();
50
  if( ! is_array($values) ) {
51
  $values = array($values);
52
  }
 
 
 
53
  if( taxonomy_is_product_attribute($attribute) && substr($attribute, 0, 3) == 'pa_' ) {
54
  $attribute = substr($attribute, 3);
55
  }
56
+
57
+ $current_url = $this->get_query_vars_name_link($current_url);
58
+
59
+ $link_data = $this->get_query_vars_name($current_url);
60
+ $new_url = $current_url;
61
+ if( $slider && count($values) == 2 ) {
62
+ $values = array_values($values);
63
+ $get_key1 = 'pa-'.$attribute.'_from';
64
+ $get_key2 = 'pa-'.$attribute.'_to';
65
+ $taxonomy_value1 = $values[0];
66
+ $taxonomy_value2 = $values[1];
67
+ $new_url = add_query_arg(array($get_key1 => $taxonomy_value1, $get_key2 => $taxonomy_value2), $new_url);
68
+ } else {
69
+ $taxonomy_value = implode(',', $values);
70
+ $get_key = 'pa-'.$attribute;
71
+ foreach($link_data['taxonomy'] as $taxonomy) {
72
+ if( $taxonomy['get_key'] == $attribute ) {
73
+ $terms = $taxonomy['data']['terms'] ;
74
+ $terms = explode(',', $terms);
75
+ foreach($values as $value) {
76
+ if( ($position = array_search($value, $terms)) === FALSE ) {
77
+ $terms[] = $value;
78
+ } else {
79
+ unset($terms[$position]);
80
+ }
81
  }
82
+ $taxonomy_value = implode(',', $terms);
83
+ $get_key = 'pa-'.$taxonomy['get_key'];
84
  }
 
 
85
  }
86
+ if( empty($taxonomy_value) ) {
87
+ $new_url = add_query_arg(array($get_key => null, $get_key.'_operator' => null), $new_url);
88
+ } else {
89
+ $operator_set = $operator;
90
+ if( $operator == (empty($options['default_operator_and']) ? 'OR' : 'AND') ) {
91
+ $operator_set = null;
92
+ }
93
+ $new_url = add_query_arg(array($get_key => $taxonomy_value, $get_key.'_operator' => $operator_set), $new_url);
94
  }
 
95
  }
96
  return $new_url;
97
  }
berocket/assets/css/admin.css CHANGED
@@ -1501,3 +1501,9 @@
1501
  .account_key_send.br_framework_settings .button.tiny-button {
1502
  margin: 0;
1503
  }
 
 
 
 
 
 
1501
  .account_key_send.br_framework_settings .button.tiny-button {
1502
  margin: 0;
1503
  }
1504
+ .wp-list-table .berocket_disabled_post {
1505
+ opacity:0.5;
1506
+ }
1507
+ .wp-list-table .berocket_disabled_post:hover {
1508
+ opacity: 0.8;
1509
+ }
berocket/assets/js/admin.js CHANGED
@@ -439,9 +439,9 @@ function berocket_display_block_messages(element, next_elements) {
439
  jQuery('body').append(jQuery(html));
440
  jQuery("html, body").stop().animate({scrollTop:top - 50}, 500, 'swing');
441
  //Button to next and close
442
- html = '<a href="#close" class="berocket_display_block_messages_close_button">Close</a>';
443
  if( next_elements.length ) {
444
- html += '<a href="#next" class="berocket_display_block_messages_next_button">Next</a>';
445
  }
446
  if( typeof(element.text) == 'undefined' ) {
447
  jQuery('.berocket_display_block_messages_hide.inside').last().append(jQuery(html));
439
  jQuery('body').append(jQuery(html));
440
  jQuery("html, body").stop().animate({scrollTop:top - 50}, 500, 'swing');
441
  //Button to next and close
442
+ html = '<a href="#close" class="berocket_display_block_messages_close_button">'+berocket_framework_admin_text.wizard_close+'</a>';
443
  if( next_elements.length ) {
444
+ html += '<a href="#next" class="berocket_display_block_messages_next_button">'+berocket_framework_admin_text.wizard_next+'</a>';
445
  }
446
  if( typeof(element.text) == 'undefined' ) {
447
  jQuery('.berocket_display_block_messages_hide.inside').last().append(jQuery(html));
berocket/framework.php CHANGED
@@ -34,7 +34,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.3';
38
  public static $settings_name = '';
39
  public $addons;
40
  public $libraries;
@@ -433,6 +433,14 @@ if( ! class_exists( 'BeRocket_Framework' ) ) {
433
  array( 'jquery' ),
434
  $this->cc->info[ 'version' ]
435
  );
 
 
 
 
 
 
 
 
436
 
437
  wp_register_style(
438
  'berocket_framework_admin_style',
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.4';
38
  public static $settings_name = '';
39
  public $addons;
40
  public $libraries;
433
  array( 'jquery' ),
434
  $this->cc->info[ 'version' ]
435
  );
436
+ wp_localize_script(
437
+ 'berocket_framework_admin',
438
+ 'berocket_framework_admin_text',
439
+ array(
440
+ 'wizard_next' => __('Next', 'BeRocket_domain'),
441
+ 'wizard_close' => __('Close', 'BeRocket_domain'),
442
+ )
443
+ );
444
 
445
  wp_register_style(
446
  'berocket_framework_admin_style',
berocket/framework_version.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- $framework_version_current = '2.5.3';
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.4';
3
  if( version_compare($framework_version_current, $framework_version, '>') ) {
4
  $framework_version = $framework_version_current;
5
  $framework_dir = __DIR__;
berocket/includes/custom_post.php CHANGED
@@ -34,6 +34,7 @@ if ( ! class_exists('BeRocket_custom_post_class') ) {
34
  public $default_settings = array();
35
  public $post_settings, $post_name;
36
  public $post_type_parameters = array();
 
37
  protected static $instance;
38
 
39
  public static function getInstance() {
@@ -50,21 +51,19 @@ if ( ! class_exists('BeRocket_custom_post_class') ) {
50
  static::$instance = $this;
51
  }
52
  $this->post_type_parameters = array_merge(array(
53
- 'sortable' => false
 
54
  ), $this->post_type_parameters);
55
  add_filter( 'init', array( $this, 'init' ) );
56
  add_filter( 'admin_init', array( $this, 'admin_init' ), 15 );
57
  add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 30, 2 );
58
  if( $this->post_type_parameters['sortable'] ) {
59
- if( is_admin() ) {
60
- add_action('berocket_custom_post_'.$this->post_name.'_admin_init', array($this, 'sortable_admin_init'));
61
- add_action('berocket_custom_post_'.$this->post_name.'_wc_save_product_before', array($this, 'sortable_wc_save_product_before'), 10, 2);
62
- add_action('berocket_custom_post_'.$this->post_name.'_wc_save_product_without_check_before', array($this, 'sortable_wc_save_product_before'), 10, 2);
63
- add_action('berocket_custom_post_'.$this->post_name.'_columns_replace', array($this, 'sortable_columns_replace'), 10, 1);
64
- add_filter('berocket_custom_post_'.$this->post_name.'_manage_edit_columns', array($this, 'sortable_manage_edit_columns'));
65
- }
66
- add_filter('berocket_custom_post_'.$this->post_name.'_get_custom_posts_args_default', array($this, 'sortable_get_custom_post'));
67
- add_action('berocket_custom_post_'.$this->post_name.'_admin_init_only', array($this, 'jquery_sortable_for_posts'));
68
  }
69
  if( ! empty($this->post_settings['capability_type']) && $this->post_settings['capability_type'] != 'product' ) {
70
  add_filter('BeRocket_admin_init_user_capabilities', array($this, 'init_user_capabilities'));
@@ -99,6 +98,11 @@ if ( ! class_exists('BeRocket_custom_post_class') ) {
99
  return $posts_array;
100
  }
101
 
 
 
 
 
 
102
  public function add_meta_box($slug, $name, $callback = false, $position = 'normal', $priority = 'high') {
103
  if( $callback === false ) {
104
  $callback = array($this, $slug);
@@ -138,6 +142,25 @@ if ( ! class_exists('BeRocket_custom_post_class') ) {
138
  if( isset($actions['inline hide-if-no-js']) ) {
139
  unset($actions['inline hide-if-no-js']);
140
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
142
  return $actions;
143
  }
@@ -357,140 +380,6 @@ if ( ! class_exists('BeRocket_custom_post_class') ) {
357
  }
358
  return $data;
359
  }
360
- //SORTABLE CUSTOM POST
361
- public function sortable_admin_init() {
362
- $this->get_custom_posts();
363
- add_action( 'pre_get_posts', array($this, 'sortable_get_posts') );
364
- if( ! empty($_POST['braction']) && $_POST['braction'] == 'berocket_custom_post_sortable' ) {
365
- $this->sortable_change();
366
- }
367
- }
368
- public function sortable_change() {
369
- if( ! empty($_POST['BRsortable_id']) && isset($_POST['BRorder']) ) {
370
- $BRsortable_id = sanitize_key($_POST['BRsortable_id']);
371
- $BRorder = sanitize_key($_POST['BRorder']);
372
- $BRsortable_id = intval($BRsortable_id);
373
- $BRorder = intval($BRorder);
374
- if( current_user_can('edit_post', $BRsortable_id) ) {
375
- update_post_meta($BRsortable_id, 'berocket_post_order', $BRorder);
376
- }
377
- }
378
- if( ! empty($_POST['BRsortable']) ) {
379
- $BRsortable = $_POST['BRsortable'];
380
- if( ! is_array($BRsortable) ) {
381
- $BRsortable = array();
382
- }
383
- foreach($BRsortable as $BRsortable_post) {
384
- $BRsortable_id = sanitize_key($BRsortable_post['id']);
385
- $BRorder = sanitize_key($BRsortable_post['order']);
386
- $BRsortable_id = intval($BRsortable_id);
387
- $BRorder = intval($BRorder);
388
- if( current_user_can('edit_post', $BRsortable_id) ) {
389
- update_post_meta($BRsortable_id, 'berocket_post_order', $BRorder);
390
- }
391
- }
392
- }
393
- }
394
- public function sortable_get_posts( $query ){
395
- global $pagenow;
396
- if( 'edit.php' == $pagenow && isset( $_GET['post_type'] ) && $_GET['post_type'] == $this->post_name ){
397
- $query->set( 'meta_key', 'berocket_post_order' );
398
- $query->set( 'orderby', 'meta_value_num' );
399
- $query->set( 'order', 'ASC' );
400
- }
401
- }
402
- public function sortable_get_custom_post($args) {
403
- if( is_admin() ) {
404
- $posts_not_ordered = new WP_Query($args);
405
- $posts_not_ordered = $posts_not_ordered->posts;
406
- }
407
- $args = array_merge($args, array(
408
- 'meta_key' => 'berocket_post_order',
409
- 'orderby' => 'meta_value_num',
410
- 'order' => 'ASC',
411
- ));
412
- if( is_admin() ) {
413
- $posts_ordered = new WP_Query($args);
414
- $posts_ordered = $posts_ordered->posts;
415
- $posts_fix = array_diff($posts_not_ordered, $posts_ordered);
416
- foreach($posts_fix as $post_fix_id) {
417
- add_post_meta( $post_fix_id, 'berocket_post_order', '0', true );
418
- }
419
- }
420
- return $args;
421
- }
422
- public function sortable_wc_save_product_before( $post_id, $post ) {
423
- $order_position = get_post_meta( $post_id, 'berocket_post_order', true );
424
- $order_position = intval($order_position);
425
- update_post_meta( $post_id, 'berocket_post_order', $order_position );
426
- }
427
- public function sortable_columns_replace($column) {
428
- global $post;
429
- $post_id = $post->ID;
430
- $order_position = get_post_meta( $post_id, 'berocket_post_order', true );
431
- $order_position = intval($order_position);
432
- switch ( $column ) {
433
- case "berocket_sortable":
434
- echo $this->sortable_html_position($post_id, $order_position);
435
- break;
436
- default:
437
- break;
438
- }
439
- }
440
- public function sortable_html_position($post_id, $order) {
441
- $html = '';
442
- if( $order > 0 ) {
443
- $html .= '<a href="#order-up" class="berocket_post_set_new_sortable" data-post_id="'.$post_id.'" data-order="'.($order - 1).'"><i class="fa fa-arrow-up"></i></a>';
444
- }
445
- $html .= '<span class="berocket_post_set_new_sortable_input"><input type="number" min="0" value="'.$order.'"><a class="berocket_post_set_new_sortable_set fa fa-arrow-circle-right" data-post_id="'.$post_id.'" href="#order-set"></a></span>';
446
- $html .= '<a href="#order-up" class="berocket_post_set_new_sortable" data-post_id="'.$post_id.'" data-order="'.($order + 1).'"><i class="fa fa-arrow-down"></i></a>';
447
- return $html;
448
- }
449
- public function sortable_manage_edit_columns($columns) {
450
- $columns["berocket_sortable"] = __( "Order", 'BeRocket_domain' );
451
- return $columns;
452
- }
453
- public function jquery_sortable_for_posts() {
454
- wp_enqueue_script('jquery-ui-sortable');
455
- add_action('in_admin_footer', array($this, 'sortable_in_admin_footer'));
456
- }
457
- public function sortable_in_admin_footer() {
458
- global $wp_query;
459
- if( $wp_query->is_main_query() && $wp_query->max_num_pages == 1 ) {
460
- ?>
461
- <script>
462
- jQuery(document).ready(function() {
463
- var BRsortable_jquery_ui = function() {
464
- if( ! jQuery("#the-list").is(".ui-sortable") ) {
465
- jQuery("#the-list .column-name").prepend(jQuery("<i class='fa fa-bars'></i>"));
466
- jQuery("#the-list").sortable({
467
- handle:".fa-bars",
468
- axis: "y",
469
- stop: function() {
470
- jQuery("#the-list .berocket_post_set_new_sortable_input input").each(function(i, o) {
471
- jQuery(o).val(i);
472
- });
473
- var BRsortable = [];
474
- jQuery("#the-list .berocket_post_set_new_sortable_input").each(function() {
475
- BRsortable.push({id:jQuery(this).find(".berocket_post_set_new_sortable_set").data('post_id'), order:jQuery(this).find("input").val()});
476
- });
477
- jQuery.post(location.href, {braction:'berocket_custom_post_sortable', BRsortable:BRsortable}, function(html) {
478
- var $html = jQuery(html);
479
- var $tbody = $html.find('.berocket_post_set_new_sortable').first().parents('tbody').first();
480
- jQuery('.berocket_post_set_new_sortable').first().parents('tbody').first().replaceWith($tbody);
481
- jQuery(document).trigger('BRsortable_loaded_html');
482
- });
483
- }
484
- });
485
- }
486
- }
487
- BRsortable_jquery_ui();
488
- jQuery(document).on("BRsortable_loaded_html", BRsortable_jquery_ui);
489
- });
490
- </script>
491
- <?php
492
- }
493
- }
494
  public function init_user_capabilities($user_caps) {
495
  $cap_settings = $this->post_settings;
496
  $cap_settings['capabilities'] = array();
34
  public $default_settings = array();
35
  public $post_settings, $post_name;
36
  public $post_type_parameters = array();
37
+ public $addons = array();
38
  protected static $instance;
39
 
40
  public static function getInstance() {
51
  static::$instance = $this;
52
  }
53
  $this->post_type_parameters = array_merge(array(
54
+ 'sortable' => false,
55
+ 'can_be_disabled' => false,
56
  ), $this->post_type_parameters);
57
  add_filter( 'init', array( $this, 'init' ) );
58
  add_filter( 'admin_init', array( $this, 'admin_init' ), 15 );
59
  add_filter( 'wp_insert_post_data', array( $this, 'wp_insert_post_data' ), 30, 2 );
60
  if( $this->post_type_parameters['sortable'] ) {
61
+ include_once('custom_post/sortable.php');
62
+ $addons['sortable'] = new BeRocket_custom_post_sortable_addon_class($this);
63
+ }
64
+ if( $this->post_type_parameters['can_be_disabled'] ) {
65
+ include_once('custom_post/enable_disable.php');
66
+ $addons['can_be_disabled'] = new BeRocket_custom_post_enable_disable_addon_class($this);
 
 
 
67
  }
68
  if( ! empty($this->post_settings['capability_type']) && $this->post_settings['capability_type'] != 'product' ) {
69
  add_filter('BeRocket_admin_init_user_capabilities', array($this, 'init_user_capabilities'));
98
  return $posts_array;
99
  }
100
 
101
+ public function get_custom_posts_frontend($args = array(), $additional = array()) {
102
+ $args = apply_filters('berocket_custom_post_'.$this->post_name.'_get_custom_posts_args_frontend', $args, $additional);
103
+ return $this->get_custom_posts($args);
104
+ }
105
+
106
  public function add_meta_box($slug, $name, $callback = false, $position = 'normal', $priority = 'high') {
107
  if( $callback === false ) {
108
  $callback = array($this, $slug);
142
  if( isset($actions['inline hide-if-no-js']) ) {
143
  unset($actions['inline hide-if-no-js']);
144
  }
145
+ if ( current_user_can( 'delete_post', $post->ID ) ) {
146
+ if( $this->post_type_parameters['can_be_disabled'] ) {
147
+ if( has_term('isdisabled', 'berocket_taxonomy_data', $post) ) {
148
+ $actions['enable'] = sprintf(
149
+ '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>',
150
+ wp_nonce_url( "post.php?action=enable&amp;post=$post->ID", 'enable-post_' . $post->ID ),
151
+ esc_attr( __( 'Enable', 'BeRocket_domain') ),
152
+ _x( 'Enable', 'BeRocket_domain')
153
+ );
154
+ } else {
155
+ $actions['disable'] = sprintf(
156
+ '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>',
157
+ wp_nonce_url( "post.php?action=disable&amp;post=$post->ID", 'disable-post_' . $post->ID ),
158
+ esc_attr( __( 'Disable', 'BeRocket_domain') ),
159
+ _x( 'Disable', 'BeRocket_domain')
160
+ );
161
+ }
162
+ }
163
+ }
164
  }
165
  return $actions;
166
  }
380
  }
381
  return $data;
382
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  public function init_user_capabilities($user_caps) {
384
  $cap_settings = $this->post_settings;
385
  $cap_settings['capabilities'] = array();
berocket/includes/custom_post/enable_disable.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists('BeRocket_custom_post_enable_disable_addon_class') ) {
3
+ class BeRocket_custom_post_enable_disable_addon_class {
4
+ public $post_name;
5
+ public $custom_post;
6
+ function __construct($custom_post) {
7
+ $this->post_name = $custom_post->post_name;
8
+ $this->custom_post = $custom_post;
9
+ add_action('init', array($this, 'register_disabled_taxonomy'), 10);
10
+ add_action('init', array($this, 'add_disabled_term'), 20);
11
+ add_filter( 'bulk_actions-edit-'.$this->post_name, array($this, 'disable_bulk_action_dropdown') );
12
+ add_action('handle_bulk_actions-edit-'.$this->post_name, array($this, 'disable_bulk_actions'), 10, 3);
13
+ add_action('post_action_enable', array($this, 'post_action_enable'));
14
+ add_action('post_action_disable', array($this, 'post_action_disable'));
15
+ add_filter('views_edit-'.$this->post_name, array($this, 'post_filter_isdisabled_menu'));
16
+ add_filter('post_class', array($this, 'disable_post_class'), 10, 3);
17
+ if( isset($_GET['brdisabled']) && berocket_isset($_GET['post_type']) == $this->post_name ) {
18
+ add_filter('pre_get_posts',array($this, 'post_filter_isdisabled'));
19
+ }
20
+ add_filter('berocket_custom_post_'.$this->post_name.'_get_custom_posts_args_frontend', array($this, 'get_custom_posts_frontend'), 10, 2);
21
+ }
22
+ public function register_disabled_taxonomy() {
23
+ register_taxonomy( 'berocket_taxonomy_data', $this->post_name);
24
+ }
25
+ public function add_disabled_term() {
26
+ wp_insert_term( 'isdisabled', 'berocket_taxonomy_data', array(
27
+ 'description' => '',
28
+ 'parent' => 0,
29
+ 'slug' => 'isdisabled',
30
+ ) );
31
+ }
32
+ public function disable_bulk_action_dropdown($actions) {
33
+ if( ! isset($_GET['brdisabled']) || $_GET['brdisabled'] == 1 ) {
34
+ $actions['enable'] = __( 'Enable', 'BeRocket_domain');
35
+ }
36
+ if( ! isset($_GET['brdisabled']) || $_GET['brdisabled'] == 0 ) {
37
+ $actions['disable'] = __( 'Disable', 'BeRocket_domain');
38
+ }
39
+ return $actions;
40
+ }
41
+ public function change_post_isdisabled($post_id, $doaction) {
42
+ $ischanged = false;
43
+ if( $doaction == 'enable' && has_term('isdisabled', 'berocket_taxonomy_data', $post_id) ) {
44
+ wp_remove_object_terms($post_id, 'isdisabled', 'berocket_taxonomy_data');
45
+ $ischanged = true;
46
+ }
47
+ if( $doaction == 'disable' && ! has_term('isdisabled', 'berocket_taxonomy_data', $post_id) ) {
48
+ wp_set_post_terms( $post_id, 'isdisabled', 'berocket_taxonomy_data', true );
49
+ $ischanged = true;
50
+ }
51
+ return $ischanged;
52
+ }
53
+ public function disable_bulk_actions($sendback, $doaction, $post_ids) {
54
+ if ( $doaction !== 'enable' && $doaction !== 'disable' ) {
55
+ return $sendback;
56
+ }
57
+ $count = 0;
58
+ foreach ( (array) $post_ids as $post_id ) {
59
+ if ( ! current_user_can( 'delete_post', $post_id ) ) {
60
+ wp_die( __( 'Sorry, you are not allowed to change this item status.', 'BeRocket_domain' ) );
61
+ }
62
+ if( $this->change_post_isdisabled($post_id, $doaction) ) {
63
+ $count++;
64
+ }
65
+ }
66
+ $sendback = add_query_arg(
67
+ array(
68
+ ($doaction == 'disable' ? 'disabled' : 'enabled') => $count,
69
+ 'ids' => join( ',', $post_ids ),
70
+ ),
71
+ $sendback
72
+ );
73
+ return $sendback;
74
+ }
75
+ public function post_action_isdisabled_change($post_id, $doaction) {
76
+ global $post_type, $post_type_object, $post;
77
+ if( $post_type != $this->post_name ) return;
78
+ check_admin_referer( $doaction.'-post_' . $post_id );
79
+ $sendback = wp_get_referer();
80
+ if ( ! $post ) {
81
+ wp_die( __( 'The item you are trying to change status no longer exists.', 'BeRocket_domain' ) );
82
+ }
83
+ if ( ! $post_type_object ) {
84
+ wp_die( __( 'Invalid post type.' ) );
85
+ }
86
+ if ( ! current_user_can( 'delete_post', $post_id ) ) {
87
+ wp_die( __( 'Sorry, you are not allowed to change this item status.', 'BeRocket_domain' ) );
88
+ }
89
+ $this->change_post_isdisabled($post_id, $doaction);
90
+
91
+ wp_redirect(
92
+ add_query_arg(
93
+ array(
94
+ ($doaction == 'disable' ? 'disabled' : 'enabled') => 1,
95
+ 'ids' => $post_id,
96
+ ),
97
+ $sendback
98
+ )
99
+ );
100
+ exit();
101
+ }
102
+ public function disable_post_class($classes, $class, $post_id) {
103
+ global $post_type;
104
+ if( $post_type == $this->post_name ) {
105
+ if( has_term('isdisabled', 'berocket_taxonomy_data', $post_id) ) {
106
+ $classes[] = 'berocket_disabled_post';
107
+ } else {
108
+ $classes[] = 'berocket_enabled_post';
109
+ }
110
+ }
111
+ return $classes;
112
+ }
113
+ public function post_action_enable($post_id) {
114
+ $this->post_action_isdisabled_change($post_id, 'enable');
115
+ }
116
+ public function post_action_disable($post_id) {
117
+ $this->post_action_isdisabled_change($post_id, 'disable');
118
+ }
119
+ public function post_filter_isdisabled_menu($views) {
120
+ global $post_type;
121
+ if( $post_type == $this->post_name ) {
122
+ $url = add_query_arg( array('post_type' => $post_type, 'brdisabled' => 0), 'edit.php' );
123
+ $class = (( isset($_GET['brdisabled']) && $_GET['brdisabled'] == 0 ) ? ' class="current"' : '');
124
+ $views['enabled'] = sprintf(
125
+ '<a href="%s"%s>%s</a>',
126
+ esc_url( $url ),
127
+ $class,
128
+ __('Enabled', 'BeRocket_domain')
129
+ );
130
+ $url = add_query_arg( array('post_type' => $post_type, 'brdisabled' => 1), 'edit.php' );
131
+ $class = (( isset($_GET['brdisabled']) && $_GET['brdisabled'] == 1 ) ? ' class="current"' : '');
132
+ $views['disabled'] = sprintf(
133
+ '<a href="%s"%s>%s</a>',
134
+ esc_url( $url ),
135
+ $class,
136
+ __('Disabled', 'BeRocket_domain')
137
+ );
138
+ }
139
+ return $views;
140
+ }
141
+ public function post_filter_isdisabled($query) {
142
+ if( ! $query->is_main_query() ) return $query;
143
+ $tax_query = $query->get('tax_query');
144
+ if( ! is_array($tax_query) ) {
145
+ $tax_query = array();
146
+ }
147
+ $tax_query[] = array(
148
+ 'taxonomy' => 'berocket_taxonomy_data',
149
+ 'field' => 'slug',
150
+ 'terms' => 'isdisabled',
151
+ 'operator' => (empty($_GET['brdisabled']) ? "NOT IN" : "IN")
152
+ );
153
+ $query->set('tax_query', $tax_query);
154
+ return $query;
155
+ }
156
+ public function get_custom_posts_frontend($args = array(), $additional = array()) {
157
+ $additional = array_merge(array(
158
+ 'hide_disabled' => true
159
+ ), $additional);
160
+ if( ! empty($additional['hide_disabled']) ) {
161
+ if( empty($args['tax_query']) ) {
162
+ $args['tax_query'] = array();
163
+ }
164
+ $args['tax_query'][] = array(
165
+ 'taxonomy' => 'berocket_taxonomy_data',
166
+ 'field' => 'slug',
167
+ 'terms' => 'isdisabled',
168
+ 'operator' => "NOT IN"
169
+ );
170
+ }
171
+ return $args;
172
+ }
173
+ }
174
+ }
berocket/includes/custom_post/sortable.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists('BeRocket_custom_post_sortable_addon_class') ) {
3
+ class BeRocket_custom_post_sortable_addon_class {
4
+ public $post_name;
5
+ public $custom_post;
6
+ function __construct($custom_post) {
7
+ $this->post_name = $custom_post->post_name;
8
+ $this->custom_post = $custom_post;
9
+ if( is_admin() ) {
10
+ add_action('berocket_custom_post_'.$this->post_name.'_admin_init', array($this, 'sortable_admin_init'));
11
+ add_action('berocket_custom_post_'.$this->post_name.'_wc_save_product_before', array($this, 'sortable_wc_save_product_before'), 10, 2);
12
+ add_action('berocket_custom_post_'.$this->post_name.'_wc_save_product_without_check_before', array($this, 'sortable_wc_save_product_before'), 10, 2);
13
+ add_action('berocket_custom_post_'.$this->post_name.'_columns_replace', array($this, 'sortable_columns_replace'), 10, 1);
14
+ add_filter('berocket_custom_post_'.$this->post_name.'_manage_edit_columns', array($this, 'sortable_manage_edit_columns'));
15
+ }
16
+ add_filter('berocket_custom_post_'.$this->post_name.'_get_custom_posts_args_default', array($this, 'sortable_get_custom_post'));
17
+ add_action('berocket_custom_post_'.$this->post_name.'_admin_init_only', array($this, 'jquery_sortable_for_posts'));
18
+ }
19
+ public function sortable_admin_init() {
20
+ add_action( 'pre_get_posts', array($this, 'sortable_get_posts') );
21
+ if( ! empty($_POST['braction']) && $_POST['braction'] == 'berocket_custom_post_sortable' ) {
22
+ $this->sortable_change();
23
+ }
24
+ }
25
+ public function sortable_change() {
26
+ if( ! empty($_POST['BRsortable_id']) && isset($_POST['BRorder']) ) {
27
+ $BRsortable_id = sanitize_key($_POST['BRsortable_id']);
28
+ $BRorder = sanitize_key($_POST['BRorder']);
29
+ $BRsortable_id = intval($BRsortable_id);
30
+ $BRorder = intval($BRorder);
31
+ if( current_user_can('edit_post', $BRsortable_id) ) {
32
+ update_post_meta($BRsortable_id, 'berocket_post_order', $BRorder);
33
+ }
34
+ }
35
+ if( ! empty($_POST['BRsortable']) ) {
36
+ $BRsortable = $_POST['BRsortable'];
37
+ if( ! is_array($BRsortable) ) {
38
+ $BRsortable = array();
39
+ }
40
+ foreach($BRsortable as $BRsortable_post) {
41
+ $BRsortable_id = sanitize_key($BRsortable_post['id']);
42
+ $BRorder = sanitize_key($BRsortable_post['order']);
43
+ $BRsortable_id = intval($BRsortable_id);
44
+ $BRorder = intval($BRorder);
45
+ if( current_user_can('edit_post', $BRsortable_id) ) {
46
+ update_post_meta($BRsortable_id, 'berocket_post_order', $BRorder);
47
+ }
48
+ }
49
+ }
50
+ }
51
+ public function sortable_get_posts( $query ){
52
+ global $pagenow;
53
+ if( 'edit.php' == $pagenow && isset( $_GET['post_type'] ) && $_GET['post_type'] == $this->post_name ){
54
+ $query->set( 'meta_key', 'berocket_post_order' );
55
+ $query->set( 'orderby', 'meta_value_num' );
56
+ $query->set( 'order', 'ASC' );
57
+ }
58
+ }
59
+ public function sortable_get_custom_post($args) {
60
+ if( is_admin() ) {
61
+ $posts_not_ordered = new WP_Query($args);
62
+ $posts_not_ordered = $posts_not_ordered->posts;
63
+ }
64
+ $args = array_merge($args, array(
65
+ 'meta_key' => 'berocket_post_order',
66
+ 'orderby' => 'meta_value_num',
67
+ 'order' => 'ASC',
68
+ ));
69
+ if( is_admin() ) {
70
+ $posts_ordered = new WP_Query($args);
71
+ $posts_ordered = $posts_ordered->posts;
72
+ $posts_fix = array_diff($posts_not_ordered, $posts_ordered);
73
+ foreach($posts_fix as $post_fix_id) {
74
+ add_post_meta( $post_fix_id, 'berocket_post_order', '0', true );
75
+ }
76
+ }
77
+ return $args;
78
+ }
79
+ public function sortable_wc_save_product_before( $post_id, $post ) {
80
+ $order_position = get_post_meta( $post_id, 'berocket_post_order', true );
81
+ $order_position = intval($order_position);
82
+ update_post_meta( $post_id, 'berocket_post_order', $order_position );
83
+ }
84
+ public function sortable_columns_replace($column) {
85
+ global $post;
86
+ $post_id = $post->ID;
87
+ $order_position = get_post_meta( $post_id, 'berocket_post_order', true );
88
+ $order_position = intval($order_position);
89
+ switch ( $column ) {
90
+ case "berocket_sortable":
91
+ echo $this->sortable_html_position($post_id, $order_position);
92
+ break;
93
+ default:
94
+ break;
95
+ }
96
+ }
97
+ public function sortable_html_position($post_id, $order) {
98
+ $html = '';
99
+ if( $order > 0 ) {
100
+ $html .= '<a href="#order-up" class="berocket_post_set_new_sortable" data-post_id="'.$post_id.'" data-order="'.($order - 1).'"><i class="fa fa-arrow-up"></i></a>';
101
+ }
102
+ $html .= '<span class="berocket_post_set_new_sortable_input"><input type="number" min="0" value="'.$order.'"><a class="berocket_post_set_new_sortable_set fa fa-arrow-circle-right" data-post_id="'.$post_id.'" href="#order-set"></a></span>';
103
+ $html .= '<a href="#order-up" class="berocket_post_set_new_sortable" data-post_id="'.$post_id.'" data-order="'.($order + 1).'"><i class="fa fa-arrow-down"></i></a>';
104
+ return $html;
105
+ }
106
+ public function sortable_manage_edit_columns($columns) {
107
+ $columns["berocket_sortable"] = __( "Order", 'BeRocket_domain' );
108
+ return $columns;
109
+ }
110
+ public function jquery_sortable_for_posts() {
111
+ wp_enqueue_script('jquery-ui-sortable');
112
+ add_action('in_admin_footer', array($this, 'sortable_in_admin_footer'));
113
+ }
114
+ public function sortable_in_admin_footer() {
115
+ global $wp_query;
116
+ if( $wp_query->is_main_query() && $wp_query->max_num_pages == 1 ) {
117
+ ?>
118
+ <script>
119
+ jQuery(document).ready(function() {
120
+ var BRsortable_jquery_ui = function() {
121
+ if( ! jQuery("#the-list").is(".ui-sortable") ) {
122
+ jQuery("#the-list .column-name").prepend(jQuery("<i class='fa fa-bars'></i>"));
123
+ jQuery("#the-list").sortable({
124
+ handle:".fa-bars",
125
+ axis: "y",
126
+ stop: function() {
127
+ jQuery("#the-list .berocket_post_set_new_sortable_input input").each(function(i, o) {
128
+ jQuery(o).val(i);
129
+ });
130
+ var BRsortable = [];
131
+ jQuery("#the-list .berocket_post_set_new_sortable_input").each(function() {
132
+ BRsortable.push({id:jQuery(this).find(".berocket_post_set_new_sortable_set").data('post_id'), order:jQuery(this).find("input").val()});
133
+ });
134
+ jQuery.post(location.href, {braction:'berocket_custom_post_sortable', BRsortable:BRsortable}, function(html) {
135
+ var $html = jQuery(html);
136
+ var $tbody = $html.find('.berocket_post_set_new_sortable').first().parents('tbody').first();
137
+ jQuery('.berocket_post_set_new_sortable').first().parents('tbody').first().replaceWith($tbody);
138
+ jQuery(document).trigger('BRsortable_loaded_html');
139
+ });
140
+ }
141
+ });
142
+ }
143
+ }
144
+ BRsortable_jquery_ui();
145
+ jQuery(document).on("BRsortable_loaded_html", BRsortable_jquery_ui);
146
+ });
147
+ </script>
148
+ <?php
149
+ }
150
+ }
151
+ }
152
+ }
berocket/includes/functions.php CHANGED
@@ -319,14 +319,14 @@ if( ! function_exists( 'br_condition_builder' ) ) {
319
  $equal = $options['equal'];
320
  }
321
  $equal_list = array(
322
- 'equal' => __('Equal', 'BeRocket_products_label_domain'),
323
- 'not_equal' => __('Not equal', 'BeRocket_products_label_domain'),
324
  );
325
  if( ! empty($extension['equal_less']) ) {
326
- $equal_list['equal_less'] = __('Equal or less', 'BeRocket_products_label_domain');
327
  }
328
  if( ! empty($extension['equal_more']) ) {
329
- $equal_list['equal_more'] = __('Equal or more', 'BeRocket_products_label_domain');
330
  }
331
  $html = '<select name="' . $name . '[equal]">';
332
  foreach($equal_list as $equal_slug => $equal_name) {
319
  $equal = $options['equal'];
320
  }
321
  $equal_list = array(
322
+ 'equal' => __('Equal', 'BeRocket_domain'),
323
+ 'not_equal' => __('Not equal', 'BeRocket_domain'),
324
  );
325
  if( ! empty($extension['equal_less']) ) {
326
+ $equal_list['equal_less'] = __('Equal or less', 'BeRocket_domain');
327
  }
328
  if( ! empty($extension['equal_more']) ) {
329
+ $equal_list['equal_more'] = __('Equal or more', 'BeRocket_domain');
330
  }
331
  $html = '<select name="' . $name . '[equal]">';
332
  foreach($equal_list as $equal_slug => $equal_name) {
berocket/includes/updater.php CHANGED
@@ -129,7 +129,7 @@ if ( ! class_exists( 'BeRocket_updater' ) ) {
129
  if ( $item[ 0 ] == 'BeRocket' ) {
130
  $BeRocket_item = $item;
131
  continue;
132
- } elseif ( $item[ 0 ] == 'Account Keys' ) {
133
  $account_keys_item = $item;
134
  continue;
135
  }
@@ -450,7 +450,7 @@ if ( ! class_exists( 'BeRocket_updater' ) ) {
450
  }
451
 
452
  public static function network_account_page() {
453
- add_menu_page( 'BeRocket Account Settings', 'BeRocket Account', 'manage_berocket', 'berocket_account', array(
454
  __CLASS__,
455
  'account_form_network'
456
  ), plugin_dir_url( __FILE__ ) . 'ico.png', '55.55' );
@@ -464,7 +464,7 @@ if ( ! class_exists( 'BeRocket_updater' ) ) {
464
  }
465
 
466
  public static function account_page() {
467
- add_submenu_page( 'berocket_account', 'BeRocket Account Settings', 'Account Keys', 'manage_berocket_account', 'berocket_account', array(
468
  __CLASS__,
469
  'account_form'
470
  ) );
@@ -522,17 +522,17 @@ if ( ! class_exists( 'BeRocket_updater' ) ) {
522
  $plugins_key = array();
523
  }
524
  ?>
525
- <h2>BeRocket Account Settings</h2>
526
  <div>
527
  <table>
528
  <tr>
529
- <td><h3>DEBUG MODE</h3></td>
530
  <td colspan=3><label><input type="checkbox" name="BeRocket_account_option[debug_mode]"
531
  value="1"<?php if ( ! empty( $options[ 'debug_mode' ] ) )
532
- echo ' checked' ?>>Enable debug mode</label></td>
533
  </tr>
534
  <tr>
535
- <td><h3>Account key</h3></td>
536
  <td><input type="text" id="berocket_account_key" name="BeRocket_account_option[account_key]"
537
  size="50"
538
  value="<?php echo( empty( $options[ 'account_key' ] ) ? '' : $options[ 'account_key' ] ) ?>">
@@ -563,12 +563,12 @@ if ( ! class_exists( 'BeRocket_updater' ) ) {
563
  </table>
564
  </div>
565
  <div class="berocket_test_result"></div>
566
- <button type="submit" class="button">Save Changes</button>
567
 
568
  <div class="berocket_debug_errors">
569
- <h3>Errors</h3>
570
  <div>
571
- Select plugin
572
  <select class="berocket_select_plugin_for_error">
573
  <?php
574
  foreach ( self::$plugin_info as $plugin ) {
129
  if ( $item[ 0 ] == 'BeRocket' ) {
130
  $BeRocket_item = $item;
131
  continue;
132
+ } elseif ( $item[ 0 ] == __('Account Keys', 'BeRocket_domain') ) {
133
  $account_keys_item = $item;
134
  continue;
135
  }
450
  }
451
 
452
  public static function network_account_page() {
453
+ add_menu_page( __('BeRocket Account Settings', 'BeRocket_domain'), __('BeRocket Account', 'BeRocket_domain'), 'manage_berocket', 'berocket_account', array(
454
  __CLASS__,
455
  'account_form_network'
456
  ), plugin_dir_url( __FILE__ ) . 'ico.png', '55.55' );
464
  }
465
 
466
  public static function account_page() {
467
+ add_submenu_page( 'berocket_account', __('BeRocket Account Settings', 'BeRocket_domain'), __('Account Keys', 'BeRocket_domain'), 'manage_berocket_account', 'berocket_account', array(
468
  __CLASS__,
469
  'account_form'
470
  ) );
522
  $plugins_key = array();
523
  }
524
  ?>
525
+ <h2><?php _e('BeRocket Account Settings', 'BeRocket_domain'); ?></h2>
526
  <div>
527
  <table>
528
  <tr>
529
+ <td><h3><?php _e('DEBUG MODE', 'BeRocket_domain'); ?></h3></td>
530
  <td colspan=3><label><input type="checkbox" name="BeRocket_account_option[debug_mode]"
531
  value="1"<?php if ( ! empty( $options[ 'debug_mode' ] ) )
532
+ echo ' checked' ?>><?php _e('Enable debug mode', 'BeRocket_domain'); ?></label></td>
533
  </tr>
534
  <tr>
535
+ <td><h3><?php _e('Account key', 'BeRocket_domain'); ?></h3></td>
536
  <td><input type="text" id="berocket_account_key" name="BeRocket_account_option[account_key]"
537
  size="50"
538
  value="<?php echo( empty( $options[ 'account_key' ] ) ? '' : $options[ 'account_key' ] ) ?>">
563
  </table>
564
  </div>
565
  <div class="berocket_test_result"></div>
566
+ <button type="submit" class="button"><?php _e('Save Changes', 'BeRocket_domain'); ?></button>
567
 
568
  <div class="berocket_debug_errors">
569
+ <h3><?php _e('Errors', 'BeRocket_domain'); ?></h3>
570
  <div>
571
+ <?php _e('Select plugin', 'BeRocket_domain'); ?>
572
  <select class="berocket_select_plugin_for_error">
573
  <?php
574
  foreach ( self::$plugin_info as $plugin ) {
includes/addons/woocommerce-variation.php CHANGED
@@ -1,12 +1,33 @@
1
  <?php
2
  class BeRocket_AAPF_compat_woocommerce_variation {
 
3
  function __construct() {
4
  add_filter('berocket_filters_query_already_filtered', array(__CLASS__, 'query_already_filtered'), 10, 3);
5
  add_filter('berocket_add_out_of_stock_variable', array(__CLASS__, 'out_of_stock_variable'), 10, 3);
6
  add_filter('brAAPFcompat_WCvariation_out_of_stock_where', array(__CLASS__, 'out_of_stock_where'), 10, 1);
 
 
 
7
  }
8
  public static function query_already_filtered($query, $terms, $limits) {
9
- $get_queried_object = $query->get_queried_object();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  if( is_a($get_queried_object, 'WP_Term') && strpos($get_queried_object->taxonomy, 'pa_') !== FALSE ) {
11
  if( ! is_array($terms) ) {
12
  $terms = array();
@@ -19,23 +40,10 @@ class BeRocket_AAPF_compat_woocommerce_variation {
19
  'attribute'
20
  );
21
  }
22
- $post_not_in = self::out_of_stock_variable(array(), $terms, $limits);
23
- if( is_array($post_not_in) && count($post_not_in) ) {
24
- $post__not_in = $query->get('post__not_in');
25
- $post__not_in = array_merge($post__not_in, $post_not_in);
26
- $post__in = $query->get('post__in');
27
- $post__in = array_diff($post__in, $post__not_in);
28
- $query->set('post__not_in', $post__not_in);
29
- $query->set('post__in', $post__in);
30
- }
31
- return $query;
32
- }
33
- public static function out_of_stock_variable($input, $terms, $limits) {
34
- global $wpdb;
35
  $outofstock = wc_get_product_visibility_term_ids();
36
  if( empty($outofstock['outofstock']) ) {
37
  $outofstock = get_term_by( 'slug', 'outofstock', 'product_visibility' );
38
- $outofstock = $outofstock->term_id;
39
  } else {
40
  $outofstock = $outofstock['outofstock'];
41
  }
@@ -66,51 +74,61 @@ class BeRocket_AAPF_compat_woocommerce_variation {
66
  $current_attributes = array_unique($current_attributes);
67
  $current_terms = implode('", "', $current_terms);
68
  $current_attributes = implode('", "', $current_attributes);
69
- $query = sprintf( '
70
- SELECT filtered_post.id, filtered_post.out_of_stock, COUNT(filtered_post.ID) as post_count FROM
71
- (
72
- SELECT filtered_post.*, max_filtered_post.max_meta_count, stock_table.out_of_stock_init as out_of_stock FROM
73
- (
74
- SELECT %1$s.id as var_id, %1$s.post_parent as ID, COUNT(%1$s.id) as meta_count FROM %1$s
75
- INNER JOIN %2$s AS pf1 ON (%1$s.ID = pf1.post_id)
76
- WHERE %1$s.post_type = "product_variation"
77
- AND %1$s.post_status != "trash"
78
- AND pf1.meta_key IN ("%4$s") AND pf1.meta_value IN ("%5$s")
79
- GROUP BY %1$s.id
80
- ) as filtered_post
81
- INNER JOIN
82
- (
83
- SELECT ID, MAX(meta_count) as max_meta_count FROM
84
- (
85
- SELECT %1$s.id as var_id, %1$s.post_parent as ID, COUNT(%1$s.id) as meta_count FROM %1$s
86
- INNER JOIN %2$s AS pf1 ON (%1$s.ID = pf1.post_id)
87
- WHERE %1$s.post_type = "product_variation"
88
- AND pf1.meta_key IN ("%4$s") AND pf1.meta_value IN ("%5$s")
89
- GROUP BY %1$s.id
90
- ) as max_filtered_post
91
- GROUP BY ID
92
- ) as max_filtered_post ON max_filtered_post.ID = filtered_post.ID AND max_filtered_post.max_meta_count = filtered_post.meta_count
93
- LEFT JOIN
94
- (
95
- SELECT %1$s .id as id, COALESCE(stock_table_init.out_of_stock_init1, "0") as out_of_stock_init
96
- FROM %1$s
97
- LEFT JOIN (
98
- SELECT %1$s.id as id, "1" as out_of_stock_init1
99
- FROM %1$s
100
- ' . apply_filters('brAAPFcompat_WCvariation_out_of_stock_where', 'WHERE %1$s.id IN
101
- (
102
- SELECT object_id FROM %3$s
103
- WHERE term_taxonomy_id IN ( '.$outofstock.' )
104
- ) ') . '
105
- ) as stock_table_init on %1$s.id = stock_table_init.id
106
- GROUP BY id
107
- ) as stock_table
108
- ON filtered_post.var_id = stock_table.id
109
- GROUP BY filtered_post.ID, out_of_stock
110
- ) as filtered_post
111
- GROUP BY filtered_post.ID
112
- HAVING post_count = 1 AND out_of_stock = 1
113
- ', $wpdb->posts, $wpdb->postmeta, $wpdb->term_relationships, $current_attributes, $current_terms );
 
 
 
 
 
 
 
 
 
 
114
  $out_of_stock_variable = $wpdb->get_results( $query, ARRAY_N );
115
  if( BeRocket_AAPF::$debug_mode ) {
116
  if( ! isset(BeRocket_AAPF::$error_log['_addons_variations_query']) || ! is_array(BeRocket_AAPF::$error_log['_addons_variations_query']) ) {
@@ -130,8 +148,15 @@ HAVING post_count = 1 AND out_of_stock = 1
130
  }
131
  return $post_not_in;
132
  }
 
 
 
 
 
 
 
 
133
  public static function out_of_stock_where($custom_where) {
134
-
135
  if ( ! empty($_POST['price_ranges']) || ! empty($_POST['price']) ) {
136
  global $wpdb;
137
  $custom_where .= ' OR %1$s.id IN (
@@ -157,5 +182,86 @@ HAVING post_count = 1 AND out_of_stock = 1
157
  }
158
  return $custom_where;
159
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  }
161
  new BeRocket_AAPF_compat_woocommerce_variation();
1
  <?php
2
  class BeRocket_AAPF_compat_woocommerce_variation {
3
+ public $limit_post__not_in_where_array = array();
4
  function __construct() {
5
  add_filter('berocket_filters_query_already_filtered', array(__CLASS__, 'query_already_filtered'), 10, 3);
6
  add_filter('berocket_add_out_of_stock_variable', array(__CLASS__, 'out_of_stock_variable'), 10, 3);
7
  add_filter('brAAPFcompat_WCvariation_out_of_stock_where', array(__CLASS__, 'out_of_stock_where'), 10, 1);
8
+ add_filter('berocket_aapf_recount_terms_query', array($this, 'faster_recount_add_data'), 60, 3);
9
+ add_filter('berocket_query_result_recount', array($this, 'faster_recount_query_result'), 60, 3);
10
+ add_filter('berocket_recount_cache_key', array($this, 'faster_recount_cache_key'), 60);
11
  }
12
  public static function query_already_filtered($query, $terms, $limits) {
13
+ $post_not_in = self::out_of_stock_variable(array(), $terms, $limits, $query);
14
+ if( is_array($post_not_in) && count($post_not_in) ) {
15
+ $post__not_in = $query->get('post__not_in');
16
+ $post__not_in = array_merge($post__not_in, $post_not_in);
17
+ $post__in = $query->get('post__in');
18
+ $post__in = array_diff($post__in, $post__not_in);
19
+ $query->set('post__not_in', $post__not_in);
20
+ $query->set('post__in', $post__in);
21
+ }
22
+ return $query;
23
+ }
24
+ public static function out_of_stock_variable($input, $terms, $limits, $query = false) {
25
+ global $wpdb;
26
+ if( $query === false ) {
27
+ $get_queried_object = get_queried_object();
28
+ } else {
29
+ $get_queried_object = $query->get_queried_object();
30
+ }
31
  if( is_a($get_queried_object, 'WP_Term') && strpos($get_queried_object->taxonomy, 'pa_') !== FALSE ) {
32
  if( ! is_array($terms) ) {
33
  $terms = array();
40
  'attribute'
41
  );
42
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  $outofstock = wc_get_product_visibility_term_ids();
44
  if( empty($outofstock['outofstock']) ) {
45
  $outofstock = get_term_by( 'slug', 'outofstock', 'product_visibility' );
46
+ $outofstock = $outofstock->term_taxonomy_id;
47
  } else {
48
  $outofstock = $outofstock['outofstock'];
49
  }
74
  $current_attributes = array_unique($current_attributes);
75
  $current_terms = implode('", "', $current_terms);
76
  $current_attributes = implode('", "', $current_attributes);
77
+ $query_filtered_posts = apply_filters( 'berocket_aapf_wcvariation_filtering_main_query', array(
78
+ 'select' => 'SELECT %1$s.id as var_id, %1$s.post_parent as ID, COUNT(%1$s.id) as meta_count',
79
+ 'from' => 'FROM %1$s',
80
+ 'join' => 'INNER JOIN %2$s AS pf1 ON (%1$s.ID = pf1.post_id)',
81
+ 'where' => 'WHERE %1$s.post_type = "product_variation"',
82
+ 'and1' => 'AND %1$s.post_status != "trash"',
83
+ 'and2' => 'AND pf1.meta_key IN ("%4$s")',
84
+ 'and3' => 'AND pf1.meta_value IN ("%5$s")',
85
+ 'group' => 'GROUP BY %1$s.id'
86
+ ), $input, $terms, $limits, $current_attributes, $current_terms);
87
+ $query = array(
88
+ 'select' => 'SELECT filtered_post.id, filtered_post.out_of_stock, COUNT(filtered_post.ID) as post_count',
89
+ 'from_open' => 'FROM (',
90
+ 'subquery' => array(
91
+ 'select' => 'SELECT filtered_post.*, max_filtered_post.max_meta_count, stock_table.out_of_stock_init as out_of_stock',
92
+ 'from_open' => 'FROM (',
93
+ 'subquery_1' => $query_filtered_posts,
94
+ 'from_close' => ') as filtered_post',
95
+ 'join_open_1' => 'INNER JOIN (',
96
+ 'subquery_2' => array(
97
+ 'select' => 'SELECT ID, MAX(meta_count) as max_meta_count',
98
+ 'from_open' => 'FROM (',
99
+ 'subquery' => $query_filtered_posts,
100
+ 'from_close' => ') as max_filtered_post',
101
+ 'group' => 'GROUP BY ID'
102
+ ),
103
+ 'join_close_1' => ') as max_filtered_post ON max_filtered_post.ID = filtered_post.ID AND max_filtered_post.max_meta_count = filtered_post.meta_count',
104
+ 'join_open_2' => 'LEFT JOIN (',
105
+ 'subquery_3' => array(
106
+ 'select' => 'SELECT %1$s .id as id, COALESCE(stock_table_init.out_of_stock_init1, "0") as out_of_stock_init',
107
+ 'from' => 'FROM %1$s',
108
+ 'join_open' => 'LEFT JOIN (',
109
+ 'subquery' => array(
110
+ 'select' => 'SELECT %1$s.id as id, "1" as out_of_stock_init1',
111
+ 'from' => 'FROM %1$s',
112
+ 'where' => apply_filters('brAAPFcompat_WCvariation_out_of_stock_where', 'WHERE %1$s.id IN
113
+ (
114
+ SELECT object_id FROM %3$s
115
+ WHERE term_taxonomy_id IN ( '.$outofstock.' )
116
+ ) '
117
+ )
118
+ ),
119
+ 'join_close' => ') as stock_table_init on %1$s.id = stock_table_init.id',
120
+ 'group' => 'GROUP BY id',
121
+ ),
122
+ 'join_close_2' => ') as stock_table ON filtered_post.var_id = stock_table.id',
123
+ 'group' => 'GROUP BY filtered_post.ID, out_of_stock',
124
+ ),
125
+ 'from_close' => ') as filtered_post',
126
+ 'group' => 'GROUP BY filtered_post.ID',
127
+ 'having' => 'HAVING post_count = 1 AND out_of_stock = 1',
128
+ );
129
+ $query = apply_filters('berocket_aapf_wcvariation_filtering_total_query', $query, $input, $terms, $limits, $current_attributes, $current_terms);
130
+ $query = self::implode_recursive($query);
131
+ $query = sprintf( $query, $wpdb->posts, $wpdb->postmeta, $wpdb->term_relationships, $current_attributes, $current_terms );
132
  $out_of_stock_variable = $wpdb->get_results( $query, ARRAY_N );
133
  if( BeRocket_AAPF::$debug_mode ) {
134
  if( ! isset(BeRocket_AAPF::$error_log['_addons_variations_query']) || ! is_array(BeRocket_AAPF::$error_log['_addons_variations_query']) ) {
148
  }
149
  return $post_not_in;
150
  }
151
+ public static function implode_recursive($array, $glue = ' ') {
152
+ foreach($array as &$element) {
153
+ if( is_array($element) ) {
154
+ $element = self::implode_recursive($element, $glue);
155
+ }
156
+ }
157
+ return implode($glue, $array);
158
+ }
159
  public static function out_of_stock_where($custom_where) {
 
160
  if ( ! empty($_POST['price_ranges']) || ! empty($_POST['price']) ) {
161
  global $wpdb;
162
  $custom_where .= ' OR %1$s.id IN (
182
  }
183
  return $custom_where;
184
  }
185
+ public function faster_recount_add_data($query, $taxonomy_data, $terms) {
186
+ global $wpdb;
187
+ extract($taxonomy_data);
188
+ if( ! $use_filters ) return $query;
189
+ $br_options = BeRocket_AAPF::get_aapf_option();
190
+ if( ! empty($br_options['out_of_stock_variable_reload']) ) {
191
+ $new_post_terms = berocket_isset($_POST['terms']);
192
+ $new_post_limits = berocket_isset($_POST['limits_arr']);
193
+ if( is_array($new_post_terms) && count($new_post_terms) ) {
194
+ foreach($new_post_terms as $new_post_terms_i => $new_post_term) {
195
+ if( $new_post_term[0] == $taxonomy ) {
196
+ unset($new_post_terms[$new_post_terms_i]);
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) ) {
218
+ $limit_post__not_in_where_array[] = "(term_relationships.term_taxonomy_id IN (".implode(', ', $limit_post__term_id_without_product)."))";
219
+ }
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
+ }
227
+ return $query;
228
+ }
229
+ public function faster_recount_query_result($results, $query, $terms) {
230
+ $limit_post__not_in_where_array = $this->limit_post__not_in_where_array;
231
+ $this->limit_post__not_in_where_array = array();
232
+ $br_options = BeRocket_AAPF::get_aapf_option();
233
+ if( ! empty($br_options['out_of_stock_variable_reload']) && ! empty($br_options['out_of_stock_variable_single']) ) {
234
+ if( isset($limit_post__not_in_where_array) && is_array($limit_post__not_in_where_array) && count($limit_post__not_in_where_array) ) {
235
+ global $wpdb;
236
+ foreach($limit_post__not_in_where_array as $term_id => $limit_post) {
237
+ $query_new = $query;
238
+ $query_new['where'] .= " AND ({$limit_post})";
239
+ $query_new = implode( ' ', $query_new );
240
+ $result = $wpdb->get_results( $query_new );
241
+ if( ! empty($result) && is_array($result) && count($result) ) {
242
+ foreach($result as $result_i) {
243
+ foreach($results as &$results_data) {
244
+ if( $results_data->term_count_id == $result_i->term_count_id ) {
245
+ $results_data->term_count = $result_i->term_count;
246
+ break;
247
+ }
248
+ }
249
+ }
250
+ }
251
+ }
252
+ }
253
+ }
254
+ return $results;
255
+ }
256
+ function faster_recount_cache_key($key) {
257
+ $br_options = BeRocket_AAPF::get_aapf_option();
258
+ if( ! empty($br_options['out_of_stock_variable_reload']) ) {
259
+ $key .= 'V';
260
+ }
261
+ if( ! empty($br_options['out_of_stock_variable_reload']) && ! empty($br_options['out_of_stock_variable_single']) ) {
262
+ $key .= 'V';
263
+ }
264
+ return $key;
265
+ }
266
  }
267
  new BeRocket_AAPF_compat_woocommerce_variation();
includes/custom_post.php CHANGED
@@ -33,6 +33,9 @@ class BeRocket_AAPF_single_filter extends BeRocket_custom_post_class {
33
  public $hook_name = 'berocket_aapf_single_filter';
34
  public $conditions;
35
  protected static $instance;
 
 
 
36
  function __construct() {
37
  add_action('ajax_filters_framework_construct', array($this, 'init_conditions'));
38
  $this->post_name = 'br_product_filter';
@@ -502,6 +505,9 @@ class BeRocket_AAPF_group_filters extends BeRocket_custom_post_class {
502
  public $hook_name = 'berocket_aapf_group_filters';
503
  public $conditions;
504
  protected static $instance;
 
 
 
505
  function __construct() {
506
  add_action('ajax_filters_framework_construct', array($this, 'init_conditions'));
507
  $this->post_name = 'br_filters_group';
33
  public $hook_name = 'berocket_aapf_single_filter';
34
  public $conditions;
35
  protected static $instance;
36
+ public $post_type_parameters = array(
37
+ 'can_be_disabled' => true
38
+ );
39
  function __construct() {
40
  add_action('ajax_filters_framework_construct', array($this, 'init_conditions'));
41
  $this->post_name = 'br_product_filter';
505
  public $hook_name = 'berocket_aapf_group_filters';
506
  public $conditions;
507
  protected static $instance;
508
+ public $post_type_parameters = array(
509
+ 'can_be_disabled' => true
510
+ );
511
  function __construct() {
512
  add_action('ajax_filters_framework_construct', array($this, 'init_conditions'));
513
  $this->post_name = 'br_filters_group';
includes/faster_recount.php ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class BeRocket_AAPF_faster_attribute_recount {
3
+ function __construct() {
4
+ add_filter('berocket_aapf_recount_terms_apply', array($this, 'recount_terms'), 10, 2);
5
+ add_filter('berocket_aapf_recount_terms_query', array($this, 'search_query'), 50, 3);
6
+ add_filter('berocket_aapf_recount_terms_query', array($this, 'date_query'), 60, 3);
7
+ add_filter('berocket_aapf_recount_terms_query', array($this, 'wpml_query'), 70, 3);
8
+ //Child terms include for hierarchical taxonomy
9
+ add_filter('berocket_aapf_recount_terms_query', array($this, 'child_include'), 50, 3);
10
+ //Stock Status custom 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
+ $taxonomy_data = apply_filters('berocket_recount_taxonomy_data', array_merge(array(
17
+ 'taxonomy' => '',
18
+ 'operator' => 'OR',
19
+ 'use_filters' => TRUE,
20
+ 'tax_query' => FALSE,
21
+ 'meta_query' => FALSE,
22
+ 'post__not_in' => array(),
23
+ 'post__in' => array(),
24
+ 'include_child' => TRUE
25
+ ), $taxonomy_data), $terms);
26
+ extract($taxonomy_data);
27
+ global $wpdb;
28
+ if( $terms === FALSE ) {
29
+ $terms = $this->get_terms($taxonomy);
30
+ }
31
+ if( empty($terms) ) {
32
+ return $terms;
33
+ }
34
+ if( $tax_query === FALSE ) {
35
+ $tax_query = WC_Query::get_main_tax_query();
36
+ }
37
+ if( $meta_query === FALSE ) {
38
+ $meta_query = WC_Query::get_main_meta_query();
39
+ }
40
+ if( strtoupper($operator) == 'OR' || ! $use_filters ) {
41
+ $tax_query = $this->remove_all_berocket_tax_query($tax_query, ($use_filters ? $taxonomy : FALSE));
42
+ }
43
+
44
+ $taxonomy_data['meta_query_ready'] = $meta_query = new WP_Meta_Query( $meta_query );
45
+ $taxonomy_data['tax_query_ready'] = $tax_query = new WP_Tax_Query( $tax_query );
46
+ $taxonomy_data['meta_query_sql'] = $meta_query_sql = $meta_query->get_sql( 'post', $wpdb->posts, 'ID' );
47
+ $taxonomy_data['tax_query_sql'] = $tax_query_sql = $tax_query->get_sql( $wpdb->posts, 'ID' );
48
+ $taxonomy_data['term_taxonomy_ids'] = $term_taxonomy_ids = wp_list_pluck($terms, 'term_taxonomy_id', 'term_id');
49
+ if( $return_terms = apply_filters('berocket_recount_extension_enabled', false, $terms, $taxonomy_data) ) {
50
+ return $return_terms;
51
+ }
52
+
53
+ // Generate query.
54
+ $query = array(
55
+ 'select' => array(
56
+ 'select' => "SELECT",
57
+ 'elements' => array(
58
+ 'term_count' => "COUNT( DISTINCT {$wpdb->posts}.ID ) as term_count",
59
+ 'term_count_id' => "term_relationships.term_taxonomy_id as term_count_id",
60
+ ),
61
+ ),
62
+ 'from' => "FROM {$wpdb->posts}",
63
+ 'join' => array(
64
+ 'term_relationships' => "INNER JOIN {$wpdb->term_relationships} AS term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id",
65
+ 'tax_query' => $tax_query_sql['join'],
66
+ 'meta_query' => $meta_query_sql['join'],
67
+ ),
68
+ 'where' => array(
69
+ 'where_main' => "WHERE {$wpdb->posts}.post_type IN ( 'product' ) AND {$wpdb->posts}.post_status = 'publish'",
70
+ 'tax_query' => $tax_query_sql['where'],
71
+ 'meta_query' => $meta_query_sql['where'],
72
+ 'term_taxonomy_id' => 'AND term_relationships.term_taxonomy_id IN (' . implode( ',', array_map( 'absint', $term_taxonomy_ids ) ) . ')',
73
+ 'post__not_in' => (empty($post__not_in) ? '' : "AND {$wpdb->posts}.ID NOT IN (\"" . implode('","', $post__not_in) . "\")"),
74
+ 'post__in' => (empty($post__in) ? '' : "AND {$wpdb->posts}.ID IN (\"" . implode('","', $post__in) . "\")"),
75
+ ),
76
+ 'group_by' => 'GROUP BY term_relationships.term_taxonomy_id',
77
+ );
78
+ $query = apply_filters('berocket_aapf_recount_terms_query', $query, $taxonomy_data, $terms);
79
+ $query['select']['elements']= implode(', ', $query['select']['elements']);
80
+ $query['select'] = implode(' ', $query['select']);
81
+ $query['join'] = implode(' ', $query['join']);
82
+ $query['where'] = implode(' ', $query['where']);
83
+ $query = apply_filters('woocommerce_get_filtered_term_product_counts_query', $query);
84
+ if( $use_filters ) {
85
+ $query = apply_filters( 'berocket_posts_clauses_recount', $query );
86
+ }
87
+ $query_imploded = implode( ' ', $query );
88
+ if( apply_filters('berocket_recount_cache_use', (! $use_filters), $taxonomy_data) ) {
89
+ $terms_cache = br_get_cache(apply_filters('berocket_recount_cache_key', md5($query_imploded), $taxonomy_data), 'berocket_recount');
90
+ }
91
+ if( empty($terms_cache) ) {
92
+ $result = $wpdb->get_results( $query_imploded );
93
+ $result = apply_filters('berocket_query_result_recount', $result, $query, $terms);
94
+ $result = wp_list_pluck($result, 'term_count', 'term_count_id');
95
+ foreach($terms as &$term) {
96
+ $term->count = (isset($result[$term->term_taxonomy_id]) ? $result[$term->term_taxonomy_id] : 0);
97
+ }
98
+ $terms = apply_filters('berocket_terms_after_recount', $terms, $query, $result);
99
+ if( ! $use_filters ) {
100
+ br_set_cache(md5(json_encode($taxonomy_data)), $terms, 'berocket_recount', DAY_IN_SECONDS);
101
+ }
102
+ } else {
103
+ $terms = $terms_cache;
104
+ }
105
+ return $terms;
106
+ }
107
+ function child_include($query, $taxonomy_data, $terms) {
108
+ global $wpdb;
109
+ extract($taxonomy_data);
110
+ if( $include_child ) {
111
+ $taxonomy_object = get_taxonomy($taxonomy);
112
+ if( ! empty($taxonomy_object->hierarchical) ) {
113
+ $hierarchy = br_get_taxonomy_hierarchy(array('taxonomy' => $taxonomy, 'return' => 'child'));
114
+ $join_query = "INNER JOIN (SELECT object_id,tt1id as term_taxonomy_id, term_order FROM {$wpdb->term_relationships}
115
+ JOIN (
116
+ SELECT tt1.term_taxonomy_id as tt1id, tt2.term_taxonomy_id as tt2id FROM wp_term_taxonomy as tt1
117
+ JOIN wp_term_taxonomy as tt2 ON (";
118
+ $join_list = array();
119
+ foreach($hierarchy as $term_id => $term_child) {
120
+ $join_list[] = "(tt1.term_id = '{$term_id}' AND tt2.term_id IN('".implode("','", $term_child)."'))";
121
+ }
122
+ $join_query .= implode('
123
+ OR
124
+ ', $join_list);
125
+ $join_query .= ") ) as term_taxonomy
126
+ ON {$wpdb->term_relationships}.term_taxonomy_id = term_taxonomy.tt2id ) as term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id";
127
+ $query['join']['term_relationships'] = $join_query;
128
+ }
129
+ }
130
+ return $query;
131
+ }
132
+ function search_query($query, $taxonomy_data, $terms) {
133
+ extract($taxonomy_data);
134
+ if( ! empty($use_filters) ) {
135
+ $search = WC_Query::get_main_search_query_sql();
136
+ if ( $search ) {
137
+ $query['where']['search'] = 'AND ' . $search;
138
+ }
139
+ }
140
+ return $query;
141
+ }
142
+ function date_query($query, $taxonomy_data, $terms) {
143
+ extract($taxonomy_data);
144
+ if( ! empty($use_filters) ) {
145
+ if( ! empty($_POST['limits']) && is_array($_POST['limits']) && count($_POST['limits']) ) {
146
+ foreach($_POST['limits'] as $limit) {
147
+ if($limit[0] == '_date') {
148
+ $from = $limit[1];
149
+ $to = $limit[2];
150
+ $from = date('Y-m-d 00:00:00', strtotime($from));
151
+ $to = date('Y-m-d 23:59:59', strtotime($to));
152
+ $date_query_data = array(
153
+ 'after' => $from,
154
+ 'before' => $to,
155
+ );
156
+ $date_query = new WP_Date_Query( $date_query_data, 'post_date' );
157
+ $query['where']['date'] = $date_query->get_sql();
158
+ break;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ return $query;
164
+ }
165
+ function wpml_query($query, $taxonomy_data, $terms) {
166
+ extract($taxonomy_data);
167
+ if( defined( 'WCML_VERSION' ) && defined('ICL_LANGUAGE_CODE') ) {
168
+ $query['join']['wpml'] = " INNER JOIN {$wpdb->prefix}icl_translations as wpml_lang ON ( {$wpdb->posts}.ID = wpml_lang.element_id )";
169
+ $query['where']['wpml'] = " AND wpml_lang.language_code = '".ICL_LANGUAGE_CODE."' AND wpml_lang.element_type = 'post_product'";
170
+ }
171
+ return $query;
172
+ }
173
+ function remove_all_berocket_tax_query($tax_query, $taxonomy = FALSE, $inside = FALSE ) {
174
+ if( is_array($tax_query) ) {
175
+ $md5_exist = array();
176
+ foreach($tax_query as $key => $value) {
177
+ if( $key === 'relation' ) continue;
178
+ if( ! $inside ) {
179
+ if( in_array(md5(json_encode($value)), $md5_exist) ) {
180
+ unset($tax_query[$key]);
181
+ continue;
182
+ }
183
+ $md5_exist[] = md5(json_encode($value));
184
+ }
185
+ if( array_key_exists('relation', $value) ) {
186
+ $value = $this->remove_all_berocket_tax_query($value, $taxonomy, true);
187
+ if( $value === FALSE ) {
188
+ unset($tax_query[$key]);
189
+ } else {
190
+ $tax_query[$key] = $value;
191
+ }
192
+ } elseif( ! empty($value['is_berocket']) && isset($value['taxonomy']) && ($taxonomy === FALSE || $taxonomy == $value['taxonomy']) ) {
193
+ unset($tax_query[$key]);
194
+ }
195
+ }
196
+ if( count($tax_query) == 1 && isset($tax_query['relation']) ) {
197
+ $tax_query = ( $inside ? FALSE : array() );
198
+ }
199
+ }
200
+ return $tax_query;
201
+ }
202
+ function get_all_taxonomies($taxonomy = FALSE) {
203
+ if( empty($taxonomy) ) {
204
+ $attributes = wc_get_attribute_taxonomies();
205
+ $taxonomy = array();
206
+ foreach($attributes as $attribute) {
207
+ $taxonomy[] = 'pa_'.$attribute->attribute_name;
208
+ }
209
+ } elseif( ! is_array($taxonomy) ) {
210
+ $taxonomy = array($taxonomy);
211
+ }
212
+ return $taxonomy;
213
+ }
214
+ function get_terms($taxonomy) {
215
+ if( ! empty($taxonomy) ) {
216
+ $terms = get_terms(array('taxonomy' => $taxonomy) );
217
+ } else {
218
+ $taxonomy = $this->get_all_taxonomies();
219
+ $terms = get_terms(array('taxonomy' => $taxonomy) );
220
+ }
221
+ return $terms;
222
+ }
223
+ function stock_status_query($query, $taxonomy_data, $terms) {
224
+ global $wpdb;
225
+ extract($taxonomy_data);
226
+ if( $taxonomy == '_stock_status' ) {
227
+ $outofstock = wc_get_product_visibility_term_ids();
228
+ if( empty($outofstock['outofstock']) ) {
229
+ $outofstock = get_term_by( 'slug', 'outofstock', 'product_visibility' );
230
+ $outofstock = $outofstock->term_taxonomy_id;
231
+ } else {
232
+ $outofstock = $outofstock['outofstock'];
233
+ }
234
+ $join_query = "INNER JOIN (SELECT {$wpdb->posts}.ID as object_id, IF({$wpdb->term_relationships}.term_taxonomy_id = {$outofstock}, 2, 1) as term_taxonomy_id, 0 as term_order FROM wp_posts
235
+ LEFT JOIN {$wpdb->term_relationships} ON {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id AND {$wpdb->term_relationships}.term_taxonomy_id = {$outofstock}
236
+ WHERE {$wpdb->posts}.post_type = 'product') as term_relationships
237
+ ON {$wpdb->posts}.ID = term_relationships.object_id";
238
+ $query['join']['term_relationships'] = $join_query;
239
+ }
240
+ return $query;
241
+ }
242
+ function onsale_query($query, $taxonomy_data, $terms) {
243
+ global $wpdb;
244
+ extract($taxonomy_data);
245
+ if( $taxonomy == '_sale' ) {
246
+ $join_query = "INNER JOIN (";
247
+ /*if( ! empty($wpdb->wc_product_meta_lookup) ) {
248
+ $join_query .= "SELECT {$wpdb->wc_product_meta_lookup}.product_id as object_id, IF({$wpdb->wc_product_meta_lookup}.onsale = 1, 1, 2) as term_taxonomy_id, 0 as term_order FROM {$wpdb->wc_product_meta_lookup}";
249
+ } else {*/
250
+ $products_id = wc_get_product_ids_on_sale();
251
+ $join_query .= "SELECT {$wpdb->posts}.ID as object_id, IF({$wpdb->posts}.ID IN (".implode(',', $products_id)."), 1, 2) as term_taxonomy_id, 0 as term_order FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_type = 'product'";
252
+ //}
253
+ $join_query .= ") as term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id";
254
+ $query['join']['term_relationships'] = $join_query;
255
+ }
256
+ return $query;
257
+ }
258
+ }
259
+ new BeRocket_AAPF_faster_attribute_recount();
includes/functions.php CHANGED
@@ -502,6 +502,7 @@ if( ! function_exists( 'br_aapf_args_converter' ) ) {
502
  $_GET['filters'] = urldecode($_GET['filters']);
503
  }
504
  $_POST['terms'] = array();
 
505
  $_POST['limits'] = array();
506
  $_POST['price'] = array();
507
  $filters = array();
@@ -2168,12 +2169,12 @@ if ( ! function_exists( 'br_filters_query' ) ) {
2168
  if( ! isset($query[ 'join' ]) ) {
2169
  $query[ 'join' ] = '';
2170
  }
2171
- $query[ 'join' ]
2172
- .= "
2173
  INNER JOIN {$wpdb->term_relationships} AS term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id
2174
  INNER JOIN {$wpdb->term_taxonomy} AS term_taxonomy USING( term_taxonomy_id )
2175
  INNER JOIN {$wpdb->terms} AS terms USING( term_id )
2176
- " . $tax_query_sql[ 'join' ] . $meta_query_sql[ 'join' ];
 
2177
  if( ! isset($query[ 'where' ]) ) {
2178
  $query[ 'where' ] = '';
2179
  }
@@ -2191,10 +2192,10 @@ if ( ! function_exists( 'br_filters_query' ) ) {
2191
  if ( ! empty( $post__in ) ) {
2192
  $query[ 'where' ] .= " AND {$wpdb->posts}.ID IN (\"" . implode( '","', $post__in ) . "\")";
2193
  }
2194
- if( function_exists('wc_get_product_visibility_term_ids') ) {
2195
  $product_visibility_term_ids = wc_get_product_visibility_term_ids();
2196
- $query[ 'where' ] .= " AND {$wpdb->posts}.ID NOT IN (\"SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id='" . $product_visibility_term_ids[ 'exclude-from-catalog' ] . "'\")";
2197
- }
2198
 
2199
  $query[ 'where' ] .= $old_join_posts;
2200
  //$query['group_by'] = "GROUP BY {$wpdb->posts}.ID";
@@ -2205,14 +2206,28 @@ if ( ! function_exists( 'br_filters_query' ) ) {
2205
  }
2206
 
2207
  if( ! function_exists('berocket_add_filter_to_link') ) {
2208
- function berocket_add_filter_to_link($attribute = '', $values = array(), $operator = 'OR', $remove_attribute = FALSE) {
 
 
 
 
 
 
 
 
 
2209
  if( ! is_array($values) ) {
2210
  $values = array($values);
2211
  }
2212
  $options = BeRocket_AAPF::get_aapf_option();
2213
 
2214
- $current_url = "//" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
2215
- $filters = (empty($_GET['filters']) ? '' : $_GET['filters']);
 
 
 
 
 
2216
  $current_url = remove_query_arg('filters', $current_url);
2217
  if( strpos($current_url, '?') === FALSE ) {
2218
  $url_string = $current_url;
@@ -2230,7 +2245,7 @@ if( ! function_exists('berocket_add_filter_to_link') ) {
2230
  $attribute = substr($attribute, 3);
2231
  }
2232
  if( strpos('|'.$filters, '|'.$attribute.'[') === FALSE ) {
2233
- $filters = ( empty($filters) ? '' : $filters.'|' ).$attribute.'['.implode(($operator == 'OR' ? '-' : '+'), $values).']';
2234
  $filter_array = explode('|', $filters);
2235
  } else {
2236
  $filter_array = explode('|', $filters);
@@ -2239,7 +2254,10 @@ if( ! function_exists('berocket_add_filter_to_link') ) {
2239
  $filter_str = str_replace($attribute.'[', '', $filter_str);
2240
  $filter_str = str_replace(']', '', $filter_str);
2241
  $filter_values = array();
2242
- if( strpos($filter_str, '+') !== FALSE ) {
 
 
 
2243
  $implode = '+';
2244
  } elseif( strpos($filter_str, '-') !== FALSE ) {
2245
  $implode = '-';
@@ -2307,7 +2325,7 @@ if( ! function_exists('br_get_taxonomy_hierarchy') ) {
2307
  ), $args);
2308
  $md5 = $wpdb->get_var(
2309
  $wpdb->prepare(
2310
- "SELECT MD5(GROUP_CONCAT(CONCAT(t.slug, t.term_id, tt.parent, tt.count))) FROM $wpdb->terms AS t
2311
  INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id
2312
  WHERE tt.taxonomy IN (%s)",
2313
  $args['taxonomy']
@@ -2320,6 +2338,7 @@ if( ! function_exists('br_get_taxonomy_hierarchy') ) {
2320
  $hierarchy_data = array(
2321
  'terms' => $hierarchy,
2322
  'hierarchy' => array(),
 
2323
  'md5' => $md5,
2324
  'time' => time()
2325
  );
@@ -2328,9 +2347,15 @@ if( ! function_exists('br_get_taxonomy_hierarchy') ) {
2328
  foreach($hierarchy_term->child_list as $child_list_id => $child_list_array) {
2329
  $hierarchy_data['hierarchy'][$child_list_id] = array_merge(array($hierarchy_term->term_id), $child_list_array);
2330
  }
 
 
 
2331
  }
2332
  update_option( apply_filters('br_aapf_md5_cache_text', 'br_get_taxonomy_hierarchy_'.$args['taxonomy']), $hierarchy_data );
2333
  }
 
 
 
2334
  if( $args['return'] == 'all' ) {
2335
  return $hierarchy_data;
2336
  }
@@ -2380,6 +2405,7 @@ if( ! function_exists('br_generate_taxonomy_hierarchy') ) {
2380
  $child_terms = br_generate_taxonomy_hierarchy($taxonomy, $term->term_id);
2381
  $term->child = array();
2382
  $term->child_list = array();
 
2383
  if( ! empty($child_terms) && is_array($child_terms) && count($child_terms) ) {
2384
  foreach($child_terms as $child_term) {
2385
  $term->child[$child_term->term_id] = $child_term;
@@ -2387,6 +2413,10 @@ if( ! function_exists('br_generate_taxonomy_hierarchy') ) {
2387
  foreach($child_term->child_list as $child_list_id => $child_list_array) {
2388
  $term->child_list[$child_list_id] = array_merge(array($child_term->term_id), $child_list_array);
2389
  }
 
 
 
 
2390
  }
2391
  }
2392
  $result_terms[$term->term_id] = $term;
502
  $_GET['filters'] = urldecode($_GET['filters']);
503
  }
504
  $_POST['terms'] = array();
505
+ $_POST['add_terms'] = array();
506
  $_POST['limits'] = array();
507
  $_POST['price'] = array();
508
  $filters = array();
2169
  if( ! isset($query[ 'join' ]) ) {
2170
  $query[ 'join' ] = '';
2171
  }
2172
+ /*$query[ 'join' ] .= "
 
2173
  INNER JOIN {$wpdb->term_relationships} AS term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id
2174
  INNER JOIN {$wpdb->term_taxonomy} AS term_taxonomy USING( term_taxonomy_id )
2175
  INNER JOIN {$wpdb->terms} AS terms USING( term_id )
2176
+ ";*/
2177
+ $query[ 'join' ] .= $tax_query_sql[ 'join' ] . $meta_query_sql[ 'join' ];
2178
  if( ! isset($query[ 'where' ]) ) {
2179
  $query[ 'where' ] = '';
2180
  }
2192
  if ( ! empty( $post__in ) ) {
2193
  $query[ 'where' ] .= " AND {$wpdb->posts}.ID IN (\"" . implode( '","', $post__in ) . "\")";
2194
  }
2195
+ /*if( function_exists('wc_get_product_visibility_term_ids') ) {
2196
  $product_visibility_term_ids = wc_get_product_visibility_term_ids();
2197
+ $query[ 'where' ] .= " AND ( {$wpdb->posts}.ID NOT IN (SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id='" . $product_visibility_term_ids[ 'exclude-from-catalog' ] . "') ) ";
2198
+ }*/
2199
 
2200
  $query[ 'where' ] .= $old_join_posts;
2201
  //$query['group_by'] = "GROUP BY {$wpdb->posts}.ID";
2206
  }
2207
 
2208
  if( ! function_exists('berocket_add_filter_to_link') ) {
2209
+ add_filter('berocket_add_filter_to_link', 'berocket_add_filter_to_link', 100, 2);
2210
+ function berocket_add_filter_to_link($current_url = FALSE, $args = array()) {
2211
+ $args = array_merge(array(
2212
+ 'attribute' => '',
2213
+ 'values' => array(),
2214
+ 'operator' => 'OR',
2215
+ 'remove_attribute' => FALSE,
2216
+ 'slider' => FALSE
2217
+ ), $args);
2218
+ extract($args);
2219
  if( ! is_array($values) ) {
2220
  $values = array($values);
2221
  }
2222
  $options = BeRocket_AAPF::get_aapf_option();
2223
 
2224
+ if( $current_url === FALSE ) {
2225
+ $current_url = "//" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
2226
+ $filters = (empty($_GET['filters']) ? '' : $_GET['filters']);
2227
+ } else {
2228
+ parse_str(parse_url($current_url, PHP_URL_QUERY), $filters);
2229
+ $filters = br_get_value_from_array($filters, 'filters');
2230
+ }
2231
  $current_url = remove_query_arg('filters', $current_url);
2232
  if( strpos($current_url, '?') === FALSE ) {
2233
  $url_string = $current_url;
2245
  $attribute = substr($attribute, 3);
2246
  }
2247
  if( strpos('|'.$filters, '|'.$attribute.'[') === FALSE ) {
2248
+ $filters = ( empty($filters) ? '' : $filters.'|' ).$attribute.'['.implode(($slider ? '_' : ($operator == 'OR' ? '-' : '+')), $values).']';
2249
  $filter_array = explode('|', $filters);
2250
  } else {
2251
  $filter_array = explode('|', $filters);
2254
  $filter_str = str_replace($attribute.'[', '', $filter_str);
2255
  $filter_str = str_replace(']', '', $filter_str);
2256
  $filter_values = array();
2257
+ if( $slider ) {
2258
+ $implode = '_';
2259
+ $filter_str = '';
2260
+ } elseif( strpos($filter_str, '+') !== FALSE ) {
2261
  $implode = '+';
2262
  } elseif( strpos($filter_str, '-') !== FALSE ) {
2263
  $implode = '-';
2325
  ), $args);
2326
  $md5 = $wpdb->get_var(
2327
  $wpdb->prepare(
2328
+ "SELECT MD5(GROUP_CONCAT(CONCAT(t.slug, t.term_id, tt.parent, tt.count, tt.term_taxonomy_id))) FROM $wpdb->terms AS t
2329
  INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id
2330
  WHERE tt.taxonomy IN (%s)",
2331
  $args['taxonomy']
2338
  $hierarchy_data = array(
2339
  'terms' => $hierarchy,
2340
  'hierarchy' => array(),
2341
+ 'child' => array(),
2342
  'md5' => $md5,
2343
  'time' => time()
2344
  );
2347
  foreach($hierarchy_term->child_list as $child_list_id => $child_list_array) {
2348
  $hierarchy_data['hierarchy'][$child_list_id] = array_merge(array($hierarchy_term->term_id), $child_list_array);
2349
  }
2350
+ foreach($hierarchy_term->parent_list as $parent_list_id => $parent_list_array) {
2351
+ $hierarchy_data['child'][$parent_list_id] = $parent_list_array;
2352
+ }
2353
  }
2354
  update_option( apply_filters('br_aapf_md5_cache_text', 'br_get_taxonomy_hierarchy_'.$args['taxonomy']), $hierarchy_data );
2355
  }
2356
+ if( is_array($hierarchy_data) && isset($hierarchy_data[$args['return']]) ) {
2357
+ return $hierarchy_data[$args['return']];
2358
+ }
2359
  if( $args['return'] == 'all' ) {
2360
  return $hierarchy_data;
2361
  }
2405
  $child_terms = br_generate_taxonomy_hierarchy($taxonomy, $term->term_id);
2406
  $term->child = array();
2407
  $term->child_list = array();
2408
+ $term->parent_list = array($term->term_id => array($term->term_id));
2409
  if( ! empty($child_terms) && is_array($child_terms) && count($child_terms) ) {
2410
  foreach($child_terms as $child_term) {
2411
  $term->child[$child_term->term_id] = $child_term;
2413
  foreach($child_term->child_list as $child_list_id => $child_list_array) {
2414
  $term->child_list[$child_list_id] = array_merge(array($child_term->term_id), $child_list_array);
2415
  }
2416
+ foreach($child_term->parent_list as $parent_list_id => $parent_list_array) {
2417
+ $term->parent_list[$term->term_id] = array_merge(array($parent_list_id), $term->parent_list[$term->term_id]);
2418
+ $term->parent_list[$parent_list_id] = $parent_list_array;
2419
+ }
2420
  }
2421
  }
2422
  $result_terms[$term->term_id] = $term;
includes/new_widget.php CHANGED
@@ -2,8 +2,8 @@
2
  class BeRocket_new_AAPF_Widget extends WP_Widget
3
  {
4
  public function __construct() {
5
- parent::__construct("berocket_aapf_group", "AAPF Filters Group",
6
- array("description" => "AJAX Product Filters Group"));
7
  }
8
  public function widget($args, $instance) {
9
  if( ! self::check_widget_by_instance($instance) ) {
@@ -31,20 +31,20 @@ class BeRocket_new_AAPF_Widget extends WP_Widget
31
  $custom_vars = apply_filters('berocket_aapf_group_before_all', $custom_vars, $filters);
32
  $new_args = apply_filters('berocket_aapf_group_new_args', $new_args, $filters, $custom_vars);
33
  foreach($filters['filters'] as $filter) {
34
- $new_args = apply_filters('berocket_aapf_group_new_args_filter', $new_args, $filters, $filter, $custom_vars);
35
  if( $is_shortcode ) {
36
- if( isset($new_args['before_widget']) ) {
37
- unset($new_args['before_widget']);
38
  }
39
- if( isset($new_args['after_widget']) ) {
40
- unset($new_args['after_widget']);
41
  }
42
  } else {
43
- $new_args['widget_id'] = $args['widget_id'].'-'.$i;
44
- $new_args['before_widget'] = sprintf($before_widget, $new_args['widget_id'], '%s');
45
  }
46
  $custom_vars = apply_filters('berocket_aapf_group_before_filter', $custom_vars, $filters);
47
- the_widget( 'BeRocket_new_AAPF_Widget_single', array('filter_id' => $filter), $new_args);
48
  $custom_vars = apply_filters('berocket_aapf_group_after_filter', $custom_vars, $filters);
49
  $i++;
50
  }
@@ -70,6 +70,9 @@ class BeRocket_new_AAPF_Widget extends WP_Widget
70
  if( empty($filters) ) {
71
  return false;
72
  }
 
 
 
73
  if( ! empty($filters['data']) && ! BeRocket_conditions::check($filters['data'], $BeRocket_AAPF_group_filters->hook_name) ) {
74
  return false;
75
  }
@@ -129,8 +132,8 @@ class BeRocket_new_AAPF_Widget extends WP_Widget
129
  class BeRocket_new_AAPF_Widget_single extends WP_Widget
130
  {
131
  public function __construct() {
132
- parent::__construct("berocket_aapf_single", "AAPF Filter Single",
133
- array("description" => "AJAX Product Filters Single"));
134
  }
135
  public function widget($args, $instance) {
136
  if( ! self::check_widget_by_instance($instance) ) {
@@ -207,7 +210,7 @@ class BeRocket_new_AAPF_Widget_single extends WP_Widget
207
  echo '{' . htmlentities($args['widget_inline_style'], ENT_HTML5) . '}';
208
  echo '</style>';
209
  }
210
- echo '<div class="' . $additional_class_esc . '" data-id="' . esc_html($instance['filter_id']) . '" style="'.htmlentities(br_get_value_from_array($args, 'inline_style')).'">';
211
  }
212
  if( apply_filters('BeRocket_AAPF_widget_old_display_conditions', true, $filter_data, $instance, $args) ) {
213
  the_widget( 'BeRocket_AAPF_widget', $filter_data, $args);
@@ -224,6 +227,9 @@ class BeRocket_new_AAPF_Widget_single extends WP_Widget
224
  $filter_post = get_post($filter_id);
225
  $BeRocket_AAPF_single_filter = BeRocket_AAPF_single_filter::getInstance();
226
  $filter_data = $BeRocket_AAPF_single_filter->get_option($filter_id);
 
 
 
227
  if( ! empty($filter_data['data']) && ! BeRocket_conditions::check($filter_data['data'], $BeRocket_AAPF_single_filter->hook_name) ) {
228
  return false;
229
  }
2
  class BeRocket_new_AAPF_Widget extends WP_Widget
3
  {
4
  public function __construct() {
5
+ parent::__construct("berocket_aapf_group", __("AAPF Filters Group", 'BeRocket_AJAX_domain'),
6
+ array("description" => __("AJAX Product Filters. Group of filters", 'BeRocket_AJAX_domain')));
7
  }
8
  public function widget($args, $instance) {
9
  if( ! self::check_widget_by_instance($instance) ) {
31
  $custom_vars = apply_filters('berocket_aapf_group_before_all', $custom_vars, $filters);
32
  $new_args = apply_filters('berocket_aapf_group_new_args', $new_args, $filters, $custom_vars);
33
  foreach($filters['filters'] as $filter) {
34
+ $new_args_filter = apply_filters('berocket_aapf_group_new_args_filter', $new_args, $filters, $filter, $custom_vars);
35
  if( $is_shortcode ) {
36
+ if( isset($new_args_filter['before_widget']) ) {
37
+ unset($new_args_filter['before_widget']);
38
  }
39
+ if( isset($new_args_filter['after_widget']) ) {
40
+ unset($new_args_filter['after_widget']);
41
  }
42
  } else {
43
+ $new_args_filter['widget_id'] = $args['widget_id'].'-'.$i;
44
+ $new_args_filter['before_widget'] = sprintf($before_widget, $new_args_filter['widget_id'], '%s');
45
  }
46
  $custom_vars = apply_filters('berocket_aapf_group_before_filter', $custom_vars, $filters);
47
+ the_widget( 'BeRocket_new_AAPF_Widget_single', array('filter_id' => $filter), $new_args_filter);
48
  $custom_vars = apply_filters('berocket_aapf_group_after_filter', $custom_vars, $filters);
49
  $i++;
50
  }
70
  if( empty($filters) ) {
71
  return false;
72
  }
73
+ if( has_term('isdisabled', 'berocket_taxonomy_data', intval($instance['group_id'])) ) {
74
+ return false;
75
+ }
76
  if( ! empty($filters['data']) && ! BeRocket_conditions::check($filters['data'], $BeRocket_AAPF_group_filters->hook_name) ) {
77
  return false;
78
  }
132
  class BeRocket_new_AAPF_Widget_single extends WP_Widget
133
  {
134
  public function __construct() {
135
+ parent::__construct("berocket_aapf_single", __("AAPF Filter Single", 'BeRocket_AJAX_domain'),
136
+ array("description" => __("AJAX Product Filters. Single Filter", 'BeRocket_AJAX_domain')));
137
  }
138
  public function widget($args, $instance) {
139
  if( ! self::check_widget_by_instance($instance) ) {
210
  echo '{' . htmlentities($args['widget_inline_style'], ENT_HTML5) . '}';
211
  echo '</style>';
212
  }
213
+ echo '<div class="' . $additional_class_esc . '" data-id="' . esc_html($instance['filter_id']) . '" style="'.htmlentities(br_get_value_from_array($args, 'inline_style')).'"'.htmlentities(br_get_value_from_array($args, 'additional_data_inline')).'>';
214
  }
215
  if( apply_filters('BeRocket_AAPF_widget_old_display_conditions', true, $filter_data, $instance, $args) ) {
216
  the_widget( 'BeRocket_AAPF_widget', $filter_data, $args);
227
  $filter_post = get_post($filter_id);
228
  $BeRocket_AAPF_single_filter = BeRocket_AAPF_single_filter::getInstance();
229
  $filter_data = $BeRocket_AAPF_single_filter->get_option($filter_id);
230
+ if( has_term('isdisabled', 'berocket_taxonomy_data', intval($instance['filter_id'])) ) {
231
+ return false;
232
+ }
233
  if( ! empty($filter_data['data']) && ! BeRocket_conditions::check($filter_data['data'], $BeRocket_AAPF_single_filter->hook_name) ) {
234
  return false;
235
  }
includes/widget.php CHANGED
@@ -572,6 +572,8 @@ class BeRocket_AAPF_Widget extends WP_Widget {
572
  if ( $attribute == 'price' ) {
573
  if ( ! empty($price_values) ) {
574
  $price_range = explode( ",", $price_values );
 
 
575
  } else {
576
  $price_range = br_get_cache( 'price_range', $wp_check_product_cat );
577
  if ( $price_range === false ) {
@@ -764,6 +766,9 @@ class BeRocket_AAPF_Widget extends WP_Widget {
764
  $terms = self::get_terms_child_parent ( $child_parent, $custom_taxonomy, FALSE, ( isset($child_parent_depth) ? $child_parent_depth : 0 ) );
765
  $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 );
766
  }
 
 
 
767
  if ( $order_values_by != 'Default' || in_array($custom_taxonomy, array('berocket_brand', 'product_cat')) ) {
768
  self::sort_terms( $terms, array(
769
  "order_values_by" => $order_values_by,
@@ -771,9 +776,6 @@ class BeRocket_AAPF_Widget extends WP_Widget {
771
  "order_values_type"=> (empty($order_values_type) || $order_values_type == 'asc' ? SORT_ASC : SORT_DESC)
772
  ) );
773
  }
774
- if( $custom_taxonomy == 'product_cat' ) {
775
- $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 );
776
- }
777
  if ( ! br_is_filtered() && $child_parent != 'parent' && $child_parent != 'child' ) {
778
  br_set_cache( $custom_taxonomy . $order_values_by, $terms, $filter_type . $wp_check_product_cat, BeRocket_AJAX_cache_expire );
779
  }
@@ -858,6 +860,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
858
  $set_query_var_title['widget_id'] = ( $this->id ? $this->id : $widget_id );
859
  $set_query_var_title['widget_id_number'] = ( $this->number ? $this->number : $widget_id_number );
860
  $set_query_var_title['slug_urls'] = ! empty($br_options['slug_urls']);
 
861
  set_query_var( 'berocket_query_var_title', $set_query_var_title );
862
 
863
  // widget title and start tag ( <ul> ) can be found in templates/widget_start.php
@@ -991,8 +994,8 @@ class BeRocket_AAPF_Widget extends WP_Widget {
991
  $max = count( $all_terms_name ) - 1;
992
  if( ! empty($stringed_is_numeric) ) {
993
  array_multisort( $all_terms_slug, SORT_NUMERIC, $all_terms_slug, $all_terms_name );
994
- } else {
995
- //array_multisort( $all_terms_name, $all_terms_name, $all_terms_slug );
996
  }
997
  }
998
  $widget_error_log['all_terms_slug'] = (isset($all_terms_slug) ? $all_terms_slug : null);
@@ -1240,25 +1243,35 @@ class BeRocket_AAPF_Widget extends WP_Widget {
1240
  public static function get_price_range( $wp_query_product_cat, $product_cat = null ) {
1241
  global $wpdb;
1242
 
1243
- $query[ 'select' ] = "SELECT MIN(cast(FLOOR(wp_price_check.meta_value) as decimal)) as min_price,
1244
- MAX(cast(CEIL(wp_price_check.meta_value) as decimal)) as max_price ";
1245
- $query[ 'from' ] = "FROM {$wpdb->postmeta} as wp_price_check";
1246
- $query[ 'join' ] = "INNER JOIN {$wpdb->posts} ON ({$wpdb->posts}.ID = wp_price_check.post_id)";
1247
 
 
 
 
 
 
 
 
 
 
 
 
1248
  if ( ! empty( $br_options[ 'show_all_values' ] ) ) {
1249
  $query[ 'where' ] = " WHERE {$wpdb->posts}.post_type = 'product' AND " . br_select_post_status();
1250
  } else {
1251
  $query = br_filters_query( $query, 'price', $product_cat );
1252
  }
1253
 
1254
- if ( $query[ 'where' ] ) {
1255
- $query[ 'where' ] .= "AND ";
1256
- } else {
1257
- $query[ 'where' ] = " WHERE ";
 
 
 
1258
  }
1259
 
1260
- $query[ 'where' ] .= "wp_price_check.meta_key = '".apply_filters('berocket_price_filter_meta_key', '_price', 'widget_1243')."' AND wp_price_check.meta_value > ''";
1261
-
1262
  $query_string = implode( ' ', $query );
1263
 
1264
  $query_string = $wpdb->get_row( $query_string );
@@ -1276,20 +1289,11 @@ class BeRocket_AAPF_Widget extends WP_Widget {
1276
 
1277
  public static function get_attribute_values( $taxonomy = '', $order_by = 'id', $hide_empty = false, $count_filtering = true, $input_terms = FALSE, $product_cat = FALSE, $operator = 'OR' ) {
1278
  $br_options = apply_filters( 'berocket_aapf_listener_br_options', BeRocket_AAPF::get_aapf_option() );
1279
- if( BeRocket_AAPF::$debug_mode ) {
1280
- $time = microtime(true);
1281
- if( ! isset( BeRocket_AAPF::$error_log['6_term_recount'] ) )
1282
- {
1283
- BeRocket_AAPF::$error_log['6_term_recount'] = array();
1284
- }
1285
- $term_recount_log = array();
1286
- $term_recount_log['start_time'] = $time;
1287
- }
1288
-
1289
  if ( ! $taxonomy || $taxonomy == 'price' ) return array();
1290
  if( $taxonomy == '_rating' ) $taxonomy = 'product_visibility';
 
1291
 
1292
- global $wp_query, $wpdb, $br_wc_query;
1293
 
1294
  $post__in = ( isset($wp_query->query_vars['post__in']) ? $wp_query->query_vars['post__in'] : array() );
1295
  if (
@@ -1308,1020 +1312,38 @@ if( BeRocket_AAPF::$debug_mode ) {
1308
  if( empty($post__not_in) || ! is_array($post__not_in) || count($post__not_in) == 0 ) {
1309
  $post__not_in = false;
1310
  }
1311
-
1312
- $old_join_posts = '';
1313
- $has_new_function = method_exists('WC_Query', 'get_main_query') && method_exists('WC_Query', 'get_main_meta_query') && method_exists('WC_Query', 'get_main_tax_query');
1314
- if( $has_new_function ) {
1315
- $WC_Query_get_main_query = WC_Query::get_main_query();
1316
- $has_new_function = ! empty($WC_Query_get_main_query);
1317
- }
1318
- if( ! $has_new_function ) {
1319
- $old_query_vars = self::old_wc_compatible($wp_query);
1320
- $old_meta_query = (empty( $old_query_vars[ 'meta_query' ] ) || ! is_array($old_query_vars[ 'meta_query' ]) ? array() : $old_query_vars['meta_query']);
1321
- $old_tax_query = (empty($old_query_vars['tax_query']) || ! is_array($old_query_vars[ 'tax_query' ]) ? array() : $old_query_vars['tax_query']);
1322
- } else {
1323
- $old_query_vars = self::old_wc_compatible($wp_query, true);
1324
- }
1325
-
1326
- if( ! empty( $old_query_vars['posts__in'] ) ) {
1327
- $old_join_posts = " AND {$wpdb->posts}.ID IN (".implode(',', $old_query_vars['posts__in']).") ";
1328
- }
1329
-
1330
- if( $taxonomy == '_stock_status' && ( $count_filtering || $hide_empty ) ) {
1331
- if( class_exists('WP_Meta_Query') && class_exists('WP_Tax_Query') ) {
1332
- if( $has_new_function ) {
1333
- $meta_query = WC_Query::get_main_meta_query();
1334
- } else {
1335
- $meta_query = $old_meta_query;
1336
- }
1337
- if ( 'OR' == $operator ) {
1338
- foreach( $meta_query as $key => $val ) {
1339
- if ( isset( $val['key'] ) && $val['key'] == $taxonomy ) {
1340
- if ( isset( $meta_query[ $key ] ) ) unset( $meta_query[ $key ] );
1341
- }
1342
- }
1343
- }
1344
- if( $count_filtering ) {
1345
- if( $has_new_function ) {
1346
- $tax_query = WC_Query::get_main_tax_query();
1347
- } else {
1348
- $tax_query = $old_tax_query;
1349
- }
1350
- $args = $wp_query->query_vars;
1351
- } else {
1352
- $args = $wp_query->query_vars;
1353
- $tax_query = array();
1354
- if ( ! empty( $args['product_cat'] ) ) {
1355
- $tax_query[ 'product_cat' ] = array(
1356
- 'taxonomy' => 'product_cat',
1357
- 'terms' => array( $args['product_cat'] ),
1358
- 'field' => 'slug',
1359
- );
1360
- }
1361
- foreach( $meta_query as $key => $val ) {
1362
- if( is_array($val) ) {
1363
- if ( ! empty( $val['price_filter'] ) || ! empty( $val['rating_filter'] ) ) {
1364
- unset( $meta_query[ $key ] );
1365
- }
1366
- if( isset( $val['relation']) ) {
1367
- unset($val['relation']);
1368
- foreach( $val as $key2 => $val2 ) {
1369
- if ( isset( $val2['key'] ) && $val2['key'] == apply_filters('berocket_price_filter_meta_key', '_price', 'widget_1352') ) {
1370
- if ( isset( $meta_query[ $key ][ $key2 ] ) ) unset( $meta_query[ $key ][ $key2 ] );
1371
- }
1372
- }
1373
- if( count($meta_query[ $key ]) <= 1 ) {
1374
- unset( $meta_query[ $key ] );
1375
- }
1376
- } else {
1377
- if ( isset( $val['key'] ) && $val['key'] == apply_filters('berocket_price_filter_meta_key', '_price', 'widget_1360') ) {
1378
- if ( isset( $meta_query[ $key ] ) ) unset( $meta_query[ $key ] );
1379
- }
1380
- }
1381
- }
1382
- }
1383
- }
1384
- $queried_object = $wp_query->get_queried_object_id();
1385
- if( ! empty($queried_object) ) {
1386
- $query_object = $wp_query->get_queried_object();
1387
- if( ! empty($query_object->taxonomy) && ! empty($query_object->slug) ) {
1388
- $tax_query[ $query_object->taxonomy ] = array(
1389
- 'taxonomy' => $query_object->taxonomy,
1390
- 'terms' => array( $query_object->slug ),
1391
- 'field' => 'slug',
1392
- );
1393
- }
1394
- }
1395
- $meta_query = new WP_Meta_Query( $meta_query );
1396
- $tax_query = new WP_Tax_Query( $tax_query );
1397
- $meta_query_sql = $meta_query->get_sql( 'post', $wpdb->posts, 'ID' );
1398
- $tax_query_sql = $tax_query->get_sql( $wpdb->posts, 'ID' );
1399
- $term_ids = wp_list_pluck( $input_terms, 'term_id' );
1400
-
1401
- // Generate query
1402
- $query = array();
1403
- $query['select'] = "SELECT COUNT( DISTINCT {$wpdb->posts}.ID ) as term_count, postmeta_stock.meta_value as term_count_id";
1404
- $query['from'] = "FROM {$wpdb->posts}";
1405
- $query['join'] = "
1406
- INNER JOIN {$wpdb->term_relationships} AS term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id
1407
- INNER JOIN {$wpdb->term_taxonomy} AS term_taxonomy USING( term_taxonomy_id )
1408
- INNER JOIN {$wpdb->postmeta} AS postmeta_stock ON ( {$wpdb->posts}.ID = postmeta_stock.post_id )
1409
- INNER JOIN {$wpdb->terms} AS terms USING( term_id )
1410
- " . $tax_query_sql['join'] . $meta_query_sql['join'];
1411
- $query['where'] = "
1412
- WHERE {$wpdb->posts}.post_type IN ( 'product' )
1413
- AND " . br_select_post_status() . "
1414
- " . $tax_query_sql['where'] . $meta_query_sql['where'] . "
1415
- AND postmeta_stock.meta_key = '_stock_status'
1416
- ";
1417
- if( defined( 'WCML_VERSION' ) && defined('ICL_LANGUAGE_CODE') ) {
1418
- $query['join'] = $query['join']." INNER JOIN {$wpdb->prefix}icl_translations as wpml_lang ON ( {$wpdb->posts}.ID = wpml_lang.element_id )";
1419
- $query['where'] = $query['where']." AND wpml_lang.language_code = '".ICL_LANGUAGE_CODE."' AND wpml_lang.element_type = 'post_product'";
1420
- }
1421
- br_where_search( $query );
1422
- if( ! empty($post__in) ) {
1423
- $query['where'] .= " AND {$wpdb->posts}.ID IN (\"" . implode('","', $post__in) . "\")";
1424
- }
1425
- if( ! empty($post__not_in) ) {
1426
- $query['where'] .= " AND {$wpdb->posts}.ID NOT IN (\"" . implode('","', $post__not_in) . "\")";
1427
- }
1428
- if( $count_filtering ) {
1429
- $query['where'] .= $old_join_posts;
1430
- }
1431
- $query['group_by'] = "GROUP BY postmeta_stock.meta_value";
1432
- $query = apply_filters( 'woocommerce_get_filtered_term_product_counts_query', $query );
1433
- $query = implode( ' ', $query );
1434
- if( BeRocket_AAPF::$debug_mode ) {
1435
- $term_recount_log['query_stock'] = $query;
1436
- }
1437
- $results = $wpdb->get_results( $query );
1438
- $results = wp_list_pluck( $results, 'term_count', 'term_count_id' );
1439
- foreach($input_terms as &$res_count) {
1440
- if( ! empty($results[$res_count->slug] ) ) {
1441
- $res_count->count = $results[$res_count->slug];
1442
- } else {
1443
- $res_count->count = 0;
1444
- }
1445
- }
1446
- }
1447
- if( BeRocket_AAPF::$debug_mode ) {
1448
- $term_recount_log['time_after_recount'] = microtime(true) - $time;
1449
- $term_recount_log['after_recount'] = $input_terms;
1450
- BeRocket_AAPF::$error_log['6_term_recount'][] = $term_recount_log;
1451
- }
1452
- return $input_terms;
1453
- }
1454
-
1455
- if( $taxonomy == '_sale' && ( $count_filtering || $hide_empty ) ) {
1456
- if( class_exists('WP_Meta_Query') && class_exists('WP_Tax_Query') ) {
1457
- if( $has_new_function ) {
1458
- $meta_query = WC_Query::get_main_meta_query();
1459
- } else {
1460
- $meta_query = $old_meta_query;
1461
- }
1462
- if ( 'OR' == $operator ) {
1463
- foreach( $meta_query as $key => $val ) {
1464
- if ( isset( $val['key'] ) && $val['key'] == $taxonomy ) {
1465
- if ( isset( $meta_query[ $key ] ) ) unset( $meta_query[ $key ] );
1466
- }
1467
- }
1468
- }
1469
- if( $count_filtering ) {
1470
- if( $has_new_function ) {
1471
- $tax_query = WC_Query::get_main_tax_query();
1472
- } else {
1473
- $tax_query = $old_tax_query;
1474
- }
1475
- $args = $wp_query->query_vars;
1476
- } else {
1477
- $args = $wp_query->query_vars;
1478
- $tax_query = array();
1479
- if ( ! empty( $args['product_cat'] ) ) {
1480
- $tax_query[ 'product_cat' ] = array(
1481
- 'taxonomy' => 'product_cat',
1482
- 'terms' => array( $args['product_cat'] ),
1483
- 'field' => 'slug',
1484
- );
1485
- }
1486
- foreach( $meta_query as $key => $val ) {
1487
- if( is_array($val) ) {
1488
- if ( ! empty( $val['price_filter'] ) || ! empty( $val['rating_filter'] ) ) {
1489
- unset( $meta_query[ $key ] );
1490
- }
1491
- if( isset( $val['relation']) ) {
1492
- unset($val['relation']);
1493
- foreach( $val as $key2 => $val2 ) {
1494
- if ( isset( $val2['key'] ) && $val2['key'] == apply_filters('berocket_price_filter_meta_key', '_price', 'widget_1477') ) {
1495
- if ( isset( $meta_query[ $key ][ $key2 ] ) ) unset( $meta_query[ $key ][ $key2 ] );
1496
- }
1497
- }
1498
- if( count($meta_query[ $key ]) <= 1 ) {
1499
- unset( $meta_query[ $key ] );
1500
- }
1501
- } else {
1502
- if ( isset( $val['key'] ) && $val['key'] == apply_filters('berocket_price_filter_meta_key', '_price', 'widget_1485') ) {
1503
- if ( isset( $meta_query[ $key ] ) ) unset( $meta_query[ $key ] );
1504
- }
1505
- }
1506
- }
1507
- }
1508
- }
1509
- $queried_object = $wp_query->get_queried_object_id();
1510
- if( ! empty($queried_object) ) {
1511
- $query_object = $wp_query->get_queried_object();
1512
- if( ! empty($query_object->taxonomy) && ! empty($query_object->slug) ) {
1513
- $tax_query[ $query_object->taxonomy ] = array(
1514
- 'taxonomy' => $query_object->taxonomy,
1515
- 'terms' => array( $query_object->slug ),
1516
- 'field' => 'slug',
1517
- );
1518
- }
1519
- }
1520
- $meta_query = new WP_Meta_Query( $meta_query );
1521
- $tax_query = new WP_Tax_Query( $tax_query );
1522
- $meta_query_sql = $meta_query->get_sql( 'post', $wpdb->posts, 'ID' );
1523
- $tax_query_sql = $tax_query->get_sql( $wpdb->posts, 'ID' );
1524
- $term_ids = wp_list_pluck( $input_terms, 'term_id' );
1525
-
1526
- // Generate query
1527
- $query = array();
1528
- $query['select'] = "SELECT COUNT( DISTINCT {$wpdb->posts}.ID ) as term_count";
1529
- $query['from'] = "FROM {$wpdb->posts}";
1530
- $query['join'] = "
1531
- INNER JOIN {$wpdb->term_relationships} AS term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id
1532
- INNER JOIN {$wpdb->term_taxonomy} AS term_taxonomy USING( term_taxonomy_id )
1533
- INNER JOIN {$wpdb->terms} AS terms USING( term_id )
1534
- " . $tax_query_sql['join'] . $meta_query_sql['join'];
1535
- $query['where'] = "
1536
- WHERE {$wpdb->posts}.post_type IN ( 'product' )
1537
- AND " . br_select_post_status() . "
1538
- " . $tax_query_sql['where'] . $meta_query_sql['where'] . "
1539
- ";
1540
- if( defined( 'WCML_VERSION' ) && defined('ICL_LANGUAGE_CODE') ) {
1541
- $query['join'] = $query['join']." INNER JOIN {$wpdb->prefix}icl_translations as wpml_lang ON ( {$wpdb->posts}.ID = wpml_lang.element_id )";
1542
- $query['where'] = $query['where']." AND wpml_lang.language_code = '".ICL_LANGUAGE_CODE."' AND wpml_lang.element_type = 'post_product'";
1543
- }
1544
- br_where_search( $query );
1545
- global $berocket_post_before_add_terms;
1546
- if( isset($berocket_post_before_add_terms) ) {
1547
- if( ! empty($post__in) ) {
1548
- $post__in = $berocket_post_before_add_terms;
1549
- }
1550
- if( $count_filtering ) {
1551
- if( empty($berocket_post_before_add_terms) ) {
1552
- $old_join_posts = '';
1553
- } else {
1554
- $old_join_posts = " AND {$wpdb->posts}.ID IN (".implode(',', $berocket_post_before_add_terms).") ";
1555
- }
1556
- }
1557
- }
1558
- if( $count_filtering ) {
1559
- $query['where'] .= $old_join_posts;
1560
- }
1561
- $query = apply_filters( 'woocommerce_get_filtered_term_product_counts_query', $query );
1562
- $on_sale = array_merge( array( 0 ), wc_get_product_ids_on_sale() );
1563
- $not_on_sale = $on_sale;
1564
- $query_sale = $query;
1565
- $query_not_sale = $query;
1566
- if( ! empty($post__in) ) {
1567
- $on_sale = array_intersect($on_sale, $post__in);
1568
- $query_not_sale['where'] .= " AND {$wpdb->posts}.ID IN (\"" . implode('","', $post__in) . "\")";
1569
- }
1570
- if( ! empty($post__not_in) ) {
1571
- $query_sale['where'] .= " AND {$wpdb->posts}.ID NOT IN (\"" . implode('","', $post__not_in) . "\")";
1572
- $not_on_sale = array_merge($not_on_sale, $post__not_in);
1573
- }
1574
- $query_sale['where'] .= " AND {$wpdb->posts}.ID IN (".implode(',', $on_sale).") ";
1575
- $query_not_sale['where'] .= " AND {$wpdb->posts}.ID NOT IN (".implode(',', $not_on_sale).") ";
1576
- $query_sale = implode( ' ', $query_sale );
1577
- $results = $wpdb->get_results( $query_sale );
1578
- foreach($input_terms as &$res_count) {
1579
- if( $res_count->term_id == 1 ) {
1580
- if( ! empty($results[0]->term_count ) ) {
1581
- $res_count->count = $results[0]->term_count;
1582
- } else {
1583
- $res_count->count = 0;
1584
- }
1585
- }
1586
- }
1587
- $query_not_sale = implode( ' ', $query_not_sale );
1588
- if( BeRocket_AAPF::$debug_mode ) {
1589
- $term_recount_log['query_not_sale'] = $query_not_sale;
1590
- $term_recount_log['query_sale'] = $query_sale;
1591
- }
1592
- $results = $wpdb->get_results( $query_not_sale );
1593
- foreach($input_terms as &$res_count) {
1594
- if( $res_count->term_id == 2 ) {
1595
- if( ! empty($results[0]->term_count ) ) {
1596
- $res_count->count = $results[0]->term_count;
1597
- } else {
1598
- $res_count->count = 0;
1599
- }
1600
- }
1601
- }
1602
- }
1603
- if( BeRocket_AAPF::$debug_mode ) {
1604
- $term_recount_log['time_after_recount'] = microtime(true) - $time;
1605
- $term_recount_log['after_recount'] = $input_terms;
1606
- BeRocket_AAPF::$error_log['6_term_recount'][] = $term_recount_log;
1607
- }
1608
- return $input_terms;
1609
- }
1610
-
1611
  if( $product_cat || $hide_empty) {
1612
- $cache_name = 'br2_'.$taxonomy.'_'.$order_by;
1613
-
1614
- $queried_object = $wp_query->get_queried_object_id();
1615
- if ( ! empty($queried_object) ) {
1616
- $cache_name .= '_'.$queried_object;
1617
- }
1618
-
1619
- $cache_result = br_get_cache( $cache_name, 'get_attribute_values_hide_empty' );
1620
-
1621
- if ( $cache_result === false || ! isset( $cache_result['terms'] ) || ! isset( $cache_result['term_count'] ) ) {
1622
- if ( class_exists('WP_Meta_Query') && class_exists('WP_Tax_Query') ) {
1623
- $args = array(
1624
- 'orderby' => $order_by,
1625
- 'order' => 'ASC',
1626
- 'hide_empty' => false,
1627
- );
1628
-
1629
- $woocommerce_hide_out_of_stock_items = ( BeRocket_AAPF_Widget::woocommerce_hide_out_of_stock_items() == 'no' );
1630
-
1631
- if ( $taxonomy == 'product_cat' ) {
1632
- $re = self::get_product_categories( '', 0, array(), 0, 50, true );
1633
- $re = self::set_terms_on_same_level( $re, array(), false );
1634
- } elseif ( ! isset( $input_terms ) || $input_terms === FALSE ) {
1635
- $re = get_terms( $taxonomy, $args );
1636
- if( is_a($re, 'WP_Error') ) {
1637
- trigger_error('Filter uses incorrect attribute(taxonomy). Please check that taxonomy with this slug('.$taxonomy.') exist and has values');
1638
- return array();
1639
- }
1640
- } else {
1641
- $re = $input_terms;
1642
- }
1643
-
1644
- if( $has_new_function ) {
1645
- $meta_query = WC_Query::get_main_meta_query();
1646
- } else {
1647
- $meta_query = $old_meta_query;
1648
- }
1649
-
1650
- $tax_query = array();
1651
- if( ! $woocommerce_hide_out_of_stock_items && function_exists('wc_get_product_visibility_term_ids') ) {
1652
- $product_visibility_terms = wc_get_product_visibility_term_ids();
1653
- $tax_query[] = array(
1654
- 'taxonomy' => 'product_visibility',
1655
- 'field' => 'term_taxonomy_id',
1656
- 'terms' => array($product_visibility_terms['outofstock'], (is_search() ? $product_visibility_terms['exclude-from-search'] : $product_visibility_terms['exclude-from-catalog'])),
1657
- 'operator' => 'NOT IN',
1658
- );
1659
- }
1660
- if( ! empty($product_cat) ) {
1661
- $tax_query[] = array(
1662
- 'taxonomy' => 'product_cat',
1663
- 'field' => 'slug',
1664
- 'terms' => array($product_cat),
1665
- 'operator' => 'IN',
1666
- );
1667
- }
1668
- foreach( $meta_query as $key => $val ) {
1669
- if( is_array($val) ) {
1670
- if ( ! empty( $val['price_filter'] ) || ! empty( $val['rating_filter'] ) ) {
1671
- unset( $meta_query[ $key ] );
1672
- }
1673
- if( isset( $val['relation']) ) {
1674
- unset($val['relation']);
1675
- foreach( $val as $key2 => $val2 ) {
1676
- if ( isset( $val2['key'] ) && $val2['key'] == apply_filters('berocket_price_filter_meta_key', '_price', 'widget_1658') ) {
1677
- if ( isset( $meta_query[ $key ][ $key2 ] ) ) unset( $meta_query[ $key ][ $key2 ] );
1678
- } else if( $woocommerce_hide_out_of_stock_items ) {
1679
- if ( isset( $val2['key'] ) && $val2['key'] == '_stock_status' ) {
1680
- if ( isset( $meta_query[ $key ][ $key2 ] ) ) unset( $meta_query[ $key ][ $key2 ] );
1681
- }
1682
- }
1683
- }
1684
- if( count($meta_query[ $key ]) <= 1 ) {
1685
- unset( $meta_query[ $key ] );
1686
- }
1687
- } else {
1688
- if ( isset( $val['key'] ) && $val['key'] == apply_filters('berocket_price_filter_meta_key', '_price', 'widget_1670') ) {
1689
- if ( isset( $meta_query[ $key ] ) ) unset( $meta_query[ $key ] );
1690
- } else if( $woocommerce_hide_out_of_stock_items ) {
1691
- if ( isset( $val['key'] ) && $val['key'] == '_stock_status' ) {
1692
- if ( isset( $meta_query[ $key ] ) ) unset( $meta_query[ $key ] );
1693
- }
1694
- }
1695
- }
1696
- }
1697
- }
1698
- $args = $wp_query->query_vars;
1699
- if ( ! empty( $args['product_cat'] ) ) {
1700
- $tax_query[ 'product_cat' ] = array(
1701
- 'taxonomy' => 'product_cat',
1702
- 'terms' => array( $args['product_cat'] ),
1703
- 'field' => 'slug',
1704
- );
1705
- }
1706
- $queried_object = $wp_query->get_queried_object_id();
1707
- if( ! empty($queried_object) ) {
1708
- $query_object = $wp_query->get_queried_object();
1709
- if( ! empty($query_object->taxonomy) && ! empty($query_object->slug) ) {
1710
- $tax_query[ $query_object->taxonomy ] = array(
1711
- 'taxonomy' => $query_object->taxonomy,
1712
- 'terms' => array( $query_object->slug ),
1713
- 'field' => 'slug',
1714
- );
1715
- }
1716
- }
1717
- $meta_query = new WP_Meta_Query( $meta_query );
1718
- $meta_query_sql = $meta_query->get_sql( 'post', $wpdb->posts, 'ID' );
1719
- unset($meta_query);
1720
- $tax_query = new WP_Tax_Query( $tax_query );
1721
- $tax_query_sql = $tax_query->get_sql( $wpdb->posts, 'ID' );
1722
- unset($tax_query);
1723
- if( ! empty($re) && ! is_wp_error($re) ) {
1724
- $term_ids = wp_list_pluck( $re, 'term_id' );
1725
- }
1726
- if( empty($term_ids) || ! is_array($term_ids) || ! count($term_ids) ) {
1727
- $terms = array();
1728
- $term_count = array();
1729
- } else {
1730
-
1731
- // Generate query
1732
- $query = array();
1733
- $query['select'] = "SELECT COUNT( DISTINCT {$wpdb->posts}.ID ) as term_count, GROUP_CONCAT({$wpdb->posts}.ID SEPARATOR ',') as PID, terms.term_id as term_count_id";
1734
- $query['from'] = "FROM {$wpdb->posts}";
1735
- $query['join'] = "
1736
- INNER JOIN {$wpdb->term_relationships} AS term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id
1737
- INNER JOIN {$wpdb->term_taxonomy} AS term_taxonomy USING( term_taxonomy_id )
1738
- INNER JOIN {$wpdb->terms} AS terms USING( term_id )
1739
- " . $tax_query_sql['join'] . $meta_query_sql['join'];
1740
- $query['where'] = "
1741
- WHERE {$wpdb->posts}.post_type IN ( 'product' )
1742
- AND " . br_select_post_status() . "
1743
- " . $tax_query_sql['where'] . $meta_query_sql['where'] . "
1744
- AND terms.term_id IN (" . implode( ',', array_map( 'absint', $term_ids ) ) . ")
1745
- ";
1746
-
1747
- br_where_search( $query );
1748
- if( defined( 'WCML_VERSION' ) && defined('ICL_LANGUAGE_CODE') ) {
1749
- $query['join'] = $query['join']." INNER JOIN {$wpdb->prefix}icl_translations as wpml_lang ON ( {$wpdb->posts}.ID = wpml_lang.element_id )";
1750
- $query['where'] = $query['where']." AND wpml_lang.language_code = '".ICL_LANGUAGE_CODE."' AND wpml_lang.element_type = 'post_product'";
1751
- }
1752
- $query['group_by'] = "GROUP BY terms.term_id";
1753
- $query = apply_filters( 'woocommerce_get_filtered_term_product_counts_query', $query );
1754
- $query = implode( ' ', $query );
1755
- if( BeRocket_AAPF::$debug_mode ) {
1756
- $term_recount_log['query_1'] = $query;
1757
- }
1758
- $results = $wpdb->get_results( $query );
1759
- $results_pid = wp_list_pluck( $results, 'PID', 'term_count_id' );
1760
- $results = wp_list_pluck( $results, 'term_count', 'term_count_id' );
1761
- $term_count = array();
1762
- $terms = array();
1763
- foreach($re as &$res_count) {
1764
- if( ! empty($results[$res_count->term_id] ) ) {
1765
- $res_count->count = $results[$res_count->term_id];
1766
- } elseif( $res_count->term_id != 'R__term_id__R' ) {
1767
- $res_count->count = 0;
1768
- }
1769
- if( $res_count->count > 0 ) {
1770
- $terms[] = $res_count->term_id;
1771
- $term_count[$res_count->term_id] = $res_count->count;
1772
- }
1773
- }
1774
- }
1775
-
1776
- if( $taxonomy == 'product_cat' ) {
1777
- $sort_cat = self::get_product_categories( '', 0, array(), 0, 50, true );
1778
- $assoc_re = array();
1779
- foreach($re as $term_re) {
1780
- if( empty($term_re->count) ) {
1781
- $term_re->count = 0;
1782
- }
1783
-
1784
- if ( isset( $results_pid ) and isset( $results_pid[$term_re->term_id] ) ) {
1785
- $term_re->PID = $results_pid[ $term_re->term_id ];
1786
- }
1787
-
1788
- $assoc_re[$term_re->term_id] = $term_re;
1789
- }
1790
- if ( isset( $results_pid ) && ! empty($assoc_re) ) {
1791
- self::product_cat_recount_with_child_pid( $sort_cat, $assoc_re, $new_re );
1792
- }
1793
- foreach($assoc_re as $term_id => $assoc_r) {
1794
- if( $assoc_r->count > 0 ) {
1795
- $term_count[$term_id] = $assoc_r->count;
1796
- if( ! in_array($term_id, $terms) ) {
1797
- $terms[] = $term_id;
1798
- }
1799
- }
1800
- }
1801
- }
1802
-
1803
- $cache_result = array('terms' => $terms, 'term_count' => $term_count, 'results_pid' => $results_pid);
1804
- br_set_cache ( $cache_name, $cache_result, 'get_attribute_values_hide_empty', BeRocket_AJAX_cache_expire );
1805
- } else {
1806
- $terms = array();
1807
- $q_args = $wp_query->query_vars;
1808
- $q_args['nopaging'] = true;
1809
- $q_args['post__in'] = '';
1810
- $q_args['tax_query'] = '';
1811
- $q_args['taxonomy'] = '';
1812
- $q_args['term'] = '';
1813
- $q_args['meta_query'] = '';
1814
- $q_args['attribute'] = '';
1815
- $q_args['title'] = '';
1816
- $q_args['fields'] = 'ids';
1817
- if ( $product_cat ) {
1818
- $q_args['product_cat'] = $product_cat;
1819
- }
1820
- $the_query = new WP_Query( $q_args );
1821
-
1822
- $term_count = array();
1823
- foreach ( $the_query->posts as $post_id ) {
1824
- $curent_terms = wp_get_object_terms( $post_id, $taxonomy, array( "fields" => "ids" ) );
1825
-
1826
- foreach ( $curent_terms as $t ) {
1827
- if ( ! in_array( $t, $terms ) ) {
1828
- $terms[] = $t;
1829
- }
1830
- if ( isset( $term_count[$t] ) ) {
1831
- $term_count[$t]++;
1832
- } else {
1833
- $term_count[$t] = 1;
1834
- }
1835
- }
1836
- }
1837
- $cache_result = array('terms' => $terms, 'term_count' => $term_count);
1838
- br_set_cache ( $cache_name, $cache_result, 'get_attribute_values_hide_empty', BeRocket_AJAX_cache_expire );
1839
- }
1840
- } else {
1841
- $terms = $cache_result['terms'];
1842
- $term_count = $cache_result['term_count'];
1843
- if( ! empty($cache_result['results_pid']) ) {
1844
- $results_pid = $cache_result['results_pid'];
1845
- }
1846
- }
1847
- }
1848
- if( BeRocket_AAPF::$debug_mode ) {
1849
- $term_recount_log['cache_result'] = array();
1850
- $term_recount_log['cache_result']['terms'] = (isset($terms) ? $terms : null);
1851
- $term_recount_log['cache_result']['term_count'] = (isset($term_count) ? $term_count : null);
1852
- }
1853
- if ( $hide_empty ) {
1854
-
1855
- unset( $curent_terms, $the_query );
1856
-
1857
- $args = array(
1858
- 'orderby' => $order_by,
1859
- 'order' => 'ASC',
1860
- 'hide_empty' => false,
1861
- );
1862
-
1863
- if ( $taxonomy == 'product_cat' ) {
1864
- $terms2 = self::get_product_categories( '', 0, array(), 0, 50, true );
1865
- $terms2 = self::set_terms_on_same_level( $terms2, array(), false );
1866
- } elseif ( ! isset($input_terms) || $input_terms === FALSE ) {
1867
- $terms2 = get_terms( $taxonomy, $args );
1868
- } else {
1869
- $terms2 = $input_terms;
1870
- unset( $input_terms );
1871
- }
1872
- if( $input_terms !== FALSE && is_array($input_terms) && is_array($re) ) {
1873
- $re2 = array();
1874
- $is_child = false;
1875
- foreach($re as $re_id => $re_term) {
1876
- $remove = true;
1877
- foreach($input_terms as $input_term) {
1878
- if( ! $is_child && $input_term->term_id == 'R__term_id__R' ) {
1879
- $re2[0] = $input_term;
1880
- $is_child = true;
1881
- }
1882
- if( $input_term->term_id == $re_term->term_id ) {
1883
- $remove = false;
1884
- if( $is_child ) {
1885
- $re2[$re_id] = $re_term;
1886
- }
1887
- break;
1888
- }
1889
- }
1890
- if( $remove ) {
1891
- unset($re[$re_id]);
1892
- }
1893
- }
1894
- if( $is_child ) {
1895
- $re = $re2;
1896
- }
1897
- }
1898
-
1899
- $re = array();
1900
- if( is_array($terms2) ) {
1901
- foreach ( $terms2 as $t ) {
1902
- if( isset($t->term_id) ) {
1903
- if( $t->term_id == 'R__term_id__R' ) {
1904
- $re[$t->term_id] = $t;
1905
- } elseif ( in_array( $t->term_id, $terms ) ) {
1906
- $re[$t->term_id] = $t;
1907
- $re[$t->term_id]->count = $term_count[$t->term_id];
1908
- }
1909
- }
1910
- }
1911
- }
1912
- unset( $terms2 );
1913
- } else {
1914
- $args = array(
1915
- 'orderby' => $order_by,
1916
- 'order' => 'ASC',
1917
- 'hide_empty' => false,
1918
- );
1919
- if ( $taxonomy == 'product_cat' ) {
1920
- $re = self::get_product_categories( '', 0, array(), 0, 50, true );
1921
- $re = self::set_terms_on_same_level( $re, array(), false );
1922
- } elseif ( $input_terms === FALSE ) {
1923
- $re = get_terms( $taxonomy, $args );
1924
- } else {
1925
- $re = $input_terms;
1926
- unset( $input_terms );
1927
- }
1928
- if( $product_cat ) {
1929
- foreach ( $re as $key => $t ) {
1930
- if( isset( $term_count[$re[$key]->term_id] ) ) {
1931
- $re[$key]->count = $term_count[$re[$key]->term_id];
1932
- } else {
1933
- $re[$key]->count = 0;
1934
- }
1935
- }
1936
- }
1937
- }
1938
- if( BeRocket_AAPF::$debug_mode ) {
1939
- $term_recount_log['time_before_recount'] = microtime(true) - $time;
1940
- $term_recount_log['before_recount'] = $re;
1941
- }
1942
- if( empty($re) || ! is_array($re) || count($re) == 0 ) {
1943
- if( BeRocket_AAPF::$debug_mode ) {
1944
- BeRocket_AAPF::$error_log['6_term_recount'][] = $term_recount_log;
1945
- }
1946
- return $re;
1947
- }
1948
- if( isset($input_terms) && $input_terms !== FALSE && is_array($input_terms) && is_array($re) ) {
1949
- $re2 = array();
1950
- $is_child = false;
1951
- foreach($re as $re_id => $re_term) {
1952
- $remove = true;
1953
- foreach($input_terms as $input_term) {
1954
- if( ! $is_child && $input_term->term_id == 'R__term_id__R' ) {
1955
- $re2[0] = $input_term;
1956
- $is_child = true;
1957
- }
1958
- if( $input_term->term_id == $re_term->term_id ) {
1959
- $remove = false;
1960
- if( $is_child ) {
1961
- $re2[$re_id] = $re_term;
1962
- }
1963
- break;
1964
- }
1965
- }
1966
- if( $remove ) {
1967
- unset($re[$re_id]);
1968
- }
1969
- }
1970
- if( $is_child ) {
1971
- $re = $re2;
1972
- }
1973
  }
1974
-
1975
- if ( $count_filtering ) {
1976
- if ( class_exists('WP_Meta_Query') && class_exists('WP_Tax_Query') ) {
1977
- if ( $has_new_function ) {
1978
- $tax_query = WC_Query::get_main_tax_query();
1979
- } else {
1980
- $tax_query = $old_tax_query;
1981
- }
1982
-
1983
- if ( $has_new_function ) {
1984
- $meta_query = WC_Query::get_main_meta_query();
1985
- } else {
1986
- $meta_query = $old_meta_query;
1987
- }
1988
-
1989
- if ( is_array( $tax_query ) && 'OR' == $operator ) {
1990
- foreach ( $tax_query as $key => $val ) {
1991
- if ( is_array($val) ) {
1992
- if( isset( $val['relation']) ) {
1993
- unset($val['relation']);
1994
- foreach( $val as $key2 => $val2 ) {
1995
- if ( isset( $val2['taxonomy'] ) && $val2['taxonomy'] == $taxonomy && ! empty($val2['is_berocket']) ) {
1996
- if ( isset( $tax_query[ $key ][ $key2 ] ) ) unset( $tax_query[ $key ][ $key2 ] );
1997
- }
1998
- }
1999
- if( count($tax_query[ $key ]) <= 1 ) {
2000
- unset( $tax_query[ $key ] );
2001
- }
2002
- } else {
2003
- if ( isset( $val['taxonomy'] ) && $val['taxonomy'] == $taxonomy && ! empty($val['is_berocket']) ) {
2004
- if ( isset( $tax_query[ $key ] ) ) unset( $tax_query[ $key ] );
2005
- }
2006
- }
2007
- }
2008
- }
2009
- }
2010
-
2011
- $queried_object = $wp_query->get_queried_object_id();
2012
- if ( ! empty($queried_object) ) {
2013
- $query_object = $wp_query->get_queried_object();
2014
- if ( ! empty($query_object->taxonomy) && ! empty($query_object->slug) ) {
2015
- $tax_query[ $query_object->taxonomy ] = array(
2016
- 'taxonomy' => $query_object->taxonomy,
2017
- 'terms' => array( $query_object->slug ),
2018
- 'field' => 'slug',
2019
- );
2020
- }
2021
- }
2022
- if( ! empty($product_cat) ) {
2023
- $tax_query[] = array(
2024
- 'taxonomy' => 'product_cat',
2025
- 'field' => 'slug',
2026
- 'terms' => array($product_cat),
2027
- 'operator' => 'IN',
2028
- );
2029
- }
2030
- $meta_query = new WP_Meta_Query( $meta_query );
2031
- $tax_query = new WP_Tax_Query( $tax_query );
2032
- $meta_query_sql = $meta_query->get_sql( 'post', $wpdb->posts, 'ID' );
2033
- $tax_query_sql = $tax_query->get_sql( $wpdb->posts, 'ID' );
2034
- if( ! empty($re) && count($re)) {
2035
- $term_ids = wp_list_pluck( $re, 'term_id' );
2036
-
2037
- // Generate query
2038
- $query = array();
2039
- $query['select'] = "SELECT COUNT( DISTINCT {$wpdb->posts}.ID ) as term_count, GROUP_CONCAT(DISTINCT {$wpdb->posts}.ID SEPARATOR ',') as PID, terms.term_id as term_count_id";
2040
- $query['from'] = "FROM {$wpdb->posts}";
2041
- $query['join'] = "
2042
- INNER JOIN {$wpdb->term_relationships} AS term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id
2043
- INNER JOIN {$wpdb->term_taxonomy} AS term_taxonomy USING( term_taxonomy_id )
2044
- INNER JOIN {$wpdb->terms} AS terms USING( term_id )
2045
- " . $tax_query_sql['join'] . $meta_query_sql['join'];
2046
- $query['where'] = "
2047
- WHERE {$wpdb->posts}.post_type IN ( 'product' )
2048
- AND " . br_select_post_status() . "
2049
- " . $tax_query_sql['where'] . $meta_query_sql['where'] . "
2050
- AND terms.term_id IN (" . implode( ',', array_map( 'absint', $term_ids ) ) . ")
2051
- ";
2052
- if( defined( 'WCML_VERSION' ) && defined('ICL_LANGUAGE_CODE') ) {
2053
- $query['join'] = $query['join']." INNER JOIN {$wpdb->prefix}icl_translations as wpml_lang ON ( {$wpdb->posts}.ID = wpml_lang.element_id )";
2054
- $query['where'] = $query['where']." AND wpml_lang.language_code = '".ICL_LANGUAGE_CODE."' AND wpml_lang.element_type = 'post_product'";
2055
- }
2056
- br_where_search( $query );
2057
- if( ! empty($post__in) ) {
2058
- $query['where'] .= " AND {$wpdb->posts}.ID IN (\"" . implode('","', $post__in) . "\")";
2059
- }
2060
- if( function_exists('wc_get_product_visibility_term_ids') ) {
2061
- $product_visibility_term_ids = wc_get_product_visibility_term_ids();
2062
- $query['where'] .= " AND {$wpdb->posts}.ID NOT IN (\"SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id='" . $product_visibility_term_ids['exclude-from-catalog'] . "'\")";
2063
- }
2064
-
2065
- $query['where'] .= $old_join_posts;
2066
- $query['group_by'] = "GROUP BY terms.term_id";
2067
- if( ! empty($br_options['out_of_stock_variable_reload']) ) {
2068
- $new_post_terms = berocket_isset($_POST['terms']);
2069
- $new_post_limits = berocket_isset($_POST['limits_arr']);
2070
- if( is_array($new_post_terms) && count($new_post_terms) ) {
2071
- foreach($new_post_terms as $new_post_terms_i => $new_post_term) {
2072
- if( $new_post_term[0] == $taxonomy ) {
2073
- unset($new_post_terms[$new_post_terms_i]);
2074
- }
2075
- }
2076
- }
2077
- $taxonomy_terms = get_terms( array(
2078
- 'taxonomy' => $taxonomy,
2079
- 'hide_empty' => true,
2080
- 'fields' => 'ids'
2081
- ));
2082
- $limit_post__not_in = array();
2083
- foreach($taxonomy_terms as $taxonomy_term_id) {
2084
- $new_post_limits[$taxonomy] = array($taxonomy_term_id);
2085
- $limit_post__not_in[$taxonomy_term_id] = apply_filters('berocket_add_out_of_stock_variable', array(), $new_post_terms, $new_post_limits);
2086
- }
2087
-
2088
- if( is_array($limit_post__not_in) && count($limit_post__not_in) ) {
2089
- $limit_post__not_in_where_array = array();
2090
- $limit_post__term_id_without_product = array();
2091
- foreach($limit_post__not_in as $terms_id => $limit_post) {
2092
- if( is_array($limit_post) && count($limit_post) ) {
2093
- $limit_post__not_in_where_array[$terms_id] = "({$wpdb->posts}.ID NOT IN (\"" . implode('","', $limit_post) . "\") AND terms.term_id = {$terms_id})";
2094
- } else {
2095
- $limit_post__term_id_without_product[] = $terms_id;
2096
- }
2097
- }
2098
- if( count($limit_post__term_id_without_product) ) {
2099
- $limit_post__not_in_where_array[] = "(terms.term_id IN (".implode(', ', $limit_post__term_id_without_product)."))";
2100
- }
2101
- $limit_post__not_in_where = implode(' OR ', $limit_post__not_in_where_array);
2102
- }
2103
- if( empty($br_options['out_of_stock_variable_single']) && ! empty($limit_post__not_in_where) ) {
2104
- $query['where'] .= " AND ({$limit_post__not_in_where})";
2105
- }
2106
- } else {
2107
- if( ! empty($post__not_in) ) {
2108
- $query['where'] .= " AND {$wpdb->posts}.ID NOT IN (\"" . implode('","', $post__not_in) . "\")";
2109
- }
2110
- }
2111
- $query = apply_filters( 'woocommerce_get_filtered_term_product_counts_query', $query );
2112
-
2113
- $wpdb->query( 'SET SESSION group_concat_max_len = 1000000' );
2114
- if( ! empty($br_options['out_of_stock_variable_reload']) && ! empty($br_options['out_of_stock_variable_single']) ) {
2115
- if( isset($limit_post__not_in_where_array) &&is_array($limit_post__not_in_where_array) && count($limit_post__not_in_where_array) ) {
2116
- $results = array();
2117
- $results_pid = array();
2118
- foreach($limit_post__not_in_where_array as $limit_post) {
2119
- $query_new = $query;
2120
- $query_new['where'] .= " AND ({$limit_post})";
2121
- $query_new = implode( ' ', $query_new );
2122
- $result = $wpdb->get_results( $query_new );
2123
- $results_pid_temp = wp_list_pluck( $result, 'PID', 'term_count_id' );
2124
- $results_temp = wp_list_pluck( $result, 'term_count', 'term_count_id' );
2125
- $results_pid = $results_pid + $results_pid_temp;
2126
- $results = $results + $results_temp;
2127
- unset($results_pid_temp, $results_temp, $result);
2128
- }
2129
- }
2130
- } else {
2131
- $query = implode( ' ', $query );
2132
- if( BeRocket_AAPF::$debug_mode ) {
2133
- $term_recount_log['query_2'] = $query;
2134
- }
2135
- $results = $wpdb->get_results( $query );
2136
- $results_pid = wp_list_pluck( $results, 'PID', 'term_count_id' );
2137
- $results = wp_list_pluck( $results, 'term_count', 'term_count_id' );
2138
- }
2139
-
2140
- foreach ( $re as &$res_count ) {
2141
- if ( ! empty( $results[ $res_count->term_id ] ) ) {
2142
- $res_count->count = $results[ $res_count->term_id ];
2143
- } else {
2144
- $res_count->count = 0; //this function uses to fix count of term, when count is 0 but term must be displayed
2145
- if( $hide_empty && $taxonomy != 'product_cat' ) {
2146
- unset( $re[ $res_count->term_id ] );
2147
- }
2148
- }
2149
- }
2150
- }
2151
-
2152
- } else {
2153
- $q_args = $wp_query->query_vars;
2154
- $q_args['nopaging'] = true;
2155
- if ( $product_cat ) {
2156
- $q_args['product_cat'] = $product_cat;
2157
- }
2158
- if ( isset($q_args['tax_query']) && is_array( $q_args['tax_query'] ) ) {
2159
- foreach( $q_args['tax_query'] as $key => $val ) {
2160
- if( is_array($val) ) {
2161
- if( isset( $val['relation']) ) {
2162
- unset($val['relation']);
2163
- foreach( $val as $key2 => $val2 ) {
2164
- if ( isset( $val2['taxonomy'] ) && $val2['taxonomy'] == $taxonomy ) {
2165
- if ( isset( $q_args['tax_query'][ $key ][ $key2 ] ) ) unset( $q_args['tax_query'][ $key ][ $key2 ] );
2166
- }
2167
- }
2168
- if( count($q_args['tax_query'][ $key ]) <= 1 ) {
2169
- unset( $q_args['tax_query'][ $key ] );
2170
- }
2171
- } else {
2172
- if ( isset( $val['taxonomy'] ) && $val['taxonomy'] == $taxonomy ) {
2173
- if ( isset( $q_args['tax_query'][ $key ] ) ) unset( $q_args['tax_query'][ $key ] );
2174
- }
2175
- }
2176
- }
2177
- }
2178
- }
2179
-
2180
- $q_args['taxonomy'] = '';
2181
- $q_args['term'] = '';
2182
- $q_args['attribute'] = '';
2183
- $q_args['title'] = '';
2184
- $args = apply_filters( 'berocket_aapf_listener_wp_query_args', array() );
2185
- if ( isset( $args['product_tag'] ) )
2186
- {
2187
- $q_args['product_tag'] = $args['product_tag'];
2188
- }
2189
- $q_args['fields'] = 'ids';
2190
-
2191
- if( isset($q_args['tax_query']) ) {
2192
- $tax_query_reset = $q_args['tax_query'];
2193
- unset($q_args['tax_query']);
2194
- }
2195
- $the_query = new WP_Query( $q_args );
2196
- if( isset($tax_query_reset) ) {
2197
- $the_query->set('tax_query', $tax_query_reset);
2198
- $q_args['tax_query'] = $tax_query_reset;
2199
- unset($tax_query_reset);
2200
- }
2201
- if( BeRocket_AAPF::$debug_mode ) {
2202
- $term_recount_log['count_query'] = $the_query;
2203
- $term_recount_log['inside_query'] = $wp_query;
2204
- }
2205
- $count_terms = array();
2206
-
2207
- //debug( "1---------------------" );
2208
- //debug( microtime() );
2209
- foreach ( $the_query->posts as $post ) {
2210
- $curent_terms = br_wp_get_object_terms( $post, $taxonomy, array( "fields" => "ids" ) );
2211
- foreach ( $curent_terms as $t ) {
2212
- if ( isset( $count_terms[$t] ) ) {
2213
- $count_terms[$t] += 1;
2214
- } else {
2215
- $count_terms[$t] = 1;
2216
- }
2217
- }
2218
- }
2219
- //debug( "2---------------------" );
2220
- //debug( microtime() );
2221
- if( BeRocket_AAPF::$debug_mode ) {
2222
- $term_recount_log['count'] = $count_terms;
2223
- }
2224
- unset( $the_query, $curent_terms, $q_args, $post );
2225
- if ( isset($re) && is_array( $re ) ) {
2226
- foreach ( $re as $i => $re_val ) {
2227
- $re[$i]->count = 0;
2228
- if ( isset( $count_terms[$re[$i]->term_id] ) ) {
2229
- $re[$i]->count = $count_terms[$re[$i]->term_id];
2230
- }
2231
-
2232
- $children = get_term_children( $re[$i]->term_id, $taxonomy );
2233
- $children_count = 0;
2234
- if( is_array( $children ) ) {
2235
- foreach ( $children as $child ) {
2236
- if( isset($count_terms[$child]) ) {
2237
- $children_count += $count_terms[$child];
2238
- }
2239
- }
2240
- }
2241
- $re[$i]->count += ( $children_count );
2242
- }
2243
- }
2244
- unset( $children_count, $children, $count_terms );
2245
  }
2246
  }
2247
- if( is_array($re) ) {
2248
- $re = array_values( $re );
2249
- }
2250
- if( BeRocket_AAPF::$debug_mode ) {
2251
- $term_recount_log['time_after_recount'] = microtime(true) - $time;
2252
- $term_recount_log['after_recount'] = $re;
2253
- BeRocket_AAPF::$error_log['6_term_recount'][] = $term_recount_log;
2254
- }
2255
- if( $taxonomy == 'product_cat' ) {
2256
- $sort_cat = self::get_product_categories( '', 0, array(), 0, 50, true );
2257
- $assoc_re = array();
2258
- foreach($re as $term_re) {
2259
- if( empty($term_re->count) ) {
2260
- $term_re->count = 0;
2261
- }
2262
-
2263
- if ( isset( $results_pid ) and isset( $results_pid[$term_re->term_id] ) ) {
2264
- $term_re->PID = $results_pid[ $term_re->term_id ];
2265
- }
2266
-
2267
- $assoc_re[$term_re->term_id] = $term_re;
2268
- }
2269
- if ( isset( $results_pid ) && ! empty($assoc_re) ) {
2270
- self::product_cat_recount_with_child_pid( $sort_cat, $assoc_re, $new_re );
2271
- }
2272
- $re = $assoc_re;
2273
- if ( is_array( $re ) && $hide_empty ) {
2274
- foreach ( $re as $term_id => $term_re ) {
2275
- if ( $term_re->count == 0 ) {
2276
- unset($re[$term_id]);
2277
- }
2278
- }
2279
- }
2280
- $input_terms = self::set_terms_on_same_level($input_terms);
2281
- if( $input_terms !== FALSE && is_array($input_terms) && is_array($re) ) {
2282
- $re2 = array();
2283
- $is_child = false;
2284
- foreach($re as $re_id => $re_term) {
2285
- $remove = true;
2286
- foreach($input_terms as $input_term) {
2287
- if( ! $is_child && $input_term->term_id == 'R__term_id__R' ) {
2288
- $re2[0] = $input_term;
2289
- $is_child = true;
2290
- } elseif( $input_term->term_id == $re_term->term_id ) {
2291
- $remove = false;
2292
- if( $is_child ) {
2293
- $re2[$re_id] = $re_term;
2294
- }
2295
- break;
2296
- }
2297
- }
2298
- if( $remove ) {
2299
- unset($re[$re_id]);
2300
- }
2301
- }
2302
- if( $is_child ) {
2303
- $re = $re2;
2304
- }
2305
- }
2306
- /*
2307
- if ( isset( $input_terms ) && $input_terms !== FALSE ) {
2308
- $re = $input_terms; //FIXME: kills subcategories in taxonomy->product_cat
2309
- }
2310
-
2311
- if ( is_array( $re ) ) {
2312
- foreach ( $re as $term_id => $term_re ) {
2313
- if ( isset( $assoc_re[ $term_re->term_id ] ) ) {
2314
- $re[ $term_id ] = $assoc_re[ $term_re->term_id ];
2315
- } else {
2316
- if ( $term_re->term_id != 'R__term_id__R' ) {
2317
- unset( $re[ $term_id ] );
2318
- }
2319
- }
2320
- }
2321
- }*/
2322
  }
2323
-
2324
- return $re;
2325
  }
2326
 
2327
  public static function product_cat_recount_with_child_pid( $terms, $re, &$new_re, $parent_products = array() ) {
@@ -2477,14 +1499,17 @@ if( BeRocket_AAPF::$debug_mode ) {
2477
  break;
2478
  }
2479
 
2480
- $terms2 = get_terms( $terms[0]->taxonomy, $get_terms_args );
2481
- foreach ( $terms as $term ) {
2482
- $sort_array[] = array_search($term->term_id, $terms2);
2483
- if ( ! empty($term->child) ) {
2484
- self::sort_terms( $term->child, $sort_data );
 
 
 
2485
  }
 
2486
  }
2487
- @ array_multisort( $sort_array, $sort_data['order_values_type'], SORT_NUMERIC, $terms );
2488
  }
2489
  $sort_array = self::sort_child_parent_hierarchy($terms);
2490
  @ array_multisort( $sort_array, SORT_DESC, SORT_NUMERIC, $terms );
@@ -2757,8 +1782,8 @@ if( BeRocket_AAPF::$debug_mode ) {
2757
  $terms = FALSE;
2758
  if( $attribute == '_stock_status' ) {
2759
  $terms = array();
2760
- array_push($terms, (object)array('term_id' => '1', 'name' => __('In stock', 'BeRocket_AJAX_domain'), 'slug' => 'instock', 'taxonomy' => '_stock_status', 'count' => 1));
2761
- array_push($terms, (object)array('term_id' => '2', 'name' => __('Out of stock', 'BeRocket_AJAX_domain'), 'slug' => 'outofstock', 'taxonomy' => '_stock_status', 'count' => 1));
2762
  }
2763
  $_RESPONSE['attributesname'][] = $attribute;
2764
  $terms = BeRocket_AAPF_Widget::get_attribute_values( $attribute, 'id', false, TRUE, $terms, $cat_limit );
@@ -3030,8 +2055,8 @@ if( BeRocket_AAPF::$debug_mode ) {
3030
  $terms = FALSE;
3031
  if( $attribute == '_stock_status' ) {
3032
  $terms = array();
3033
- array_push($terms, (object)array('term_id' => '1', 'name' => __('In stock', 'BeRocket_AJAX_domain'), 'slug' => 'instock', 'taxonomy' => '_stock_status', 'count' => 1));
3034
- array_push($terms, (object)array('term_id' => '2', 'name' => __('Out of stock', 'BeRocket_AJAX_domain'), 'slug' => 'outofstock', 'taxonomy' => '_stock_status', 'count' => 1));
3035
  }
3036
  $_RESPONSE['attributesname'][] = $attribute;
3037
  $terms = BeRocket_AAPF_Widget::get_attribute_values( $attribute, 'id', ( empty($br_options['show_all_values']) ), TRUE, $terms, $cat_limit );
572
  if ( $attribute == 'price' ) {
573
  if ( ! empty($price_values) ) {
574
  $price_range = explode( ",", $price_values );
575
+ } elseif( $use_min_price && $use_max_price ) {
576
+ $price_range = array($min_price, $max_price);
577
  } else {
578
  $price_range = br_get_cache( 'price_range', $wp_check_product_cat );
579
  if ( $price_range === false ) {
766
  $terms = self::get_terms_child_parent ( $child_parent, $custom_taxonomy, FALSE, ( isset($child_parent_depth) ? $child_parent_depth : 0 ) );
767
  $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 );
768
  }
769
+ if( $custom_taxonomy == 'product_cat' ) {
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,
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 );
781
  }
860
  $set_query_var_title['widget_id'] = ( $this->id ? $this->id : $widget_id );
861
  $set_query_var_title['widget_id_number'] = ( $this->number ? $this->number : $widget_id_number );
862
  $set_query_var_title['slug_urls'] = ! empty($br_options['slug_urls']);
863
+ $set_query_var_title = apply_filters('berocket_aapf_query_var_title_filter', $set_query_var_title, $instance, $br_options);
864
  set_query_var( 'berocket_query_var_title', $set_query_var_title );
865
 
866
  // widget title and start tag ( <ul> ) can be found in templates/widget_start.php
994
  $max = count( $all_terms_name ) - 1;
995
  if( ! empty($stringed_is_numeric) ) {
996
  array_multisort( $all_terms_slug, SORT_NUMERIC, $all_terms_slug, $all_terms_name );
997
+ } elseif($filter_type == 'custom_taxonomy') {
998
+ array_multisort( $all_terms_name, $all_terms_name, $all_terms_slug );
999
  }
1000
  }
1001
  $widget_error_log['all_terms_slug'] = (isset($all_terms_slug) ? $all_terms_slug : null);
1243
  public static function get_price_range( $wp_query_product_cat, $product_cat = null ) {
1244
  global $wpdb;
1245
 
1246
+ $BeRocket_AAPF = BeRocket_AAPF::getInstance();
1247
+ $br_options = $BeRocket_AAPF->get_option();
 
 
1248
 
1249
+ if( br_woocommerce_version_check('3.6') ) {
1250
+ $query[ 'select' ] = "SELECT MIN(cast(FLOOR(wc_product_meta_lookup.min_price) as decimal)) as min_price,
1251
+ MAX(cast(CEIL(wc_product_meta_lookup.max_price) as decimal)) as max_price ";
1252
+ $query[ 'from' ] = "FROM {$wpdb->posts}";
1253
+ $query[ 'join' ] = " INNER JOIN {$wpdb->wc_product_meta_lookup} as wc_product_meta_lookup ON $wpdb->posts.ID = wc_product_meta_lookup.product_id ";
1254
+ } else {
1255
+ $query[ 'select' ] = "SELECT MIN(cast(FLOOR(wp_price_check.meta_value) as decimal)) as min_price,
1256
+ MAX(cast(CEIL(wp_price_check.meta_value) as decimal)) as max_price ";
1257
+ $query[ 'from' ] = "FROM {$wpdb->postmeta} as wp_price_check";
1258
+ $query[ 'join' ] = "INNER JOIN {$wpdb->posts} ON ({$wpdb->posts}.ID = wp_price_check.post_id)";
1259
+ }
1260
  if ( ! empty( $br_options[ 'show_all_values' ] ) ) {
1261
  $query[ 'where' ] = " WHERE {$wpdb->posts}.post_type = 'product' AND " . br_select_post_status();
1262
  } else {
1263
  $query = br_filters_query( $query, 'price', $product_cat );
1264
  }
1265
 
1266
+ if( !br_woocommerce_version_check('3.6') ) {
1267
+ if ( $query[ 'where' ] ) {
1268
+ $query[ 'where' ] .= " AND ";
1269
+ } else {
1270
+ $query[ 'where' ] = " WHERE ";
1271
+ }
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 );
1289
 
1290
  public static function get_attribute_values( $taxonomy = '', $order_by = 'id', $hide_empty = false, $count_filtering = true, $input_terms = FALSE, $product_cat = FALSE, $operator = 'OR' ) {
1291
  $br_options = apply_filters( 'berocket_aapf_listener_br_options', BeRocket_AAPF::get_aapf_option() );
 
 
 
 
 
 
 
 
 
 
1292
  if ( ! $taxonomy || $taxonomy == 'price' ) return array();
1293
  if( $taxonomy == '_rating' ) $taxonomy = 'product_visibility';
1294
+ $terms = (empty($input_terms) ? FALSE : $input_terms);
1295
 
1296
+ global $wp_query, $br_wc_query, $br_aapf_wc_footer_widget;
1297
 
1298
  $post__in = ( isset($wp_query->query_vars['post__in']) ? $wp_query->query_vars['post__in'] : array() );
1299
  if (
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 (
1332
+ ( ! $hide_empty
1333
+ || apply_filters( 'berocket_aapf_is_filtered_page_check', ! empty($_GET['filters']), 'get_filter_args', $wp_query )
1334
+ || ( ! empty($br_options['out_of_stock_variable_reload']) && ! empty($br_options['out_of_stock_variable']) )
1335
+ || is_filtered()
1336
+ ) && $count_filtering
1337
+ ) {
1338
+ $terms = apply_filters('berocket_aapf_recount_terms_apply', $terms, array(
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() ) {
1499
  break;
1500
  }
1501
 
1502
+ if( count($terms) ) {
1503
+ $terms_first = reset($terms);
1504
+ $terms2 = get_terms( $terms_first->taxonomy, $get_terms_args );
1505
+ foreach ( $terms as $term ) {
1506
+ $sort_array[] = array_search($term->term_id, $terms2);
1507
+ if ( ! empty($term->child) ) {
1508
+ self::sort_terms( $term->child, $sort_data );
1509
+ }
1510
  }
1511
+ @ array_multisort( $sort_array, $sort_data['order_values_type'], SORT_NUMERIC, $terms );
1512
  }
 
1513
  }
1514
  $sort_array = self::sort_child_parent_hierarchy($terms);
1515
  @ array_multisort( $sort_array, SORT_DESC, SORT_NUMERIC, $terms );
1782
  $terms = FALSE;
1783
  if( $attribute == '_stock_status' ) {
1784
  $terms = array();
1785
+ array_push($terms, (object)array('term_id' => '1', 'term_taxonomy_id' => '1','name' => __('In stock', 'BeRocket_AJAX_domain'), 'slug' => 'instock', 'taxonomy' => '_stock_status', 'count' => 1));
1786
+ array_push($terms, (object)array('term_id' => '2', 'term_taxonomy_id' => '2', 'name' => __('Out of stock', 'BeRocket_AJAX_domain'), 'slug' => 'outofstock', 'taxonomy' => '_stock_status', 'count' => 1));
1787
  }
1788
  $_RESPONSE['attributesname'][] = $attribute;
1789
  $terms = BeRocket_AAPF_Widget::get_attribute_values( $attribute, 'id', false, TRUE, $terms, $cat_limit );
2055
  $terms = FALSE;
2056
  if( $attribute == '_stock_status' ) {
2057
  $terms = array();
2058
+ array_push($terms, (object)array('term_id' => '1', 'term_taxonomy_id' => '1','name' => __('In stock', 'BeRocket_AJAX_domain'), 'slug' => 'instock', 'taxonomy' => '_stock_status', 'count' => 1));
2059
+ array_push($terms, (object)array('term_id' => '2', 'term_taxonomy_id' => '2', 'name' => __('Out of stock', 'BeRocket_AJAX_domain'), 'slug' => 'outofstock', 'taxonomy' => '_stock_status', 'count' => 1));
2060
  }
2061
  $_RESPONSE['attributesname'][] = $attribute;
2062
  $terms = BeRocket_AAPF_Widget::get_attribute_values( $attribute, 'id', ( empty($br_options['show_all_values']) ), TRUE, $terms, $cat_limit );
includes/wizard.php CHANGED
@@ -15,31 +15,31 @@ class BeRocket_AAPF_Wizard {
15
  public static function setup_wizard_steps($steps) {
16
  $steps = array(
17
  'wizard_selectors' => array(
18
- 'name' => __( 'Selectors', 'BeRocket_domain' ),
19
  'view' => array( __CLASS__, 'wizard_selectors' ),
20
  'handler' => array( __CLASS__, 'wizard_selectors_save' ),
21
  'fa_icon' => 'fa-circle-o',
22
  ),
23
  'wizard_permalinks' => array(
24
- 'name' => __( 'URL', 'BeRocket_domain' ),
25
  'view' => array( __CLASS__, 'wizard_permalinks' ),
26
  'handler' => array( __CLASS__, 'wizard_permalinks_save' ),
27
  'fa_icon' => 'fa-link',
28
  ),
29
  'wizard_count_reload' => array(
30
- 'name' => __( 'Attribute count', 'BeRocket_domain' ),
31
  'view' => array( __CLASS__, 'wizard_count_reload' ),
32
  'handler' => array( __CLASS__, 'wizard_count_reload_save' ),
33
  'fa_icon' => 'fa-eye',
34
  ),
35
  'wizard_extra' => array(
36
- 'name' => __( 'Extra', 'BeRocket_domain' ),
37
  'view' => array( __CLASS__, 'wizard_extra' ),
38
  'handler' => array( __CLASS__, 'wizard_extra_save' ),
39
  'fa_icon' => 'fa-cogs',
40
  ),
41
  'wizard_end' => array(
42
- 'name' => __( 'Ready!', 'BeRocket_domain' ),
43
  'view' => array( __CLASS__, 'wizard_ready' ),
44
  'handler' => array( __CLASS__, 'wizard_ready_save' ),
45
  'fa_icon' => 'fa-check',
@@ -74,14 +74,26 @@ class BeRocket_AAPF_Wizard {
74
  <li><?php _e('Save settings with new selectors', 'BeRocket_AJAX_domain') ?></li>
75
  </ol>
76
  </div>
77
- <?php echo BeRocket_wizard_generate_autoselectors(array(
 
 
 
 
 
 
 
 
 
 
 
78
  'products' => '.berocket_aapf_products_selector',
79
  'pagination' => '.berocket_aapf_pagination_selector',
80
- 'result_count' => '.berocket_aapf_product_count_selector')); ?>
 
81
  </td>
82
  </tr>
83
  <tr style="display: table-row;">
84
- <th scope="row">Products Container Selector</th>
85
  <td><label>
86
  <input type="text" name="berocket_aapf_wizard_settings[products_holder_id]"
87
  value="<?php if( ! empty($option['products_holder_id']) ) echo $option['products_holder_id']; ?>"
@@ -89,7 +101,7 @@ class BeRocket_AAPF_Wizard {
89
  </label></td>
90
  </tr>
91
  <tr style="display: table-row;">
92
- <th scope="row">Pagination Selector</th>
93
  <td><label>
94
  <input type="text" name="berocket_aapf_wizard_settings[woocommerce_pagination_class]"
95
  value="<?php if( ! empty($option['woocommerce_pagination_class']) ) echo $option['woocommerce_pagination_class']; ?>"
15
  public static function setup_wizard_steps($steps) {
16
  $steps = array(
17
  'wizard_selectors' => array(
18
+ 'name' => __( 'Selectors', 'BeRocket_AJAX_domain' ),
19
  'view' => array( __CLASS__, 'wizard_selectors' ),
20
  'handler' => array( __CLASS__, 'wizard_selectors_save' ),
21
  'fa_icon' => 'fa-circle-o',
22
  ),
23
  'wizard_permalinks' => array(
24
+ 'name' => __( 'URL', 'BeRocket_AJAX_domain' ),
25
  'view' => array( __CLASS__, 'wizard_permalinks' ),
26
  'handler' => array( __CLASS__, 'wizard_permalinks_save' ),
27
  'fa_icon' => 'fa-link',
28
  ),
29
  'wizard_count_reload' => array(
30
+ 'name' => __( 'Attribute count', 'BeRocket_AJAX_domain' ),
31
  'view' => array( __CLASS__, 'wizard_count_reload' ),
32
  'handler' => array( __CLASS__, 'wizard_count_reload_save' ),
33
  'fa_icon' => 'fa-eye',
34
  ),
35
  'wizard_extra' => array(
36
+ 'name' => __( 'Extra', 'BeRocket_AJAX_domain' ),
37
  'view' => array( __CLASS__, 'wizard_extra' ),
38
  'handler' => array( __CLASS__, 'wizard_extra_save' ),
39
  'fa_icon' => 'fa-cogs',
40
  ),
41
  'wizard_end' => array(
42
+ 'name' => __( 'Ready!', 'BeRocket_AJAX_domain' ),
43
  'view' => array( __CLASS__, 'wizard_ready' ),
44
  'handler' => array( __CLASS__, 'wizard_ready_save' ),
45
  'fa_icon' => 'fa-check',
74
  <li><?php _e('Save settings with new selectors', 'BeRocket_AJAX_domain') ?></li>
75
  </ol>
76
  </div>
77
+ <?php
78
+ $output_text = array(
79
+ 'important' => __('IMPORTANT: It will generate some products on your site. Please disable all SEO plugins and plugins, that doing anything on product creating.', 'BeRocket_AJAX_domain'),
80
+ 'was_runned' => __('Script was runned, but page closed until end. Please stop it to prevent any problems on your site', 'BeRocket_AJAX_domain'),
81
+ 'run_button' => __('Auto-Selectors', 'BeRocket_AJAX_domain'),
82
+ 'was_runned_stop' => __('Stop', 'BeRocket_AJAX_domain'),
83
+ 'steps' => __('Steps:', 'BeRocket_AJAX_domain'),
84
+ 'step_create_products' => __('Creating products', 'BeRocket_AJAX_domain'),
85
+ 'step_get_selectors' => __('Gettings selectors', 'BeRocket_AJAX_domain'),
86
+ 'step_remove_product' => __('Removing products', 'BeRocket_AJAX_domain')
87
+ );
88
+ echo BeRocket_wizard_generate_autoselectors(array(
89
  'products' => '.berocket_aapf_products_selector',
90
  'pagination' => '.berocket_aapf_pagination_selector',
91
+ 'result_count' => '.berocket_aapf_product_count_selector'),
92
+ array(), $output_text); ?>
93
  </td>
94
  </tr>
95
  <tr style="display: table-row;">
96
+ <th scope="row"><?php _e('Products Container Selector', 'BeRocket_AJAX_domain'); ?></th>
97
  <td><label>
98
  <input type="text" name="berocket_aapf_wizard_settings[products_holder_id]"
99
  value="<?php if( ! empty($option['products_holder_id']) ) echo $option['products_holder_id']; ?>"
101
  </label></td>
102
  </tr>
103
  <tr style="display: table-row;">
104
+ <th scope="row"><?php _e('Pagination Selector', 'BeRocket_AJAX_domain'); ?></th>
105
  <td><label>
106
  <input type="text" name="berocket_aapf_wizard_settings[woocommerce_pagination_class]"
107
  value="<?php if( ! empty($option['woocommerce_pagination_class']) ) echo $option['woocommerce_pagination_class']; ?>"
js/admin.js CHANGED
@@ -8,13 +8,13 @@ var berocket_admin_filter_types = {
8
  filter_by:['checkbox','radio','select','color','image']
9
  };
10
  var berocket_admin_filter_types_by_attr = {
11
- checkbox:'<option value="checkbox">Checkbox</option>',
12
- radio:'<option value="radio">Radio</option>',
13
- select:'<option value="select">Select</option>',
14
- color:'<option value="color">Color</option>',
15
- image:'<option value="image">Image</option>',
16
- slider:'<option value="slider">Slider</option>',
17
- tag_cloud:'<option value="tag_cloud">Tag cloud</option>'
18
  };
19
 
20
  (function ($) {
@@ -330,6 +330,8 @@ var berocket_admin_filter_types_by_attr = {
330
  && filter_type != 'product_cat'
331
  && filter_type != 'tag' )
332
  || type != 'select' ) );
 
 
333
  if ( type == 'color' || type == 'image' ) {
334
  var tax_color_name;
335
  if ( filter_type == 'attribute' ) {
8
  filter_by:['checkbox','radio','select','color','image']
9
  };
10
  var berocket_admin_filter_types_by_attr = {
11
+ checkbox:'<option value="checkbox">'+aapf_admin_text.checkbox_text+'</option>',
12
+ radio:'<option value="radio">'+aapf_admin_text.radio_text+'</option>',
13
+ select:'<option value="select">'+aapf_admin_text.select_text+'</option>',
14
+ color:'<option value="color">'+aapf_admin_text.color_text+'</option>',
15
+ image:'<option value="image">'+aapf_admin_text.image_text+'</option>',
16
+ slider:'<option value="slider">'+aapf_admin_text.slider_text+'</option>',
17
+ tag_cloud:'<option value="tag_cloud">'+aapf_admin_text.tag_cloud_text+'</option>'
18
  };
19
 
20
  (function ($) {
330
  && filter_type != 'product_cat'
331
  && filter_type != 'tag' )
332
  || type != 'select' ) );
333
+ berocket_aapf_show_hide( $('.br_aapf_date_style_select', $parent),
334
+ ( filter_type != 'date' ) );
335
  if ( type == 'color' || type == 'image' ) {
336
  var tax_color_name;
337
  if ( filter_type == 'attribute' ) {
js/themes/the7.js CHANGED
@@ -52,3 +52,7 @@ function fixWooOrdering() {
52
  jQuery(this).customSelect();
53
  });
54
  }
 
 
 
 
52
  jQuery(this).customSelect();
53
  });
54
  }
55
+ jQuery(document).on('berocket_ajax_products_loaded berocket_lmp_end', function() {
56
+ fixWooIsotope();
57
+ fixWooOrdering();
58
+ });
js/widget.min.js CHANGED
@@ -25,16 +25,29 @@ var berocket_aapf_widget_product_filters = [],
25
  $(document).on('change', '.br_date_filter', function() {
26
  var $berocket_aapf_widget = $(this).parents('.berocket_aapf_widget');
27
  var $date_info = $berocket_aapf_widget.find('.berocket_date_picker');
28
- var value = $(this).val();
29
  value = value.replace(/\//g, '');
30
  if( $(this).is('.br_start_date')) {
31
- $date_info.data('value_1', $(this).val());
32
  $date_info.data('value1', value);
33
  } else {
34
- $date_info.data('value_2', $(this).val());
35
  $date_info.data('value2', value);
36
  }
37
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  if( $(the_ajax_script.products_holder_id).is('.wf-container') ) {
39
  berocket_replace_only_html = true;
40
  }
@@ -596,10 +609,10 @@ var berocket_aapf_widget_product_filters = [],
596
  is_product_table = true;
597
  }
598
  }
 
599
  if( is_product_table ) {
600
  $data = $(data);
601
  berocket_aapf_attribute_data.jquery = $data;
602
- $('.hide_products').removeClass('hide_products');
603
  } else {
604
  if( the_ajax_script.ajax_request_load && the_ajax_script.ajax_request_load_style == 'jquery' ) {
605
  $data = $(data);
@@ -615,7 +628,22 @@ var berocket_aapf_widget_product_filters = [],
615
  args_ajax.no_products = the_ajax_script.no_products;
616
  }
617
  } else {
618
- args_ajax.products = $data.find(the_ajax_script.products_holder_id).prop('outerHTML');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
619
  }
620
  result = afterAjaxLoad(args_ajax);
621
  berocket_aapf_attribute_data.jquery = $data;
@@ -713,6 +741,8 @@ var berocket_aapf_widget_product_filters = [],
713
  }
714
  }
715
  // call user func on_update
 
 
716
  if( the_ajax_script.user_func != null )
717
  berocket_fire( the_ajax_script.user_func.on_update );
718
 
@@ -725,28 +755,43 @@ var berocket_aapf_widget_product_filters = [],
725
  }
726
  }
727
  } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
728
  if ( typeof args.no_products != 'undefined' ) {
729
  if( berocket_child_no_products ) {
730
  args.no_products = berocket_child_no_products;
731
  }
732
- if ( $(the_ajax_script.products_holder_id).length > 0 ) {
733
- $(the_ajax_script.products_holder_id).html(args.no_products).removeClass('hide_products');
734
  } else if ( $('div.woocommerce').length > 0 ) {
735
  $('div.woocommerce').html(args.no_products);
736
  }
737
  } else {
738
  var $products = $(args.products);
739
  if ( $products.length > 0 ) {
740
- if ( $(the_ajax_script.products_holder_id).length > 0 ) {
741
  if( berocket_replace_only_html ) {
742
- $(the_ajax_script.products_holder_id).removeClass('hide_products').html($products.html());
743
- if( typeof($(the_ajax_script.products_holder_id).isotope) == 'function' ) {
744
- $(the_ajax_script.products_holder_id).isotope( 'reloadItems' );
745
- $(the_ajax_script.products_holder_id).isotope();
746
  }
747
- $(the_ajax_script.products_holder_id).find('*').filter(function() {return $(this).css('opacity') == '0';}).css('opacity', 1);
748
  } else {
749
- $(the_ajax_script.products_holder_id).replaceWith($products);
750
  }
751
  } else {
752
  if ( $('div.woocommerce').length > 0 ) {
@@ -755,14 +800,14 @@ var berocket_aapf_widget_product_filters = [],
755
  }
756
  } else {
757
  if ( $products.find(the_ajax_script.products_holder_id).length > 0 ) {
758
- if ( $(the_ajax_script.products_holder_id).length > 0 ) {
759
- $(the_ajax_script.products_holder_id).html($products.find(the_ajax_script.products_holder_id).html()).removeClass('hide_products');
760
  } else if ( $('div.woocommerce').length > 0 ) {
761
  $('div.woocommerce').html($products.find(the_ajax_script.products_holder_id).prop('outerHTML'));
762
  }
763
  } else {
764
- if ( $(the_ajax_script.products_holder_id).length > 0 ) {
765
- $(the_ajax_script.products_holder_id).html('').removeClass('hide_products');
766
  } else if ( $('div.woocommerce').length > 0 ) {
767
  $('div.woocommerce').html('');
768
  }
@@ -1647,8 +1692,8 @@ var berocket_aapf_widget_product_filters = [],
1647
  } else if ( el_type == 'slider' ) {
1648
  $slider = $('#'+el_id).closest('li').find('.berocket_filter_slider');
1649
 
1650
- val1 = parseFloat($slider.data('min'));
1651
- val2 = parseFloat($slider.data('max'));
1652
 
1653
  ui = {handle:$slider.children(), values:[val1,val2]};
1654
  $slider.slider( "values", [ val1, val2 ] ).trigger('slide', ui);
@@ -1657,8 +1702,8 @@ var berocket_aapf_widget_product_filters = [],
1657
  } else if ( el_type == '_date' ) {
1658
  $date = $('.'+el_id+'.berocket_date_picker');
1659
 
1660
- val1 = $date.data('min');
1661
- val2 = $date.data('max');
1662
 
1663
  berocket_unselect_all = true;
1664
  $('.'+el_id+'.br_start_date').val(val1).trigger('change');
@@ -2176,11 +2221,18 @@ load_hash_test();
2176
  $element = $('.berocket_single_filter_widget.berocket_inline_filters:not(".berocket_inline_filters_rewidth")').first();
2177
  width_to_set = '12.5%!important';
2178
  $style = $element.attr('style');
 
 
 
2179
  $style = $style.replace(/width:\s?(\d|\.)+%!important;/g, '');
2180
  $style = $style.replace(/clear:both!important;/g, '');
2181
  $style = $style.replace(/opacity:0!important;/g, '');
2182
  $element.attr('style', $style);
2183
  min_width = 200;
 
 
 
 
2184
  every_clear = 9;
2185
  $(document).trigger('berocket_inline_before_width_calculate');
2186
  var check_array = [];
25
  $(document).on('change', '.br_date_filter', function() {
26
  var $berocket_aapf_widget = $(this).parents('.berocket_aapf_widget');
27
  var $date_info = $berocket_aapf_widget.find('.berocket_date_picker');
28
+ var value = berocket_convert_date_to_date_picker($(this).datepicker( "getDate" ));
29
  value = value.replace(/\//g, '');
30
  if( $(this).is('.br_start_date')) {
31
+ $date_info.data('value_1', $(this).val());
32
  $date_info.data('value1', value);
33
  } else {
34
+ $date_info.data('value_2', $(this).val());
35
  $date_info.data('value2', value);
36
  }
37
  });
38
+ function berocket_convert_date_to_date_picker(date) {
39
+ var mm = date.getMonth();
40
+ mm++;
41
+ if( mm < 10 ) {
42
+ mm = '0'+mm;
43
+ }
44
+ var dd = date.getDate();
45
+ if( dd < 10 ) {
46
+ dd = '0'+dd;
47
+ }
48
+ var yy = date.getFullYear();
49
+ return mm+'/'+dd+'/'+yy;
50
+ }
51
  if( $(the_ajax_script.products_holder_id).is('.wf-container') ) {
52
  berocket_replace_only_html = true;
53
  }
609
  is_product_table = true;
610
  }
611
  }
612
+ $('.hide_products').removeClass('hide_products');
613
  if( is_product_table ) {
614
  $data = $(data);
615
  berocket_aapf_attribute_data.jquery = $data;
 
616
  } else {
617
  if( the_ajax_script.ajax_request_load && the_ajax_script.ajax_request_load_style == 'jquery' ) {
618
  $data = $(data);
628
  args_ajax.no_products = the_ajax_script.no_products;
629
  }
630
  } else {
631
+ var $block_products_holder_id;
632
+ if( $data.find(the_ajax_script.products_holder_id).length > 1 ) {
633
+ $data.find(the_ajax_script.products_holder_id).each(function () {
634
+ if( $(this).is('.berocket_aapf_true') || $(this).parents('.berocket_aapf_true').length || $(this).find('.berocket_aapf_true').length ) {
635
+ $block_products_holder_id = $(this);
636
+ return false;
637
+ }
638
+ if( typeof($block_products_holder_id) == 'undefined' && ! $(this).is('.berocket_aapf_false') && $(this).parents('.berocket_aapf_false').length && $(this).find('.berocket_aapf_false').length ) {
639
+ $block_products_holder_id = $(this);
640
+ }
641
+ });
642
+ }
643
+ if( typeof($block_products_holder_id) == 'undefined' ) {
644
+ $block_products_holder_id = $data.find(the_ajax_script.products_holder_id);
645
+ }
646
+ args_ajax.products = $block_products_holder_id.prop('outerHTML');
647
  }
648
  result = afterAjaxLoad(args_ajax);
649
  berocket_aapf_attribute_data.jquery = $data;
741
  }
742
  }
743
  // call user func on_update
744
+
745
+ $(document).trigger('berocket_ajax_filtering_on_update');
746
  if( the_ajax_script.user_func != null )
747
  berocket_fire( the_ajax_script.user_func.on_update );
748
 
755
  }
756
  }
757
  } else {
758
+ var $block_products_holder_id;
759
+ if( $(the_ajax_script.products_holder_id).length > 1 ) {
760
+ $(the_ajax_script.products_holder_id).each(function () {
761
+ if( $(this).is('.berocket_aapf_true') || $(this).parents('.berocket_aapf_true').length || $(this).find('.berocket_aapf_true').length ) {
762
+ $block_products_holder_id = $(this);
763
+ return false;
764
+ }
765
+ if( typeof($block_products_holder_id) == 'undefined' && ! $(this).is('.berocket_aapf_false') && $(this).parents('.berocket_aapf_false').length && $(this).find('.berocket_aapf_false').length ) {
766
+ $block_products_holder_id = $(this);
767
+ }
768
+ });
769
+ }
770
+ if( typeof($block_products_holder_id) == 'undefined' ) {
771
+ $block_products_holder_id = $(the_ajax_script.products_holder_id);
772
+ }
773
  if ( typeof args.no_products != 'undefined' ) {
774
  if( berocket_child_no_products ) {
775
  args.no_products = berocket_child_no_products;
776
  }
777
+ if ( $block_products_holder_id.length > 0 ) {
778
+ $block_products_holder_id.html(args.no_products);
779
  } else if ( $('div.woocommerce').length > 0 ) {
780
  $('div.woocommerce').html(args.no_products);
781
  }
782
  } else {
783
  var $products = $(args.products);
784
  if ( $products.length > 0 ) {
785
+ if ( $block_products_holder_id.length > 0 ) {
786
  if( berocket_replace_only_html ) {
787
+ $block_products_holder_id.html($products.html());
788
+ if( typeof($block_products_holder_id.isotope) == 'function' ) {
789
+ $block_products_holder_id.isotope( 'reloadItems' );
790
+ $block_products_holder_id.isotope();
791
  }
792
+ jQuery(document).trigger('berocket_aapf_time_to_fix_products_style');
793
  } else {
794
+ $block_products_holder_id.replaceWith($products);
795
  }
796
  } else {
797
  if ( $('div.woocommerce').length > 0 ) {
800
  }
801
  } else {
802
  if ( $products.find(the_ajax_script.products_holder_id).length > 0 ) {
803
+ if ( $block_products_holder_id.length > 0 ) {
804
+ $block_products_holder_id.html($products.find(the_ajax_script.products_holder_id).html());
805
  } else if ( $('div.woocommerce').length > 0 ) {
806
  $('div.woocommerce').html($products.find(the_ajax_script.products_holder_id).prop('outerHTML'));
807
  }
808
  } else {
809
+ if ( $block_products_holder_id.length > 0 ) {
810
+ $block_products_holder_id.html(the_ajax_script.no_products);
811
  } else if ( $('div.woocommerce').length > 0 ) {
812
  $('div.woocommerce').html('');
813
  }
1692
  } else if ( el_type == 'slider' ) {
1693
  $slider = $('#'+el_id).closest('li').find('.berocket_filter_slider');
1694
 
1695
+ var val1 = parseFloat($slider.data('min'));
1696
+ var val2 = parseFloat($slider.data('max'));
1697
 
1698
  ui = {handle:$slider.children(), values:[val1,val2]};
1699
  $slider.slider( "values", [ val1, val2 ] ).trigger('slide', ui);
1702
  } else if ( el_type == '_date' ) {
1703
  $date = $('.'+el_id+'.berocket_date_picker');
1704
 
1705
+ var val1 = $date.data('min');
1706
+ var val2 = $date.data('max');
1707
 
1708
  berocket_unselect_all = true;
1709
  $('.'+el_id+'.br_start_date').val(val1).trigger('change');
2221
  $element = $('.berocket_single_filter_widget.berocket_inline_filters:not(".berocket_inline_filters_rewidth")').first();
2222
  width_to_set = '12.5%!important';
2223
  $style = $element.attr('style');
2224
+ if( typeof($style) == 'undefined' ) {
2225
+ $style = '';
2226
+ }
2227
  $style = $style.replace(/width:\s?(\d|\.)+%!important;/g, '');
2228
  $style = $style.replace(/clear:both!important;/g, '');
2229
  $style = $style.replace(/opacity:0!important;/g, '');
2230
  $element.attr('style', $style);
2231
  min_width = 200;
2232
+ var min_filter_width_inline = $element.data('min_filter_width_inline');
2233
+ if( min_filter_width_inline ) {
2234
+ min_width = parseInt(min_filter_width_inline);
2235
+ }
2236
  every_clear = 9;
2237
  $(document).trigger('berocket_inline_before_width_calculate');
2238
  var check_array = [];
libraries/link_parser.php CHANGED
@@ -41,6 +41,8 @@ class BeRocket_AAPF_link_parser {
41
  add_filter('BR_AAPF_link_parser_phpp', array($this, 'php_parse'), 10, 2);
42
  add_filter('BR_AAPF_link_parser_phpg', array($this, 'php_generate'), 10, 2);
43
  add_filter('BR_AAPF_link_parser_phpr', array($this, 'php_remove'), 10, 2);
 
 
44
  }
45
  function js_parse($data, $args = array()) {
46
  if( $this->js_parse_result === false || ! empty($args['force']) ) {
@@ -144,4 +146,10 @@ class BeRocket_AAPF_link_parser {
144
  }
145
  return $term_data;
146
  }
 
 
 
 
 
 
147
  }
41
  add_filter('BR_AAPF_link_parser_phpp', array($this, 'php_parse'), 10, 2);
42
  add_filter('BR_AAPF_link_parser_phpg', array($this, 'php_generate'), 10, 2);
43
  add_filter('BR_AAPF_link_parser_phpr', array($this, 'php_remove'), 10, 2);
44
+ remove_all_filters('berocket_add_filter_to_link', 100);
45
+ add_filter('berocket_add_filter_to_link', array($this, 'add_filter_to_link'), 10, 2);
46
  }
47
  function js_parse($data, $args = array()) {
48
  if( $this->js_parse_result === false || ! empty($args['force']) ) {
146
  }
147
  return $term_data;
148
  }
149
+ function add_filter_to_link($current_url = FALSE, $args = array()) {
150
+ if( $current_url === FALSE ) {
151
+ $current_url = $this->get_query_vars_name_link();
152
+ }
153
+ return $current_url;
154
+ }
155
  }
main.php CHANGED
@@ -58,8 +58,8 @@ class BeRocket_AAPF extends BeRocket_Framework {
58
  'key' => '',
59
  'name' => '',
60
  'plugin_name' => 'ajax_filters',
61
- 'full_name' => 'WooCommerce AJAX Products Filter',
62
- 'norm_name' => 'Product Filters',
63
  'price' => '',
64
  'domain' => 'BeRocket_AJAX_domain',
65
  'templates' => AAPF_TEMPLATE_PATH,
@@ -69,7 +69,7 @@ class BeRocket_AAPF extends BeRocket_Framework {
69
  );
70
  $this->defaults = array(
71
  'plugin_key' => '',
72
- 'no_products_message' => 'There are no products meeting your criteria',
73
  'pos_relative' => '1',
74
  'no_products_class' => '',
75
  'products_holder_id' => 'ul.products',
@@ -93,7 +93,7 @@ class BeRocket_AAPF extends BeRocket_Framework {
93
  'seo_element_description' => '',
94
  'seo_meta_title_visual' => 'BeRocket_AAPF_wcseo_title_visual1',
95
  'filters_turn_off' => '',
96
- 'show_all_values' => '',
97
  'hide_value' => array(
98
  'o' => '1',
99
  'sel' => '',
@@ -109,8 +109,8 @@ class BeRocket_AAPF extends BeRocket_Framework {
109
  'selected_area_show' => '',
110
  'selected_area_hide_empty' => '',
111
  'products_only' => '1',
112
- 'out_of_stock_variable' => '1',
113
- 'out_of_stock_variable_reload' => '1',
114
  'out_of_stock_variable_single' => '',
115
  'alternative_load' => '',
116
  'alternative_load_type' => 'wpajax',
@@ -268,6 +268,11 @@ class BeRocket_AAPF extends BeRocket_Framework {
268
  add_filter( 'plugin_action_links_' . $plugin_base_slug, array( $this, 'plugin_action_links' ) );
269
  add_filter( 'berocket_aapf_widget_terms', array($this, 'wpml_attribute_slug_translate'));
270
  add_filter ( 'BeRocket_updater_menu_order_custom_post', array($this, 'menu_order_custom_post') );
 
 
 
 
 
271
  } else {
272
  if( is_plugin_active( 'woocommerce/woocommerce.php' ) || is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) {
273
  add_action( 'admin_notices', array( $this, 'update_woocommerce' ) );
@@ -359,35 +364,45 @@ class BeRocket_AAPF extends BeRocket_Framework {
359
  array(
360
  'General' => array(
361
  'icon' => 'cog',
 
362
  ),
363
  'Elements' => array(
364
  'icon' => 'bars',
 
365
  ),
366
  'Selectors' => array(
367
  'icon' => 'circle-o',
 
368
  ),
369
  'SEO' => array(
370
  'icon' => 'html5',
 
371
  ),
372
  'Advanced' => array(
373
  'icon' => 'cogs',
 
374
  ),
375
  'Design' => array(
376
  'icon' => 'eye',
 
377
  ),
378
  'JavaScript/CSS' => array(
379
  'icon' => 'css3',
 
380
  ),
381
  'Filters' => array(
382
  'icon' => 'plus-square',
383
  'link' => admin_url( 'edit.php?post_type=br_product_filter' ),
 
384
  ),
385
  'License' => array(
386
  'icon' => 'unlock-alt',
387
- 'link' => admin_url( 'admin.php?page=berocket_account' )
 
388
  ),
389
  'Addons' => array(
390
  'icon' => 'plus',
 
391
  ),
392
  ),
393
  array(
@@ -926,7 +941,22 @@ class BeRocket_AAPF extends BeRocket_Framework {
926
  return $html;
927
  }
928
  public function section_autoselector ( $item, $options ) {
929
- do_action('BeRocket_wizard_javascript');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
930
  $html = '<tr>
931
  <th scope="row">' . __('Get selectors automatically', 'BeRocket_AJAX_domain') . '</th>
932
  <td>
@@ -936,7 +966,7 @@ class BeRocket_AAPF extends BeRocket_Framework {
936
  <li>' . __('Wait until end <strong style="color:red;">do not close this page</strong>', 'BeRocket_AJAX_domain') . '</li>
937
  <li>' . __('Save settings with new selectors', 'BeRocket_AJAX_domain') . '</li>
938
  </ol>
939
- ' . BeRocket_wizard_generate_autoselectors(array('products' => '.berocket_aapf_products_selector', 'pagination' => '.berocket_aapf_pagination_selector', 'result_count' => '.berocket_aapf_product_count_selector')) . '
940
  </td>
941
  </tr>';
942
  return $html;
@@ -1179,6 +1209,19 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1179
  wp_enqueue_style( 'berocket_aapf_widget-admin-style' );
1180
  wp_register_script( 'brjsf-ui', plugins_url( 'js/brjsf.js', __FILE__ ), array( 'jquery' ), BeRocket_AJAX_filters_version );
1181
  wp_register_script( 'berocket_aapf_widget-admin', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' ), BeRocket_AJAX_filters_version, false );
 
 
 
 
 
 
 
 
 
 
 
 
 
1182
  register_setting( 'br_filters_plugin_options', 'br_filters_options', array( $this, 'sanitize_aapf_option' ) );
1183
  }
1184
  public function is_active_sidebar($is_active_sidebar, $index) {
@@ -1249,6 +1292,20 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1249
  add_filter( 'pre_get_posts', array( $this, 'apply_user_price' ) );
1250
  add_filter( 'pre_get_posts', array( $this, 'apply_user_filters' ), 900000 );
1251
  add_filter( 'woocommerce_shortcode_products_query', array( $this, 'woocommerce_shortcode_products_query' ), 10, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1252
  add_filter( 'shortcode_atts_sale_products', array($this, 'shortcode_atts_products'), 10, 3);
1253
  add_filter( 'shortcode_atts_featured_products', array($this, 'shortcode_atts_products'), 10, 3);
1254
  add_filter( 'shortcode_atts_best_selling_products', array($this, 'shortcode_atts_products'), 10, 3);
@@ -1258,8 +1315,16 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1258
  add_filter( 'shortcode_atts_products', array($this, 'shortcode_atts_products'), 10, 3);
1259
  }
1260
  function shortcode_atts_products($out, $pairs, $atts) {
1261
- if( ! empty($atts['berocket_aapf']) && $atts['berocket_aapf'] == 'true' ) {
1262
- $out['berocket_aapf'] = true;
 
 
 
 
 
 
 
 
1263
  }
1264
  return $out;
1265
  }
@@ -1298,8 +1363,8 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1298
  public function include_all_scripts() {
1299
  /* theme scripts */
1300
  if( defined('THE7_VERSION') && THE7_VERSION ) {
 
1301
  wp_enqueue_script( 'berocket_ajax_fix-the7', plugins_url( 'js/themes/the7.js', __FILE__ ), array( 'jquery' ), BeRocket_AJAX_filters_version );
1302
- add_filter('berocket_aapf_user_func', array($this, 'the7_fix'));
1303
  }
1304
  global $wp_query, $wp, $sitepress, $wp_rewrite;
1305
  $this->wp_print_special_scripts();
@@ -1359,6 +1424,8 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1359
  }
1360
 
1361
  $br_options['no_products_message'] = (empty($br_options['no_products_message']) ? __('There are no products meeting your criteria', 'BeRocket_AJAX_domain') : $br_options['no_products_message']);
 
 
1362
 
1363
  wp_localize_script(
1364
  'berocket_aapf_widget-script',
@@ -1390,7 +1457,7 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1390
  'ub_product_button_text' => '',
1391
  'berocket_aapf_widget_product_filters' => $post_temrs,
1392
  'user_func' => apply_filters( 'berocket_aapf_user_func', $user_func ),
1393
- 'default_sorting' => get_option('woocommerce_default_catalog_orderby'),
1394
  'first_page' => ( empty($br_options['first_page_jump']) ? '' : $br_options['first_page_jump'] ),
1395
  'scroll_shop_top' => ( empty($br_options['scroll_shop_top']) ? '' : $br_options['scroll_shop_top'] ),
1396
  'ajax_request_load' => ( ! empty($br_options['alternative_load']) && $br_options['alternative_load_type'] == 'wpajax' ? '' : '1' ),
@@ -1431,10 +1498,6 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1431
  ) )
1432
  );
1433
  }
1434
- public function the7_fix($scripts) {
1435
- $scripts['after_update'] = 'fixWooIsotope();fixWooOrdering(); '.$scripts['after_update'];
1436
- return $scripts;
1437
- }
1438
  public function add_error_log( $error_log ) {
1439
  $error_log[plugin_basename( __FILE__ )] = self::$error_log;
1440
  return $error_log;
@@ -1562,11 +1625,42 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1562
  return ob_get_clean();
1563
  }
1564
  public function woocommerce_shortcode_products_query( $query_vars, $atts = array(), $name = 'products' ) {
 
 
 
1565
  if( apply_filters('berocket_aapf_wcshortcode_is_filtering', ( (! is_shop() && ! is_product_taxonomy() && ! is_product_category() && ! is_product_tag()) || ! empty($atts['berocket_aapf']) ), $query_vars, $atts, $name ) ) {
1566
  $query_vars = $this->woocommerce_filter_query_vars($query_vars, $atts, $name);
1567
  }
1568
  return $query_vars;
1569
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1570
  public function woocommerce_filter_query_vars( $query_vars, $atts = array(), $name = 'products' ) {
1571
  $new_query_vars = $query_vars;
1572
  $new_query_vars['nopaging'] = true;
@@ -1628,9 +1722,14 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1628
  }
1629
  $query_vars['post__not_in'] = array_merge($query_vars['post__not_in'], apply_filters('berocket_add_out_of_stock_variable', array(), $custom_terms, berocket_isset($_POST['limits_arr'])));
1630
  $query_vars['post__in'] = apply_filters( 'loop_shop_post_in', $query_vars['post__in']);
1631
- global $br_wc_query;
 
 
 
 
1632
  $br_wc_query = $query_vars;
1633
  add_action( 'wp_footer', array( $this, 'wp_footer_widget'), 99999 );
 
1634
  $query_vars = apply_filters('berocket_filters_query_vars_already_filtered', $query_vars, berocket_isset($_POST['terms']), berocket_isset($_POST['limits_arr']));
1635
  return $query_vars;
1636
  }
@@ -1677,40 +1776,42 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1677
  if( apply_filters( 'berocket_aapf_is_filtered_page_check', ! empty($_GET['filters']), 'apply_user_filters', $query ) ) {
1678
  br_aapf_args_converter( $query );
1679
  }
1680
- if ( ( ( ! is_admin() && $is_wc_main_query ) || $is_shortcode ) && ( apply_filters( 'berocket_aapf_is_filtered_page_check', ! empty($_GET['filters']), 'apply_user_filters', $query ) )
1681
- && ( ( 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' ) ) ) {
1682
-
1683
- $args = $this->get_filter_args($query);
1684
- $args_fields = array( 'meta_key', 'tax_query', 'fields', 'where', 'join', 'meta_query', 'date_query' );
1685
- foreach ( $args_fields as $args_field ) {
1686
- if ( ! empty($args[ $args_field ]) ) {
1687
- $variable = $query->get( $args_field );
1688
- if( is_array($variable) ) {
1689
- $variable = array_merge($variable, $args[ $args_field ]);
1690
- } else {
1691
- $variable = $args[ $args_field ];
 
 
1692
  }
1693
- $query->set( $args_field, $variable );
1694
  }
1695
- }
1696
 
1697
- //THIS CAN BE NEW FIX FOR SORTING, BUT NOT SURE
1698
- if( class_exists('WC_Query') && method_exists('WC_Query', 'product_query') ) {
1699
-
1700
- if( empty($_GET['orderby']) && wc_clean( get_query_var( 'orderby' ) ) && strtolower(wc_clean( get_query_var( 'order' ) )) == 'desc' ) {
1701
- $orderby = strtolower(wc_clean( get_query_var( 'orderby' ) ));
1702
- $orderby = explode(' ', $orderby);
1703
- $orderby = $orderby[0];
1704
- if( in_array($orderby, array('date')) ) {
1705
- $_GET['orderby'] = strtolower($orderby);
1706
- } else {
1707
- $_GET['orderby'] = strtolower($orderby.'-'.wc_clean( get_query_var( 'order' ) ));
 
1708
  }
 
 
 
 
1709
  }
1710
- wc()->query->product_query($query);
1711
- }
1712
- if( self::$debug_mode ) {
1713
- self::$error_log['8_query_out'] = $query;
1714
  }
1715
  $query = apply_filters('berocket_filters_query_already_filtered', $query, berocket_isset($_POST['terms']), berocket_isset($_POST['limits_arr']));
1716
  }
@@ -1720,6 +1821,8 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1720
  $br_wc_query = $query;
1721
  }
1722
  if ( $is_shortcode ) {
 
 
1723
  add_action( 'wp_footer', array( $this, 'wp_footer_widget'), 99999 );
1724
  }
1725
 
@@ -1754,7 +1857,7 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1754
  $args['meta_query'] = $meta_query;
1755
  }
1756
  $_POST['terms'] = $old_post_terms;
1757
- if ( ! empty($_POST['price']) ) {
1758
  $min = isset( $_POST['price'][0] ) ? floatval( $_POST['price'][0] ) : 0;
1759
  $max = isset( $_POST['price'][1] ) ? floatval( $_POST['price'][1] ) : 9999999999;
1760
  if ( wc_tax_enabled() && 'incl' === get_option( 'woocommerce_tax_display_shop' ) && ! wc_prices_include_tax() ) {
@@ -2471,60 +2574,31 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
2471
  $md5 = $md5 . br_get_value_from_array($options, 'purge_cache_time');
2472
  return $md5;
2473
  }
2474
- public function fix_WC_outofstock($variation_id) {
2475
- $product = wc_get_product($variation_id);
2476
- $this->update_visibility($product, true);
2477
  }
2478
-
2479
- /**
2480
- * Update visibility terms based on props.
2481
- *
2482
- * @since 3.0.0
2483
- *
2484
- * @param WC_Product $product Product object.
2485
- * @param bool $force Force update. Used during create.
2486
- */
2487
- protected function update_visibility( &$product, $force = false ) {
2488
- $changes = $product->get_changes();
2489
-
2490
- if ( $force || array_intersect( array( 'stock_status' ), array_keys( $changes ) ) ) {
2491
- $terms = array();
2492
-
2493
- if ( 'outofstock' === $product->get_stock_status() ) {
2494
- $terms[] = 'outofstock';
2495
- }
2496
-
2497
- wp_set_post_terms( $product->get_id(), $terms, 'product_visibility', false );
2498
  }
 
2499
  }
2500
-
2501
- public function as_schedule_WC_outofstock() {
2502
- $variation_ids = wp_parse_id_list(
2503
- get_posts(
2504
- array(
2505
- 'post_type' => 'product_variation',
2506
- 'fields' => 'ids',
2507
- 'post_status' => array( 'any', 'trash', 'auto-draft' ),
2508
- 'numberposts' => -1, // phpcs:ignore WordPress.VIP.PostsPerPage.posts_per_page_numberposts
2509
- )
2510
- )
2511
- );
2512
- foreach($variation_ids as $variation_id) {
2513
- if( function_exists('as_schedule_single_action') ) {
2514
- as_schedule_single_action( time(), 'berocket_fix_WC_outofstock', array($variation_id), 'BeRocket' );
2515
- }
2516
  }
2517
  }
2518
- public function sanitize_option( $input ) {
2519
- $input = parent::sanitize_option( $input );
2520
- $option = $this->get_option();
2521
- if( br_get_value_from_array($input, 'purge_cache_time') != br_get_value_from_array($option, 'purge_cache_time') ) {
2522
- $this->as_schedule_WC_outofstock();
2523
  }
2524
- return $input;
2525
- }
2526
- public function option_page_capability($capability = '') {
2527
- return 'manage_berocket_aapf';
2528
  }
2529
  }
2530
 
58
  'key' => '',
59
  'name' => '',
60
  'plugin_name' => 'ajax_filters',
61
+ 'full_name' => __('WooCommerce AJAX Products Filter', 'BeRocket_AJAX_domain'),
62
+ 'norm_name' => __('Product Filters', 'BeRocket_AJAX_domain'),
63
  'price' => '',
64
  'domain' => 'BeRocket_AJAX_domain',
65
  'templates' => AAPF_TEMPLATE_PATH,
69
  );
70
  $this->defaults = array(
71
  'plugin_key' => '',
72
+ 'no_products_message' => __('There are no products meeting your criteria', 'BeRocket_AJAX_domain'),
73
  'pos_relative' => '1',
74
  'no_products_class' => '',
75
  'products_holder_id' => 'ul.products',
93
  'seo_element_description' => '',
94
  'seo_meta_title_visual' => 'BeRocket_AAPF_wcseo_title_visual1',
95
  'filters_turn_off' => '',
96
+ 'show_all_values' => '1',
97
  'hide_value' => array(
98
  'o' => '1',
99
  'sel' => '',
109
  'selected_area_show' => '',
110
  'selected_area_hide_empty' => '',
111
  'products_only' => '1',
112
+ 'out_of_stock_variable' => '',
113
+ 'out_of_stock_variable_reload' => '',
114
  'out_of_stock_variable_single' => '',
115
  'alternative_load' => '',
116
  'alternative_load_type' => 'wpajax',
268
  add_filter( 'plugin_action_links_' . $plugin_base_slug, array( $this, 'plugin_action_links' ) );
269
  add_filter( 'berocket_aapf_widget_terms', array($this, 'wpml_attribute_slug_translate'));
270
  add_filter ( 'BeRocket_updater_menu_order_custom_post', array($this, 'menu_order_custom_post') );
271
+ if( br_woocommerce_version_check('3.6') ) {
272
+ //TEST FUNCTIONS
273
+ add_filter( 'posts_clauses', array( $this, 'price_filter_post_clauses' ), 10, 2 );
274
+ add_filter( 'berocket_posts_clauses_recount', array( $this, 'add_price_to_post_clauses' ), 10, 1 );
275
+ }
276
  } else {
277
  if( is_plugin_active( 'woocommerce/woocommerce.php' ) || is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) {
278
  add_action( 'admin_notices', array( $this, 'update_woocommerce' ) );
364
  array(
365
  'General' => array(
366
  'icon' => 'cog',
367
+ 'name' => __( 'General', "BeRocket_AJAX_domain" )
368
  ),
369
  'Elements' => array(
370
  'icon' => 'bars',
371
+ 'name' => __( 'Elements', "BeRocket_AJAX_domain" )
372
  ),
373
  'Selectors' => array(
374
  'icon' => 'circle-o',
375
+ 'name' => __( 'Selectors', "BeRocket_AJAX_domain" )
376
  ),
377
  'SEO' => array(
378
  'icon' => 'html5',
379
+ 'name' => __( 'SEO', "BeRocket_AJAX_domain" )
380
  ),
381
  'Advanced' => array(
382
  'icon' => 'cogs',
383
+ 'name' => __( 'Advanced', "BeRocket_AJAX_domain" )
384
  ),
385
  'Design' => array(
386
  'icon' => 'eye',
387
+ 'name' => __( 'Design', "BeRocket_AJAX_domain" )
388
  ),
389
  'JavaScript/CSS' => array(
390
  'icon' => 'css3',
391
+ 'name' => __( 'JavaScript/CSS', "BeRocket_AJAX_domain" )
392
  ),
393
  'Filters' => array(
394
  'icon' => 'plus-square',
395
  'link' => admin_url( 'edit.php?post_type=br_product_filter' ),
396
+ 'name' => __( 'Filters', "BeRocket_AJAX_domain" )
397
  ),
398
  'License' => array(
399
  'icon' => 'unlock-alt',
400
+ 'link' => admin_url( 'admin.php?page=berocket_account' ),
401
+ 'name' => __( 'License', "BeRocket_AJAX_domain" )
402
  ),
403
  'Addons' => array(
404
  'icon' => 'plus',
405
+ 'name' => __( 'Addons', "BeRocket_AJAX_domain" )
406
  ),
407
  ),
408
  array(
941
  return $html;
942
  }
943
  public function section_autoselector ( $item, $options ) {
944
+ do_action('BeRocket_wizard_javascript', array(
945
+ 'creating_products' => __('Creating products', 'BeRocket_AJAX_domain'),
946
+ 'getting_selectors' => __('Gettings selectors', 'BeRocket_AJAX_domain'),
947
+ 'removing_products' => __('Removing products', 'BeRocket_AJAX_domain'),
948
+ 'error' => __('Error:', 'BeRocket_AJAX_domain')
949
+ ));
950
+ $output_text = array(
951
+ 'important' => __('IMPORTANT: It will generate some products on your site. Please disable all SEO plugins and plugins, that doing anything on product creating.', 'BeRocket_AJAX_domain'),
952
+ 'was_runned' => __('Script was runned, but page closed until end. Please stop it to prevent any problems on your site', 'BeRocket_AJAX_domain'),
953
+ 'run_button' => __('Auto-Selectors', 'BeRocket_AJAX_domain'),
954
+ 'was_runned_stop' => __('Stop', 'BeRocket_AJAX_domain'),
955
+ 'steps' => __('Steps:', 'BeRocket_AJAX_domain'),
956
+ 'step_create_products' => __('Creating products', 'BeRocket_AJAX_domain'),
957
+ 'step_get_selectors' => __('Gettings selectors', 'BeRocket_AJAX_domain'),
958
+ 'step_remove_product' => __('Removing products', 'BeRocket_AJAX_domain')
959
+ );
960
  $html = '<tr>
961
  <th scope="row">' . __('Get selectors automatically', 'BeRocket_AJAX_domain') . '</th>
962
  <td>
966
  <li>' . __('Wait until end <strong style="color:red;">do not close this page</strong>', 'BeRocket_AJAX_domain') . '</li>
967
  <li>' . __('Save settings with new selectors', 'BeRocket_AJAX_domain') . '</li>
968
  </ol>
969
+ ' . BeRocket_wizard_generate_autoselectors(array('products' => '.berocket_aapf_products_selector', 'pagination' => '.berocket_aapf_pagination_selector', 'result_count' => '.berocket_aapf_product_count_selector'), array(), $output_text) . '
970
  </td>
971
  </tr>';
972
  return $html;
1209
  wp_enqueue_style( 'berocket_aapf_widget-admin-style' );
1210
  wp_register_script( 'brjsf-ui', plugins_url( 'js/brjsf.js', __FILE__ ), array( 'jquery' ), BeRocket_AJAX_filters_version );
1211
  wp_register_script( 'berocket_aapf_widget-admin', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' ), BeRocket_AJAX_filters_version, false );
1212
+ wp_localize_script(
1213
+ 'berocket_aapf_widget-admin',
1214
+ 'aapf_admin_text',
1215
+ array(
1216
+ 'checkbox_text' => __('Checkbox', 'BeRocket_AJAX_domain'),
1217
+ 'radio_text' => __('Radio', 'BeRocket_AJAX_domain'),
1218
+ 'select_text' => __('Select', 'BeRocket_AJAX_domain'),
1219
+ 'color_text' => __('Color', 'BeRocket_AJAX_domain'),
1220
+ 'image_text' => __('Image', 'BeRocket_AJAX_domain'),
1221
+ 'slider_text' => __('Slider', 'BeRocket_AJAX_domain'),
1222
+ 'tag_cloud_text' => __('Tag cloud', 'BeRocket_AJAX_domain'),
1223
+ )
1224
+ );
1225
  register_setting( 'br_filters_plugin_options', 'br_filters_options', array( $this, 'sanitize_aapf_option' ) );
1226
  }
1227
  public function is_active_sidebar($is_active_sidebar, $index) {
1292
  add_filter( 'pre_get_posts', array( $this, 'apply_user_price' ) );
1293
  add_filter( 'pre_get_posts', array( $this, 'apply_user_filters' ), 900000 );
1294
  add_filter( 'woocommerce_shortcode_products_query', array( $this, 'woocommerce_shortcode_products_query' ), 10, 3 );
1295
+ $shortcode_types = array(
1296
+ 'products',
1297
+ 'product',
1298
+ 'sale_products',
1299
+ 'recent_products',
1300
+ 'best_selling_products',
1301
+ 'top_rated_products',
1302
+ 'featured_products',
1303
+ 'product_attribute',
1304
+ 'product_category',
1305
+ );
1306
+ foreach($shortcode_types as $shortcode_type) {
1307
+ add_action( "woocommerce_shortcode_{$shortcode_type}_loop_no_results", array( $this, 'woocommerce_shortcode_no_result' ), 10, 1 );
1308
+ }
1309
  add_filter( 'shortcode_atts_sale_products', array($this, 'shortcode_atts_products'), 10, 3);
1310
  add_filter( 'shortcode_atts_featured_products', array($this, 'shortcode_atts_products'), 10, 3);
1311
  add_filter( 'shortcode_atts_best_selling_products', array($this, 'shortcode_atts_products'), 10, 3);
1315
  add_filter( 'shortcode_atts_products', array($this, 'shortcode_atts_products'), 10, 3);
1316
  }
1317
  function shortcode_atts_products($out, $pairs, $atts) {
1318
+ if( ! empty($atts['berocket_aapf']) ) {
1319
+ if( $atts['berocket_aapf'] == 'false' || $atts['berocket_aapf'] == '0' ) {
1320
+ $out['berocket_aapf'] = false;
1321
+ $out['class'] = (empty($out['class']) ? '' : $out['class'] . ' ') . 'berocket_aapf_false';
1322
+ }
1323
+ if( $atts['berocket_aapf'] == 'true' || $atts['berocket_aapf'] == '1' ) {
1324
+ $out['cache'] = false;
1325
+ $out['berocket_aapf'] = true;
1326
+ $out['class'] = (empty($out['class']) ? '' : $out['class'] . ' ') . 'berocket_aapf_true';
1327
+ }
1328
  }
1329
  return $out;
1330
  }
1363
  public function include_all_scripts() {
1364
  /* theme scripts */
1365
  if( defined('THE7_VERSION') && THE7_VERSION ) {
1366
+ add_filter('berocket_aapf_time_to_fix_products_style', '__return_false');
1367
  wp_enqueue_script( 'berocket_ajax_fix-the7', plugins_url( 'js/themes/the7.js', __FILE__ ), array( 'jquery' ), BeRocket_AJAX_filters_version );
 
1368
  }
1369
  global $wp_query, $wp, $sitepress, $wp_rewrite;
1370
  $this->wp_print_special_scripts();
1424
  }
1425
 
1426
  $br_options['no_products_message'] = (empty($br_options['no_products_message']) ? __('There are no products meeting your criteria', 'BeRocket_AJAX_domain') : $br_options['no_products_message']);
1427
+ $default_sorting = get_option('woocommerce_default_catalog_orderby');
1428
+ $default_sorting = (empty($default_sorting) ? "menu_order" : $default_sorting);
1429
 
1430
  wp_localize_script(
1431
  'berocket_aapf_widget-script',
1457
  'ub_product_button_text' => '',
1458
  'berocket_aapf_widget_product_filters' => $post_temrs,
1459
  'user_func' => apply_filters( 'berocket_aapf_user_func', $user_func ),
1460
+ 'default_sorting' => $default_sorting,
1461
  'first_page' => ( empty($br_options['first_page_jump']) ? '' : $br_options['first_page_jump'] ),
1462
  'scroll_shop_top' => ( empty($br_options['scroll_shop_top']) ? '' : $br_options['scroll_shop_top'] ),
1463
  'ajax_request_load' => ( ! empty($br_options['alternative_load']) && $br_options['alternative_load_type'] == 'wpajax' ? '' : '1' ),
1498
  ) )
1499
  );
1500
  }
 
 
 
 
1501
  public function add_error_log( $error_log ) {
1502
  $error_log[plugin_basename( __FILE__ )] = self::$error_log;
1503
  return $error_log;
1625
  return ob_get_clean();
1626
  }
1627
  public function woocommerce_shortcode_products_query( $query_vars, $atts = array(), $name = 'products' ) {
1628
+ if( isset($atts['berocket_aapf']) && $atts['berocket_aapf'] === false ) {
1629
+ return $query_vars;
1630
+ }
1631
  if( apply_filters('berocket_aapf_wcshortcode_is_filtering', ( (! is_shop() && ! is_product_taxonomy() && ! is_product_category() && ! is_product_tag()) || ! empty($atts['berocket_aapf']) ), $query_vars, $atts, $name ) ) {
1632
  $query_vars = $this->woocommerce_filter_query_vars($query_vars, $atts, $name);
1633
  }
1634
  return $query_vars;
1635
  }
1636
+ public function woocommerce_shortcode_no_result($atts) {
1637
+ if( ! empty($atts['berocket_aapf']) ) {
1638
+ wc_no_products_found();
1639
+ }
1640
+ }
1641
+ public function price_filter_post_clauses( $args, $wp_query ) {
1642
+ if( empty($wp_query->query_vars['berocket_filtered']) ) {
1643
+ return $args;
1644
+ }
1645
+ return $this->add_price_to_post_clauses($args);
1646
+ }
1647
+ public function add_price_to_post_clauses($args) {
1648
+ if( ! empty($_POST['price']) ) {
1649
+ global $wpdb;
1650
+
1651
+ if ( ! strstr( $args['join'], 'wc_product_meta_lookup' ) ) {
1652
+ $args['join'] .= " LEFT JOIN {$wpdb->wc_product_meta_lookup} as wc_product_meta_lookup ON {$wpdb->posts}.ID = wc_product_meta_lookup.product_id ";
1653
+ }
1654
+ $min = isset( $_POST['price'][0] ) ? floatval( $_POST['price'][0] ) : 0;
1655
+ $max = isset( $_POST['price'][1] ) ? floatval( $_POST['price'][1] ) : 9999999999;
1656
+ $args['where'] .= $wpdb->prepare(
1657
+ ' AND wc_product_meta_lookup.min_price >= %f AND wc_product_meta_lookup.max_price <= %f ',
1658
+ $min,
1659
+ $max
1660
+ );
1661
+ }
1662
+ return $args;
1663
+ }
1664
  public function woocommerce_filter_query_vars( $query_vars, $atts = array(), $name = 'products' ) {
1665
  $new_query_vars = $query_vars;
1666
  $new_query_vars['nopaging'] = true;
1722
  }
1723
  $query_vars['post__not_in'] = array_merge($query_vars['post__not_in'], apply_filters('berocket_add_out_of_stock_variable', array(), $custom_terms, berocket_isset($_POST['limits_arr'])));
1724
  $query_vars['post__in'] = apply_filters( 'loop_shop_post_in', $query_vars['post__in']);
1725
+ if ( br_woocommerce_version_check('3.6') && ! empty($_POST['price']) ) {
1726
+ $query_vars['berocket_price'] = $_POST['price'];
1727
+ }
1728
+ $query_vars['berocket_filtered'] = true;
1729
+ global $br_wc_query, $br_aapf_wc_footer_widget;
1730
  $br_wc_query = $query_vars;
1731
  add_action( 'wp_footer', array( $this, 'wp_footer_widget'), 99999 );
1732
+ $br_aapf_wc_footer_widget = true;
1733
  $query_vars = apply_filters('berocket_filters_query_vars_already_filtered', $query_vars, berocket_isset($_POST['terms']), berocket_isset($_POST['limits_arr']));
1734
  return $query_vars;
1735
  }
1776
  if( apply_filters( 'berocket_aapf_is_filtered_page_check', ! empty($_GET['filters']), 'apply_user_filters', $query ) ) {
1777
  br_aapf_args_converter( $query );
1778
  }
1779
+ if ( ( ( ! is_admin() && $is_wc_main_query ) || $is_shortcode ) ) {
1780
+ if( ( apply_filters( 'berocket_aapf_is_filtered_page_check', ! empty($_GET['filters']), 'apply_user_filters', $query ) )
1781
+ && ( ( 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' ) ) ) {
1782
+ $args = $this->get_filter_args($query);
1783
+ $args_fields = array( 'meta_key', 'tax_query', 'fields', 'where', 'join', 'meta_query', 'date_query' );
1784
+ foreach ( $args_fields as $args_field ) {
1785
+ if ( ! empty($args[ $args_field ]) ) {
1786
+ $variable = $query->get( $args_field );
1787
+ if( is_array($variable) ) {
1788
+ $variable = array_merge($variable, $args[ $args_field ]);
1789
+ } else {
1790
+ $variable = $args[ $args_field ];
1791
+ }
1792
+ $query->set( $args_field, $variable );
1793
  }
 
1794
  }
1795
+ $query->set('berocket_filtered', true);
1796
 
1797
+ //THIS CAN BE NEW FIX FOR SORTING, BUT NOT SURE
1798
+ if( class_exists('WC_Query') && method_exists('WC_Query', 'product_query') ) {
1799
+
1800
+ if( empty($_GET['orderby']) && wc_clean( get_query_var( 'orderby' ) ) && strtolower(wc_clean( get_query_var( 'order' ) )) == 'desc' ) {
1801
+ $orderby = strtolower(wc_clean( get_query_var( 'orderby' ) ));
1802
+ $orderby = explode(' ', $orderby);
1803
+ $orderby = $orderby[0];
1804
+ if( in_array($orderby, array('date')) ) {
1805
+ $_GET['orderby'] = strtolower($orderby);
1806
+ } else {
1807
+ $_GET['orderby'] = strtolower($orderby.'-'.wc_clean( get_query_var( 'order' ) ));
1808
+ }
1809
  }
1810
+ wc()->query->product_query($query);
1811
+ }
1812
+ if( self::$debug_mode ) {
1813
+ self::$error_log['8_query_out'] = $query;
1814
  }
 
 
 
 
1815
  }
1816
  $query = apply_filters('berocket_filters_query_already_filtered', $query, berocket_isset($_POST['terms']), berocket_isset($_POST['limits_arr']));
1817
  }
1821
  $br_wc_query = $query;
1822
  }
1823
  if ( $is_shortcode ) {
1824
+ global $br_aapf_wc_footer_widget;
1825
+ $br_aapf_wc_footer_widget = true;
1826
  add_action( 'wp_footer', array( $this, 'wp_footer_widget'), 99999 );
1827
  }
1828
 
1857
  $args['meta_query'] = $meta_query;
1858
  }
1859
  $_POST['terms'] = $old_post_terms;
1860
+ if ( ! br_woocommerce_version_check('3.6') && ! empty($_POST['price']) ) {
1861
  $min = isset( $_POST['price'][0] ) ? floatval( $_POST['price'][0] ) : 0;
1862
  $max = isset( $_POST['price'][1] ) ? floatval( $_POST['price'][1] ) : 9999999999;
1863
  if ( wc_tax_enabled() && 'incl' === get_option( 'woocommerce_tax_display_shop' ) && ! wc_prices_include_tax() ) {
2574
  $md5 = $md5 . br_get_value_from_array($options, 'purge_cache_time');
2575
  return $md5;
2576
  }
2577
+ public function option_page_capability($capability = '') {
2578
+ return 'manage_berocket_aapf';
 
2579
  }
2580
+ public function set_scripts() {
2581
+ if( apply_filters('berocket_aapf_time_to_fix_products_style', true) ) {
2582
+ echo '<script>
2583
+ jQuery(document).on("berocket_aapf_time_to_fix_products_style", function() {
2584
+ jQuery(the_ajax_script.products_holder_id).find("*").filter(function() {return jQuery(this).css("opacity") == "0";}).css("opacity", 1);
2585
+ });
2586
+ </script>';
 
 
 
 
 
 
 
 
 
 
 
 
 
2587
  }
2588
+ parent::set_scripts();
2589
  }
2590
+ public function update_version($previous, $current) {
2591
+ if( $previous === '0' ) {
2592
+ update_option('berocket_filter_open_wizard_on_settings', true);
 
 
 
 
 
 
 
 
 
 
 
 
 
2593
  }
2594
  }
2595
+ public function save_settings_callback( $settings ) {
2596
+ $options = $this->get_option();
2597
+ if ( $options['nice_urls'] != $settings['nice_urls'] ) {
2598
+ delete_option( 'rewrite_rules' );
 
2599
  }
2600
+
2601
+ return parent::save_settings_callback( $settings );
 
 
2602
  }
2603
  }
2604
 
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === Advanced AJAX Product Filters ===
2
  Plugin Name: Advanced AJAX Product Filters
3
  Contributors: dholovnia, berocket
4
- Donate link: http://berocket.com/product/woocommerce-ajax-products-filter
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.1
8
- Stable tag: 1.3.2.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -69,11 +69,11 @@ WooCommerce AJAX Product Filters - Advanced product filtering ability for your W
69
 
70
  = Plugin Links: =
71
  [Paid Plugin](https://berocket.com/l/filters-upgrade/?utm_source=wordpress_org&utm_medium=plugin_links&utm_campaign=ajax_filters)
72
- [Demo](http://woocommerce-products-filter.berocket.com/shop/)
73
- [Demo Description](http://woocommerce-products-filter.berocket.com/)
74
 
75
  = &#127852; Wanna try admin side? =
76
- [Admin Demo](http://berocket.com/product/woocommerce-ajax-products-filter#try-admin) - Get access to this plugin's admin and try it from inside. Change things and watch how they work.
77
 
78
  = Premium plugin video =
79
  [youtube https://youtu.be/8gaMj-IxUj0]
@@ -92,9 +92,6 @@ Advanced AJAX Product Filters has been tested and compatibility is certain with
92
  &#128312; [**Products Compare for WooCommerce**](https://wordpress.org/plugins/products-compare-for-woocommerce/)
93
  &#128312; [**Wishlist and Waitlist for WooCommerce**](https://wordpress.org/plugins/wish-wait-list-for-woocommerce/)
94
 
95
- Nevertheless, it could be compatible with many other WooCommerce plugins that have not been tested yet. If you want to inform us about compatibility with other plugins, please, [email to us](http://berocket.com/contact).
96
-
97
-
98
  = Shortcode: =
99
  * In editor `[br_filters attribute=price type=slider title="Price Filter"]`
100
  * In PHP `do_shortcode('[br_filters attribute=price type=slider title="Price Filter"]');`
@@ -174,7 +171,7 @@ You can get more features with the premium version of Advanced AJAX Product Filt
174
 
175
 
176
  = How can I try the full-featured plugin? =
177
- You can try this plugin's admin side [here](http://berocket.com/product/woocommerce-ajax-products-filter#try-admin). Configure plugin the way you need to check the results.
178
 
179
  ---
180
 
@@ -187,6 +184,39 @@ You can try this plugin's admin side [here](http://berocket.com/product/woocomme
187
 
188
  == Changelog ==
189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  = 1.3.2.6 =
191
  * Fix - Values Order - Default/Numeric, Order Type was not working with multigobyte values
192
  * Fix - PHP notices/errors
1
  === Advanced AJAX Product Filters ===
2
  Plugin Name: Advanced AJAX Product Filters
3
  Contributors: dholovnia, berocket
4
+ Donate link: https://berocket.com/product/woocommerce-ajax-products-filter?utm_source=wordpress_org&utm_medium=donate&utm_campaign=ajax_filters
5
  Tags: filters, product filters, ajax product filters, ajax filter, ajax filter widget, color filter, size filter, product onsale filter, product preview, product category filter, product reset filter, product sort by filter, stock filter, product tag filter, price range filter, price box filter, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce products filter, woocommerce ajax product filters, widget, plugin, woocommerce item filters, filters plugin, ajax filters plugin, filter woocommerce products, filter woocommerce products plugin, wc filters, wc filters products, wc products filters, wc ajax products filters, wc product filters, wc advanced product filters, woocommerce layered nav, woocommerce layered navigation, ajax filtered nav, ajax filtered navigation, price filter, ajax price filter, woocommerce product sorting, sidebar filter, sidebar ajax filter, taxonomy filter, category filter, attribute filter, attributes filter, woocommerce product sort, ajax products filter plugin for woocommerce, rocket, berocket, berocket woocommerce ajax products filter
6
  Requires at least: 4.0
7
+ Tested up to: 5.2.3
8
+ Stable tag: 1.3.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
69
 
70
  = Plugin Links: =
71
  [Paid Plugin](https://berocket.com/l/filters-upgrade/?utm_source=wordpress_org&utm_medium=plugin_links&utm_campaign=ajax_filters)
72
+ [Demo](https://woocommerce-products-filter.berocket.com/shop/?utm_source=wordpress_org&utm_medium=plugin_links&utm_campaign=ajax_filters)
73
+ [Demo Description](https://woocommerce-products-filter.berocket.com/?utm_source=wordpress_org&utm_medium=plugin_links&utm_campaign=ajax_filters)
74
 
75
  = &#127852; Wanna try admin side? =
76
+ [Admin Demo](https://berocket.com/product/woocommerce-ajax-products-filter?utm_source=wordpress_org&utm_medium=admin_demo&utm_campaign=ajax_filters#try-admin) - Get access to this plugin's admin and try it from inside. Change things and watch how they work.
77
 
78
  = Premium plugin video =
79
  [youtube https://youtu.be/8gaMj-IxUj0]
92
  &#128312; [**Products Compare for WooCommerce**](https://wordpress.org/plugins/products-compare-for-woocommerce/)
93
  &#128312; [**Wishlist and Waitlist for WooCommerce**](https://wordpress.org/plugins/wish-wait-list-for-woocommerce/)
94
 
 
 
 
95
  = Shortcode: =
96
  * In editor `[br_filters attribute=price type=slider title="Price Filter"]`
97
  * In PHP `do_shortcode('[br_filters attribute=price type=slider title="Price Filter"]');`
171
 
172
 
173
  = How can I try the full-featured plugin? =
174
+ You can try this plugin's admin side [here](https://berocket.com/product/woocommerce-ajax-products-filter?utm_source=wordpress_org&utm_medium=faq&utm_campaign=ajax_filters#try-admin). Configure plugin the way you need to check the results.
175
 
176
  ---
177
 
184
 
185
  == Changelog ==
186
 
187
+ = 1.3.4 =
188
+ * Enhancement - More correct filters recount
189
+ * Enhancement - More elemnts for translation
190
+ * Fix - Order by element always displayed
191
+ * Fix - Rewrite rules override every load
192
+ * Fix - Some filters products count
193
+
194
+ = 1.3.3.2 =
195
+ * Fix - Attribute value recount on attribute and taxonomy pages
196
+
197
+ = 1.3.3.1 =
198
+ * Fix - WooCommerce Shortcode with multiple categories
199
+ * Fix - Incorrect recount terms on some sites
200
+
201
+ = 1.3.3 =
202
+ * Enhancement - Filtering speed optimization
203
+ * Enhancement - Multiple WooCommerce shortcode can work correct
204
+ * Enhancement - Database query optimization and less query count
205
+
206
+ = 1.3.2.8 =
207
+ * Enhancement - Price slider speed woocommerce 3.6
208
+ * Enhancement - WooCommerce shortcode add no products message
209
+ * Fix - PHP notices
210
+ * Fix - Remove some files
211
+
212
+ = 1.3.2.7 =
213
+ * Fix - Links to BeRocket
214
+ * Fix - Compatibility with other BeRocket plugins
215
+ * Fix - Categories default sorting is not working
216
+ * Fix - Remove some php notices
217
+ * Fix - Reset in above products position break other filters
218
+ * Fix - Tax rates option for price
219
+
220
  = 1.3.2.6 =
221
  * Fix - Values Order - Default/Numeric, Order Type was not working with multigobyte values
222
  * Fix - PHP notices/errors
templates/filter_condition.php DELETED
@@ -1,293 +0,0 @@
1
- <?php
2
- echo '<div class="submitbox" id="submitpost">';
3
- $product_categories = get_terms( 'product_cat' );
4
- $condition_types = array(
5
- 'page' => __('Page', 'BeRocket_products_label_domain'),
6
- 'attribute' => __('Product Attribute', 'BeRocket_products_label_domain'),
7
- 'search' => __('Search', 'BeRocket_products_label_domain'),
8
- );
9
- if( is_array($product_categories) && count($product_categories) > 0 ) {
10
- $condition_types['category'] = __('Product category', 'BeRocket_products_label_domain');
11
- }
12
- $condition_types = apply_filters('berocket_filters_condition_types', $condition_types);
13
- ?>
14
- <div class="">
15
- <div class="br_filter_group_example" style="display:none;">
16
- <div class="br_cond_select" data-current="1">
17
- <span>
18
- <select class="br_cond_type">
19
- <?php
20
- foreach($condition_types as $condition_type_slug => $condition_type_name) {
21
- echo '<option value="', $condition_type_slug, '">', $condition_type_name, '</option>';
22
- }
23
- ?>
24
- </select>
25
- </span>
26
- <span class="button berocket_remove_condition"><i class="fa fa-minus"></i></span>
27
- <div class="br_current_cond">
28
- </div>
29
- </div>
30
- <span class="button berocket_add_condition"><i class="fa fa-plus"></i></span>
31
- <span class="button br_remove_group"><i class="fa fa-minus"></i></span>
32
- </div>
33
- <div class="br_cond_example" style="display:none;">
34
- <?php
35
- foreach($condition_types as $condition_type_slug => $condition_type_name) {
36
- $condition_html = apply_filters('berocket_filters_condition_type_' . $condition_type_slug, '', '%name%[data][%id%][%current_id%]', array());
37
- if( ! empty($condition_html) ) {
38
- echo '<div class="br_cond br_cond_', $condition_type_slug, '">
39
- ', $condition_html, '
40
- <input type="hidden" name="%name%[data][%id%][%current_id%][type]" value="', $condition_type_slug, '">
41
- </div>';
42
- }
43
- }
44
- ?>
45
- </div>
46
- <div class="br_conditions">
47
- <?php
48
- $last_id = 0;
49
- foreach($filters['data'] as $id => $data) {
50
- $current_id = 1;
51
- ob_start();
52
- foreach($data as $current => $conditions) {
53
- if( $current > $current_id ) {
54
- $current_id = $current;
55
- }
56
- ?>
57
- <div class="br_cond_select" data-current="<?php echo $current; ?>">
58
- <span>
59
- <select class="br_cond_type">
60
- <?php
61
- foreach($condition_types as $condition_type_slug => $condition_type_name) {
62
- echo '<option value="', $condition_type_slug, '"', ( isset($conditions['type']) && $conditions['type'] == $condition_type_slug ? ' selected' : '' ) , '>', $condition_type_name, '</option>';
63
- }
64
- ?>
65
- </select>
66
- </span>
67
- <span class="button berocket_remove_condition"><i class="fa fa-minus"></i></span>
68
- <div class="br_current_cond">
69
- </div>
70
- <?php
71
- $condition_html = apply_filters('berocket_filters_condition_type_' . $conditions['type'], '', 'BeRocket_product_new_filter[data][' . $id . '][' . $current . ']', $conditions);
72
- if( ! empty($condition_html) ) {
73
- echo '<div class="br_cond br_cond_', $conditions['type'], '">
74
- ', $condition_html, '
75
- <input type="hidden" name="BeRocket_product_new_filter[data][' . $id . '][' . $current . '][type]" value="', $conditions['type'], '">
76
- </div>';
77
- }
78
- ?>
79
- </div>
80
- <?php
81
- }
82
- ?>
83
- <span class="button berocket_add_condition"><i class="fa fa-plus"></i></span>
84
- <span class="button br_remove_group"><i class="fa fa-minus"></i></span>
85
- <?php
86
- $html = ob_get_clean();
87
- echo '<div class="br_filter_group_condition" data-id="'.$id.'" data-current="'.$current_id.'">';
88
- echo $html;
89
- echo '</div>';
90
- if( $id > $last_id ) {
91
- $last_id = $id;
92
- }
93
- }
94
- $last_id++;
95
- ?>
96
- <span class="button br_add_group"><i class="fa fa-plus"></i></span>
97
- </div>
98
- <script>
99
- var last_id = <?php echo $last_id; ?>;
100
- var $html = jQuery('.br_filter_group_example').html();
101
- $html = '<div class="br_cond_one">'+$html+'</div>';
102
- jQuery(document).on('change', '.br_cond_type', function(event) {
103
- var $parent = jQuery(this).parents('.br_cond_select');
104
- $parent.find('.br_cond').remove();
105
- var id = $parent.parents('.br_filter_group_condition');
106
- var current_id = $parent.data('current');
107
- id = id.data('id');
108
- var html_need = jQuery('.br_cond_example .br_cond_'+jQuery(this).val()).get(0);
109
- html_need = html_need.outerHTML;
110
- html_need = html_need.replace(/%id%/g, id);
111
- html_need = html_need.replace(/%current_id%/g, current_id);
112
- html_need = html_need.replace(/%name%/g, 'BeRocket_product_new_filter');
113
- $parent.find('.br_current_cond').html(html_need);
114
- });
115
- jQuery(document).on('click', '.berocket_add_condition', function() {
116
- var id = jQuery(this).parents('.br_filter_group_condition');
117
- var current_id = id.data('current');
118
- current_id = current_id + 1;
119
- id.data('current', current_id);
120
- id = id.data('id');
121
- var $html = jQuery('.br_filter_group_example .br_cond_select').html();
122
- $html = '<div class="br_cond_select" data-current="'+current_id+'">'+$html+'</div>';
123
- $html = $html.replace('%id%', id);
124
- jQuery(this).before($html);
125
- $parent = jQuery(this).prev();
126
- $parent.find('.br_cond_type').trigger('change');
127
- });
128
- jQuery(document).on('click', '.berocket_remove_condition', function() {
129
- $parent = jQuery(this).parents('.br_cond_select');
130
- $parent.remove();
131
- });
132
- jQuery(document).on('click', '.br_add_group', function() {
133
- last_id++;
134
- var html = $html.replace( '%id%', last_id );
135
- var html = '<div class="br_filter_group_condition" data-id="'+last_id+'" data-current="1">'+html+'</div>';
136
- jQuery(this).before(html);
137
- $parent = jQuery(this).prev();
138
- $parent.find('.br_cond_type').trigger('change');
139
- });
140
- jQuery(document).on('click', '.br_remove_group', function() {
141
- $parent = jQuery(this).parents('.br_filter_group_condition');
142
- $parent.remove();
143
- });
144
- jQuery(document).on('change', '.br_cond_attr_select', function() {
145
- var $attr_block = jQuery(this).parents('.br_cond_attribute');
146
- $attr_block.find('.br_attr_values').hide();
147
- $attr_block.find('.br_attr_value_'+jQuery(this).val()).show();
148
- });
149
- jQuery(document).on('change', '.price_from', function() {
150
- var val_price_from = jQuery(this).val();
151
- var val_price_to = jQuery(this).parents('.br_cond').first().find('.price_to').val();
152
- price_from = parseFloat(val_price_from);
153
- price_to = parseFloat(val_price_to);
154
- price_to_int = parseInt(val_price_to);
155
- if( val_price_from == '' ) {
156
- jQuery(this).val(0);
157
- price_from = 0;
158
- }
159
- if( price_from > price_to ) {
160
- jQuery(this).val(price_to_int);
161
- }
162
- });
163
- jQuery(document).on('change', '.price_to', function() {
164
- var val_price_from = jQuery(this).parents('.br_cond').first().find('.price_from').val();
165
- var val_price_to = jQuery(this).val();
166
- price_from = parseFloat(val_price_from);
167
- price_from_int = parseInt(val_price_from);
168
- price_to = parseFloat(val_price_to);
169
- if( val_price_to == '' ) {
170
- jQuery(this).val(0);
171
- price_to = 0;
172
- }
173
- if( price_from > price_to ) {
174
- jQuery(this).val(price_from_int);
175
- }
176
- });
177
- </script>
178
- <style>
179
- .br_conditions .br_filter_group_condition {
180
- margin-top: 40px;
181
- }
182
- .br_conditions .br_filter_group_condition:first-child {
183
- margin-top: 0;
184
- }
185
- .br_conditions .br_filter_group_condition:before {
186
- content: "OR";
187
- display: block;
188
- position: absolute;
189
- top: -30px;
190
- font-size: 30px;
191
- }
192
- .br_conditions .br_filter_group_condition:first-child:before {
193
- display: none;
194
- }
195
- .br_filter_group_condition .br_cond_select {
196
- margin-top: 40px;
197
- position: relative;
198
- }
199
- .br_filter_group_condition .br_cond_select:first-child {
200
- margin-top: 0;
201
- }
202
- .br_filter_group_condition .br_cond_select:before {
203
- content: "AND";
204
- display: block;
205
- position: absolute;
206
- top: -30px;
207
- font-size: 30px;
208
- }
209
- .br_filter_group_condition .br_cond_select:first-child:before {
210
- display: none;
211
- }
212
- .br_filter_group_condition .br_cond_one .br_cond_select:first-child .berocket_remove_condition {
213
- display: none;
214
- }
215
- .br_filter_group_condition {
216
- border: 1px solid #999;
217
- background-color: #fafafa;
218
- padding: 0.5em;
219
- margin-bottom: 1em;
220
- position: relative;
221
- }
222
- .br_filter_group_condition .br_remove_group {
223
- position: absolute!important;
224
- top:-10px;
225
- right: -10px;
226
- }
227
- .br_cond_select {
228
- padding-bottom: 1em;
229
- }
230
- .br_cond_select {
231
- border: 1px solid #999;
232
- padding: 0.5em;
233
- margin-bottom: 0.5em;
234
- background-color: #eee;
235
- }
236
- .br_framework_settings .button.berocket_remove_condition,
237
- .br_framework_settings .button.berocket_add_condition,
238
- .br_framework_settings .button.br_remove_group,
239
- .br_framework_settings .button.br_add_group {
240
- padding: 0 10px;
241
- margin: 0;
242
- width: initial;
243
- min-width: initial;
244
- }
245
-
246
- .berocket_label_preview_wrap {
247
- display: inline-block;
248
- width: 240px;
249
- padding: 20px;
250
- background: white;
251
- position: fixed;
252
- top: 100%;
253
- margin-top: -320px;
254
- min-height: 320px;
255
- right: 20px;
256
- box-sizing: border-box;
257
- }
258
- .berocket_label_preview_wrap .berocket_label_preview {
259
- position: relative;
260
- }
261
- .berocket_label_preview_wrap .berocket_product_image {
262
- display: block;
263
- width: 200px;
264
- }
265
- @media screen and (max-width: 850px) {
266
- .berocket_label_preview_wrap {
267
- position: relative;
268
- }
269
- }
270
- </style>
271
- </div>
272
- <div>
273
- <table>
274
- <tr>
275
- <th>Hide this group on:</th>
276
- <td>
277
- <label>
278
- <input type="checkbox" value="1" name="BeRocket_product_new_filter[is_hide_mobile]"<?php if( ! empty($filters['is_hide_mobile']) ) echo ' checked'; ?>>
279
- <?php _e('Mobile', 'BeRocket_AJAX_domain'); ?>
280
- </label>
281
- <label>
282
- <input type="checkbox" value="1" name="BeRocket_product_new_filter[hide_group][tablet]"<?php if( ! empty($filters['hide_group']['tablet']) ) echo ' checked'; ?>>
283
- <?php _e('Tablet', 'BeRocket_AJAX_domain'); ?>
284
- </label>
285
- <label>
286
- <input type="checkbox" value="1" name="BeRocket_product_new_filter[hide_group][desktop]"<?php if( ! empty($filters['hide_group']['desktop']) ) echo ' checked'; ?>>
287
- <?php _e('Desktop', 'BeRocket_AJAX_domain'); ?>
288
- </label>
289
- </td>
290
- </tr>
291
- </table>
292
- </div>
293
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/filter_post.php CHANGED
@@ -675,9 +675,9 @@ $custom_taxonomies = array_combine($custom_taxonomies, $custom_taxonomies);
675
  <div class="berocket_widget_reset_button_block"<?php if( empty($instance['widget_type']) || $instance['widget_type'] != 'reset_button' ) echo ' style="display: none";'?>>
676
  <label class="br_admin_center"><?php _e('Hide button', 'BeRocket_AJAX_domain') ?></label>
677
  <select id="<?php echo 'operator'; ?>" name="<?php echo $post_name.'[reset_hide]'; ?>" class="br_select_menu_left">
678
- <option <?php if ( empty($instance['reset_hide']) ) echo 'selected'; ?> value="">Do not hide</option>
679
- <option <?php if ( $instance['reset_hide'] == 'berocket_no_filters' ) echo 'selected'; ?> value="berocket_no_filters">Hide only when no filters on page</option>
680
- <option <?php if ( $instance['reset_hide'] == 'berocket_no_filters berocket_not_selected' ) echo 'selected'; ?> value="berocket_no_filters berocket_not_selected">Hide when no filters on page or page not filtered</option>
681
  </select>
682
  </div>
683
  <script>
675
  <div class="berocket_widget_reset_button_block"<?php if( empty($instance['widget_type']) || $instance['widget_type'] != 'reset_button' ) echo ' style="display: none";'?>>
676
  <label class="br_admin_center"><?php _e('Hide button', 'BeRocket_AJAX_domain') ?></label>
677
  <select id="<?php echo 'operator'; ?>" name="<?php echo $post_name.'[reset_hide]'; ?>" class="br_select_menu_left">
678
+ <option <?php if ( empty($instance['reset_hide']) ) echo 'selected'; ?> value=""><?php _e('Do not hide', 'BeRocket_AJAX_domain'); ?></option>
679
+ <option <?php if ( $instance['reset_hide'] == 'berocket_no_filters' ) echo 'selected'; ?> value="berocket_no_filters"><?php _e('Hide only when no filters on page', 'BeRocket_AJAX_domain'); ?></option>
680
+ <option <?php if ( $instance['reset_hide'] == 'berocket_no_filters berocket_not_selected' ) echo 'selected'; ?> value="berocket_no_filters berocket_not_selected"><?php _e('Hide when no filters on page or page not filtered', 'BeRocket_AJAX_domain'); ?></option>
681
  </select>
682
  </div>
683
  <script>
templates/filters_condition.php DELETED
@@ -1,293 +0,0 @@
1
- <?php
2
- echo '<div class="submitbox" id="submitpost">';
3
- $product_categories = get_terms( 'product_cat' );
4
- $condition_types = array(
5
- 'page' => __('Page', 'BeRocket_products_label_domain'),
6
- 'attribute' => __('Product Attribute', 'BeRocket_products_label_domain'),
7
- 'search' => __('Search', 'BeRocket_products_label_domain'),
8
- );
9
- if( is_array($product_categories) && count($product_categories) > 0 ) {
10
- $condition_types['category'] = __('Product category', 'BeRocket_products_label_domain');
11
- }
12
- $condition_types = apply_filters('berocket_filters_condition_types', $condition_types);
13
- ?>
14
- <div class="">
15
- <div class="br_filter_group_example" style="display:none;">
16
- <div class="br_cond_select" data-current="1">
17
- <span>
18
- <select class="br_cond_type">
19
- <?php
20
- foreach($condition_types as $condition_type_slug => $condition_type_name) {
21
- echo '<option value="', $condition_type_slug, '">', $condition_type_name, '</option>';
22
- }
23
- ?>
24
- </select>
25
- </span>
26
- <span class="button berocket_remove_condition"><i class="fa fa-minus"></i></span>
27
- <div class="br_current_cond">
28
- </div>
29
- </div>
30
- <span class="button berocket_add_condition"><i class="fa fa-plus"></i></span>
31
- <span class="button br_remove_group"><i class="fa fa-minus"></i></span>
32
- </div>
33
- <div class="br_cond_example" style="display:none;">
34
- <?php
35
- foreach($condition_types as $condition_type_slug => $condition_type_name) {
36
- $condition_html = apply_filters('berocket_filters_condition_type_' . $condition_type_slug, '', '%name%[data][%id%][%current_id%]', array());
37
- if( ! empty($condition_html) ) {
38
- echo '<div class="br_cond br_cond_', $condition_type_slug, '">
39
- ', $condition_html, '
40
- <input type="hidden" name="%name%[data][%id%][%current_id%][type]" value="', $condition_type_slug, '">
41
- </div>';
42
- }
43
- }
44
- ?>
45
- </div>
46
- <div class="br_conditions">
47
- <?php
48
- $last_id = 0;
49
- foreach($filters['data'] as $id => $data) {
50
- $current_id = 1;
51
- ob_start();
52
- foreach($data as $current => $conditions) {
53
- if( $current > $current_id ) {
54
- $current_id = $current;
55
- }
56
- ?>
57
- <div class="br_cond_select" data-current="<?php echo $current; ?>">
58
- <span>
59
- <select class="br_cond_type">
60
- <?php
61
- foreach($condition_types as $condition_type_slug => $condition_type_name) {
62
- echo '<option value="', $condition_type_slug, '"', ( isset($conditions['type']) && $conditions['type'] == $condition_type_slug ? ' selected' : '' ) , '>', $condition_type_name, '</option>';
63
- }
64
- ?>
65
- </select>
66
- </span>
67
- <span class="button berocket_remove_condition"><i class="fa fa-minus"></i></span>
68
- <div class="br_current_cond">
69
- </div>
70
- <?php
71
- $condition_html = apply_filters('berocket_filters_condition_type_' . $conditions['type'], '', 'br_filter_group[data][' . $id . '][' . $current . ']', $conditions);
72
- if( ! empty($condition_html) ) {
73
- echo '<div class="br_cond br_cond_', $conditions['type'], '">
74
- ', $condition_html, '
75
- <input type="hidden" name="br_filter_group[data][' . $id . '][' . $current . '][type]" value="', $conditions['type'], '">
76
- </div>';
77
- }
78
- ?>
79
- </div>
80
- <?php
81
- }
82
- ?>
83
- <span class="button berocket_add_condition"><i class="fa fa-plus"></i></span>
84
- <span class="button br_remove_group"><i class="fa fa-minus"></i></span>
85
- <?php
86
- $html = ob_get_clean();
87
- echo '<div class="br_filter_group_condition" data-id="'.$id.'" data-current="'.$current_id.'">';
88
- echo $html;
89
- echo '</div>';
90
- if( $id > $last_id ) {
91
- $last_id = $id;
92
- }
93
- }
94
- $last_id++;
95
- ?>
96
- <span class="button br_add_group"><i class="fa fa-plus"></i></span>
97
- </div>
98
- <script>
99
- var last_id = <?php echo $last_id; ?>;
100
- var $html = jQuery('.br_filter_group_example').html();
101
- $html = '<div class="br_cond_one">'+$html+'</div>';
102
- jQuery(document).on('change', '.br_cond_type', function(event) {
103
- var $parent = jQuery(this).parents('.br_cond_select');
104
- $parent.find('.br_cond').remove();
105
- var id = $parent.parents('.br_filter_group_condition');
106
- var current_id = $parent.data('current');
107
- id = id.data('id');
108
- var html_need = jQuery('.br_cond_example .br_cond_'+jQuery(this).val()).get(0);
109
- html_need = html_need.outerHTML;
110
- html_need = html_need.replace(/%id%/g, id);
111
- html_need = html_need.replace(/%current_id%/g, current_id);
112
- html_need = html_need.replace(/%name%/g, 'br_filter_group');
113
- $parent.find('.br_current_cond').html(html_need);
114
- });
115
- jQuery(document).on('click', '.berocket_add_condition', function() {
116
- var id = jQuery(this).parents('.br_filter_group_condition');
117
- var current_id = id.data('current');
118
- current_id = current_id + 1;
119
- id.data('current', current_id);
120
- id = id.data('id');
121
- var $html = jQuery('.br_filter_group_example .br_cond_select').html();
122
- $html = '<div class="br_cond_select" data-current="'+current_id+'">'+$html+'</div>';
123
- $html = $html.replace('%id%', id);
124
- jQuery(this).before($html);
125
- $parent = jQuery(this).prev();
126
- $parent.find('.br_cond_type').trigger('change');
127
- });
128
- jQuery(document).on('click', '.berocket_remove_condition', function() {
129
- $parent = jQuery(this).parents('.br_cond_select');
130
- $parent.remove();
131
- });
132
- jQuery(document).on('click', '.br_add_group', function() {
133
- last_id++;
134
- var html = $html.replace( '%id%', last_id );
135
- var html = '<div class="br_filter_group_condition" data-id="'+last_id+'" data-current="1">'+html+'</div>';
136
- jQuery(this).before(html);
137
- $parent = jQuery(this).prev();
138
- $parent.find('.br_cond_type').trigger('change');
139
- });
140
- jQuery(document).on('click', '.br_remove_group', function() {
141
- $parent = jQuery(this).parents('.br_filter_group_condition');
142
- $parent.remove();
143
- });
144
- jQuery(document).on('change', '.br_cond_attr_select', function() {
145
- var $attr_block = jQuery(this).parents('.br_cond_attribute');
146
- $attr_block.find('.br_attr_values').hide();
147
- $attr_block.find('.br_attr_value_'+jQuery(this).val()).show();
148
- });
149
- jQuery(document).on('change', '.price_from', function() {
150
- var val_price_from = jQuery(this).val();
151
- var val_price_to = jQuery(this).parents('.br_cond').first().find('.price_to').val();
152
- price_from = parseFloat(val_price_from);
153
- price_to = parseFloat(val_price_to);
154
- price_to_int = parseInt(val_price_to);
155
- if( val_price_from == '' ) {
156
- jQuery(this).val(0);
157
- price_from = 0;
158
- }
159
- if( price_from > price_to ) {
160
- jQuery(this).val(price_to_int);
161
- }
162
- });
163
- jQuery(document).on('change', '.price_to', function() {
164
- var val_price_from = jQuery(this).parents('.br_cond').first().find('.price_from').val();
165
- var val_price_to = jQuery(this).val();
166
- price_from = parseFloat(val_price_from);
167
- price_from_int = parseInt(val_price_from);
168
- price_to = parseFloat(val_price_to);
169
- if( val_price_to == '' ) {
170
- jQuery(this).val(0);
171
- price_to = 0;
172
- }
173
- if( price_from > price_to ) {
174
- jQuery(this).val(price_from_int);
175
- }
176
- });
177
- </script>
178
- <style>
179
- .br_conditions .br_filter_group_condition {
180
- margin-top: 40px;
181
- }
182
- .br_conditions .br_filter_group_condition:first-child {
183
- margin-top: 0;
184
- }
185
- .br_conditions .br_filter_group_condition:before {
186
- content: "OR";
187
- display: block;
188
- position: absolute;
189
- top: -30px;
190
- font-size: 30px;
191
- }
192
- .br_conditions .br_filter_group_condition:first-child:before {
193
- display: none;
194
- }
195
- .br_filter_group_condition .br_cond_select {
196
- margin-top: 40px;
197
- position: relative;
198
- }
199
- .br_filter_group_condition .br_cond_select:first-child {
200
- margin-top: 0;
201
- }
202
- .br_filter_group_condition .br_cond_select:before {
203
- content: "AND";
204
- display: block;
205
- position: absolute;
206
- top: -30px;
207
- font-size: 30px;
208
- }
209
- .br_filter_group_condition .br_cond_select:first-child:before {
210
- display: none;
211
- }
212
- .br_filter_group_condition .br_cond_one .br_cond_select:first-child .berocket_remove_condition {
213
- display: none;
214
- }
215
- .br_filter_group_condition {
216
- border: 1px solid #999;
217
- background-color: #fafafa;
218
- padding: 0.5em;
219
- margin-bottom: 1em;
220
- position: relative;
221
- }
222
- .br_filter_group_condition .br_remove_group {
223
- position: absolute!important;
224
- top:-10px;
225
- right: -10px;
226
- }
227
- .br_cond_select {
228
- padding-bottom: 1em;
229
- }
230
- .br_cond_select {
231
- border: 1px solid #999;
232
- padding: 0.5em;
233
- margin-bottom: 0.5em;
234
- background-color: #eee;
235
- }
236
- .br_framework_settings .button.berocket_remove_condition,
237
- .br_framework_settings .button.berocket_add_condition,
238
- .br_framework_settings .button.br_remove_group,
239
- .br_framework_settings .button.br_add_group {
240
- padding: 0 10px;
241
- margin: 0;
242
- width: initial;
243
- min-width: initial;
244
- }
245
-
246
- .berocket_label_preview_wrap {
247
- display: inline-block;
248
- width: 240px;
249
- padding: 20px;
250
- background: white;
251
- position: fixed;
252
- top: 100%;
253
- margin-top: -320px;
254
- min-height: 320px;
255
- right: 20px;
256
- box-sizing: border-box;
257
- }
258
- .berocket_label_preview_wrap .berocket_label_preview {
259
- position: relative;
260
- }
261
- .berocket_label_preview_wrap .berocket_product_image {
262
- display: block;
263
- width: 200px;
264
- }
265
- @media screen and (max-width: 850px) {
266
- .berocket_label_preview_wrap {
267
- position: relative;
268
- }
269
- }
270
- </style>
271
- </div>
272
- <div>
273
- <table>
274
- <tr>
275
- <th>Hide this group on:</th>
276
- <td>
277
- <label>
278
- <input type="checkbox" value="1" name="br_filter_group[hide_group][mobile]"<?php if( ! empty($filters['hide_group']['mobile']) ) echo ' checked'; ?>>
279
- <?php _e('Mobile', 'BeRocket_AJAX_domain'); ?>
280
- </label>
281
- <label>
282
- <input type="checkbox" value="1" name="br_filter_group[hide_group][tablet]"<?php if( ! empty($filters['hide_group']['tablet']) ) echo ' checked'; ?>>
283
- <?php _e('Tablet', 'BeRocket_AJAX_domain'); ?>
284
- </label>
285
- <label>
286
- <input type="checkbox" value="1" name="br_filter_group[hide_group][desktop]"<?php if( ! empty($filters['hide_group']['desktop']) ) echo ' checked'; ?>>
287
- <?php _e('Desktop', 'BeRocket_AJAX_domain'); ?>
288
- </label>
289
- </td>
290
- </tr>
291
- </table>
292
- </div>
293
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/filters_group.php CHANGED
@@ -86,6 +86,7 @@
86
  line-height: 40px;
87
  height: 40px;
88
  border-right-width: 3px;
 
89
  }
90
  .berocket_filter_added_list li .fa-bars {
91
  margin-right: 0.5em;
@@ -114,12 +115,13 @@
114
  }
115
  .berocket_filter_added_list .berocket_edit_filter {
116
  vertical-align: middle;
117
- font-size: 0.5em;
118
  float: right;
119
  line-height: 40px;
120
- height: 2em;
121
  display: inline-block;
122
  color: #2c3b48;
 
 
123
  }
124
  .berocket_filter_added_list li .fa-times:hover,
125
  .berocket_filter_added_list .berocket_edit_filter:hover {
@@ -148,4 +150,22 @@
148
  .berocket_filter_added_list.berocket_hidden_clickable_enabled .berocket_hidden_clickable_options {
149
  display: inline-block;
150
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  </style>
86
  line-height: 40px;
87
  height: 40px;
88
  border-right-width: 3px;
89
+ background-color: rgb(238, 238, 238);
90
  }
91
  .berocket_filter_added_list li .fa-bars {
92
  margin-right: 0.5em;
115
  }
116
  .berocket_filter_added_list .berocket_edit_filter {
117
  vertical-align: middle;
118
+ font-size: 0.6em;
119
  float: right;
120
  line-height: 40px;
 
121
  display: inline-block;
122
  color: #2c3b48;
123
+ margin-left: 0.5em;
124
+ margin-right: 0.5em;
125
  }
126
  .berocket_filter_added_list li .fa-times:hover,
127
  .berocket_filter_added_list .berocket_edit_filter:hover {
150
  .berocket_filter_added_list.berocket_hidden_clickable_enabled .berocket_hidden_clickable_options {
151
  display: inline-block;
152
  }
153
+ @media screen and (max-width: 600px) {
154
+ .berocket_filter_added_list small,
155
+ .berocket_filter_added_list .berocket_edit_filter {
156
+ display: none;
157
+ }
158
+ .berocket_filter_added_list li {
159
+ position: relative;
160
+ }
161
+ .berocket_filter_added_list li .fa-times {
162
+ position: absolute;
163
+ top: 1px;
164
+ right: 0;
165
+ background-color: rgb(238, 238, 238);
166
+ margin: 0;
167
+ padding: 0 10px;
168
+ line-height: 38px;
169
+ }
170
+ }
171
  </style>
templates/free/features.php CHANGED
@@ -5,7 +5,7 @@
5
  <h5>Our WooCommerce AJAX Products Filter offers several layouts including slider, image and color</h5>
6
 
7
  <div class="demo-site">
8
- <a href="https://woocommerce-products-filter.berocket.com/shop/" target="_blank">[ demo site ]</a>
9
  </div>
10
  <img alt="Choose best layout for your filter" src="https://berocket.com/images/features/filters/filters-types.jpg" />
11
  </div>
@@ -16,7 +16,7 @@
16
  <h5>Users will get next page loaded ordered by their preferences and without page reloading</h5>
17
 
18
  <div class="demo-site">
19
- <a href="https://woocommerce-products-filter.berocket.com/shop/" target="_blank">[ demo site ]</a>
20
  </div>
21
 
22
  <img alt="Pagination and Order without page reloading" src="https://berocket.com/images/features/filters/ajax_order_nav.jpg" />
@@ -28,7 +28,7 @@
28
  <h5>Need more space for the products? Say no to sidebars</h5>
29
 
30
  <div class="demo-site">
31
- <a href="https://woocommerce-products-filter.berocket.com/product-category/tshirts/" target="_blank">[ demo site ]</a>
32
  </div>
33
  <img alt="Show filters above products" src="https://berocket.com/images/features/filters/above_products.jpg" />
34
  </div>
@@ -39,7 +39,7 @@
39
  <h5>Use Nice URLs with canonicalization and slugs instead of IDs</h5>
40
 
41
  <div class="demo-site">
42
- <a href="https://woocommerce-products-filter.berocket.com/product-category/tshirts/" target="_blank">[ demo site ]</a>
43
  </div>
44
 
45
  <div>&nbsp;</div>
@@ -61,7 +61,7 @@
61
  <h5>Show users what they will get before filters applied. Fast and efficient</h5>
62
 
63
  <div class="demo-site">
64
- <a href="https://woocommerce-products-filter.berocket.com/woocommerce-products-filter-demo-4/" target="_blank">[ demo site ]</a>
65
  </div>
66
 
67
  <div>&nbsp;</div>
@@ -75,7 +75,7 @@
75
  <h5>Show only needed values from the attribute or hide few</h5>
76
 
77
  <div class="demo-site">
78
- <a href="https://woocommerce-products-filter.berocket.com/woocommerce-products-filter-demo-4/" target="_blank">[ demo site ]</a>
79
  </div>
80
  <img alt="Include/Exclude values" src="https://berocket.com/images/features/filters/include_exclude.jpg" />
81
  </div>
@@ -86,7 +86,7 @@
86
  <h5>Users can pre-fill filters before visiting shop page</h5>
87
 
88
  <div class="demo-site">
89
- <a href="https://woocommerce-products-filter.berocket.com/" target="_blank">[ demo site ]</a>
90
  </div>
91
  <img alt="Search Box on any page" src="https://berocket.com/images/features/filters/searchbox.jpg" />
92
  </div>
@@ -97,7 +97,7 @@
97
  <h5>Hate &quot;No Products!&quot; message? Hide values without products on the go</h5>
98
 
99
  <div class="demo-site">
100
- <a href="https://woocommerce-products-filter.berocket.com/shop/" target="_blank">[ demo site ]</a>
101
  </div>
102
 
103
  <div>&nbsp;</div>
@@ -119,7 +119,7 @@
119
  <h5>Users love brands. Help them find favorite brands faster</h5>
120
 
121
  <div class="demo-site">
122
- <a href="https://woocommerce-products-filter.berocket.com/woocommerce-products-filter-demo-5/" target="_blank">[ demo site ]</a>
123
  </div>
124
  <img alt="Brands" src="https://berocket.com/images/features/filters/brands.jpg" />
125
  </div>
@@ -130,7 +130,7 @@
130
  <h5>Love sliders? Use them now for the attributes too!</h5>
131
 
132
  <div class="demo-site">
133
- <a href="https://woocommerce-products-filter.berocket.com/woocommerce-products-filter-demo-2/" target="_blank">[ demo site ]</a>
134
  </div>
135
  <img alt="Price Ranges and Sliders for Attributes" src="https://berocket.com/images/features/filters/range_slider.jpg" />
136
  </div>
5
  <h5>Our WooCommerce AJAX Products Filter offers several layouts including slider, image and color</h5>
6
 
7
  <div class="demo-site">
8
+ <a href="https://woocommerce-products-filter.berocket.com/shop/?utm_source=free_plugin&utm_medium=upgrade&utm_campaign=ajax_filters" target="_blank">[ demo site ]</a>
9
  </div>
10
  <img alt="Choose best layout for your filter" src="https://berocket.com/images/features/filters/filters-types.jpg" />
11
  </div>
16
  <h5>Users will get next page loaded ordered by their preferences and without page reloading</h5>
17
 
18
  <div class="demo-site">
19
+ <a href="https://woocommerce-products-filter.berocket.com/shop/?utm_source=free_plugin&utm_medium=upgrade&utm_campaign=ajax_filters" target="_blank">[ demo site ]</a>
20
  </div>
21
 
22
  <img alt="Pagination and Order without page reloading" src="https://berocket.com/images/features/filters/ajax_order_nav.jpg" />
28
  <h5>Need more space for the products? Say no to sidebars</h5>
29
 
30
  <div class="demo-site">
31
+ <a href="https://woocommerce-products-filter.berocket.com/product-category/tshirts/?utm_source=free_plugin&utm_medium=upgrade&utm_campaign=ajax_filters" target="_blank">[ demo site ]</a>
32
  </div>
33
  <img alt="Show filters above products" src="https://berocket.com/images/features/filters/above_products.jpg" />
34
  </div>
39
  <h5>Use Nice URLs with canonicalization and slugs instead of IDs</h5>
40
 
41
  <div class="demo-site">
42
+ <a href="https://woocommerce-products-filter.berocket.com/product-category/tshirts/?utm_source=free_plugin&utm_medium=upgrade&utm_campaign=ajax_filters" target="_blank">[ demo site ]</a>
43
  </div>
44
 
45
  <div>&nbsp;</div>
61
  <h5>Show users what they will get before filters applied. Fast and efficient</h5>
62
 
63
  <div class="demo-site">
64
+ <a href="https://woocommerce-products-filter.berocket.com/woocommerce-products-filter-demo-4/?utm_source=free_plugin&utm_medium=upgrade&utm_campaign=ajax_filters" target="_blank">[ demo site ]</a>
65
  </div>
66
 
67
  <div>&nbsp;</div>
75
  <h5>Show only needed values from the attribute or hide few</h5>
76
 
77
  <div class="demo-site">
78
+ <a href="https://woocommerce-products-filter.berocket.com/woocommerce-products-filter-demo-4/?utm_source=free_plugin&utm_medium=upgrade&utm_campaign=ajax_filters" target="_blank">[ demo site ]</a>
79
  </div>
80
  <img alt="Include/Exclude values" src="https://berocket.com/images/features/filters/include_exclude.jpg" />
81
  </div>
86
  <h5>Users can pre-fill filters before visiting shop page</h5>
87
 
88
  <div class="demo-site">
89
+ <a href="https://woocommerce-products-filter.berocket.com/?utm_source=free_plugin&utm_medium=upgrade&utm_campaign=ajax_filters" target="_blank">[ demo site ]</a>
90
  </div>
91
  <img alt="Search Box on any page" src="https://berocket.com/images/features/filters/searchbox.jpg" />
92
  </div>
97
  <h5>Hate &quot;No Products!&quot; message? Hide values without products on the go</h5>
98
 
99
  <div class="demo-site">
100
+ <a href="https://woocommerce-products-filter.berocket.com/shop/?utm_source=free_plugin&utm_medium=upgrade&utm_campaign=ajax_filters" target="_blank">[ demo site ]</a>
101
  </div>
102
 
103
  <div>&nbsp;</div>
119
  <h5>Users love brands. Help them find favorite brands faster</h5>
120
 
121
  <div class="demo-site">
122
+ <a href="https://woocommerce-products-filter.berocket.com/woocommerce-products-filter-demo-5/?utm_source=free_plugin&utm_medium=upgrade&utm_campaign=ajax_filters" target="_blank">[ demo site ]</a>
123
  </div>
124
  <img alt="Brands" src="https://berocket.com/images/features/filters/brands.jpg" />
125
  </div>
130
  <h5>Love sliders? Use them now for the attributes too!</h5>
131
 
132
  <div class="demo-site">
133
+ <a href="https://woocommerce-products-filter.berocket.com/woocommerce-products-filter-demo-2/?utm_source=free_plugin&utm_medium=upgrade&utm_campaign=ajax_filters" target="_blank">[ demo site ]</a>
134
  </div>
135
  <img alt="Price Ranges and Sliders for Attributes" src="https://berocket.com/images/features/filters/range_slider.jpg" />
136
  </div>
templates/settings_footer.php DELETED
@@ -1,62 +0,0 @@
1
- <div class="wrap">
2
- <?php if( ! empty($feature_list) && count($feature_list) > 0 ) { ?>
3
- <div class="paid_features">
4
- <?php
5
- $feature_text = '';
6
- foreach($feature_list as $feature) {
7
- $feature_text .= '<li>'.$feature.'</li>';
8
- }
9
- $text = '<h3>Receive more features and control with Paid version of the plugin:</h3>
10
- <div>
11
- <ul>
12
- %feature_list%
13
- </ul>
14
- </div>
15
- <div><a class="get_premium_version" href="%link%">PREMIUM VERSION</a></div>
16
- <p>Support the plugin by purchasing paid version. This will provide faster growth, better support and much more functionality for the plugin</p>';
17
- $text = str_replace('%feature_list%', $feature_text, $text);
18
- $text = str_replace('%link%', $dplugin_link, $text);
19
- $text = str_replace('%plugin_name%', br_get_value_from_array($plugin_info, 'Name'), $text);
20
- $text = str_replace('%plugin_link%', br_get_value_from_array($plugin_info, 'PluginURI'), $text);
21
- echo $text;
22
- ?>
23
- </div>
24
- <?php
25
- $text = '<h4>Both <a href="%plugin_link%" target="_blank">Free</a> and <a href="%link%" target="_blank">Paid</a> versions of %plugin_name% developed by <a href="http://berocket.com" target="_blank">BeRocket</a></h4>';
26
- } else {
27
- $text = '<h4><a href="%plugin_link%" target="_blank">%plugin_name%</a> developed by <a href="http://berocket.com" target="_blank">BeRocket</a></h4>';
28
- }
29
- $text = str_replace('%link%', $dplugin_link, $text);
30
- $text = str_replace('%plugin_name%', br_get_value_from_array($plugin_info, 'Name'), $text);
31
- $text = str_replace('%plugin_link%', br_get_value_from_array($plugin_info, 'PluginURI'), $text);
32
- echo $text;
33
- ?>
34
- </div>
35
- <style>
36
- .paid_features {
37
- border: 1px solid #c29a9a;
38
- background: white;
39
- padding: 20px 20px 10px 30px;
40
- font-weight: 600;
41
- }
42
- .get_premium_version {
43
- display: inline-block;
44
- background-color: rgb(239, 109, 109);
45
- border-color: rgb(222, 72, 72);
46
- color: white;
47
- font-size: 20px;
48
- height: auto;
49
- padding: 10px 41px;
50
- margin: 1em 0 1em 0;
51
- text-decoration: none;
52
- cursor: pointer;
53
- }
54
- .get_premium_version:hover {
55
- color: white;
56
- background-color: rgb(222, 72, 72);
57
- }
58
- .paid_features ul li{
59
- list-style: initial;
60
- margin-left: 2em;
61
- }
62
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/settings_head.php DELETED
@@ -1,9 +0,0 @@
1
- <div class="wrap">
2
- <?php
3
- $text = '<h1>%plugin_name% by BeRocket</h1>
4
- <div>%desc%</div>';
5
- $text = str_replace('%plugin_name%', $plugin_info['Name'], $text);
6
- $text = str_replace('%desc%', $plugin_info['Description'], $text);
7
- echo $text;
8
- ?>
9
- </div>
 
 
 
 
 
 
 
 
 
wizard/main.php CHANGED
@@ -4,7 +4,7 @@ if( ! class_exists('BeRocket_selector_wizard_woocommerce') ) {
4
  class BeRocket_selector_wizard_woocommerce{
5
  function __construct() {
6
  add_action('BeRocket_wizard_start', array($this, 'import_products'));
7
- add_action('BeRocket_wizard_javascript', array($this, 'javascript'));
8
  add_action('BeRocket_wizard_end', array($this, 'remove_products'));
9
  add_action('BeRocket_wizard_ended_check', array($this, 'remove_products_ended'));
10
  add_filter('BeRocket_wizard_category_link', array($this, 'category_link'));
@@ -27,19 +27,20 @@ if( ! class_exists('BeRocket_selector_wizard_woocommerce') ) {
27
  function loop_shop_per_page($cols) {
28
  return 3;
29
  }
30
- public function javascript() {
31
  wp_enqueue_script( 'jquery' );
32
  wp_enqueue_script( 'berocket_wizard_autoselect', plugins_url( 'wizard.js', __FILE__ ), array( 'jquery' ) );
 
 
 
 
 
 
 
33
  wp_localize_script(
34
  'berocket_wizard_autoselect',
35
  'berocket_wizard_autoselect',
36
- array(
37
- 'creating_products' => __('Creating products', 'BeRocket_domain'),
38
- 'getting_selectors' => __('Gettings selectors', 'BeRocket_domain'),
39
- 'removing_products' => __('Removing products', 'BeRocket_domain'),
40
- 'error' => __('Error:', 'BeRocket_domain'),
41
- 'ajaxurl' => admin_url('admin-ajax.php')
42
- )
43
  );
44
  wp_register_style( 'berocket_wizard_autoselect', plugins_url( 'wizard.css', __FILE__ ) );
45
  wp_enqueue_style( 'berocket_wizard_autoselect' );
@@ -164,7 +165,7 @@ if( ! class_exists('BeRocket_selector_wizard_woocommerce') ) {
164
  }
165
  }
166
  new BeRocket_selector_wizard_woocommerce();
167
- function BeRocket_wizard_generate_autoselectors($input_classes = array(), $js_functions = array()) {
168
  $status = get_option('BeRocket_selector_wizard_status');
169
  $status = $status == 'started';
170
  $js_functions = array_merge(
@@ -183,6 +184,17 @@ if( ! class_exists('BeRocket_selector_wizard_woocommerce') ) {
183
  'prev_page' => '',
184
  'result_count' => '',
185
  ), $input_classes);
 
 
 
 
 
 
 
 
 
 
 
186
  $active_plugins = get_option('active_plugins');
187
  $apl=get_option('active_plugins');
188
  $plugins=get_plugins();
@@ -196,18 +208,18 @@ if( ! class_exists('BeRocket_selector_wizard_woocommerce') ) {
196
  }
197
  }
198
  $html = '<div class="berocket_wizard_autoselectors" data-functions=\'' . json_encode($js_functions) . '\' data-inputs=\'' . json_encode($input_classes) . '\'>
199
- <p><strong>'.__('IMPORTANT: It will generate some products on your site. Please disable all SEO plugins and plugins, that doing anything on product creating.', 'BeRocket_domain').'</strong></p>
200
- '.($status ? '<div class="berocket_selectors_was_runned"><strong style="color: red;">'.__('Script was runned, but page closed until end. Please stop it to prevent any problems on your site', 'BeRocket_domain').'</strong></div>' : '').'
201
- <button data-seoplugins="'.implode(', ', $activated_plugins).'" class="'.(count($activated_plugins) ? 'berocket_autoselector_seo' : 'berocket_autoselector').' button" type="button"'.($status ? ' disabled' : '').'>Auto-Selectors</button>
202
- <span class="berocket_autoselect_spin"'.($status ? '' : 'style="display:none;').'"><i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i><button class="berocket_autoselector_stop button" type="button">Stop</button></span>
203
  <span class="berocket_autoselect_ready" style="display:none;"><i class="fa fa-check fa-3x fa-fw"></i></span>
204
  <span class="berocket_autoselect_error" style="display:none;"><i class="fa fa-times fa-3x fa-fw"></i></span>
205
  <div class="berocket_autoselector_load" style="display:none;"><div class="berocket_line"></div><div class="berocket_autoselector_action"></div></div>
206
- <h4>' . __('Steps:', 'BeRocket_domain') . '</h4>
207
  <ol>
208
- <li><span>' . __('Creating products', 'BeRocket_domain') . '</span> <i class="fa"></i></li>
209
- <li><span>' . __('Gettings selectors', 'BeRocket_domain') . '</span> <i class="fa"></i></li>
210
- <li><span>' . __('Removing products', 'BeRocket_domain') . '</span> <i class="fa"></i></li>
211
  </ol>
212
  </div>
213
  <script>jQuery(document).ready(function(){
4
  class BeRocket_selector_wizard_woocommerce{
5
  function __construct() {
6
  add_action('BeRocket_wizard_start', array($this, 'import_products'));
7
+ add_action('BeRocket_wizard_javascript', array($this, 'javascript'), 10, 1);
8
  add_action('BeRocket_wizard_end', array($this, 'remove_products'));
9
  add_action('BeRocket_wizard_ended_check', array($this, 'remove_products_ended'));
10
  add_filter('BeRocket_wizard_category_link', array($this, 'category_link'));
27
  function loop_shop_per_page($cols) {
28
  return 3;
29
  }
30
+ public function javascript($translating_text = array()) {
31
  wp_enqueue_script( 'jquery' );
32
  wp_enqueue_script( 'berocket_wizard_autoselect', plugins_url( 'wizard.js', __FILE__ ), array( 'jquery' ) );
33
+ $translating_text = array_merge(array(
34
+ 'creating_products' => __('Creating products', 'BeRocket_domain'),
35
+ 'getting_selectors' => __('Gettings selectors', 'BeRocket_domain'),
36
+ 'removing_products' => __('Removing products', 'BeRocket_domain'),
37
+ 'error' => __('Error:', 'BeRocket_domain'),
38
+ 'ajaxurl' => admin_url('admin-ajax.php')
39
+ ), $translating_text);
40
  wp_localize_script(
41
  'berocket_wizard_autoselect',
42
  'berocket_wizard_autoselect',
43
+ $translating_text
 
 
 
 
 
 
44
  );
45
  wp_register_style( 'berocket_wizard_autoselect', plugins_url( 'wizard.css', __FILE__ ) );
46
  wp_enqueue_style( 'berocket_wizard_autoselect' );
165
  }
166
  }
167
  new BeRocket_selector_wizard_woocommerce();
168
+ function BeRocket_wizard_generate_autoselectors($input_classes = array(), $js_functions = array(), $output_text = array()) {
169
  $status = get_option('BeRocket_selector_wizard_status');
170
  $status = $status == 'started';
171
  $js_functions = array_merge(
184
  'prev_page' => '',
185
  'result_count' => '',
186
  ), $input_classes);
187
+ $output_text = array_merge(
188
+ array(
189
+ 'important' => __('IMPORTANT: It will generate some products on your site. Please disable all SEO plugins and plugins, that doing anything on product creating.', 'BeRocket_domain'),
190
+ 'was_runned' => __('Script was runned, but page closed until end. Please stop it to prevent any problems on your site', 'BeRocket_domain'),
191
+ 'run_button' => __('Auto-Selectors', 'BeRocket_domain'),
192
+ 'was_runned_stop' => __('Stop', 'BeRocket_domain'),
193
+ 'steps' => __('Steps:', 'BeRocket_domain'),
194
+ 'step_create_products' => __('Creating products', 'BeRocket_domain'),
195
+ 'step_get_selectors' => __('Gettings selectors', 'BeRocket_domain'),
196
+ 'step_remove_product' => __('Removing products', 'BeRocket_domain')
197
+ ), $output_text);
198
  $active_plugins = get_option('active_plugins');
199
  $apl=get_option('active_plugins');
200
  $plugins=get_plugins();
208
  }
209
  }
210
  $html = '<div class="berocket_wizard_autoselectors" data-functions=\'' . json_encode($js_functions) . '\' data-inputs=\'' . json_encode($input_classes) . '\'>
211
+ <p><strong>'.$output_text['important'].'</strong></p>
212
+ '.($status ? '<div class="berocket_selectors_was_runned"><strong style="color: red;">'.$output_text['was_runned'].'</strong></div>' : '').'
213
+ <button data-seoplugins="'.implode(', ', $activated_plugins).'" class="'.(count($activated_plugins) ? 'berocket_autoselector_seo' : 'berocket_autoselector').' button" type="button"'.($status ? ' disabled' : '').'>'.$output_text['run_button'].'</button>
214
+ <span class="berocket_autoselect_spin"'.($status ? '' : 'style="display:none;').'"><i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i><button class="berocket_autoselector_stop button" type="button">'.$output_text['was_runned_stop'].'</button></span>
215
  <span class="berocket_autoselect_ready" style="display:none;"><i class="fa fa-check fa-3x fa-fw"></i></span>
216
  <span class="berocket_autoselect_error" style="display:none;"><i class="fa fa-times fa-3x fa-fw"></i></span>
217
  <div class="berocket_autoselector_load" style="display:none;"><div class="berocket_line"></div><div class="berocket_autoselector_action"></div></div>
218
+ <h4>' . $output_text['steps'] . '</h4>
219
  <ol>
220
+ <li><span>' . $output_text['step_create_products'] . '</span> <i class="fa"></i></li>
221
+ <li><span>' . $output_text['step_get_selectors'] . '</span> <i class="fa"></i></li>
222
+ <li><span>' . $output_text['step_remove_product'] . '</span> <i class="fa"></i></li>
223
  </ol>
224
  </div>
225
  <script>jQuery(document).ready(function(){
wizard/setup-wizard.php CHANGED
@@ -31,7 +31,7 @@ if( ! class_exists('BeRocket_Setup_Wizard') ) {
31
  )
32
  );
33
  add_action( 'admin_menu', array( $this, 'admin_menus' ) );
34
- add_action( 'admin_init', array( $this, 'setup_wizard' ) );
35
  }
36
  }
37
  public function admin_menus() {
@@ -50,7 +50,8 @@ if( ! class_exists('BeRocket_Setup_Wizard') ) {
50
  wp_admin_css();
51
  wp_register_style( 'wizard-setup', plugins_url( 'admin.css', __FILE__ ) );
52
  wp_enqueue_style( 'wizard-setup' );
53
- wp_enqueue_style( 'font-awesome' );
 
54
 
55
  ob_start();
56
  $this->setup_wizard_header();
@@ -90,7 +91,7 @@ if( ! class_exists('BeRocket_Setup_Wizard') ) {
90
  <title><?php esc_html_e( 'WooCommerce &rsaquo; Setup Wizard', 'woocommerce' ); ?></title>
91
  <?php do_action( 'admin_print_scripts' ); ?>
92
  <?php do_action( 'admin_print_styles' ); ?>
93
- <?php do_action( 'admin_head' ); ?>
94
  </head>
95
  <body class="wp-admin wp-core-ui js">
96
  <div class="br_framework_settings br_setup_wizard">
31
  )
32
  );
33
  add_action( 'admin_menu', array( $this, 'admin_menus' ) );
34
+ add_action( 'admin_init', array( $this, 'setup_wizard' ), 100 );
35
  }
36
  }
37
  public function admin_menus() {
50
  wp_admin_css();
51
  wp_register_style( 'wizard-setup', plugins_url( 'admin.css', __FILE__ ) );
52
  wp_enqueue_style( 'wizard-setup' );
53
+ BeRocket_Framework::register_font_awesome('fa5');
54
+ wp_enqueue_style( 'font-awesome-5' );
55
 
56
  ob_start();
57
  $this->setup_wizard_header();
91
  <title><?php esc_html_e( 'WooCommerce &rsaquo; Setup Wizard', 'woocommerce' ); ?></title>
92
  <?php do_action( 'admin_print_scripts' ); ?>
93
  <?php do_action( 'admin_print_styles' ); ?>
94
+ <?php //do_action( 'admin_head' ); ?>
95
  </head>
96
  <body class="wp-admin wp-core-ui js">
97
  <div class="br_framework_settings br_setup_wizard">
woocommerce-filters.php CHANGED
@@ -1,18 +1,16 @@
1
  <?php
2
  /**
3
  * Plugin Name: Advanced AJAX Product Filters for WooCommerce
4
- * Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-filters/
5
  * Description: Unlimited AJAX products filters to make your shop perfect
6
- * Version: 1.3.2.6
7
  * Author: BeRocket
8
  * Requires at least: 4.0
9
- * Author URI: https://berocket.com
10
- * License: Berocket License
11
- * License URI: https://berocket.com/license
12
  * Text Domain: BeRocket_AJAX_domain
13
  * Domain Path: /languages/
14
- * WC tested up to: 3.7
15
  */
16
- define( "BeRocket_AJAX_filters_version", '1.3.2.6' );
17
  define( "BeRocket_AJAX_filters_file", __FILE__ );
18
  include_once('main.php');
1
  <?php
2
  /**
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.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
 
 
10
  * Text Domain: BeRocket_AJAX_domain
11
  * Domain Path: /languages/
12
+ * WC tested up to: 3.7.0
13
  */
14
+ define( "BeRocket_AJAX_filters_version", '1.3.4' );
15
  define( "BeRocket_AJAX_filters_file", __FILE__ );
16
  include_once('main.php');