/** * Filters template for the user compliments tab. * * @since 0.0.1 * @package BuddyPress_Compliments * * @global object $bp BuddyPress instance. * @param string $found_template Located template file. * @param array $templates The template array. * @return string Template file. */ function bp_compliments_load_template_filter($found_template, $templates) { global $bp; // Only filter the template location when we're on the compliments component pages. if (!bp_is_current_component($bp->compliments->compliments->slug)) { return $found_template; } if (empty($found_template)) { bp_register_template_stack('bp_compliments_get_template_directory', 14); // locate_template() will attempt to find the plugins.php template in the // child and parent theme and return the located template when found // // plugins.php is the preferred template to use, since all we'd need to do is // inject our content into BP // // note: this is only really relevant for bp-default themes as theme compat // will kick in on its own when this template isn't found $found_template = locate_template('members/single/plugins.php', false, false); // add our hook to inject content into BP add_action('bp_template_content', 'bp_compliments_single_compliments_content'); } /** * Filters the compliment page template. * * @since 0.0.1 * @package BuddyPress_Compliments * * @param string $found_template Located template file. */ return apply_filters('bp_compliments_load_template_filter', $found_template); }
/** * Initial component setup. */ public function __construct() { global $bp; parent::start('humcore_deposits', __('Humanities CORE Deposits', 'humcore_domain'), dirname(__FILE__)); $this->includes(); $this->setup_filters(); bp_register_template_stack('humcore_register_template_location', 14); $bp->active_components[$this->id] = '1'; }
function buatp_load_template_filter($found_template, $templates) { global $bp; if (!bp_is_current_component($bp->buatp->slug)) { return $found_template; } if (empty($found_template)) { bp_register_template_stack('buatp_get_template_directory', 14); add_action('bp_template_include_reset_dummy_post_data', 'buatp_dummy_post'); add_filter('bp_replace_the_content', 'buatp_get_template_part'); } return apply_filters('buatp_load_template_filter', $found_template); }
public function restrict_blocked() { global $bp; // if site admin, skip check if ($bp->loggedin_user->is_site_admin == 1) { return; } if (bp_is_user() && !bp_is_my_profile() && is_user_logged_in()) { $displayed_id = bp_displayed_user_id(); $user_id = get_current_user_id(); if ($this->check_blocking($user_id, $displayed_id)) { if (bp_is_current_component('blocked')) { bp_register_template_stack('BP_Block_User::register_template_location'); add_filter('bp_get_template_part', array($this, 'replace_template'), 10, 3); bp_core_load_template('members/single/plugins'); } else { wp_redirect(bp_get_members_component_link('') . 'blocked/'); exit; } } } }
/** * 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 Default', 'buddypress'), 'version' => bp_get_version(), 'dir' => trailingslashit($this->themes_dir . '/bp-legacy'), 'url' => trailingslashit($this->themes_url . '/bp-legacy'))); // 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); }
$locations = array('buddypress', 'community', ''); return apply_filters('bp_get_template_locations', $locations, $templates); } } if (!function_exists('bp_add_template_stack_locations')) { /** * @since 1.2 */ function bp_add_template_stack_locations($stacks = array()) { $retval = array(); // Get alternate locations $locations = bp_get_template_locations(); // Loop through locations and stacks and combine foreach ((array) $stacks as $stack) { foreach ((array) $locations as $custom_location) { $retval[] = untrailingslashit(trailingslashit($stack) . $custom_location); } } return apply_filters('bp_add_template_stack_locations', array_unique($retval), $stacks); } } // HOOKS //////////////////////////////////////////////////////////// // Filter BuddyPress template locations if (!has_filter('bp_get_template_stack', 'bp_add_template_stack_locations')) { add_filter('bp_get_template_stack', 'bp_add_template_stack_locations'); } // Register template stacks bp_register_template_stack('get_stylesheet_directory', 10); bp_register_template_stack('get_template_directory', 12);
/** * BP Follow template loader. * * This function sets up BP Follow to use custom templates. * * If a template does not exist in the current theme, we will use our own * bundled templates. * * We're doing two things here: * 1) Support the older template format for themes that are using them * for backwards-compatibility (the template passed in * {@link bp_core_load_template()}). * 2) Route older template names to use our new template locations and * format. * * View the inline doc for more details. * * @since 1.0 */ function bp_follow_load_template_filter($found_template, $templates) { global $bp; // Only filter the template location when we're on the follow component pages. if (!bp_is_current_component($bp->follow->followers->slug) && !bp_is_current_component($bp->follow->following->slug)) { return $found_template; } // $found_template is not empty when the older template files are found in the // parent and child theme // // /wp-content/themes/YOUR-THEME/members/single/following.php // /wp-content/themes/YOUR-THEME/members/single/followers.php // // The older template files utilize a full template ( get_header() + // get_footer() ), which sucks for themes and theme compat. // // When the older template files are not found, we use our new template method, // which will act more like a template part. if (empty($found_template)) { // register our theme compat directory // // this tells BP to look for templates in our plugin directory last // when the template isn't found in the parent / child theme bp_register_template_stack('bp_follow_get_template_directory', 14); // locate_template() will attempt to find the plugins.php template in the // child and parent theme and return the located template when found // // plugins.php is the preferred template to use, since all we'd need to do is // inject our content into BP // // note: this is only really relevant for bp-default themes as theme compat // will kick in on its own when this template isn't found $found_template = locate_template('members/single/plugins.php', false, false); // add AJAX support to the members loop // can disable with the 'bp_follow_allow_ajax_on_follow_pages' filter if (apply_filters('bp_follow_allow_ajax_on_follow_pages', true)) { // add the "Order by" dropdown filter add_action('bp_member_plugin_options_nav', 'bp_follow_add_members_dropdown_filter'); // add ability to use AJAX add_action('bp_after_member_plugin_template', 'bp_follow_add_ajax_to_members_loop'); } // add our hook to inject content into BP // // note the new template name for our template part add_action('bp_template_content', create_function('', "\n\t\t\tbp_get_template_part( 'members/single/follow' );\n\t\t")); } return apply_filters('bp_follow_load_template_filter', $found_template); }
function uni_avatar_bp_start() { if (function_exists('bp_register_template_stack')) { bp_register_template_stack('uni_avatar_register_template_location'); } // if viewing a member page, overload the template if (bp_is_user()) { add_filter('bp_get_template_part', 'uni_avatar_maybe_replace_template', 10, 3); } }
/** * If a template does not exist in the current theme, we will use our own * bundled templates. * * We're doing two things here: * 1) Support the older template format for themes that are using them * for backwards-compatibility (the template passed in * {@link bp_core_load_template()}). * 2) Route older template names to use our new template locations and * format. * * From work by r-a-y * * @since 1.1 */ function load_template_filter($found_template, $templates) { // Only filter the template location when we're on the group invitation screen, the group creation invite-anyone step, or the members component if (!ccgn_is_component()) { return $found_template; } // $found_template may not empty if template files were found in the // parent or child theme if (empty($found_template)) { // locate_template() will attempt to find the plugins.php template in the // child and parent theme and return the located template when found $found_template = locate_template('/groups/single/plugins.php', false, false); } // Register our theme compat directory. // This tells BP to look for templates in our plugin directory // if the template isn't found in the parent/child theme. bp_register_template_stack(array($this, 'get_template_directory'), 14); if (1 == 1) { // add our hook to inject content into BP's group screen add_action('bp_template_content', create_function('', "\n\t\t\t\tbp_get_template_part( 'groups/single/narratives' );\n\t\t\t")); } return apply_filters('ccgn_load_template_filter', $found_template); }
/** * Get the party started */ function bp_group_hierarchy_extension_init() { global $bp; add_action('wp_ajax_groups_tree_filter', 'bp_dtheme_object_template_loader'); add_action('wp_ajax_nopriv_groups_tree_filter', 'bp_dtheme_object_template_loader'); /** Register templates folder for theme compatibility support when available */ if (function_exists('bp_register_template_stack')) { bp_register_template_stack('bp_group_hierarchy_register_template_location'); } $bp->group_hierarchy->extension_settings = array('show_group_tree' => get_site_option('bpgh_extension_show_group_tree', false), 'hide_group_list' => get_site_option('bpgh_extension_hide_group_list', false), 'nav_item_name' => get_site_option('bpgh_extension_nav_item_name', __('Member Groups (%d)', 'bp-group-hierarchy')), 'group_tree_name' => get_site_option('bpgh_extension_group_tree_name', __('Group Tree', 'bp-group-hierarchy'))); wp_register_script('bp-group-hierarchy-tree-script', plugins_url('includes/hierarchy.js', __FILE__), array('jquery')); /** Load the hierarchy.css file from the user's theme, if available */ if ($hierarchy_css = apply_filters('bp_located_template', locate_template(array('_inc/css/hierarchy.css'), false), '_inc/css/hierarchy.css')) { // Detect when loading CSS from the plugin dir and rewrite with plugins_url for better MS / symlink support if (0 === strpos($hierarchy_css, dirname(__FILE__))) { $hierarchy_css = plugins_url('templates/_inc/css/hierarchy.css', __FILE__); } wp_register_style('bp-group-hierarchy-tree-style', str_replace(array(substr(ABSPATH, 0, -1), '\\'), array('', '/'), $hierarchy_css)); } if (bp_is_groups_component() && $bp->current_action == '' && $bp->group_hierarchy->extension_settings['hide_group_list']) { add_filter('groups_get_groups', 'bp_group_hierarchy_get_groups_tree', 10, 2); add_filter('wp_title', 'bp_group_hierarchy_group_tree_title', 10, 3); if ($bp->current_action == '' && !isset($_POST['object'])) { wp_enqueue_script('bp-group-hierarchy-tree-script'); wp_enqueue_style('bp-group-hierarchy-tree-style'); /** * Override BP's default group index with the tree */ if (!class_exists('BP_Theme_Compat') || current_theme_supports('buddypress') || in_array('bp-default', array(get_stylesheet(), get_template()))) { add_filter('groups_template_directory_groups', create_function('$template', 'return "tree/index";')); } else { add_filter('bp_get_template_part', 'bp_group_hierarchy_maybe_replace_group_loop_template', 10, 3); } } } else { if (bp_is_groups_component() && $bp->current_action == '' && $bp->group_hierarchy->extension_settings['show_group_tree']) { wp_enqueue_script('bp-group-hierarchy-tree-script'); wp_enqueue_style('bp-group-hierarchy-tree-style'); add_action('bp_groups_directory_group_filter', 'bp_group_hierarchy_tab'); } } }
/** * BuddyForms template loader. * * I copied this function from the buddypress.org website and modified it for my needs. * * This function sets up BuddyForms to use custom templates. * * If a template does not exist in the current theme, we will use our own * bundled templates. * * We're doing two things here: * 1) Support the older template format for themes that are using them * for backwards-compatibility (the template passed in * {@link bp_core_load_template()}). * 2) Route older template names to use our new template locations and * format. * * View the inline doc for more details. * * @since 1.0 */ function buddyforms_load_template_filter($found_template, $templates) { global $bp, $wp_query, $buddyforms; $current_component = $bp->current_component; if (!bp_current_component()) { return apply_filters('buddyforms_members_load_template_filter', $found_template); } if (is_array($templates) && is_array($buddyforms) && empty($found_template) && isset($buddyforms) && array_key_exists(bp_current_component(), $buddyforms)) { // register our theme compat directory // // this tells BP to look for templates in our plugin directory last // when the template isn't found in the parent / child theme bp_register_template_stack('buddyforms_members_get_template_directory', 14); // locate_template() will attempt to find the plugins.php template in the // child and parent theme and return the located template when found // // plugins.php is the preferred template to use, since all we'd need to do is // inject our content into BP // // note: this is only really relevant for bp-default themes as theme compat // will kick in on its own when this template isn't found $found_template = locate_template('members/single/plugins.php', false, false); $child_form_slug = ''; foreach ($buddyforms as $key => $member_form) { if ('noparent' != $member_form['profiles_parent_tab']) { if ($bp->current_action == $member_form['slug'] . '-my-posts' || $bp->current_action == $member_form['slug'] . '-create' || $bp->current_action == $member_form['slug'] . '-edit') { $child_form_slug = $member_form['slug']; //$post_type = $member_form['post_type']; } } } // add our hook to inject content into BP if ($bp->current_action == 'my-posts' || $bp->current_action == $child_form_slug . '-my-posts') { add_action('bp_template_content', create_function('', "\n\t\t\t\t\tbp_get_template_part( 'buddyforms/members/members-post-display' );\n\t\t\t\t")); } elseif ($bp->current_action == 'create' || $bp->current_action == $child_form_slug . '-create') { add_action('bp_template_content', create_function('', "\n\t\t\t\t\tbp_get_template_part( 'buddyforms/members/members-post-create' );\n\t\t\t\t")); } elseif ($bp->current_action == 'edit' || $bp->current_action == $child_form_slug . '-edit') { add_action('bp_template_content', create_function('', "\n\t\t\t\t\tbp_get_template_part( 'buddyforms/members/members-post-create' );\n\t\t\t\t")); } elseif ($bp->current_action == 'revision') { add_action('bp_template_content', create_function('', "\n\t\t\t\t\tbp_get_template_part( 'buddyforms/members/members-post-create' );\n\t\t\t\t")); } elseif ($bp->current_action == 'page') { add_action('bp_template_content', create_function('', "\n\t\t\t\t\tbp_get_template_part( 'buddyforms/members/members-post-display' );\n\t\t\t\t")); } } return apply_filters('buddyforms_members_load_template_filter', $found_template); }