PluginProbe
The WP Remote WordPress Plugin / 5.88
The WP Remote WordPress Plugin v5.88
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 +44 -14 4.875.88 View file →
@@ -7,8 +7,10 @@
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;
11 13
12 14 public function __construct($db, $settings, $config) {
13 15 $this->db = $db;
14 16 $this->settings = $settings;
@@ -17,9 +19,9 @@
17 19 }
18 20
19 21 function init() {
20 22 $this->add_actions_and_listeners();
21 - add_action('clear_dynsync_config', array($this, 'clearConfig'));
23 + add_action('wpr_clear_dynsync_config', array($this, 'clearConfig'));
22 24 }
23 25
24 26 public function clearConfig() {
25 27 $this->db->dropBVTable(BVWPDynSync::$dynsync_table);
@@ -196,9 +198,9 @@
196 198 function is_key_ignored($ignored_keys, $value) {
197 199 $is_ignored = false;
198 200 foreach($ignored_keys as $val) {
199 201 if ($val[0] == '/') {
200 - if (preg_match($val, $value))
202 + if (WPRHelper::safePregMatch($val, $value))
201 203 $is_ignored = true;
202 204 } else {
203 205 if ($val == $value)
204 206 $is_ignored = true;
@@ -252,22 +254,34 @@
252 254 return !$is_ignored;
253 255 }
254 256
255 257 /* WOOCOMMERCE SUPPORT FUNCTIONS BEGINS FROM HERE*/
256 -
257 - function woocommerce_resume_order_handler($order_id) {
258 + function handle_order_items($order_id, $type = null) {
258 259 $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 - 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'));
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'));
266 271 }
267 272 }
268 273 }
269 274
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 +
270 284 function woocommerce_update_order_handler($order_id, $order = null) {
271 285 $this->add_db_event('wc_orders', array('id' => $order_id));
272 286 $this->add_db_event('wc_orders_meta', array('order_id' => $order_id));
273 287 $this->add_db_event('wc_order_addresses', array('order_id' => $order_id));
@@ -325,9 +339,8 @@
325 339 }
326 340
327 341 function woocommerce_tax_rate_handler($tax_rate_id, $_tax_rate) {
328 342 $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));
330 343 }
331 344
332 345 function woocommerce_tax_rate_deleted_handler($tax_rate_id) {
333 346 $this->add_db_event('woocommerce_tax_rates', array('tax_rate_id' => $tax_rate_id, 'msg_type' => 'delete'));
@@ -491,12 +504,28 @@
491 504 function woocommerce_analytics_tax_delete_handler($tax_rate_id, $order_id) {
492 505 $this->add_db_event('wc_order_tax_lookup', array('order_id' => $order_id, 'msg_type' => 'delete'));
493 506 }
494 507
495 - function woocommerce_product_update_handler($product_id) {
508 + function woocommerce_product_update_handler($product_id, $meta_key = null) {
496 509 $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 + }
497 514 }
498 515
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 +
499 528 function woocommerce_trash_untrash_post_handler($post_id) {
500 529 if (!$post_id) {
501 530 return;
502 531 }
@@ -616,8 +645,9 @@
616 645 add_action('add_site_option', array($this, 'sitemeta_handler'), 10, 1);
617 646 add_action('update_site_option', array($this, 'sitemeta_handler'), 10, 1);
618 647
619 648 /* CAPTURING EVENTS FOR WOOCOMMERCE */
649 + add_action('woocommerce_remove_order_items', array($this, 'woocommerce_remove_order_items_handler'), 10, 2);
620 650 add_action('woocommerce_update_order', array($this, 'woocommerce_update_order_handler'), 10, 2);
621 651 add_action('woocommerce_delete_order', array($this, 'woocommerce_delete_order_handler'), 10, 1);
622 652 add_action('woocommerce_trash_order', array($this, 'woocommerce_trash_order_handler'), 10, 1);
623 653 add_action('woocommerce_resume_order', array($this, 'woocommerce_resume_order_handler'), 10, 1);
@@ -683,11 +713,11 @@
683 713
684 714 add_action('woocommerce_analytics_update_tax', array($this, 'woocommerce_analytics_tax_update_handler'), 10, 2);
685 715 add_action('woocommerce_analytics_delete_tax', array($this, 'woocommerce_analytics_tax_delete_handler'), 10, 2);
686 716
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);
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);
690 720
691 721 add_action('wp_trash_post', array($this, 'woocommerce_trash_untrash_post_handler'), 10, 1);
692 722 add_action('untrashed_post', array($this, 'woocommerce_trash_untrash_post_handler'), 10, 1);
693 723