/** * Can't test using bp_activity_get_permalink(); see bp_activity_action_permalink_router(). */ function test_activity_permalink() { $a = $this->factory->activity->create(); $activity = $this->factory->activity->get_object_by_id($a); $url = bp_core_get_user_domain($activity->user_id) . bp_get_activity_slug() . '/' . $activity->id . '/'; $this->go_to($url); $this->assertTrue(bp_is_single_activity()); }
function activity_loop_link() { $act_type = bp_get_activity_type(); if (empty($this->types_map[$act_type])) { return; } $args = array('type' => $this->types_map[$act_type], 'id' => bp_get_activity_item_id(), 'id2' => bp_get_activity_secondary_item_id(), 'author_id' => bp_get_activity_user_id(), 'is_main_content' => bp_is_single_activity(), 'context' => 'activity-loop', 'custom_class' => 'button'); $args = apply_filters("bp_moderation_activity_loop_link_args_{$act_type}", $args); if ($args) { echo $this->generate_link($args); } }
/** * Add the Activity top-level menu link when viewing single activity item. * * @since 2.6.0 * * @return null Null if user does not have access to editing functionality. */ function bp_activity_admin_menu() { global $wp_admin_bar; // Only show if viewing a single activity item. if (!bp_is_single_activity()) { return; } // Only show this menu to super admins if (!bp_current_user_can('bp_moderate')) { return; } $activity_edit_link = add_query_arg(array('page' => 'bp-activity', 'aid' => bp_current_action(), 'action' => 'edit'), bp_get_admin_url('admin.php')); // Add the top-level Edit Activity button. $wp_admin_bar->add_menu(array('id' => 'activity-admin', 'title' => __('Edit Activity', 'buddypress'), 'href' => esc_url($activity_edit_link))); }
/** * Add inline styles for BP activity embeds. * * @since 2.6.0 */ function bp_activity_embed_add_inline_styles() { if (false === bp_is_single_activity()) { return; } $min = bp_core_get_minified_asset_suffix(); if (is_rtl()) { $css = bp_locate_template_asset("css/embeds-activity-rtl{$min}.css"); } else { $css = bp_locate_template_asset("css/embeds-activity{$min}.css"); } // Bail if file wasn't found. if (false === $css) { return; } // Grab contents of CSS file and do some rudimentary CSS protection. $css = file_get_contents($css['file']); $css = wp_kses($css, array("\\'", '\\"')); printf('<style type="text/css">%s</style>', $css); }
/** * Set up the theme compatibility hooks, if we're looking at an activity page. * * @since 1.7.0 */ public function is_activity() { // Bail if not looking at a group. if (!bp_is_activity_component()) { return; } // Activity Directory. if (!bp_displayed_user_id() && !bp_current_action()) { bp_update_is_directory(true, 'activity'); /** This action is documented in bp-activity/bp-activity-screens.php */ do_action('bp_activity_screen_index'); add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy')); add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post')); add_filter('bp_replace_the_content', array($this, 'directory_content')); // Single activity. } elseif (bp_is_single_activity()) { add_filter('bp_get_buddypress_template', array($this, 'single_template_hierarchy')); add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post')); add_filter('bp_replace_the_content', array($this, 'single_dummy_content')); } }
/** * Are we looking at something that needs members theme compatibility? * * @since 1.7.0 */ public function is_members() { // Bail if not looking at the members component or a user's page. if (!bp_is_members_component() && !bp_is_user()) { return; } // Members Directory. if (!bp_current_action() && !bp_current_item()) { bp_update_is_directory(true, 'members'); /** * Fires if looking at Members directory when needing theme compat. * * @since 1.5.0 */ do_action('bp_members_screen_index'); add_filter('bp_get_buddypress_template', array($this, 'directory_template_hierarchy')); add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post')); add_filter('bp_replace_the_content', array($this, 'directory_content')); // User page. } elseif (bp_is_user()) { // If we're on a single activity permalink page, we shouldn't use the members // template, so stop here! if (bp_is_active('activity') && bp_is_single_activity()) { return; } /** * Fires if looking at Members user page when needing theme compat. * * @since 1.5.0 */ do_action('bp_members_screen_display_profile'); add_filter('bp_get_buddypress_template', array($this, 'single_template_hierarchy')); add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post')); add_filter('bp_replace_the_content', array($this, 'single_dummy_content')); } }
/** * Stop WordPress performing a DB query for its main loop. * * As of WordPress 4.6, it is possible to bypass the main WP_Query entirely. * This saves us one unnecessary database query! :) * * @since 2.7.0 * * @param null $retval Current return value for filter. * @param WP_Query $query Current WordPress query object. * @return null|array */ function bp_core_filter_wp_query($retval, $query) { if (!$query->is_main_query()) { return $retval; } /* * If not on a BP single page, bail. * Too early to use bp_is_single_item(), so use BP conditionals. */ if (false === (bp_is_group() || bp_is_user() || bp_is_single_activity())) { return $retval; } // Set default properties as recommended in the 'posts_pre_query' DocBlock. $query->found_posts = 0; $query->max_num_pages = 0; // Return something other than a null value to bypass WP_Query. return array(); }
/** * Customizes the post CSS class according to BuddyPress content. * * Hooked to the 'post_class' filter. * * @since BuddyPress (2.1.0) * * @param array $wp_classes The post classes coming from WordPress. * @return array */ function bp_get_the_post_class($wp_classes = array()) { // don't do anything if we're not on a BP page if (!is_buddypress()) { return $wp_classes; } $bp_classes = array(); if (bp_is_user() || bp_is_single_activity()) { $bp_classes[] = 'bp_members'; } elseif (bp_is_group()) { $bp_classes[] = 'bp_group'; } elseif (bp_is_activity_component()) { $bp_classes[] = 'bp_activity'; } elseif (bp_is_blogs_component()) { $bp_classes[] = 'bp_blogs'; } elseif (bp_is_register_page()) { $bp_classes[] = 'bp_register'; } elseif (bp_is_activation_page()) { $bp_classes[] = 'bp_activate'; } elseif (bp_is_forums_component() && bp_is_directory()) { $bp_classes[] = 'bp_forum'; } if (empty($bp_classes)) { return $wp_classes; } // emulate post type css class foreach ($bp_classes as $bp_class) { $bp_classes[] = "type-{$bp_class}"; } // removes the 'page' and 'type-page' post classes // we need to remove these classes since they did not exist before we switched // theme compat to use the 'page' post type $page_key = array_search('page', $wp_classes); $page_type_key = array_search('type-page', $wp_classes); unset($wp_classes[$page_key], $wp_classes[$page_type_key]); // okay let's merge! return array_unique(array_merge($bp_classes, $wp_classes)); }
/** * Truncate long activity entries when viewed in activity streams. * * This method can only be used inside the Activity loop. * * @since 1.5.0 * * @uses bp_is_single_activity() * @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook. * @uses apply_filters() To call the 'bp_activity_excerpt_length' hook. * @uses bp_create_excerpt() * @uses bp_get_activity_id() * @uses bp_get_activity_thread_permalink() * @uses apply_filters() To call the 'bp_activity_truncate_entry' hook. * * @param string $text The original activity entry text. * @return string $excerpt The truncated text. */ function bp_activity_truncate_entry($text) { global $activities_template; /** * Provides a filter that lets you choose whether to skip this filter on a per-activity basis. * * @since 2.3.0 * * @param bool $value If true, text should be checked to see if it needs truncating. */ $maybe_truncate_text = apply_filters('bp_activity_maybe_truncate_entry', isset($activities_template->activity->type) && !in_array($activities_template->activity->type, array('new_blog_post'), true)); // The full text of the activity update should always show on the single activity screen. if (!$maybe_truncate_text || bp_is_single_activity()) { return $text; } /** * Filters the appended text for the activity excerpt. * * @since 1.5.0 * * @param string $value Internationalized "Read more" text. */ $append_text = apply_filters('bp_activity_excerpt_append_text', __('[Read more]', 'buddypress')); /** * Filters the excerpt length for the activity excerpt. * * @since 1.5.0 * * @param int $value Number indicating how many words to trim the excerpt down to. */ $excerpt_length = apply_filters('bp_activity_excerpt_length', 358); // Run the text through the excerpt function. If it's too short, the original text will be returned. $excerpt = bp_create_excerpt($text, $excerpt_length, array('ending' => __('…', 'buddypress'))); /* * If the text returned by bp_create_excerpt() is different from the original text (ie it's * been truncated), add the "Read More" link. Note that bp_create_excerpt() is stripping * shortcodes, so we have strip them from the $text before the comparison. */ if ($excerpt != strip_shortcodes($text)) { $id = !empty($activities_template->activity->current_comment->id) ? 'acomment-read-more-' . $activities_template->activity->current_comment->id : 'activity-read-more-' . bp_get_activity_id(); $excerpt = sprintf('%1$s<span class="activity-read-more" id="%2$s"><a href="%3$s" rel="nofollow">%4$s</a></span>', $excerpt, $id, bp_get_activity_thread_permalink(), $append_text); } /** * Filters the composite activity excerpt entry. * * @since 1.5.0 * * @param string $excerpt Excerpt text and markup to be displayed. * @param string $text The original activity entry text. * @param string $append_text The final append text applied. */ return apply_filters('bp_activity_truncate_entry', $excerpt, $text, $append_text); }
function bp_get_the_body_class($nxt_classes, $custom_classes = false) { $bp_classes = array(); /** Pages *************************************************************/ if (is_front_page()) { $bp_classes[] = 'home-page'; } if (bp_is_directory()) { $bp_classes[] = 'directory'; } if (bp_is_single_item()) { $bp_classes[] = 'single-item'; } /** Components ********************************************************/ if (!bp_is_blog_page()) { if (bp_is_user_profile()) { $bp_classes[] = 'xprofile'; } if (bp_is_activity_component()) { $bp_classes[] = 'activity'; } if (bp_is_blogs_component()) { $bp_classes[] = 'blogs'; } if (bp_is_messages_component()) { $bp_classes[] = 'messages'; } if (bp_is_friends_component()) { $bp_classes[] = 'friends'; } if (bp_is_groups_component()) { $bp_classes[] = 'groups'; } if (bp_is_settings_component()) { $bp_classes[] = 'settings'; } } /** User **************************************************************/ if (!bp_is_directory()) { if (bp_is_user_blogs()) { $bp_classes[] = 'my-blogs'; } if (bp_is_user_groups()) { $bp_classes[] = 'my-groups'; } if (bp_is_user_activity()) { $bp_classes[] = 'my-activity'; } } if (bp_is_my_profile()) { $bp_classes[] = 'my-account'; } if (bp_is_user_profile()) { $bp_classes[] = 'my-profile'; } if (bp_is_user_friends()) { $bp_classes[] = 'my-friends'; } if (bp_is_user_messages()) { $bp_classes[] = 'my-messages'; } if (bp_is_user_recent_commments()) { $bp_classes[] = 'recent-comments'; } if (bp_is_user_recent_posts()) { $bp_classes[] = 'recent-posts'; } if (bp_is_user_change_avatar()) { $bp_classes[] = 'change-avatar'; } if (bp_is_user_profile_edit()) { $bp_classes[] = 'profile-edit'; } if (bp_is_user_friends_activity()) { $bp_classes[] = 'friends-activity'; } if (bp_is_user_groups_activity()) { $bp_classes[] = 'groups-activity'; } if (is_user_logged_in()) { $bp_classes[] = 'logged-in'; } /** Messages **********************************************************/ if (bp_is_messages_inbox()) { $bp_classes[] = 'inbox'; } if (bp_is_messages_sentbox()) { $bp_classes[] = 'sentbox'; } if (bp_is_messages_compose_screen()) { $bp_classes[] = 'compose'; } if (bp_is_notices()) { $bp_classes[] = 'notices'; } if (bp_is_user_friend_requests()) { $bp_classes[] = 'friend-requests'; } if (bp_is_create_blog()) { $bp_classes[] = 'create-blog'; } /** Groups ************************************************************/ if (bp_is_group_leave()) { $bp_classes[] = 'leave-group'; } if (bp_is_group_invites()) { $bp_classes[] = 'group-invites'; } if (bp_is_group_members()) { $bp_classes[] = 'group-members'; } if (bp_is_group_forum_topic()) { $bp_classes[] = 'group-forum-topic'; } if (bp_is_group_forum_topic_edit()) { $bp_classes[] = 'group-forum-topic-edit'; } if (bp_is_group_forum()) { $bp_classes[] = 'group-forum'; } if (bp_is_group_admin_page()) { $bp_classes[] = 'group-admin'; } if (bp_is_group_create()) { $bp_classes[] = 'group-create'; } if (bp_is_group_home()) { $bp_classes[] = 'group-home'; } if (bp_is_single_activity()) { $bp_classes[] = 'activity-permalink'; } /** Registration ******************************************************/ if (bp_is_register_page()) { $bp_classes[] = 'registration'; } if (bp_is_activation_page()) { $bp_classes[] = 'activation'; } /** Current Component & Action ****************************************/ if (!bp_is_blog_page()) { $bp_classes[] = bp_current_component(); $bp_classes[] = bp_current_action(); } /** Clean up***********************************************************/ // We don't want NXTClass blog classes to appear on non-blog pages. if (!bp_is_blog_page()) { // Preserve any custom classes already set if (!empty($custom_classes)) { $nxt_classes = (array) $custom_classes; } else { $nxt_classes = array(); } } // Merge nxt classes with BP classes $classes = array_merge((array) $bp_classes, (array) $nxt_classes); // Remove any duplicates $classes = array_unique($classes); return apply_filters('bp_get_the_body_class', $classes, $bp_classes, $nxt_classes, $custom_classes); }
/** * Insert activity meta * * @since 1.2.0 * * @param string $content * * @global object $activities_template {@link BP_Activity_Template} * @global object $bp BuddyPress global settings * @uses bp_core_time_since() * @uses apply_filters_ref_array() To call the 'bp_activity_time_since' hook * @uses bp_is_single_activity() * @uses bp_activity_get_permalink() * @uses esc_attr__() * @uses apply_filters_ref_array() To call the 'bp_activity_permalink' hook * @uses apply_filters() To call the 'bp_insert_activity_meta' hook * * @return string The activity content */ function bp_insert_activity_meta($content) { global $activities_template, $bp; // Strip any legacy time since placeholders from BP 1.0-1.1 $content = str_replace('<span class="time-since">%s</span>', '', $content); // Insert the time since. $time_since = apply_filters_ref_array('bp_activity_time_since', array('<span class="time-since">' . bp_core_time_since($activities_template->activity->date_recorded) . '</span>', &$activities_template->activity)); // Insert the permalink if (!bp_is_single_activity()) { $content = apply_filters_ref_array('bp_activity_permalink', array(sprintf('%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', $content, bp_activity_get_permalink($activities_template->activity->id, $activities_template->activity), esc_attr__('View Discussion', 'buddypress'), $time_since), &$activities_template->activity)); } else { $content .= str_pad($time_since, strlen($time_since) + 2, ' ', STR_PAD_BOTH); } return apply_filters('bp_insert_activity_meta', $content); }
function bp_checkins_display_user_checkin() { if ((int) bp_get_option('bp-checkins-disable-activity-checkins') && !bp_is_current_component('checkins') && !bp_is_current_action('checkins') && !bp_is_single_activity() || (int) bp_get_option('bp-checkins-disable-activity-checkins') && bp_is_single_activity() && (!(int) bp_get_option('bp-checkins-activate-component') || '' == bp_get_option('bp-checkins-activate-component'))) { return false; } $activity_id = bp_get_activity_id(); $activity_permalink = bp_activity_get_permalink($activity_id) . '?map=1'; $address = bp_activity_get_meta($activity_id, 'bpci_activity_address'); if ($address) { ?> <div class="activity-checkin"> <a href="<?php echo $activity_permalink; ?> " title="<?php _e('Open the map for this update', 'bp-checkins'); ?> " class="link-checkin"><span class="update-checkin"><?php echo stripslashes($address); ?> </span></a> </div> <?php } }
/** * Prints the markup for the activity embed comments button. * * Basically a copy of {@link print_embed_comments_button()}, but modified for * the BP activity component. * * @since 2.6.0 */ public function embed_comments_button() { if (!did_action('bp_embed_content') || !bp_is_single_activity()) { return; } // Make sure our custom permalink shows up in the 'WordPress Embed' block. add_filter('the_permalink', array($this, 'filter_embed_url')); // Only show comment bubble if we have some activity comments. $count = bp_activity_get_comment_count(); if (empty($count)) { return; } ?> <div class="wp-embed-comments"> <a href="<?php bp_activity_thread_permalink(); ?> "> <span class="dashicons dashicons-admin-comments"></span> <?php printf(_n('%s <span class="screen-reader-text">Comment</span>', '%s <span class="screen-reader-text">Comments</span>', $count, 'buddypress'), number_format_i18n($count)); ?> </a> </div> <?php }
/** * Truncates long activity entries when viewed in activity streams * * @since 1.5.0 * * @param $text The original activity entry text * * @uses bp_is_single_activity() * @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook * @uses apply_filters() To call the 'bp_activity_excerpt_length' hook * @uses bp_create_excerpt() * @uses bp_get_activity_id() * @uses bp_get_activity_thread_permalink() * @uses apply_filters() To call the 'bp_activity_truncate_entry' hook * * @return string $excerpt The truncated text */ function bp_activity_truncate_entry($text) { global $activities_template; // The full text of the activity update should always show on the single activity screen if (bp_is_single_activity()) { return $text; } $append_text = apply_filters('bp_activity_excerpt_append_text', __('[Read more]', 'buddypress')); $excerpt_length = apply_filters('bp_activity_excerpt_length', 358); // Run the text through the excerpt function. If it's too short, the original text will be // returned. $excerpt = bp_create_excerpt($text, $excerpt_length, array('ending' => __('…', 'buddypress'))); // If the text returned by bp_create_excerpt() is different from the original text (ie it's // been truncated), add the "Read More" link. if ($excerpt != $text) { $id = !empty($activities_template->activity->current_comment->id) ? 'acomment-read-more-' . $activities_template->activity->current_comment->id : 'activity-read-more-' . bp_get_activity_id(); $excerpt = sprintf('%1$s<span class="activity-read-more" id="%2$s"><a href="%3$s" rel="nofollow">%4$s</a></span>', $excerpt, $id, bp_get_activity_thread_permalink(), $append_text); } return apply_filters('bp_activity_truncate_entry', $excerpt, $text, $append_text); }
/** * Customizes the post CSS class according to BuddyPress content. * * Hooked to the 'post_class' filter. * * @since 2.1.0 * * @param array $wp_classes The post classes coming from WordPress. * @return array */ function bp_get_the_post_class($wp_classes = array()) { // Don't do anything if we're not on a BP page. if (!is_buddypress()) { return $wp_classes; } $bp_classes = array(); if (bp_is_user() || bp_is_single_activity()) { $bp_classes[] = 'bp_members'; } elseif (bp_is_group()) { $bp_classes[] = 'bp_group'; } elseif (bp_is_activity_component()) { $bp_classes[] = 'bp_activity'; } elseif (bp_is_blogs_component()) { $bp_classes[] = 'bp_blogs'; } elseif (bp_is_register_page()) { $bp_classes[] = 'bp_register'; } elseif (bp_is_activation_page()) { $bp_classes[] = 'bp_activate'; } elseif (bp_is_forums_component() && bp_is_directory()) { $bp_classes[] = 'bp_forum'; } if (empty($bp_classes)) { return $wp_classes; } // Emulate post type css class. foreach ($bp_classes as $bp_class) { $bp_classes[] = "type-{$bp_class}"; } // Okay let's merge! return array_unique(array_merge($bp_classes, $wp_classes)); }
</div> </div> <?php /** * Fires before the display of the activity entry comments. * * @since BuddyPress (1.2.0) */ do_action('bp_before_activity_entry_comments'); ?> <?php if (bp_activity_get_comment_count() || bp_activity_can_comment() || bp_is_single_activity()) { ?> <div class="activity-comments"> <?php bp_activity_comments(); ?> <?php if (is_user_logged_in() && bp_activity_can_comment()) { ?> <form action="<?php bp_activity_comment_form_action(); ?>
/** * Filter the document title for BuddyPress pages. * * @since 2.4.3 * * @param array $title The WordPress document title parts * @return array the unchanged title parts or the BuddyPress ones */ function bp_modify_document_title_parts($title = array()) { // Get the BuddyPress title parts $bp_title_parts = bp_get_title_parts(); // If not set, simply return the original title if (!$bp_title_parts) { return $title; } // Get the separator used by wp_get_document_title() $sep = apply_filters('document_title_separator', '-'); // Build the BuddyPress portion of the title. // We don't need to sanitize this as WordPress will take care of it. $bp_title = array('title' => join(" {$sep} ", $bp_title_parts)); // Add the pagination number if needed (not sure if this is necessary). if (isset($title['page']) && !bp_is_single_activity()) { $bp_title['page'] = $title['page']; } // Add the sitename if needed. if (isset($title['site'])) { $bp_title['site'] = $title['site']; } /** * Filters BuddyPress title parts that will be used into the document title. * * @since 2.4.3 * * @param array $bp_title The BuddyPress page title parts. * @param array $title The original WordPress title parts. */ return apply_filters('bp_modify_document_title_parts', $bp_title, $title); }
function bp_get_the_body_class($wp_classes = array(), $custom_classes = false) { $bp_classes = array(); /** Pages *************************************************************/ if (is_front_page()) { $bp_classes[] = 'home-page'; } if (bp_is_directory()) { $bp_classes[] = 'directory'; } if (bp_is_single_item()) { $bp_classes[] = 'single-item'; } /** Components ********************************************************/ if (!bp_is_blog_page()) { if (bp_is_user_profile()) { $bp_classes[] = 'xprofile'; } if (bp_is_activity_component()) { $bp_classes[] = 'activity'; } if (bp_is_blogs_component()) { $bp_classes[] = 'blogs'; } if (bp_is_messages_component()) { $bp_classes[] = 'messages'; } if (bp_is_friends_component()) { $bp_classes[] = 'friends'; } if (bp_is_groups_component()) { $bp_classes[] = 'groups'; } if (bp_is_settings_component()) { $bp_classes[] = 'settings'; } } /** User **************************************************************/ if (bp_is_user()) { $bp_classes[] = 'bp-user'; } if (!bp_is_directory()) { if (bp_is_user_blogs()) { $bp_classes[] = 'my-blogs'; } if (bp_is_user_groups()) { $bp_classes[] = 'my-groups'; } if (bp_is_user_activity()) { $bp_classes[] = 'my-activity'; } } if (bp_is_my_profile()) { $bp_classes[] = 'my-account'; } if (bp_is_user_profile()) { $bp_classes[] = 'my-profile'; } if (bp_is_user_friends()) { $bp_classes[] = 'my-friends'; } if (bp_is_user_messages()) { $bp_classes[] = 'my-messages'; } if (bp_is_user_recent_commments()) { $bp_classes[] = 'recent-comments'; } if (bp_is_user_recent_posts()) { $bp_classes[] = 'recent-posts'; } if (bp_is_user_change_avatar()) { $bp_classes[] = 'change-avatar'; } if (bp_is_user_profile_edit()) { $bp_classes[] = 'profile-edit'; } if (bp_is_user_friends_activity()) { $bp_classes[] = 'friends-activity'; } if (bp_is_user_groups_activity()) { $bp_classes[] = 'groups-activity'; } /** Messages **********************************************************/ if (bp_is_messages_inbox()) { $bp_classes[] = 'inbox'; } if (bp_is_messages_sentbox()) { $bp_classes[] = 'sentbox'; } if (bp_is_messages_compose_screen()) { $bp_classes[] = 'compose'; } if (bp_is_notices()) { $bp_classes[] = 'notices'; } if (bp_is_user_friend_requests()) { $bp_classes[] = 'friend-requests'; } if (bp_is_create_blog()) { $bp_classes[] = 'create-blog'; } /** Groups ************************************************************/ if (bp_is_group_leave()) { $bp_classes[] = 'leave-group'; } if (bp_is_group_invites()) { $bp_classes[] = 'group-invites'; } if (bp_is_group_members()) { $bp_classes[] = 'group-members'; } if (bp_is_group_forum_topic()) { $bp_classes[] = 'group-forum-topic'; } if (bp_is_group_forum_topic_edit()) { $bp_classes[] = 'group-forum-topic-edit'; } if (bp_is_group_forum()) { $bp_classes[] = 'group-forum'; } if (bp_is_group_admin_page()) { $bp_classes[] = 'group-admin'; $bp_classes[] = bp_get_group_current_admin_tab(); } if (bp_is_group_create()) { $bp_classes[] = 'group-create'; $bp_classes[] = bp_get_groups_current_create_step(); } if (bp_is_group_home()) { $bp_classes[] = 'group-home'; } if (bp_is_single_activity()) { $bp_classes[] = 'activity-permalink'; } /** Registration ******************************************************/ if (bp_is_register_page()) { $bp_classes[] = 'registration'; } if (bp_is_activation_page()) { $bp_classes[] = 'activation'; } /** Current Component & Action ****************************************/ if (!bp_is_blog_page()) { $bp_classes[] = bp_current_component(); $bp_classes[] = bp_current_action(); } /** Clean up ***********************************************************/ // Add BuddyPress class if we are within a BuddyPress page if (!bp_is_blog_page()) { $bp_classes[] = 'buddypress'; } // Merge WP classes with BuddyPress classes and remove any duplicates $classes = array_unique(array_merge((array) $bp_classes, (array) $wp_classes)); return apply_filters('bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes); }
/** * Check if this is a BuddyPress page or not. * Returns true or false (boolean) */ function shoestrap_is_bp() { $bp = false; /** Pages *************************************************************/ if (!$bp && bp_is_directory()) { $bp = true; } elseif (!$bp && bp_is_single_item()) { $bp = true; } elseif (!$bp && bp_is_user_profile()) { $bp = true; } elseif (!$bp && bp_is_activity_component()) { $bp = true; } elseif (!$bp && bp_is_blogs_component()) { $bp = true; } elseif (!$bp && bp_is_messages_component()) { $bp = true; } elseif (!$bp && bp_is_friends_component()) { $bp = true; } elseif (!$bp && bp_is_groups_component()) { $bp = true; } elseif (!$bp && bp_is_settings_component()) { $bp = true; } elseif (!$bp && bp_is_user()) { $bp = true; } elseif (!$bp && bp_is_user_blogs()) { $bp = true; } elseif (!$bp && bp_is_user_groups()) { $bp = true; } elseif (!$bp && bp_is_user_activity()) { $bp = true; } elseif (!$bp && bp_is_my_profile()) { $bp = true; } elseif (!$bp && bp_is_user_profile()) { $bp = true; } elseif (!$bp && bp_is_user_friends()) { $bp = true; } elseif (!$bp && bp_is_user_messages()) { $bp = true; } elseif (!$bp && bp_is_user_recent_commments()) { $bp = true; } elseif (!$bp && bp_is_user_recent_posts()) { $bp = true; } elseif (!$bp && bp_is_user_change_avatar()) { $bp = true; } elseif (!$bp && bp_is_user_profile_edit()) { $bp = true; } elseif (!$bp && bp_is_user_friends_activity()) { $bp = true; } elseif (!$bp && bp_is_user_groups_activity()) { $bp = true; } elseif (!$bp && is_user_logged_in()) { $bp = true; } elseif (!$bp && bp_is_messages_inbox()) { $bp = true; } elseif (!$bp && bp_is_messages_sentbox()) { $bp = true; } elseif (!$bp && bp_is_messages_compose_screen()) { $bp = true; } elseif (!$bp && bp_is_notices()) { $bp = true; } elseif (!$bp && bp_is_user_friend_requests()) { $bp = true; } elseif (!$bp && bp_is_create_blog()) { $bp = true; } elseif (!$bp && bp_is_group_leave()) { $bp = true; } elseif (!$bp && bp_is_group_invites()) { $bp = true; } elseif (!$bp && bp_is_group_members()) { $bp = true; } elseif (!$bp && bp_is_group_forum_topic()) { $bp = true; } elseif (!$bp && bp_is_group_forum_topic_edit()) { $bp = true; } elseif (!$bp && bp_is_group_forum()) { $bp = true; } elseif (!$bp && bp_is_group_admin_page()) { $bp = true; } elseif (!$bp && bp_is_group_create()) { $bp = true; } elseif (!$bp && bp_is_group_home()) { $bp = true; } elseif (!$bp && bp_is_single_activity()) { $bp = true; } elseif (!$bp && bp_is_register_page()) { $bp = true; } elseif (!$bp && bp_is_activation_page()) { $bp = true; } elseif (!$bp && !bp_is_blog_page()) { $bp = true; } return $bp; }
function body_class($wp_classes, $custom_classes = false) { global $bp; $bp_classes = array(); if (bp_is_directory()) { $bp_classes[] = 'directory'; } elseif (bp_is_single_item()) { $bp_classes[] = 'single-item'; } elseif (bp_is_activity_component() || $this->show_activity_page) { $bp_classes[] = 'activity'; } if ($this->adminbar && $this->theme->have_adminbar()) { $bp_classes[] = 'adminbar'; } if (!is_page() && is_front_page() && is_file(CHILD_DIR . '/home.php')) { $bp_classes[] = 'home'; } if ($this->show_activity_page) { $bp_classes[] = 'internal-page'; } elseif (!bp_is_blog_page()) { $wp_classes = array(); if (!bp_is_directory()) { $bp_classes[] = 'internal-page'; } if (bp_is_user_profile()) { $bp_classes[] = 'profile'; } elseif (bp_is_blogs_component()) { $bp_classes[] = 'blogs'; } elseif (bp_is_messages_component()) { $bp_classes[] = 'messages'; } elseif (bp_is_friends_component()) { $bp_classes[] = 'friends'; } elseif (bp_is_groups_component()) { $bp_classes[] = 'groups'; } elseif (bp_is_settings_component()) { $bp_classes[] = 'settings'; } } if (is_user_logged_in()) { $bp_classes[] = 'logged-in'; if (!bp_is_directory()) { if (bp_is_user_friends()) { $bp_classes[] = 'my-friends'; } elseif (bp_is_user_activity()) { $bp_classes[] = 'my-activity'; } elseif (bp_is_user_blogs()) { $bp_classes[] = 'my-blogs'; } elseif (bp_is_user_groups()) { $bp_classes[] = 'my-groups'; } elseif (bp_is_messages_inbox()) { $bp_classes[] = 'inbox'; } elseif (bp_is_messages_sentbox()) { $bp_classes[] = 'sentbox'; } elseif (bp_is_messages_compose_screen()) { $bp_classes[] = 'compose'; } elseif (bp_is_notices()) { $bp_classes[] = 'notices'; } elseif (bp_is_user_friend_requests()) { $bp_classes[] = 'friend-requests'; } elseif (bp_is_create_blog()) { $bp_classes[] = 'create-blog'; } elseif (bp_is_group_leave()) { $bp_classes[] = 'leave-group'; } elseif (bp_is_group_invites()) { $bp_classes[] = 'group-invites'; } elseif (bp_is_group_forum_topic_edit()) { $bp_classes[] = 'group-forum-topic-edit'; } elseif (bp_is_group_admin_page()) { $bp_classes[] = 'group-admin'; } elseif (bp_is_group_create()) { $bp_classes[] = 'group-create'; } elseif (bp_is_user_change_avatar()) { $bp_classes[] = 'change-avatar'; } elseif (bp_is_user_profile_edit()) { $bp_classes[] = 'profile-edit'; } } } else { $bp_classes[] = 'visitor'; } if (bp_is_group_members()) { $bp_classes[] = 'group-members'; } elseif (bp_is_group_home()) { $bp_classes[] = 'group-home'; } elseif (bp_is_group_forum()) { $bp_classes[] = 'group-forum'; if (bp_is_group_forum_topic()) { $bp_classes[] = 'group-forum-topic'; } } else { if (bp_is_user_recent_commments()) { $bp_classes[] = 'recent-comments'; } if (bp_is_user_recent_posts()) { $bp_classes[] = 'recent-posts'; } if (bp_is_user_friends_activity()) { $bp_classes[] = 'friends-activity'; } elseif (bp_is_single_activity()) { $bp_classes[] = 'activity-permalink'; } elseif (bp_is_register_page()) { $bp_classes[] = 'registration'; } elseif (bp_is_activation_page()) { $bp_classes[] = 'activation'; } } /* Add the current_component, current_action into the bp classes */ if (!bp_is_blog_page()) { if (!empty($bp->current_component)) { $bp_classes[] = $bp->current_component; } if (!empty($bp->current_action)) { $bp_classes[] = $bp->current_action; } } if ((!bp_is_blog_page() || is_home()) && !empty($custom_classes)) { $wp_classes = (array) $custom_classes; } /* Merge WP classes with BP classes */ $classes = array_merge((array) $bp_classes, (array) $wp_classes); /* Remove any duplicates */ $classes = array_unique($classes); return apply_filters('bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes); }
/** * Attach metadata about an activity item to the activity content. * * This metadata includes the time since the item was posted (which will appear * as a link to the item's permalink). * * @since 1.2.0 * * @global object $activities_template {@link BP_Activity_Template} * * @param string $content The activity content. * @return string The activity content with the metadata string attached. */ function bp_insert_activity_meta($content = '') { global $activities_template; // Strip any legacy time since placeholders from BP 1.0-1.1. $new_content = str_replace('<span class="time-since">%s</span>', '', $content); // Get the time since this activity was recorded. $date_recorded = bp_core_time_since($activities_template->activity->date_recorded); // Set up 'time-since' <span>. $time_since = sprintf('<span class="time-since" data-livestamp="%1$s">%2$s</span>', bp_core_get_iso8601_date($activities_template->activity->date_recorded), $date_recorded); /** * Filters the activity item time since markup. * * @since 1.2.0 * * @param array $value Array containing the time since markup and the current activity component. */ $time_since = apply_filters_ref_array('bp_activity_time_since', array($time_since, &$activities_template->activity)); // Insert the permalink. if (!bp_is_single_activity()) { // Setup variables for activity meta. $activity_permalink = bp_activity_get_permalink($activities_template->activity->id, $activities_template->activity); $activity_meta = sprintf('%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', $new_content, $activity_permalink, esc_attr__('View Discussion', 'buddypress'), $time_since); /** * Filters the activity permalink to be added to the activity content. * * @since 1.2.0 * * @param array $value Array containing the html markup for the activity permalink, after being parsed by * sprintf and current activity component. */ $new_content = apply_filters_ref_array('bp_activity_permalink', array($activity_meta, &$activities_template->activity)); } else { $new_content .= str_pad($time_since, strlen($time_since) + 2, ' ', STR_PAD_BOTH); } /** * Filters the activity content after activity metadata has been attached. * * @since 1.2.0 * * @param string $content Activity content with the activity metadata added. */ return apply_filters('bp_insert_activity_meta', $new_content, $content); }
?> </div> <?php } ?> </div> <?php do_action('bp_before_activity_entry_comments'); ?> <?php if (is_user_logged_in() && bp_activity_can_comment() || bp_is_single_activity()) { ?> <div class="activity-comments"> <?php bp_activity_comments(); ?> <?php if (is_user_logged_in()) { ?> <form action="<?php bp_activity_comment_form_action(); ?>
/** * Attach metadata about an activity item to the activity content. * * This metadata includes the time since the item was posted (which will appear * as a link to the item's permalink). * * @since BuddyPress (1.2.0) * * @global object $activities_template {@link BP_Activity_Template} * @uses bp_core_time_since() * @uses apply_filters_ref_array() To call the 'bp_activity_time_since' hook. * @uses bp_is_single_activity() * @uses bp_activity_get_permalink() * @uses esc_attr__() * @uses apply_filters_ref_array() To call the 'bp_activity_permalink' hook. * @uses apply_filters() To call the 'bp_insert_activity_meta' hook. * * @param string $content The activity content. * @return string The activity content with the metadata string attached. */ function bp_insert_activity_meta($content) { global $activities_template; // Strip any legacy time since placeholders from BP 1.0-1.1 $content = str_replace('<span class="time-since">%s</span>', '', $content); /** * Filters the activity item time since markup. * * @since BuddyPress (1.2.0) * * @param array $value Array containing the time since markup and the current activity component. */ $time_since = apply_filters_ref_array('bp_activity_time_since', array('<span class="time-since">' . bp_core_time_since($activities_template->activity->date_recorded) . '</span>', &$activities_template->activity)); // Insert the permalink if (!bp_is_single_activity()) { /** * Filters the activity permalink to be added to the activity content. * * @since BuddyPress (1.2.0) * * @param array $value Array containing the html markup for the activity permalink, after being parsed by sprintf and current activity component. */ $content = apply_filters_ref_array('bp_activity_permalink', array(sprintf('%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', $content, bp_activity_get_permalink($activities_template->activity->id, $activities_template->activity), esc_attr__('View Discussion', 'buddypress'), $time_since), &$activities_template->activity)); } else { $content .= str_pad($time_since, strlen($time_since) + 2, ' ', STR_PAD_BOTH); } /** * Filters the activity content after activity metadata has been attached. * * @since BuddyPress (1.2.0) * * @param string $content Activity content with the activity metadata added. */ return apply_filters('bp_insert_activity_meta', $content); }
function rtmedia_wpseo_og_image($data) { global $wp_query; if (class_exists("BuddyPress")) { global $bp; if (bp_is_single_activity()) { $mediaObj = new RTMediaModel(); $media_details = $mediaObj->get(array('activity_id' => $bp->current_action)); foreach ($media_details as $media) { if ($media->media_type == 'photo') { $img = wp_get_attachment_image_src($media->media_id, "full"); if ($img && isset($img[0]) && $img[0] != "") { echo "<meta property='og:image' content='" . esc_url($img[0]) . "' />\n"; } } } } } if (array_key_exists('media', $wp_query->query_vars)) { global $rtmedia_query; if (isset($rtmedia_query->media) && $rtmedia_query->media && count($rtmedia_query->media) > 0) { foreach ($rtmedia_query->media as $media) { $img = wp_get_attachment_image_src($media->media_id, "full"); if ($img && isset($img[0]) && $img[0] != "") { echo "<meta property='og:image' content='" . esc_url($img[0]) . "' />\n"; } } } } return $data; }
function dwqa_replace_activity_meta() { global $activities_template; $blog_url = bp_blogs_get_blogmeta($activity->item_id, 'url'); $blog_name = bp_blogs_get_blogmeta($activity->item_id, 'name'); if (empty($blog_url) || empty($blog_name)) { $blog_url = get_home_url($activity->item_id); $blog_name = get_blog_option($activity->item_id, 'blogname'); bp_blogs_update_blogmeta($activity->item_id, 'url', $blog_url); bp_blogs_update_blogmeta($activity->item_id, 'name', $blog_name); } $post_url = add_query_arg('p', $activities_template->activity->secondary_item_id, trailingslashit($blog_url)); $post_title = bp_activity_get_meta($activities_template->activity->id, 'post_title'); if (empty($post_title)) { $post = get_post($activities_template->activity->secondary_item_id); if (is_a($post, 'WP_Post')) { $post_title = $post->post_title; bp_activity_update_meta($activities_template->activity->id, 'post_title', $post_title); } } $post_link = '<a href="' . $post_url . '">' . $post_title . '</a>'; $user_link = bp_core_get_userlink($activities_template->activity->user_id); if ($activities_template->activity->type == 'new_question') { $action = sprintf(__('%1$s asked a new question: %2$s', 'dwqa'), $user_link, $post_link); } elseif ($activities_template->activity->type == 'new_answer') { $action = sprintf(__('%1$s answered the question: %2$s', 'dwqa'), $user_link, $post_link); } elseif ($activities_template->activity->type == 'comment_question') { $action = sprintf(__('%1$s commented on the question: %2$s', 'dwqa'), $user_link, $post_link); } elseif ($activities_template->activity->type == 'comment_answer') { $action = sprintf(__('%1$s commented on the answer at: %2$s', 'dwqa'), $user_link, $post_link); } else { $action = $activities_template->activity->action; } // Strip any legacy time since placeholders from BP 1.0-1.1 $content = str_replace('<span class="time-since">%s</span>', '', $content); // Insert the time since. $time_since = apply_filters_ref_array('bp_activity_time_since', array('<span class="time-since">' . bp_core_time_since($activities_template->activity->date_recorded) . '</span>', &$activities_template->activity)); // Insert the permalink if (!bp_is_single_activity()) { $content = apply_filters_ref_array('bp_activity_permalink', array(sprintf('%1$s <a href="%2$s" class="view activity-time-since" title="%3$s">%4$s</a>', $content, bp_activity_get_permalink($activities_template->activity->id, $activities_template->activity), esc_attr__('View Discussion', 'buddypress'), $time_since), &$activities_template->activity)); } else { $content .= str_pad($time_since, strlen($time_since) + 2, ' ', STR_PAD_BOTH); } echo $action . ' ' . $content; // echo 'abc'; // echo $activities_template->activity->content; }
/** Activity ******************************************************************/ function bp_is_activity_permalink() { _deprecated_function(__FUNCTION__, '1.5', 'bp_is_single_activity'); bp_is_single_activity(); }
/** * Truncate long activity entries when viewed in activity streams. * * @since BuddyPress (1.5.0) * * @uses bp_is_single_activity() * @uses apply_filters() To call the 'bp_activity_excerpt_append_text' hook. * @uses apply_filters() To call the 'bp_activity_excerpt_length' hook. * @uses bp_create_excerpt() * @uses bp_get_activity_id() * @uses bp_get_activity_thread_permalink() * @uses apply_filters() To call the 'bp_activity_truncate_entry' hook. * * @param string $text The original activity entry text. * @return string $excerpt The truncated text. */ function bp_activity_truncate_entry($text) { global $activities_template; // The full text of the activity update should always show on the single activity screen if (bp_is_single_activity()) { return $text; } /** * Filters the appended text for the activity excerpt. * * @since BuddyPress (1.5.0) * * @param string $read_more Internationalized "Read more" text. */ $append_text = apply_filters('bp_activity_excerpt_append_text', __('[Read more]', 'buddypress')); /** * Filters the excerpt length for the activity excerpt. * * @since BuddyPress (1.5.0) * * @param int $excerpt_length Number indicating how many words to trim the excerpt down to. */ $excerpt_length = apply_filters('bp_activity_excerpt_length', 358); // Run the text through the excerpt function. If it's too short, the original text will be // returned. $excerpt = bp_create_excerpt($text, $excerpt_length, array('ending' => __('…', 'buddypress'))); // If the text returned by bp_create_excerpt() is different from the original text (ie it's // been truncated), add the "Read More" link. Note that bp_create_excerpt() is stripping // shortcodes, so we have strip them from the $text before the comparison if ($excerpt != strip_shortcodes($text)) { $id = !empty($activities_template->activity->current_comment->id) ? 'acomment-read-more-' . $activities_template->activity->current_comment->id : 'activity-read-more-' . bp_get_activity_id(); $excerpt = sprintf('%1$s<span class="activity-read-more" id="%2$s"><a href="%3$s" rel="nofollow">%4$s</a></span>', $excerpt, $id, bp_get_activity_thread_permalink(), $append_text); } /** * Filters the composite activity excerpt entry. * * @since BuddyPress (1.5.0) * * @param string $excerpt Excerpt text and markup to be displayed. * @param string $text The original activity entry text. * @param string $append_text The final append text applied. */ return apply_filters('bp_activity_truncate_entry', $excerpt, $text, $append_text); }