| @@ -15,9 +15,8 @@ | ||
| 15 | 15 | $this->settings = $settings; |
| 16 | 16 | $this->bvinfo = $info; |
| 17 | 17 | $this->request_id = WPRInfo::getRequestID(); |
| 18 | 18 | $this->ip_header = array_key_exists('ip_header', $config) ? $config['ip_header'] : false; |
| 19 | - $this->ignored_events = array_key_exists('ignored_events', $config) ? $config['ignored_events'] : array(); | |
| 20 | 19 | } |
| 21 | 20 | |
| 22 | 21 | function init() { |
| 23 | 22 | $this->add_actions_and_listeners(); |
| @@ -62,9 +61,8 @@ | ||
| 62 | 61 | $data = array('id' => $user_id); |
| 63 | 62 | if (!empty($user)) { |
| 64 | 63 | $data['username'] = $user->user_login; |
| 65 | 64 | $data['email'] = $user->user_email; |
| 66 | - $data['role'] = $user->roles; | |
| 67 | 65 | } |
| 68 | 66 | return $data; |
| 69 | 67 | } |
| 70 | 68 | |
| @@ -145,27 +143,8 @@ | ||
| 145 | 143 | $values["time"] = time(); |
| 146 | 144 | $this->db->replaceIntoBVTable(BVWPActLog::$actlog_table, $values); |
| 147 | 145 | } |
| 148 | 146 | |
| 149 | - function is_key_ignored($ignored_keys, $value) { | |
| 150 | - $is_ignored = false; | |
| 151 | - if (array_key_exists("post_types_regex", $ignored_keys)) { | |
| 152 | - foreach ($ignored_keys['post_types_regex'] as $val) { | |
| 153 | - if (preg_match($val, $value)) { | |
| 154 | - return true; | |
| 155 | - } | |
| 156 | - } | |
| 157 | - } | |
| 158 | - if (array_key_exists("post_types", $ignored_keys)) { | |
| 159 | - foreach ($ignored_keys['post_types'] as $val) { | |
| 160 | - if ($val == $value) { | |
| 161 | - return true; | |
| 162 | - } | |
| 163 | - } | |
| 164 | - } | |
| 165 | - return $is_ignored; | |
| 166 | - } | |
| 167 | - | |
| 168 | 147 | function user_login_handler($user_login, $user) { |
| 169 | 148 | $event_data = array("user" => $this->get_user($user->ID)); |
| 170 | 149 | $this->add_activity($event_data); |
| 171 | 150 | } |
| @@ -205,10 +184,8 @@ | ||
| 205 | 184 | } |
| 206 | 185 | |
| 207 | 186 | function post_handler($post_id) { |
| 208 | 187 | $post = $this->get_post($post_id); |
| 209 | - if ($this->is_key_ignored($this->ignored_events, $post["type"])) | |
| 210 | - return; | |
| 211 | 188 | $event_data = array(); |
| 212 | 189 | if ($post["type"] === "product") { |
| 213 | 190 | $event_data["product"] = $post; |
| 214 | 191 | } elseif ($post["type"] === "shop_order") { |
| @@ -220,10 +197,8 @@ | ||
| 220 | 197 | } |
| 221 | 198 | |
| 222 | 199 | function post_saved_handler($post_id, $post, $update) { |
| 223 | 200 | $post = $this->get_post($post_id); |
| 224 | - if ($this->is_key_ignored($this->ignored_events, $post["type"])) | |
| 225 | - return; | |
| 226 | 201 | $event_data = array(); |
| 227 | 202 | if ($post["type"] === "product") { |
| 228 | 203 | $event_data["product"] = $post; |
| 229 | 204 | } elseif ($post["type"] === "shop_order") { |
| @@ -400,25 +375,22 @@ | ||
| 400 | 375 | return $data; |
| 401 | 376 | } |
| 402 | 377 | |
| 403 | 378 | function get_update_data($options) { |
| 379 | + global $wp_version; | |
| 404 | 380 | $event_data = array('action' => 'update'); |
| 405 | 381 | if ($options['type'] === 'plugin') { |
| 406 | 382 | $event_data['type'] = 'plugin'; |
| 407 | - if (array_key_exists("plugin", $options)) { | |
| 408 | - $options['plugins'] = array($options['plugin']); | |
| 409 | - unset($options['plugin']); | |
| 410 | - } | |
| 411 | 383 | $event_data['plugins'] = $this->get_plugin_update_data($options['plugins']); |
| 412 | 384 | } |
| 413 | 385 | else if ($options['type'] === 'theme') { |
| 414 | 386 | $event_data['type'] = 'theme'; |
| 415 | - if (array_key_exists("theme", $options)) { | |
| 416 | - $options['themes'] = array($options['theme']); | |
| 417 | - unset($options['theme']); | |
| 418 | - } | |
| 419 | 387 | $event_data['themes'] = $this->get_theme_update_data($options['themes']); |
| 420 | 388 | } |
| 389 | + else if ($options['type'] === 'core') { | |
| 390 | + $event_data['type'] = 'core'; | |
| 391 | + $event_data['wp_core'] = array('prev_version' => $wp_version); | |
| 392 | + } | |
| 421 | 393 | return $event_data; |
| 422 | 394 | } |
| 423 | 395 | |
| 424 | 396 | function get_install_data($upgrader, $options) { |
| @@ -436,11 +408,8 @@ | ||
| 436 | 408 | |
| 437 | 409 | function upgrade_handler($upgrader, $data) { |
| 438 | 410 | $event_data = array(); |
| 439 | 411 | if ($data['action'] === 'update') { |
| 440 | - if ('core' === $data['type']) { | |
| 441 | - return; | |
| 442 | - } | |
| 443 | 412 | $event_data = $this->get_update_data($data); |
| 444 | 413 | } else if ($data['action'] === 'install') { |
| 445 | 414 | $event_data = $this->get_install_data($upgrader, $data); |
| 446 | 415 | } |
| @@ -446,16 +415,8 @@ | ||
| 446 | 415 | } |
| 447 | 416 | $this->add_activity($event_data); |
| 448 | 417 | } |
| 449 | 418 | |
| 450 | - function core_upgrade_handler($new_wp_version) { | |
| 451 | - global $wp_version; | |
| 452 | - $event_data = array(); | |
| 453 | - $event_data['type'] = 'core'; | |
| 454 | - $event_data['wp_core'] = array('prev_version' => $wp_version, 'new_version' => $new_wp_version); | |
| 455 | - $this->add_activity($event_data); | |
| 456 | - } | |
| 457 | - | |
| 458 | 419 | /* ADDING ACTION AND LISTENERS FOR SENSING EVENTS. */ |
| 459 | 420 | public function add_actions_and_listeners() { |
| 460 | 421 | /* SENSORS FOR POST AND PAGE CHANGES */ |
| 461 | 422 | add_action('pre_post_update', array($this, 'post_handler')); |
| @@ -501,9 +462,8 @@ | ||
| 501 | 462 | add_action('password_reset', array( $this, 'password_reset_handler'), 10, 2); |
| 502 | 463 | |
| 503 | 464 | /* SENSOR FOR PLUGIN, THEME, WPCORE UPGRADES */ |
| 504 | 465 | add_action('upgrader_process_complete', array($this, 'upgrade_handler'), 10, 2); |
| 505 | - add_action('_core_updated_successfully', array($this, 'core_upgrade_handler'), 10, 1); | |
| 506 | 466 | |
| 507 | 467 | /* SENSORS FOR WOOCOMMERCE EVENTS */ |
| 508 | 468 | add_action('woocommerce_attribute_added', array($this, 'woocommerce_attribute_created_handler'), 10, 2); |
| 509 | 469 | add_action('woocommerce_attribute_updated', array($this, 'woocommerce_attribute_handler'), 10, 1); |