/**
  * Are we looking at something that needs group theme compatibility?
  *
  * @since 1.7.0
  */
 public function is_group()
 {
     // Bail if not looking at a group.
     if (!bp_is_groups_component()) {
         return;
     }
     // Group Directory.
     if (!bp_current_action() && !bp_current_item()) {
         bp_update_is_directory(true, 'groups');
         /**
          * Fires at the start of the group theme compatibility setup.
          *
          * @since 1.1.0
          */
         do_action('groups_directory_groups_setup');
         add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
         // Creating a group.
     } elseif (bp_is_groups_component() && bp_is_current_action('create')) {
         add_filter('bp_get_buddypress_template', array($this, 'create_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'create_content'));
         // Group page.
     } elseif (bp_is_single_item()) {
         add_filter('bp_get_buddypress_template', array($this, 'single_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'single_content'));
     }
 }
/**
 * Load the index page 
 */
function bp_portfolio_directory_setup()
{
    if (bp_is_portfolio_component() && !bp_current_action() && !bp_current_item()) {
        bp_update_is_directory(true, 'portfolio');
        do_action('bp_portfolio_directory_setup');
        bp_core_load_template(apply_filters('portfolio_directory_template', BP_PORTFOLIO_TEMPLATE . '/index'));
    }
}
function groups_directory_groups_setup()
{
    if (bp_is_groups_component() && !bp_current_action() && !bp_current_item()) {
        bp_update_is_directory(true, 'groups');
        do_action('groups_directory_groups_setup');
        bp_core_load_template(apply_filters('groups_template_directory_groups', 'groups/index'));
    }
}
function bp_forums_directory_forums_setup()
{
    global $bp;
    if (bp_is_forums_component() && (!bp_current_action() || 'tag' == bp_current_action() && bp_action_variables()) && !bp_current_item()) {
        if (!bp_forums_has_directory()) {
            return false;
        }
        if (!bp_forums_is_installed_correctly()) {
            bp_core_add_message(__('The forums component has not been set up yet.', 'buddypress'), 'error');
            bp_core_redirect(bp_get_root_domain());
        }
        bp_update_is_directory(true, 'forums');
        do_action('bbpress_init');
        // Check to see if the user has posted a new topic from the forums page.
        if (isset($_POST['submit_topic']) && bp_is_active('forums')) {
            check_admin_referer('bp_forums_new_topic');
            $bp->groups->current_group = groups_get_group(array('group_id' => $_POST['topic_group_id']));
            if (!empty($bp->groups->current_group->id)) {
                // Auto join this user if they are not yet a member of this group
                if (!is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member($bp->loggedin_user->id, $bp->groups->current_group->id)) {
                    groups_join_group($bp->groups->current_group->id);
                }
                $error_message = '';
                $forum_id = groups_get_groupmeta($bp->groups->current_group->id, 'forum_id');
                if (!empty($forum_id)) {
                    if (empty($_POST['topic_title'])) {
                        $error_message = __('Please provide a title for your forum topic.', 'buddypress');
                    } else {
                        if (empty($_POST['topic_text'])) {
                            $error_message = __('Forum posts cannot be empty. Please enter some text.', 'buddypress');
                        }
                    }
                    if ($error_message) {
                        bp_core_add_message($error_message, 'error');
                        $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                    } else {
                        if (!($topic = groups_new_group_forum_topic($_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id))) {
                            bp_core_add_message(__('There was an error when creating the topic', 'buddypress'), 'error');
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum';
                        } else {
                            bp_core_add_message(__('The topic was created successfully', 'buddypress'));
                            $redirect = bp_get_group_permalink($bp->groups->current_group) . 'forum/topic/' . $topic->topic_slug . '/';
                        }
                    }
                    bp_core_redirect($redirect);
                } else {
                    bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                    bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
                }
            } else {
                bp_core_add_message(__('Please pick the group forum where you would like to post this topic.', 'buddypress'), 'error');
                bp_core_redirect(add_query_arg('new', '', bp_get_forums_directory_permalink()));
            }
        }
        do_action('bp_forums_directory_forums_setup');
        bp_core_load_template(apply_filters('bp_forums_template_directory_forums_setup', 'forums/index'));
    }
}
/**
 * If your component uses a top-level directory, this function will catch the requests and load
 * the index page.
 *
 * @package BuddyPress_Template_Pack
 * @since 1.6
 */
function bp_course_directory_setup()
{
    if (bp_is_course_component() && !bp_current_action() && !bp_current_item()) {
        // This wrapper function sets the $bp->is_directory flag to true, which help other
        // content to display content properly on your directory.
        bp_update_is_directory(true, BP_COURSE_SLUG);
        // Add an action so that plugins can add content or modify behavior
        do_action('bp_course_directory_setup');
        bp_core_load_template(apply_filters('course_directory_template', 'course/index'));
    }
}
Example #6
0
function breadcrumb_bp_current_item($item)
{
    $params = array('bp_component' => bp_current_component(), 'bp_item' => bp_current_item(), 'bp_action' => bp_current_action(), 'bp_action_variables' => bp_action_variables());
    switch (bp_current_component()) {
        case false:
            return $item;
            break;
        case 'groups':
            return new Breadcrumb_BP_Component_Group($item, $params);
            break;
        default:
            return new Breadcrumb_BP_Component($item, $params);
    }
}
 /**
  * Are we looking at something that needs members theme compatibility?
  *
  * @since 1.7.0
  */
 public function is_members()
 {
     // Bail if not looking at the members component or a user's page.
     if (!bp_is_members_component() && !bp_is_user()) {
         return;
     }
     // Members Directory.
     if (!bp_current_action() && !bp_current_item()) {
         bp_update_is_directory(true, 'members');
         /**
          * Fires if looking at Members directory when needing theme compat.
          *
          * @since 1.5.0
          */
         do_action('bp_members_screen_index');
         add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
         // User page.
     } elseif (bp_is_user()) {
         // If we're on a single activity permalink page, we shouldn't use the members
         // template, so stop here!
         if (bp_is_active('activity') && bp_is_single_activity()) {
             return;
         }
         /**
          * Fires if looking at Members user page when needing theme compat.
          *
          * @since 1.5.0
          */
         do_action('bp_members_screen_display_profile');
         add_filter('bp_get_buddypress_template', array($this, 'single_template_hierarchy'));
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'single_dummy_content'));
     }
 }
	/**
	 * Return the permalink to a given forum.
	 *
	 * @param int $forum_id Optional. Defaults to the current forum, if
	 *        there is one.
	 * @return string|bool False on failure, a URL on success.
	 */
	function bp_get_forum_permalink( $forum_id = 0 ) {
		global $bp;

		if ( bp_is_groups_component() ) {
			$permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_current_item() . '/forum' );
		} else {
			if ( empty( $forum_id ) ) {
				global $topic_template;
				if ( isset( $topic_template->forum_id ) )
					$forum_id = $topic_template->forum_id;
			}

			if ( $forum = bp_forums_get_forum( $forum_id ) )
				$permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/forum/' . $forum->forum_slug );
			else
				return false;
		}

		/**
		 * Filters the permalink to a given forum.
		 *
		 * @since BuddyPress (1.0.0)
		 *
		 * @param string $value Peramlink to the given forum.
		 */
		return apply_filters( 'bp_get_forum_permalink', trailingslashit( $permalink ) );
	}
function bp_is_current_item($item = '')
{
    if (!empty($item) && $item == bp_current_item()) {
        return true;
    }
    return false;
}
Example #10
0
function meso_schema_breadcrumbs()
{
    global $post;
    $schema_on = '';
    $schema_link = '';
    $schema_prop_url = '';
    $schema_prop_title = '';
    $showOnHome = 1;
    // 1 - show breadcrumbs on the homepage, 0 - don't show
    $delimiter = ' » ';
    // delimiter between crumbs
    $home = __('Home', 'mesocolumn');
    // text for the 'Home' link
    $showCurrent = 1;
    // 1 - show current post/page title in breadcrumbs, 0 - don't show
    $before = '<span class="current">';
    // tag before the current crumb
    $after = '</span>';
    // tag after the current crumb
    $schema_breadcrumb_on = get_theme_mod('schema_breadcrumb_on');
    if ($schema_breadcrumb_on == 'enable') {
        $schema_link = ' itemscope itemtype="http://data-vocabulary.org/Breadcrumb"';
        $schema_prop_url = ' itemprop="url"';
        $schema_prop_title = ' itemprop="title"';
    }
    $homeLink = home_url();
    if (is_home() || is_front_page()) {
        if ($showOnHome == 1) {
            echo '<div id="breadcrumbs"><div class="innerwrap">';
            echo __('You are here: ', 'mesocolumn');
            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . $homeLink . '">' . '<span' . $schema_prop_title . '>' . $home . '</span>' . '</a></span>';
            echo '</div></div>';
        }
    } else {
        echo '<div id="breadcrumbs"><div class="innerwrap">';
        if (!is_single()) {
            echo __('You are here: ', 'mesocolumn');
        }
        echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . $homeLink . '">' . '<span' . $schema_prop_title . '>' . $home . '</span>' . '</a></span>' . $delimiter . ' ';
        if (is_category()) {
            $thisCat = get_category(get_query_var('cat'), false);
            if ($thisCat->parent != 0) {
                $category_link = get_category_link($thisCat->parent);
                echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . $category_link . '">' . '<span' . $schema_prop_title . '>' . get_cat_name($thisCat->parent) . '</span>' . '</a></span>' . $delimiter . ' ';
            }
            $category_id = get_cat_ID(single_cat_title('', false));
            $category_link = get_category_link($category_id);
            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . $category_link . '">' . '<span' . $schema_prop_title . '>' . single_cat_title('', false) . '</span>' . '</a></span>';
        } elseif (is_search()) {
            echo __('Search results for', 'mesocolumn') . ' "' . get_search_query() . '"';
        } elseif (is_day()) {
            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_year_link(get_the_time('Y')) . '">' . '<span' . $schema_prop_title . '>' . get_the_time('Y') . '</span>' . '</a></span>' . $delimiter . ' ';
            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . '<span' . $schema_prop_title . '>' . get_the_time('F') . '</span>' . '</a></span>' . $delimiter . ' ';
            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_day_link(get_the_time('Y'), get_the_time('m'), get_the_time('d')) . '">' . '<span' . $schema_prop_title . '>' . get_the_time('d') . '</span>' . '</a></span>';
        } elseif (is_month()) {
            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_year_link(get_the_time('Y')) . '">' . '<span' . $schema_prop_title . '>' . get_the_time('Y') . '</span>' . '</a></span>' . $delimiter . ' ';
            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . '<span' . $schema_prop_title . '>' . get_the_time('F') . '</span>' . '</a></span>';
        } elseif (is_year()) {
            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_year_link(get_the_time('Y')) . '">' . '<span' . $schema_prop_title . '>' . get_the_time('Y') . '</span>' . '</a></span>';
        } elseif (is_single() && !is_attachment()) {
            if (get_post_type() != 'post') {
                $post_type = get_post_type_object(get_post_type());
                $slug = $post_type->rewrite;
                echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . $homeLink . '/' . $slug['slug'] . '">' . '<span' . $schema_prop_title . '>' . $post_type->labels->singular_name . '</span>' . '</a></span>';
                // get post type by post
                $post_type = $post->post_type;
                // get post type taxonomies
                $taxonomies = get_object_taxonomies($post_type, 'objects');
                if ($taxonomies) {
                    foreach ($taxonomies as $taxonomy_slug => $taxonomy) {
                        // get the terms related to post
                        $terms = get_the_terms($post->ID, $taxonomy_slug);
                        if (!empty($terms)) {
                            foreach ($terms as $term) {
                                $taxlist .= ' ' . $delimiter . ' ' . '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_term_link($term->slug, $taxonomy_slug) . '">' . '<span' . $schema_prop_title . '>' . ucfirst($term->name) . '</span>' . '</a></span>';
                            }
                        }
                    }
                    if ($taxlist) {
                        echo $taxlist;
                    }
                }
                echo ' ' . $delimiter . ' ' . __('You are reading &raquo;', 'mesocolumn');
            } else {
                $category = get_the_category();
                if ($category) {
                    foreach ($category as $cat) {
                        echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_category_link($cat->term_id) . '">' . '<span' . $schema_prop_title . '>' . $cat->name . '</span>' . '</a></span>' . $delimiter . ' ';
                    }
                }
                echo __('You are reading &raquo;', 'mesocolumn');
            }
        } elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) {
            $post_type = get_post_type_object(get_post_type());
            echo $before . $post_type->labels->singular_name . $after;
        } elseif (is_attachment()) {
            $parent = get_post($post->post_parent);
            $cat = get_the_category($parent->ID);
            $cat = $cat[0];
            if ($cat) {
                echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
            }
            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_permalink($parent) . '">' . '<span' . $schema_prop_title . '>' . $parent->post_title . '</span>' . '</a></span>';
            if ($showCurrent == 1) {
                echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
            }
        } elseif (is_page() && !$post->post_parent) {
            if (class_exists('buddypress')) {
                global $bp;
                if (bp_is_groups_component()) {
                    echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . home_url() . '/' . bp_get_root_slug('groups') . '">' . '<span' . $schema_prop_title . '>' . bp_get_root_slug('groups') . '</span>' . '</a></span>';
                    if (!bp_is_directory()) {
                        echo $delimiter . '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . home_url() . '/' . bp_get_root_slug('groups') . '/' . bp_current_item() . '">' . '<span' . $schema_prop_title . '>' . bp_current_item() . '</span>' . '</a></span>';
                        if (bp_current_action()) {
                            echo $delimiter . '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . home_url() . '/' . bp_get_root_slug('groups') . '/' . bp_current_item() . '/' . bp_current_action() . '">' . '<span' . $schema_prop_title . '>' . bp_current_action() . '</span>' . '</a></span>';
                        }
                    }
                } else {
                    if (bp_is_members_directory()) {
                        echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . home_url() . '/' . bp_get_root_slug('members') . '">' . '<span' . $schema_prop_title . '>' . bp_get_root_slug('members') . '</span>' . '</a></span>';
                    } else {
                        if (bp_is_user()) {
                            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . home_url() . '/' . bp_get_root_slug('members') . '">' . '<span' . $schema_prop_title . '>' . bp_get_root_slug('members') . '</span>' . '</a></span>';
                            echo $delimiter . '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . bp_core_get_user_domain($bp->displayed_user->id) . '">' . '<span' . $schema_prop_title . '>' . bp_get_displayed_user_username() . '</span>' . '</a></span>';
                            if (bp_current_action()) {
                                echo $delimiter . '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . bp_core_get_user_domain($bp->displayed_user->id) . bp_current_component() . '">' . '<span' . $schema_prop_title . '>' . bp_current_component() . '</span>' . '</a></span>';
                            }
                        } else {
                            if (bp_is_directory()) {
                                echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_permalink() . '">' . '<span' . $schema_prop_title . '>' . bp_current_component() . '</span>' . '</a></span>';
                            } else {
                                echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_permalink() . '">' . '<span' . $schema_prop_title . '>' . the_title_attribute('echo=0') . '</span>' . '</a></span>';
                            }
                        }
                    }
                }
            } else {
                echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_permalink() . '">' . '<span' . $schema_prop_title . '>' . the_title_attribute('echo=0') . '</span>' . '</a></span>';
            }
        } elseif (is_page() && $post->post_parent) {
            $parent_id = $post->post_parent;
            $breadcrumbs = array();
            while ($parent_id) {
                $page = get_page($parent_id);
                $breadcrumbs[] = '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_permalink($page->ID) . '">' . '<span' . $schema_prop_title . '>' . get_the_title($page->ID) . '</span>' . '</a></span>';
                $parent_id = $page->post_parent;
            }
            $breadcrumbs = array_reverse($breadcrumbs);
            for ($i = 0; $i < count($breadcrumbs); $i++) {
                echo $breadcrumbs[$i];
                if ($i != count($breadcrumbs) - 1) {
                    echo ' ' . $delimiter . ' ';
                }
            }
            echo $delimiter . '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_permalink() . '">' . '<span' . $schema_prop_title . '>' . the_title_attribute('echo=0') . '</span>' . '</a></span>';
        } elseif (is_tag()) {
            $tag_id = get_term_by('name', single_cat_title('', false), 'post_tag');
            if ($tag_id) {
                $tag_link = get_tag_link($tag_id->term_id);
            }
            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . $tag_link . '">' . '<span' . $schema_prop_title . '>' . single_cat_title('', false) . '</span>' . '</a></span>';
        } elseif (is_author()) {
            global $author;
            $userdata = get_userdata($author);
            echo '<span' . $schema_link . '><a' . $schema_prop_url . ' href="' . get_author_posts_url($userdata->ID) . '">' . '<span' . $schema_prop_title . '>' . $userdata->display_name . '</span>' . '</a></span>';
        } elseif (is_404()) {
            echo ' ' . $delimiter . ' ' . __('Error 404', 'mesocolumn');
        }
        if (get_query_var('paged')) {
            if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) {
                echo ' (';
            }
            echo ' ' . $delimiter . ' ' . __('Page', 'mesocolumn') . ' ' . get_query_var('paged');
            if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) {
                echo ')';
            }
        }
        echo '</div></div>';
    }
}
Example #11
0
/**
 * Filter the page title for BuddyPress pages.
 *
 * @since BuddyPress (1.5.0)
 *
 * @see wp_title()
 * @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.
 */
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 a 404, let WordPress handle it
	if ( is_404() ) {
		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 its name
		$component_id = $component_name = bp_current_component();

		// Use the component nav name
		if ( ! empty( $bp->bp_nav[$component_id] ) ) {
			// Remove counts that are added by the nav item
			$span = strpos( $bp->bp_nav[ $component_id ]['name'], '<span' );
			if ( false !== $span ) {
				$component_name = substr( $bp->bp_nav[ $component_id ]['name'], 0, $span - 1 );

			} else {
				$component_name = $bp->bp_nav[ $component_id ]['name'];
			}

		// Fall back on the component ID
		} elseif ( ! empty( $bp->{$component_id}->id ) ) {
			$component_name = ucwords( $bp->{$component_id}->id );
		}

		// Append action name if we're on a member component sub-page
		if ( ! empty( $bp->bp_options_nav[ $component_id ] ) && ! empty( $bp->canonical_stack['action'] ) ) {
			$component_subnav_name = wp_filter_object_list( $bp->bp_options_nav[ $component_id ], array( 'slug' => bp_current_action() ), 'and', 'name' );

			if ( $component_subnav_name ) {
				$component_subnav_name = array_shift( $component_subnav_name );
			} else {
				$component_subnav_name = '';
			}

		} else {
			$component_subnav_name = '';
		}

		// If on the user profile's landing page, just use the fullname
		if ( bp_is_current_component( $bp->default_component ) && bp_get_requested_url() === bp_displayed_user_domain() ) {
			$title = bp_get_displayed_user_fullname();

		// Use component name on member pages
		} else {
			// If we have a subnav name, add it separately for localization
			if ( ! empty( $component_subnav_name ) ) {
				// translators: construct the page title. 1 = user name, 2 = component name, 3 = separator, 4 = component subnav name
				$title = strip_tags( sprintf( __( '%1$s %3$s %2$s %3$s %4$s', 'buddypress' ), bp_get_displayed_user_fullname(), $component_name, $sep, $component_subnav_name ) );

			} else {
				// translators: construct the page title. 1 = user name, 2 = component name, 3 = separator
				$title = strip_tags( sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), bp_get_displayed_user_fullname(), $component_name, $sep ) );
			}
		}

	// 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: 1 = group name, 2 = group nav section name, 3 = separator
		$title = sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), $bp->bp_options_title, $subnav, $sep );

	// A single item from a component other than groups
	} elseif ( bp_is_single_item() ) {
		// translators: 1 = component item name, 2 = component nav section name, 3 = separator
		$title = sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), $bp->bp_options_title, $bp->bp_options_nav[ bp_current_item() ][ bp_current_action() ]['name'], $sep );

	// An index or directory
	} elseif ( bp_is_directory() ) {
		$current_component = bp_current_component();

		// No current component (when does this happen?)
		if ( empty( $current_component ) ) {
			$title = _x( 'Directory', 'component directory title', 'buddypress' );
		} else {
			$title = bp_get_directory_title( $current_component );
		}

	// 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 );
}
/**
 * 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);
}
/**
 * Filter the page title for BuddyPress pages.
 *
 * @since 1.5.0
 *
 * @see wp_title()
 * @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.
 */
function bp_modify_page_title($title = '', $sep = '&raquo;', $seplocation = 'right')
{
    global $bp, $paged, $page, $_wp_theme_features;
    // If this is not a BP page, just return the title produced by WP.
    if (bp_is_blog_page()) {
        return $title;
    }
    // If this is a 404, let WordPress handle it.
    if (is_404()) {
        return $title;
    }
    // If this is the front page of the site, return WP's title.
    if (is_front_page() || is_home()) {
        return $title;
    }
    // Return WP's title if not a BuddyPress page.
    if (!is_buddypress()) {
        return $title;
    }
    // Setup an empty title parts array.
    $title_parts = array();
    // Is there a displayed user, and do they have a name?
    $displayed_user_name = bp_get_displayed_user_fullname();
    // Displayed user.
    if (!empty($displayed_user_name) && !is_404()) {
        // Get the component's ID to try and get its name.
        $component_id = $component_name = bp_current_component();
        // Set empty subnav name.
        $component_subnav_name = '';
        // Use the component nav name.
        if (!empty($bp->bp_nav[$component_id])) {
            $component_name = _bp_strip_spans_from_title($bp->bp_nav[$component_id]['name']);
            // Fall back on the component ID.
        } elseif (!empty($bp->{$component_id}->id)) {
            $component_name = ucwords($bp->{$component_id}->id);
        }
        // Append action name if we're on a member component sub-page.
        if (!empty($bp->bp_options_nav[$component_id]) && !empty($bp->canonical_stack['action'])) {
            $component_subnav_name = wp_filter_object_list($bp->bp_options_nav[$component_id], array('slug' => bp_current_action()), 'and', 'name');
            if (!empty($component_subnav_name)) {
                $component_subnav_name = array_shift($component_subnav_name);
            }
        }
        // If on the user profile's landing page, just use the fullname.
        if (bp_is_current_component($bp->default_component) && bp_get_requested_url() === bp_displayed_user_domain()) {
            $title_parts[] = $displayed_user_name;
            // Use component name on member pages.
        } else {
            $title_parts = array_merge($title_parts, array_map('strip_tags', array($displayed_user_name, $component_name)));
            // If we have a subnav name, add it separately for localization.
            if (!empty($component_subnav_name)) {
                $title_parts[] = strip_tags($component_subnav_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'] : '';
        $title_parts = array($bp->bp_options_title, $subnav);
        // A single item from a component other than groups.
    } elseif (bp_is_single_item()) {
        $title_parts = array($bp->bp_options_title, $bp->bp_options_nav[bp_current_item()][bp_current_action()]['name']);
        // An index or directory.
    } elseif (bp_is_directory()) {
        $current_component = bp_current_component();
        // No current component (when does this happen?).
        $title_parts = array(_x('Directory', 'component directory title', 'buddypress'));
        if (!empty($current_component)) {
            $title_parts = array(bp_get_directory_title($current_component));
        }
        // Sign up page.
    } elseif (bp_is_register_page()) {
        $title_parts = array(__('Create an Account', 'buddypress'));
        // Activation page.
    } elseif (bp_is_activation_page()) {
        $title_parts = array(__('Activate Your Account', 'buddypress'));
        // Group creation page.
    } elseif (bp_is_group_create()) {
        $title_parts = array(__('Create a Group', 'buddypress'));
        // Blog creation page.
    } elseif (bp_is_create_blog()) {
        $title_parts = array(__('Create a Site', 'buddypress'));
    }
    // Strip spans.
    $title_parts = array_map('_bp_strip_spans_from_title', $title_parts);
    // Sep on right, so reverse the order.
    if ('right' == $seplocation) {
        $title_parts = array_reverse($title_parts);
    }
    // Get the blog name, so we can check if the original $title included it.
    $blogname = get_bloginfo('name', 'display');
    /**
     * Are we going to fake 'title-tag' theme functionality?
     *
     * @link https://buddypress.trac.wordpress.org/ticket/6107
     * @see wp_title()
     */
    $title_tag_compatibility = (bool) (!empty($_wp_theme_features['title-tag']) || strstr($title, $blogname));
    // Append the site title to title parts if theme supports title tag.
    if (true === $title_tag_compatibility) {
        $title_parts[] = $blogname;
        if (($paged >= 2 || $page >= 2) && !is_404()) {
            $title_parts[] = sprintf(__('Page %s', 'buddypress'), max($paged, $page));
        }
    }
    // Pad the separator with 1 space on each side.
    $prefix = str_pad($sep, strlen($sep) + 2, ' ', STR_PAD_BOTH);
    // Join the parts together.
    $new_title = join($prefix, array_filter($title_parts));
    // Append the prefix for pre `title-tag` compatibility.
    if (false === $title_tag_compatibility) {
        $new_title = $new_title . $prefix;
    }
    /**
     * Filters the page title for BuddyPress pages.
     *
     * @since  1.5.0
     *
     * @param  string $new_title   The BuddyPress page title.
     * @param  string $title       The original WordPress page title.
     * @param  string $sep         The title parts separator.
     * @param  string $seplocation Location of the separator (left or right).
     */
    return apply_filters('bp_modify_page_title', $new_title, $title, $sep, $seplocation);
}
Example #14
0
 /**
  * Map IdeaStream needed vars to the group's context and prepare the
  * group's extension display method
  *
  * @package WP Idea Stream
  * @subpackage buddypress/groups
  *
  * @since  2.0.0
  *
  * @uses bp_is_group() to check a group is displayed
  * @uses bp_is_current_action() to check the group's current action
  * @uses wp_idea_stream_root_slug() to get the IdeaStream root slug
  * @uses WP_Idea_Stream_Group::group_get_option() to check for the group setting
  * @uses bp_get_current_group_id() to get current group's ID
  * @uses bp_core_redirect() to safely redirect the user
  * @uses bp_get_group_permalink() to get the group's permalink
  * @uses groups_get_current_group() to get the current group's object
  * @uses wp_idea_stream_buddypress_set_is_ideastream() to set a new IdeaStream territory for a later use
  * @uses bp_action_variables() to get all action variables at once
  * @uses wp_idea_stream_action_get_slug() to get IdeaStream's action slug
  * @uses wp_idea_stream_addnew_slug() to get IdeaStream's add slug
  * @uses wp_idea_stream_buddypress_set_is_new() to set IdeaStream global 'is_new' for a later use
  * @uses add_action() to add a field to the new idea form
  * @uses wp_idea_stream_edit_slug() to get the edit slug
  * @uses get_query_var() to get the value of a specific query var
  * @uses wp_idea_stream_get_post_type() to get the ideas post type identifier
  * @uses wp_idea_stream_ideas_get_idea_by_name() to get the idea object
  * @uses wp_idea_stream_ideas_lock_idea() to check if the idea is edited by another user
  * @uses wp_idea_stream_ideas_can_edit() to check if the user can edit the idea
  * @uses WP_Idea_Stream_Group->is_idea_attached_to_group() to check if the idea is attached to currrent group
  * @uses wp_idea_stream_set_idea_var() to set an IdeaStream global for a later use
  * @uses wp_idea_stream_buddypress_set_is_edit() to set IdeaStream global 'is_edit' for a later use
  * @uses wp_idea_stream_idea_get_slug() to get IdeaStream's idea slug
  * @uses wp_idea_stream_tag_get_slug() to get the ideas tag taxonomy slug
  * @uses wp_idea_stream_category_get_slug() to get the ideas category taxonomy slug
  * @uses set_query_var() to set some query var for a later use
  * @uses get_term_by() to get idea's term
  * @uses wp_idea_stream_paged_slug() to get the ideas paged slug
  * @uses wp_idea_stream_add_message() to add a feedback to display to the user once redirected
  * @uses WP_Idea_Stream_Group->group_ideas_archive_url() to get the group's IdeaStream archive page
  * @uses bp_is_current_component() to check for a BuddyPress component
  * @uses bp_current_item() to make sure a group item is requested
  * @uses bp_do_404() to set the WP Query to a 404.
  */
 public function maybe_set_ideastream()
 {
     if (bp_is_group() && bp_is_current_action(wp_idea_stream_root_slug())) {
         // Bail if group is not (more) using IdeaStream
         if (!self::group_get_option(bp_get_current_group_id(), '_group_ideastream_activate', false)) {
             bp_core_redirect(bp_get_group_permalink(groups_get_current_group()));
         }
         // Set is_ideastream to load main css file
         wp_idea_stream_buddypress_set_is_ideastream();
         $actions = array_map('sanitize_title', (array) bp_action_variables());
         $message = false;
         switch ($actions[0]) {
             // Adding a new idea
             case wp_idea_stream_action_get_slug():
                 if (wp_idea_stream_addnew_slug() == $actions[1]) {
                     $this->group_ideastream->is_action = 'new';
                     $this->group_ideastream->context = 'new-idea';
                     // Set is_new to load javascripts
                     wp_idea_stream_buddypress_set_is_new();
                     // Add the group_id field in the form
                     add_action('wp_idea_stream_ideas_the_idea_meta_edit', array($this, 'meta_group_id'));
                 } else {
                     if (wp_idea_stream_edit_slug() == $actions[1]) {
                         $idea_name = get_query_var(wp_idea_stream_get_post_type());
                         if (empty($idea_name)) {
                             $message = __('No idea was requested', 'wp-idea-stream');
                         }
                         // Get the idea thanks to its name
                         $idea = wp_idea_stream_ideas_get_idea_by_name($idea_name);
                         // Check if the idea is currently being edited by someone else
                         $user_is_editing = wp_idea_stream_ideas_lock_idea($idea->ID);
                         if (!empty($user_is_editing)) {
                             $message = sprintf(__('The idea: &#34;%s&#34; is already being edited by another user.', 'wp-idea-stream'), $idea->post_title);
                             break;
                         }
                         // Does the user can edit the idea ?
                         if (!wp_idea_stream_ideas_can_edit($idea)) {
                             $message = __('You are not allowed to edit this idea.', 'wp-idea-stream');
                             break;
                         }
                         if ($this->is_idea_attached_to_group($idea)) {
                             $this->group_ideastream->is_action = 'edit';
                             $this->group_ideastream->context = 'edit-idea';
                             // Set the query loop
                             $query_loop = new StdClass();
                             $query_loop->idea = $idea;
                             wp_idea_stream_set_idea_var('query_loop', $query_loop);
                             wp_idea_stream_set_idea_var('single_idea_id', $idea->ID);
                             // Set is_new to load javascripts
                             wp_idea_stream_buddypress_set_is_edit();
                             // Add the group_id field in the form
                             add_action('wp_idea_stream_ideas_the_idea_meta_edit', array($this, 'meta_group_id'));
                         } else {
                             $message = __('The idea was not found in this group.', 'wp-idea-stream');
                         }
                     } else {
                         $message = __('The action requested is not available', 'wp-idea-stream');
                     }
                 }
                 break;
                 // Viewing a single idea
             // Viewing a single idea
             case wp_idea_stream_idea_get_slug():
                 // No name, stop
                 if (empty($actions[1])) {
                     $message = __('No idea was requested', 'wp-idea-stream');
                     break;
                 }
                 // Get the idea thanks to its name
                 $idea = wp_idea_stream_ideas_get_idea_by_name($actions[1]);
                 if ($this->is_idea_attached_to_group($idea)) {
                     $this->group_ideastream->is_action = 'idea';
                     $this->group_ideastream->idea_name = $actions[1];
                     // Set the query loop
                     $query_loop = new StdClass();
                     $query_loop->idea = $idea;
                     wp_idea_stream_set_idea_var('query_loop', $query_loop);
                     wp_idea_stream_set_idea_var('single_idea_id', $idea->ID);
                 } else {
                     $message = __('The idea was not found in this group.', 'wp-idea-stream');
                 }
                 break;
             case wp_idea_stream_tag_get_slug():
             case wp_idea_stream_category_get_slug():
                 // No term name, stop
                 if (empty($actions[1])) {
                     $message = sprintf(__('No %s was requested', 'wp-idea-stream'), $actions[0]);
                     break;
                 }
                 // Does the group support categories ?
                 if ($actions[0] == wp_idea_stream_category_get_slug() && !self::group_get_option(bp_get_current_group_id(), '_group_ideastream_categories', true)) {
                     $message = sprintf(__('This group does not support the %s feature.', 'wp-idea-stream'), $actions[0]);
                     break;
                 }
                 // Using tag as default, as category can be disabled from group settings.
                 if ($actions[0] == wp_idea_stream_tag_get_slug()) {
                     $this->group_ideastream->current_taxonomy = wp_idea_stream_get_tag();
                     // Set tag as a query var.
                     set_query_var(wp_idea_stream_get_tag(), $actions[1]);
                 } else {
                     if ($actions[0] == wp_idea_stream_category_get_slug()) {
                         $this->group_ideastream->current_taxonomy = wp_idea_stream_get_category();
                         // Set category as a query var.
                         set_query_var(wp_idea_stream_get_category(), $actions[1]);
                     }
                 }
                 // Try to get the term with its slug
                 $this->group_ideastream->current_term = get_term_by('slug', $actions[1], $this->group_ideastream->current_taxonomy);
                 if (!empty($this->group_ideastream->current_term)) {
                     $this->group_ideastream->is_action = $actions[0];
                     $this->group_ideastream->context = 'taxonomy';
                     // Set the current term
                     wp_idea_stream_set_idea_var('current_term', $this->group_ideastream->current_term);
                 } else {
                     $message = sprintf(__('The %s was not found', 'wp-idea-stream'), $actions[0]);
                     break;
                 }
                 break;
             default:
                 $this->group_ideastream->is_action = 'archive';
                 $this->group_ideastream->context = 'archive';
                 break;
         }
         // Set pagination for taxonomy & archive page
         if (!empty($this->group_ideastream->context) && in_array($this->group_ideastream->context, array('taxonomy', 'archive'))) {
             $possible_page_number = array($actions[0]);
             if (!empty($actions[2])) {
                 $possible_page_number = array_merge($possible_page_number, array($actions[2]));
             }
             if (in_array(wp_idea_stream_paged_slug(), $possible_page_number)) {
                 if (is_numeric($actions[1])) {
                     $this->group_ideastream->is_paged = absint($actions[1]);
                 } else {
                     if (is_numeric($actions[3])) {
                         $this->group_ideastream->is_paged = absint($actions[3]);
                     } else {
                         $this->group_ideastream->is_paged = 0;
                     }
                 }
             }
         }
         if (!empty($message)) {
             wp_idea_stream_add_message(array('type' => 'error', 'content' => $message));
             bp_core_redirect($this->group_ideas_archive_url(groups_get_current_group(), true));
         }
         /**
          * Redirect to a 404 if needed
          *
          * It's the case when trying to see an idea attached to an hidden group while the user
          * is not a member of this group.
          */
     } else {
         if (bp_is_current_component('groups') && bp_is_current_action(wp_idea_stream_root_slug()) && bp_current_item()) {
             bp_do_404();
             return;
         }
     }
 }
Example #15
0
			      </li>
			    
			    </ul>

			</div>

		</div>
		<div class="header-bottom">
			<nav id="sub-navigation" class="site-navigation sub-navigation">
			
			<?php 
if (bp_current_item()) {
    ?>
				
					<?php 
    $args = array('name' => bp_current_item(), 'post_type' => 'page', 'post_status' => 'publish', 'numberposts' => 1);
    $page = get_posts($args);
    if ($page[0]->ID) {
        $pageID = $page[0]->ID;
        $args = array('post_parent' => $page[0]->ID, 'post_type' => 'page', 'posts_per_page' => -1, 'post_status' => 'publish');
        $subpages = get_children($args);
        echo '<ul class="menu">';
        $listItems = '';
        $oneActive = false;
        foreach ($subpages as $page) {
            if ($page->ID == get_the_ID()) {
                $class = 'active';
                $oneActive = true;
            } else {
                $class = '';
            }
/**
 * Get the title parts of the BuddyPress displayed page
 *
 * @since 2.4.3
 *
 * @param string $seplocation Location for the separator.
 * @return array the title parts
 */
function bp_get_title_parts($seplocation = 'right')
{
    $bp = buddypress();
    // Defaults to an empty array.
    $bp_title_parts = array();
    // If this is not a BP page, return the empty array.
    if (bp_is_blog_page()) {
        return $bp_title_parts;
    }
    // If this is a 404, return the empty array.
    if (is_404()) {
        return $bp_title_parts;
    }
    // If this is the front page of the site, return the empty array.
    if (is_front_page() || is_home()) {
        return $bp_title_parts;
    }
    // Return the empty array if not a BuddyPress page.
    if (!is_buddypress()) {
        return $bp_title_parts;
    }
    // Now we can build the BP Title Parts
    // Is there a displayed user, and do they have a name?
    $displayed_user_name = bp_get_displayed_user_fullname();
    // Displayed user.
    if (!empty($displayed_user_name) && !is_404()) {
        // Get the component's ID to try and get its name.
        $component_id = $component_name = bp_current_component();
        // Set empty subnav name.
        $component_subnav_name = '';
        if (!empty($bp->members->nav)) {
            $primary_nav_item = $bp->members->nav->get_primary(array('slug' => $component_id), false);
            $primary_nav_item = reset($primary_nav_item);
        }
        // Use the component nav name.
        if (!empty($primary_nav_item->name)) {
            $component_name = _bp_strip_spans_from_title($primary_nav_item->name);
            // Fall back on the component ID.
        } elseif (!empty($bp->{$component_id}->id)) {
            $component_name = ucwords($bp->{$component_id}->id);
        }
        if (!empty($bp->members->nav)) {
            $secondary_nav_item = $bp->members->nav->get_secondary(array('parent_slug' => $component_id, 'slug' => bp_current_action()), false);
            if ($secondary_nav_item) {
                $secondary_nav_item = reset($secondary_nav_item);
            }
        }
        // Append action name if we're on a member component sub-page.
        if (!empty($secondary_nav_item->name) && !empty($bp->canonical_stack['action'])) {
            $component_subnav_name = $secondary_nav_item->name;
        }
        // If on the user profile's landing page, just use the fullname.
        if (bp_is_current_component($bp->default_component) && bp_get_requested_url() === bp_displayed_user_domain()) {
            $bp_title_parts[] = $displayed_user_name;
            // Use component name on member pages.
        } else {
            $bp_title_parts = array_merge($bp_title_parts, array_map('strip_tags', array($displayed_user_name, $component_name)));
            // If we have a subnav name, add it separately for localization.
            if (!empty($component_subnav_name)) {
                $bp_title_parts[] = strip_tags($component_subnav_name);
            }
        }
        // A single item from a component other than Members.
    } elseif (bp_is_single_item()) {
        $component_id = bp_current_component();
        if (!empty($bp->{$component_id}->nav)) {
            $secondary_nav_item = $bp->{$component_id}->nav->get_secondary(array('parent_slug' => bp_current_item(), 'slug' => bp_current_action()), false);
            if ($secondary_nav_item) {
                $secondary_nav_item = reset($secondary_nav_item);
            }
        }
        $single_item_subnav = '';
        if (!empty($secondary_nav_item->name)) {
            $single_item_subnav = $secondary_nav_item->name;
        }
        $bp_title_parts = array($bp->bp_options_title, $single_item_subnav);
        // An index or directory.
    } elseif (bp_is_directory()) {
        $current_component = bp_current_component();
        // No current component (when does this happen?).
        $bp_title_parts = array(_x('Directory', 'component directory title', 'buddypress'));
        if (!empty($current_component)) {
            $bp_title_parts = array(bp_get_directory_title($current_component));
        }
        // Sign up page.
    } elseif (bp_is_register_page()) {
        $bp_title_parts = array(__('Create an Account', 'buddypress'));
        // Activation page.
    } elseif (bp_is_activation_page()) {
        $bp_title_parts = array(__('Activate Your Account', 'buddypress'));
        // Group creation page.
    } elseif (bp_is_group_create()) {
        $bp_title_parts = array(__('Create a Group', 'buddypress'));
        // Blog creation page.
    } elseif (bp_is_create_blog()) {
        $bp_title_parts = array(__('Create a Site', 'buddypress'));
    }
    // Strip spans.
    $bp_title_parts = array_map('_bp_strip_spans_from_title', $bp_title_parts);
    // Sep on right, so reverse the order.
    if ('right' === $seplocation) {
        $bp_title_parts = array_reverse($bp_title_parts);
    }
    /**
     * Filter BuddyPress title parts before joining.
     *
     * @since 2.4.3
     *
     * @param array $bp_title_parts Current BuddyPress title parts.
     * @return array
     */
    return (array) apply_filters('bp_get_title_parts', $bp_title_parts);
}
 /**
  * Are we looking at something that needs old forum theme compatibility?
  *
  * @since 1.7.0
  */
 public function is_legacy_forum()
 {
     // Bail if not looking at a group.
     if (!bp_is_forums_component()) {
         return;
     }
     // Forum Directory.
     if ((!bp_current_action() || 'tag' == bp_current_action() && bp_action_variables()) && !bp_current_item()) {
         if (!bp_forums_has_directory()) {
             return false;
         }
         if (!bp_forums_is_installed_correctly()) {
             bp_core_add_message(__('The forums component has not been set up yet.', 'buddypress'), 'error');
             bp_core_redirect(bp_get_root_domain());
         }
         bp_update_is_directory(true, 'forums');
         do_action('bp_forums_directory_forums_setup');
         add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
         add_filter('bp_replace_the_content', array($this, 'directory_content'));
     }
 }
/**
 * Check whether a given nav item has subnav items.
 *
 * @since 1.5.0
 * @since 2.6.0 Introduced the `$component` parameter.
 *
 * @param string $nav_item  The slug of the top-level nav item whose subnav items you're checking.
 *                          Default: the current component slug.
 * @param string $component The component the navigation is attached to. Defaults to 'members'.
 * @return bool $has_subnav True if the nav item is found and has subnav items; false otherwise.
 */
function bp_nav_item_has_subnav($nav_item = '', $component = 'members')
{
    $bp = buddypress();
    if (!isset($bp->{$component}->nav)) {
        return false;
    }
    if (!$nav_item) {
        $nav_item = bp_current_component();
        if (bp_is_group()) {
            $nav_item = bp_current_item();
        }
    }
    $has_subnav = (bool) $bp->{$component}->nav->get_secondary(array('parent_slug' => $nav_item), false);
    /**
     * Filters whether or not a given nav item has subnav items.
     *
     * @since 1.5.0
     *
     * @param bool   $has_subnav Whether or not there is any subnav items.
     * @param string $nav_item   The slug of the top-level nav item whose subnav items you're checking.
     */
    return apply_filters('bp_nav_item_has_subnav', $has_subnav, $nav_item);
}
 /**
  * Perform actions about rendez-vous (insert/edit/delete/save prefs)
  *
  * @package Rendez Vous
  * @subpackage Groups
  *
  * @since Rendez Vous (1.1.0)
  *
  * @uses  Rendez_Vous_Group->is_rendez_vous()   Checks whether we're on a rendez-vous page of a group
  * @uses  rendez_vous()                         to get the plugin's instance
  * @uses  rendez_vous_handle_actions()          to insert/edit/delete/save prefs about a rendez-vous
  * @uses  bp_get_current_group_id()             to get the group id
  * @uses  Rendez_Vous_Group::group_get_option() to get the needed group metas.
  * @uses  groups_is_user_member()               to check the organizer is still a member of the group
  * @uses  delete_post_meta()                    to remove a rendez-vous from a group
  * @uses  rendez_vous_get_single_link()         to get the rendez-vous link
  * @uses  bp_core_add_message()                 to give a feedback to the user
  * @uses  do_action()                           call 'rendez_vous_groups_component_deactivated' or
  *                                                   'rendez_vous_groups_member_removed' to perform custom actions
  * @uses  bp_core_redirect()                    to safely redirect the user
  * @uses  bp_is_current_component()             to check for a BuddyPress component
  * @uses  bp_current_item()                     to make sure a group item is requested
  * @uses  bp_do_404()                           to set the WP Query to a 404.
  */
 public function group_handle_screens()
 {
     if ($this->is_rendez_vous()) {
         $rendez_vous = rendez_vous();
         $this->screen = rendez_vous_handle_actions();
         $rendez_vous->screens->screen = $this->screen;
         $group_id = bp_get_current_group_id();
         /**
          * Should we remove the rendez-vous from the group ?
          *
          * Although, this is already handled in Rendez_Vous_Group->group_rendez_vous_link()
          * an invited user can click on an email he received where the link is a group rendez-vous link.
          * @see rendez_vous_published_notification()
          *
          * Not checking if notifications are active, because there's also an edge case when the activity
          * has not been deleted yet and the user clicks on the activity link.
          */
         if ('single' == $this->screen && !empty($rendez_vous->item->id)) {
             $message = $action = false;
             // The group doesn't support rendez-vous anymore
             if (!self::group_get_option($group_id, '_rendez_vous_group_activate', false)) {
                 $message = __('The Group, the rendez-vous was attached to, does not support rendez-vous anymore', 'rendez-vous');
                 $action = 'rendez_vous_groups_component_deactivated';
                 // The organizer was removed or left the group
             } else {
                 if (!groups_is_user_member($rendez_vous->item->organizer, $group_id)) {
                     $message = sprintf(__('%s is not a member of the group, the rendez-vous was attached to, anymore. As a result, the rendez-vous was removed from the group.', 'rendez-vous'), bp_core_get_user_displayname($rendez_vous->item->organizer));
                     $action = 'rendez_vous_groups_member_removed';
                 }
             }
             // Bail if everything is ok.
             if (empty($message)) {
                 return;
             }
             // Delete the rendez-vous group id meta
             delete_post_meta($rendez_vous->item->id, '_rendez_vous_group_id');
             $redirect = rendez_vous_get_single_link($rendez_vous->item->id, $rendez_vous->item->organizer);
             bp_core_add_message($message, 'error');
             // fire an action to deal with group activities
             do_action($action, $rendez_vous->item->id, $rendez_vous->item);
             // Redirect to organizer's rendez-vous page
             bp_core_redirect($redirect);
         }
     } else {
         if (bp_is_current_component('groups') && bp_is_current_action($this->slug) && bp_current_item()) {
             bp_do_404();
             return;
         }
     }
 }
/**
 * Is the current page the groups directory?
 *
 * @since 2.0.0
 *
 * @return True if the current page is the groups directory.
 */
function bp_is_groups_directory()
{
    if (bp_is_groups_component() && !bp_current_action() && !bp_current_item()) {
        return true;
    }
    return false;
}
/**
 * Return the permalink to a given forum.
 *
 * @param int $forum_id Optional. Defaults to the current forum, if
 *        there is one.
 * @return string|bool False on failure, a URL on success.
 */
function bp_get_forum_permalink($forum_id = 0)
{
    global $bp;
    if (bp_is_groups_component()) {
        $permalink = trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_current_item() . '/forum');
    } else {
        if (empty($forum_id)) {
            global $topic_template;
            if (isset($topic_template->forum_id)) {
                $forum_id = $topic_template->forum_id;
            }
        }
        if ($forum = bp_forums_get_forum($forum_id)) {
            $permalink = trailingslashit(bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/forum/' . $forum->forum_slug);
        } else {
            return false;
        }
    }
    return apply_filters('bp_get_forum_permalink', trailingslashit($permalink));
}
Example #22
0
/**
 * Toggle directory flag on if applicable.
 */
function bp_links_setup_directory()
{
    // get action and item
    $action = bp_current_action();
    $action_var = bp_action_variable();
    $item = bp_current_item();
    // links must be current component
    if (bp_is_current_component('links')) {
        // check action and item
        if (true === empty($action) && true === empty($item) || 'create' === $action && true === empty($item) || BP_LINKS_CAT_URL_SLUG === $action && false === empty($action_var)) {
            // toggle directory on
            bp_update_is_directory(true, 'links');
        }
    }
    do_action('bp_links_setup_directory');
}