/** * Handle the display of the Groups directory index. * * @since 1.0.0 */ function groups_directory_groups_setup() { if (bp_is_groups_directory()) { // Set group type if available. if (bp_is_current_action(bp_get_groups_group_type_base()) && bp_action_variable()) { $matched_types = bp_groups_get_group_types(array('has_directory' => true, 'directory_slug' => bp_action_variable())); // Redirect back to group directory if no match. if (empty($matched_types)) { bp_core_redirect(bp_get_groups_directory_permalink()); } // Set our global variable. buddypress()->groups->current_directory_type = reset($matched_types); } bp_update_is_directory(true, 'groups'); /** * Fires before the loading of the Groups directory index. * * @since 1.1.0 */ do_action('groups_directory_groups_setup'); /** * Filters the template to load for the Groups directory index. * * @since 1.0.0 * * @param string $value Path to the groups directory index template to load. */ bp_core_load_template(apply_filters('groups_template_directory_groups', 'groups/index')); } }
/** * 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_is_groups_directory()) { 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')); } }
/** * Forces the BP Profile Pages to be 1 Column * * @package lsx * @subpackage jetpack * @category infinite scroll */ function lsx_buddypress_page_columns($layout) { if (bp_is_profile_component() || bp_is_settings_component() || bp_is_activity_component() || bp_is_group() || bp_is_messages_component() || bp_is_members_directory() || bp_is_groups_directory() || bp_is_groups_component() || bp_is_members_component()) { $layout = '1c'; } return $layout; }
/** * Handle the display of the Groups directory index. */ function groups_directory_groups_setup() { if (bp_is_groups_directory()) { bp_update_is_directory(true, 'groups'); do_action('groups_directory_groups_setup'); bp_core_load_template(apply_filters('groups_template_directory_groups', 'groups/index')); } }
/** * Redirect to user's Profile * * @return void */ function newwriting_child_redirect() { // bail if not logged in if (!is_user_logged_in()) { return; } // bail if not BP root site if (!bp_is_root_blog()) { return; } // bail if POST if ($_SERVER['REQUEST_METHOD'] == 'POST') { return; } // if restricted pages requested if (bp_is_activity_directory() or bp_is_members_directory()) { // get profile URL $home = bp_core_get_user_domain(bp_loggedin_user_id()) . 'groups/'; // redirect to member's profile wp_redirect($home); exit; } // groups directory if (bp_is_groups_directory()) { // bail if admin if (!is_super_admin()) { // get profile URL $home = bp_core_get_user_domain(bp_loggedin_user_id()) . 'groups/'; // redirect to member's profile wp_redirect($home); exit; } } // groups directory if (is_front_page()) { // bail if admin if (!is_super_admin()) { // get profile URL $home = bp_core_get_user_domain(bp_loggedin_user_id()) . 'groups/'; // redirect to member's profile wp_redirect($home); exit; } } }
/** * Handle the display of the Groups directory index. */ function groups_directory_groups_setup() { if (bp_is_groups_directory()) { bp_update_is_directory(true, 'groups'); /** * Fires before the loading of the Groups directory index. * * @since 1.1.0 */ do_action('groups_directory_groups_setup'); /** * Filters the template to load for the Groups directory index. * * @since 1.0.0 * * @param string $value Path to the groups directory index template to load. */ bp_core_load_template(apply_filters('groups_template_directory_groups', 'groups/index')); } }
/** * Start the Groups Template Loop. * * @since 1.0.0 * @since 2.6.0 Added `$group_type`, `$group_type__in`, and `$group_type__not_in` parameters. * @since 2.7.0 Added `$update_admin_cache` parameter. * * @param array|string $args { * Array of parameters. All items are optional. * @type string $type Shorthand for certain orderby/order combinations. 'newest', 'active', * 'popular', 'alphabetical', 'random'. When present, will override * orderby and order params. Default: null. * @type string $order Sort order. 'ASC' or 'DESC'. Default: 'DESC'. * @type string $orderby Property to sort by. 'date_created', 'last_activity', * 'total_member_count', 'name', 'random'. Default: 'last_activity'. * @type int $page Page offset of results to return. Default: 1 (first page of results). * @type int $per_page Number of items to return per page of results. Default: 20. * @type int $max Does NOT affect query. May change the reported number of total groups * found, but not the actual number of found groups. Default: false. * @type bool $show_hidden Whether to include hidden groups in results. Default: false. * @type string $page_arg Query argument used for pagination. Default: 'grpage'. * @type int $user_id If provided, results will be limited to groups of which the specified * user is a member. Default: value of bp_displayed_user_id(). * @type string $slug If provided, only the group with the matching slug will be returned. * Default: false. * @type string $search_terms If provided, only groups whose names or descriptions match the search * terms will be returned. Default: value of `$_REQUEST['groups_search']` or * `$_REQUEST['s']`, if present. Otherwise false. * @type array|string $group_type Array or comma-separated list of group types to limit results to. * @type array|string $group_type__in Array or comma-separated list of group types to limit results to. * @type array|string $group_type__not_in Array or comma-separated list of group types that will be * excluded from results. * @type array $meta_query An array of meta_query conditions. * See {@link WP_Meta_Query::queries} for description. * @type array|string $include Array or comma-separated list of group IDs. Results will be limited * to groups within the list. Default: false. * @type array|string $exclude Array or comma-separated list of group IDs. Results will exclude * the listed groups. Default: false. * @type array|string $parent_id Array or comma-separated list of group IDs. Results will include only * child groups of the listed groups. Default: null. * @type bool $update_meta_cache Whether to fetch groupmeta for queried groups. Default: true. * @type bool $update_admin_cache Whether to pre-fetch group admins for queried groups. * Defaults to true when on a group directory, where this * information is needed in the loop. Otherwise false. * } * @return bool True if there are groups to display that match the params */ function bp_has_groups($args = '') { global $groups_template; /* * Defaults based on the current page & overridden by parsed $args */ $slug = false; $type = ''; $search_terms = false; // When looking your own groups, check for two action variables. if (bp_is_current_action('my-groups')) { if (bp_is_action_variable('most-popular', 0)) { $type = 'popular'; } elseif (bp_is_action_variable('alphabetically', 0)) { $type = 'alphabetical'; } // When looking at invites, set type to invites. } elseif (bp_is_current_action('invites')) { $type = 'invites'; // When looking at a single group, set the type and slug. } elseif (bp_get_current_group_slug()) { $type = 'single-group'; $slug = bp_get_current_group_slug(); } $group_type = bp_get_current_group_directory_type(); if (!$group_type && !empty($_GET['group_type'])) { if (is_array($_GET['group_type'])) { $group_type = $_GET['group_type']; } else { // Can be a comma-separated list. $group_type = explode(',', $_GET['group_type']); } } // Default search string (too soon to escape here). $search_query_arg = bp_core_get_component_search_query_arg('groups'); if (!empty($_REQUEST[$search_query_arg])) { $search_terms = stripslashes($_REQUEST[$search_query_arg]); } elseif (!empty($_REQUEST['group-filter-box'])) { $search_terms = $_REQUEST['group-filter-box']; } elseif (!empty($_REQUEST['s'])) { $search_terms = $_REQUEST['s']; } // Parse defaults and requested arguments. $r = bp_parse_args($args, array('type' => $type, 'order' => 'DESC', 'orderby' => 'last_activity', 'page' => 1, 'per_page' => 20, 'max' => false, 'show_hidden' => false, 'page_arg' => 'grpage', 'user_id' => bp_displayed_user_id(), 'slug' => $slug, 'search_terms' => $search_terms, 'group_type' => $group_type, 'group_type__in' => '', 'group_type__not_in' => '', 'meta_query' => false, 'include' => false, 'exclude' => false, 'parent_id' => null, 'update_meta_cache' => true, 'update_admin_cache' => bp_is_groups_directory() || bp_is_user_groups()), 'has_groups'); // Setup the Groups template global. $groups_template = new BP_Groups_Template(array('type' => $r['type'], 'order' => $r['order'], 'orderby' => $r['orderby'], 'page' => (int) $r['page'], 'per_page' => (int) $r['per_page'], 'max' => (int) $r['max'], 'show_hidden' => $r['show_hidden'], 'page_arg' => $r['page_arg'], 'user_id' => (int) $r['user_id'], 'slug' => $r['slug'], 'search_terms' => $r['search_terms'], 'group_type' => $r['group_type'], 'group_type__in' => $r['group_type__in'], 'group_type__not_in' => $r['group_type__not_in'], 'meta_query' => $r['meta_query'], 'include' => $r['include'], 'exclude' => $r['exclude'], 'parent_id' => $r['parent_id'], 'update_meta_cache' => (bool) $r['update_meta_cache'], 'update_admin_cache' => (bool) $r['update_admin_cache'])); /** * Filters whether or not there are groups to iterate over for the groups loop. * * @since 1.1.0 * * @param bool $value Whether or not there are groups to iterate over. * @param BP_Groups_Template $groups_template BP_Groups_Template object based on parsed arguments. * @param array $r Array of parsed arguments for the query. */ return apply_filters('bp_has_groups', $groups_template->has_groups(), $groups_template, $r); }
function x_buddypress_is_component_with_landmark_header() { if (bp_is_activity_directory() || bp_is_groups_directory() || bp_is_members_directory() || bp_is_blogs_directory() || bp_is_current_component('register') || bp_is_current_component('activate')) { return true; } else { return false; } }
function x_is_buddypress_groups_directory() { if (function_exists('bp_is_groups_directory') && bp_is_groups_directory()) { return true; } else { return false; } }
function join_button($button) { // Remove the div wrapper $button['wrapper'] = false; // Dark buttons on directories $button['link_class'] = bp_is_groups_directory() ? 'button-dark ' . $button['link_class'] : 'button ' . $button['link_class']; // Button icon $button['link_text'] = 'leave_group' === $button['id'] ? '<i class="fa fa-remove"></i>' . $button['link_text'] : '<i class="fa fa-check"></i>' . $button['link_text']; // Return the button return $button; }
function kleo_bp_get_component_id() { $current_page_id = NULL; $page_array = get_option('bp-pages'); if (bp_is_register_page()) { /* register page */ $current_page_id = $page_array['register']; } elseif (bp_is_members_component() || bp_is_user()) { /* members component */ $current_page_id = $page_array['members']; } elseif (bp_is_activity_directory()) { /* activity directory */ $current_page_id = $page_array['activity']; } elseif (bp_is_groups_directory() || bp_is_group_single()) { /* groups directory */ $current_page_id = $page_array['groups']; } elseif (bp_is_activation_page()) { /* activation page */ $current_page_id = $page_array['activate']; } return $current_page_id; }