/** * Should we use Heartbeat to refresh activities? * * @since BuddyPress (2.0.0) * * @uses bp_is_activity_heartbeat_active() to check if heatbeat setting is on. * @uses bp_is_activity_directory() to check if the current page is the activity * directory. * @uses bp_is_active() to check if the group component is active. * @uses bp_is_group_activity() to check if on a single group, the current page * is the group activities. * @uses bp_is_group_home() to check if the current page is a single group home * page. * * @return bool True if activity heartbeat is enabled, otherwise false. */ function bp_activity_do_heartbeat() { $retval = false; if (!bp_is_activity_heartbeat_active()) { return $retval; } if (bp_is_activity_directory()) { $retval = true; } if (bp_is_active('groups')) { // If no custom front, then activities are loaded in group's home $has_custom_front = bp_locate_template(array('groups/single/front.php'), false, true); if (bp_is_group_activity() || !$has_custom_front && bp_is_group_home()) { $retval = true; } } return $retval; }
<?php /** * Fires after the display of the group status message. * * @since 1.1.0 */ do_action('bp_after_group_status_message'); } // Not looking at home } else { // Group Admin if (bp_is_group_admin_page()) { bp_get_template_part('groups/single/admin'); // Group Activity } elseif (bp_is_group_activity()) { bp_get_template_part('groups/single/activity'); // Group Members } elseif (bp_is_group_members()) { bp_groups_members_template_part(); // Group Invitations } elseif (bp_is_group_invites()) { bp_get_template_part('groups/single/send-invites'); // Old group forums } elseif (bp_is_group_forum()) { bp_get_template_part('groups/single/forum'); // Membership request } elseif (bp_is_group_membership_request()) { bp_get_template_part('groups/single/request-membership'); // Anything else (plugins mostly) } else {
/** * Should we use Heartbeat to refresh activities? * * @since 2.0.0 * * @uses bp_is_activity_heartbeat_active() to check if heartbeat setting is on. * @uses bp_is_activity_directory() to check if the current page is the activity * directory. * @uses bp_is_group_activity() to check if on a single group, the current page * is the group activities. * * @return bool True if activity heartbeat is enabled, otherwise false. */ function bp_activity_do_heartbeat() { $retval = false; if (!bp_is_activity_heartbeat_active()) { return $retval; } if (bp_is_activity_directory() || bp_is_group_activity()) { $retval = true; } return $retval; }
/** * Should BuddyPress load the mentions scripts and related assets, including results to prime the * mentions suggestions? * * @param bool $load_mentions True to load mentions assets, false otherwise. * @param bool $mentions_enabled True if mentions are enabled. * @return bool True if mentions scripts should be loaded. * @since BuddyPress (2.2.0) */ function bp_groups_maybe_load_mentions_scripts($load_mentions, $mentions_enabled) { if (!$mentions_enabled) { return $load_mentions; } if ($load_mentions || (bp_is_group_activity() || bp_is_group_home())) { return true; } return $load_mentions; }
/** * Should we use Heartbeat to refresh activities? * * @since 2.0.0 * * @return bool True if activity heartbeat is enabled, otherwise false. */ function bp_activity_do_heartbeat() { $retval = false; if (bp_is_activity_heartbeat_active() && (bp_is_activity_directory() || bp_is_group_activity())) { $retval = true; } /** * Filters whether the heartbeat feature in the activity stream should be active. * * @since 2.8.0 * * @param bool $retval Whether or not activity heartbeat is active. */ return (bool) apply_filters('bp_activity_do_heartbeat', $retval); }
/** * */ function miss_is_bp() { if (function_exists('bp_is_group') && (bp_is_blog_page() || bp_is_my_profile() || bp_is_my_profile() || is_front_page() || bp_is_component_front_page('activity') || bp_is_directory() || bp_is_profile_component() || bp_is_activity_component() || bp_is_blogs_component() || bp_is_messages_component() || bp_is_friends_component() || bp_is_groups_component() || bp_is_settings_component() || bp_is_user_activity() || bp_is_user_friends_activity() || bp_is_activity_permalink() || bp_is_user_profile() || bp_is_profile_edit() || bp_is_change_avatar() || bp_is_user_groups() || bp_is_group() || bp_is_group_home() || bp_is_group_create() || bp_is_group_admin_page() || bp_is_group_forum() || bp_is_group_activity() || bp_is_group_forum_topic() || bp_is_group_forum_topic_edit() || bp_is_group_members() || bp_is_group_invites() || bp_is_group_membership_request() || bp_is_group_leave() || bp_is_group_single() || bp_is_user_blogs() || bp_is_user_recent_posts() || bp_is_user_recent_commments() || bp_is_create_blog() || bp_is_user_friends() || bp_is_friend_requests() || bp_is_user_messages() || bp_is_messages_inbox() || bp_is_messages_sentbox() || bp_is_notices() || bp_is_messages_compose_screen() || bp_is_activation_page() || bp_is_register_page())) { return true; } return false; }
/** * Get the page context * @version 2.0 */ function get_context() { // Setup placeholders $title = SITENAME; $desc = get_bloginfo('description'); $classes = get_body_class(); $crumbs = array(); // Get some data $id = $this->queried_object_id; $object = $this->queried_object; $sep = " • "; /*-------------------------------------------- DEFAULT CONTEXT ---------------------------------------------*/ $classes[] = 0 == get_current_user_id() ? 'logged-out' : 'logged-in'; $crumbs[] = '<a href="' . SITEURL . '" title="' . SITENAME . '" rel="home" class="trail-home">Home</a>'; // Homepage if (is_home()) { $title = SITENAME . $sep . 'Home'; $classes[] = 'home'; $classes[] = 'sidebar'; $classes[] = 'archive'; /*-------------------------------------------- BUDDYPRESS CONTEXT ---------------------------------------------*/ } elseif (class_exists('BuddyPress') && is_buddypress()) { // BuddyPress Defaults $title = "BuddyPress Page"; $desc = "This is a BuddyPress page."; $classes[] = 'buddypress'; // User Profiles if (bp_is_user()) { $title = bp_get_displayed_user_fullname() . $sep . "User Profile"; $desc = SITENAME . " user profile for member " . bp_get_displayed_user_fullname(); // Your own profile if (bp_is_my_profile()) { $crumbs[] = 'Your Profile'; } else { $crumbs[] = '<a href="' . bp_get_members_directory_permalink() . '" title="Members Directory">Members</a>'; $crumbs[] = '<a href="' . bp_displayed_user_domain() . '" title="' . bp_get_displayed_user_fullname() . '">' . bp_get_displayed_user_fullname() . '</a>'; } // Display the profile component if it isnt the profile home if (!bp_is_user_profile()) { $crumbs[] = ucfirst(bp_current_component()); } // Display the current action if it is not the default public profile if (!in_array(bp_current_action(), array('public', 'just-me', 'my-friends'))) { $crumbs[] = ucfirst(bp_current_action()); } // Single Group } elseif (bp_is_group() || bp_is_group_create()) { // Group Creation if (bp_is_group_create()) { $title = 'Submit New Group'; $desc = 'Submit a new user group for listing on the ' . SITENAME . ' community groups directory.'; $crumbs[] = '<a href="' . SITEURL . '/' . bp_get_groups_root_slug() . '" title="Groups Directory">Groups</a>'; $crumbs[] = 'Create Group'; } elseif (bp_is_group()) { // Default entries $title = bp_get_group_name(); $desc = SITENAME . ' guild profile for ' . bp_get_group_name(); $classes = array_diff($classes, array('page', 'page-template-default')); $crumbs[] = '<a href="' . bp_get_groups_directory_permalink() . '" title="Groups Directory">Groups</a>'; // Group Profile Home if (bp_is_group_home()) { $title = $title . $sep . 'Profile'; $crumbs[] = bp_get_group_name(); // Advanced Component } else { // Link back to group profile $crumbs[] = '<a href="' . bp_get_group_permalink() . '" title="Return to Group Profile">' . bp_get_group_name() . '</a>'; // Members if (bp_is_group_members()) { $title = $title . $sep . 'Members'; $crumbs[] = 'Members'; // Activity } elseif (bp_is_group_activity()) { $title = $title . $sep . 'Activity'; $crumbs[] = 'Activity'; // Invites } elseif (bp_is_group_invites()) { $title = $title . $sep . 'Invitations'; $crumbs[] = 'Invitations'; // Admin } elseif (bp_is_group_admin_page()) { $title = $title . $sep . 'Admin'; $crumbs[] = 'Admin'; // Forum } else { // Forum Root if (NULL == bp_action_variable()) { $title = $title . $sep . 'Forum'; $crumbs[] = 'Forum'; // Sub-Component } else { $crumbs[] = '<a href="' . bp_get_group_permalink() . 'forum/" title="Group Forum">Forum</a>'; // Retrieve topic information from the database global $bp; global $wpdb; // Single Topic if (bp_is_action_variable('topic', 0)) { // Get the topic $topic = $wpdb->get_row($wpdb->prepare("SELECT post_title AS title, post_name AS url\n\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts} \n\t\t\t\t\t\t\t\t\t\tWHERE post_name = %s", $bp->action_variables[1])); $title = $topic->title; $crumbs[] = $topic->title; // Replies } elseif (bp_is_action_variable('reply', 0)) { // Get the reply parent topic $topic = $wpdb->get_row($wpdb->prepare("SELECT post_title AS title, post_name AS url\n\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts} \n\t\t\t\t\t\t\t\t\t\tWHERE ID = ( \n\t\t\t\t\t\t\t\t\t\t\tSELECT post_parent\n\t\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->posts}\n\t\t\t\t\t\t\t\t\t\t\tWHERE post_name = %s \n\t\t\t\t\t\t\t\t\t\t)", $bp->action_variables[1])); $title = $topic->title; $crumbs[] = $topic->title; } // Topic and Reply Edits if (bp_is_action_variable('edit', 2)) { $crumbs[] = 'Edit'; } } } } } // Directories } elseif (bp_is_directory()) { // Sitewide Activity if (bp_is_activity_component()) { $title = SITENAME . ' Sitewide Activity Feed'; $desc = 'A listing of all recent activity happening throughout the ' . SITENAME . ' community.'; $crumbs[] = 'Sitewide Activity'; // Members Directory } elseif (bp_is_members_component()) { $title = SITENAME . ' Members Directory'; $desc = 'A listing of all registered members in the ' . SITENAME . ' community.'; $crumbs[] = 'Members Directory'; // Groups Directory } elseif (bp_is_groups_component()) { $title = SITENAME . ' Guilds Directory'; $desc = 'A directory listing of guilds active within in the ' . SITENAME . ' community.'; $crumbs[] = 'Guilds Directory'; } // Registration } elseif (bp_is_register_page()) { $title = SITENAME . ' User Registration'; $desc = "Register to join the " . SITENAME . " community."; $crumbs[] = "User Registration"; // Activation } elseif (bp_is_activation_page()) { $title = SITENAME . ' Account Activation'; $desc = "Activate a pending " . SITENAME . " user account."; $crumbs[] = "Account Activation"; } /*-------------------------------------------- BBPRESS CONTEXT ---------------------------------------------*/ } elseif (class_exists('bbPress') && is_bbpress()) { // bbPress Defaults $classes[] = 'bbpress'; $classes[] = 'forums'; $crumbs[] = bbp_is_forum_archive() ? "Forums" : '<a href="' . get_post_type_archive_link('forum') . '">Forums</a>'; // Main Forum Archive if (bbp_is_forum_archive()) { $title = SITENAME . " Forums"; $desc = "Get involved in the community on the " . SITENAME . " forums."; // Recent Topics } elseif (bbp_is_topic_archive()) { $title = "Recent Topics in the " . SITENAME . " Forums"; $desc = "Browse a list of the most recent topics in the " . SITENAME . " Forums."; $crumbs[] = "Recent Topics"; // Single Forum } elseif (bbp_is_single_forum()) { $title = $object->post_title; $desc = $object->post_content; // Loop through parent forums $parent_id = bbp_get_forum_parent_id($id); if (0 != $parent_id) { $crumbs = array_merge($crumbs, $this->parent_crumbs($parent_id)); } $crumbs[] = $object->post_title; // Single Topic } elseif (bbp_is_single_topic()) { $title = $object->post_title; $desc = bbp_get_topic_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs(bbp_get_topic_forum_id($id))); $crumbs[] = $object->post_title; // Edit Topic } elseif (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) { $title = 'Edit Topic' . $sep . $object->post_title; $desc = bbp_get_topic_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs($id)); // Tag the specific task if (bbp_is_topic_split()) { $crumbs[] = 'Split Topic'; } elseif (bbp_is_topic_merge()) { $crumbs[] = 'Merge Topic'; } elseif (bbp_is_topic_edit()) { $crumbs[] = 'Edit Topic'; } // Edit Reply } elseif (bbp_is_reply_edit()) { $title = 'Edit Reply' . $sep . bbp_get_reply_topic_title($id); $desc = bbp_get_reply_excerpt($id); $crumbs = array_merge($crumbs, $this->parent_crumbs(bbp_get_reply_topic_id($id))); $crumbs[] = 'Edit Reply'; } /*-------------------------------------------- WORDPRESS CONTEXT ---------------------------------------------*/ } else { // Singular Posts and Pages if (is_singular()) { $title = $object->post_title; $desc = get_post_meta($id, 'description', true); // If no description is found, use an excerpt if (empty($desc)) { $desc = get_post_field('post_excerpt', $id); } // Check for custom template $template = get_post_meta($id, "_wp_{$object->post_type}_template", true); if ('' != $template) { $template = str_replace(array("{$object->post_type}-template-", "{$object->post_type}-"), '', basename($template, '.php')); $classes[] = "{$template}-template"; } // Generate breadcrumbs by post type switch ($object->post_type) { // Single Posts case 'post': // Is the post in a category? $categories = get_the_category(); if ($categories) { // Start with the first category $term = $categories[0]; // If the category has a parent, add it to the trail. if (0 != $term->parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($term->parent, 'category')); } // Add the category archive link to the trail. $crumbs[] = '<a href="' . get_term_link($term) . '" title="' . esc_attr($term->name) . '">' . $term->name . '</a>'; } // Does the post have an ancestor? if ($object->post_parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($object->post_parent)); } // Editing a comment on this post if (is_comment_edit()) { $crumbs[] = '<a href="' . get_permalink() . '" title="Return to article">' . get_the_title() . '</a>'; $crumbs[] = 'Edit Comment'; // Reading the post } else { $crumbs[] = get_the_title(); } break; // Pages // Pages case 'page': // Does the page have an ancestor? if ($object->post_parent) { $crumbs = array_merge($crumbs, $this->parent_crumbs($object->post_parent)); } // Otherwise, viewing the page $crumbs[] = get_the_title(); break; // Events // Events case 'event': // Get the calendar the event belongs to $calendar = get_the_terms($object->ID, 'calendar'); $calendar = array_shift($calendar); $desc = 'Upcoming event on the ' . $calendar->name . ' calendar.'; $crumbs[] = '<a href="' . SITEURL . '/calendar/' . $calendar->slug . '" title="' . $calendar->name . ' Calendar">' . $calendar->name . ' Calendar</a>'; $crumbs[] = get_the_title(); break; } // Archives } elseif (is_archive()) { // Category Archives if (is_category()) { $crumbs[] = 'Category'; // If the category has a parent, add it to the trail. if ($object->parent != 0) { $crumbs = array_merge($crumbs, $this->trail_parents($object->parent)); } // Finish up with the term name $crumbs[] = $object->name; // Author Archive } elseif (is_author()) { $title = 'Author Archive' . $sep . $object->display_name; $desc = 'An archive of articles written by ' . $object->display_name; $crumbs[] = 'Author'; $crumbs[] = $object->display_name; // Advanced Search Page } elseif (is_search()) { $title = SITENAME . " Advanced Search"; $desc = "Search for a variety of content types throughout " . SITENAME; $crumbs[] = 'Advanced Search'; $classes[] = 'page'; // Calendar } elseif (is_calendar()) { $title = $object->name . " Calendar"; $desc = "Upcoming events on the " . $object->name . " calendar."; $crumbs[] = $object->name . " Calendar"; } // 404 } elseif (is_404()) { $title = "Error" . $sep . "Page Not Found"; $desc = "Sorry, but this page does not exist, or is not accessible at this time."; $classes[] = 'page'; $crumbs[] = '404 Page Not Found'; } } /*-------------------------------------------- RETURN DATA ---------------------------------------------*/ $this->title = html_entity_decode($title); $this->description = html_entity_decode($desc); $this->classes = $classes; $this->crumbs = $crumbs; }
/** * Extends the default WordPress body classes. * * @since Boss 1.0.0 * * @param array Existing class values. * @return array Filtered class values. */ function buddyboss_body_class($classes) { global $wp_customize; if (!empty($wp_customize)) { $classes[] = 'wp-customizer'; } if (!is_multi_author()) { $classes[] = 'single-author'; } if (current_user_can('manage_options')) { $classes[] = 'role-admin'; } if (bp_is_user_activity() || bp_is_group_home() && bp_is_active('activity') || bp_is_group_activity() || bp_is_current_component('activity')) { $classes[] = 'has-activity'; } return array_unique($classes); }
/** * Similar to the post_class() function, but for BP. This is NOT used by core Suffusion, but is useful for child themes using BP. * This might be defined by the Suffusion BuddyPress Pack for BP users of Suffusion, but is included conditionally here so * that the theme and the plugin can be used independently of each other and so that one version of Suffusion can work with an older * version of the BP pack. * * @since 3.6.7 * @param bool $custom * @param bool $echo * @return bool|string */ function suffusion_bp_content_class($custom = false, $echo = true) { if (!function_exists('bp_is_group')) { return false; } $css = array(); $css[] = 'post'; if (function_exists('bp_is_profile_component') && bp_is_profile_component()) { $css[] = 'profile-component'; } if (function_exists('bp_is_activity_component') && bp_is_activity_component()) { $css[] = 'activity-component'; } if (function_exists('bp_is_blogs_component') && bp_is_blogs_component()) { $css[] = 'blogs-component'; } if (function_exists('bp_is_messages_component') && bp_is_messages_component()) { $css[] = 'messages-component'; } if (function_exists('bp_is_friends_component') && bp_is_friends_component()) { $css[] = 'friends-component'; } if (function_exists('bp_is_groups_component') && bp_is_groups_component()) { $css[] = 'groups-component'; } if (function_exists('bp_is_settings_component') && bp_is_settings_component()) { $css[] = 'settings-component'; } if (function_exists('bp_is_member') && bp_is_member()) { $css[] = 'member'; } if (function_exists('bp_is_user_activity') && bp_is_user_activity()) { $css[] = 'user-activity'; } if (function_exists('bp_is_user_friends_activity') && bp_is_user_friends_activity()) { $css[] = 'user-friends-activity'; } if (function_exists('bp_is_activity_permalink') && bp_is_activity_permalink()) { $css[] = 'activity-permalink'; } if (function_exists('bp_is_user_profile') && bp_is_user_profile()) { $css[] = 'user-profile'; } if (function_exists('bp_is_profile_edit') && bp_is_profile_edit()) { $css[] = 'profile-edit'; } if (function_exists('bp_is_change_avatar') && bp_is_change_avatar()) { $css[] = 'change-avatar'; } if (function_exists('bp_is_user_groups') && bp_is_user_groups()) { $css[] = 'user-groups'; } if (function_exists('bp_is_group') && bp_is_group()) { $css[] = 'group'; } if (function_exists('bp_is_group_home') && bp_is_group_home()) { $css[] = 'group-home'; } if (function_exists('bp_is_group_create') && bp_is_group_create()) { $css[] = 'group-create'; } if (function_exists('bp_is_group_admin_page') && bp_is_group_admin_page()) { $css[] = 'group-admin-page'; } if (function_exists('bp_is_group_forum') && bp_is_group_forum()) { $css[] = 'group-forum'; } if (function_exists('bp_is_group_activity') && bp_is_group_activity()) { $css[] = 'group-activity'; } if (function_exists('bp_is_group_forum_topic') && bp_is_group_forum_topic()) { $css[] = 'group-forum-topic'; } if (function_exists('bp_is_group_forum_topic_edit') && bp_is_group_forum_topic_edit()) { $css[] = 'group-forum-topic-edit'; } if (function_exists('bp_is_group_members') && bp_is_group_members()) { $css[] = 'group-members'; } if (function_exists('bp_is_group_invites') && bp_is_group_invites()) { $css[] = 'group-invites'; } if (function_exists('bp_is_group_membership_request') && bp_is_group_membership_request()) { $css[] = 'group-membership-request'; } if (function_exists('bp_is_group_leave') && bp_is_group_leave()) { $css[] = 'group-leave'; } if (function_exists('bp_is_group_single') && bp_is_group_single()) { $css[] = 'group-single'; } if (function_exists('bp_is_user_blogs') && bp_is_user_blogs()) { $css[] = 'user-blogs'; } if (function_exists('bp_is_user_recent_posts') && bp_is_user_recent_posts()) { $css[] = 'user-recent-posts'; } if (function_exists('bp_is_user_recent_commments') && bp_is_user_recent_commments()) { $css[] = 'user-recent-commments'; } if (function_exists('bp_is_create_blog') && bp_is_create_blog()) { $css[] = 'create-blog'; } if (function_exists('bp_is_user_friends') && bp_is_user_friends()) { $css[] = 'user-friends'; } if (function_exists('bp_is_friend_requests') && bp_is_friend_requests()) { $css[] = 'friend-requests'; } if (function_exists('bp_is_user_messages') && bp_is_user_messages()) { $css[] = 'user-messages'; } if (function_exists('bp_is_messages_inbox') && bp_is_messages_inbox()) { $css[] = 'messages-inbox'; } if (function_exists('bp_is_messages_sentbox') && bp_is_messages_sentbox()) { $css[] = 'messages-sentbox'; } if (function_exists('bp_is_notices') && bp_is_notices()) { $css[] = 'notices'; } if (function_exists('bp_is_messages_compose_screen') && bp_is_messages_compose_screen()) { $css[] = 'messages-compose-screen'; } if (function_exists('bp_is_single_item') && bp_is_single_item()) { $css[] = 'single-item'; } if (function_exists('bp_is_activation_page') && bp_is_activation_page()) { $css[] = 'activation-page'; } if (function_exists('bp_is_register_page') && bp_is_register_page()) { $css[] = 'register-page'; } $css[] = 'fix'; if (is_array($custom)) { foreach ($custom as $class) { if (!in_array($class, $css)) { $css[] = esc_attr($class); } } } else { if ($custom != false) { $css[] = $custom; } } $css_class = implode(' ', $css); if ($echo) { echo ' class="' . $css_class . '" '; } return ' class="' . $css_class . '" '; }