[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BP Nouveau Members 4 * 5 * @since 3.0.0 6 * @version 6.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 * @since 6.0.0 Removes the BP Core number formatting filter on total members count. 87 */ 88 protected function setup_filters() { 89 // Add the default-front to User's front hierarchy if user enabled it (Enabled by default). 90 add_filter( 'bp_displayed_user_get_front_template', 'bp_nouveau_member_reset_front_template', 10, 1 ); 91 add_filter( 'bp_nouveau_register_scripts', 'bp_nouveau_members_register_scripts', 10, 1 ); 92 93 // The number formatting is done into the `bp_nouveau_nav_count()` template tag. 94 remove_filter( 'bp_get_total_member_count', 'bp_core_number_format' ); 95 } 96 97 /** 98 * Add filters to be sure the (BuddyPress) widgets display will be consistent 99 * with the displayed user's default front page. 100 * 101 * @since 3.0.0 102 * 103 * @param string $sidebar_index The Sidebar identifier. 104 */ 105 public function user_home_sidebar_set( $sidebar_index = '' ) { 106 if ( 'sidebar-buddypress-members' !== $sidebar_index ) { 107 return; 108 } 109 110 $this->is_user_home_sidebar = true; 111 112 // Add needed filters. 113 bp_nouveau_members_add_home_widget_filters(); 114 } 115 116 /** 117 * Remove filters to be sure the (BuddyPress) widgets display will no more take 118 * the displayed user in account. 119 * 120 * @since 3.0.0 121 * 122 * @param string $sidebar_index The Sidebar identifier. 123 */ 124 public function user_home_sidebar_unset( $sidebar_index = '' ) { 125 if ( 'sidebar-buddypress-members' !== $sidebar_index ) { 126 return; 127 } 128 129 $this->is_user_home_sidebar = false; 130 131 // Remove no more needed filters. 132 bp_nouveau_members_remove_home_widget_filters(); 133 } 134 } 135 136 /** 137 * Launch the Members loader class. 138 * 139 * @since 3.0.0 140 */ 141 function bp_nouveau_members( $bp_nouveau = null ) { 142 if ( is_null( $bp_nouveau ) ) { 143 return; 144 } 145 146 $bp_nouveau->members = new BP_Nouveau_Members(); 147 } 148 add_action( 'bp_nouveau_includes', 'bp_nouveau_members', 5, 1 );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:57 2024 | Cross-referenced by PHPXref 0.7.1 |