Example #1
0
 public function check_legacy($tpl)
 {
     $status = function_exists('buddypress');
     if (!$status) {
         return $tpl;
     }
     $this->bp_plugin_name = bp_get_name_from_root_slug();
     // This check fails for some plugins
     // $status = $this->bp_plugin_name != false;
     if ($status) {
         $bp_defaults = array('members', 'xprofile', 'activity', 'blogs', 'messages', 'friends', 'groups', 'forums', 'settings');
         foreach ($bp_defaults as $bp_default) {
             if (bp_is_current_component($bp_default)) {
                 break;
             }
         }
     }
     if ($status && bp_is_directory()) {
         $this->is_legacy = $status = false;
     }
     if ($status && false === (bool) locate_template(array('members/single/item-header.php'), false)) {
         add_action('wp_footer', array($this, 'item_header'));
     }
     if ($status) {
         add_action('wp_footer', array($this, 'page_title'));
         add_action('wp_footer', array($this, 'echo_legacy_tpl'));
     }
     return $tpl;
 }
/**
 * Filter the page title for BuddyPress pages
 *
 * @global object $bp BuddyPress global settings
 * @param string $title Original page title
 * @param string $sep How to separate the various items within the page title.
 * @param string $seplocation Direction to display title
 * @return string new page title
 * @see wp_title()
 * @since BuddyPress (1.5)
 */
function bp_modify_page_title($title, $sep, $seplocation)
{
    global $bp;
    // If this is not a BP page, just return the title produced by WP
    if (bp_is_blog_page()) {
        return $title;
    }
    // If this is the front page of the site, return WP's title
    if (is_front_page() || is_home()) {
        return $title;
    }
    $title = '';
    // Displayed user
    if (bp_get_displayed_user_fullname() && !is_404()) {
        // Get the component's ID to try and get it's name
        $component_id = $component_name = bp_current_component();
        // Use the actual component name
        if (!empty($bp->{$component_id}->name)) {
            $component_name = $bp->{$component_id}->name;
            // Fall back on the component ID (probably same as current_component)
        } elseif (!empty($bp->{$component_id}->id)) {
            $component_name = $bp->{$component_id}->id;
        }
        // translators: "displayed user's name | canonicalised component name"
        $title = strip_tags(sprintf(__('%1$s | %2$s', 'buddypress'), bp_get_displayed_user_fullname(), ucwords($component_name)));
        // A single group
    } elseif (bp_is_active('groups') && !empty($bp->groups->current_group) && !empty($bp->bp_options_nav[$bp->groups->current_group->slug])) {
        $subnav = isset($bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()]['name']) ? $bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()]['name'] : '';
        // translators: "group name | group nav section name"
        $title = sprintf(__('%1$s | %2$s', 'buddypress'), $bp->bp_options_title, $subnav);
        // A single item from a component other than groups
    } elseif (bp_is_single_item()) {
        // translators: "component item name | component nav section name | root component name"
        $title = sprintf(__('%1$s | %2$s | %3$s', 'buddypress'), $bp->bp_options_title, $bp->bp_options_nav[bp_current_item()][bp_current_action()]['name'], bp_get_name_from_root_slug(bp_get_root_slug()));
        // An index or directory
    } elseif (bp_is_directory()) {
        if (!bp_current_component()) {
            $title = sprintf(__('%s Directory', 'buddypress'), bp_get_name_from_root_slug());
        } else {
            $title = sprintf(__('%s Directory', 'buddypress'), bp_get_name_from_root_slug());
        }
        // Sign up page
    } elseif (bp_is_register_page()) {
        $title = __('Create an Account', 'buddypress');
        // Activation page
    } elseif (bp_is_activation_page()) {
        $title = __('Activate your Account', 'buddypress');
        // Group creation page
    } elseif (bp_is_group_create()) {
        $title = __('Create a Group', 'buddypress');
        // Blog creation page
    } elseif (bp_is_create_blog()) {
        $title = __('Create a Site', 'buddypress');
    }
    // Some BP nav items contain item counts. Remove them
    $title = preg_replace('|<span>[0-9]+</span>|', '', $title);
    return apply_filters('bp_modify_page_title', $title . ' ' . $sep . ' ', $title, $sep, $seplocation);
}
Example #3
0
/**
 * Change the HTML title to reflect custom Group Tree name
 */
function bp_group_hierarchy_group_tree_title($title, $sep, $sep_location = null)
{
    global $bp;
    if ($sep_location != null) {
        return str_replace(sprintf(__('%s Directory', 'buddypress'), bp_get_name_from_root_slug()), bp_group_hierarchy_clean_title($bp->group_hierarchy->extension_settings['group_tree_name']), $title);
    }
    // I think this is left over from BP 1.2, so just return the title
    return $title;
}