/** * @since 2.6.1 * Public $item_info * Oget the post location information from database */ public function item_info() { global $members_template; if (is_single() && empty($this->args['show_in_single_post'])) { $this->args['no_location_message'] = false; } if (empty($this->args['item_id']) && empty($members_template->member->ID) && !bp_is_user() && (!is_single() || empty($this->args['show_in_single_post']))) { return false; } if (!empty($this->args['item_id'])) { $this->args['item_id'] = $this->args['item_id']; } elseif (bp_is_user()) { global $bp; $this->args['item_id'] = $bp->displayed_user->id; } elseif (is_single()) { global $post; $this->args['item_id'] = $post->post_author; } elseif (!empty($members_template->member->ID)) { $this->args['item_id'] = $members_template->member->ID; } else { return false; } $item_info = gmw_get_member_info_from_db($this->args['item_id']); return $item_info; }
/** * Set up component navigation. * * @since BuddyPress (1.9.0) * * @see BP_Component::setup_nav() for a description of arguments. * * @param array $main_nav Optional. See BP_Component::setup_nav() for * description. * @param array $sub_nav Optional. See BP_Component::setup_nav() for * description. */ public function setup_nav($main_nav = array(), $sub_nav = array()) { // Only grab count if we're on a user page and current user has access if (bp_is_user() && bp_user_has_access()) { $count = bp_notifications_get_unread_notification_count(bp_displayed_user_id()); $class = 0 === $count ? 'no-count' : 'count'; $nav_name = sprintf(_x('Notifications <span class="%s">%s</span>', 'Profile screen nav', 'buddypress'), esc_attr($class), number_format_i18n($count)); } else { $nav_name = _x('Notifications', 'Profile screen nav', 'buddypress'); } // Add 'Notifications' to the main navigation $main_nav = array('name' => $nav_name, 'slug' => $this->slug, 'position' => 30, 'show_for_displayed_user' => bp_core_can_edit_settings(), 'screen_function' => 'bp_notifications_screen_unread', 'default_subnav_slug' => 'unread', 'item_css_id' => $this->id); // Determine user to use if (bp_displayed_user_domain()) { $user_domain = bp_displayed_user_domain(); } elseif (bp_loggedin_user_domain()) { $user_domain = bp_loggedin_user_domain(); } else { return; } $notifications_link = trailingslashit($user_domain . bp_get_notifications_slug()); // Add the subnav items to the notifications nav item $sub_nav[] = array('name' => _x('Unread', 'Notification screen nav', 'buddypress'), 'slug' => 'unread', 'parent_url' => $notifications_link, 'parent_slug' => bp_get_notifications_slug(), 'screen_function' => 'bp_notifications_screen_unread', 'position' => 10, 'item_css_id' => 'notifications-my-notifications', 'user_has_access' => bp_core_can_edit_settings()); $sub_nav[] = array('name' => _x('Read', 'Notification screen nav', 'buddypress'), 'slug' => 'read', 'parent_url' => $notifications_link, 'parent_slug' => bp_get_notifications_slug(), 'screen_function' => 'bp_notifications_screen_read', 'position' => 20, 'user_has_access' => bp_core_can_edit_settings()); parent::setup_nav($main_nav, $sub_nav); }
/** * Are we looking at something that needs Blogs theme compatibility? * * @since 1.7.0 */ public function is_blogs() { // Bail if not looking at a group. if (!bp_is_blogs_component()) { return; } // Bail if looking at a users sites. if (bp_is_user()) { return; } // Blog Directory. if (is_multisite() && !bp_current_action()) { bp_update_is_directory(true, 'blogs'); /** * Fires if in the blog directory and BuddyPress needs Blog theme compatibility, * before the actions and filters are added. * * @since 1.5.0 */ do_action('bp_blogs_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')); // Create blog. } elseif (is_user_logged_in() && bp_blog_signup_enabled()) { 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')); } }
/** * Adds the User Admin top-level menu to user pages * * @package BuddyPress * @since 1.5 */ function bp_members_admin_bar_user_admin_menu() { global $bp, $wp_admin_bar; // Only show if viewing a user if (!bp_is_user()) { return false; } // Don't show this menu to non site admins or if you're viewing your own profile if (!current_user_can('edit_users') || bp_is_my_profile()) { return false; } // User avatar $avatar = bp_core_fetch_avatar(array('item_id' => $bp->displayed_user->id, 'email' => $bp->displayed_user->userdata->user_email, 'width' => 16, 'height' => 16)); // Unique ID for the 'My Account' menu $bp->user_admin_menu_id = !empty($avatar) ? 'user-admin-with-avatar' : 'user-admin'; // Add the top-level User Admin button $wp_admin_bar->add_menu(array('id' => $bp->user_admin_menu_id, 'title' => $avatar . bp_get_displayed_user_fullname(), 'href' => bp_displayed_user_domain())); // User Admin > Edit this user's profile $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => 'edit-profile', 'title' => __("Edit Profile", 'buddypress'), 'href' => bp_get_members_component_link('profile', 'edit'))); // User Admin > Edit this user's avatar $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => 'change-avatar', 'title' => __("Edit Avatar", 'buddypress'), 'href' => bp_get_members_component_link('profile', 'change-avatar'))); // User Admin > Spam/unspam if (!bp_core_is_user_spammer(bp_displayed_user_id())) { $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => 'spam-user', 'title' => __('Mark as Spammer', 'buddypress'), 'href' => wp_nonce_url(bp_displayed_user_domain() . 'admin/mark-spammer/', 'mark-unmark-spammer'), 'meta' => array('onclick' => 'confirm(" ' . __('Are you sure you want to mark this user as a spammer?', 'buddypress') . '");'))); } else { $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => 'unspam-user', 'title' => __('Not a Spammer', 'buddypress'), 'href' => wp_nonce_url(bp_displayed_user_domain() . 'admin/unmark-spammer/', 'mark-unmark-spammer'), 'meta' => array('onclick' => 'confirm(" ' . __('Are you sure you want to mark this user as not a spammer?', 'buddypress') . '");'))); } // User Admin > Delete Account $wp_admin_bar->add_menu(array('parent' => $bp->user_admin_menu_id, 'id' => 'delete-user', 'title' => __('Delete Account', 'buddypress'), 'href' => wp_nonce_url(bp_displayed_user_domain() . 'admin/delete-user/', 'delete-user'), 'meta' => array('onclick' => 'confirm(" ' . __("Are you sure you want to delete this user's account?", 'buddypress') . '");'))); }
/** * Is it User Gallery component? * @return boolean */ function mpp_is_user_gallery_component() { if (function_exists('bp_is_user') && bp_is_user() && mpp_is_gallery_component()) { return true; } return false; }
/** * Is it User Gallery component? * @return boolean */ function mpp_is_user_gallery_component() { if (bp_is_user() && mpp_is_gallery_component()) { return true; } return false; }
/** * Filter the bbPress is_single_user function with BuddyPress eqivalent * * @since bbPress (r3552) * * @param bool $is Optional. Default false * @return bool True if viewing single user, false if not */ function bbp_filter_is_single_user($is = false) { if (!empty($is)) { return $is; } return bp_is_user(); }
/** * Verify access to the current content. * * Related: * A reference of available BuddyPress template tags * https://codex.buddypress.org/developer/template-tag-reference/ * * @since 1.0.0 * * @param int $id The content post ID to verify access. * @return bool|null True if has access, false otherwise. * Null means: Rule not relevant for current page. */ public function has_access($id, $admin_has_access = true) { global $bp; $has_access = null; if (!function_exists('bp_current_component')) { return null; } if (is_buddypress()) { // Check if access to *all* BuddyPress pages is restricted $has_access = parent::has_access(MS_Addon_BuddyPress_Rule::PROTECT_ALL, $admin_has_access); } if ($has_access) { // General BuddyPress access is either *allowed* or *not denied* $component = bp_current_component(); if (!empty($component)) { if ('members' == $component || bp_is_user()) { // Member listing or member profile access. $has_access = parent::has_access(MS_Addon_BuddyPress_Rule::PROTECT_MEMBERS, $admin_has_access); } elseif ('messages' == $component) { // Private messaging direct access. if ('compose' == $bp->current_action) { $has_access = parent::has_access(MS_Addon_BuddyPress_Rule::PROTECT_PRIVATE_MSG, $admin_has_access); } } elseif ('messages' == $component) { // Don't modify, handled by MS_Addon_Buddypress_Rule_Group } else { // Other BP pages can be handled by other rules. $has_access = null; } } } return apply_filters('ms_rule_buddypress_has_access', $has_access, $id, $this); }
/** * Setup BuddyBar navigation */ public function setup_nav($main_nav = array(), $sub_nav = array()) { // Only grab count if we're on a user page and current user has access if (bp_is_user() && bp_user_has_access()) { $count = bp_get_total_unread_messages_count(); $class = 0 === $count ? 'no-count' : 'count'; $nav_name = sprintf(__('Messages <span class="%s">%s</span>', 'buddypress'), esc_attr($class), number_format_i18n($count)); } else { $nav_name = __('Messages', 'buddypress'); } // Add 'Messages' to the main navigation $main_nav = array('name' => $nav_name, 'slug' => $this->slug, 'position' => 50, 'show_for_displayed_user' => false, 'screen_function' => 'messages_screen_inbox', 'default_subnav_slug' => 'inbox', 'item_css_id' => $this->id); // Determine user to use if (bp_displayed_user_domain()) { $user_domain = bp_displayed_user_domain(); } elseif (bp_loggedin_user_domain()) { $user_domain = bp_loggedin_user_domain(); } else { return; } // Link to user messages $messages_link = trailingslashit($user_domain . $this->slug); // Add the subnav items to the profile $sub_nav[] = array('name' => __('Inbox', 'buddypress'), 'slug' => 'inbox', 'parent_url' => $messages_link, 'parent_slug' => $this->slug, 'screen_function' => 'messages_screen_inbox', 'position' => 10, 'user_has_access' => bp_core_can_edit_settings()); $sub_nav[] = array('name' => __('Sent', 'buddypress'), 'slug' => 'sentbox', 'parent_url' => $messages_link, 'parent_slug' => $this->slug, 'screen_function' => 'messages_screen_sentbox', 'position' => 20, 'user_has_access' => bp_core_can_edit_settings()); $sub_nav[] = array('name' => __('Compose', 'buddypress'), 'slug' => 'compose', 'parent_url' => $messages_link, 'parent_slug' => $this->slug, 'screen_function' => 'messages_screen_compose', 'position' => 30, 'user_has_access' => bp_core_can_edit_settings()); if (bp_current_user_can('bp_moderate')) { $sub_nav[] = array('name' => __('Notices', 'buddypress'), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $this->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => bp_current_user_can('bp_moderate')); } parent::setup_nav($main_nav, $sub_nav); }
function mpp_current_component_id_for_user($component_id) { if (mediapress()->is_bp_active() && bp_is_user()) { return bp_displayed_user_id(); //that is displayed user id } return $component_id; }
function mpp_current_component_id_for_user($component_id) { if (bp_is_user()) { return bp_displayed_user_id(); } //that is displayed user id return $component_id; }
function subscriptions_component() { if (bp_is_user()) { return true; } else { return false; } }
/** * Handles the display of the members directory index * * @global object $bp * * @uses bp_is_user() * @uses bp_is_current_component() * @uses do_action() * @uses bp_core_load_template() * @uses apply_filters() */ function bp_members_screen_index() { if (!bp_is_user() && bp_is_members_component()) { bp_update_is_directory(true, 'members'); do_action('bp_members_screen_index'); bp_core_load_template(apply_filters('bp_members_screen_index', 'members/index')); } }
public function setup_nav($main = array(), $sub = array()) { $bp = buddypress(); $component = 'members'; $component_id = mpp_get_current_component_id(); if (!mpp_is_enabled($component, $component_id)) { //allow to disable user galleries in case they don't want it return false; } $view_helper = MPP_Gallery_Screens::get_instance(); // Add 'Gallery' to the user's main navigation $main_nav = array('name' => sprintf(__('Gallery <span>%d</span>', 'mediapress'), mpp_get_total_gallery_for_user()), 'slug' => $this->slug, 'position' => 86, 'screen_function' => array($view_helper, 'user_galleries'), 'default_subnav_slug' => 'my-galleries', 'item_css_id' => $this->id); if (bp_is_user()) { $user_domain = bp_displayed_user_domain(); } else { $user_domain = bp_loggedin_user_domain(); } $gallery_link = trailingslashit($user_domain . $this->slug); //with a trailing slash // Add the My Gallery nav item $sub_nav[] = array('name' => __('My Gallery', 'mediapress'), 'slug' => 'my-galleries', 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'position' => 10, 'item_css_id' => 'gallery-my-gallery'); if (mpp_user_can_create_gallery($component, get_current_user_id())) { // Add the Create gallery link to gallery nav $sub_nav[] = array('name' => __('Create a Gallery', 'mediapress'), 'slug' => 'create', 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'user_has_access' => bp_is_my_profile(), 'position' => 20); } if (mpp_component_has_type_filters_enabled($component, $component_id)) { $i = 10; $supported_types = mpp_component_get_supported_types($component); foreach ($supported_types as $type) { if (!mpp_is_active_type($type)) { continue; } $type_object = mpp_get_type_object($type); $sub_nav[] = array('name' => $type_object->label, 'slug' => 'type/' . $type, 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'position' => 20 + $i); $i = $i + 10; //increment the position } } // Add the Upload link to gallery nav /*$sub_nav[] = array( 'name' => __( 'Upload', 'mediapress'), 'slug' => 'upload', 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array( $view_helper, 'upload_media' ), 'user_has_access' => bp_is_my_profile(), 'position' => 30 );*/ parent::setup_nav($main_nav, $sub_nav); //disallow these names in various lists //we have yet to implement it $this->forbidden_names = apply_filters('mpp_forbidden_names', array('gallery', 'galleries', 'my-gallery', 'create', 'delete', 'upload', 'add', 'edit', 'admin', 'request', 'upload', 'tags', 'audio', 'video', 'photo')); //use this to extend the valid status $this->valid_status = apply_filters('mpp_valid_gallery_status', array_keys(mpp_get_active_statuses())); do_action('mpp_setup_nav'); // $bp->gallery->current_gallery->user_has_access }
public function test_member_activity_page() { $url = home_url($this->u->user_nicename) . '/' . bp_get_activity_slug(); $this->go_to($url); $this->assertTrue(bp_is_user()); $this->assertTrue(bp_is_my_profile()); $this->assertEquals($this->u->ID, bp_displayed_user_id()); $this->assertTrue(bp_is_activity_component()); }
/** * Should we do theme compatibility? * * Do it whenever it's available in BuddyPress (whether enabled or not for the * theme more generally) * * @since 1.5.6 * * @return bool */ function bp_docs_do_theme_compat($template = false) { if (!class_exists('BP_Theme_Compat')) { return false; } // Pre-theme-compat templates are not available for user tabs, so we // force theme compat in these cases if (bp_is_user()) { return true; } return apply_filters('bp_docs_do_theme_compat', true, $template); }
public function add_activity_nav() { $bp = buddypress(); if (!bp_is_user() || !is_user_logged_in() || !bp_is_my_profile()) { return; } $activity_link = bp_core_get_user_domain(bp_loggedin_user_id()) . $bp->activity->slug . '/'; //add to user activity subnav if it is logged in users profile bp_core_new_subnav_item(array('name' => __('News Feed', 'fb-like-activity-stream'), 'slug' => MYSTREAM_ACTIVITY_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => array($this, 'activity_screen'), 'position' => 2, 'user_has_access' => bp_is_my_profile())); //bp_core_new_nav_default(array('parent_slug'=>$bp->activity->slug,'subnav_slug'=>MYSTREAM_ACTIVITY_SLUG,'screen_function'=>array($this,'activity_screen'))); bp_core_remove_subnav_item('activity', 'just-me'); $sub_nav = array('name' => __('My Posts', 'buddypress'), 'slug' => 'personal', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_my_activity', 'position' => 10); bp_core_new_subnav_item($sub_nav); }
/** * Echoes the right link to BuddyDrive root folder regarding to context * * @uses bp_is_user() to check for user's buddydrive * @uses bp_current_action() to check for BuddyDrive nav * @uses buddydrive_get_user_buddydrive_url() to print the BuuddyBox user's url * @uses buddydrive_get_friends_subnav_slug() to get friends subnav slug * @uses buddydrive_get_friends_buddydrive_url() to print the Shared by friends BuddyDrive Url * @uses buddydrive_is_group() to check for the BuddyDrive group area * @uses buddydrive_get_group_buddydrive_url() to print the BuddyDrive group's url * @return the right url */ function buddydrive_component_home_url() { if (bp_is_user() && bp_current_action() == 'files') { echo buddydrive_get_user_buddydrive_url(); } else { if (bp_is_user() && bp_current_action() == buddydrive_get_friends_subnav_slug()) { echo buddydrive_get_friends_buddydrive_url(); } else { if (buddydrive_is_group()) { echo buddydrive_get_group_buddydrive_url(); } } } }
/** * Get a user's count viewable by others * * @since 1.2.2 * * @param int $count the number of files for the displayed user */ function buddydrive_view_add_script_data($count = 0) { global $wp_scripts; if (!bp_is_user() || bp_is_my_profile() || defined('DOING_AJAX') && DOING_AJAX) { return; } $data = $wp_scripts->get_data('buddydrive-view', 'data'); $count_data = array('id' => 'user-' . buddydrive_get_slug(), 'count' => $count); // Extend the script data $script = 'var BuddyDriveFilesCount = ' . json_encode($count_data) . ';'; if ($data) { $script = "{$data}\n{$script}"; } $wp_scripts->add_data('buddydrive-view', 'data', $script); }
/** * Enqueue the js. * * @since 1.0.0 */ function bp_mute_js() { if (!bp_mute_buddypress_exists()) { return; } if (!bp_is_active('activity')) { return; } if (!is_user_logged_in()) { return; } if (bp_is_user() || bp_is_members_directory() || bp_is_group_members()) { wp_enqueue_script('bp-mute-js', plugins_url('js/script.min.js', __FILE__), array('jquery'), NULL, true); wp_localize_script('bp-mute-js', 'mute', array('ajax_url' => admin_url('admin-ajax.php'), 'start' => wp_create_nonce('mute-nonce'), 'stop' => wp_create_nonce('unmute-nonce'))); } }
/** * Set up component navigation, and register display callbacks. */ public function setup_nav($main_nav = array(), $sub_nav = array()) { // Only grab count if we're on a user page. $count = 0; if (bp_is_user()) { $count = $this->humcore_get_user_deposit_count(); } $class = 0 === $count ? 'no-count' : 'count'; $nav_name = sprintf(__('Deposits <span class="%s">%s</span>', 'humcore_domain'), esc_attr($class), number_format_i18n($count)); $main_nav = array('name' => $nav_name, 'slug' => $this->slug, 'position' => 35, 'default_subnav_slug' => 'my-deposits', 'screen_function' => array($this, 'screen_function')); /** BuddyPress needs to have at least one subnav item, even if * it's redundant */ $sub_nav[] = array('name' => __('Deposits', 'humcore_domain'), 'slug' => 'my-deposits', 'parent_slug' => 'deposits', 'parent_url' => bp_displayed_user_domain() . 'deposits/'); parent::setup_nav($main_nav, $sub_nav); }
/** * Setup profile navigation * * @package BuddyForms * @since 0.1 beta */ public function setup_nav($main_nav = array(), $sub_nav = array()) { global $buddyforms, $bp, $wp_admin_bar, $current_user; if (!bp_is_user()) { return; } get_currentuserinfo(); $position = 20; if (empty($buddyforms)) { return; } foreach ($buddyforms as $key => $member_form) { $position++; if (isset($member_form['profiles_integration'])) { $slug = $member_form['slug']; if (current_user_can('buddyforms_' . $slug . '_create') || user_can(bp_displayed_user_id(), 'buddyforms_' . $slug . '_create')) { $post_type_object = get_post_type_object($member_form['post_type']); if (isset($post_type_object->labels->name)) { $name = $post_type_object->labels->name; } if (isset($member_form['name'])) { $name = $member_form['name']; } $count = $this->get_user_posts_count($bp->displayed_user->id, $member_form['post_type'], $slug); if ('noparent' == $member_form['profiles_parent_tab']) { $main_nav = array('name' => sprintf('%s <span>%d</span>', $name, $count), 'slug' => $key, 'position' => $position, 'default_subnav_slug' => 'my-posts'); $sub_nav[] = array('name' => sprintf(__(' My %s', 'buddyforms'), $name), 'slug' => 'my-posts', 'parent_slug' => $slug, 'parent_url' => trailingslashit(bp_loggedin_user_domain() . $slug), 'item_css_id' => 'my-posts', 'screen_function' => array($this, 'buddyforms_screen_settings')); $sub_nav[] = array('name' => sprintf(__(' Add %s', 'buddyforms'), $member_form['singular_name']), 'slug' => 'create', 'parent_slug' => $slug, 'parent_url' => trailingslashit(bp_loggedin_user_domain() . $slug), 'item_css_id' => 'apps_sub_nav', 'screen_function' => array($this, 'load_members_post_create'), 'user_has_access' => bp_is_my_profile()); $sub_nav[] = array('name' => sprintf(__(' Edit %s', 'buddyforms'), $member_form['singular_name']), 'slug' => 'edit', 'parent_slug' => $slug, 'parent_url' => trailingslashit(bp_loggedin_user_domain() . $slug), 'item_css_id' => 'sub_nav_edit', 'screen_function' => array($this, 'buddyforms_screen_settings'), 'user_has_access' => bp_is_my_profile()); $sub_nav[] = array('name' => sprintf(__(' Revision %s', 'buddyforms'), $member_form['singular_name']), 'slug' => 'revision', 'parent_slug' => $slug, 'parent_url' => trailingslashit(bp_loggedin_user_domain() . $slug), 'item_css_id' => 'sub_nav_edit', 'screen_function' => array($this, 'buddyforms_screen_settings'), 'user_has_access' => bp_is_my_profile()); $sub_nav[] = array('name' => sprintf(__(' Page %s', 'buddyforms'), $member_form['singular_name']), 'slug' => 'page', 'parent_slug' => $slug, 'parent_url' => trailingslashit(bp_loggedin_user_domain() . $slug), 'item_css_id' => 'sub_nav_edit', 'screen_function' => array($this, 'buddyforms_screen_settings')); } if ('noparent' != $member_form['profiles_parent_tab']) { $key = $member_form['profiles_parent_tab']; $sub_nav[] = array('name' => sprintf(__(' My %s', 'buddyforms'), $name), 'slug' => $member_form['slug'] . '-my-posts', 'position' => $position + 100, 'parent_slug' => $key, 'parent_url' => trailingslashit(bp_loggedin_user_domain() . $key), 'item_css_id' => 'my-posts', 'screen_function' => array($this, 'buddyforms_screen_settings')); $sub_nav[] = array('name' => sprintf(__(' Add %s', 'buddyforms'), $member_form['singular_name']), 'slug' => $member_form['slug'] . '-create', 'position' => $position + 100, 'parent_slug' => $key, 'parent_url' => trailingslashit(bp_loggedin_user_domain() . $key), 'item_css_id' => 'apps_sub_nav', 'screen_function' => array($this, 'load_members_post_create'), 'user_has_access' => bp_is_my_profile()); $sub_nav[] = array('name' => sprintf(__(' Edit %s', 'buddyforms'), $member_form['singular_name']), 'slug' => $member_form['slug'] . '-edit', 'parent_slug' => $key, 'parent_url' => trailingslashit(bp_loggedin_user_domain() . $key), 'item_css_id' => 'sub_nav_edit', 'screen_function' => array($this, 'buddyforms_screen_settings'), 'user_has_access' => bp_is_my_profile()); } if ($current_user->ID != bp_displayed_user_id()) { parent::setup_nav($main_nav, $sub_nav); } elseif (current_user_can('buddyforms_' . $slug . '_create')) { parent::setup_nav($main_nav, $sub_nav); } } } } }
/** * Return solr results when called from an ajax call. */ function humcore_ajax_return_solr_results() { ob_start(); if (bp_is_user()) { locate_template(array('deposits/user-deposits-loop.php'), true); } else { if (bp_is_group()) { locate_template(array('deposits/group-deposits-loop.php'), true); } else { locate_template(array('deposits/deposits-loop.php'), true); } } $results = ob_get_contents(); ob_end_clean(); echo $results; // XSS OK. exit; }
function remove_wpseo_from_buddypress($title) { global $bp, $post; if (empty($this->bp_pages)) { $this->bp_pages = get_option('bp-pages'); } if (function_exists('bp_is_directory') && bp_is_directory() || in_array($post->ID, $this->bp_pages)) { $title = sprintf(_x('%s Directory - %s', 'Directory Title format', 'vibe'), ucfirst(bp_current_component()), get_bloginfo('name')); } if (function_exists('bp_is_user') && bp_is_user()) { //$title = sprintf(_x('%1s group - %2s','Member Name',ucfirst(bp_get_displayed_user_fullname()),get_bloginfo('name'))); $title = ucfirst(bp_get_displayed_user_fullname()) . ' - ' . get_bloginfo('name'); } if (function_exists('bp_is_group') && bp_is_group()) { //$title = sprintf(_x('%1s group - %2s','Group Name',ucfirst(bp_get_current_group_name()),get_bloginfo('name'))); $title = ucfirst(bp_get_current_group_name()) . ' - ' . get_bloginfo('name'); } return $title; }
public function hide_role_fields($args) { global $pagenow; $hide = false; if (is_admin() && isset($_GET['page']) && $_GET['page'] == 'bp-profile-edit' && $pagenow == 'users.php') { $hide = true; } if (!$hide && !bp_is_user() && !bp_is_register_page()) { return $args; } $excluded_fields = $args['exclude_fields']; if (empty($excluded_fields)) { $excluded_fields = array(); } $role_field_ids = bd_pseudo_get_role_fields(); $excluded_fields = array_merge($excluded_fields, $role_field_ids); $args['exclude_fields'] = $excluded_fields; return $args; }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ function widget($args, $instance) { extract($args); $single_post = $instance['single_post']; $display_name = $instance['display_name']; $map_height = $instance['map_height']; $map_width = $instance['map_width']; $directions = $instance['directions']; $map_type = $instance['map_type']; $address = $instance['address']; $no_location = $instance['no_location']; $zoom_level = $instance['zoom_level']; $address_fields = $instance['address_fields']; if (bp_is_user() || is_single() && isset($single_post) && $single_post == 1) { if (!isset($no_location)) { if (is_single()) { global $post; $member_id = $post->post_author; } else { $member_id = $bp->displayed_user->id; } $member_info = gmw_get_member_info_from_db($member_id); if (!isset($member_info) || empty($member_info)) { return; } } echo $before_widget; if (isset($display_name) && $display_name == 1) { if (is_single() && !bp_is_user()) { global $post; $member_id = $post->post_author; } elseif (bp_is_user()) { global $bp; $member_id = $bp->displayed_user->id; } echo $before_title . '<a href="' . bp_core_get_user_domain($member_id) . '">' . bp_core_get_user_displayname($member_id) . ''s Location</a>' . $after_title; } $mAddress = isset($address_fields) && !empty($address_fields) ? implode(',', $address_fields) : 'street,city,state,zipcode,country'; echo do_shortcode('[gmw_member_location widget="1" display_name="0" show_on_single_post="' . $single_post . '" address_fields="' . $mAddress . '" map_width="' . $map_width . '" map_height="' . $map_height . '" address="' . $address . '" map_type="' . $map_type . '" directions="' . $directions . '" no_location="' . $no_location . '" zoom_level="' . $zoom_level . '"]'); echo $after_widget; } }
/** * Get the total compliment counts for a user. * * @since 0.0.1 * @package BuddyPress_Compliments * * @global object $bp BuddyPress instance. * @param string|array $args { * Attributes of the $args. * * @type int $user_id User ID. * * } * @return mixed|void */ function bp_compliments_total_counts($args = '') { $r = wp_parse_args($args, array('user_id' => bp_loggedin_user_id())); $count = false; /* try to get locally-cached values first */ // logged-in user if ($r['user_id'] == bp_loggedin_user_id() && is_user_logged_in()) { global $bp; if (!empty($bp->loggedin_user->total_compliment_counts)) { $count = $bp->loggedin_user->total_compliment_counts; } // displayed user } elseif ($r['user_id'] == bp_displayed_user_id() && bp_is_user()) { global $bp; if (!empty($bp->displayed_user->total_compliment_counts)) { $count = $bp->displayed_user->total_compliment_counts; } } // no cached value, so query for it if ($count === false) { $count = BP_Compliments::get_counts($r['user_id']); } /** * Filters the compliment count array. * * @since 0.0.1 * @package BuddyPress_Compliments * * @param array $count { * Attributes of the $count. * * @type int $received Count of total compliments received. * @type int $sent Count of total compliments sent. * * } * @param int $r['user_id'] User ID. */ return apply_filters('bp_compliments_total_counts', $count, $r['user_id']); }
function setup_nav($main_nav = array(), $sub_nav = array()) { $directWorkflow = isDirectWorkflow(); $main_nav = array('name' => __('My articles', 'social-articles'), 'slug' => SA_SLUG, 'position' => 100, 'screen_function' => 'social_articles_screen', 'default_subnav_slug' => 'articles'); $user_domain = bp_is_user() ? bp_displayed_user_domain() : bp_loggedin_user_domain(); $social_articles_link = trailingslashit($user_domain . SA_SLUG); $user_id = bp_is_user() ? bp_displayed_user_id() : bp_loggedin_user_id(); if (bp_displayed_user_id() == bp_loggedin_user_id()) { $publishCount = custom_get_user_posts_count('publish'); $pendingCount = custom_get_user_posts_count('pending'); $draftCount = custom_get_user_posts_count('draft'); $sub_nav[] = array('name' => sprintf(__("Published", "social-articles") . '<span>%d</span>', $publishCount), 'slug' => 'articles', 'parent_url' => $social_articles_link, 'parent_slug' => SA_SLUG, 'screen_function' => 'my_articles_screen', 'position' => 10); if (!$directWorkflow) { $sub_nav[] = array('name' => sprintf(__("Under Review", "social-articles") . '<span>%d</span>', $pendingCount), 'slug' => 'under-review', 'parent_url' => $social_articles_link, 'parent_slug' => SA_SLUG, 'screen_function' => 'pending_articles_screen', 'position' => 20); } $sub_nav[] = array('name' => sprintf(__("Draft", "social-articles") . '<span>%d</span>', $draftCount), 'slug' => 'draft', 'parent_url' => $social_articles_link, 'parent_slug' => SA_SLUG, 'screen_function' => 'draft_articles_screen', 'position' => 30); $sub_nav[] = array('name' => __('New article', 'social-articles'), 'slug' => 'new', 'parent_url' => $social_articles_link, 'parent_slug' => SA_SLUG, 'screen_function' => 'new_article_screen', 'position' => 40); } if ($this->check_visibility()) { parent::setup_nav($main_nav, $sub_nav); } }
/** * Are we looking at something that needs Blogs theme compatability? * * @since BuddyPress (1.7.0) */ public function is_blogs() { // Bail if not looking at a group if (!bp_is_blogs_component()) { return; } // Bail if looking at a users sites if (bp_is_user()) { return; } // Blog Directory if (is_multisite() && !bp_current_action()) { bp_update_is_directory(true, 'blogs'); do_action('bp_blogs_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')); // Create blog } elseif (is_user_logged_in() && bp_blog_signup_enabled()) { 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')); } }
/** * 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')); } }