本文整理汇总了PHP中bp_get_current_group_slug函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_get_current_group_slug函数的具体用法?PHP bp_get_current_group_slug怎么用?PHP bp_get_current_group_slug使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_get_current_group_slug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: custom_media_nav_tab
/**
* Load Custom tabs on BuddyPress
*
* @global object $bp global BuddyPress object
*/
function custom_media_nav_tab()
{
global $bp;
if (!function_exists("bp_core_new_nav_item")) {
return;
}
if (bp_is_blog_page() || !bp_is_group() && !(isset($bp->displayed_user) && isset($bp->displayed_user->id)) || apply_filters('rtmedia_render_bp_nav', false)) {
return;
}
global $rtmedia;
if (function_exists("bp_is_group") && !bp_is_group()) {
if (isset($bp->displayed_user) && isset($bp->displayed_user->id)) {
$profile_counts = $this->actual_counts($bp->displayed_user->id);
}
$tab_position = apply_filters('rtmedia_media_tab_position', 99);
if ($rtmedia->options["buddypress_enableOnProfile"] != 0) {
bp_core_new_nav_item(array('name' => RTMEDIA_MEDIA_LABEL . '<span>' . $profile_counts['total']['all'] . '</span>', 'slug' => apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG), 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all', 'position' => $tab_position));
}
}
if (bp_is_group() && $rtmedia->options["buddypress_enableOnGroup"] != 0) {
global $bp;
$media_enabled = true;
//filter for rtMedia PRO for PER GROUP MEDIA enable/disable functionality
$media_enabled = apply_filters('rtmedia_media_enabled_for_current_group', $media_enabled);
// check if current user can view this group
$current_group = groups_get_current_group();
$is_visible_to_current_user = $current_group->is_visible;
if ($media_enabled && $is_visible_to_current_user) {
$group_counts = $this->actual_counts($bp->groups->current_group->id, "group");
$bp->bp_options_nav[bp_get_current_group_slug()]['media'] = array('name' => RTMEDIA_MEDIA_LABEL . '<span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . RTMEDIA_MEDIA_SLUG, 'slug' => RTMEDIA_MEDIA_SLUG, 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all');
}
}
}
示例2: custom_media_nav_tab
/**
* Load Custom tabs on BuddyPress
*
* @global object $bp global BuddyPress object
*/
function custom_media_nav_tab()
{
$bp = buddypress();
if (!function_exists('bp_core_new_nav_item')) {
return;
}
if (bp_is_blog_page() || !bp_is_group() && !(isset($bp->displayed_user) && isset($bp->displayed_user->id)) || apply_filters('rtmedia_render_bp_nav', false)) {
return;
}
global $rtmedia;
if (function_exists('bp_is_group') && !bp_is_group()) {
if (isset($bp->displayed_user) && isset($bp->displayed_user->id)) {
$profile_counts = $this->actual_counts($bp->displayed_user->id);
}
$tab_position = apply_filters('rtmedia_media_tab_position', 99);
if (0 !== intval($rtmedia->options['buddypress_enableOnProfile'])) {
bp_core_new_nav_item(array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $profile_counts['total']['all'] . '</span>', 'slug' => apply_filters('rtmedia_media_tab_slug', RTMEDIA_MEDIA_SLUG), 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all', 'position' => $tab_position));
}
}
if (bp_is_group() && 0 !== intval($rtmedia->options['buddypress_enableOnGroup'])) {
$media_enabled = true;
//filter for rtMedia PRO for PER GROUP MEDIA enable/disable functionality
$media_enabled = apply_filters('rtmedia_media_enabled_for_current_group', $media_enabled);
// check if current user can view this group
$current_group = groups_get_current_group();
/**
* remove `$current_group->is_visible` and add `bp_group_is_visible( $current_group )`
* reason : In Buddypress 2.7 `is_visible` return false so we can't display `media` tab on group
* issue id : http://git.rtcamp.com/rtmedia/rtMedia/issues/119
*/
// $is_visible_to_current_user = $current_group->is_visible;
$is_visible_to_current_user = bp_group_is_visible($current_group);
if ($media_enabled && $is_visible_to_current_user) {
$group_counts = $this->actual_counts($bp->groups->current_group->id, 'group');
$slug = apply_filters('rtmedia_group_media_tab_slug', RTMEDIA_MEDIA_SLUG);
if (isset($bp->version) && $bp->version > '2.5.3') {
/*
* As from BuddyPress 2.6, you can't access $bp->bp_options_nav directly.
* Use `bp_core_new_subnav_item` to add subnav item.
*
* Check https://buddypress.trac.wordpress.org/ticket/6534 and https://buddypress.trac.wordpress.org/changeset/10745
* for more details
*/
bp_core_new_subnav_item(array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . $slug, 'slug' => $slug, 'parent_slug' => bp_get_current_group_slug(), 'parent_url' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/'), 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all'));
} else {
$bp->bp_options_nav[bp_get_current_group_slug()]['media'] = array('name' => RTMEDIA_MEDIA_LABEL . ' <span>' . $group_counts['total']['all'] . '</span>', 'link' => trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/') . $slug, 'slug' => $slug, 'user_has_access' => true, 'css_id' => 'rtmedia-media-nav', 'position' => 99, 'screen_function' => array($this, 'media_screen'), 'default_subnav_slug' => 'all');
}
}
}
}
示例3: test_backcompat_remove_group_nav_items
public function test_backcompat_remove_group_nav_items()
{
$g1 = $this->factory->group->create();
// In group context
$g_obj = groups_get_group($g1);
$this->go_to(bp_get_group_permalink($g_obj));
bp_core_new_subnav_item(array('name' => 'Clam', 'slug' => 'clam', 'parent_slug' => bp_get_current_group_slug(), 'parent_url' => bp_get_group_permalink($g_obj), 'screen_function' => 'clam_subnav'));
bp_core_remove_subnav_item($g_obj->slug, 'clam');
$nav = bp_get_nav_menu_items('groups');
$found = false;
foreach ($nav as $_nav) {
if ('clam' === $_nav->css_id) {
$found = true;
break;
}
}
$this->assertFalse($found);
}
示例4: setup_display_hooks
/**
* Hook this extension's group tab into BuddyPress, if necessary
*
* @since BuddyPress (1.8)
*/
protected function setup_display_hooks()
{
// Bail if not a group
if (!bp_is_group()) {
return;
}
// Bail if the current user doesn't have access
if ('public' !== $this->visibility && !buddypress()->groups->current_group->user_has_access) {
return;
}
if (true === $this->enable_nav_item) {
bp_core_new_subnav_item(array('name' => !$this->nav_item_name ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => bp_get_current_group_slug(), 'parent_url' => bp_get_group_permalink(groups_get_current_group()), 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array(&$this, '_display_hook'), 'user_has_access' => $this->enable_nav_item));
// When we are viewing the extension display page, set the title and options title
if (bp_is_current_action($this->slug)) {
add_action('bp_template_content_header', create_function('', 'echo "' . esc_attr($this->name) . '";'));
add_action('bp_template_title', create_function('', 'echo "' . esc_attr($this->name) . '";'));
}
}
// Hook the group home widget
if (!bp_current_action() && bp_is_current_action('home')) {
add_action($this->display_hook, array(&$this, 'widget_display'));
}
}
示例5: printPostsByBuddypressGroupTax
/**
* Prints a linked list of all posts assigned to the buddypress $groupslug or if not set the current Buddypress group.
*
* @param string $groupslug slug of the buddypress_group taxonomy to get the post of (the slug should be sthe same as the real Buddypress group slug)
*/
function printPostsByBuddypressGroupTax($groupslug = NULL)
{
if (function_exists('bp_get_current_group_slug')) {
if (is_null($groupslug)) {
$currentgroup = bp_get_current_group_slug();
$posts = get_posts(array('numberposts' => -1, 'post_type' => 'post', 'tax_query' => array(array('taxonomy' => 'buddypress_groups', 'field' => 'slug', 'terms' => $currentgroup))));
if ($posts) {
?>
<ul class="posts_by_buddypressgroup">
<?php
foreach ($posts as $post) {
?>
<li><a href="<?php
echo esc_url(get_permalink($post->ID));
?>
" title="<?php
echo esc_attr($post->post_title);
?>
"><?php
echo esc_html($post->post_title);
?>
</a></li>
<?php
}
?>
</ul>
<?php
}
}
}
}
示例6: setup_display_hooks
/**
* Hook this extension's group tab into BuddyPress, if necessary.
*
* @since BuddyPress (1.8.0)
*/
protected function setup_display_hooks()
{
// Bail if not a group
if (!bp_is_group()) {
return;
}
// Backward compatibility only
if ('public' !== $this->visibility && !buddypress()->groups->current_group->user_has_access) {
return;
}
// If the user can see the nav item, we create it.
$user_can_see_nav_item = $this->user_can_see_nav_item();
if ($user_can_see_nav_item) {
$group_permalink = bp_get_group_permalink(groups_get_current_group());
bp_core_create_subnav_link(array('name' => !$this->nav_item_name ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => bp_get_current_group_slug(), 'parent_url' => $group_permalink, 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array(&$this, '_display_hook'), 'user_has_access' => $user_can_see_nav_item, 'no_access_url' => $group_permalink));
}
// If the user can visit the screen, we register it.
$user_can_visit = $this->user_can_visit();
if ($user_can_visit) {
$group_permalink = bp_get_group_permalink(groups_get_current_group());
bp_core_register_subnav_screen_function(array('slug' => $this->slug, 'parent_slug' => bp_get_current_group_slug(), 'screen_function' => array(&$this, '_display_hook'), 'user_has_access' => $user_can_visit, 'no_access_url' => $group_permalink));
// When we are viewing the extension display page, set the title and options title
if (bp_is_current_action($this->slug)) {
add_filter('bp_group_user_has_access', array($this, 'group_access_protection'), 10, 2);
add_action('bp_template_content_header', create_function('', 'echo "' . esc_attr($this->name) . '";'));
add_action('bp_template_title', create_function('', 'echo "' . esc_attr($this->name) . '";'));
}
}
// Hook the group home widget
if (!bp_current_action() && bp_is_current_action('home')) {
add_action($this->display_hook, array(&$this, 'widget_display'));
}
}
示例7: test_bp_core_new_subnav_item_should_work_in_group_context
/**
* @group groups
*/
public function test_bp_core_new_subnav_item_should_work_in_group_context()
{
$this->set_up_group();
bp_core_new_subnav_item(array('name' => 'Foo Subnav', 'slug' => 'foo-subnav', 'parent_slug' => bp_get_current_group_slug(), 'parent_url' => bp_get_group_permalink(groups_get_current_group()), 'screen_function' => 'foo_subnav'));
$bp = buddypress();
// Touch bp_nav since we told PHPUnit it was expectedDeprecated.
$f = $bp->bp_options_nav[bp_get_current_group_slug()];
$nav = bp_get_nav_menu_items('groups');
foreach ($nav as $_nav) {
if ('foo-subnav' === $_nav->css_id) {
$found = $_nav;
break;
}
}
$this->assertSame('Foo Subnav', $found->name);
}
示例8: rtmedia_pagination_page_link
function rtmedia_pagination_page_link($page_no)
{
global $rtmedia_media, $rtmedia_interaction, $rtmedia_query;
$page_url = 'pg/' . $page_no;
$site_url = is_multisite() ? trailingslashit(get_site_url(get_current_blog_id())) : trailingslashit(get_site_url());
$author_name = get_query_var('author_name');
$link = '';
if ($rtmedia_interaction && isset($rtmedia_interaction->context) && $rtmedia_interaction->context->type == "profile") {
if (function_exists("bp_core_get_user_domain")) {
$link .= trailingslashit(bp_core_get_user_domain($rtmedia_query->media_query['media_author']));
} else {
$link .= $site_url . 'author/' . $author_name . '/';
}
} else {
if ($rtmedia_interaction && isset($rtmedia_interaction->context) && $rtmedia_interaction->context->type == 'group') {
if (function_exists("bp_get_current_group_slug")) {
$link .= $site_url . bp_get_groups_root_slug() . '/' . bp_get_current_group_slug() . '/';
}
} else {
//$post = get_post ( $rtmedia_media->post_parent );
$post = get_post(get_post_field("post_parent", $rtmedia_query->media->media_id));
$link .= $site_url . $post->post_name . '/';
}
}
$link .= RTMEDIA_MEDIA_SLUG . '/';
if (isset($rtmedia_query->media_query["album_id"]) && intval($rtmedia_query->media_query["album_id"]) > 0) {
$link .= $rtmedia_query->media_query["album_id"] . "/";
}
if (isset($rtmedia_query->action_query->media_type)) {
if (in_array($rtmedia_query->action_query->media_type, array("photo", "music", "video", "album", "playlist"))) {
$link .= $rtmedia_query->action_query->media_type . '/';
}
}
return apply_filters('rtmedia_pagination_page_link', $link . $page_url, $link, $page_url);
}
示例9: get_create_link
function get_create_link($link)
{
$slug = bp_get_current_group_slug();
if ($slug && current_user_can('bp_docs_associate_with_group', bp_get_current_group_id())) {
$link = add_query_arg('group', $slug, $link);
}
return $link;
}
示例10: single_template_hierarchy
/**
* Add custom template hierarchy to theme compat for group pages.
*
* This is to mirror how WordPress has
* {@link https://codex.wordpress.org/Template_Hierarchy template hierarchy}.
*
* @since BuddyPress (1.8.0)
*
* @param string $templates The templates from bp_get_theme_compat_templates().
* @return array $templates Array of custom templates to look for.
*/
public function single_template_hierarchy($templates)
{
// Setup some variables we're going to reference in our custom templates
$group = groups_get_current_group();
// Setup our templates based on priority
$new_templates = apply_filters('bp_template_hierarchy_groups_single_item', array('groups/single/index-id-' . sanitize_file_name(bp_get_current_group_id()) . '.php', 'groups/single/index-slug-' . sanitize_file_name(bp_get_current_group_slug()) . '.php', 'groups/single/index-action-' . sanitize_file_name(bp_current_action()) . '.php', 'groups/single/index-status-' . sanitize_file_name($group->status) . '.php', 'groups/single/index.php'));
// Merge new templates with existing stack
// @see bp_get_theme_compat_templates()
$templates = array_merge((array) $new_templates, $templates);
return $templates;
}
示例11: get_component
/**
* Get the component to which the a nav item belongs.
*
* We use the following heuristic to guess, based on an offset, which component the item belongs to:
* - If this is a group, and the offset is the same as the current group's slug, it's a group nav item.
* - Otherwise, it's a member nav item.
*
* @since 2.6.0
*
* @param mixed $offset Array offset.
* @return string
*/
public function get_component($offset = '')
{
if (!isset($this->component)) {
if (bp_is_active('groups') && $offset === bp_get_current_group_slug()) {
$this->component = 'groups';
} else {
$this->component = 'members';
}
}
return $this->component;
}
示例12: get_create_link
function get_create_link($link)
{
if (bp_is_group()) {
$link = add_query_arg('group', bp_get_current_group_slug(), $link);
}
return $link;
}
示例13: display
function display($group_id = null)
{
$this->appliquerCaracterePrive();
// paramètres automatiques :
// - domaine racine
$this->config['domainRoot'] = $this->getServerRoot();
// - URI de base
$this->config['baseUri'] = $this->getBaseUri();
// - URI de base pour les données (/wp-content/*)
$this->config['dataBaseUri'] = $this->getDataBaseUri();
// - nom de la liste
if (empty($this->config['ezmlm-php']['list'])) {
$this->config['ezmlm-php']['list'] = bp_get_current_group_slug();
}
//var_dump($this->config);
// portée des styles
echo '<div class="wp-bootstrap">';
echo '<div id="ezmlm-forum-main">';
// amorcer l'outil
chdir(dirname(__FILE__) . "/forum/");
require "ezmlm-forum.php";
$fc = new EzmlmForum($this->config);
// front controller
// - définir le titre
// - inclure le corps de page
$fc->renderPage();
echo "</div>";
echo "</div>";
}
示例14: buatp_prepare_url
function buatp_prepare_url($url = '')
{
global $bp;
if (!$url) {
return;
}
if ($url == 'current') {
$url = str_replace(site_url(), '', buatp_get_full_url());
}
$current_user = get_userdata($bp->displayed_user->id);
if (function_exists('bp_get_current_group_slug')) {
$current_group_slug = bp_get_current_group_slug();
}
$bp_components = array('[user_name]' => $current_user->user_login, '[group_name]' => $current_group_slug);
foreach ($bp_components as $code => $val) {
if (strpos($url, $code) && $val) {
$url = str_replace($code, $val, $url);
}
}
return $url;
}
示例15: bp_has_groups_hierarchy
/**
* Hierarchy-aware replacement for bp_has_groups
*/
function bp_has_groups_hierarchy($args = '')
{
global $groups_template, $bp;
/***
* Set the defaults based on the current page. Any of these will be overridden
* if arguments are directly passed into the loop. Custom plugins should always
* pass their parameters directly to the loop.
*/
$type = 'active';
$user_id = false;
$search_terms = false;
$slug = false;
/* User filtering */
if (bp_displayed_user_id()) {
$user_id = bp_displayed_user_id();
}
/* Type */
if ('my-groups' == bp_current_action()) {
if ('most-popular' == $order) {
$type = 'popular';
} else {
if ('alphabetically' == $order) {
$type = 'alphabetical';
}
}
} else {
if ('invites' == bp_current_action()) {
$type = 'invites';
} else {
if (bp_get_current_group_slug()) {
$type = 'single-group';
$slug = bp_get_current_group_slug();
}
}
}
if (isset($_REQUEST['group-filter-box']) || isset($_REQUEST['s'])) {
$search_terms = isset($_REQUEST['group-filter-box']) ? $_REQUEST['group-filter-box'] : $_REQUEST['s'];
}
$defaults = array('type' => $type, 'page' => 1, 'per_page' => 20, 'max' => false, 'user_id' => $user_id, 'slug' => $slug, 'search_terms' => $search_terms, 'populate_extras' => true);
$r = wp_parse_args($args, $defaults);
extract($r);
$groups_template = new BP_Groups_Hierarchy_Template((int) $user_id, $type, (int) $page, (int) $per_page, (int) $max, $slug, $search_terms, (bool) $populate_extras, (int) $parent_id);
return apply_filters('bp_has_groups', $groups_template->has_groups(), $groups_template);
}