[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * BP Nouveau Members
   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   * Members Loader class
  14   *
  15   * @since 3.0.0
  16   */
  17  class BP_Nouveau_Members {
  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                  = dirname( __FILE__ );
  37          $this->is_user_home_sidebar = false;
  38      }
  39  
  40      /**
  41       * Include needed files
  42       *
  43       * @since 3.0.0
  44       */
  45  	protected function includes() {
  46          require( trailingslashit( $this->dir ) . 'functions.php' );
  47          require( trailingslashit( $this->dir ) . 'template-tags.php' );
  48      }
  49  
  50      /**
  51       * Register do_action() hooks
  52       *
  53       * @since 3.0.0
  54       */
  55  	protected function setup_actions() {
  56          $ajax_actions = array(
  57              array(
  58                  'members_filter' => array(
  59                      'function' => 'bp_nouveau_ajax_object_template_loader',
  60                      'nopriv'   => true,
  61                  ),
  62              ),
  63          );
  64  
  65          foreach ( $ajax_actions as $ajax_action ) {
  66              $action = key( $ajax_action );
  67  
  68              add_action( 'wp_ajax_' . $action, $ajax_action[ $action ]['function'] );
  69  
  70              if ( ! empty( $ajax_action[ $action ]['nopriv'] ) ) {
  71                  add_action( 'wp_ajax_nopriv_' . $action, $ajax_action[ $action ]['function'] );
  72              }
  73          }
  74  
  75          add_action( 'bp_nouveau_enqueue_scripts', 'bp_nouveau_members_enqueue_scripts' );
  76  
  77          // Actions to check whether we are in the member's default front page sidebar
  78          add_action( 'dynamic_sidebar_before', array( $this, 'user_home_sidebar_set' ), 10, 1 );
  79          add_action( 'dynamic_sidebar_after', array( $this, 'user_home_sidebar_unset' ), 10, 1 );
  80      }
  81  
  82      /**
  83       * Register add_filter() hooks
  84       *
  85       * @since 3.0.0
  86       */
  87  	protected function setup_filters() {
  88          // Add the default-front to User's front hierarchy if user enabled it (Enabled by default).
  89          add_filter( 'bp_displayed_user_get_front_template', 'bp_nouveau_member_reset_front_template', 10, 1 );
  90      }
  91  
  92      /**
  93       * Add filters to be sure the (BuddyPress) widgets display will be consistent
  94       * with the displayed user's default front page.
  95       *
  96       * @since 3.0.0
  97       *
  98       * @param string $sidebar_index The Sidebar identifier.
  99       */
 100  	public function user_home_sidebar_set( $sidebar_index = '' ) {
 101          if ( 'sidebar-buddypress-members' !== $sidebar_index ) {
 102              return;
 103          }
 104  
 105          $this->is_user_home_sidebar = true;
 106  
 107          // Add needed filters.
 108          bp_nouveau_members_add_home_widget_filters();
 109      }
 110  
 111      /**
 112       * Remove filters to be sure the (BuddyPress) widgets display will no more take
 113       * the displayed user in account.
 114       *
 115       * @since 3.0.0
 116       *
 117       * @param  string $sidebar_index The Sidebar identifier.
 118       */
 119  	public function user_home_sidebar_unset( $sidebar_index = '' ) {
 120          if ( 'sidebar-buddypress-members' !== $sidebar_index ) {
 121              return;
 122          }
 123  
 124          $this->is_user_home_sidebar = false;
 125  
 126          // Remove no more needed filters.
 127          bp_nouveau_members_remove_home_widget_filters();
 128      }
 129  }
 130  
 131  /**
 132   * Launch the Members loader class.
 133   *
 134   * @since 3.0.0
 135   */
 136  function bp_nouveau_members( $bp_nouveau = null ) {
 137      if ( is_null( $bp_nouveau ) ) {
 138          return;
 139      }
 140  
 141      $bp_nouveau->members = new BP_Nouveau_Members();
 142  }
 143  add_action( 'bp_nouveau_includes', 'bp_nouveau_members', 5, 1 );


Generated: Fri Nov 15 01:01:37 2019 Cross-referenced by PHPXref 0.7.1