Advanced AJAX Product Filters - Version 1.4.0.2

Version Description

  • Enhancement - Additional table generation withour WP-Cron
  • Enhancement - Option to disable AJAX Pagination
  • Enhancement - Write table generation errors and status
Download this release

Release Info

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

Code changes from version 1.4.0.1 to 1.4.0.2

addons/additional_tables/additional_tables.php CHANGED
@@ -9,22 +9,22 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
9
  'percentage' => 1
10
  ),
11
  2 => array(
12
- 'percentage' => 13
13
  ),
14
  3 => array(
15
- 'percentage' => 1
16
  ),
17
  4 => array(
18
- 'percentage' => 80
19
  ),
20
  5 => array(
21
- 'percentage' => 1
22
  ),
23
  6 => array(
24
- 'percentage' => 2
25
  ),
26
  7 => array(
27
- 'percentage' => 1
28
  ),
29
  8 => array(
30
  'percentage' => 1
@@ -40,7 +40,10 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
40
  if( in_array($this->addon_file, $active_addons) ) {
41
  if( $create_position < $this->last_postion ) {
42
  $this->activate();
43
- $this->activate_hooks();
 
 
 
44
  }
45
  } else {
46
  if( ! empty($create_position) ) {
@@ -73,19 +76,28 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
73
  function set_current_create_position_data($data) {
74
  update_option('BeRocket_aapf_additional_tables_addon_position_data', $data);
75
  }
76
- function activate($current_position = -1) {
77
  if( $current_position == -1 ) {
78
  $current_position = $this->get_current_create_position();
79
  }
80
  if( empty($current_position) ) {
 
 
81
  $this->create_table_braapf_product_stock_status_parent();
82
- } elseif( $current_position == 3 ) {
 
 
83
  $this->create_table_braapf_product_variation_attributes();
84
- } elseif( $current_position == 5 ) {
 
 
85
  $this->create_table_braapf_variation_attributes();
86
- } elseif( $current_position == 7 ) {
87
- $this->create_table_braapf_term_taxonomy_hierarchical();
88
  } elseif( $current_position == 8 ) {
 
 
 
89
  if( class_exists('berocket_information_notices') ) {
90
  new berocket_information_notices(array(
91
  'name' => $this->plugin_name.'_additional_table_status_end',
@@ -156,6 +168,10 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
156
  }
157
  function get_global_status_ajax() {
158
  echo $this->get_current_global_status();
 
 
 
 
159
  wp_die();
160
  }
161
  function get_current_global_status($current_position = -1) {
@@ -175,7 +191,61 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
175
  $global_status = intval($global_status);
176
  return $global_status;
177
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  function create_table_braapf_product_stock_status_parent() {
 
 
 
 
 
 
 
 
179
  global $wpdb;
180
  $charset_collate = $wpdb->get_charset_collate();
181
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
@@ -183,46 +253,104 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
183
  $sql = "DROP TABLE IF EXISTS {$table_name};";
184
  $wpdb->query($sql);
185
  $sql = "CREATE TABLE $table_name (
186
- post_id BIGINT NOT NULL,
187
- parent_id BIGINT NOT NULL,
188
- stock_status TINYINT,
189
  PRIMARY KEY (post_id),
190
  INDEX stock_status (stock_status)
191
  ) $charset_collate;";
192
- dbDelta( $sql );
 
193
  $sql = "SELECT MIN({$wpdb->prefix}wc_product_meta_lookup.product_id) as min, MAX({$wpdb->prefix}wc_product_meta_lookup.product_id) as max FROM {$wpdb->prefix}wc_product_meta_lookup";
194
  $product_data = $wpdb->get_row($sql);
 
195
  $this->set_current_create_position_data(array('status' => 0));
196
  if( ! empty($product_data) && ! empty($product_data->min) && ! empty($product_data->max) ) {
197
- $this->set_current_create_position(2);
 
 
 
 
 
198
  $this->activate();
199
- wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_product_stock_status_parent', array($product_data->min, $product_data->min, $product_data->max) );
 
 
 
 
 
 
 
200
  } else {
201
- $this->set_current_create_position(3);
 
 
 
 
202
  $this->activate();
203
  }
204
  }
205
- function insert_table_braapf_product_stock_status_parent($start_id, $min_id, $max_id) {
 
 
 
 
 
 
 
 
 
206
  $end_id = $start_id + 5000;
 
 
 
 
207
  global $wpdb;
208
  $table_name = $wpdb->prefix . 'braapf_product_stock_status_parent';
209
  $charset_collate = $wpdb->get_charset_collate();
210
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
211
- $sql = "INSERT INTO {$table_name}
212
- 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
213
  JOIN {$wpdb->posts} ON {$wpdb->prefix}wc_product_meta_lookup.product_id = {$wpdb->posts}.ID
214
  WHERE {$wpdb->prefix}wc_product_meta_lookup.product_id >= {$start_id} AND {$wpdb->prefix}wc_product_meta_lookup.product_id < {$end_id}";
215
- $wpdb->query($sql);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  $status = max(0, min(100, (($end_id - $min_id) / ($max_id - $min_id) * 100)));
217
- $this->set_current_create_position_data(array('status' => $status));
 
 
 
 
 
 
218
  if( $end_id <= $max_id ) {
219
- wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_product_stock_status_parent', array($end_id, $min_id, $max_id) );
220
  } else {
221
- $this->set_current_create_position(3);
222
  $this->activate();
223
  }
224
  }
225
  function create_table_braapf_product_variation_attributes() {
 
 
 
 
 
 
 
 
226
  global $wpdb;
227
  $charset_collate = $wpdb->get_charset_collate();
228
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
@@ -230,43 +358,69 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
230
  $sql = "DROP TABLE IF EXISTS {$table_name};";
231
  $wpdb->query($sql);
232
  $sql = "CREATE TABLE $table_name (
233
- post_id BIGINT NOT NULL,
234
- parent_id BIGINT NOT NULL,
235
- meta_key VARCHAR(255) NOT NULL,
236
- meta_value_id BIGINT NOT NULL,
237
  INDEX post_id (post_id),
238
  INDEX meta_key (meta_key),
239
  INDEX meta_value_id (meta_value_id)
240
  ) $charset_collate;";
241
- dbDelta( $sql );
 
242
  $sql = "SELECT MIN({$wpdb->postmeta}.meta_id) as min, MAX({$wpdb->postmeta}.meta_id) as max FROM {$wpdb->postmeta}";
243
  $postmeta_data = $wpdb->get_row($sql);
244
  $this->set_current_create_position_data(array('status' => 0));
245
  if( ! empty($postmeta_data) && ! empty($postmeta_data->min) && ! empty($postmeta_data->max) ) {
246
- $this->set_current_create_position(4);
247
  $this->activate();
248
- wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_product_variation_attributes', array($postmeta_data->min, $postmeta_data->min, $postmeta_data->max) );
 
 
 
 
 
 
 
249
  } else {
250
- $this->set_current_create_position(5);
 
 
 
 
251
  $this->activate();
252
  }
253
  }
254
- function insert_table_braapf_product_variation_attributes($start_id, $min_id, $max_id) {
 
 
 
 
 
 
 
 
 
255
  $end_id = $start_id + 10000;
256
  global $wpdb;
257
  $table_name = $wpdb->prefix . 'braapf_product_variation_attributes';
258
  $charset_collate = $wpdb->get_charset_collate();
259
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
260
- $sql = "INSERT INTO {$table_name}
261
- 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}
262
  JOIN {$wpdb->term_taxonomy} ON CONCAT('attribute_', {$wpdb->term_taxonomy}.taxonomy) = {$wpdb->postmeta}.meta_key
263
  JOIN {$wpdb->terms} ON {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id AND {$wpdb->postmeta}.meta_value = {$wpdb->terms}.slug
264
  JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID
265
  WHERE {$wpdb->postmeta}.meta_id >= {$start_id} AND {$wpdb->postmeta}.meta_id < {$end_id}
266
  AND {$wpdb->postmeta}.meta_key LIKE 'attribute_pa_%'";
267
- $wpdb->query($sql);
268
- $sql = "INSERT INTO {$table_name}
269
- SELECT {$wpdb->posts}.ID as post_id, {$wpdb->posts}.post_parent as parent_id, {$wpdb->term_taxonomy}.taxonomy as meta_key, {$wpdb->term_taxonomy}.term_id as meta_value_id
 
 
 
 
 
 
270
  FROM {$wpdb->postmeta}
271
  JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID
272
  JOIN {$wpdb->term_relationships} ON {$wpdb->posts}.post_parent = {$wpdb->term_relationships}.object_id
@@ -274,17 +428,38 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
274
  AND CONCAT('attribute_', {$wpdb->term_taxonomy}.taxonomy) = {$wpdb->postmeta}.meta_key
275
  WHERE {$wpdb->postmeta}.meta_id >= {$start_id} AND {$wpdb->postmeta}.meta_id < {$end_id}
276
  AND {$wpdb->postmeta}.meta_key LIKE 'attribute_pa_%' AND {$wpdb->postmeta}.meta_value = ''";
277
- $wpdb->query($sql);
 
 
 
 
 
 
 
278
  $status = max(0, min(100, (($end_id - $min_id) / ($max_id - $min_id) * 100)));
279
- $this->set_current_create_position_data(array('status' => $status));
 
 
 
 
 
 
280
  if( $end_id <= $max_id ) {
281
- wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_product_variation_attributes', array($end_id, $min_id, $max_id) );
282
  } else {
283
- $this->set_current_create_position(5);
284
  $this->activate();
285
  }
286
  }
287
  function create_table_braapf_variation_attributes() {
 
 
 
 
 
 
 
 
288
  global $wpdb;
289
  $charset_collate = $wpdb->get_charset_collate();
290
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
@@ -292,49 +467,49 @@ class BeRocket_aapf_variations_tables_addon extends BeRocket_framework_addon_lib
292
  $sql = "DROP TABLE IF EXISTS {$table_name};";
293
  $wpdb->query($sql);
294
  $sql = "CREATE TABLE $table_name (
295
- post_id BIGINT(20) NOT NULL,
296
  taxonomy varchar(32) NOT NULL,
297
  INDEX post_id (post_id),
298
  INDEX taxonomy (taxonomy)
299
  ) $charset_collate;";
300
- dbDelta( $sql );
301
- $this->set_current_create_position_data(array('status' => 0));
302
- $this->set_current_create_position(6);
 
 
 
 
303
  $this->activate();
304
  wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_variation_attributes' );
305
  }
306
  function insert_table_braapf_variation_attributes() {
 
 
 
 
 
 
 
 
307
  global $wpdb;
308
  $table_name = $wpdb->prefix . 'braapf_variation_attributes';
309
  $charset_collate = $wpdb->get_charset_collate();
310
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
311
- $sql = "INSERT INTO {$table_name}
312
- SELECT parent_id as post_id, meta_key as taxonomy
313
  FROM {$wpdb->prefix}braapf_product_variation_attributes
314
  GROUP BY meta_key, parent_id";
315
- $wpdb->query($sql);
316
- $this->set_current_create_position_data(array('status' => 100));
317
- $this->set_current_create_position(7);
318
- $this->activate();
319
- }
320
- function create_table_braapf_term_taxonomy_hierarchical() {
321
- global $wpdb;
322
- $charset_collate = $wpdb->get_charset_collate();
323
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
324
- $table_name = $wpdb->prefix . 'braapf_term_taxonomy_hierarchical';
325
- $sql = "DROP TABLE IF EXISTS {$table_name};";
326
- $wpdb->query($sql);
327
- $sql = "CREATE TABLE $table_name (
328
- term_taxonomy_id BIGINT(20) NOT NULL,
329
- term_id BIGINT(20) NOT NULL,
330
- term_taxonomy_child_id BIGINT(20) NOT NULL,
331
- term_child_id BIGINT(20) NOT NULL,
332
- taxonomy varchar(32) NOT NULL,
333
- INDEX term_taxonomy_id (term_taxonomy_id),
334
- INDEX term_taxonomy_child_id (term_taxonomy_child_id),
335
- INDEX child_parent_id (term_taxonomy_id, term_taxonomy_child_id)
336
- ) $charset_collate;";
337
- dbDelta( $sql );
338
  $this->set_current_create_position(8);
339
  }
340
  function deactivate() {
9
  'percentage' => 1
10
  ),
11
  2 => array(
12
+ 'percentage' => 1
13
  ),
14
  3 => array(
15
+ 'percentage' => 13
16
  ),
17
  4 => array(
18
+ 'percentage' => 1
19
  ),
20
  5 => array(
21
+ 'percentage' => 80
22
  ),
23
  6 => array(
24
+ 'percentage' => 1
25
  ),
26
  7 => array(
27
+ 'percentage' => 2
28
  ),
29
  8 => array(
30
  'percentage' => 1
40
  if( in_array($this->addon_file, $active_addons) ) {
41
  if( $create_position < $this->last_postion ) {
42
  $this->activate();
43
+ $create_position = $this->get_current_create_position();
44
+ if( $create_position < $this->last_postion ) {
45
+ $this->activate_hooks();
46
+ }
47
  }
48
  } else {
49
  if( ! empty($create_position) ) {
76
  function set_current_create_position_data($data) {
77
  update_option('BeRocket_aapf_additional_tables_addon_position_data', $data);
78
  }
79
+ function activate($current_position = -1, $brajax = false) {
80
  if( $current_position == -1 ) {
81
  $current_position = $this->get_current_create_position();
82
  }
83
  if( empty($current_position) ) {
84
+ $this->create_table_braapf_term_taxonomy_hierarchical();
85
+ } elseif( $current_position == 2 ) {
86
  $this->create_table_braapf_product_stock_status_parent();
87
+ } elseif( $current_position == 3 && $brajax ) {
88
+ $this->insert_table_braapf_product_stock_status_parent();
89
+ } elseif( $current_position == 4 ) {
90
  $this->create_table_braapf_product_variation_attributes();
91
+ } elseif( $current_position == 5 && $brajax ) {
92
+ $this->insert_table_braapf_product_variation_attributes();
93
+ } elseif( $current_position == 6 ) {
94
  $this->create_table_braapf_variation_attributes();
95
+ } elseif( $current_position == 7 && $brajax ) {
96
+ $this->insert_table_braapf_variation_attributes();
97
  } elseif( $current_position == 8 ) {
98
+ wp_unschedule_hook('berocket_create_table_braapf_product_stock_status_parent');
99
+ wp_unschedule_hook('berocket_create_table_braapf_product_variation_attributes');
100
+ wp_unschedule_hook('berocket_create_table_braapf_variation_attributes');
101
  if( class_exists('berocket_information_notices') ) {
102
  new berocket_information_notices(array(
103
  'name' => $this->plugin_name.'_additional_table_status_end',
168
  }
169
  function get_global_status_ajax() {
170
  echo $this->get_current_global_status();
171
+ if ( function_exists( 'fastcgi_finish_request' ) && version_compare( phpversion(), '7.0.16', '>=' ) ) {
172
+ fastcgi_finish_request();
173
+ }
174
+ $this->activate(-1, true);
175
  wp_die();
176
  }
177
  function get_current_global_status($current_position = -1) {
191
  $global_status = intval($global_status);
192
  return $global_status;
193
  }
194
+ function save_query_error($query, $error = false) {
195
+ global $wpdb;
196
+ if( $error === false ) {
197
+ $error = $wpdb->last_error;
198
+ }
199
+ BeRocket_error_notices::add_plugin_error(1, 'Additional tables generation', array(
200
+ 'query' => $query,
201
+ 'error' => $error,
202
+ 'cron' => (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ? 'DISABLED' : 'ENABLED')
203
+ ));
204
+ }
205
+ function create_table_braapf_term_taxonomy_hierarchical() {
206
+ $run_data = $this->get_current_create_position_data();
207
+ if( ! empty($run_data) && ! empty($run_data['run']) ) {
208
+ return false;
209
+ }
210
+ $this->set_current_create_position_data(array(
211
+ 'status' => 0,
212
+ 'run' => true,
213
+ ));
214
+ $this->set_current_create_position_data($run_data);
215
+ global $wpdb;
216
+ $charset_collate = $wpdb->get_charset_collate();
217
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
218
+ $table_name = $wpdb->prefix . 'braapf_term_taxonomy_hierarchical';
219
+ $sql = "DROP TABLE IF EXISTS {$table_name};";
220
+ $wpdb->query($sql);
221
+ $sql = "CREATE TABLE $table_name (
222
+ term_taxonomy_id bigint(20) NOT NULL,
223
+ term_id bigint(20) NOT NULL,
224
+ term_taxonomy_child_id bigint(20) NOT NULL,
225
+ term_child_id bigint(20) NOT NULL,
226
+ taxonomy varchar(32) NOT NULL,
227
+ INDEX term_taxonomy_id (term_taxonomy_id),
228
+ INDEX term_taxonomy_child_id (term_taxonomy_child_id),
229
+ INDEX child_parent_id (term_taxonomy_id, term_taxonomy_child_id)
230
+ ) $charset_collate;";
231
+ $query_status = dbDelta( $sql );
232
+ $this->save_query_error($sql, $query_status);
233
+ $this->set_current_create_position_data(array(
234
+ 'status' => 0,
235
+ 'run' => false,
236
+ ));
237
+ $this->set_current_create_position(2);
238
+ $this->activate();
239
+ }
240
  function create_table_braapf_product_stock_status_parent() {
241
+ $run_data = $this->get_current_create_position_data();
242
+ if( ! empty($run_data) && ! empty($run_data['run']) ) {
243
+ return false;
244
+ }
245
+ $this->set_current_create_position_data(array(
246
+ 'status' => 0,
247
+ 'run' => true,
248
+ ));
249
  global $wpdb;
250
  $charset_collate = $wpdb->get_charset_collate();
251
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
253
  $sql = "DROP TABLE IF EXISTS {$table_name};";
254
  $wpdb->query($sql);
255
  $sql = "CREATE TABLE $table_name (
256
+ post_id bigint(20) NOT NULL,
257
+ parent_id bigint(20) NOT NULL,
258
+ stock_status tinyint(2),
259
  PRIMARY KEY (post_id),
260
  INDEX stock_status (stock_status)
261
  ) $charset_collate;";
262
+ $query_status = dbDelta( $sql );
263
+ $this->save_query_error($sql, $query_status);
264
  $sql = "SELECT MIN({$wpdb->prefix}wc_product_meta_lookup.product_id) as min, MAX({$wpdb->prefix}wc_product_meta_lookup.product_id) as max FROM {$wpdb->prefix}wc_product_meta_lookup";
265
  $product_data = $wpdb->get_row($sql);
266
+ $this->save_query_error($sql, $product_data);
267
  $this->set_current_create_position_data(array('status' => 0));
268
  if( ! empty($product_data) && ! empty($product_data->min) && ! empty($product_data->max) ) {
269
+ BeRocket_error_notices::add_plugin_error(1, 'SET CRON', array(
270
+ 'time' => (time()+1),
271
+ 'hook' => 'berocket_create_table_braapf_product_stock_status_parent',
272
+ 'var' => array($product_data->min, $product_data->min, $product_data->max)
273
+ ));
274
+ $this->set_current_create_position(3);
275
  $this->activate();
276
+ $this->set_current_create_position_data(array(
277
+ 'status' => 0,
278
+ 'run' => false,
279
+ 'start_id' => $product_data->min,
280
+ 'min_id' => $product_data->min,
281
+ 'max_id' => $product_data->max
282
+ ));
283
+ wp_schedule_single_event( time(), 'berocket_create_table_braapf_product_stock_status_parent' );
284
  } else {
285
+ $this->set_current_create_position_data(array(
286
+ 'status' => 0,
287
+ 'run' => false,
288
+ ));
289
+ $this->set_current_create_position(4);
290
  $this->activate();
291
  }
292
  }
293
+ function insert_table_braapf_product_stock_status_parent() {
294
+ $run_data = $this->get_current_create_position_data();
295
+ if( empty($run_data) || ! empty($run_data['run']) ) {
296
+ return false;
297
+ }
298
+ $run_data['run'] = true;
299
+ $this->set_current_create_position_data($run_data);
300
+ $start_id = $run_data['start_id'];
301
+ $min_id = $run_data['min_id'];
302
+ $max_id = $run_data['max_id'];
303
  $end_id = $start_id + 5000;
304
+ BeRocket_error_notices::add_plugin_error(1, 'insert_table_braapf_product_stock_status_parent', array(
305
+ 'start_id' => $start_id,
306
+ 'end_id' => $end_id,
307
+ ));
308
  global $wpdb;
309
  $table_name = $wpdb->prefix . 'braapf_product_stock_status_parent';
310
  $charset_collate = $wpdb->get_charset_collate();
311
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
312
+ $sql_select = "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
 
313
  JOIN {$wpdb->posts} ON {$wpdb->prefix}wc_product_meta_lookup.product_id = {$wpdb->posts}.ID
314
  WHERE {$wpdb->prefix}wc_product_meta_lookup.product_id >= {$start_id} AND {$wpdb->prefix}wc_product_meta_lookup.product_id < {$end_id}";
315
+ $test_row = $wpdb->get_row($sql_select);
316
+ BeRocket_error_notices::add_plugin_error(1, 'insert_table_braapf_product_stock_status_parent test', array(
317
+ 'start_id' => $start_id,
318
+ 'end_id' => $end_id,
319
+ 'min_id' => $min_id,
320
+ 'max_id' => $max_id,
321
+ 'result' => $test_row,
322
+ ));
323
+ if( ! empty($test_row) ) {
324
+ $sql = "INSERT INTO {$table_name} {$sql_select}";
325
+ $query_status = $wpdb->query($sql);
326
+ if( $query_status === FALSE ) {
327
+ $this->save_query_error($sql);
328
+ }
329
+ }
330
  $status = max(0, min(100, (($end_id - $min_id) / ($max_id - $min_id) * 100)));
331
+ $this->set_current_create_position_data(array(
332
+ 'status' => $status,
333
+ 'run' => false,
334
+ 'start_id' => $end_id,
335
+ 'min_id' => $min_id,
336
+ 'max_id' => $max_id
337
+ ));
338
  if( $end_id <= $max_id ) {
339
+ wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_product_stock_status_parent' );
340
  } else {
341
+ $this->set_current_create_position(4);
342
  $this->activate();
343
  }
344
  }
345
  function create_table_braapf_product_variation_attributes() {
346
+ $run_data = $this->get_current_create_position_data();
347
+ if( ! empty($run_data) && ! empty($run_data['run']) ) {
348
+ return false;
349
+ }
350
+ $this->set_current_create_position_data(array(
351
+ 'status' => 0,
352
+ 'run' => true,
353
+ ));
354
  global $wpdb;
355
  $charset_collate = $wpdb->get_charset_collate();
356
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
358
  $sql = "DROP TABLE IF EXISTS {$table_name};";
359
  $wpdb->query($sql);
360
  $sql = "CREATE TABLE $table_name (
361
+ post_id bigint(20) NOT NULL,
362
+ parent_id bigint(20) NOT NULL,
363
+ meta_key varchar(255) NOT NULL,
364
+ meta_value_id bigint(20) NOT NULL,
365
  INDEX post_id (post_id),
366
  INDEX meta_key (meta_key),
367
  INDEX meta_value_id (meta_value_id)
368
  ) $charset_collate;";
369
+ $query_status = dbDelta( $sql );
370
+ $this->save_query_error($sql, $query_status);
371
  $sql = "SELECT MIN({$wpdb->postmeta}.meta_id) as min, MAX({$wpdb->postmeta}.meta_id) as max FROM {$wpdb->postmeta}";
372
  $postmeta_data = $wpdb->get_row($sql);
373
  $this->set_current_create_position_data(array('status' => 0));
374
  if( ! empty($postmeta_data) && ! empty($postmeta_data->min) && ! empty($postmeta_data->max) ) {
375
+ $this->set_current_create_position(5);
376
  $this->activate();
377
+ $this->set_current_create_position_data(array(
378
+ 'status' => 0,
379
+ 'run' => false,
380
+ 'start_id' => $postmeta_data->min,
381
+ 'min_id' => $postmeta_data->min,
382
+ 'max_id' => $postmeta_data->max
383
+ ));
384
+ wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_product_variation_attributes' );
385
  } else {
386
+ $this->set_current_create_position_data(array(
387
+ 'status' => 0,
388
+ 'run' => false,
389
+ ));
390
+ $this->set_current_create_position(6);
391
  $this->activate();
392
  }
393
  }
394
+ function insert_table_braapf_product_variation_attributes() {
395
+ $run_data = $this->get_current_create_position_data();
396
+ if( empty($run_data) || ! empty($run_data['run']) ) {
397
+ return false;
398
+ }
399
+ $run_data['run'] = true;
400
+ $this->set_current_create_position_data($run_data);
401
+ $start_id = $run_data['start_id'];
402
+ $min_id = $run_data['min_id'];
403
+ $max_id = $run_data['max_id'];
404
  $end_id = $start_id + 10000;
405
  global $wpdb;
406
  $table_name = $wpdb->prefix . 'braapf_product_variation_attributes';
407
  $charset_collate = $wpdb->get_charset_collate();
408
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
409
+ $sql_select = "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}
 
410
  JOIN {$wpdb->term_taxonomy} ON CONCAT('attribute_', {$wpdb->term_taxonomy}.taxonomy) = {$wpdb->postmeta}.meta_key
411
  JOIN {$wpdb->terms} ON {$wpdb->terms}.term_id = {$wpdb->term_taxonomy}.term_id AND {$wpdb->postmeta}.meta_value = {$wpdb->terms}.slug
412
  JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID
413
  WHERE {$wpdb->postmeta}.meta_id >= {$start_id} AND {$wpdb->postmeta}.meta_id < {$end_id}
414
  AND {$wpdb->postmeta}.meta_key LIKE 'attribute_pa_%'";
415
+ $test_row = $wpdb->get_row($sql_select);
416
+ if( ! empty($test_row) ) {
417
+ $sql = "INSERT INTO {$table_name} {$sql_select}";
418
+ $query_status = $wpdb->query($sql);
419
+ if( $query_status === FALSE ) {
420
+ $this->save_query_error($sql);
421
+ }
422
+ }
423
+ $sql_select = "SELECT {$wpdb->posts}.ID as post_id, {$wpdb->posts}.post_parent as parent_id, {$wpdb->term_taxonomy}.taxonomy as meta_key, {$wpdb->term_taxonomy}.term_id as meta_value_id
424
  FROM {$wpdb->postmeta}
425
  JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID
426
  JOIN {$wpdb->term_relationships} ON {$wpdb->posts}.post_parent = {$wpdb->term_relationships}.object_id
428
  AND CONCAT('attribute_', {$wpdb->term_taxonomy}.taxonomy) = {$wpdb->postmeta}.meta_key
429
  WHERE {$wpdb->postmeta}.meta_id >= {$start_id} AND {$wpdb->postmeta}.meta_id < {$end_id}
430
  AND {$wpdb->postmeta}.meta_key LIKE 'attribute_pa_%' AND {$wpdb->postmeta}.meta_value = ''";
431
+ $test_row = $wpdb->get_row($sql_select);
432
+ if( ! empty($test_row) ) {
433
+ $sql = "INSERT INTO {$table_name} {$sql_select}";
434
+ $query_status = $wpdb->query($sql);
435
+ if( $query_status === FALSE ) {
436
+ $this->save_query_error($sql);
437
+ }
438
+ }
439
  $status = max(0, min(100, (($end_id - $min_id) / ($max_id - $min_id) * 100)));
440
+ $this->set_current_create_position_data(array(
441
+ 'status' => $status,
442
+ 'run' => false,
443
+ 'start_id' => $end_id,
444
+ 'min_id' => $min_id,
445
+ 'max_id' => $max_id
446
+ ));
447
  if( $end_id <= $max_id ) {
448
+ wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_product_variation_attributes' );
449
  } else {
450
+ $this->set_current_create_position(6);
451
  $this->activate();
452
  }
453
  }
454
  function create_table_braapf_variation_attributes() {
455
+ $run_data = $this->get_current_create_position_data();
456
+ if( ! empty($run_data) && ! empty($run_data['run']) ) {
457
+ return false;
458
+ }
459
+ $this->set_current_create_position_data(array(
460
+ 'status' => 0,
461
+ 'run' => true,
462
+ ));
463
  global $wpdb;
464
  $charset_collate = $wpdb->get_charset_collate();
465
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
467
  $sql = "DROP TABLE IF EXISTS {$table_name};";
468
  $wpdb->query($sql);
469
  $sql = "CREATE TABLE $table_name (
470
+ post_id bigint(20) NOT NULL,
471
  taxonomy varchar(32) NOT NULL,
472
  INDEX post_id (post_id),
473
  INDEX taxonomy (taxonomy)
474
  ) $charset_collate;";
475
+ $query_status = dbDelta( $sql );
476
+ $this->save_query_error($sql, $query_status);
477
+ $this->set_current_create_position_data(array(
478
+ 'status' => 0,
479
+ 'run' => false,
480
+ ));
481
+ $this->set_current_create_position(7);
482
  $this->activate();
483
  wp_schedule_single_event( (time()+1), 'berocket_create_table_braapf_variation_attributes' );
484
  }
485
  function insert_table_braapf_variation_attributes() {
486
+ $run_data = $this->get_current_create_position_data();
487
+ if( ! empty($run_data) && ! empty($run_data['run']) ) {
488
+ return false;
489
+ }
490
+ $this->set_current_create_position_data(array(
491
+ 'status' => 0,
492
+ 'run' => true,
493
+ ));
494
  global $wpdb;
495
  $table_name = $wpdb->prefix . 'braapf_variation_attributes';
496
  $charset_collate = $wpdb->get_charset_collate();
497
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
498
+ $sql_select = "SELECT parent_id as post_id, meta_key as taxonomy
 
499
  FROM {$wpdb->prefix}braapf_product_variation_attributes
500
  GROUP BY meta_key, parent_id";
501
+ $test_row = $wpdb->get_row($sql_select);
502
+ if( ! empty($test_row) ) {
503
+ $sql = "INSERT INTO {$table_name} {$sql_select}";
504
+ $query_status = $wpdb->query($sql);
505
+ if( $query_status === FALSE ) {
506
+ $this->save_query_error($sql);
507
+ }
508
+ }
509
+ $this->set_current_create_position_data(array(
510
+ 'status' => 100,
511
+ 'run' => false,
512
+ ));
 
 
 
 
 
 
 
 
 
 
 
513
  $this->set_current_create_position(8);
514
  }
515
  function deactivate() {
berocket/assets/popup/br_popup.css CHANGED
@@ -73,7 +73,8 @@ body.hide_scroll {
73
  #br_popup .br_popup_close:hover {
74
  opacity: 0.80;
75
  }
76
- #br_popup.counting .br_popup_close {
 
77
  display: none;
78
  }
79
  #br_popup .counters.after_close {
73
  #br_popup .br_popup_close:hover {
74
  opacity: 0.80;
75
  }
76
+ #br_popup.counting .br_popup_close,
77
+ #br_popup.cannot_be_closed .br_popup_close {
78
  display: none;
79
  }
80
  #br_popup .counters.after_close {
berocket/assets/popup/br_popup.js CHANGED
@@ -16,115 +16,150 @@
16
  }
17
  };
18
  this.reset_option = function () {
19
- var popup_data = {timer_interval: undefined, close_delay: undefined, can_close_popup: true, opened:false};
20
  this.data('br_popup_data', popup_data);
 
21
  };
22
  this.create_popup = function() {
23
  var settings = this.data('br_popup_settings');
24
- $header = settings.title;
25
 
26
- $popup_html = '<div id="br_popup" class="br_popup animated';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  if ( settings.theme != 'default' && settings.theme != '' ) {
28
- $popup_html += ' ' + settings.theme;
29
  }
30
- $popup_html += '"><div class="br_popup_wrapper" style="';
31
- if ( settings.width ) {
32
- $popup_html += 'width: '+settings.width+';';
33
- }
34
- if ( settings.height ) {
35
- $popup_html += 'height: '+settings.height+';';
36
- }
37
-
38
- $popup_html += '"><div class="animated popup_animation';
39
- if ( settings.yes_no_buttons.show == true
 
 
 
 
 
 
 
40
  && settings.yes_no_buttons.custom == false
41
  && settings.yes_no_buttons.location == 'popup'
42
  || settings.print_button == true
43
  ) {
44
- $popup_html += ' with_yes_no_buttons';
45
- }
46
- $popup_html += ' yes_no_buttons_'+settings.yes_no_buttons.align;
47
- if ( $header != '' ) {
48
- $popup_html += ' with_header';
49
- }
50
  if ( settings.print_button == true ) {
51
- $popup_html += ' with_print_button';
52
  }
53
- $popup_html += '">';
54
-
55
- if ( settings.no_x_button == false ) {
56
- $popup_html += '<a href="#" class="br_popup_close">×</a>';
57
- }
58
-
59
- if ( settings.close_delay * 1 > 0 ) {
60
- $popup_html += '<span class="counters after_close"><span>' + ( settings.close_delay * 1 ) + '</span> second(s) before close</span>';
61
- }
62
-
63
- if ( $header != '' ) {
64
- $popup_html += '<div class="br_popup_header popup_header_' + settings.header_align + '">' + $header + '</div>';
65
  }
66
-
67
- $popup_html += '<div class="br_popup_inner">';
68
- if (
69
- ( settings.yes_no_buttons.show == true
70
- && settings.yes_no_buttons.custom == false
71
- || settings.print_button == true
72
- )
73
- && settings.yes_no_buttons.location == 'content'
74
- ) {
75
- $popup_html += '<div class="br_popup_buttons">';
76
- if ( settings.yes_no_buttons.show == true && settings.yes_no_buttons.custom == false ) {
77
- $popup_html += '<a href="' + settings.yes_no_buttons.yes_text + '" class="br_yes_button ' +
78
- settings.yes_no_buttons.yes_classes + '">' + settings.yes_no_buttons.yes_text + '</a><a href="' +
79
- settings.yes_no_buttons.no_text + '" class="br_no_button ' + settings.yes_no_buttons.no_classes + '">' +
80
- settings.yes_no_buttons.no_text + '</a>';
81
- }
82
- if ( settings.print_button == true ) {
83
- $popup_html += '<a href="Print" class="print_button">Print</a>';
84
- }
85
- $popup_html += '</div>';
86
- }
87
- $popup_html += '</div>';
88
-
89
- if (
90
- ( settings.yes_no_buttons.show == true
91
- && settings.yes_no_buttons.custom == false
92
- || settings.print_button == true
93
- )
94
- && settings.yes_no_buttons.location == 'popup'
95
- ) {
96
- $popup_html += '<div class="br_popup_buttons">';
97
- if ( settings.yes_no_buttons.show == true && settings.yes_no_buttons.custom == false ) {
98
- $popup_html += '<a href="' + settings.yes_no_buttons.yes_text +'" class="br_yes_button ' +
99
- settings.yes_no_buttons.yes_classes + '">' + settings.yes_no_buttons.yes_text + '</a><a href="' +
100
- settings.yes_no_buttons.no_text +'" class="br_no_button ' +
101
- settings.yes_no_buttons.no_classes + '">' + settings.yes_no_buttons.no_text + '</a>';
102
- }
103
- if ( settings.print_button == true ) {
104
- $popup_html += '<a href="Print" class="print_button">Print</a>';
105
  }
106
- $popup_html += '</div>';
107
- }
108
-
109
- $popup_html += '</div></div>';
110
-
111
- if ( settings.no_overlay == false ) {
112
- $popup_html += '<div class="br_popup_overlay"></div>';
113
- }
114
-
115
- $popup_html += '</div>';
116
- $popup_html = $($popup_html);
117
- $popup_html.appendTo('body');
118
- $popup_html.data('br_popup_main', this);
119
- this.data('br_popup_object', $popup_html);
120
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  this.add_content = function() {
122
  var settings = this.data('br_popup_settings');
123
  if( settings.content ) {
124
  this.data('br_popup_object').find('.br_popup_inner').prepend( settings.content );
125
  } else {
126
  this.data('br_popup_object').find('.br_popup_inner').prepend( this.html() );
127
- }
 
128
  };
129
  this.add_events = function() {
130
  var settings = this.data('br_popup_settings');
@@ -205,11 +240,12 @@
205
  $this.print();
206
  });
207
  }
 
208
  };
209
  this.show_popup = function() {
210
  var settings = this.data('br_popup_settings');
211
  var popup_data = this.data('br_popup_data');
212
- if ( this.data('br_popup_object') && this.data('br_popup_object').is(':hidden') ) {
213
  var $this = this;
214
  popup_data.opened = true;
215
 
@@ -219,31 +255,66 @@
219
  $('body').addClass('hide_scroll');
220
  }
221
 
222
- jQuery(this).trigger('br_popup-show_popup', this);
223
- this.data('br_popup_object').css({display:'block'});
224
- this.animateCss(this.data('br_popup_object'), 'fadeIn');
225
- this.animateCss(this.data('br_popup_object').find('.popup_animation'), 'fadeInDown');
226
-
227
- if ( settings.close_delay * 1 > 0 ) {
228
- this.data('br_popup_object').addClass('counting');
229
- popup_data.can_close_popup = false;
230
-
231
- popup_data.close_delay = settings.close_delay * 1 - 1;
232
- popup_data.timer_interval = setInterval(function (){
233
- if ( popup_data.close_delay <= 0 ) {
234
- popup_data.can_close_popup = true;
235
- clearInterval(popup_data.timer_interval);
236
- $this.data('br_popup_object').removeClass('counting');
237
- } else {
238
- $this.data('br_popup_object').find('.counters span').text(popup_data.close_delay);
239
- }
240
- popup_data.close_delay--;
241
- $this.data('br_popup_data', popup_data);
242
- }, 1000);
243
- }
244
  this.data('br_popup_data', popup_data);
245
- }
246
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  this.hide_popup = function () {
248
  var $this = this;
249
  var popup_data = this.data('br_popup_data');
16
  }
17
  };
18
  this.reset_option = function () {
19
+ var popup_data = {timer_interval: undefined, close_delay: undefined, can_close_popup: true, opened:false, can_close_popup_count:0};
20
  this.data('br_popup_data', popup_data);
21
+ jQuery(this).trigger('br_popup-after_reset_option', this);
22
  };
23
  this.create_popup = function() {
24
  var settings = this.data('br_popup_settings');
 
25
 
26
+ $popup_html = '<div id="br_popup" class="br_popup animated'+this.builder.popup_class(settings)+'" style="'+this.builder.popup_style(settings)+'">';
27
+ $popup_html += '<div class="br_popup_wrapper'+this.builder.popup_wrapper_class(settings)+'" style="'+this.builder.popup_wrapper_style(settings)+'">';
28
+ $popup_html += '<div class="animated popup_animation'+this.builder.popup_animation_class(settings)+'">';
29
+
30
+ $popup_html += this.builder.close_button(settings);
31
+ $popup_html += this.builder.close_delay(settings);
32
+ $popup_html += this.builder.header_title(settings);
33
+
34
+ $popup_html += '<div class="br_popup_inner">';
35
+ if (
36
+ ( settings.yes_no_buttons.show == true
37
+ && settings.yes_no_buttons.custom == false
38
+ || settings.print_button == true
39
+ )
40
+ && settings.yes_no_buttons.location == 'content'
41
+ ) {
42
+ $popup_html += '<div class="br_popup_buttons">';
43
+ $popup_html += this.builder.buttons(settings);
44
+ $popup_html += '</div>';
45
+ }
46
+ $popup_html += '</div>';
47
+
48
+ if (
49
+ ( settings.yes_no_buttons.show == true
50
+ && settings.yes_no_buttons.custom == false
51
+ || settings.print_button == true
52
+ )
53
+ && settings.yes_no_buttons.location == 'popup'
54
+ ) {
55
+ $popup_html += '<div class="br_popup_buttons">';
56
+ $popup_html += this.builder.buttons(settings);
57
+ $popup_html += '</div>';
58
+ }
59
+
60
+ $popup_html += '</div></div>';
61
+
62
+ if ( settings.no_overlay == false ) {
63
+ $popup_html += '<div class="br_popup_overlay"></div>';
64
+ }
65
+
66
+ $popup_html += '</div>';
67
+ $popup_html = $($popup_html);
68
+ $popup_html.appendTo('body');
69
+ $popup_html.data('br_popup_main', this);
70
+ this.data('br_popup_object', $popup_html);
71
+ jQuery(this).trigger('br_popup-after_create_popup', this);
72
+ };
73
+ this.builder = {
74
+ popup_class: function(settings) {
75
+ var text = '';
76
  if ( settings.theme != 'default' && settings.theme != '' ) {
77
+ text += ' ' + settings.theme;
78
  }
79
+ return text;
80
+ },
81
+ popup_style: function(settings) {return '';},
82
+ popup_wrapper_class: function(settings) {return '';},
83
+ popup_wrapper_style: function(settings) {
84
+ var text = '';
85
+ if ( settings.width ) {
86
+ text += 'width: '+settings.width+';';
87
+ }
88
+ if ( settings.height ) {
89
+ text += 'height: '+settings.height+';';
90
+ }
91
+ return text;
92
+ },
93
+ popup_animation_class: function(settings) {
94
+ var text = '';
95
+ if ( settings.yes_no_buttons.show == true
96
  && settings.yes_no_buttons.custom == false
97
  && settings.yes_no_buttons.location == 'popup'
98
  || settings.print_button == true
99
  ) {
100
+ text += ' with_yes_no_buttons';
101
+ }
102
+ text += ' yes_no_buttons_'+settings.yes_no_buttons.align;
103
+ if ( settings.title && settings.title != '' ) {
104
+ text += ' with_header';
105
+ }
106
  if ( settings.print_button == true ) {
107
+ text += ' with_print_button';
108
  }
109
+ return text;
110
+ },
111
+ close_button: function(settings) {
112
+ var text = '';
113
+ if ( settings.no_x_button == false ) {
114
+ text += '<a href="#" class="br_popup_close">×</a>';
 
 
 
 
 
 
115
  }
116
+ return text;
117
+ },
118
+ close_delay: function(settings) {
119
+ var text = '';
120
+ if ( settings.close_delay * 1 > 0 ) {
121
+ var close_delay_text = '%s second(s) before close';
122
+ if( settings.close_delay_text && (typeof(settings.close_delay_text) === 'string' || settings.close_delay_text instanceof String) ) {
123
+ close_delay_text = settings.close_delay_text;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
+ close_delay_text = close_delay_text.replace('%s', '<span>' + ( settings.close_delay * 1 ) + '</span>');
126
+ text += '<span class="counters after_close">'+close_delay_text+'</span>';
127
+ }
128
+ return text;
129
+ },
130
+ header_title: function(settings) {
131
+ var text = '';
132
+ if ( settings.title && settings.title != '' ) {
133
+ text += '<div class="br_popup_header popup_header_' + settings.header_align + '">' + settings.title + '</div>';
134
+ }
135
+ return text;
136
+ },
137
+ buttons: function(settings) {
138
+ var text = '';
139
+ if ( settings.yes_no_buttons.show == true && settings.yes_no_buttons.custom == false ) {
140
+ text += '<a href="' + settings.yes_no_buttons.yes_text + '" '
141
+ + 'class="br_yes_button ' + settings.yes_no_buttons.yes_classes + '">'
142
+ + settings.yes_no_buttons.yes_text
143
+ + '</a>';
144
+ text += '<a href="' + settings.yes_no_buttons.no_text + '" '
145
+ + 'class="br_no_button ' +settings.yes_no_buttons.no_classes + '">'
146
+ + settings.yes_no_buttons.no_text
147
+ + '</a>';
148
+ }
149
+ if ( settings.print_button == true ) {
150
+ text += '<a href="Print" class="print_button">Print</a>';
151
+ }
152
+ return text;
153
+ }
154
+ };
155
  this.add_content = function() {
156
  var settings = this.data('br_popup_settings');
157
  if( settings.content ) {
158
  this.data('br_popup_object').find('.br_popup_inner').prepend( settings.content );
159
  } else {
160
  this.data('br_popup_object').find('.br_popup_inner').prepend( this.html() );
161
+ }
162
+ jQuery(this).trigger('br_popup-after_add_content', this);
163
  };
164
  this.add_events = function() {
165
  var settings = this.data('br_popup_settings');
240
  $this.print();
241
  });
242
  }
243
+ jQuery(this).trigger('br_popup-after_add_events', this);
244
  };
245
  this.show_popup = function() {
246
  var settings = this.data('br_popup_settings');
247
  var popup_data = this.data('br_popup_data');
248
+ if ( this.data('br_popup_object') && this.data('br_popup_object').is(':hidden') ) {
249
  var $this = this;
250
  popup_data.opened = true;
251
 
255
  $('body').addClass('hide_scroll');
256
  }
257
 
258
+ this.data('br_popup_object').css({display:'block'});
259
+ this.animateCss(this.data('br_popup_object'), 'fadeIn');
260
+ this.animateCss(this.data('br_popup_object').find('.popup_animation'), 'fadeInDown');
261
+ popup_data = this.set_close_delay(popup_data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  this.data('br_popup_data', popup_data);
263
+ jQuery(this).trigger('br_popup-show_popup', this);
264
+ }
265
+ };
266
+ this.set_close_delay = function (popup_data, close_delay_sec) {
267
+ var settings = this.data('br_popup_settings');
268
+ var $this = this;
269
+ if( typeof(popup_data) == 'undefined' || ! popup_data ) {
270
+ popup_data = this.data('br_popup_data');
271
+ }
272
+ if( typeof(close_delay_sec) == 'undefined' || ! close_delay_sec ) {
273
+ close_delay_sec = settings.close_delay;
274
+ }
275
+ if ( close_delay_sec * 1 > 0 ) {
276
+ this.data('br_popup_object').addClass('counting');
277
+ this.disable_close();
278
+
279
+ popup_data.close_delay = close_delay_sec * 1 - 1;
280
+ popup_data.timer_interval = setInterval(function (){
281
+ if ( popup_data.close_delay <= 0 ) {
282
+ $this.enable_close();
283
+ clearInterval(popup_data.timer_interval);
284
+ $this.data('br_popup_object').removeClass('counting');
285
+ } else {
286
+ $this.data('br_popup_object').find('.counters span').text(popup_data.close_delay);
287
+ }
288
+ popup_data.close_delay--;
289
+ $this.data('br_popup_data', popup_data);
290
+ }, 1000);
291
+ }
292
+ this.data('br_popup_data', popup_data);
293
+ return popup_data;
294
+ }
295
+ this.disable_close = function (popup_data) {
296
+ if( typeof(popup_data) == 'undefined' || ! popup_data ) {
297
+ popup_data = this.data('br_popup_data');
298
+ }
299
+ popup_data.can_close_popup = false;
300
+ popup_data.can_close_popup_count = popup_data.can_close_popup_count*1 + 1;
301
+ this.data('br_popup_object').addClass('cannot_be_closed');
302
+ this.data('br_popup_data', popup_data);
303
+ return popup_data;
304
+ }
305
+ this.enable_close = function (popup_data) {
306
+ if( typeof(popup_data) == 'undefined' || ! popup_data ) {
307
+ popup_data = this.data('br_popup_data');
308
+ }
309
+ popup_data.can_close_popup_count = popup_data.can_close_popup_count*1 - 1;
310
+ if( popup_data.can_close_popup_count <= 0 ) {
311
+ popup_data.can_close_popup_count = 0;
312
+ popup_data.can_close_popup = true;
313
+ this.data('br_popup_object').removeClass('cannot_be_closed');
314
+ }
315
+ this.data('br_popup_data', popup_data);
316
+ return popup_data;
317
+ }
318
  this.hide_popup = function () {
319
  var $this = this;
320
  var popup_data = this.data('br_popup_data');
berocket/framework.php CHANGED
@@ -35,7 +35,7 @@ if( ! class_exists( 'BeRocket_Framework' ) ) {
35
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
36
  load_plugin_textdomain('BeRocket_domain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
37
  class BeRocket_Framework {
38
- public static $framework_version = '2.5.5.2';
39
  public static $settings_name = '';
40
  public $addons;
41
  public $libraries;
35
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
36
  load_plugin_textdomain('BeRocket_domain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
37
  class BeRocket_Framework {
38
+ public static $framework_version = '2.5.5.3';
39
  public static $settings_name = '';
40
  public $addons;
41
  public $libraries;
berocket/framework_version.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- $framework_version_current = '2.5.5.2';
3
  if( version_compare($framework_version_current, $framework_version, '>') ) {
4
  $framework_version = $framework_version_current;
5
  $framework_dir = __DIR__;
1
  <?php
2
+ $framework_version_current = '2.5.5.3';
3
  if( version_compare($framework_version_current, $framework_version, '>') ) {
4
  $framework_version = $framework_version_current;
5
  $framework_dir = __DIR__;
includes/addons/woocommerce-variation.php CHANGED
@@ -72,8 +72,8 @@ class BeRocket_AAPF_compat_woocommerce_variation {
72
  }
73
  $current_terms = array_unique($current_terms);
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',
@@ -128,7 +128,11 @@ class BeRocket_AAPF_compat_woocommerce_variation {
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 = br_get_cache(apply_filters('berocket_variation_cache_key', md5($query)), 'berocket_variation');
133
  if( empty($out_of_stock_variable) ) {
134
  $out_of_stock_variable = $wpdb->get_results( $query, ARRAY_N );
72
  }
73
  $current_terms = array_unique($current_terms);
74
  $current_attributes = array_unique($current_attributes);
75
+ $current_terms = null;
76
+ $current_attributes = null;
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',
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 = str_replace(
132
+ array( '%1$s', '%2$s', '%3$s', '%4$s', '%5$s' ),
133
+ array( $wpdb->posts, $wpdb->postmeta, $wpdb->term_relationships, $current_attributes, $current_terms ),
134
+ $query
135
+ );
136
  $out_of_stock_variable = br_get_cache(apply_filters('berocket_variation_cache_key', md5($query)), 'berocket_variation');
137
  if( empty($out_of_stock_variable) ) {
138
  $out_of_stock_variable = $wpdb->get_results( $query, ARRAY_N );
js/widget.min.js CHANGED
@@ -1295,40 +1295,42 @@ var berocket_aapf_widget_product_filters = [],
1295
  }
1296
  }
1297
  // Take control over (default) pagination and sorting, make it AJAXy and work with filters
1298
- $(document).on('click', the_ajax_script.pagination_class+' a', function (event) {
1299
- var permalink_page = /\/page\/(\d+)/;
1300
- var non_permalink_page = /paged=(\d+)/;
1301
- var href = $(this).attr('href');
1302
- if( permalink_page.test(href) ) {
1303
- _next_page = href.match(permalink_page);
1304
- _next_page = _next_page[1];
1305
- } else if( non_permalink_page.test(href) ) {
1306
- _next_page = href.match(non_permalink_page);
1307
- _next_page = _next_page[1];
1308
- } else if ( $(this).hasClass('next') || $(this).parent().hasClass('next') ) {
1309
- _next_page = $(the_ajax_script.pagination_class+' .current').first().text();
1310
- _next_page = _next_page.replace(/\D/g,'');
1311
- _next_page = parseInt( _next_page ) + 1;
1312
- } else if ( $(this).hasClass('prev') || $(this).parent().hasClass('prev') ) {
1313
- _next_page = $(the_ajax_script.pagination_class+' .current').first().text();
1314
- _next_page = _next_page.replace(/\D/g,'');
1315
- _next_page = parseInt( _next_page ) - 1;
1316
- } else {
1317
- _next_page = $(this).text();
1318
- _next_page = _next_page.replace(/\D/g,'');
1319
- _next_page = parseInt(_next_page);
1320
- }
1321
- if( typeof(_next_page) == 'undefined' || _next_page <= 0 ) {
1322
- _next_page = 1;
1323
- }
1324
- event.preventDefault();
1325
- $(the_ajax_script.pagination_class+' .current').removeClass('current');
1326
- $(this).after("<span class='page-numbers current' style='display:none;'>"+_next_page+"</span>");
1327
- if( the_ajax_script.first_page ) {
1328
- berocket_aapf_widget_first_page_jump = false;
1329
- }
1330
- updateProducts(true);
1331
- });
 
 
1332
 
1333
  function in_array(needle, haystack, strict) {
1334
  var found = false, key, strict = !!strict;
1295
  }
1296
  }
1297
  // Take control over (default) pagination and sorting, make it AJAXy and work with filters
1298
+ if( ! the_ajax_script.woocommerce_removes.pagination_ajax ) {
1299
+ $(document).on('click', the_ajax_script.pagination_class+' a', function (event) {
1300
+ var permalink_page = /\/page\/(\d+)/;
1301
+ var non_permalink_page = /paged=(\d+)/;
1302
+ var href = $(this).attr('href');
1303
+ if( permalink_page.test(href) ) {
1304
+ _next_page = href.match(permalink_page);
1305
+ _next_page = _next_page[1];
1306
+ } else if( non_permalink_page.test(href) ) {
1307
+ _next_page = href.match(non_permalink_page);
1308
+ _next_page = _next_page[1];
1309
+ } else if ( $(this).hasClass('next') || $(this).parent().hasClass('next') ) {
1310
+ _next_page = $(the_ajax_script.pagination_class+' .current').first().text();
1311
+ _next_page = _next_page.replace(/\D/g,'');
1312
+ _next_page = parseInt( _next_page ) + 1;
1313
+ } else if ( $(this).hasClass('prev') || $(this).parent().hasClass('prev') ) {
1314
+ _next_page = $(the_ajax_script.pagination_class+' .current').first().text();
1315
+ _next_page = _next_page.replace(/\D/g,'');
1316
+ _next_page = parseInt( _next_page ) - 1;
1317
+ } else {
1318
+ _next_page = $(this).text();
1319
+ _next_page = _next_page.replace(/\D/g,'');
1320
+ _next_page = parseInt(_next_page);
1321
+ }
1322
+ if( typeof(_next_page) == 'undefined' || _next_page <= 0 ) {
1323
+ _next_page = 1;
1324
+ }
1325
+ event.preventDefault();
1326
+ $(the_ajax_script.pagination_class+' .current').removeClass('current');
1327
+ $(this).after("<span class='page-numbers current' style='display:none;'>"+_next_page+"</span>");
1328
+ if( the_ajax_script.first_page ) {
1329
+ berocket_aapf_widget_first_page_jump = false;
1330
+ }
1331
+ updateProducts(true);
1332
+ });
1333
+ }
1334
 
1335
  function in_array(needle, haystack, strict) {
1336
  var found = false, key, strict = !!strict;
main.php CHANGED
@@ -80,6 +80,7 @@ class BeRocket_AAPF extends BeRocket_Framework {
80
  'result_count' => '',
81
  'ordering' => '',
82
  'pagination' => '',
 
83
  ),
84
  'products_per_page' => '',
85
  'attribute_count' => '',
@@ -633,6 +634,12 @@ class BeRocket_AAPF extends BeRocket_Framework {
633
  "value" => '1',
634
  'label_for' => __('Enable if page doesn\'t have pagination.<strong>Page with lazy load also has pagination</strong>', 'BeRocket_AJAX_domain') . '<br>',
635
  ),
 
 
 
 
 
 
636
  ),
637
  ),
638
  ),
@@ -1487,6 +1494,7 @@ jQuery(document).on('change', '.br_selected_area_show', br_selected_area_show);
1487
  'result_count' => ( empty($br_options['woocommerce_removes']['result_count']) ? '' : $br_options['woocommerce_removes']['result_count'] ),
1488
  'ordering' => ( empty($br_options['woocommerce_removes']['ordering']) ? '' : $br_options['woocommerce_removes']['ordering'] ),
1489
  'pagination' => ( empty($br_options['woocommerce_removes']['pagination']) ? '' : $br_options['woocommerce_removes']['pagination'] ),
 
1490
  ) ),
1491
  'description_show' => ( ! empty($br_options['description']['show']) ? $br_options['description']['show'] : 'click' ),
1492
  'description_hide' => ( ! empty($br_options['description']['hide']) ? $br_options['description']['hide'] : 'click' ),
80
  'result_count' => '',
81
  'ordering' => '',
82
  'pagination' => '',
83
+ 'pagination_ajax' => '',
84
  ),
85
  'products_per_page' => '',
86
  'attribute_count' => '',
634
  "value" => '1',
635
  'label_for' => __('Enable if page doesn\'t have pagination.<strong>Page with lazy load also has pagination</strong>', 'BeRocket_AJAX_domain') . '<br>',
636
  ),
637
+ 'pagination_ajax' => array(
638
+ "type" => "checkbox",
639
+ "name" => array("woocommerce_removes", "pagination_ajax"),
640
+ "value" => '1',
641
+ 'label_for' => __('Disable AJAX Pagination', 'BeRocket_AJAX_domain') . '<br>',
642
+ ),
643
  ),
644
  ),
645
  ),
1494
  'result_count' => ( empty($br_options['woocommerce_removes']['result_count']) ? '' : $br_options['woocommerce_removes']['result_count'] ),
1495
  'ordering' => ( empty($br_options['woocommerce_removes']['ordering']) ? '' : $br_options['woocommerce_removes']['ordering'] ),
1496
  'pagination' => ( empty($br_options['woocommerce_removes']['pagination']) ? '' : $br_options['woocommerce_removes']['pagination'] ),
1497
+ 'pagination_ajax' => ( empty($br_options['woocommerce_removes']['pagination_ajax']) ? '' : $br_options['woocommerce_removes']['pagination_ajax'] ),
1498
  ) ),
1499
  'description_show' => ( ! empty($br_options['description']['show']) ? $br_options['description']['show'] : 'click' ),
1500
  'description_hide' => ( ! empty($br_options['description']['hide']) ? $br_options['description']['hide'] : 'click' ),
readme.txt CHANGED
@@ -4,8 +4,8 @@ Contributors: dholovnia, berocket
4
  Donate link: https://berocket.com/product/woocommerce-ajax-products-filter?utm_source=wordpress_org&utm_medium=donate&utm_campaign=ajax_filters
5
  Tags: filters, product filters, ajax product filters, ajax filter, ajax filter widget, color filter, size filter, product onsale filter, product preview, product category filter, product reset filter, product sort by filter, stock filter, product tag filter, price range filter, price box filter, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce products filter, woocommerce ajax product filters, widget, plugin, woocommerce item filters, filters plugin, ajax filters plugin, filter woocommerce products, filter woocommerce products plugin, wc filters, wc filters products, wc products filters, wc ajax products filters, wc product filters, wc advanced product filters, woocommerce layered nav, woocommerce layered navigation, ajax filtered nav, ajax filtered navigation, price filter, ajax price filter, woocommerce product sorting, sidebar filter, sidebar ajax filter, taxonomy filter, category filter, attribute filter, attributes filter, woocommerce product sort, ajax products filter plugin for woocommerce, rocket, berocket, berocket woocommerce ajax products filter
6
  Requires at least: 4.0
7
- Tested up to: 5.2.3
8
- Stable tag: 1.4.0.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -184,6 +184,11 @@ You can try this plugin's admin side [here](https://berocket.com/product/woocomm
184
 
185
  == Changelog ==
186
 
 
 
 
 
 
187
  = 1.4.0.1 =
188
  * Fix - Compatibility with other BeRocket plugins on activation
189
 
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.4
8
+ Stable tag: 1.4.0.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
184
 
185
  == Changelog ==
186
 
187
+ = 1.4.0.2 =
188
+ * Enhancement - Additional table generation withour WP-Cron
189
+ * Enhancement - Option to disable AJAX Pagination
190
+ * Enhancement - Write table generation errors and status
191
+
192
  = 1.4.0.1 =
193
  * Fix - Compatibility with other BeRocket plugins on activation
194
 
woocommerce-filters.php CHANGED
@@ -3,14 +3,14 @@
3
  * Plugin Name: Advanced AJAX Product Filters for WooCommerce
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-filters/?utm_source=free_plugin&utm_medium=plugins&utm_campaign=ajax_filters
5
  * Description: Unlimited AJAX products filters to make your shop perfect
6
- * Version: 1.4.0.1
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.4.0.1' );
15
  define( "BeRocket_AJAX_filters_file", __FILE__ );
16
  include_once('main.php');
3
  * Plugin Name: Advanced AJAX Product Filters for WooCommerce
4
  * Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-filters/?utm_source=free_plugin&utm_medium=plugins&utm_campaign=ajax_filters
5
  * Description: Unlimited AJAX products filters to make your shop perfect
6
+ * Version: 1.4.0.2
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.1
13
  */
14
+ define( "BeRocket_AJAX_filters_version", '1.4.0.2' );
15
  define( "BeRocket_AJAX_filters_file", __FILE__ );
16
  include_once('main.php');