dpoint' => 'messages', 'BP_REST_Sitewide_Notices_Endpoint' => 'messages', 'BP_REST_Notifications_Endpoint' => 'notifications', 'BP_REST_XProfile_Fields_Endpoint' => 'xprofile', 'BP_REST_XProfile_Field_Groups_Endpoint' => 'xprofile', 'BP_REST_XProfile_Data_Endpoint' => 'xprofile', ); $component = null; // First check to see if the class is one without a properly namespaced name. if ( isset( $irregular_map[ $class ] ) ) { $component = $irregular_map[ $class ]; // Next chunk is usually the component name. } elseif ( in_array( $class_parts[1], $components, true ) ) { $component = $class_parts[1]; } if ( ! $component ) { return; } // Sanitize class name. $class = strtolower( str_replace( '_', '-', $class ) ); if ( 'bp-rest-attachments' === $class ) { $path = dirname( __FILE__ ) . "/bp-{$component}/classes/trait-attachments.php"; } else { $path = dirname( __FILE__ ) . "/bp-{$component}/classes/class-{$class}.php"; } // Sanity check. if ( ! file_exists( $path ) ) { return; } /* * Sanity check 2 - Check if component is active before loading class. * Skip if PHPUnit is running, or BuddyPress is installing for the first time. */ if ( ! in_array( $component, array( 'core', 'members' ), true ) && ! bp_is_active( $component ) && ! $this->is_phpunit_running ) { return; } require $path; } /** * Set up the default hooks and actions. * * @since 1.6.0 */ private function setup_actions() { // Add actions to plugin activation and deactivation hooks. add_action( 'activate_' . $this->basename, 'bp_activation' ); add_action( 'deactivate_' . $this->basename, 'bp_deactivation' ); // If BuddyPress is being deactivated, do not add any actions. if ( bp_is_deactivation( $this->basename ) ) { return; } // Array of BuddyPress core actions. $actions = array( 'setup_theme', // Setup the default theme compat. 'setup_current_user', // Setup currently logged in user. 'register_post_types', // Register post types. 'register_post_statuses', // Register post statuses. 'register_taxonomies', // Register taxonomies. 'register_views', // Register the views. 'register_theme_packages', // Register bundled theme packages (bp-themes). 'load_textdomain', // Load textdomain. 'add_rewrite_tags', // Add rewrite tags. 'generate_rewrite_rules', // Generate rewrite rules. ); // Add the actions. foreach ( $actions as $class_action ) { if ( method_exists( $this, $class_action ) ) { add_action( 'bp_' . $class_action, array( $this, $class_action ), 5 ); } } /** * Fires after the setup of all BuddyPress actions. * * Includes bbp-core-hooks.php. * * @since 1.7.0 * * @param BuddyPress $this. Current BuddyPress instance. Passed by reference. */ do_action_ref_array( 'bp_after_setup_actions', array( &$this ) ); } /** * Private method to align the active and database versions. * * @since 1.7.0 */ private function versions() { // Get the possible DB versions (boy is this gross). $versions = array(); $versions['1.6-single'] = get_blog_option( $this->root_blog_id, '_bp_db_version' ); // 1.6-single exists, so trust it. if ( ! empty( $versions['1.6-single'] ) ) { $this->db_version_raw = (int) $versions['1.6-single']; // If no 1.6-single exists, use the max of the others. } else { $versions['1.2'] = get_site_option( 'bp-core-db-version' ); $versions['1.5-multi'] = get_site_option( 'bp-db-version' ); $versions['1.6-multi'] = get_site_option( '_bp_db_version' ); $versions['1.5-single'] = get_blog_option( $this->root_blog_id, 'bp-db-version' ); // Remove empty array items. $versions = array_filter( $versions ); $this->db_version_raw = (int) ( ! empty( $versions ) ) ? (int) max( $versions ) : 0; } } /** Public Methods ********************************************************/ /** * Set up BuddyPress's legacy theme directory. * * Starting with version 1.2, and ending with version 1.8, BuddyPress * registered a custom theme directory - bp-themes - which contained * the bp-default theme. Since BuddyPress 1.9, bp-themes is no longer * registered (and bp-default no longer offered) on new installations. * Sites using bp-default (or a child theme of bp-default) will * continue to have bp-themes registered as before. * Since 12.0, BuddyPress is no longer including BP Default. To find it * back, you need to install and activate the BP Classic plugin. * * @since 1.5.0 * @deprecated 12.0.0 */ public function register_theme_directory() { _deprecated_function( __METHOD__, '12.0.0' ); } /** * Register bundled theme packages. * * Note that since we currently have complete control over bp-themes and * the bp-legacy folders, it's fine to hardcode these here. If at a * later date we need to automate this, an API will need to be built. * * @since 1.7.0 */ public function register_theme_packages() { // Register the default theme compatibility package. bp_register_theme_package( array( 'id' => 'legacy', 'name' => __( 'BuddyPress Legacy', 'buddypress' ), 'version' => bp_get_version(), 'dir' => trailingslashit( $this->themes_dir . '/bp-legacy' ), 'url' => trailingslashit( $this->themes_url . '/bp-legacy' ), ) ); bp_register_theme_package( array( 'id' => 'nouveau', 'name' => __( 'BuddyPress Nouveau', 'buddypress' ), 'version' => bp_get_version(), 'dir' => trailingslashit( $this->themes_dir . '/bp-nouveau' ), 'url' => trailingslashit( $this->themes_url . '/bp-nouveau' ), ) ); // Register the basic theme stack. This is really dope. bp_register_template_stack( 'get_stylesheet_directory', 10 ); bp_register_template_stack( 'get_template_directory', 12 ); bp_register_template_stack( 'bp_get_theme_compat_dir', 14 ); } /** * Set up the default BuddyPress theme compatibility location. * * @since 1.7.0 */ public function setup_theme() { // Bail if something already has this under control. if ( ! empty( $this->theme_compat->theme ) ) { return; } // Setup the theme package to use for compatibility. bp_setup_theme_compat( bp_get_theme_package_id() ); } }