/**
  * @param Theme_Upgrader $upgrader
  * @param array $extra
  */
 public function hooks_theme_install_or_update($upgrader, $extra)
 {
     if (!isset($extra['type']) || 'theme' !== $extra['type']) {
         return;
     }
     if ('install' === $extra['action']) {
         $slug = $upgrader->theme_info();
         if (!$slug) {
             return;
         }
         wp_clean_themes_cache();
         $theme = wp_get_theme($slug);
         $name = $theme->name;
         $version = $theme->version;
         aal_insert_log(array('action' => 'installed', 'object_type' => 'Theme', 'object_name' => $name, 'object_subtype' => $version));
     }
     if ('update' === $extra['action']) {
         if (isset($extra['bulk']) && true == $extra['bulk']) {
             $slugs = $extra['themes'];
         } else {
             $slugs = array($upgrader->skin->theme);
         }
         foreach ($slugs as $slug) {
             $theme = wp_get_theme($slug);
             $stylesheet = $theme['Stylesheet Dir'] . '/style.css';
             $theme_data = get_file_data($stylesheet, array('Version' => 'Version'));
             $name = $theme['Name'];
             $version = $theme_data['Version'];
             aal_insert_log(array('action' => 'updated', 'object_type' => 'Theme', 'object_name' => $name, 'object_subtype' => $version));
         }
     }
 }
 /**
  * @param Plugin_Upgrader $upgrader
  * @param array $extra
  */
 public function hooks_plugin_install_or_update($upgrader, $extra)
 {
     if (!isset($extra['type']) || 'plugin' !== $extra['type']) {
         return;
     }
     if ('install' === $extra['action']) {
         $path = $upgrader->plugin_info();
         if (!$path) {
             return;
         }
         $data = get_plugin_data($upgrader->skin->result['local_destination'] . '/' . $path, true, false);
         aal_insert_log(array('action' => 'installed', 'object_type' => 'Plugin', 'object_name' => $data['Name'], 'object_subtype' => $data['Version']));
     }
     if ('update' === $extra['action']) {
         if (isset($extra['bulk']) && true == $extra['bulk']) {
             $slugs = $extra['plugins'];
         } else {
             if (!isset($upgrader->skin->plugin)) {
                 return;
             }
             $slugs = array($upgrader->skin->plugin);
         }
         foreach ($slugs as $slug) {
             $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $slug, true, false);
             aal_insert_log(array('action' => 'updated', 'object_type' => 'Plugin', 'object_name' => $data['Name'], 'object_subtype' => $data['Version']));
         }
     }
 }
 protected function _add_comment_log($id, $action, $comment = null)
 {
     if (is_null($comment)) {
         $comment = get_comment($id);
     }
     aal_insert_log(array('action' => $action, 'object_type' => 'Comments', 'object_subtype' => get_post_type($comment->comment_post_ID), 'object_name' => get_the_title($comment->comment_post_ID), 'object_id' => $id));
 }
 public function hooks_theme_customizer_modified(WP_Customize_Manager $obj)
 {
     $aal_args = array('action' => 'updated', 'object_type' => 'Theme', 'object_subtype' => $obj->theme()->display('Name'), 'object_id' => 0, 'object_name' => 'Theme Customizer');
     if ('customize_preview_init' === current_filter()) {
         $aal_args['action'] = 'accessed';
     }
     aal_insert_log($aal_args);
 }
 public function hooks_updated_option($option, $oldvalue, $_newvalue)
 {
     $whitelist_options = apply_filters('aal_whitelist_options', array('blogname', 'blogdescription', 'siteurl', 'home', 'admin_email', 'users_can_register', 'default_role', 'timezone_string', 'date_format', 'time_format', 'start_of_week', 'use_smilies', 'use_balanceTags', 'default_category', 'default_post_format', 'mailserver_url', 'mailserver_login', 'mailserver_pass', 'default_email_category', 'ping_sites', 'show_on_front', 'page_on_front', 'page_for_posts', 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_public', 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'require_name_email', 'comment_registration', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comments_notify', 'moderation_notify', 'comment_moderation', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'uploads_use_yearmonth_folders', 'permalink_structure', 'category_base', 'tag_base', 'sidebars_widgets'));
     if (!in_array($option, $whitelist_options)) {
         return;
     }
     // TODO: need to think about save old & new values.
     aal_insert_log(array('action' => 'updated', 'object_type' => 'Options', 'object_name' => $option));
 }
 public function hooks_widget_delete()
 {
     // A reference: http://grinninggecko.com/hooking-into-widget-delete-action-in-wordpress/
     if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && !empty($_REQUEST['widget-id'])) {
         if (isset($_REQUEST['delete_widget']) && 1 === (int) $_REQUEST['delete_widget']) {
             aal_insert_log(array('action' => 'deleted', 'object_type' => 'Widget', 'object_subtype' => strtolower($_REQUEST['sidebar']), 'object_id' => 0, 'object_name' => $_REQUEST['id_base']));
         }
     }
 }
 public function core_updated_successfully($wp_version)
 {
     global $pagenow;
     // Auto updated
     if ('update-core.php' !== $pagenow) {
         $object_name = 'WordPress Auto Updated';
     } else {
         $object_name = 'WordPress Updated';
     }
     aal_insert_log(array('action' => 'updated', 'object_type' => 'Core', 'object_id' => 0, 'object_name' => $object_name));
 }
Esempio n. 8
0
 public function hooks_delete_post($post_id)
 {
     if (wp_is_post_revision($post_id)) {
         return;
     }
     $post = get_post($post_id);
     if (in_array($post->post_status, array('auto-draft', 'inherit'))) {
         return;
     }
     // Skip for menu items.
     if ('nav_menu_item' === get_post_type($post->ID)) {
         return;
     }
     aal_insert_log(array('action' => 'deleted', 'object_type' => 'Post', 'object_subtype' => $post->post_type, 'object_id' => $post->ID, 'object_name' => $this->_draft_or_post_title($post->ID)));
 }
 public function hooks_plugin_modify($location, $status)
 {
     if (false !== strpos($location, 'plugin-editor.php')) {
         if (!empty($_POST) && 'update' === $_REQUEST['action']) {
             $aal_args = array('action' => 'file_updated', 'object_type' => 'Plugin', 'object_subtype' => 'plugin_unknown', 'object_id' => 0, 'object_name' => 'file_unknown');
             if (!empty($_REQUEST['file'])) {
                 $aal_args['object_name'] = $_REQUEST['file'];
                 // Get plugin name
                 $plugin_dir = explode('/', $_REQUEST['file']);
                 $plugin_data = array_shift(array_values(get_plugins('/' . $plugin_dir[0])));
                 $aal_args['object_subtype'] = $plugin_data['Name'];
             }
             aal_insert_log($aal_args);
         }
     }
     // We are need return the instance, for complete the filter.
     return $location;
 }
 public function hooks_created_edited_deleted_term($term_id, $tt_id, $taxonomy, $deleted_term = null)
 {
     // Make sure do not action nav menu taxonomy.
     if ('nav_menu' === $taxonomy) {
         return;
     }
     if ('delete_term' === current_filter()) {
         $term = $deleted_term;
     } else {
         $term = get_term($term_id, $taxonomy);
     }
     if ($term && !is_wp_error($term)) {
         if ('edited_term' === current_filter()) {
             $action = 'updated';
         } elseif ('delete_term' === current_filter()) {
             $action = 'deleted';
             $term_id = '';
         } else {
             $action = 'created';
         }
         aal_insert_log(array('action' => $action, 'object_type' => 'Taxonomy', 'object_subtype' => $taxonomy, 'object_id' => $term_id, 'object_name' => $term->name));
     }
 }
 public function hooks_wrong_password($username)
 {
     aal_insert_log(array('action' => 'wrong_password', 'object_type' => 'User', 'user_id' => 0, 'object_id' => 0, 'object_name' => $username));
 }
 public function hooks_menu_deleted($term, $tt_id, $deleted_term)
 {
     aal_insert_log(array('action' => 'deleted', 'object_type' => 'Menu', 'object_name' => $deleted_term->name));
 }
Esempio n. 13
0
 public function hook_mail_sent_or_blocked($form_id)
 {
     $is_blocked = 'pojo_forms_mail_blocked' === current_filter();
     aal_insert_log(array('action' => $is_blocked ? 'blocked' : 'sent', 'object_type' => 'Forms', 'object_id' => $form_id, 'object_name' => get_the_title($form_id)));
 }
 public function hooks_export_wp($args)
 {
     aal_insert_log(array('action' => 'downloaded', 'object_type' => 'Export', 'object_id' => 0, 'object_name' => isset($args['content']) ? $args['content'] : 'all'));
 }
Esempio n. 15
0
 public function hooks_menu_updated($nav_menu_selected_id)
 {
     if ($menu_object = wp_get_nav_menu_object($nav_menu_selected_id)) {
         aal_insert_log(array('action' => 'updated', 'object_type' => 'Menu', 'object_name' => $menu_object->name));
     }
 }
 protected function _add_log_attachment($action, $attachment_id)
 {
     $post = get_post($attachment_id);
     aal_insert_log(array('action' => $action, 'object_type' => 'Attachment', 'object_subtype' => $post->post_type, 'object_id' => $attachment_id, 'object_name' => get_the_title($post->ID)));
 }