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 +33 -44 5.094.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,13 +257,13 @@
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 269
@@ -268,27 +279,8 @@
268 279 }
269 280 }
270 281 }
271 282
272 - function woocommerce_update_order_handler($order_id, $order = null) {
273 - $this->add_db_event('wc_orders', array('id' => $order_id));
274 - $this->add_db_event('wc_orders_meta', array('order_id' => $order_id));
275 - $this->add_db_event('wc_order_addresses', array('order_id' => $order_id));
276 - $this->add_db_event('wc_order_operational_data', array('order_id' => $order_id));
277 - }
278 -
279 - function woocommerce_trash_order_handler($order_id) {
280 - $this->add_db_event('wc_orders', array('id' => $order_id));
281 - $this->add_db_event('wc_orders_meta', array('order_id' => $order_id));
282 - }
283 -
284 - function woocommerce_delete_order_handler($order_id) {
285 - $this->add_db_event('wc_orders', array('id' => $order_id, 'msg_type' => 'delete'));
286 - $this->add_db_event('wc_orders_meta', array('order_id' => $order_id, 'msg_type' => 'delete'));
287 - $this->add_db_event('wc_order_addresses', array('order_id' => $order_id, 'msg_type' => 'delete'));
288 - $this->add_db_event('wc_order_operational_data', array('order_id' => $order_id, 'msg_type' => 'delete'));
289 - }
290 -
291 283 function woocommerce_new_order_item_handler($item_id, $item, $order_id) {
292 284 $this->add_db_event('woocommerce_order_items', array('order_item_id' => $item_id));
293 285 $this->add_db_event('woocommerce_order_itemmeta', array('order_item_id' => $item_id));
294 286 }
@@ -566,9 +558,9 @@
566 558 add_action('wp_insert_post', array($this, 'post_action_handler'));
567 559 add_action('edit_attachment', array($this, 'post_action_handler'));
568 560 add_action('add_attachment', array($this, 'post_action_handler'));
569 561 add_action('delete_attachment', array($this, 'post_action_handler'));
570 - add_action('private_to_publish', array($this, 'post_action_handler'));
562 + add_action('private_to_published', array($this, 'post_action_handler'));
571 563 add_action('wp_restore_post_revision', array($this, 'post_action_handler'));
572 564
573 565 /* CAPTURING EVENTS FOR WP_POSTMETA TABLE */
574 566 // Why events for both delete and deleted
@@ -618,11 +610,8 @@
618 610 add_action('add_site_option', array($this, 'sitemeta_handler'), 10, 1);
619 611 add_action('update_site_option', array($this, 'sitemeta_handler'), 10, 1);
620 612
621 613 /* CAPTURING EVENTS FOR WOOCOMMERCE */
622 - add_action('woocommerce_update_order', array($this, 'woocommerce_update_order_handler'), 10, 2);
623 - add_action('woocommerce_delete_order', array($this, 'woocommerce_delete_order_handler'), 10, 1);
624 - add_action('woocommerce_trash_order', array($this, 'woocommerce_trash_order_handler'), 10, 1);
625 614 add_action('woocommerce_resume_order', array($this, 'woocommerce_resume_order_handler'), 10, 1);
626 615 add_action('woocommerce_new_order_item', array($this, 'woocommerce_new_order_item_handler'), 10, 3);
627 616 add_action('woocommerce_update_order_item', array($this, 'woocommerce_update_order_item_handler'), 10, 2);
628 617 add_action('woocommerce_delete_order_item', array($this, 'woocommerce_delete_order_item_handler'), 10, 1);