PluginProbe
The WP Remote WordPress Plugin / 4.79
The WP Remote WordPress Plugin v4.79
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 +45 -84 5.424.79 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;
@@ -49,23 +47,26 @@
49 47 $this->add_db_event('posts', array('ID' => $post_id, 'msg_type' => $msg_type));
50 48 }
51 49
52 50 function get_ignored_postmeta() {
51 + $defaults = array(
52 + '_excluded_links'
53 + );
53 54 $ignored_postmeta = $this->ignored_events['postmeta'];
54 55 if (empty($ignored_postmeta)) {
55 56 $ignored_postmeta = array();
56 57 }
57 - return array_unique($ignored_postmeta);
58 + return array_unique(array_merge($defaults, $ignored_postmeta));
58 59 }
59 60
60 61 function postmeta_insert_handler($meta_id, $post_id, $meta_key, $meta_value='') {
61 - if ($this->is_key_ignored($this->get_ignored_postmeta(), $meta_key))
62 + if (in_array($meta_key, $this->get_ignored_postmeta(), true))
62 63 return;
63 64 $this->add_db_event('postmeta', array('meta_id' => $meta_id));
64 65 }
65 66
66 67 function postmeta_modification_handler($meta_id, $object_id, $meta_key, $meta_value) {
67 - if ($this->is_key_ignored($this->get_ignored_postmeta(), $meta_key))
68 + if (in_array($meta_key, $this->get_ignored_postmeta(), true))
68 69 return;
69 70 if (!is_array($meta_id))
70 71 return $this->add_db_event('postmeta', array('meta_id' => $meta_id));
71 72 foreach ($meta_id as $id) {
@@ -73,9 +74,9 @@
73 74 }
74 75 }
75 76
76 77 function postmeta_action_handler($meta_id, $post_id = null, $meta_key = null) {
77 - if ($this->is_key_ignored($this->get_ignored_postmeta(), $meta_key))
78 + if (in_array($meta_key, $this->get_ignored_postmeta(), true))
78 79 return;
79 80 if ( !is_array($meta_id) )
80 81 return $this->add_db_event('postmeta', array('meta_id' => $meta_id));
81 82 foreach ( $meta_id as $id )
@@ -187,29 +188,39 @@
187 188 $this->term_relationships_handler( $object_id, $tt_ids );
188 189 }
189 190
190 191 function get_ignored_options() {
192 + $defaults = array(
193 + 'cron',
194 + 'wpsupercache_gc_time',
195 + 'rewrite_rules',
196 + 'akismet_spam_count',
197 + 'iwp_client_user_hit_count',
198 + '_disqus_sync_lock',
199 + 'stats_cache'
200 + );
191 201 $ignored_options = $this->ignored_events['options'];
192 202 if (empty($ignored_options)) {
193 203 $ignored_options = array();
194 204 }
195 - return array_unique($ignored_options);
205 + return array_unique(array_merge($defaults, $ignored_options));
196 206 }
197 207
198 - function is_key_ignored($ignored_keys, $value) {
199 - $is_ignored = false;
200 - foreach($ignored_keys as $val) {
208 + function get_ping_permission($option_name) {
209 + $ping_permitted = true;
210 + $ignored_options = $this->get_ignored_options();
211 + foreach($ignored_options as $val) {
201 212 if ($val[0] == '/') {
202 - if (WPRHelper::safePregMatch($val, $value))
203 - $is_ignored = true;
213 + if (preg_match($val, $option_name))
214 + $ping_permitted = false;
204 215 } else {
205 - if ($val == $value)
206 - $is_ignored = true;
216 + if ($val == $option_name)
217 + $ping_permitted = false;
207 218 }
208 - if ($is_ignored)
219 + if (!$ping_permitted)
209 220 break;
210 221 }
211 - return $is_ignored;
222 + return $ping_permitted;
212 223 }
213 224
214 225 function option_handler($option_name) {
215 226 if (current_filter() == 'deleted_option')
@@ -215,10 +226,10 @@
215 226 if (current_filter() == 'deleted_option')
216 227 $msg_type = 'delete';
217 228 else
218 229 $msg_type = 'edit';
219 - $is_ignored = $this->is_key_ignored($this->get_ignored_options(), $option_name);
220 - if (!$is_ignored)
230 + $ping_permitted = $this->get_ping_permission($option_name);
231 + if ($ping_permitted)
221 232 $this->add_db_event('options', array('option_name' => $option_name, 'msg_type' => $msg_type));
222 233 return $option_name;
223 234 }
224 235
@@ -246,61 +257,30 @@
246 257 $this->add_db_event('blogs', array('site_id' => $site_id));
247 258 }
248 259
249 260 function sitemeta_handler($option) {
250 - $is_ignored = $this->is_key_ignored($this->get_ignored_options(), $option);
251 - if (!$is_ignored && is_multisite()) {
261 + $ping_permitted = $this->get_ping_permission($option);
262 + if ($ping_permitted && is_multisite()) {
252 263 $this->add_db_event('sitemeta', array('site_id' => $this->db->getSiteId(), 'meta_key' => $option));
253 264 }
254 - return !$is_ignored;
265 + return $ping_permitted;
255 266 }
256 267
257 268 /* WOOCOMMERCE SUPPORT FUNCTIONS BEGINS FROM HERE*/
258 - function handle_order_items($order_id, $type = null) {
269 +
270 + function woocommerce_resume_order_handler($order_id) {
259 271 $this->add_db_event('woocommerce_order_items', array('order_id' => $order_id, 'msg_type' => 'delete'));
272 + $meta_ids = array();
260 273 $itemmeta_table = $this->db->getWPTable('woocommerce_order_itemmeta');
261 274 $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'));
275 + 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) {
276 + if (!in_array($row->meta_id, $meta_ids, true)) {
277 + $meta_ids[] = $row->meta_id;
278 + $this->add_db_event('woocommerce_order_itemmeta', array('meta_id' => $row->meta_id, 'msg_type' => 'delete'));
271 279 }
272 280 }
273 281 }
274 282
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 - function woocommerce_update_order_handler($order_id, $order = null) {
285 - $this->add_db_event('wc_orders', array('id' => $order_id));
286 - $this->add_db_event('wc_orders_meta', array('order_id' => $order_id));
287 - $this->add_db_event('wc_order_addresses', array('order_id' => $order_id));
288 - $this->add_db_event('wc_order_operational_data', array('order_id' => $order_id));
289 - }
290 -
291 - function woocommerce_trash_order_handler($order_id) {
292 - $this->add_db_event('wc_orders', array('id' => $order_id));
293 - $this->add_db_event('wc_orders_meta', array('order_id' => $order_id));
294 - }
295 -
296 - function woocommerce_delete_order_handler($order_id) {
297 - $this->add_db_event('wc_orders', array('id' => $order_id, 'msg_type' => 'delete'));
298 - $this->add_db_event('wc_orders_meta', array('order_id' => $order_id, 'msg_type' => 'delete'));
299 - $this->add_db_event('wc_order_addresses', array('order_id' => $order_id, 'msg_type' => 'delete'));
300 - $this->add_db_event('wc_order_operational_data', array('order_id' => $order_id, 'msg_type' => 'delete'));
301 - }
302 -
303 283 function woocommerce_new_order_item_handler($item_id, $item, $order_id) {
304 284 $this->add_db_event('woocommerce_order_items', array('order_item_id' => $item_id));
305 285 $this->add_db_event('woocommerce_order_itemmeta', array('order_item_id' => $item_id));
306 286 }
@@ -339,8 +319,9 @@
339 319 }
340 320
341 321 function woocommerce_tax_rate_handler($tax_rate_id, $_tax_rate) {
342 322 $this->add_db_event('woocommerce_tax_rates', array('tax_rate_id' => $tax_rate_id));
323 + $this->add_db_event('woocommerce_tax_rate_locations', array('tax_rate_id' => $tax_rate_id));
343 324 }
344 325
345 326 function woocommerce_tax_rate_deleted_handler($tax_rate_id) {
346 327 $this->add_db_event('woocommerce_tax_rates', array('tax_rate_id' => $tax_rate_id, 'msg_type' => 'delete'));
@@ -504,28 +485,12 @@
504 485 function woocommerce_analytics_tax_delete_handler($tax_rate_id, $order_id) {
505 486 $this->add_db_event('wc_order_tax_lookup', array('order_id' => $order_id, 'msg_type' => 'delete'));
506 487 }
507 488
508 - function woocommerce_product_update_handler($product_id, $meta_key = null) {
489 + function woocommerce_product_update_handler($product_id) {
509 490 $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 491 }
515 492
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 493 function woocommerce_trash_untrash_post_handler($post_id) {
529 494 if (!$post_id) {
530 495 return;
531 496 }
@@ -593,9 +558,9 @@
593 558 add_action('wp_insert_post', array($this, 'post_action_handler'));
594 559 add_action('edit_attachment', array($this, 'post_action_handler'));
595 560 add_action('add_attachment', array($this, 'post_action_handler'));
596 561 add_action('delete_attachment', array($this, 'post_action_handler'));
597 - add_action('private_to_publish', array($this, 'post_action_handler'));
562 + add_action('private_to_published', array($this, 'post_action_handler'));
598 563 add_action('wp_restore_post_revision', array($this, 'post_action_handler'));
599 564
600 565 /* CAPTURING EVENTS FOR WP_POSTMETA TABLE */
601 566 // Why events for both delete and deleted
@@ -645,12 +610,8 @@
645 610 add_action('add_site_option', array($this, 'sitemeta_handler'), 10, 1);
646 611 add_action('update_site_option', array($this, 'sitemeta_handler'), 10, 1);
647 612
648 613 /* CAPTURING EVENTS FOR WOOCOMMERCE */
649 - add_action('woocommerce_remove_order_items', array($this, 'woocommerce_remove_order_items_handler'), 10, 2);
650 - add_action('woocommerce_update_order', array($this, 'woocommerce_update_order_handler'), 10, 2);
651 - add_action('woocommerce_delete_order', array($this, 'woocommerce_delete_order_handler'), 10, 1);
652 - add_action('woocommerce_trash_order', array($this, 'woocommerce_trash_order_handler'), 10, 1);
653 614 add_action('woocommerce_resume_order', array($this, 'woocommerce_resume_order_handler'), 10, 1);
654 615 add_action('woocommerce_new_order_item', array($this, 'woocommerce_new_order_item_handler'), 10, 3);
655 616 add_action('woocommerce_update_order_item', array($this, 'woocommerce_update_order_item_handler'), 10, 2);
656 617 add_action('woocommerce_delete_order_item', array($this, 'woocommerce_delete_order_item_handler'), 10, 1);
@@ -713,11 +674,11 @@
713 674
714 675 add_action('woocommerce_analytics_update_tax', array($this, 'woocommerce_analytics_tax_update_handler'), 10, 2);
715 676 add_action('woocommerce_analytics_delete_tax', array($this, 'woocommerce_analytics_tax_delete_handler'), 10, 2);
716 677
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);
678 + add_action('woocommerce_updated_product_stock', array($this, 'woocommerce_product_update_handler'), 10, 1);
679 + add_action('woocommerce_updated_product_sales', array($this, 'woocommerce_product_update_handler'), 10, 1);
680 + add_action('woocommerce_updated_product_price', array($this, 'woocommerce_product_update_handler'), 10, 1);
720 681
721 682 add_action('wp_trash_post', array($this, 'woocommerce_trash_untrash_post_handler'), 10, 1);
722 683 add_action('untrashed_post', array($this, 'woocommerce_trash_untrash_post_handler'), 10, 1);
723 684