本文整理汇总了PHP中bp_is_current_component函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_is_current_component函数的具体用法?PHP bp_is_current_component怎么用?PHP bp_is_current_component使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_is_current_component函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_profile_url
/**
* Override bbPress profile URL with BuddyPress profile URL
*
* @since bbPress (r3401)
* @param string $url
* @param int $user_id
* @param string $user_nicename
* @return string
*/
public function user_profile_url($user_id)
{
// Define local variable(s)
$profile_url = '';
// Special handling for forum component
if (bp_is_current_component('forums')) {
// Empty action or 'topics' action
if (!bp_current_action() || bp_is_current_action('topics')) {
$profile_url = bp_core_get_user_domain($user_id) . 'forums/topics';
// Empty action or 'topics' action
} elseif (bp_is_current_action('replies')) {
$profile_url = bp_core_get_user_domain($user_id) . 'forums/replies';
// 'favorites' action
} elseif (bbp_is_favorites_active() && bp_is_current_action('favorites')) {
$profile_url = $this->get_favorites_permalink('', $user_id);
// 'subscriptions' action
} elseif (bbp_is_subscriptions_active() && bp_is_current_action('subscriptions')) {
$profile_url = $this->get_subscriptions_permalink('', $user_id);
}
// Not in users' forums area
} else {
$profile_url = bp_core_get_user_domain($user_id);
}
return trailingslashit($profile_url);
}
示例2: mpp_is_gallery_component
/**
* Are we on Gallery Directory or User Gallery Pages?
*
* @return boolean
*/
function mpp_is_gallery_component()
{
if (function_exists('bp_is_current_component') && bp_is_current_component('mediapress')) {
return true;
}
return false;
}
示例3: mpp_is_gallery_component
/**
* Are we on Gallery Directory or User Gallery Pages?
*
* @return boolean
*/
function mpp_is_gallery_component()
{
if (bp_is_current_component('mediapress')) {
return true;
}
return false;
}
示例4: setup_filters
/**
* Set filters
*
* @package Rendez Vous
* @subpackage Screens
*
* @since Rendez Vous (1.0.0)
*/
private function setup_filters()
{
if (bp_is_current_component('rendez_vous')) {
add_filter('bp_located_template', array($this, 'template_filter'), 20, 2);
add_filter('bp_get_template_stack', array($this, 'add_to_template_stack'), 10, 1);
}
}
示例5: bp_core_action_set_spammer_status
/**
* When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
* this action will fire and mark or unmark the user and their blogs as spam.
* Must be a site admin for this function to run.
*
* @package BuddyPress Core
* @param int $user_id Optional user ID to mark as spam
* @global object $nxtdb Global NXTClass Database object
*/
function bp_core_action_set_spammer_status($user_id = 0)
{
// Use displayed user if it's not yourself
if (empty($user_id)) {
$user_id = bp_displayed_user_id();
}
if (bp_is_current_component('admin') && in_array(bp_current_action(), array('mark-spammer', 'unmark-spammer'))) {
// Check the nonce
check_admin_referer('mark-unmark-spammer');
// To spam or not to spam
$status = bp_is_current_action('mark-spammer') ? 'spam' : 'ham';
// The heavy lifting
bp_core_process_spammer_status($user_id, $status);
// Add feedback message. @todo - Error reporting
if ('spam' == $status) {
bp_core_add_message(__('User marked as spammer. Spam users are visible only to site admins.', 'buddypress'));
} else {
bp_core_add_message(__('User removed as spammer.', 'buddypress'));
}
// Deprecated. Use bp_core_process_spammer_status.
$is_spam = 'spam' == $status;
do_action('bp_core_action_set_spammer_status', bp_displayed_user_id(), $is_spam);
// Redirect back to where we came from
bp_core_redirect(nxt_get_referer());
}
}
示例6: infinity_bp_nav_inject_options_filter
/**
* Inject options nav onto end of active displayed user nav component
*
* @param string $html
* @param array $user_nav_item
* @return string
*/
function infinity_bp_nav_inject_options_filter($html, $user_nav_item)
{
// slug of nav item being filtered
$component = $user_nav_item['slug'];
// show options nav?
$show = bp_is_current_component($component);
// special hack to handle profile in BP versions < 1.7
if ('profile' == $component && -1 == version_compare(BP_VERSION, '1.7') && false == bp_is_my_profile()) {
// force hide it
$show = false;
}
// filter the show var because i love developers
$show = (bool) apply_filters('infinity_bp_nav_inject_options_show', $show, $user_nav_item);
// ok, finally... should we show it?
if (true === $show) {
// yes, need to capture options nav output
ob_start();
// run options nav template tag
bp_get_options_nav();
// grab buffer and wipe it
$nav = trim((string) ob_get_clean());
// make sure the result has some meat
if ('' != $nav) {
// yep, inject options nav onto end of list item wrapped in special <ul>
return preg_replace('/(<\\/li>.*)$/', '<ul class="profile-subnav">' . $nav . '</ul>$1', $html, 1);
}
}
// no changes
return $html;
}
示例7: bp_core_action_delete_user
/**
* Process user deletion requests.
*
* Note: No longer called here. See the Settings component.
*/
function bp_core_action_delete_user()
{
$userID = bp_displayed_user_id();
echo "Buddypress:";
echo $userID;
$now = current_time('mysql');
$args = array('date_query' => array('after' => '5 minute ago', 'before' => $now, 'inclusive' => true), 'post_id' => $postID, 'user_id' => $userID, 'count' => true);
$userActivityCount = get_comments($args);
if (!bp_current_user_can('bp_moderate') || bp_is_my_profile() || !bp_displayed_user_id() || $userActivityCount != 0) {
return false;
}
if (bp_is_current_component('admin') && bp_is_current_action('delete-user') && $userActivityCount == 0) {
// Check the nonce.
check_admin_referer('delete-user');
$errors = false;
$style = "<style> #account-delete-form .submit{ display:none !important;} </style>";
if ($userActivityCount != 0) {
$errors = true;
return $style;
}
do_action('bp_core_before_action_delete_user', $errors);
if (bp_core_delete_account(bp_displayed_user_id()) || $userActivityCount == 0) {
bp_core_add_message(sprintf(__('%s has been deleted from the system.', 'buddypress'), bp_get_displayed_user_fullname()));
} else {
bp_core_add_message(sprintf(__('There was an error deleting %s from the system. Please try again.', 'buddypress'), bp_get_displayed_user_fullname()), 'error');
$errors = true;
}
do_action('bp_core_action_delete_user', $errors);
if ($errors) {
bp_core_redirect(bp_displayed_user_domain());
} else {
bp_core_redirect(bp_loggedin_user_domain());
}
}
}
示例8: bp_compliments_load_template_filter
/**
* Filters template for the user compliments tab.
*
* @since 0.0.1
* @package BuddyPress_Compliments
*
* @global object $bp BuddyPress instance.
* @param string $found_template Located template file.
* @param array $templates The template array.
* @return string Template file.
*/
function bp_compliments_load_template_filter($found_template, $templates)
{
global $bp;
// Only filter the template location when we're on the compliments component pages.
if (!bp_is_current_component($bp->compliments->compliments->slug)) {
return $found_template;
}
if (empty($found_template)) {
bp_register_template_stack('bp_compliments_get_template_directory', 14);
// locate_template() will attempt to find the plugins.php template in the
// child and parent theme and return the located template when found
//
// plugins.php is the preferred template to use, since all we'd need to do is
// inject our content into BP
//
// note: this is only really relevant for bp-default themes as theme compat
// will kick in on its own when this template isn't found
$found_template = locate_template('members/single/plugins.php', false, false);
// add our hook to inject content into BP
add_action('bp_template_content', 'bp_compliments_single_compliments_content');
}
/**
* Filters the compliment page template.
*
* @since 0.0.1
* @package BuddyPress_Compliments
*
* @param string $found_template Located template file.
*/
return apply_filters('bp_compliments_load_template_filter', $found_template);
}
示例9: check_legacy
public function check_legacy($tpl)
{
$status = function_exists('buddypress');
if (!$status) {
return $tpl;
}
$this->bp_plugin_name = bp_get_name_from_root_slug();
// This check fails for some plugins
// $status = $this->bp_plugin_name != false;
if ($status) {
$bp_defaults = array('members', 'xprofile', 'activity', 'blogs', 'messages', 'friends', 'groups', 'forums', 'settings');
foreach ($bp_defaults as $bp_default) {
if (bp_is_current_component($bp_default)) {
break;
}
}
}
if ($status && bp_is_directory()) {
$this->is_legacy = $status = false;
}
if ($status && false === (bool) locate_template(array('members/single/item-header.php'), false)) {
add_action('wp_footer', array($this, 'item_header'));
}
if ($status) {
add_action('wp_footer', array($this, 'page_title'));
add_action('wp_footer', array($this, 'echo_legacy_tpl'));
}
return $tpl;
}
示例10: bp_checkins_if_category_place
function bp_checkins_if_category_place()
{
if (!bp_displayed_user_id() && bp_is_current_component('checkins') && bp_is_current_action('place') && bp_action_variable(0) && 'category' == bp_action_variable(0) && bp_action_variable(1)) {
return true;
} else {
return false;
}
}
示例11: bcg_is_component
/**
* Are we dealing with blog categories pages?
* @return type
*/
function bcg_is_component()
{
$bp = buddypress();
if (bp_is_current_component($bp->groups->slug) && bp_is_current_action(BCG_SLUG)) {
return true;
}
return false;
}
示例12: bp_core_new_nav_item
/**
* Adds a navigation item to the main navigation array used in BuddyPress themes.
*
* @package BuddyPress Core
* @global object $bp Global BuddyPress settings object
*/
function bp_core_new_nav_item($args = '')
{
global $bp;
$defaults = array('name' => false, 'slug' => false, 'item_css_id' => false, 'show_for_displayed_user' => true, 'site_admin_only' => false, 'position' => 99, 'screen_function' => false, 'default_subnav_slug' => false);
$r = nxt_parse_args($args, $defaults);
extract($r, EXTR_SKIP);
// If we don't have the required info we need, don't create this subnav item
if (empty($name) || empty($slug)) {
return false;
}
// If this is for site admins only and the user is not one, don't create the subnav item
if ($site_admin_only && !is_super_admin()) {
return false;
}
if (empty($item_css_id)) {
$item_css_id = $slug;
}
$bp->bp_nav[$slug] = array('name' => $name, 'slug' => $slug, 'link' => $bp->loggedin_user->domain . $slug . '/', 'css_id' => $item_css_id, 'show_for_displayed_user' => $show_for_displayed_user, 'position' => $position, 'screen_function' => &$screen_function);
/***
* If this nav item is hidden for the displayed user, and
* the logged in user is not the displayed user
* looking at their own profile, don't create the nav item.
*/
if (!$show_for_displayed_user && !bp_user_has_access()) {
return false;
}
/***
* If the nav item is visible, we are not viewing a user, and this is a root
* component, don't attach the default subnav function so we can display a
* directory or something else.
*/
if (-1 != $position && bp_is_root_component($slug) && !bp_displayed_user_id()) {
return;
}
// Look for current component
if (bp_is_current_component($slug) && !bp_current_action()) {
if (!is_object($screen_function[0])) {
add_action('bp_screens', $screen_function);
} else {
add_action('bp_screens', array(&$screen_function[0], $screen_function[1]), 3);
}
if (!empty($default_subnav_slug)) {
$bp->current_action = apply_filters('bp_default_component_subnav', $default_subnav_slug, $r);
}
// Look for current item
} elseif (bp_is_current_item($slug) && !bp_current_action()) {
if (!is_object($screen_function[0])) {
add_action('bp_screens', $screen_function);
} else {
add_action('bp_screens', array(&$screen_function[0], $screen_function[1]), 3);
}
if (!empty($default_subnav_slug)) {
$bp->current_action = apply_filters('bp_default_component_subnav', $default_subnav_slug, $r);
}
}
do_action('bp_core_new_nav_item', $r, $args, $defaults);
}
示例13: is_bp_plugin
public function is_bp_plugin()
{
if (bp_is_current_component('articles')) {
// first we reset the post
add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post'));
// then we filter ‘the_content’ thanks to bp_replace_the_content
add_filter('bp_replace_the_content', array($this, 'directory_content'));
}
}
示例14: members_please_log_in
/**
* Redirects users that are not logged in to the 'wp-login.php' page.
*
* @since 0.1.0
* @uses is_user_logged_in() Checks if the current user is logged in.
* @uses auth_redirect() Redirects people that are not logged in to the login page.
*/
function members_please_log_in()
{
/* Check if the private blog feature is active. */
if (members_get_setting('private_blog')) {
/* If using BuddyPress and on the register page, don't do anything. */
if (function_exists('bp_is_current_component') && bp_is_current_component('register')) {
return;
} elseif (!is_user_logged_in()) {
auth_redirect();
}
}
}
示例15: members_please_log_in
/**
* Redirects users that are not logged in to the 'wp-login.php' page.
*
* @since 0.1.0
* @access public
* @return void
*/
function members_please_log_in()
{
// Check if the private blog feature is active and if the user is not logged in.
if (members_is_private_blog() && !is_user_logged_in()) {
// If using BuddyPress and on the register page, don't do anything.
if (function_exists('bp_is_current_component') && bp_is_current_component('register')) {
return;
}
// Redirect to the login page.
auth_redirect();
exit;
}
}