[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-templates/bp-nouveau/includes/activity/ -> loader.php (source)

   1  <?php
   2  /**
   3   * BP Nouveau Activity
   4   *
   5   * @since 3.0.0
   6   * @version 8.0.0
   7   */
   8  
   9  // Exit if accessed directly.
  10  defined( 'ABSPATH' ) || exit;
  11  
  12  /**
  13   * Activity Loader class
  14   *
  15   * @since 3.0.0
  16   */
  17  class BP_Nouveau_Activity {
  18      /**
  19       * Nouveau Activity directory.
  20       *
  21       * @since 3.0.0
  22       * @var string
  23       */
  24      public $dir = '';
  25  
  26      /**
  27       * RSS feed link data.
  28       *
  29       * @since 3.0.0
  30       * @var string
  31       */
  32      public $current_rss_feed = array();
  33  
  34      /**
  35       * Constructor
  36       *
  37       * @since 3.0.0
  38       */
  39  	public function __construct() {
  40          $this->setup_globals();
  41          $this->includes();
  42          $this->setup_actions();
  43          $this->setup_filters();
  44      }
  45  
  46      /**
  47       * Globals
  48       *
  49       * @since 3.0.0
  50       */
  51  	protected function setup_globals() {
  52          $this->dir = trailingslashit( dirname( __FILE__ ) );
  53      }
  54  
  55      /**
  56       * Include needed files
  57       *
  58       * @since 3.0.0
  59       */
  60  	protected function includes() {
  61          require $this->dir . 'functions.php';
  62          require $this->dir . 'template-tags.php';
  63  
  64          if ( bp_core_retain_legacy_widgets() ) {
  65              require $this->dir . 'widgets.php';
  66          }
  67  
  68          // Test suite requires the AJAX functions early.
  69          if ( function_exists( 'tests_add_filter' ) ) {
  70              require $this->dir . 'ajax.php';
  71  
  72          // Load AJAX code only on AJAX requests.
  73          } else {
  74              add_action( 'admin_init', function() {
  75                  // AJAX condtion.
  76                  if ( defined( 'DOING_AJAX' ) && true === DOING_AJAX &&
  77                      // Check to see if action is activity-specific.
  78                      ( false !== strpos( $_REQUEST['action'], 'activity' ) || ( 'post_update' === $_REQUEST['action'] ) )
  79                  ) {
  80                      require bp_nouveau()->activity->dir . 'ajax.php';
  81                  }
  82              } );
  83          }
  84      }
  85  
  86      /**
  87       * Register do_action() hooks
  88       *
  89       * @since 3.0.0
  90       */
  91  	protected function setup_actions() {
  92          add_action( 'bp_nouveau_enqueue_scripts', 'bp_nouveau_activity_enqueue_scripts' );
  93          add_action( 'bp_nouveau_notifications_init_filters', 'bp_nouveau_activity_notification_filters' );
  94  
  95          if ( bp_core_retain_legacy_widgets() ) {
  96              add_action( 'bp_widgets_init', array( 'BP_Latest_Activities', 'register_widget' ) );
  97          }
  98  
  99          $bp = buddypress();
 100  
 101          if ( bp_is_akismet_active() && isset( $bp->activity->akismet ) ) {
 102              remove_action( 'bp_activity_entry_meta', array( $bp->activity->akismet, 'add_activity_spam_button' ) );
 103              remove_action( 'bp_activity_comment_options', array( $bp->activity->akismet, 'add_activity_comment_spam_button' ) );
 104          }
 105      }
 106  
 107      /**
 108       * Register add_filter() hooks
 109       *
 110       * @since 3.0.0
 111       */
 112  	protected function setup_filters() {
 113          // Register customizer controls.
 114          add_filter( 'bp_nouveau_customizer_controls', 'bp_nouveau_activity_customizer_controls', 10, 1 );
 115  
 116          // Register activity scripts
 117          add_filter( 'bp_nouveau_register_scripts', 'bp_nouveau_activity_register_scripts', 10, 1 );
 118  
 119          // Localize Scripts
 120          add_filter( 'bp_core_get_js_strings', 'bp_nouveau_activity_localize_scripts', 10, 1 );
 121  
 122          add_filter( 'bp_get_activity_action_pre_meta', 'bp_nouveau_activity_secondary_avatars', 10, 2 );
 123          add_filter( 'bp_get_activity_css_class', 'bp_nouveau_activity_scope_newest_class', 10, 1 );
 124      }
 125  }
 126  
 127  /**
 128   * Launch the Activity loader class.
 129   *
 130   * @since 3.0.0
 131   */
 132  function bp_nouveau_activity( $bp_nouveau = null ) {
 133      if ( is_null( $bp_nouveau ) ) {
 134          return;
 135      }
 136  
 137      $bp_nouveau->activity = new BP_Nouveau_Activity();
 138  }
 139  add_action( 'bp_nouveau_includes', 'bp_nouveau_activity', 10, 1 );


Generated: Thu Dec 26 01:01:04 2024 Cross-referenced by PHPXref 0.7.1