/** * Prevent specific pages (eg 'Activate') from showing on page listings. * * @uses bp_is_active() checks if a BuddyPress component is active. * * @param array $pages List of excluded page IDs, as passed to the * 'wp_list_pages_excludes' filter. * @return array The exclude list, with BP's pages added. */ function bp_core_exclude_pages($pages = array()) { // Bail if not the root blog. if (!bp_is_root_blog()) { return $pages; } $bp = buddypress(); if (!empty($bp->pages->activate)) { $pages[] = $bp->pages->activate->id; } if (!empty($bp->pages->register)) { $pages[] = $bp->pages->register->id; } if (!empty($bp->pages->forums) && (!bp_is_active('forums') || bp_is_active('forums') && bp_forums_has_directory() && !bp_forums_is_installed_correctly())) { $pages[] = $bp->pages->forums->id; } /** * Filters specific pages that shouldn't show up on page listings. * * @since 1.5.0 * * @param array $pages Array of pages to exclude. */ return apply_filters('bp_core_exclude_pages', $pages); }
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')); } }
/** * bp_core_exclude_pages() * * Excludes specific pages from showing on page listings, for example the "Activation" page. * * @package BuddyPress Core * @uses bp_is_active() checks if a BuddyPress component is active. * @return array The list of page ID's to exclude */ function bp_core_exclude_pages($pages) { global $bp; if (!empty($bp->pages->activate)) { $pages[] = $bp->pages->activate->id; } if (!empty($bp->pages->register)) { $pages[] = $bp->pages->register->id; } if (!empty($bp->pages->forums) && (!bp_is_active('forums') || bp_is_active('forums') && bp_forums_has_directory() && !bp_forums_is_installed_correctly())) { $pages[] = $bp->pages->forums->id; } return apply_filters('bp_core_exclude_pages', $pages); }
/** * Prevent specific pages (eg 'Activate') from showing on page listings. * * @uses bp_is_active() checks if a BuddyPress component is active. * * @param array $pages List of excluded page IDs, as passed to the * 'wp_list_pages_excludes' filter. * @return array The exclude list, with BP's pages added. */ function bp_core_exclude_pages($pages = array()) { // Bail if not the root blog if (!bp_is_root_blog()) { return $pages; } $bp = buddypress(); if (!empty($bp->pages->activate)) { $pages[] = $bp->pages->activate->id; } if (!empty($bp->pages->register)) { $pages[] = $bp->pages->register->id; } if (!empty($bp->pages->forums) && (!bp_is_active('forums') || bp_is_active('forums') && bp_forums_has_directory() && !bp_forums_is_installed_correctly())) { $pages[] = $bp->pages->forums->id; } return apply_filters('bp_core_exclude_pages', $pages); }
</div><!-- #item-header --> <div id="item-nav"> <div class="item-list-tabs no-ajax" id="subnav" role="navigation"> <ul> <li> <a href="#post-new" class="show-hide-new"><?php _e('New Topic', 'buddypress'); ?> </a> </li> <?php if (bp_forums_has_directory()) { ?> <li> <a href="<?php bp_forums_directory_permalink(); ?> "><?php _e('Forum Directory', 'buddypress'); ?> </a> </li> <?php } ?>
/** * Generate the basic search form as used in BP-Default's header. * * @since 1.0.0 * * @return string HTML <select> element. */ function bp_search_form_type_select() { $options = array(); if (bp_is_active('xprofile')) { $options['members'] = _x('Members', 'search form', 'buddypress'); } if (bp_is_active('groups')) { $options['groups'] = _x('Groups', 'search form', 'buddypress'); } if (bp_is_active('blogs') && is_multisite()) { $options['blogs'] = _x('Blogs', 'search form', 'buddypress'); } if (bp_is_active('forums') && bp_forums_is_installed_correctly() && bp_forums_has_directory()) { $options['forums'] = _x('Forums', 'search form', 'buddypress'); } $options['posts'] = _x('Posts', 'search form', 'buddypress'); // Eventually this won't be needed and a page will be built to integrate all search results. $selection_box = '<label for="search-which" class="accessibly-hidden">' . _x('Search these:', 'search form', 'buddypress') . '</label>'; $selection_box .= '<select name="search-which" id="search-which" style="width: auto">'; /** * Filters all of the component options available for search scope. * * @since 1.5.0 * * @param array $options Array of options to add to select field. */ $options = apply_filters('bp_search_form_type_select_options', $options); foreach ((array) $options as $option_value => $option_title) { $selection_box .= sprintf('<option value="%s">%s</option>', $option_value, $option_title); } $selection_box .= '</select>'; /** * Filters the complete <select> input used for search scope. * * @since 1.0.0 * * @param string $selection_box <select> input for selecting search scope. */ return apply_filters('bp_search_form_type_select', $selection_box); }
/** * Generates the basic search form as used in BP-Default's header. * * @global object $bp BuddyPress global settings * @return string HTML <select> element * @since 1.0 */ function bp_search_form_type_select() { global $bp; $options = array(); if (bp_is_active('xprofile')) { $options['members'] = __('Members', 'buddypress'); } if (bp_is_active('groups')) { $options['groups'] = __('Groups', 'buddypress'); } if (bp_is_active('blogs') && is_multisite()) { $options['blogs'] = __('Blogs', 'buddypress'); } if (bp_is_active('forums') && bp_forums_is_installed_correctly() && bp_forums_has_directory()) { $options['forums'] = __('Forums', 'buddypress'); } $options['posts'] = __('Posts', 'buddypress'); // Eventually this won't be needed and a page will be built to integrate all search results. $selection_box = '<label for="search-which" class="accessibly-hidden">' . __('Search these:', 'buddypress') . '</label>'; $selection_box .= '<select name="search-which" id="search-which" style="width: auto">'; $options = apply_filters('bp_search_form_type_select_options', $options); foreach ((array) $options as $option_value => $option_title) { $selection_box .= sprintf('<option value="%s">%s</option>', $option_value, $option_title); } $selection_box .= '</select>'; return apply_filters('bp_search_form_type_select', $selection_box); }
/** * 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')); } }