public function test_should_accept_component_override()
 {
     $this->go_to(bp_get_activity_directory_permalink());
     $found = bp_core_get_directory_page_id('members');
     $pages = bp_core_get_directory_page_ids();
     $this->assertSame($pages['members'], $found);
 }
function bpg_init()
{
    require_once dirname(__FILE__) . '/includes/functions.php';
    if (defined('BP_VERSION') && defined('WPGLOBUS_VERSION')) {
        $apply_filters = false;
        //TOFIX
        // Always on frontend
        if (!is_admin() || $apply_filters) {
            $optionLanguages = wpgl_get_option_language();
            $defaultLanguage = wpgl_get_default_language($optionLanguages);
            $currentLanguage = wpgl_get_current_language($optionLanguages);
            if ($currentLanguage != $defaultLanguage) {
                apply_filters('bp_get_groups_directory_permalink', trailingslashit(bp_get_groups_directory_permalink() . $currentLanguage . '/'));
                apply_filters('bp_get_activity_directory_permalink', trailingslashit(bp_get_activity_directory_permalink() . $currentLanguage . '/'));
                apply_filters('bp_get_blogs_directory_permalink', trailingslashit(bp_get_blogs_directory_permalink() . $currentLanguage . '/'));
                apply_filters('bp_get_forum_directory_permalink', trailingslashit(bp_get_forum_directory_permalink() . $currentLanguage . '/'));
                apply_filters('bp_get_members_directory_permalink', trailingslashit(bp_get_members_directory_permalink() . $currentLanguage . '/'));
            }
        }
    } else {
        if (is_admin()) {
            add_action('admin_notices', 'bpgl_admin_notice_required_plugins');
        }
    }
}
function rtmedia_modify_activity_upload_url($params)
{
    // return original params if BuddyPress multilingual plugin is not active
    include_once ABSPATH . 'wp-admin/includes/plugin.php';
    if (function_exists('is_plugin_active') && is_plugin_active('buddypress-multilingual/sitepress-bp.php')) {
        if (class_exists('BuddyPress')) {
            // change upload url only if it's activity page and if it's group page than it shouldn't group media page
            if (bp_is_activity_component() || bp_is_groups_component() && !is_rtmedia_page()) {
                if (function_exists('bp_get_activity_directory_permalink')) {
                    $params['url'] = bp_get_activity_directory_permalink() . 'upload/';
                }
            }
        }
    }
    return $params;
}
 /**
  * Action handler when a follow activity button is clicked.
  */
 public function action_listener()
 {
     if (!bp_is_activity_component()) {
         return;
     }
     if (!bp_is_current_action('follow') && !bp_is_current_action('unfollow')) {
         return false;
     }
     if (empty($activity_id) && bp_action_variable(0)) {
         $activity_id = (int) bp_action_variable(0);
     }
     // Not viewing a specific activity item.
     if (empty($activity_id)) {
         return;
     }
     $action = bp_is_current_action('follow') ? 'follow' : 'unfollow';
     // Check the nonce.
     check_admin_referer("bp_follow_activity_{$action}");
     $save = bp_is_current_action('follow') ? 'bp_follow_start_following' : 'bp_follow_stop_following';
     $follow_type = bp_follow_activity_get_type($activity_id);
     // Failure on action
     if (!$save(array('leader_id' => $activity_id, 'follower_id' => bp_loggedin_user_id(), 'follow_type' => $follow_type))) {
         $message_type = 'error';
         if ('follow' === $action) {
             $message = __('You are already following that item.', 'bp-follow');
         } else {
             $message = __('You were not following that item.', 'bp-follow');
         }
         // Success!
     } else {
         $message_type = 'success';
         if ('follow' === $action) {
             $message = __('You are now following that item.', 'bp-follow');
         } else {
             $message = __('You are no longer following that item.', 'bp-follow');
         }
     }
     /**
      * Dynamic filter for the message displayed after the follow button is clicked.
      *
      * Default filter name is 'bp_follow_activity_message_activity'.
      *
      * Handy for plugin devs.
      *
      * @since 1.3.0
      *
      * @param string $message      Message that gets displayed after a follow action.
      * @param string $action       Either 'follow' or 'unfollow'.
      * @param int    $activity_id  Activity ID.
      * @param string $message_type Either 'success' or 'error'.
      */
     $message = apply_filters("bp_follow_activity_message_{$follow_type}", $message, $action, $activity_id, $message_type);
     bp_core_add_message($message, $message_type);
     // Redirect
     $redirect = wp_get_referer() ? wp_get_referer() : bp_get_activity_directory_permalink();
     bp_core_redirect($redirect);
     die;
 }
/**
 * Load the sitewide activity feed.
 *
 * @since 1.0.0
 *
 * @uses bp_is_activity_component()
 * @uses bp_is_current_action()
 * @uses bp_is_user()
 * @uses status_header()
 *
 * @return bool False on failure.
 */
function bp_activity_action_sitewide_feed()
{
    $bp = buddypress();
    if (!bp_is_activity_component() || !bp_is_current_action('feed') || bp_is_user() || !empty($bp->groups->current_group)) {
        return false;
    }
    // Setup the feed.
    buddypress()->activity->feed = new BP_Activity_Feed(array('id' => 'sitewide', 'title' => sprintf(__('%s | Site-Wide Activity', 'buddypress'), bp_get_site_name()), 'link' => bp_get_activity_directory_permalink(), 'description' => __('Activity feed for the entire site.', 'buddypress'), 'activity_args' => 'display_comments=threaded'));
}
Esempio n. 6
0
 function test_activity_directory()
 {
     $this->go_to(bp_get_activity_directory_permalink());
     $this->assertEquals(bp_get_activity_root_slug(), bp_current_component());
 }
 function x_buddypress_navbar_menu($items, $args)
 {
     if (X_BUDDYPRESS_IS_ACTIVE && x_get_option('x_buddypress_header_menu_enable', '') == '1') {
         $top_level_link = is_user_logged_in() ? bp_loggedin_user_domain() : bp_get_activity_directory_permalink();
         $submenu_items = '';
         if (bp_is_active('activity')) {
             $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_activity_directory_permalink() . '" class="cf"><i class="x-icon-thumbs-up" data-x-icon="&#xf164;"></i> <span>' . x_get_option('x_buddypress_activity_title', __('Activity', '__x__')) . '</span></a></li>';
         }
         if (bp_is_active('groups')) {
             $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_groups_directory_permalink() . '" class="cf"><i class="x-icon-sitemap" data-x-icon="&#xf0e8;"></i> <span>' . x_get_option('x_buddypress_groups_title', __('Groups', '__x__')) . '</span></a></li>';
         }
         if (is_multisite() && bp_is_active('blogs')) {
             $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_blogs_directory_permalink() . '" class="cf"><i class="x-icon-file" data-x-icon="&#xf15b;"></i> <span>' . x_get_option('x_buddypress_blogs_title', __('Blogs', '__x__')) . '</span></a></li>';
         }
         $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_members_directory_permalink() . '" class="cf"><i class="x-icon-male" data-x-icon="&#xf183;"></i> <span>' . x_get_option('x_buddypress_members_title', __('Members', '__x__')) . '</span></a></li>';
         if (!is_user_logged_in()) {
             if (bp_get_signup_allowed()) {
                 $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_signup_page() . '" class="cf"><i class="x-icon-pencil" data-x-icon="&#xf040;"></i> <span>' . x_get_option('x_buddypress_register_title', __('Create an Account', '__x__')) . '</span></a></li>';
                 $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_get_activation_page() . '" class="cf"><i class="x-icon-key" data-x-icon="&#xf084;"></i> <span>' . x_get_option('x_buddypress_activate_title', __('Activate Your Account', '__x__')) . '</span></a></li>';
             }
             $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . wp_login_url() . '" class="cf"><i class="x-icon-sign-in" data-x-icon="&#xf090;"></i> <span>' . __('Log in', '__x__') . '</span></a></li>';
         } else {
             $submenu_items .= '<li class="menu-item menu-item-buddypress-navigation"><a href="' . bp_loggedin_user_domain() . '" class="cf"><i class="x-icon-cog" data-x-icon="&#xf013;"></i> <span>' . __('Profile', '__x__') . '</span></a></li>';
         }
         if ($args->theme_location == 'primary') {
             $items .= '<li class="menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-buddypress">' . '<a href="' . $top_level_link . '" class="x-btn-navbar-buddypress">' . '<span><i class="x-icon-user" data-x-icon="&#xf007;"></i><span class="x-hidden-desktop"> ' . __('Social', '__x__') . '</span></span>' . '</a>' . '<ul class="sub-menu">' . $submenu_items . '</ul>' . '</li>';
         }
     }
     return $items;
 }
Esempio n. 8
0
/**
 * Output member directory permalink
 *
 * @since 1.5.0
 *
 * @uses bp_get_activity_directory_permalink()
 */
function bp_activity_directory_permalink()
{
    echo bp_get_activity_directory_permalink();
}
/**
 * Return the public message link for the displayed user.
 *
 * @since BuddyPress (1.2.0)
 *
 * @uses is_user_logged_in()
 * @uses bp_is_my_profile()
 * @uses bp_is_user()
 * @uses wp_nonce_url()
 * @uses bp_get_activity_directory_permalink()
 * @uses apply_filters() To call the 'bp_get_send_public_message_link' hook
 *
 * @return string The public message link for the displayed user.
 */
function bp_get_send_public_message_link()
{
    // No link if not logged in, not looking at someone else's profile
    if (!is_user_logged_in() || !bp_is_user() || bp_is_my_profile()) {
        $retval = '';
    } else {
        $args = array('r' => bp_get_displayed_user_mentionname());
        $url = add_query_arg($args, bp_get_activity_directory_permalink());
        $retval = wp_nonce_url($url);
    }
    /**
     * Filters the public message link for the displayed user.
     *
     * @since BuddyPress (1.2.0)
     *
     * @param string $retval The URL for the public message link.
     */
    return apply_filters('bp_get_send_public_message_link', $retval);
}
Esempio n. 10
0
/**
 * Return the public message link for the displayed user.
 *
 * @since BuddyPress (1.2)
 *
 * @uses is_user_logged_in()
 * @uses bp_is_my_profile()
 * @uses bp_is_user()
 * @uses wp_nonce_url()
 * @uses bp_get_activity_directory_permalink()
 * @uses apply_filters() To call the 'bp_get_send_public_message_link' hook
 *
 * @return string The public message link for the displayed user.
 */
function bp_get_send_public_message_link()
{
    // No link if not logged in, not looking at someone else's profile
    if (!is_user_logged_in() || !bp_is_user() || bp_is_my_profile()) {
        $retval = '';
    } else {
        $args = array('r' => bp_get_displayed_user_mentionname());
        $url = add_query_arg($args, bp_get_activity_directory_permalink());
        $retval = wp_nonce_url($url);
    }
    return apply_filters('bp_get_send_public_message_link', $retval);
}
/**
 * Return the public message link for the displayed user.
 *
 * @since BuddyPress (1.2)
 *
 * @uses is_user_logged_in()
 * @uses bp_is_my_profile()
 * @uses bp_is_user()
 * @uses wp_nonce_url()
 * @uses bp_get_activity_directory_permalink()
 * @uses apply_filters() To call the 'bp_get_send_public_message_link' hook
 *
 * @return string The public message link for the displayed user.
 */
function bp_get_send_public_message_link()
{
    if (!is_user_logged_in() || !bp_is_user() || bp_is_my_profile()) {
        return false;
    }
    return apply_filters('bp_get_send_public_message_link', wp_nonce_url(bp_get_activity_directory_permalink() . '?r=' . bp_get_displayed_user_mentionname()));
}
/**
 * Template tag to return the activity hashtag permalink.
 *
 * @param str $hashtag The hashtag to append to the hashtag permalink.
 * @return str The full activity hashtag permalink
 */
function bp_get_activity_hashtags_permalink($hashtag = false)
{
    $hashtag = !empty($hashtag) && is_string($hashtag) ? trailingslashit($hashtag) : '';
    return bp_get_activity_directory_permalink() . constant("BP_ACTIVITY_HASHTAGS_SLUG") . "/" . $hashtag;
}
/**
 * Output a 'Follow' activity button.
 *
 * @param $args {
 *      Array of arguments.  Also see other args via {@link BP_Button} class.
 *      @type int  $leader_id           Activity ID to follow.
 *      @type int  $follower_id         User ID initiating the follow request.
 *      @type bool $show_follower_count Should we show the follower count for this item? Default: false.
 * }
 */
function bp_follow_activity_button($args = array())
{
    global $activities_template;
    $r = bp_parse_args($args, array('leader_id' => !empty($activities_template->in_the_loop) ? bp_get_activity_id() : 0, 'follower_id' => bp_loggedin_user_id(), 'link_text' => '', 'link_title' => '', 'wrapper_class' => '', 'link_class' => 'button bp-primary-action', 'wrapper' => false, 'show_follower_count' => false), 'follow_activity_button');
    if (!$r['leader_id'] || !$r['follower_id']) {
        return;
    }
    $follow_type = bp_follow_activity_get_type($r['leader_id']);
    // if we're checking during an activity loop, then follow status is already
    // queried via bulk_inject_follow_activity_status()
    if (!empty($activities_template->in_the_loop) && $r['follower_id'] == bp_loggedin_user_id() && $r['leader_id'] == bp_get_activity_id() && 'activity' === $follow_type) {
        $is_following = $activities_template->activity->is_following;
        // else we manually query the follow status
    } else {
        $is_following = bp_follow_is_following(array('leader_id' => $r['leader_id'], 'follower_id' => $r['follower_id'], 'follow_type' => $follow_type));
    }
    // setup some variables
    if ($is_following) {
        $id = 'following';
        $action = 'unfollow';
        /* @todo Maybe bring back the count for the 'unfollow' button?
        		$count  = bp_follow_get_the_followers_count( array(
        			'object_id'   => $r['leader_id'],
        			'follow_type' => $follow_type
        		) );
        		*/
        $count = 0;
        if (empty($count)) {
            $link_text = _x('Unfollow', 'Follow activity button', 'bp-follow');
        } else {
            $link_text = sprintf(_x('Unfollow %s', 'Follow activity button', 'bp-follow'), '<span>' . $count . '</span>');
        }
        if (empty($r['link_text'])) {
            $r['link_text'] = $link_text;
        }
    } else {
        $id = 'not-following';
        $action = 'follow';
        $count = 0;
        if (true === $r['show_follower_count']) {
            $count = bp_follow_get_the_followers_count(array('object_id' => $r['leader_id'], 'follow_type' => $follow_type));
        }
        if (empty($count)) {
            $link_text = _x('Follow', 'Follow activity button', 'bp-follow');
        } else {
            $link_text = sprintf(_x('Follow %s', 'Follow activity button', 'bp-follow'), '<span>' . $count . '</span>');
        }
        if (empty($r['link_text'])) {
            $r['link_text'] = $link_text;
        }
    }
    $wrapper_class = 'follow-button ' . $id;
    if (!empty($r['wrapper_class'])) {
        $wrapper_class .= ' ' . esc_attr($r['wrapper_class']);
    }
    $link_class = $action;
    if (!empty($r['link_class'])) {
        $link_class .= ' ' . esc_attr($r['link_class']);
    }
    // setup the button arguments
    $button = array('id' => $id, 'component' => 'follow', 'must_be_logged_in' => true, 'block_self' => false, 'wrapper_class' => $wrapper_class, 'wrapper_id' => 'follow-button-' . (int) $r['leader_id'], 'link_href' => wp_nonce_url(trailingslashit(bp_get_activity_directory_permalink() . $action . '/' . esc_attr($r['leader_id'])), "bp_follow_activity_{$action}"), 'link_text' => $r['link_text'], 'link_title' => esc_attr($r['link_title']), 'link_id' => $action . '-' . (int) $r['leader_id'], 'link_class' => $link_class, 'wrapper' => !empty($r['wrapper']) ? esc_attr($r['wrapper']) : false);
    // Filter and output the HTML button
    bp_button(apply_filters('bp_follow_activity_get_follow_button', $button, $r, $is_following));
}
/**
 * Returns the public message link for displayed user
 *
 * @since BuddyPress (1.2)
 *
 * @global object $bp BuddyPress global settings
 * @uses bp_is_my_profile()
 * @uses is_user_logged_in()
 * @uses wp_nonce_url()
 * @uses bp_loggedin_user_domain()
 * @uses bp_get_activity_slug()
 * @uses bp_core_get_username()
 * @uses apply_filters() To call the 'bp_get_send_public_message_link' hook
 *
 * @return string The public message link for displayed user
 */
function bp_get_send_public_message_link()
{
    global $bp;
    if (bp_is_my_profile() || !is_user_logged_in()) {
        return false;
    }
    return apply_filters('bp_get_send_public_message_link', wp_nonce_url(bp_get_activity_directory_permalink() . '?r=' . bp_core_get_username(bp_displayed_user_id(), bp_get_displayed_user_username(), $bp->displayed_user->userdata->user_login)));
}