/**
  * Public constructor
  */
 public static function load()
 {
     // User and role caps
     add_filter('user_has_cap', array(__CLASS__, '_filter_user_caps'), 10, 4);
     add_filter('role_has_cap', array(__CLASS__, '_filter_role_caps'), 10, 3);
     if (WP_Stream_API::is_restricted()) {
         return;
     }
     // Add Reports settings tab to Stream settings
     add_filter('wp_stream_settings_option_fields', array(__CLASS__, '_register_settings'));
 }
 /**
  * Add a specific body class to all Stream admin screens
  *
  * @filter admin_body_class
  *
  * @param  string $classes
  *
  * @return string $classes
  */
 public static function admin_body_class($classes)
 {
     if (self::is_stream_screen()) {
         $classes .= sprintf(' %s ', self::ADMIN_BODY_CLASS);
         if (WP_Stream::is_connected() || WP_Stream::is_development_mode()) {
             $classes .= ' wp_stream_connected ';
         } else {
             $classes .= ' wp_stream_disconnected ';
         }
         if (WP_Stream_API::is_restricted()) {
             $classes .= ' wp_stream_restricted ';
         }
     }
     $settings_pages = array(self::SETTINGS_PAGE_SLUG);
     if (isset($_GET['page']) && in_array($_GET['page'], $settings_pages)) {
         $classes .= sprintf(' %s ', self::SETTINGS_PAGE_SLUG);
     }
     return $classes;
 }
    public function load_page()
    {
        if (WP_Stream_API::is_restricted()) {
            add_action('in_admin_header', array(__CLASS__, 'in_admin_header'));
            return;
        }
        if (is_admin() && WP_Stream_Reports_Settings::is_first_visit()) {
            $this->setup_user();
        }
        $this->existing_records = $this->get_existing_records();
        // Add screen option for chart height
        add_filter('screen_settings', array($this, 'chart_height_display'), 10, 2);
        // Enqueue all core scripts required for this page to work
        add_screen_option('layout_columns', array('max' => 2, 'default' => 2));
        // Add all metaboxes
        foreach (self::$sections as $key => $section) {
            $delete_url = add_query_arg(array_merge(array('action' => 'wp_stream_reports_delete_metabox', 'key' => $key), WP_Stream_Reports::$nonce), admin_url('admin-ajax.php'));
            //  Configure button
            $configure = sprintf('<span class="postbox-title-action">
					<a href="javascript:void(0);" class="edit-box open-box">%3$s</a>
				</span>
				<span class="postbox-title-action postbox-delete-action">
					<a href="%1$s">
						%2$s
					</a>
				</span>', esc_url($delete_url), esc_html__('Delete', 'stream'), esc_html__('Configure', 'stream'));
            // Parse default argument
            $section = $this->parse_section($section);
            // Set the key for template use
            $section['key'] = $key;
            $section['generated_title'] = $this->get_generated_title($section);
            // Generate the title automatically if not already set
            $title = empty($section['title']) ? $section['generated_title'] : $section['title'];
            // Add the actual metabox
            add_meta_box(self::META_PREFIX . $key, sprintf('<span class="title">%s</span>%s', esc_html($title), $configure), array($this, 'metabox_content'), WP_Stream_Reports::$screen_id, $section['context'], $section['priority'], $section);
        }
    }
 /**
  * Apply list actions, and load our list-table object
  *
  * @action load-edit.php
  *
  * @return void
  */
 public function load_list_table()
 {
     global $typenow;
     if (self::POSTTYPE !== $typenow || WP_Stream_API::is_restricted(true)) {
         return;
     }
     require_once WP_STREAM_NOTIFICATIONS_INC_DIR . 'class-wp-stream-notifications-list-table.php';
     WP_Stream_Notifications_List_Table::get_instance();
 }
 /**
  * Load our classes, actions/filters, only if our big brother is activated.
  * GO GO GO!
  *
  * @return void
  */
 public function load()
 {
     if (!apply_filters('wp_stream_notifications_disallow_site_access', false) && (WP_Stream::is_connected() || WP_Stream::is_development_mode())) {
         add_action('admin_menu', array($this, 'register_menu'), 11);
     }
     // Load settings, enabling extensions to hook in
     require_once WP_STREAM_NOTIFICATIONS_INC_DIR . 'class-wp-stream-notifications-settings.php';
     add_action('init', array('WP_Stream_Notifications_Settings', 'load'), 9);
     if (WP_Stream_API::is_restricted()) {
         add_action('in_admin_header', array(__CLASS__, 'in_admin_header'));
         return;
     }
     // Include all adapters
     include_once WP_STREAM_NOTIFICATIONS_INC_DIR . 'class-wp-stream-notifications-adapter.php';
     $adapters = array('email', 'push', 'sms');
     foreach ($adapters as $adapter) {
         include WP_STREAM_NOTIFICATIONS_INC_DIR . 'adapters/class-wp-stream-notifications-adapter-' . $adapter . '.php';
     }
     // Load network class
     if (is_multisite()) {
         require_once WP_STREAM_NOTIFICATIONS_INC_DIR . 'class-wp-stream-notifications-network.php';
         $this->network = new WP_Stream_Notifications_Network();
         if (WP_Stream_Network::is_network_activated()) {
             add_action('network_admin_menu', array($this, 'register_menu'), 11);
         }
         // Allow Stream to override the admin_menu creation if on multisite
         add_filter('wp_stream_notifications_disallow_site_access', array('WP_Stream_Network', 'disable_admin_access'));
     }
     // Load Matcher
     include_once WP_STREAM_NOTIFICATIONS_INC_DIR . 'class-wp-stream-notifications-matcher.php';
     $this->matcher = new WP_Stream_Notifications_Matcher();
 }