PluginProbe
The WP Remote WordPress Plugin / 4.84
The WP Remote WordPress Plugin v4.84
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
← All changes | wp_dynsync.php +13 -43 5.424.84 View file →
@@ -7,10 +7,8 @@
7 7
8 8 public static $dynsync_table = 'dynamic_sync';
9 9 public $db;
10 10 public $settings;
11 - public $config;
12 - public $ignored_events;
13 11
14 12 public function __construct($db, $settings, $config) {
15 13 $this->db = $db;
16 14 $this->settings = $settings;
@@ -198,9 +196,9 @@
198 196 function is_key_ignored($ignored_keys, $value) {
199 197 $is_ignored = false;
200 198 foreach($ignored_keys as $val) {
201 199 if ($val[0] == '/') {
202 - if (WPRHelper::safePregMatch($val, $value))
200 + if (preg_match($val, $value))
203 201 $is_ignored = true;
204 202 } else {
205 203 if ($val == $value)
206 204 $is_ignored = true;
@@ -254,34 +252,22 @@
254 252 return !$is_ignored;
255 253 }
256 254
257 255 /* WOOCOMMERCE SUPPORT FUNCTIONS BEGINS FROM HERE*/
258 - function handle_order_items($order_id, $type = null) {
256 +
257 + function woocommerce_resume_order_handler($order_id) {
259 258 $this->add_db_event('woocommerce_order_items', array('order_id' => $order_id, 'msg_type' => 'delete'));
259 + $meta_ids = array();
260 260 $itemmeta_table = $this->db->getWPTable('woocommerce_order_itemmeta');
261 261 $items_table = $this->db->getWPTable('woocommerce_order_items');
262 - $query = "SELECT {$itemmeta_table}.meta_id FROM {$itemmeta_table} INNER JOIN {$items_table} WHERE {$itemmeta_table}.order_item_id = {$items_table}.order_item_id AND {$items_table}.order_id = {$order_id}";
263 - if (!empty($type)) {
264 - $query .= " AND {$items_table}.order_item_type = '{$type}'";
265 - }
266 - $meta_ids = array();
267 - foreach ($this->db->getResult($query) as $row) {
268 - if (!in_array($row['meta_id'], $meta_ids, true)) {
269 - $meta_ids[] = $row['meta_id'];
270 - $this->add_db_event('woocommerce_order_itemmeta', array('meta_id' => $row['meta_id'], 'msg_type' => 'delete'));
262 + foreach( $this->db->getResult($this->db->prepare("SELECT {$itemmeta_table}.meta_id FROM {$itemmeta_table} INNER JOIN {$items_table} WHERE {$items_table}.order_item_id = {$itemmeta_table}.order_item_id AND {$items_table}.order_id = %d", $order_id)) as $key => $row) {
263 + if (!in_array($row->meta_id, $meta_ids, true)) {
264 + $meta_ids[] = $row->meta_id;
265 + $this->add_db_event('woocommerce_order_itemmeta', array('meta_id' => $row->meta_id, 'msg_type' => 'delete'));
271 266 }
272 267 }
273 268 }
274 269
275 - function woocommerce_remove_order_items_handler($order, $type = null) {
276 - $order_id = $order->get_id();
277 - $this->handle_order_items($order_id, $type);
278 - }
279 -
280 - function woocommerce_resume_order_handler($order_id) {
281 - $this->handle_order_items($order_id);
282 - }
283 -
284 270 function woocommerce_update_order_handler($order_id, $order = null) {
285 271 $this->add_db_event('wc_orders', array('id' => $order_id));
286 272 $this->add_db_event('wc_orders_meta', array('order_id' => $order_id));
287 273 $this->add_db_event('wc_order_addresses', array('order_id' => $order_id));
@@ -339,8 +325,9 @@
339 325 }
340 326
341 327 function woocommerce_tax_rate_handler($tax_rate_id, $_tax_rate) {
342 328 $this->add_db_event('woocommerce_tax_rates', array('tax_rate_id' => $tax_rate_id));
329 + $this->add_db_event('woocommerce_tax_rate_locations', array('tax_rate_id' => $tax_rate_id));
343 330 }
344 331
345 332 function woocommerce_tax_rate_deleted_handler($tax_rate_id) {
346 333 $this->add_db_event('woocommerce_tax_rates', array('tax_rate_id' => $tax_rate_id, 'msg_type' => 'delete'));
@@ -504,28 +491,12 @@
504 491 function woocommerce_analytics_tax_delete_handler($tax_rate_id, $order_id) {
505 492 $this->add_db_event('wc_order_tax_lookup', array('order_id' => $order_id, 'msg_type' => 'delete'));
506 493 }
507 494
508 - function woocommerce_product_update_handler($product_id, $meta_key = null) {
495 + function woocommerce_product_update_handler($product_id) {
509 496 $this->add_db_event('wc_product_meta_lookup', array('product_id' => $product_id, 'msg_type' => 'edit'));
510 - if(!empty($meta_key)) {
511 - $meta_ids = $this->db->getResult("SELECT meta_id FROM {$this->db->dbprefix()}postmeta WHERE post_id = {$product_id} AND meta_key = '{$meta_key}';");
512 - $this->postmeta_action_handler(array_column($meta_ids, 'meta_id'), null, $meta_key);
513 - }
514 497 }
515 498
516 - function woocommerce_product_stock_update_handler($product_id) {
517 - $this->woocommerce_product_update_handler($product_id, '_stock');
518 - }
519 -
520 - function woocommerce_product_sales_update_handler($product_id) {
521 - $this->woocommerce_product_update_handler($product_id, 'total_sales');
522 - }
523 -
524 - function woocommerce_product_price_update_handler($product_id) {
525 - $this->woocommerce_product_update_handler($product_id);
526 - }
527 -
528 499 function woocommerce_trash_untrash_post_handler($post_id) {
529 500 if (!$post_id) {
530 501 return;
531 502 }
@@ -645,9 +616,8 @@
645 616 add_action('add_site_option', array($this, 'sitemeta_handler'), 10, 1);
646 617 add_action('update_site_option', array($this, 'sitemeta_handler'), 10, 1);
647 618
648 619 /* CAPTURING EVENTS FOR WOOCOMMERCE */
649 - add_action('woocommerce_remove_order_items', array($this, 'woocommerce_remove_order_items_handler'), 10, 2);
650 620 add_action('woocommerce_update_order', array($this, 'woocommerce_update_order_handler'), 10, 2);
651 621 add_action('woocommerce_delete_order', array($this, 'woocommerce_delete_order_handler'), 10, 1);
652 622 add_action('woocommerce_trash_order', array($this, 'woocommerce_trash_order_handler'), 10, 1);
653 623 add_action('woocommerce_resume_order', array($this, 'woocommerce_resume_order_handler'), 10, 1);
@@ -713,11 +683,11 @@
713 683
714 684 add_action('woocommerce_analytics_update_tax', array($this, 'woocommerce_analytics_tax_update_handler'), 10, 2);
715 685 add_action('woocommerce_analytics_delete_tax', array($this, 'woocommerce_analytics_tax_delete_handler'), 10, 2);
716 686
717 - add_action('woocommerce_updated_product_stock', array($this, 'woocommerce_product_stock_update_handler'), 10, 1);
718 - add_action('woocommerce_updated_product_sales', array($this, 'woocommerce_product_sales_update_handler'), 10, 1);
719 - add_action('woocommerce_updated_product_price', array($this, 'woocommerce_product_price_update_handler'), 10, 1);
687 + add_action('woocommerce_updated_product_stock', array($this, 'woocommerce_product_update_handler'), 10, 1);
688 + add_action('woocommerce_updated_product_sales', array($this, 'woocommerce_product_update_handler'), 10, 1);
689 + add_action('woocommerce_updated_product_price', array($this, 'woocommerce_product_update_handler'), 10, 1);
720 690
721 691 add_action('wp_trash_post', array($this, 'woocommerce_trash_untrash_post_handler'), 10, 1);
722 692 add_action('untrashed_post', array($this, 'woocommerce_trash_untrash_post_handler'), 10, 1);
723 693