[ 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 3.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       * Constructor
  20       *
  21       * @since 3.0.0
  22       */
  23  	public function __construct() {
  24          $this->setup_globals();
  25          $this->includes();
  26          $this->setup_actions();
  27          $this->setup_filters();
  28      }
  29  
  30      /**
  31       * Globals
  32       *
  33       * @since 3.0.0
  34       */
  35  	protected function setup_globals() {
  36          $this->dir = trailingslashit( dirname( __FILE__ ) );
  37      }
  38  
  39      /**
  40       * Include needed files
  41       *
  42       * @since 3.0.0
  43       */
  44  	protected function includes() {
  45          require $this->dir . 'functions.php';
  46          require $this->dir . 'template-tags.php';
  47          require $this->dir . 'widgets.php';
  48  
  49          // Test suite requires the AJAX functions early.
  50          if ( function_exists( 'tests_add_filter' ) ) {
  51              require $this->dir . 'ajax.php';
  52  
  53          // Load AJAX code only on AJAX requests.
  54          } else {
  55              add_action( 'admin_init', function() {
  56                  // AJAX condtion.
  57                  if ( defined( 'DOING_AJAX' ) && true === DOING_AJAX &&
  58                      // Check to see if action is activity-specific.
  59                      ( false !== strpos( $_REQUEST['action'], 'activity' ) || ( 'post_update' === $_REQUEST['action'] ) )
  60                  ) {
  61                      require bp_nouveau()->activity->dir . 'ajax.php';
  62                  }
  63              } );
  64          }
  65      }
  66  
  67      /**
  68       * Register do_action() hooks
  69       *
  70       * @since 3.0.0
  71       */
  72  	protected function setup_actions() {
  73          add_action( 'bp_nouveau_enqueue_scripts', 'bp_nouveau_activity_enqueue_scripts' );
  74          add_action( 'bp_widgets_init', array( 'BP_Latest_Activities', 'register_widget' ) );
  75          add_action( 'bp_nouveau_notifications_init_filters', 'bp_nouveau_activity_notification_filters' );
  76  
  77          $bp = buddypress();
  78  
  79          if ( bp_is_akismet_active() && isset( $bp->activity->akismet ) ) {
  80              remove_action( 'bp_activity_entry_meta', array( $bp->activity->akismet, 'add_activity_spam_button' ) );
  81              remove_action( 'bp_activity_comment_options', array( $bp->activity->akismet, 'add_activity_comment_spam_button' ) );
  82          }
  83      }
  84  
  85      /**
  86       * Register add_filter() hooks
  87       *
  88       * @since 3.0.0
  89       */
  90  	protected function setup_filters() {
  91          // Register customizer controls.
  92          add_filter( 'bp_nouveau_customizer_controls', 'bp_nouveau_activity_customizer_controls', 10, 1 );
  93  
  94          // Register activity scripts
  95          add_filter( 'bp_nouveau_register_scripts', 'bp_nouveau_activity_register_scripts', 10, 1 );
  96  
  97          // Localize Scripts
  98          add_filter( 'bp_core_get_js_strings', 'bp_nouveau_activity_localize_scripts', 10, 1 );
  99  
 100          add_filter( 'bp_get_activity_action_pre_meta', 'bp_nouveau_activity_secondary_avatars', 10, 2 );
 101          add_filter( 'bp_get_activity_css_class', 'bp_nouveau_activity_scope_newest_class', 10, 1 );
 102      }
 103  }
 104  
 105  /**
 106   * Launch the Activity loader class.
 107   *
 108   * @since 3.0.0
 109   */
 110  function bp_nouveau_activity( $bp_nouveau = null ) {
 111      if ( is_null( $bp_nouveau ) ) {
 112          return;
 113      }
 114  
 115      $bp_nouveau->activity = new BP_Nouveau_Activity();
 116  }
 117  add_action( 'bp_nouveau_includes', 'bp_nouveau_activity', 10, 1 );


Generated: Wed Jul 24 01:01:43 2019 Cross-referenced by PHPXref 0.7.1