Пример #1
0
 /**
  * Data exported out of WordPress
  *
  * @since 0.1.0
  *
  * @param array $args
  */
 public function export_wp($args = array())
 {
     // Get content name
     $name = isset($args['content']) ? $args['content'] : 'all';
     // Insert activity
     wp_insert_user_activity(array('object_type' => $this->object_type, 'object_name' => $name, 'object_id' => 0, 'action' => 'export'));
 }
Пример #2
0
 /**
  * Menu deleted
  *
  * @sice 0.1.0
  *
  * @param  id  $term
  * @param  id  $tt_id
  * @param  id  $deleted_term
  */
 public function menu_deleted($term, $tt_id, $deleted_term)
 {
     wp_insert_user_activity(array('object_type' => $this->object_type, 'object_name' => $deleted_term->name, 'object_id' => $deleted_term->term_id, 'action' => 'delete'));
 }
Пример #3
0
 /**
  * Theme install of update
  *
  * @since 0.1.0
  *
  * @param Theme_Upgrader $upgrader
  * @param array $extra
  */
 public function theme_install_or_update($upgrader, $extra)
 {
     // Bail if not a theme
     if (!isset($extra['type']) || 'theme' !== $extra['type']) {
         return;
     }
     // Install
     if ('install' === $extra['action']) {
         // Bail if no theme found
         $slug = $upgrader->theme_info();
         if (empty($slug)) {
             return;
         }
         wp_clean_themes_cache();
         $theme = wp_get_theme($slug);
         $name = $theme->name;
         $version = $theme->version;
         // Insert activity
         wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $version, 'object_name' => $name, 'action' => 'install'));
         // Update
     } elseif ('update' === $extra['action']) {
         // Get theme slugs
         if (isset($extra['bulk']) && true == $extra['bulk']) {
             $slugs = $extra['themes'];
         } else {
             $slugs = array($upgrader->skin->theme);
         }
         // Activity for each 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'];
             // Insert activity
             wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $version, 'object_name' => $name, 'action' => 'update'));
         }
     }
 }
Пример #4
0
 /**
  * Widget deleted
  *
  * @since 0.1.0
  */
 public function widget_delete()
 {
     // Bail if not widget deletion request
     if (!$this->is_widget_delete()) {
         return;
     }
     // Insert activity
     wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $this->get_sidebar(), 'object_name' => $_REQUEST['id_base'], 'object_id' => 0, 'action' => 'delete'));
 }
 /**
  * Post edit
  *
  * @since 0.1.0
  *
  * @param  int  $post_id
  */
 public function edit_post($post_id = 0)
 {
     // Get the post
     $post = get_post($post_id);
     // Bail if no post
     if (empty($post)) {
         return;
     }
     // Bail if nav menu item or activity item
     if (in_array($post->post_type, array('nav_menu_item', 'activity'), true)) {
         return;
     }
     // Bail if auto-draft (@todo handle inherited children)
     if (in_array($post->post_status, array('auto-draft', 'inherit'), true)) {
         return;
     }
     // Insert activity
     wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $post->post_type, 'object_name' => $this->_draft_or_post_title($post), 'object_id' => $post->ID, 'action' => 'update'));
 }
 /**
  * Helper function for logging attachment actions
  *
  * @since 0.1.0
  *
  * @param  string  $action
  * @param  int     $attachment_id
  */
 protected function add_attachment_activity($action = '', $attachment_id = 0)
 {
     $post = get_post($attachment_id);
     // Insert activity
     wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $post->post_mime_type, 'object_name' => $post->post_title, 'object_id' => $attachment_id, 'action' => $action));
 }
 /**
  * Helper function for adding comment activity
  *
  * @since 0.1.0
  *
  * @param  int     $id
  * @param  string  $action
  * @param  int     $comment
  */
 protected function add_comment_activity($id, $action, $comment = null)
 {
     // Get comment
     if (is_null($comment)) {
         $comment = get_comment($id);
     }
     // Get the post so we can use raw db data
     $post = get_post($comment->comment_post_ID);
     // Insert activity
     wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $post->post_type, 'object_name' => $post->post_title, 'object_id' => $id, 'action' => $action));
 }
Пример #8
0
 /**
  * Updated WordPress core
  *
  * @since 0.1.0
  *
  * @global  string  $pagenow
  * @param   string  $wp_version
  */
 public function core_updated_successfully($wp_version)
 {
     global $pagenow;
     // Auto updated
     if ('update-core.php' !== $pagenow) {
         $object_name = 'WordPress Auto Updated';
         $action = 'auto_update';
     } else {
         $object_name = 'WordPress Updated';
         $action = 'update';
     }
     // Insert activity
     wp_insert_user_activity(array('object_type' => $this->object_type, 'object_name' => $object_name, 'object_id' => get_current_blog_id(), 'action' => $action));
 }
Пример #9
0
 /**
  * Username attempted login
  *
  * @since 0.1.0
  *
  * @param  string  $user_login
  */
 public function wp_login_failed($user_login = '')
 {
     // Insert activity
     wp_insert_user_activity(array('object_type' => $this->object_type, 'object_name' => $user_login, 'object_id' => 0, 'action' => 'login_fail'));
 }
Пример #10
0
 /**
  * Plugin installed or updated
  *
  * @since 0.1.0
  *
  * @param  object  $upgrader
  * @param  array   $extra
  */
 public function 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);
         // Insert activity
         wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $data['Version'], 'object_name' => $data['Name'], 'action' => 'install'));
     }
     if ('update' !== $extra['action']) {
         return;
     }
     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);
         // Insert activity
         wp_insert_user_activity(array('object_type' => $this->object_type, 'object_subtype' => $data['Version'], 'object_name' => $data['Name'], 'action' => 'update'));
     }
 }
 /**
  * Option updated
  *
  * @since 0.1.0
  *
  * @param  string  $option
  * @param  string  $oldvalue
  * @param  string  $newvalue
  */
 public function updated_option($option, $oldvalue = '', $newvalue = '')
 {
     // Bail if not a whitelisted option
     if (!in_array($option, $this->get_whitelist_options())) {
         return;
     }
     // Insert activity
     wp_insert_user_activity(array('object_type' => $this->object_type, 'object_name' => $option, 'action' => 'update'));
 }