/**
  * Class constructor.
  */
 public function __construct()
 {
     add_action('wp_login', function ($user_login, $user) {
         if (user_can($user, 'activate_plugins')) {
             $this->log('login');
         }
     }, 10, 2);
     /**
      * We will ignore publish activity when:
      *
      * 1. WP Easy Mode is running.
      * 2. WP-CLI is being used.
      * 3. Not triggered by a logged in user.
      */
     if (gd_is_doing_wpem() || defined('WP_CLI') && WP_CLI) {
         return;
     }
     // Themes
     add_action('switch_theme', function () {
         $this->log_user_action('publish');
     });
     // Plugins
     add_action('activated_plugin', function () {
         $this->log_user_action('publish');
     });
     add_action('deactivated_plugin', function () {
         $this->log_user_action('publish');
     });
     // Attachments
     add_action('add_attachment', function () {
         $this->log_user_action('publish');
     });
     add_action('edit_attachment', function () {
         $this->log_user_action('publish');
     });
     add_action('delete_attachment', function () {
         $this->log_user_action('publish');
     });
     // Create/edit/schedule posts
     add_action('save_post', function ($post_id, $post) {
         if (in_array($post->post_status, ['publish', 'future'])) {
             $this->log_user_action('publish');
         }
     }, 10, 2);
     // Trash posts
     add_action('transition_post_status', function ($new_status, $old_status, $post) {
         if (in_array($old_status, ['publish', 'future']) && 'trash' === $new_status) {
             $this->log_user_action('publish');
         }
     }, 10, 3);
     // Widgets
     add_action('updated_option', function ($option) {
         if (0 === strpos($option, 'widget_')) {
             $this->log_user_action('publish');
         }
     });
 }
 /**
  * Constructor.
  * Hook any needed actions/filters
  * @return void
  */
 public function __construct()
 {
     // If we've already recorded a first publish time, just bail
     if ('' == get_option('gd_system_first_publish') && !gd_is_doing_wpem()) {
         // Theme change
         add_action('switch_theme', array($this, 'record_first_publish'));
         // Update posts
         add_action('publish_post', array($this, 'record_first_publish'));
         add_action('edit_post', array($this, 'record_first_publish'));
         add_action('deleted_post', array($this, 'record_first_publish'));
     }
     // Record first login
     if ('' == get_option('gd_system_first_login')) {
         add_action('admin_init', array($this, 'record_first_login'));
     }
 }