public function profile_tab_gifts() { global $bp; bp_core_new_nav_item(array('parent_url' => bp_loggedin_user_domain() . '/gifts/', 'parent_slug' => $bp->profile->slug, 'default_subnav_slug' => 'send_gift', 'show_for_displayed_user' => false, 'name' => 'Gifts', 'slug' => 'gifts', 'screen_function' => array($this, 'send_gift_posts'), 'position' => 40)); bp_core_new_subnav_item(array('name' => 'Send Gift', 'slug' => 'send_gift', 'show_for_displayed_user' => false, 'parent_url' => bp_loggedin_user_domain() . '/gifts/', 'parent_slug' => $bp->bp_nav['gifts']['slug'], 'position' => 10, 'screen_function' => array($this, 'send_gift_posts'))); bp_core_new_subnav_item(array('name' => 'Received Gift', 'slug' => 'received_gift', 'parent_url' => bp_loggedin_user_domain() . '/gifts/', 'parent_slug' => $bp->bp_nav['gifts']['slug'], 'position' => 10, 'screen_function' => array($this, 'received_gifts_posts'))); }
/** * Add the "My Account" menu and all submenus. * * @since 1.6.0 * * @todo Deprecate WP 3.2 Toolbar compatibility when we drop 3.2 support */ function bp_members_admin_bar_my_account_menu() { global $wp_admin_bar; // Bail if this is an ajax request if (defined('DOING_AJAX')) { return; } // Logged in user if (is_user_logged_in()) { $bp = buddypress(); // Stored in the global so we can add menus easily later on $bp->my_account_menu_id = 'my-account-buddypress'; // Create the main 'My Account' menu $wp_admin_bar->add_menu(array('id' => $bp->my_account_menu_id, 'group' => true, 'title' => __('Edit My Profile', 'buddypress'), 'href' => bp_loggedin_user_domain(), 'meta' => array('class' => 'ab-sub-secondary'))); // Show login and sign-up links } elseif (!empty($wp_admin_bar)) { add_filter('show_admin_bar', '__return_true'); // Create the main 'My Account' menu $wp_admin_bar->add_menu(array('id' => 'bp-login', 'title' => __('Log in', 'buddypress'), 'href' => wp_login_url(bp_get_requested_url()))); // Sign up if (bp_get_signup_allowed()) { $wp_admin_bar->add_menu(array('id' => 'bp-register', 'title' => __('Register', 'buddypress'), 'href' => bp_get_signup_page())); } } }
function bp_reshare_notajaxed_feed_url($feed_url) { if ($_COOKIE['bp-activity-scope'] == 'reshares') { $feed_url = bp_loggedin_user_domain() . bp_get_activity_slug() . '/reshares/feed/'; } return $feed_url; }
function bp_content_setup_nav() { global $bp; bp_core_new_nav_item(array('name' => __('My Posts', 'buddypress'), 'slug' => 'my-posts', 'screen_function' => 'my_posts_screen_link', 'position' => 40, 'default_subnav_slug' => 'my-posts-subnav')); bp_core_new_subnav_item(array('name' => __('', 'buddypress'), 'slug' => 'my-posts', 'parent_url' => trailingslashit(bp_loggedin_user_domain() . 'main-tab'), 'parent_slug' => 'my-posts', 'screen_function' => 'my_posts_screen_link', 'position' => 10)); do_action('bp_content_setup_nav'); }
/** * Catch and process the Requests page. */ function friends_screen_requests() { if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) { // Check the nonce check_admin_referer('friends_accept_friendship'); if (friends_accept_friendship(bp_action_variable(1))) { bp_core_add_message(__('Friendship accepted', 'buddypress')); } else { bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error'); } bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action())); } elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) { // Check the nonce check_admin_referer('friends_reject_friendship'); if (friends_reject_friendship(bp_action_variable(1))) { bp_core_add_message(__('Friendship rejected', 'buddypress')); } else { bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error'); } bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action())); } elseif (bp_is_action_variable('cancel', 0) && is_numeric(bp_action_variable(1))) { // Check the nonce check_admin_referer('friends_withdraw_friendship'); if (friends_withdraw_friendship(bp_loggedin_user_id(), bp_action_variable(1))) { bp_core_add_message(__('Friendship request withdrawn', 'buddypress')); } else { bp_core_add_message(__('Friendship request could not be withdrawn', 'buddypress'), 'error'); } bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action())); } do_action('friends_screen_requests'); bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home')); }
/** * Format the BuddyBar/Toolbar notifications for the Friends component * * @package BuddyPress * * @param string $action The kind of notification being rendered * @param int $item_id The primary item id * @param int $secondary_item_id The secondary item id * @param int $total_items The total number of messaging-related notifications waiting for the user * @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar */ function friends_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string') { switch ($action) { case 'friendship_accepted': $link = trailingslashit(bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends'); // Set up the string and the filter if ((int) $total_items > 1) { $text = sprintf(__('%d friends accepted your friendship requests', 'buddypress'), (int) $total_items); $filter = 'bp_friends_multiple_friendship_accepted_notification'; } else { $text = sprintf(__('%s accepted your friendship request', 'buddypress'), bp_core_get_user_displayname($item_id)); $filter = 'bp_friends_single_friendship_accepted_notification'; } break; case 'friendship_request': $link = bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/?new'; // Set up the string and the filter if ((int) $total_items > 1) { $text = sprintf(__('You have %d pending friendship requests', 'buddypress'), (int) $total_items); $filter = 'bp_friends_multiple_friendship_request_notification'; } else { $text = sprintf(__('You have a friendship request from %s', 'buddypress'), bp_core_get_user_displayname($item_id)); $filter = 'bp_friends_single_friendship_request_notification'; } break; } // Return either an HTML link or an array, depending on the requested format if ('string' == $format) { $return = apply_filters($filter, '<a href="' . $link . '">' . $text . '</a>', (int) $total_items); } else { $return = apply_filters($filter, array('link' => $link, 'text' => $text), (int) $total_items); } do_action('friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return); return $return; }
/** * Format on screen notifications into something readable by users. * * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() */ function bp_follow_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string') { global $bp; do_action('bp_follow_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $format); switch ($action) { case 'new_follow': $link = $text = false; if (1 == $total_items) { $text = sprintf(__('%s is now following you', 'bp-follow'), bp_core_get_user_displayname($item_id)); $link = bp_core_get_user_domain($item_id) . '?bpf_read'; } else { $text = sprintf(__('%d more users are now following you', 'bp-follow'), $total_items); if (bp_is_active('notifications')) { $link = bp_get_notifications_permalink(); } else { $link = bp_loggedin_user_domain() . $bp->follow->followers->slug . '/?new'; } } break; default: $link = apply_filters('bp_follow_extend_notification_link', false, $action, $item_id, $secondary_item_id, $total_items); $text = apply_filters('bp_follow_extend_notification_text', false, $action, $item_id, $secondary_item_id, $total_items); break; } if (!$link || !$text) { return false; } if ('string' == $format) { return apply_filters('bp_follow_new_followers_notification', '<a href="' . $link . '">' . $text . '</a>', $total_items, $link, $text, $item_id, $secondary_item_id); } else { $array = array('text' => $text, 'link' => $link); return apply_filters('bp_follow_new_followers_return_notification', $array, $item_id, $secondary_item_id, $total_items); } }
function friends_screen_requests() { if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) { // Check the nonce check_admin_referer('friends_accept_friendship'); if (friends_accept_friendship(bp_action_variable(1))) { bp_core_add_message(__('Friendship accepted', 'buddypress')); } else { bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error'); } bp_core_redirect(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()); } elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) { // Check the nonce check_admin_referer('friends_reject_friendship'); if (friends_reject_friendship(bp_action_variable(1))) { bp_core_add_message(__('Friendship rejected', 'buddypress')); } else { bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error'); } bp_core_redirect(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action()); } do_action('friends_screen_requests'); if (isset($_GET['new'])) { bp_core_delete_notifications_by_type(bp_loggedin_user_id(), 'friends', 'friendship_request'); } bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home')); }
function mme_nav_menu_profile_links($menu, $args) { if (is_user_logged_in() && $args->theme_location == 'member') { $profilelink = '<li><a href="' . bp_loggedin_user_domain('/') . '">' . __('Mein Profil', 'hr-beisl') . '</a></li>'; $menu = $profilelink . $menu; } return $menu; }
function add_dashboard_in_menu($menu) { $dash_menu['dashboard'] = array('icon' => 'icon-meter', 'label' => __('Dashboard', 'wplms-dashboard'), 'link' => bp_loggedin_user_domain() . WPLMS_DASHBOARD_SLUG); foreach ($menu as $key => $item) { $dash_menu[$key] = $item; } return $dash_menu; }
/** * Set up navigation * * @since 1.3 */ function setup_nav($main_nav = array(), $sub_nav = array()) { // Add 'Example' to the main navigation $main_nav = array('name' => __('Projects', 'collabpress'), 'slug' => $this->slug, 'position' => 44, 'screen_function' => array($this, 'template_loader'), 'default_subnav_slug' => 'tasks', 'show_for_displayed_user' => array($this, 'show_tab_for_current_user')); $projects_link = trailingslashit(bp_loggedin_user_domain() . $this->slug); // Add a few subnav items under the main Example tab $sub_nav[] = array('name' => bp_is_my_profile() ? __('My Tasks', 'collabpress') : sprintf(__('%s’s Tasks', 'collabpress'), bp_get_user_firstname()), 'slug' => 'tasks', 'parent_url' => $projects_link, 'parent_slug' => $this->slug, 'screen_function' => array($this, 'template_loader'), 'position' => 10); parent::setup_nav($main_nav, $sub_nav); }
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 }
/** * Get user profile URL to add our Google Drive options. * * If BuddyPress is enabled and the BP Settings component is enabled, we'll * use the user settings URL. Otherwise, we'll use the admin dashboard * profile link from the main site. * * @return string */ function mexp_gdrive_get_user_profile_url() { if (function_exists('buddypress') && bp_is_active('settings')) { $url = trailingslashit(bp_loggedin_user_domain() . bp_get_settings_slug()); } else { $url = get_admin_url($GLOBALS['current_site']->blog_id, 'profile.php'); } return apply_filters('mexp_gdrive_get_user_profile_url', $url . '#gauth'); }
public function setup_settings_privacy_nav($wp_admin_nav) { // Setup the logged in user variables if (is_rtmedia_privacy_user_overide()) { $settings_link = trailingslashit(bp_loggedin_user_domain() . bp_get_settings_slug()); // Add the "Profile" subnav item $wp_admin_nav[] = array('parent' => 'my-account-' . buddypress()->settings->id, 'id' => 'my-account-' . buddypress()->settings->id . '-privacy', 'title' => _x('Privacy', 'My Account Privacy sub nav', 'rtmedia'), 'href' => trailingslashit($settings_link . 'privacy')); } return $wp_admin_nav; }
function bp_links_dtheme_activity_type_tabs_setup() { global $bp; if (!bp_links_is_default_theme()) { return false; } if (is_user_logged_in() && bp_links_total_links_for_user(bp_loggedin_user_id())) { echo sprintf('<li id="activity-links"><a href="%s" title="%s">%s</a></li>', bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/' . bp_links_slug() . '/', __('The activity of links I created.', 'buddypress-links'), __('My Links', 'buddypress-links') . sprintf(' <span>%s</span>', bp_links_total_links_for_user(bp_loggedin_user_id()))); } }
function add_videos_subnav_tab() { global $bp; bp_core_new_subnav_item(array('name' => 'Posts', 'slug' => 'posts', 'parent_url' => trailingslashit(bp_loggedin_user_domain() . 'favorites'), 'parent_slug' => 'favorites', 'screen_function' => 'profile_screen_posts', 'position' => 10)); bp_core_new_subnav_item(array('name' => 'Articles', 'slug' => 'articles', 'parent_url' => trailingslashit(bp_loggedin_user_domain() . 'favorites'), 'parent_slug' => 'favorites', 'screen_function' => 'profile_screen_articles', 'position' => 20)); $bp->bp_nav['profile']['name'] = 'About Me'; $bp->bp_nav['buddyblog']['name'] = 'Published Articles'; $bp->bp_nav['friends']['name'] = 'Soul Family'; $bp->bp_nav['friends']['position'] = 20; }
function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget; // set widget title when logged out if (!is_user_logged_in()) { $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); if (!empty($title)) { echo $before_title . $title . $after_title; } } // start widget display code if (function_exists('bp_is_active')) { // check is user is logged in if (is_user_logged_in()) { echo "<div id='sidebarme'>"; echo "<a href='" . bp_loggedin_user_domain() . "'>"; echo bp_loggedin_user_avatar('type=thumb'); echo "</a>"; echo "<ul class='sidebarme-quicklinks'>"; echo "<li class='sidebarme-username'>" . bp_core_get_userlink(bp_loggedin_user_id()) . "</li>"; echo "<li class='sidebarme-profile'>"; echo "<a href='" . bp_loggedin_user_domain() . "profile/edit'>" . __('Edit Profile', 'boss') . "</a>"; echo " · "; echo wp_loginout(); echo "</li>"; echo "</ul>"; echo "</div>"; // check if user is logged out } else { echo "<form name='login-form' id='sidebar-login-form' class='standard-form' action='" . site_url('wp-login.php', 'login_post') . "' method='post'>"; echo "<label>" . __('Username', 'boss') . "</label>"; $return = isset($_POST['value']) ? $_POST['value'] : ''; $return .= "<input type='text' name='log' id='sidebar-user-login' class='input' value='"; if (isset($user_login)) { $return .= esc_attr(stripslashes($user_login)); } $return .= "' tabindex='97' />"; echo $return; echo "<label>" . __('Password', 'boss') . "</label>"; echo "<input type='password' name='pwd' id='sidebar-user-pass' class='input' value='' tabindex='98' />"; echo "<p class='forgetmenot'><input name='rememberme' type='checkbox' id='sidebar-rememberme' value='forever' tabindex='99' /> " . __('Remember Me', 'boss') . "</p>"; echo do_action('bp_sidebar_login_form'); echo "<input type='submit' name='wp-submit' id='sidebar-wp-submit' value='" . __('Log In', 'boss') . "' tabindex='100' />"; if (bp_get_signup_allowed()) { echo " <a class='sidebar-wp-register' href='" . bp_get_signup_page() . "'>" . __('Register', 'boss') . "</a>"; } echo "</form>"; } } // end widget display code echo $after_widget; }
/** * Add an item to the main BuddyPress navigation array. * * @global BuddyPress $bp The one true BuddyPress instance. * * @param array $args { * Array describing the new nav item. * @type string $name Display name for the nav item. * @type string $slug Unique URL slug for the nav item. * @type bool|string $item_css_id Optional. 'id' attribute for the nav * item. Default: the value of $slug. * @type bool $show_for_displayed_user Optional. Whether the nav item * should be visible when viewing a member profile other than your * own. Default: true. * @type bool $site_admin_only Optional. Whether the nav item should be * visible only to site admins (those with the 'bp_moderate' cap). * Default: false. * @type int $position Optional. Numerical index specifying where the item * should appear in the nav array. Default: 99. * @type callable $screen_function The callback function that will run * when the nav item is clicked. * @type bool|string $default_subnav_slug Optional. The slug of the default * subnav item to select when the nav item is clicked. * } * @return bool|null Returns false on failure. */ 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 = wp_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 (!empty($site_admin_only) && !bp_current_user_can('bp_moderate')) { return false; } if (empty($item_css_id)) { $item_css_id = $slug; } $bp->bp_nav[$slug] = array('name' => $name, 'slug' => $slug, 'link' => trailingslashit(bp_loggedin_user_domain() . $slug), 'css_id' => $item_css_id, 'show_for_displayed_user' => $show_for_displayed_user, 'position' => $position, 'screen_function' => &$screen_function, 'default_subnav_slug' => $default_subnav_slug); /** * 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 (empty($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_is_current_item($slug)) { // The requested URL has explicitly included the default subnav // (eg: http://example.com/members/membername/activity/just-me/) // The canonical version will not contain this subnav slug. if (!empty($default_subnav_slug) && bp_is_current_action($default_subnav_slug) && !bp_action_variable(0)) { unset($bp->canonical_stack['action']); } elseif (!bp_current_action()) { // Add our screen hook if screen function is callable if (is_callable($screen_function)) { add_action('bp_screens', $screen_function, 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); }
function kleo_menu_notifications($item_output, $item, $depth, $args) { global $kleo_config; $output = ''; $url = bp_loggedin_user_domain() . BP_NOTIFICATIONS_SLUG; $notifications = bp_notifications_get_notifications_for_user(bp_loggedin_user_id(), 'object'); $count = !empty($notifications) ? count($notifications) : 0; if ($count > 0) { $alert = 'new-alert'; $status = ' has-notif'; } else { $alert = 'no-alert'; $status = ''; } $attr_title = strip_tags($item->attr_title); if (isset($item->icon) && $item->icon != '') { $kleo_config['mobile_notify_icon'] = $item->icon; $title_icon = '<i class="icon-' . $item->icon . '"></i>'; if ($item->iconpos == 'after') { $title = $item->title . ' ' . $title_icon; } elseif ($item->iconpos == 'icon') { $title = $title_icon; } else { $title = $title_icon . ' ' . $item->title; } //If we have the menu item then add it to the mobile menu add_action('kleo_mobile_header_icons', 'kleo_bp_mobile_notify', 9); } else { $title = $item->title; } $output .= '<a class="notify-contents" href="' . $url . '" title="' . $attr_title . '">' . '<span class="notify-items"> ' . $title . ' <span class="kleo-notifications ' . $alert . '">' . $count . '</span></span>' . '</a>'; $output .= '<div class="kleo-toggle-submenu"><ul class="submenu-inner' . $status . '">'; if (!empty($notifications)) { foreach ((array) $notifications as $notification) { $output .= '<li class="kleo-submenu-item" id="kleo-notification-' . $notification->id . '">'; $output .= '<a href="' . $notification->href . '">' . $notification->content . '</a>'; //$output .= '<a data-id="' . $notification->id . '" title="' . __( 'Mark as read', 'kleo_framework' ) . '" class="remove" href="#">×</a>'; $output .= '</li>'; } } else { $output .= '<li class="kleo-submenu-item">' . __('No new notifications', 'kleo_framework') . '</li>'; } $output .= '</ul>'; if (!empty($notifications)) { $style = ''; } else { $style = ' style="display: none;"'; } $output .= '<div class="minicart-buttons text-center"' . $style . '><a class="btn btn-default mark-as-read" href="#">' . __('Mark all as read', 'kleo_framework') . '</a></div>'; $output .= '</div>'; return $output; }
/** * Set the component's navigation */ public function setup_nav() { // Main navigation $main_nav = array('name' => sprintf(__('Projects <span>%s</span>', 'bp-portfolio'), bp_portfolio_get_user_projects_count(bp_displayed_user_id())), 'slug' => bp_get_portfolio_slug(), 'position' => 80, 'screen_function' => 'bp_portfolio_screen_personal', 'default_subnav_slug' => 'personal'); $portfolio_link = trailingslashit(bp_loggedin_user_domain() . bp_get_portfolio_slug()); // Add a few subnav items under the main Portfolio tab $sub_nav[] = array('name' => __('Personal', 'bp-portfolio'), 'slug' => 'personal', 'parent_url' => $portfolio_link, 'parent_slug' => bp_get_portfolio_slug(), 'screen_function' => 'bp_portfolio_screen_personal', 'position' => 10); if (bp_displayed_user_id() == bp_loggedin_user_id()) { // Add a few subnav items under the main Portfolio tab $sub_nav[] = array('name' => __('Add', 'bp-portfolio'), 'slug' => 'add', 'parent_url' => $portfolio_link, 'parent_slug' => bp_get_portfolio_slug(), 'screen_function' => 'bp_portfolio_screen_add', 'position' => 20); } parent::setup_nav($main_nav, $sub_nav); }
/** * Create the Notifications menu for the BuddyBar. * * @since BuddyPress (1.9.0) */ function bp_notifications_buddybar_menu() { if (!is_user_logged_in()) { return false; } echo '<li id="bp-adminbar-notifications-menu"><a href="' . esc_url(bp_loggedin_user_domain()) . '">'; _e('Notifications', 'buddypress'); if ($notification_count = bp_notifications_get_unread_notification_count(bp_loggedin_user_id())) { ?> <span><?php echo bp_core_number_format($notification_count); ?> </span> <?php } echo '</a>'; echo '<ul>'; if ($notifications = bp_notifications_get_notifications_for_user(bp_loggedin_user_id())) { $counter = 0; for ($i = 0, $count = count($notifications); $i < $count; ++$i) { $alt = 0 == $counter % 2 ? ' class="alt"' : ''; ?> <li<?php echo $alt; ?> ><?php echo $notifications[$i]; ?> </li> <?php $counter++; } } else { ?> <li><a href="<?php echo esc_url(bp_loggedin_user_domain()); ?> "><?php _e('No new notifications.', 'buddypress'); ?> </a></li> <?php } echo '</ul>'; echo '</li>'; }
function bp_core_get_notifications_for_user($user_id, $format = 'simple') { global $bp; $notifications = BP_Core_Notification::get_all_for_user($user_id); // Group notifications by component and component_action and provide totals for ($i = 0, $count = count($notifications); $i < $count; ++$i) { $notification = $notifications[$i]; $grouped_notifications[$notification->component_name][$notification->component_action][] = $notification; } if (empty($grouped_notifications)) { return false; } $renderable = array(); // Calculate a renderable output for each notification type foreach ((array) $grouped_notifications as $component_name => $action_arrays) { if (!$action_arrays) { continue; } foreach ((array) $action_arrays as $component_action_name => $component_action_items) { $action_item_count = count($component_action_items); if ($action_item_count < 1) { continue; } // @deprecated format_notification_function - 1.5 if (isset($bp->{$component_name}->format_notification_function) && function_exists($bp->{$component_name}->format_notification_function)) { $renderable[] = call_user_func($bp->{$component_name}->format_notification_function, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count); } elseif (isset($bp->{$component_name}->notification_callback) && function_exists($bp->{$component_name}->notification_callback)) { if ('object' == $format) { $content = call_user_func($bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count, 'array'); $notification_object = new stdClass(); // Minimal backpat with non-compatible notification // callback functions if (is_string($content)) { $notification_object->content = $content; $notification_object->href = bp_loggedin_user_domain(); } else { $notification_object->content = $content['text']; $notification_object->href = $content['link']; } $notification_object->id = $component_action_items[0]->id; $renderable[] = $notification_object; } else { $content = call_user_func($bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count); $renderable[] = $content; } } } } return isset($renderable) ? $renderable : false; }
/** * Render user avatar menu item * * @param string $item_output * @param array $item * @param integer $depth * @param object $args * @return string */ function kleo_menu_user_avatar($item_output, $item, $depth, $args) { $output = ''; if (is_user_logged_in()) { $url = bp_loggedin_user_domain(); $attr_title = strip_tags($item->attr_title); $output .= '<a title="' . bp_get_loggedin_user_fullname() . '" class="kleo-bp-user-avatar' . ($args->has_children && in_array($depth, array(0, 1)) ? ' js-activated' : '') . '" href="' . $url . '" title="' . $attr_title . '">' . '<img src="' . bp_get_loggedin_user_avatar(array('width' => 25, 'height' => 25, 'html' => false)) . '" class="kleo-rounded" alt="">' . ($item->attr_title != '' ? ' ' . $item->attr_title : ''); $output .= $args->has_children && in_array($depth, array(0, 1)) ? ' <span class="caret"></span></a>' : '</a>'; return $output; } elseif ($args->has_children && in_array($depth, array(0, 1))) { return $item_output; } else { return ''; } }
/** * Catch and process the Requests page. */ function friends_screen_requests() { if (bp_is_action_variable('accept', 0) && is_numeric(bp_action_variable(1))) { // Check the nonce check_admin_referer('friends_accept_friendship'); if (friends_accept_friendship(bp_action_variable(1))) { bp_core_add_message(__('Friendship accepted', 'buddypress')); } else { bp_core_add_message(__('Friendship could not be accepted', 'buddypress'), 'error'); } bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action())); } elseif (bp_is_action_variable('reject', 0) && is_numeric(bp_action_variable(1))) { // Check the nonce check_admin_referer('friends_reject_friendship'); if (friends_reject_friendship(bp_action_variable(1))) { bp_core_add_message(__('Friendship rejected', 'buddypress')); } else { bp_core_add_message(__('Friendship could not be rejected', 'buddypress'), 'error'); } bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action())); } elseif (bp_is_action_variable('cancel', 0) && is_numeric(bp_action_variable(1))) { // Check the nonce check_admin_referer('friends_withdraw_friendship'); if (friends_withdraw_friendship(bp_loggedin_user_id(), bp_action_variable(1))) { bp_core_add_message(__('Friendship request withdrawn', 'buddypress')); } else { bp_core_add_message(__('Friendship request could not be withdrawn', 'buddypress'), 'error'); } bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action())); } /** * Fires before the loading of template for the friends requests page. * * @since BuddyPress (1.0.0) */ do_action('friends_screen_requests'); /** * Filters the template used to display the My Friends page. * * @since BuddyPress (1.0.0) * * @param string $template Path to the friends request template to load. */ bp_core_load_template(apply_filters('friends_template_requests', 'members/single/home')); }
/** * Add a Sites menu to the BuddyBar. * * @since BuddyPress (1.0.0) * * @global object $bp The BuddyPress global settings object. * * @return bool|null Returns false on failure. Otherwise echoes the menu item. */ function bp_adminbar_blogs_menu() { global $bp; if (!is_user_logged_in() || !bp_is_active('blogs')) { return false; } if (!is_multisite()) { return false; } $blogs = wp_cache_get('bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', 'bp'); if (empty($blogs)) { $blogs = bp_blogs_get_blogs_for_user(bp_loggedin_user_id(), true); wp_cache_set('bp_blogs_of_user_' . bp_loggedin_user_id() . '_inc_hidden', $blogs, 'bp'); } $counter = 0; if (is_array($blogs['blogs']) && (int) $blogs['count']) { echo '<li id="bp-adminbar-blogs-menu"><a href="' . trailingslashit(bp_loggedin_user_domain() . bp_get_blogs_slug()) . '">'; _e('My Sites', 'buddypress'); echo '</a>'; echo '<ul>'; foreach ((array) $blogs['blogs'] as $blog) { $alt = 0 == $counter % 2 ? ' class="alt"' : ''; $site_url = esc_attr($blog->siteurl); echo '<li' . $alt . '>'; echo '<a href="' . $site_url . '">' . esc_html($blog->name) . '</a>'; echo '<ul>'; echo '<li class="alt"><a href="' . $site_url . 'wp-admin/">' . __('Dashboard', 'buddypress') . '</a></li>'; echo '<li><a href="' . $site_url . 'wp-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>'; echo '<li class="alt"><a href="' . $site_url . 'wp-admin/edit.php">' . __('Manage Posts', 'buddypress') . '</a></li>'; echo '<li><a href="' . $site_url . 'wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>'; echo '</ul>'; do_action('bp_adminbar_blog_items', $blog); echo '</li>'; $counter++; } $alt = 0 == $counter % 2 ? ' class="alt"' : ''; if (bp_blog_signup_enabled()) { echo '<li' . $alt . '>'; echo '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __('Create a Site!', 'buddypress') . '</a>'; echo '</li>'; } echo '</ul>'; echo '</li>'; } }
function bp_reshare_type_tabs() { ?> <li id="activity-reshares"><a href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/reshares/'; ?> " title="<?php _e('Activity that I have reshared.', 'bp-reshare'); ?> "><?php _e('Reshares', 'bp-reshare'); ?> <strong><?php printf(__('<span>%s</span>', 'bp-reshare'), bp_reshare_get_total_reshare_count_for_user(bp_loggedin_user_id())); ?> </strong></a></li> <?php }
/** * replace_tags function. * * @param mixed $text */ public function replace_tags($text) { if ($this->user) { $text = str_replace(array('%username%', '%userid%', '%firstname%', '%lastname%', '%name%'), array(ucwords($this->user->display_name), $this->user->ID, $this->user->first_name, $this->user->last_name, trim($this->user->first_name . ' ' . $this->user->last_name)), $text); // Buddypress if (function_exists('bp_loggedin_user_domain')) { $text = str_replace(array('%buddypress_profile_url%'), array(bp_loggedin_user_domain()), $text); } // BBpress if (function_exists('bbp_get_user_profile_url')) { $text = str_replace(array('%bbpress_profile_url%'), array(bbp_get_user_profile_url($this->user->ID)), $text); } } $logout_redirect = wp_logout_url(empty($this->instance['logout_redirect_url']) ? $this->current_url('nologout') : $this->instance['logout_redirect_url']); $text = str_replace(array('%admin_url%', '%logout_url%'), array(untrailingslashit(admin_url()), apply_filters('sidebar_login_widget_logout_redirect', $logout_redirect)), $text); $text = do_shortcode($text); return $text; }
function bp_adminbar_account_menu() { global $bp; if ( !$bp->bp_nav || !is_user_logged_in() ) return false; echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">'; echo __( 'My Account', 'buddypress' ) . '</a>'; echo '<ul>'; /* Loop through each navigation item */ $counter = 0; foreach( (array)$bp->bp_nav as $nav_item ) { $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; echo '<li' . $alt . '>'; echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>'; if ( is_array( $bp->bp_options_nav[$nav_item['slug']] ) ) { echo '<ul>'; $sub_counter = 0; foreach( (array)$bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) { $link = str_replace( $bp->displayed_user->domain, $bp->loggedin_user->domain, $subnav_item['link'] ); $name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] ); $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : ''; echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $link . '">' . $name . '</a></li>'; $sub_counter++; } echo '</ul>'; } echo '</li>'; $counter++; } $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; echo '<li' . $alt . '><a id="bp-admin-logout" class="logout" href="' . wp_logout_url( site_url() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; echo '</ul>'; echo '</li>'; }
function save() { global $wpdb, $bp; $this->id = apply_filters_ref_array('bp_activity_id_before_save', array($this->id, &$this)); $this->item_id = apply_filters_ref_array('bp_activity_item_id_before_save', array($this->item_id, &$this)); $this->secondary_item_id = apply_filters_ref_array('bp_activity_secondary_item_id_before_save', array($this->secondary_item_id, &$this)); $this->user_id = apply_filters_ref_array('bp_activity_user_id_before_save', array($this->user_id, &$this)); $this->primary_link = apply_filters_ref_array('bp_activity_primary_link_before_save', array($this->primary_link, &$this)); $this->component = apply_filters_ref_array('bp_activity_component_before_save', array($this->component, &$this)); $this->type = apply_filters_ref_array('bp_activity_type_before_save', array($this->type, &$this)); $this->action = apply_filters_ref_array('bp_activity_action_before_save', array($this->action, &$this)); $this->content = apply_filters_ref_array('bp_activity_content_before_save', array($this->content, &$this)); $this->date_recorded = apply_filters_ref_array('bp_activity_date_recorded_before_save', array($this->date_recorded, &$this)); $this->hide_sitewide = apply_filters_ref_array('bp_activity_hide_sitewide_before_save', array($this->hide_sitewide, &$this)); $this->mptt_left = apply_filters_ref_array('bp_activity_mptt_left_before_save', array($this->mptt_left, &$this)); $this->mptt_right = apply_filters_ref_array('bp_activity_mptt_right_before_save', array($this->mptt_right, &$this)); $this->is_spam = apply_filters_ref_array('bp_activity_is_spam_before_save', array($this->is_spam, &$this)); // Use this, not the filters above do_action_ref_array('bp_activity_before_save', array(&$this)); if (!$this->component || !$this->type) { return false; } if (!$this->primary_link) { $this->primary_link = bp_loggedin_user_domain(); } // If we have an existing ID, update the activity item, otherwise insert it. if ($this->id) { $q = $wpdb->prepare("UPDATE {$bp->activity->table_name} SET user_id = %d, component = %s, type = %s, action = %s, content = %s, primary_link = %s, date_recorded = %s, item_id = %d, secondary_item_id = %d, hide_sitewide = %d, is_spam = %d WHERE id = %d", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam, $this->id); } else { $q = $wpdb->prepare("INSERT INTO {$bp->activity->table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %d, %d, %d, %d )", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam); } if (false === $wpdb->query($q)) { return false; } // If this is a new activity item, set the $id property if (empty($this->id)) { $this->id = $wpdb->insert_id; // If an existing activity item, prevent any changes to the content generating new @mention notifications. } else { add_filter('bp_activity_at_name_do_notifications', '__return_false'); } do_action_ref_array('bp_activity_after_save', array(&$this)); return true; }
function setup_admin_bar($wp_admin_nav = array()) { global $bp; $directWorkflow = isDirectWorkflow(); if (is_user_logged_in()) { if ($directWorkflow) { $postCount = custom_get_user_posts_count(array("publish", "draft")); } else { $postCount = custom_get_user_posts_count(array("publish", "pending", "draft")); } $user_domain = bp_loggedin_user_domain(); $wp_admin_nav[] = array('parent' => 'my-account-buddypress', 'id' => 'my-account-social-articles', 'title' => __('Social Articles', 'social-articles'), 'href' => trailingslashit($user_domain . 'articles')); $wp_admin_nav[] = array('parent' => 'my-account-social-articles', 'title' => sprintf(__('My Articles <span class="count">%d</span>', 'social-articles'), $postCount), 'href' => trailingslashit($user_domain . 'articles')); $wp_admin_nav[] = array('parent' => 'my-account-social-articles', 'title' => sprintf(__('New Article', 'social-articles')), 'href' => trailingslashit($user_domain . 'articles/new')); } if ($this->check_visibility()) { parent::setup_admin_bar($wp_admin_nav); } }