/** * Setup the theme's features * * Note: BP Legacy's buddypress-functions.php is not loaded in WP Administration * as it's loaded using bp_locate_template(). That's why this function is here. * * @since 2.4.0 * * @global $content_width the content width of the theme */ function bp_register_theme_compat_default_features() { global $content_width; // Do not set up default features on deactivation if (bp_is_deactivation()) { return; } // If the current theme doesn't need theme compat, bail at this point. if (!bp_use_theme_compat_with_current_theme()) { return; } // Make sure BP Legacy is the Theme Compat in use. if ('legacy' !== bp_get_theme_compat_id()) { return; } // Get the theme $current_theme = wp_get_theme(); $theme_handle = $current_theme->get_stylesheet(); $parent = $current_theme->parent(); if ($parent) { $theme_handle = $parent->get_stylesheet(); } /** * Since Companion stylesheets, the $content_width is smaller * than the width used by BuddyPress, so we need to manually set the * content width for the concerned themes. * * array( stylesheet => content width used by BuddyPress ) */ $bp_content_widths = array('twentyfifteen' => 1300, 'twentyfourteen' => 955, 'twentythirteen' => 890); // Default values $bp_content_width = (int) $content_width; $bp_handle = 'bp-legacy-css'; // Specific to themes having companion stylesheets if (isset($bp_content_widths[$theme_handle])) { $bp_content_width = $bp_content_widths[$theme_handle]; $bp_handle = 'bp-' . $theme_handle; } if (is_rtl()) { $bp_handle .= '-rtl'; } $top_offset = 150; $avatar_height = apply_filters('bp_core_avatar_full_height', $top_offset); if ($avatar_height > $top_offset) { $top_offset = $avatar_height; } bp_set_theme_compat_feature('legacy', array('name' => 'cover_image', 'settings' => array('components' => array('xprofile', 'groups'), 'width' => $bp_content_width, 'height' => $top_offset + round($avatar_height / 2), 'callback' => 'bp_legacy_theme_cover_image', 'theme_handle' => $bp_handle))); }
/** * 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_current_user', 'register_post_types', 'register_post_statuses', 'register_taxonomies', 'register_views', 'register_theme_directory', 'register_theme_packages', 'load_textdomain', 'add_rewrite_tags', '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)); }
/** * Attempt to load a custom BP functions file, similar to each themes functions.php file. * * @since 1.7.0 * * @global string $pagenow * @uses bp_locate_template() */ function bp_load_theme_functions() { global $pagenow, $wp_query; // do not load our custom BP functions file if theme compat is disabled if (!bp_use_theme_compat_with_current_theme()) { return; } // Do not include on BuddyPress deactivation if (bp_is_deactivation()) { return; } // If the $wp_query global is empty (the main query has not been run, // or has been reset), load_template() will fail at setting certain // global values. This does not happen on a normal page load, but can // cause problems when running automated tests if (!is_a($wp_query, 'WP_Query')) { return; } // Only include if not installing or if activating via wp-activate.php if (!defined('WP_INSTALLING') || 'wp-activate.php' === $pagenow) { bp_locate_template('buddypress-functions.php', true); } }
/** * Set up the default hooks and actions. * * @since BuddyPress (1.6.0) * @access private * * @uses register_activation_hook() To register the activation hook. * @uses register_deactivation_hook() To register the deactivation hook. * @uses add_action() To add various actions. */ 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_current_user', 'register_post_types', 'register_post_statuses', 'register_taxonomies', 'register_views', 'register_theme_directory', 'register_theme_packages', 'load_textdomain', 'add_rewrite_tags', 'generate_rewrite_rules'); // Add the actions foreach ($actions as $class_action) { add_action('bp_' . $class_action, array($this, $class_action), 5); } // All BuddyPress actions are setup (includes bbp-core-hooks.php) do_action_ref_array('bp_after_setup_actions', array(&$this)); }
/** * Setup the default hooks and actions * * @since BuddyPress (1.6) * @access private * * @uses register_activation_hook() To register the activation hook * @uses register_deactivation_hook() To register the deactivation hook * @uses add_action() To add various actions */ 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_current_user', 'register_post_types', 'register_post_statuses', 'register_taxonomies', 'register_views', 'register_theme_directory', 'load_textdomain', 'add_rewrite_tags', 'generate_rewrite_rules'); // Add the actions foreach ($actions as $class_action) { add_action('bp_' . $class_action, array($this, $class_action), 5); } // Setup the BuddyPress theme directory register_theme_directory($this->themes_dir); }
/** * Set up the default hooks and actions. * * @since BuddyPress (1.6.0) * @access private * * @uses register_activation_hook() To register the activation hook. * @uses register_deactivation_hook() To register the deactivation hook. * @uses add_action() To add various actions. */ 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_directory', // Register the theme directory '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 ); } } // All BuddyPress actions are setup (includes bbp-core-hooks.php) do_action_ref_array( 'bp_after_setup_actions', array( &$this ) ); }
/** * Attempt to load a custom BuddyPress functions file, similar to each themes * functions.php file. * * @since BuddyPress (1.7) * * @global string $pagenow * @uses bp_locate_template() */ function bp_load_theme_functions() { global $pagenow; // Do not include on BuddyPress deactivation if (bp_is_deactivation()) { return; } // Only include if not installing or if activating via wp-activate.php if (!defined('WP_INSTALLING') || 'wp-activate.php' === $pagenow) { bp_locate_template('buddypress-functions.php', true); } }