/**
 * Require the plugin's files.
 *
 * @since 1.0.0
 */
function crowdmentions_init()
{
    if (!bp_is_active('activity') || !bp_is_active('notifications')) {
        return;
    }
    if (!bp_activity_do_mentions()) {
        return;
    }
    require_once dirname(__FILE__) . '/inc/functions.php';
    require_once dirname(__FILE__) . '/inc/actions.php';
    require_once dirname(__FILE__) . '/inc/filters.php';
}
/**
 * Should BuddyPress load the mentions scripts and related assets, including results to prime the
 * mentions suggestions?
 *
 * @since 2.1.0
 *
 * @return bool True if mentions scripts should be loaded.
 */
function bp_activity_maybe_load_mentions_scripts()
{
    $mentions_enabled = bp_activity_do_mentions() && bp_is_user_active();
    $load_mentions = $mentions_enabled && (bp_is_activity_component() || is_admin());
    /**
     * Filters whether or not BuddyPress should load mentions scripts and assets.
     *
     * @since 2.1.0
     *
     * @param bool $load_mentions    True to load mentions assets, false otherwise.
     * @param bool $mentions_enabled True if mentions are enabled.
     */
    return (bool) apply_filters('bp_activity_maybe_load_mentions_scripts', $load_mentions, $mentions_enabled);
}
Example #3
0
        echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/favorites/';
        ?>
" title="<?php 
        _e("The activity I've marked as a favorite.", 'buddypress');
        ?>
"><?php 
        printf(__('My Favorites <span>%s</span>', 'buddypress'), bp_get_total_favorite_count_for_user(bp_loggedin_user_id()));
        ?>
</a></li>

				<?php 
    }
    ?>

				<?php 
    if (bp_activity_do_mentions()) {
        ?>

					<?php 
        do_action('bp_before_activity_type_tab_mentions');
        ?>

					<li id="activity-mentions"><a href="<?php 
        echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/';
        ?>
" title="<?php 
        _e('Activity that I have been mentioned in.', 'buddypress');
        ?>
"><?php 
        _e('Mentions', 'buddypress');
        if (bp_get_total_mention_count_for_user(bp_loggedin_user_id())) {
Example #4
0
/**
 * Should BuddyPress load the mentions scripts and related assets, including results to prime the
 * mentions suggestions?
 *
 * @return bool True if mentions scripts should be loaded.
 * @since BuddyPress (2.1.0)
 */
function bp_activity_maybe_load_mentions_scripts()
{
    $retval = bp_activity_do_mentions() && bp_is_user_active() && (bp_is_activity_component() || bp_is_blog_page() && is_singular() && comments_open() || is_admin());
    return (bool) apply_filters('bp_activity_maybe_load_mentions_scripts', $retval);
}
 /**
  * Set up the component entries in the WordPress Admin Bar.
  *
  * @since 1.5.0
  *
  * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
  *      parameter array.
  * @uses is_user_logged_in()
  * @uses trailingslashit()
  * @uses bp_get_total_mention_count_for_user()
  * @uses bp_loggedin_user_id()
  * @uses bp_is_active()
  * @uses bp_get_friends_slug()
  * @uses bp_get_groups_slug()
  *
  * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
  *                            description.
  */
 public function setup_admin_bar($wp_admin_nav = array())
 {
     // Menus for logged in user.
     if (is_user_logged_in()) {
         // Setup the logged in user variables.
         $activity_link = trailingslashit(bp_loggedin_user_domain() . bp_get_activity_slug());
         // Unread message count.
         if (bp_activity_do_mentions()) {
             $count = bp_get_total_mention_count_for_user(bp_loggedin_user_id());
             if (!empty($count)) {
                 $title = sprintf(_x('Mentions <span class="count">%s</span>', 'Toolbar Mention logged in user', 'buddypress'), bp_core_number_format($count));
             } else {
                 $title = _x('Mentions', 'Toolbar Mention logged in user', 'buddypress');
             }
         }
         // Add the "Activity" sub menu.
         $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => _x('Activity', 'My Account Activity sub nav', 'buddypress'), 'href' => $activity_link);
         // Personal.
         $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-personal', 'title' => _x('Personal', 'My Account Activity sub nav', 'buddypress'), 'href' => $activity_link);
         // Mentions.
         if (bp_activity_do_mentions()) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-mentions', 'title' => $title, 'href' => trailingslashit($activity_link . 'mentions'));
         }
         // Favorite activity items.
         if (bp_activity_can_favorite()) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-favorites', 'title' => _x('Favorites', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . 'favorites'));
         }
         // Friends?
         if (bp_is_active('friends')) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-friends', 'title' => _x('Friends', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_friends_slug()));
         }
         // Groups?
         if (bp_is_active('groups')) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-groups', 'title' => _x('Groups', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_groups_slug()));
         }
     }
     parent::setup_admin_bar($wp_admin_nav);
 }
 /**
  * Set up the component entries in the WordPress Admin Bar.
  *
  * @since BuddyPress (1.5)
  *
  * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
  *      parameter array.
  * @uses is_user_logged_in()
  * @uses trailingslashit()
  * @uses bp_get_total_mention_count_for_user()
  * @uses bp_loggedin_user_id()
  * @uses bp_is_active()
  * @uses bp_get_friends_slug()
  * @uses bp_get_groups_slug()
  *
  * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
  *                            description.
  */
 public function setup_admin_bar($wp_admin_nav = array())
 {
     $bp = buddypress();
     // Menus for logged in user
     if (is_user_logged_in()) {
         // Setup the logged in user variables
         $user_domain = bp_loggedin_user_domain();
         $activity_link = trailingslashit($user_domain . $this->slug);
         // Unread message count
         if (bp_activity_do_mentions()) {
             $count = bp_get_total_mention_count_for_user(bp_loggedin_user_id());
             if (!empty($count)) {
                 $title = sprintf(__('Mentions <span class="count">%s</span>', 'buddypress'), number_format_i18n($count));
             } else {
                 $title = __('Mentions', 'buddypress');
             }
         }
         // Add the "Activity" sub menu
         $wp_admin_nav[] = array('parent' => $bp->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => __('Activity', 'buddypress'), 'href' => trailingslashit($activity_link));
         // Personal
         $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-personal', 'title' => __('Personal', 'buddypress'), 'href' => trailingslashit($activity_link));
         // Mentions
         if (bp_activity_do_mentions()) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-mentions', 'title' => $title, 'href' => trailingslashit($activity_link . 'mentions'));
         }
         // Favorites
         $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-favorites', 'title' => __('Favorites', 'buddypress'), 'href' => trailingslashit($activity_link . 'favorites'));
         // Friends?
         if (bp_is_active('friends')) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-friends', 'title' => __('Friends', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_friends_slug()));
         }
         // Groups?
         if (bp_is_active('groups')) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-groups', 'title' => __('Groups', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_groups_slug()));
         }
     }
     parent::setup_admin_bar($wp_admin_nav);
 }
/**
 * Set up activity arguments for use with the 'favorites' scope.
 *
 * @since 2.2.0
 *
 * @param array $retval Empty array by default.
 * @param array $filter Current activity arguments.
 * @return array $retval
 */
function bp_activity_filter_mentions_scope($retval = array(), $filter = array())
{
    // Are mentions disabled?
    if (!bp_activity_do_mentions()) {
        return $retval;
    }
    // Determine the user_id.
    if (!empty($filter['user_id'])) {
        $user_id = $filter['user_id'];
    } else {
        $user_id = bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id();
    }
    // Should we show all items regardless of sitewide visibility?
    $show_hidden = array();
    if (!empty($user_id) && $user_id !== bp_loggedin_user_id()) {
        $show_hidden = array('column' => 'hide_sitewide', 'value' => 0);
    }
    $retval = array('relation' => 'AND', array('column' => 'content', 'compare' => 'LIKE', 'value' => '@' . bp_activity_get_user_mentionname($user_id) . '<'), $show_hidden, 'override' => array('search_terms' => false, 'display_comments' => 'stream', 'filter' => array('user_id' => 0), 'show_hidden' => true));
    return $retval;
}
 /**
  * Hooks into required actions and filters to set up the template pack
  *
  * @since BuddyPress Templates (1.0)
  */
 protected function setup_actions()
 {
     // Template Output
     add_filter('bp_get_activity_action_pre_meta', array($this, 'secondary_avatars'), 10, 2);
     add_action('bp_enqueue_scripts', array($this, 'enqueue_styles'));
     // Enqueue theme CSS
     add_action('bp_enqueue_scripts', array($this, 'enqueue_scripts'));
     // Enqueue theme JS
     add_action('widgets_init', array($this, 'widgets_init'));
     // Widgets
     add_filter('body_class', array($this, 'add_nojs_body_class'), 20, 1);
     add_action('bp_head', array($this, 'head_scripts'));
     // Output some extra JS in the <head>
     // Run an action for third-party plugins to affect the template pack
     do_action_ref_array('bp_theme_compat_actions', array(&$this));
     /** Buttons ***********************************************************/
     if (!is_admin() || defined('DOING_AJAX') && DOING_AJAX) {
         // Register buttons for the relevant component templates
         // Friends button
         if (bp_is_active('friends')) {
             add_action('bp_member_header_actions', 'bp_add_friend_button', 5);
         }
         // Activity button
         if (bp_is_active('activity') && bp_activity_do_mentions()) {
             add_action('bp_member_header_actions', 'bp_send_public_message_button', 20);
         }
         // Messages button
         if (bp_is_active('messages')) {
             add_action('bp_member_header_actions', 'bp_send_private_message_button', 20);
         }
         // Group buttons
         if (bp_is_active('groups')) {
             add_action('bp_before_directory_groups', 'bp_group_create_button');
             add_action('bp_group_header_actions', 'bp_group_join_button', 5);
             add_action('bp_group_header_actions', 'bp_group_new_topic_button', 20);
             add_action('bp_directory_groups_actions', 'bp_group_join_button');
         }
         // Blog button
         if (bp_is_active('blogs')) {
             add_action('bp_before_directory_blogs_content', 'bp_blog_create_button');
             add_action('bp_directory_blogs_actions', 'bp_blogs_visit_blog_button');
         }
         // Specific Script to include in JS dependencies
         add_filter('bp_core_get_js_dependencies', array($this, 'js_dependencies'), 10, 1);
     }
     /** Notices ***********************************************************/
     // Only hook the 'sitewide_notices' overlay if the Sitewide
     // Notices widget is not in use (to avoid duplicate content).
     if (bp_is_active('messages') && !is_active_widget(false, false, 'bp_messages_sitewide_notices_widget', true)) {
         add_action('bp_after_member_header', array($this, 'sitewide_notices'), 9999);
         // If uesr is admin add a message to the message compose screen to inform about the widget
         if (current_user_can('manage_options')) {
             add_action('bp_before_messages_compose_content', array($this, 'notices_admin_message'));
         }
     }
     /** Ajax ************************************************************* */
     $actions = array('blogs_filter' => 'bp_template_pack_object_template_loader', 'forums_filter' => 'bp_template_pack_object_template_loader', 'groups_filter' => 'bp_template_pack_object_template_loader', 'members_filter' => 'bp_template_pack_object_template_loader', 'messages_filter' => 'bp_template_pack_messages_template_loader', 'invite_filter' => 'bp_template_pack_invite_template_loader', 'requests_filter' => 'bp_template_pack_requests_template_loader', 'accept_friendship' => 'bp_template_pack_ajax_accept_friendship', 'addremove_friend' => 'bp_template_pack_ajax_addremove_friend', 'reject_friendship' => 'bp_template_pack_ajax_reject_friendship', 'activity_get_older_updates' => 'bp_template_pack_activity_template_loader', 'activity_mark_fav' => 'bp_template_pack_mark_activity_favorite', 'activity_mark_unfav' => 'bp_template_pack_unmark_activity_favorite', 'activity_widget_filter' => 'bp_template_pack_activity_template_loader', 'delete_activity' => 'bp_template_pack_delete_activity', 'delete_activity_comment' => 'bp_template_pack_delete_activity_comment', 'get_single_activity_content' => 'bp_template_pack_get_single_activity_content', 'new_activity_comment' => 'bp_template_pack_new_activity_comment', 'post_update' => 'bp_template_pack_post_update', 'bp_spam_activity' => 'bp_template_pack_spam_activity', 'bp_spam_activity_comment' => 'bp_template_pack_spam_activity', 'groups_invite_user' => 'bp_template_pack_ajax_invite_user', 'joinleave_group' => 'bp_template_pack_ajax_joinleave_group', 'messages_autocomplete_results' => 'bp_template_pack_ajax_messages_autocomplete_results', 'messages_close_notice' => 'bp_template_pack_ajax_close_notice', 'messages_delete' => 'bp_template_pack_ajax_messages_delete', 'messages_markread' => 'bp_template_pack_ajax_message_markread', 'messages_markunread' => 'bp_template_pack_ajax_message_markunread', 'messages_send_reply' => 'bp_template_pack_ajax_messages_send_reply');
     /**
      * Register all of these AJAX handlers
      *
      * The "wp_ajax_" action is used for logged in users, and "wp_ajax_nopriv_"
      * executes for users that aren't logged in. This is for backpat with BP <1.6.
      */
     foreach ($actions as $name => $function) {
         add_action('wp_ajax_' . $name, $function);
         add_action('wp_ajax_nopriv_' . $name, $function);
     }
     add_filter('bp_ajax_querystring', 'bp_template_pack_ajax_querystring', 10, 2);
 }
 /**
  * Setup the theme hooks
  *
  * @since BuddyPress (1.7)
  * @access private
  *
  * @uses add_filter() To add various filters
  * @uses add_action() To add various actions
  */
 protected function setup_actions()
 {
     // Template Output
     add_filter('bp_get_activity_action_pre_meta', array($this, 'secondary_avatars'), 10, 2);
     // Filter BuddyPress template hierarchy and look for page templates
     add_filter('bp_get_buddypress_template', array($this, 'theme_compat_page_templates'), 10, 1);
     /** Scripts ***********************************************************/
     add_action('bp_enqueue_scripts', array($this, 'enqueue_styles'));
     // Enqueue theme CSS
     add_action('bp_enqueue_scripts', array($this, 'enqueue_scripts'));
     // Enqueue theme JS
     add_filter('bp_enqueue_scripts', array($this, 'localize_scripts'));
     // Enqueue theme script localization
     add_action('bp_head', array($this, 'head_scripts'));
     // Output some extra JS in the <head>
     /** Body no-js Class **************************************************/
     add_filter('body_class', array($this, 'add_nojs_body_class'), 20, 1);
     /** Buttons ***********************************************************/
     if (!is_admin() || defined('DOING_AJAX') && DOING_AJAX) {
         // Register buttons for the relevant component templates
         // Friends button
         if (bp_is_active('friends')) {
             add_action('bp_member_header_actions', 'bp_add_friend_button', 5);
         }
         // Activity button
         if (bp_is_active('activity') && bp_activity_do_mentions()) {
             add_action('bp_member_header_actions', 'bp_send_public_message_button', 20);
         }
         // Messages button
         if (bp_is_active('messages')) {
             add_action('bp_member_header_actions', 'bp_send_private_message_button', 20);
         }
         // Group buttons
         if (bp_is_active('groups')) {
             add_action('bp_group_header_actions', 'bp_group_join_button', 5);
             add_action('bp_group_header_actions', 'bp_group_new_topic_button', 20);
             add_action('bp_directory_groups_actions', 'bp_group_join_button');
             add_action('bp_groups_directory_group_filter', 'bp_legacy_theme_group_create_nav', 999);
         }
         // Blog button
         if (bp_is_active('blogs')) {
             add_action('bp_directory_blogs_actions', 'bp_blogs_visit_blog_button');
             add_action('bp_blogs_directory_blog_types', 'bp_legacy_theme_blog_create_nav', 999);
         }
     }
     /** Notices ***********************************************************/
     // Only hook the 'sitewide_notices' overlay if the Sitewide
     // Notices widget is not in use (to avoid duplicate content).
     if (bp_is_active('messages') && !is_active_widget(false, false, 'bp_messages_sitewide_notices_widget', true)) {
         add_action('wp_footer', array($this, 'sitewide_notices'), 9999);
     }
     /** Ajax **************************************************************/
     $actions = array('blogs_filter' => 'bp_legacy_theme_object_template_loader', 'forums_filter' => 'bp_legacy_theme_object_template_loader', 'groups_filter' => 'bp_legacy_theme_object_template_loader', 'members_filter' => 'bp_legacy_theme_object_template_loader', 'messages_filter' => 'bp_legacy_theme_messages_template_loader', 'invite_filter' => 'bp_legacy_theme_invite_template_loader', 'requests_filter' => 'bp_legacy_theme_requests_template_loader', 'accept_friendship' => 'bp_legacy_theme_ajax_accept_friendship', 'addremove_friend' => 'bp_legacy_theme_ajax_addremove_friend', 'reject_friendship' => 'bp_legacy_theme_ajax_reject_friendship', 'activity_get_older_updates' => 'bp_legacy_theme_activity_template_loader', 'activity_mark_fav' => 'bp_legacy_theme_mark_activity_favorite', 'activity_mark_unfav' => 'bp_legacy_theme_unmark_activity_favorite', 'activity_widget_filter' => 'bp_legacy_theme_activity_template_loader', 'delete_activity' => 'bp_legacy_theme_delete_activity', 'delete_activity_comment' => 'bp_legacy_theme_delete_activity_comment', 'get_single_activity_content' => 'bp_legacy_theme_get_single_activity_content', 'new_activity_comment' => 'bp_legacy_theme_new_activity_comment', 'post_update' => 'bp_legacy_theme_post_update', 'bp_spam_activity' => 'bp_legacy_theme_spam_activity', 'bp_spam_activity_comment' => 'bp_legacy_theme_spam_activity', 'groups_invite_user' => 'bp_legacy_theme_ajax_invite_user', 'joinleave_group' => 'bp_legacy_theme_ajax_joinleave_group', 'messages_autocomplete_results' => 'bp_legacy_theme_ajax_messages_autocomplete_results', 'messages_close_notice' => 'bp_legacy_theme_ajax_close_notice', 'messages_delete' => 'bp_legacy_theme_ajax_messages_delete', 'messages_markread' => 'bp_legacy_theme_ajax_message_markread', 'messages_markunread' => 'bp_legacy_theme_ajax_message_markunread', 'messages_send_reply' => 'bp_legacy_theme_ajax_messages_send_reply');
     // Conditional actions
     if (bp_is_active('messages', 'star')) {
         $actions['messages_star'] = 'bp_legacy_theme_ajax_messages_star_handler';
     }
     /**
      * Register all of these AJAX handlers
      *
      * The "wp_ajax_" action is used for logged in users, and "wp_ajax_nopriv_"
      * executes for users that aren't logged in. This is for backpat with BP <1.6.
      */
     foreach ($actions as $name => $function) {
         add_action('wp_ajax_' . $name, $function);
         add_action('wp_ajax_nopriv_' . $name, $function);
     }
     add_filter('bp_ajax_querystring', 'bp_legacy_theme_ajax_querystring', 10, 2);
     /** Override **********************************************************/
     /**
      * Fires after all of the BuddyPress theme compat actions have been added.
      *
      * @since BuddyPress (1.7.0)
      *
      * @param BP_Legacy $this Current BP_Legacy instance.
      */
     do_action_ref_array('bp_theme_compat_actions', array(&$this));
 }
/**
 * Add activity notifications settings to the notifications settings page
 *
 * @since BuddyPress (1.2)
 *
 * @uses bp_get_user_meta()
 * @uses bp_core_get_username()
 * @uses do_action() To call the 'bp_activity_screen_notification_settings' hook
 */
function bp_activity_screen_notification_settings()
{
    if (bp_activity_do_mentions()) {
        if (!($mention = bp_get_user_meta(bp_displayed_user_id(), 'notification_activity_new_mention', true))) {
            $mention = 'yes';
        }
    }
    if (!($reply = bp_get_user_meta(bp_displayed_user_id(), 'notification_activity_new_reply', true))) {
        $reply = 'yes';
    }
    ?>

	<table class="notification-settings" id="activity-notification-settings">
		<thead>
			<tr>
				<th class="icon">&nbsp;</th>
				<th class="title"><?php 
    _e('Activity', 'buddypress');
    ?>
</th>
				<th class="yes"><?php 
    _e('Yes', 'buddypress');
    ?>
</th>
				<th class="no"><?php 
    _e('No', 'buddypress');
    ?>
</th>
			</tr>
		</thead>

		<tbody>
			<?php 
    if (bp_activity_do_mentions()) {
        ?>
				<tr id="activity-notification-settings-mentions">
					<td>&nbsp;</td>
					<td><?php 
        printf(__('A member mentions you in an update using "@%s"', 'buddypress'), bp_core_get_username(bp_displayed_user_id()));
        ?>
</td>
					<td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php 
        checked($mention, 'yes', true);
        ?>
/></td>
					<td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php 
        checked($mention, 'no', true);
        ?>
/></td>
				</tr>
			<?php 
    }
    ?>

			<tr id="activity-notification-settings-replies">
				<td>&nbsp;</td>
				<td><?php 
    _e("A member replies to an update or comment you've posted", 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php 
    checked($reply, 'yes', true);
    ?>
/></td>
				<td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php 
    checked($reply, 'no', true);
    ?>
/></td>
			</tr>

			<?php 
    do_action('bp_activity_screen_notification_settings');
    ?>
		</tbody>
	</table>

<?php 
}
/**
 * Return the member activity feed link.
 *
 * @since BuddyPress (1.2.0)
 *
 * @uses bp_is_profile_component()
 * @uses bp_is_current_action()
 * @uses bp_displayed_user_domain()
 * @uses bp_get_activity_slug()
 * @uses bp_is_active()
 * @uses bp_get_friends_slug()
 * @uses bp_get_groups_slug()
 * @uses apply_filters() To call the 'bp_get_activities_member_rss_link' hook.
 *
 * @return string $link The member activity feed link.
 */
function bp_get_member_activity_feed_link()
{
    // Single member activity feed link
    if (bp_is_profile_component() || bp_is_current_action('just-me')) {
        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/';
        // Friend feed link
    } elseif (bp_is_active('friends') && bp_is_current_action(bp_get_friends_slug())) {
        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/';
        // Group feed link
    } elseif (bp_is_active('groups') && bp_is_current_action(bp_get_groups_slug())) {
        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
        // Favorites activity feed link
    } elseif ('favorites' === bp_current_action()) {
        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
        // Mentions activity feed link
    } elseif ('mentions' === bp_current_action() && bp_activity_do_mentions()) {
        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
        // No feed link
    } else {
        $link = '';
    }
    /**
     * Filters the member activity feed link.
     *
     * @since BuddyPress (1.0.0)
     *
     * @param string $link URL for the member activity feed.
     */
    return apply_filters('bp_get_activities_member_rss_link', $link);
}
/**
 * Return the member activity feed link.
 *
 * @since BuddyPress (1.2)
 *
 * @uses bp_is_profile_component()
 * @uses bp_is_current_action()
 * @uses bp_displayed_user_domain()
 * @uses bp_get_activity_slug()
 * @uses bp_is_active()
 * @uses bp_get_friends_slug()
 * @uses bp_get_groups_slug()
 * @uses apply_filters() To call the 'bp_get_activities_member_rss_link' hook.
 *
 * @return string $link The member activity feed link.
 */
function bp_get_member_activity_feed_link()
{
    if (bp_is_profile_component() || bp_is_current_action('just-me')) {
        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/';
    } elseif (bp_is_active('friends') && bp_is_current_action(bp_get_friends_slug())) {
        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/';
    } elseif (bp_is_active('groups') && bp_is_current_action(bp_get_groups_slug())) {
        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
    } elseif ('favorites' == bp_current_action()) {
        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
    } elseif ('mentions' == bp_current_action() && bp_activity_do_mentions()) {
        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
    } else {
        $link = '';
    }
    return apply_filters('bp_get_activities_member_rss_link', $link);
}
/**
 * Load a user's @mentions feed.
 *
 * @since BuddyPress (1.2)
 *
 * @global object $wp_query
 * @uses bp_is_user_activity()
 * @uses bp_is_current_action()
 * @uses bp_is_action_variable()
 * @uses status_header()
 *
 * @return bool False on failure
 */
function bp_activity_action_mentions_feed()
{
    global $wp_query;
    if (!bp_activity_do_mentions()) {
        return false;
    }
    if (!bp_is_user_activity() || !bp_is_current_action('mentions') || !bp_is_action_variable('feed', 0)) {
        return false;
    }
    $wp_query->is_404 = false;
    status_header(200);
    include_once 'feeds/bp-activity-mentions-feed.php';
    die;
}
/**
 * Sends emails and BP notifications for users @-mentioned in an activity item.
 *
 * @since BuddyPress (1.7)
 *
 * @uses bp_activity_at_message_notification()
 * @uses bp_activity_update_mention_count_for_user()
 *
 * @param BP_Activity_Activity $activity The BP_Activity_Activity object
 */
function bp_activity_at_name_send_emails($activity)
{
    // Are mentions disabled?
    if (!bp_activity_do_mentions()) {
        return;
    }
    // If our temporary variable doesn't exist, stop now.
    if (empty(buddypress()->activity->mentioned_users)) {
        return;
    }
    // Grab our temporary variable from bp_activity_at_name_filter_updates()
    $usernames = buddypress()->activity->mentioned_users;
    // Get rid of temporary variable
    unset(buddypress()->activity->mentioned_users);
    // Send @mentions and setup BP notifications
    foreach ((array) $usernames as $user_id => $username) {
        // If you want to disable notifications, you can use this filter to stop email sending
        if (apply_filters('bp_activity_at_name_do_notifications', true, $usernames)) {
            bp_activity_at_message_notification($activity->id, $user_id);
        }
        // Updates mention count for the user
        bp_activity_update_mention_count_for_user($user_id, $activity->id);
    }
}
Example #15
0
 /**
  * Sets up theme defaults and registers support for various WordPress and BuddyPress features.
  *
  * Note that this function is hooked into the after_setup_theme hook, which runs
  * before the init hook. The init hook is too late for some features, such as indicating
  * support post thumbnails.
  *
  * To override bp_dtheme_setup() in a child theme, add your own bp_dtheme_setup to your child theme's
  * functions.php file.
  *
  * @global BuddyPress $bp The one true BuddyPress instance
  * @since BuddyPress (1.5)
  */
 function bp_dtheme_setup()
 {
     // Load the AJAX functions for the theme
     require get_template_directory() . '/_inc/ajax.php';
     // This theme styles the visual editor with editor-style.css to match the theme style.
     add_editor_style();
     // This theme comes with all the BuddyPress goodies
     add_theme_support('buddypress');
     // This theme uses post thumbnails
     add_theme_support('post-thumbnails');
     // Add default posts and comments RSS feed links to head
     add_theme_support('automatic-feed-links');
     // Add responsive layout support to bp-default without forcing child
     // themes to inherit it if they don't want to
     add_theme_support('bp-default-responsive');
     // This theme uses wp_nav_menu() in one location.
     register_nav_menus(array('primary' => __('Primary Navigation', 'buddypress')));
     // This theme allows users to set a custom background
     $custom_background_args = array('wp-head-callback' => 'bp_dtheme_custom_background_style');
     add_theme_support('custom-background', $custom_background_args);
     // Add custom header support if allowed
     if (!defined('BP_DTHEME_DISABLE_CUSTOM_HEADER')) {
         define('HEADER_TEXTCOLOR', 'FFFFFF');
         // The height and width of your custom header. You can hook into the theme's own filters to change these values.
         // Add a filter to bp_dtheme_header_image_width and bp_dtheme_header_image_height to change these values.
         define('HEADER_IMAGE_WIDTH', apply_filters('bp_dtheme_header_image_width', 1250));
         define('HEADER_IMAGE_HEIGHT', apply_filters('bp_dtheme_header_image_height', 133));
         // We'll be using post thumbnails for custom header images on posts and pages. We want them to be 1250 pixels wide by 133 pixels tall.
         // Larger images will be auto-cropped to fit, smaller ones will be ignored.
         set_post_thumbnail_size(HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true);
         // Add a way for the custom header to be styled in the admin panel that controls custom headers.
         $custom_header_args = array('wp-head-callback' => 'bp_dtheme_header_style', 'admin-head-callback' => 'bp_dtheme_admin_header_style');
         add_theme_support('custom-header', $custom_header_args);
     }
     if (!is_admin() || defined('DOING_AJAX') && DOING_AJAX) {
         // Register buttons for the relevant component templates
         // Friends button
         if (bp_is_active('friends')) {
             add_action('bp_member_header_actions', 'bp_add_friend_button', 5);
         }
         // Activity button
         if (bp_is_active('activity') && bp_activity_do_mentions()) {
             add_action('bp_member_header_actions', 'bp_send_public_message_button', 20);
         }
         // Messages button
         if (bp_is_active('messages')) {
             add_action('bp_member_header_actions', 'bp_send_private_message_button', 20);
         }
         // Group buttons
         if (bp_is_active('groups')) {
             add_action('bp_group_header_actions', 'bp_group_join_button', 5);
             add_action('bp_group_header_actions', 'bp_group_new_topic_button', 20);
             add_action('bp_directory_groups_actions', 'bp_group_join_button');
         }
         // Blog button
         if (bp_is_active('blogs')) {
             add_action('bp_directory_blogs_actions', 'bp_blogs_visit_blog_button');
         }
     }
 }
Example #16
0
function wplms_bp_dtheme_setup()
{
    if (!is_admin() || defined('DOING_AJAX') && DOING_AJAX) {
        if (function_exists('bp_is_active')) {
            // Register buttons for the relevant component templates
            // Friends button
            if (bp_is_active('friends')) {
                add_action('bp_member_header_actions', 'bp_add_friend_button', 5);
            }
            // Activity button
            if (bp_is_active('activity') && bp_activity_do_mentions()) {
                add_action('bp_member_header_actions', 'bp_send_public_message_button', 20);
            }
            // Messages button
            if (bp_is_active('messages')) {
                add_action('bp_member_header_actions', 'bp_send_private_message_button', 20);
            }
            // Group buttons
            if (bp_is_active('groups')) {
                add_action('bp_group_header_actions', 'bp_group_join_button', 5);
                add_action('bp_group_header_actions', 'bp_group_new_topic_button', 20);
                add_action('bp_directory_groups_actions', 'bp_group_join_button');
            }
            // Blog button
            if (bp_is_active('blogs')) {
                add_action('bp_directory_blogs_actions', 'bp_blogs_visit_blog_button');
            }
        }
    }
}
/**
 * Add activity notifications settings to the notifications settings page.
 *
 * @since 1.2.0
 *
 * @uses bp_get_user_meta()
 * @uses bp_core_get_username()
 * @uses do_action() To call the 'bp_activity_screen_notification_settings' hook.
 */
function bp_activity_screen_notification_settings()
{
    if (bp_activity_do_mentions()) {
        if (!($mention = bp_get_user_meta(bp_displayed_user_id(), 'notification_activity_new_mention', true))) {
            $mention = 'yes';
        }
    }
    if (!($reply = bp_get_user_meta(bp_displayed_user_id(), 'notification_activity_new_reply', true))) {
        $reply = 'yes';
    }
    ?>

	<table class="notification-settings" id="activity-notification-settings">
		<thead>
			<tr>
				<th class="icon">&nbsp;</th>
				<th class="title"><?php 
    _e('Activity', 'buddypress');
    ?>
</th>
				<th class="yes"><?php 
    _e('Yes', 'buddypress');
    ?>
</th>
				<th class="no"><?php 
    _e('No', 'buddypress');
    ?>
</th>
			</tr>
		</thead>

		<tbody>
			<?php 
    if (bp_activity_do_mentions()) {
        ?>
				<tr id="activity-notification-settings-mentions">
					<td>&nbsp;</td>
					<td><?php 
        printf(__('A member mentions you in an update using "@%s"', 'buddypress'), bp_core_get_username(bp_displayed_user_id()));
        ?>
</td>
					<td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-yes" value="yes" <?php 
        checked($mention, 'yes', true);
        ?>
/><label for="notification-activity-new-mention-yes" class="bp-screen-reader-text"><?php 
        _e('Yes, send email', 'buddypress');
        ?>
</label></td>
					<td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" id="notification-activity-new-mention-no" value="no" <?php 
        checked($mention, 'no', true);
        ?>
/><label for="notification-activity-new-mention-no" class="bp-screen-reader-text"><?php 
        _e('No, do not send email', 'buddypress');
        ?>
</label></td>
				</tr>
			<?php 
    }
    ?>

			<tr id="activity-notification-settings-replies">
				<td>&nbsp;</td>
				<td><?php 
    _e("A member replies to an update or comment you've posted", 'buddypress');
    ?>
</td>
				<td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-yes" value="yes" <?php 
    checked($reply, 'yes', true);
    ?>
/><label for="notification-activity-new-reply-yes" class="bp-screen-reader-text"><?php 
    _e('Yes, send email', 'buddypress');
    ?>
</label></td>
				<td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" id="notification-activity-new-reply-no" value="no" <?php 
    checked($reply, 'no', true);
    ?>
/><label for="notification-activity-new-reply-no" class="bp-screen-reader-text"><?php 
    _e('No, do not send email', 'buddypress');
    ?>
</label></td>
			</tr>

			<?php 
    /**
     * Fires inside the closing </tbody> tag for activity screen notification settings.
     *
     * @since 1.2.0
     */
    do_action('bp_activity_screen_notification_settings');
    ?>
		</tbody>
	</table>

<?php 
}
/**
 * Load a user's @mentions feed.
 *
 * @since 1.2.0
 *
 * @uses bp_is_user_activity()
 * @uses bp_is_current_action()
 * @uses bp_is_action_variable()
 * @uses status_header()
 *
 * @return bool False on failure.
 */
function bp_activity_action_mentions_feed()
{
    if (!bp_activity_do_mentions()) {
        return false;
    }
    if (!bp_is_user_activity() || !bp_is_current_action('mentions') || !bp_is_action_variable('feed', 0)) {
        return false;
    }
    // Setup the feed.
    buddypress()->activity->feed = new BP_Activity_Feed(array('id' => 'mentions', 'title' => sprintf(__('%1$s | %2$s | Mentions', 'buddypress'), bp_get_site_name(), bp_get_displayed_user_fullname()), 'link' => bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/', 'description' => sprintf(__("Activity feed mentioning %s.", 'buddypress'), bp_get_displayed_user_fullname()), 'activity_args' => array('search_terms' => '@' . bp_core_get_username(bp_displayed_user_id()))));
}
Example #19
0
	<a href="<?php 
bp_displayed_user_link();
?>
">

		<?php 
bp_displayed_user_avatar('type=full');
?>

	</a>
</div><!-- #item-header-avatar -->

<div id="item-header-content">

	<?php 
if (bp_is_active('activity') && bp_activity_do_mentions()) {
    ?>
		<h2 class="user-nicename">@<?php 
    bp_displayed_user_mentionname();
    ?>
</h2>
	<?php 
}
?>

	<span class="activity"><?php 
bp_last_activity(bp_displayed_user_id());
?>
</span>

	<?php 
 /**
  * Sets a custom <blockquote> for our oEmbed fallback HTML.
  *
  * @since 2.6.0
  *
  * @param  int $item_id The activity ID.
  * @return string
  */
 protected function set_fallback_html($item_id)
 {
     $activity = new BP_Activity_Activity($item_id);
     $mentionname = bp_activity_do_mentions() ? ' (@' . bp_activity_get_user_mentionname($activity->user_id) . ')' : '';
     $date = date_i18n(get_option('date_format'), strtotime($activity->date_recorded));
     // Make sure we can use some activity functions that depend on the loop.
     $GLOBALS['activities_template'] = new stdClass();
     $GLOBALS['activities_template']->activity = $activity;
     // 'wp-embedded-content' CSS class is necessary due to how the embed JS works.
     $blockquote = sprintf('<blockquote class="wp-embedded-content bp-activity-item">%1$s%2$s %3$s</blockquote>', bp_activity_get_embed_excerpt($activity->content), '- ' . bp_core_get_user_displayname($activity->user_id) . $mentionname, '<a href="' . esc_url(bp_activity_get_permalink($item_id)) . '">' . $date . '</a>');
     // Clean up.
     unset($GLOBALS['activities_template']);
     /**
      * Filters the fallback HTML used when embedding a BP activity item.
      *
      * @since 2.6.0
      *
      * @param string               $blockquote Current fallback HTML
      * @param BP_Activity_Activity $activity   Activity object
      */
     return apply_filters('bp_activity_embed_fallback_html', $blockquote, $activity);
 }