コード例 #1
0
 /**
  * Load built-in connectors
  */
 public static function load()
 {
     add_action('admin_notices', array(__CLASS__, 'admin_notices'));
     $connectors = array('comments', 'editor', 'installer', 'media', 'menus', 'posts', 'settings', 'taxonomies', 'users', 'widgets', 'acf', 'bbpress', 'buddypress', 'edd', 'gravityforms', 'jetpack', 'woocommerce', 'wordpress-seo');
     if (is_network_admin()) {
         $connectors[] = 'blogs';
     }
     $classes = array();
     foreach ($connectors as $connector) {
         include_once WP_STREAM_DIR . '/connectors/class-wp-stream-connector-' . $connector . '.php';
         $class = sprintf('WP_Stream_Connector_%s', str_replace('-', '_', $connector));
         if ($class::is_dependency_satisfied()) {
             $classes[] = $class;
         }
     }
     /**
      * Allows for adding additional connectors via classes that extend WP_Stream_Connector.
      *
      * @since 0.0.2
      *
      * @param array $classes An array of connector class names.
      */
     self::$connectors = apply_filters('wp_stream_connectors', $classes);
     foreach (self::$connectors as $connector) {
         self::$term_labels['stream_connector'][$connector::$name] = $connector::get_label();
     }
     // Get excluded connectors
     $excluded_connectors = array();
     foreach (self::$connectors as $connector) {
         // Check if the connectors extends the WP_Stream_Connector class, if not skip it
         if (!is_subclass_of($connector, 'WP_Stream_Connector')) {
             self::$admin_notices[] = sprintf(__("%s class wasn't loaded because it doesn't extends the %s class.", 'stream'), $connector, 'WP_Stream_Connector');
             continue;
         }
         // Store connector label
         if (!in_array($connector::$name, self::$term_labels['stream_connector'])) {
             self::$term_labels['stream_connector'][$connector::$name] = $connector::get_label();
         }
         $connector_name = $connector::$name;
         $is_excluded = in_array($connector_name, $excluded_connectors);
         /**
          * Allows excluded connectors to be overridden and registered.
          *
          * @since 1.3.0
          *
          * @param bool   $is_excluded         True if excluded, otherwise false.
          * @param string $connector           The current connector's slug.
          * @param array  $excluded_connectors An array of all excluded connector slugs.
          */
         $is_excluded_connector = apply_filters('wp_stream_check_connector_is_excluded', $is_excluded, $connector_name, $excluded_connectors);
         if ($is_excluded_connector) {
             continue;
         }
         $connector::register();
         // Link context labels to their connector
         self::$contexts[$connector::$name] = $connector::get_context_labels();
         // Add new terms to our label lookup array
         self::$term_labels['stream_action'] = array_merge(self::$term_labels['stream_action'], $connector::get_action_labels());
         self::$term_labels['stream_context'] = array_merge(self::$term_labels['stream_context'], $connector::get_context_labels());
     }
     $connectors = self::$term_labels['stream_connector'];
     /**
      * Fires after all connectors have been registered.
      *
      * @since 1.3.0
      *
      * @param array all register connectors labels array
      */
     do_action('wp_stream_after_connectors_registration', $connectors);
 }
コード例 #2
0
ファイル: connector.php プロジェクト: xwp/stream-legacy
 /**
  * Log handler
  *
  * @param  string $message   sprintf-ready error message string
  * @param  array  $args      sprintf (and extra) arguments to use
  * @param  int    $object_id Target object id
  * @param  array  $contexts  Contexts of the action
  * @param  int    $user_id   User responsible for the action
  *
  * @internal param string $action Action performed (stream_action)
  * @return void
  */
 public static function log($message, $args, $object_id, $contexts, $user_id = null)
 {
     // Prevent inserting Excluded Context & Actions
     foreach ($contexts as $context => $action) {
         if (!WP_Stream_Connectors::is_logging_enabled('contexts', $context)) {
             unset($contexts[$context]);
         } else {
             if (!WP_Stream_Connectors::is_logging_enabled('actions', $action)) {
                 unset($contexts[$context]);
             }
         }
     }
     if (count($contexts) == 0) {
         return;
     }
     $class = get_called_class();
     return WP_Stream_Log::get_instance()->log($class::$name, $message, $args, $object_id, $contexts, $user_id);
 }
コード例 #3
0
ファイル: connectors.php プロジェクト: xwp/stream-legacy
 /**
  * Load built-in connectors
  */
 public static function load()
 {
     add_action('admin_notices', array(__CLASS__, 'admin_notices'));
     require_once WP_STREAM_INC_DIR . 'connector.php';
     $connectors = array('blogs', 'comments', 'editor', 'installer', 'media', 'menus', 'posts', 'settings', 'taxonomies', 'users', 'widgets');
     $classes = array();
     foreach ($connectors as $connector) {
         include_once WP_STREAM_DIR . '/connectors/' . $connector . '.php';
         $class = "WP_Stream_Connector_{$connector}";
         $classes[] = $class;
     }
     $exclude_all_connector = false;
     // Check if logging action is enable for user or provide a hook for plugin to override on specific cases
     if (!self::is_logging_enabled_for_user()) {
         $exclude_all_connector = true;
     }
     // Check if logging action is enable for ip or provide a hook for plugin to override on specific cases
     if (!self::is_logging_enabled_for_ip()) {
         $exclude_all_connector = true;
     }
     /**
      * Filter allows for adding additional connectors via classes that extend
      * WP_Stream_Connector
      *
      * @param  array  Connector Class names
      * @return array  Updated Array of Connector Class names
      */
     self::$connectors = apply_filters('wp_stream_connectors', $classes);
     foreach (self::$connectors as $connector) {
         self::$term_labels['stream_connector'][$connector::$name] = $connector::get_label();
     }
     // Get excluded connectors
     $excluded_connectors = WP_Stream_Settings::get_excluded_by_key('connectors');
     foreach (self::$connectors as $connector) {
         // Check if the connectors extends the WP_Stream_Connector class, if not skip it
         if (!is_subclass_of($connector, 'WP_Stream_Connector')) {
             self::$admin_notices[] = sprintf(__("%s class wasn't loaded because it doesn't extends the %s class.", 'stream'), $connector, 'WP_Stream_Connector');
             continue;
         }
         // Store connector label
         if (!in_array($connector::$name, self::$term_labels['stream_connector'])) {
             self::$term_labels['stream_connector'][$connector::$name] = $connector::get_label();
         }
         /**
          * Filter allows to continue register excluded connector
          *
          * @param boolean TRUE if exclude otherwise false
          * @param string connector unique name
          * @param array Excluded connector array
          */
         $is_excluded_connector = apply_filters('wp_stream_check_connector_is_excluded', in_array($connector::$name, $excluded_connectors), $connector::$name, $excluded_connectors);
         if ($is_excluded_connector) {
             continue;
         }
         if (!$exclude_all_connector) {
             $connector::register();
         }
         // Add new terms to our label lookup array
         self::$term_labels['stream_action'] = array_merge(self::$term_labels['stream_action'], $connector::get_action_labels());
         self::$term_labels['stream_context'] = array_merge(self::$term_labels['stream_context'], $connector::get_context_labels());
     }
     /**
      * This allow to perform action after all connectors registration
      *
      * @param array all register connectors labels array
      */
     do_action('wp_stream_after_connectors_registration', self::$term_labels['stream_connector']);
 }
コード例 #4
0
ファイル: users.php プロジェクト: xwp/stream-legacy
 /**
  * Log user login
  *
  * @action set_logged_in_cookie
  */
 public static function callback_set_logged_in_cookie($logged_in_cookie, $expire, $expiration, $user_id)
 {
     $user = get_user_by('id', $user_id);
     if (WP_Stream_Connectors::is_logging_enabled_for_user($user)) {
         self::log(__('%s logged in', 'stream'), array('display_name' => $user->display_name), $user->ID, array('sessions' => 'login'), $user->ID);
     }
 }
コード例 #5
0
ファイル: db-updates.php プロジェクト: xwp/stream-legacy
/**
 * Version 1.2.8
 *
 * Update existing Media records so that the context is the media's attachment type.
 *
 * @param string $db_version Database version updating from
 * @param string $current_version Database version updating to
 *
 * @return string $current_version if updated correctly
 */
function wp_stream_update_128($db_version, $current_version)
{
    do_action('wp_stream_before_db_update_' . $db_version, $current_version);
    add_action('wp_stream_after_connectors_registration', 'wp_stream_update_migrate_media_to_attachment_type');
    WP_Stream_Connectors::load();
    do_action('wp_stream_after_db_update_' . $db_version, $current_version, false);
    return $current_version;
}