function bp_get_template_part($slug, $name = null) { // Execute code for this part do_action('get_template_part_' . $slug, $slug, $name); // Setup possible parts $templates = array(); if (isset($name)) { $templates[] = $slug . '-' . $name . '.php'; } $templates[] = $slug . '.php'; // Allow template parts to be filtered $templates = apply_filters('bp_get_template_part', $templates, $slug, $name); // Return the part that is found return bp_locate_template($templates, true, false); }
/** * Hook this extension's Edit panel into BuddyPress, if necessary * * @since BuddyPress (1.8) */ protected function setup_edit_hooks() { // Bail if not an edit screen if (!$this->is_screen_enabled('edit') || !bp_is_item_admin()) { return; } $screen = $this->screens['edit']; $position = isset($screen['position']) ? (int) $screen['position'] : 10; // Add the tab // @todo BP should be using bp_core_new_subnav_item() add_action('groups_admin_tabs', create_function('$current, $group_slug', '$selected = ""; if ( "' . esc_attr($screen['slug']) . '" == $current ) $selected = " class=\\"current\\""; echo "<li{$selected}><a href=\\"' . trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/{$group_slug}/admin/' . esc_attr($screen['slug'])) . '\\">' . esc_attr($screen['name']) . '</a></li>";'), $position, 2); // Catch the edit screen and forward it to the plugin template if (bp_is_groups_component() && bp_is_current_action('admin') && bp_is_action_variable($screen['slug'], 0)) { $this->call_edit_screen_save($this->group_id); add_action('groups_custom_edit_steps', array(&$this, 'call_edit_screen')); // Determine the proper template and save for later // loading if ('' !== bp_locate_template(array('groups/single/home.php'), false)) { $this->edit_screen_template = '/groups/single/home'; } else { add_action('bp_template_content_header', create_function('', 'echo "<ul class=\\"content-header-nav\\">"; bp_group_admin_tabs(); echo "</ul>";')); add_action('bp_template_content', array(&$this, 'call_edit_screen')); $this->edit_screen_template = '/groups/single/plugins'; } // We load the template at bp_screens, to give all // extensions a chance to load add_action('bp_screens', array($this, 'call_edit_screen_template_loader')); } }
/** * @deprecated BuddyPress (1.7) */ function bp_get_plugin_sidebar() { _deprecated_function(__FUNCTION__, '1.7'); bp_locate_template(array('plugin-sidebar.php'), true); }
/** * Set the Post object containing the email content template. * * Also sets the email's subject, content, and template from the Post, for convenience. * * @since 2.5.0 * * @param WP_Post $post * @return BP_Email */ public function set_post_object(WP_Post $post) { /** * Filters the new value of the email's "post object" property. * * @since 2.5.0 * * @param WP_Post $post A Post. * @param BP_Email $this Current instance of the email type class. */ $this->post_object = apply_filters('bp_email_set_post_object', $post, $this); if (is_a($this->post_object, 'WP_Post')) { $this->set_subject($this->post_object->post_title)->set_content_html($this->post_object->post_content)->set_content_plaintext($this->post_object->post_excerpt); ob_start(); // Load the template. add_filter('bp_locate_template_and_load', '__return_true'); bp_locate_template(bp_email_get_template($this->post_object), true, false); remove_filter('bp_locate_template_and_load', '__return_true'); $this->set_template(ob_get_contents()); ob_end_clean(); } return $this; }
/** * Hook this extension's Edit panel into BuddyPress, if necessary. * * @since BuddyPress (1.8.0) */ protected function setup_edit_hooks() { // Bail if not in a group if (!bp_is_group()) { return; } // Bail if not an edit screen if (!$this->is_screen_enabled('edit') || !bp_is_item_admin()) { return; } $screen = $this->screens['edit']; $position = isset($screen['position']) ? (int) $screen['position'] : 10; $position += 40; $current_group = groups_get_current_group(); $admin_link = trailingslashit(bp_get_group_permalink($current_group) . 'admin'); $subnav_args = array('name' => $screen['name'], 'slug' => $screen['slug'], 'parent_slug' => $current_group->slug . '_manage', 'parent_url' => trailingslashit(bp_get_group_permalink($current_group) . 'admin'), 'user_has_access' => bp_is_item_admin(), 'position' => $position, 'screen_function' => 'groups_screen_group_admin'); // Should we add a menu to the Group's WP Admin Bar if (!empty($screen['show_in_admin_bar'])) { $subnav_args['show_in_admin_bar'] = true; } // Add the tab to the manage navigation bp_core_new_subnav_item($subnav_args); // Catch the edit screen and forward it to the plugin template if (bp_is_groups_component() && bp_is_current_action('admin') && bp_is_action_variable($screen['slug'], 0)) { $this->call_edit_screen_save($this->group_id); add_action('groups_custom_edit_steps', array(&$this, 'call_edit_screen')); // Determine the proper template and save for later // loading if ('' !== bp_locate_template(array('groups/single/home.php'), false)) { $this->edit_screen_template = '/groups/single/home'; } else { add_action('bp_template_content_header', create_function('', 'echo "<ul class=\\"content-header-nav\\">"; bp_group_admin_tabs(); echo "</ul>";')); add_action('bp_template_content', array(&$this, 'call_edit_screen')); $this->edit_screen_template = '/groups/single/plugins'; } // We load the template at bp_screens, to give all // extensions a chance to load add_action('bp_screens', array($this, 'call_edit_screen_template_loader')); } }
/** * Loops through a level of activity comments and loads the template for each * * Note: The recursion itself used to happen entirely in this function. Now it is * split between here and the comment.php template. * * @since BuddyPress (1.2) * * @todo remove $counter global * * @param object $comment The activity object currently being recursed * * @global object $activities_template {@link BP_Activity_Template} * @uses locate_template() */ function bp_activity_recurse_comments($comment) { global $activities_template; if (empty($comment)) { return false; } if (empty($comment->children)) { return false; } echo apply_filters('bp_activity_recurse_comments_start_ul', '<ul>'); foreach ((array) $comment->children as $comment_child) { // Put the comment into the global so it's available to filters $activities_template->activity->current_comment = $comment_child; $template = bp_locate_template('activity/comment.php', false, false); // Backward compatibility. In older versions of BP, the markup was // generated in the PHP instead of a template. This ensures that // older themes (which are not children of bp-default and won't // have the new template) will still work. if (!$template) { $template = BP_PLUGIN_DIR . '/bp-themes/bp-default/activity/comment.php'; } load_template($template, false); unset($activities_template->activity->current_comment); } echo apply_filters('bp_activity_recurse_comments_end_ul', '</ul>'); }
function invite_anyone_create_screen_content($event) { if (!($template = function_exists('bp_locate_template') ? bp_locate_template('groups/single/invite-anyone.php', true) : locate_template('groups/single/invite-anyone.php', true))) { include_once 'templates/invite-anyone.php'; } }
/** * Do we have a working custom activation page? * * @since 1.5.0 * * @uses bp_get_activate_slug() To make sure there is a slug assigned to the page. * @uses bp_locate_template() To make sure a template exists to provide output. * @return boolean True if page and template exist, false if not. */ function bp_has_custom_activation_page() { static $has_page = false; if (empty($has_page)) { $has_page = bp_get_activate_slug() && bp_locate_template(array('registration/activate.php', 'members/activate.php', 'activate.php'), false); } return (bool) $has_page; }
?> <div class="<?php bp_docs_container_class(); ?> "> <?php include apply_filters('bp_docs_header_template', bp_docs_locate_template('docs-header.php')); ?> <?php if (current_user_can('bp_docs_manage_folders') && bp_docs_is_folder_manage_view()) { ?> <?php bp_locate_template('docs/manage-folders.php', true); } else { ?> <h2 class="directory-title"> <?php bp_docs_directory_breadcrumb(); ?> </h2> <div class="docs-info-header"> <?php bp_docs_info_header(); ?> </div>
function devb_aawire_post_update() { global $bp; $is_wire_post = false; /* Check the nonce */ check_admin_referer('post_update', '_wpnonce_post_update'); if (!is_user_logged_in()) { echo '-1'; exit(0); } if (empty($_POST['content'])) { echo '-1<div id="message"><p>' . __('Please enter some content to post.', 'buddypress') . '</p></div>'; exit(0); } if (empty($_POST['object']) && function_exists('bp_activity_post_update')) { //this is what I have changed if (!bp_is_my_profile() && bp_is_user()) { $content = '@' . bp_get_displayed_user_username() . ' ' . $_POST['content']; $is_wire_post = true; } else { $content = $_POST['content']; } //let us get the last activity id, we will use it to reset user's last activity $last_update = bp_get_user_meta(bp_loggedin_user_id(), 'bp_latest_update', true); if ($is_wire_post) { add_filter('bp_activity_new_update_action', 'devb_aawire_filter_action'); } $activity_id = bp_activity_post_update(array('content' => $content)); if ($is_wire_post) { remove_filter('bp_activity_new_update_action', 'devb_aawire_filter_action'); //add activity meta to remember that it was a wire post and we may use it in future if ($activity_id) { bp_activity_update_meta($activity_id, 'is_wire_post', 1); } //let us remember it for future //for 2.0 Let us add the mentioned user in the meta, so in future if we plan eo extend the wall beyond mention, we can do that easily bp_activity_update_meta($activity_id, 'wire_user_id', bp_displayed_user_id()); //let us remember it for future } //reset the last update bp_update_user_meta(get_current_user_id(), 'bp_latest_update', $last_update); //end of my changes } elseif ($_POST['object'] == 'groups') { if (!empty($_POST['item_id']) && function_exists('groups_post_update')) { $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id'])); } } else { $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']); } if (!$activity_id) { echo '-1<div id="message"><p>' . __('There was a problem posting your update, please try again.', 'buddypress') . '</p></div>'; exit(0); } if (bp_has_activities('include=' . $activity_id)) { ?> <?php while (bp_activities()) { bp_the_activity(); ?> <?php bp_locate_template(array('activity/entry.php'), true); ?> <?php } ?> <?php } exit(0); }
/** * Find and render the template for Email posts (the Customizer and admin previews). * * Misuses the `template_include` filter which expects a string, but as we need to replace * the `{{{content}}}` token with the post's content, we use object buffering to load the * template, replace the token, and render it. * * The function returns an empty string to prevent WordPress rendering another template. * * @since 2.5.0 * * @param string $template Path to template (probably single.php). * @return string */ function bp_core_render_email_template($template) { if (get_post_type() !== bp_get_email_post_type() || !is_single()) { return $template; } /** * Filter template used to display Email posts. * * @since 2.5.0 * * @param string $template Path to current template (probably single.php). */ $email_template = apply_filters('bp_core_render_email_template', bp_locate_template(bp_email_get_template(get_queried_object()), false), $template); if (!$email_template) { return $template; } ob_start(); include $email_template; $template = ob_get_contents(); ob_end_clean(); // Make sure we add a <title> tag so WP Customizer picks it up. $template = str_replace('<head>', '<head><title>' . esc_html_x('BuddyPress Emails', 'screen heading', 'buddypress') . '</title>', $template); echo str_replace('{{{content}}}', nl2br(get_post()->post_content), $template); /* * Link colours are applied directly in the email template before sending, so we * need to add an extra style here to set the colour for the Customizer or preview. */ $settings = bp_email_get_appearance_settings(); printf('<style>a { color: %s; }</style>', esc_attr($settings['highlight_color'])); return ''; }
/** * This is where we actually save the activity update. */ function ajax_update_activity_contents() { $bpfb_code = $activity = ''; $aid = 0; $codec = new BpfbCodec(); if (!empty($_POST['data']['bpfb_video_url'])) { $bpfb_code = $codec->create_video_tag($_POST['data']['bpfb_video_url']); } if (!empty($_POST['data']['bpfb_link_url'])) { $bpfb_code = $codec->create_link_tag($_POST['data']['bpfb_link_url'], $_POST['data']['bpfb_link_title'], $_POST['data']['bpfb_link_body'], $_POST['data']['bpfb_link_image']); } if (!empty($_POST['data']['bpfb_photos'])) { $images = $this->move_images($_POST['data']['bpfb_photos']); $bpfb_code = $codec->create_images_tag($images); } $bpfb_code = apply_filters('bpfb_code_before_save', $bpfb_code); // All done creating tags. Now, save the code $gid = (int) @$_POST['group_id']; if ($bpfb_code) { $content = @$_POST['content'] . "\n" . $bpfb_code; $content = apply_filters('bp_activity_post_update_content', $content); $aid = $gid ? groups_post_update(array('content' => $content, 'group_id' => $gid)) : bp_activity_post_update(array('content' => $content)); global $blog_id; bp_activity_update_meta($aid, 'bpfb_blog_id', $blog_id); } if ($aid) { ob_start(); if (bp_has_activities('include=' . $aid)) { while (bp_activities()) { bp_the_activity(); if (function_exists('bp_locate_template')) { bp_locate_template(array('activity/entry.php'), true); } else { locate_template(array('activity/entry.php'), true); } } } $activity = ob_get_clean(); } header('Content-type: application/json'); echo json_encode(array('code' => $bpfb_code, 'id' => $aid, 'activity' => $activity)); exit; }
public function show_post_form() { if (is_user_logged_in() && self::is_stream()) { bp_locate_template(array('activity/post-form.php'), true); } }
public function generate_activity_stream($atts, $content = null) { //allow to use all those args awesome! $atts = shortcode_atts(array('title' => 'Latest Activity', 'pagination' => 'true', 'display_comments' => 'threaded', 'include' => false, 'exclude' => false, 'in' => false, 'sort' => 'DESC', 'page' => 1, 'per_page' => 5, 'max' => false, 'scope' => false, 'user_id' => false, 'object' => false, 'action' => false, 'primary_id' => false, 'secondary_id' => false, 'search_terms' => false, 'use_compat' => bp_use_theme_compat_with_current_theme(), 'allow_posting' => false), $atts); extract($atts); //hide on user activity, activity directory and group activity if (is_user_logged_in() && (function_exists('bp_is_activity_component') && bp_is_activity_component() || function_exists('bp_is_group_home') && bp_is_group_home())) { return ''; } ob_start(); ?> <?php if ($use_compat) { ?> <div id="buddypress"> <?php } ?> <?php if ($title) { ?> <h3 class="activity-shortcode-title"><?php echo $title; ?> </h3> <?php } ?> <?php do_action('bp_before_activity_loop'); ?> <?php if ($allow_posting && is_user_logged_in()) { ?> <?php bp_locate_template(array('activity/post-form.php'), true); ?> <?php } ?> <?php if (bp_has_activities($atts)) { ?> <div class="activity <?php if (!$display_comments) { ?> hide-activity-comments<?php } ?> shortcode-activity-stream"> <?php if (empty($_POST['page'])) { ?> <ul id="activity-stream" class="activity-list item-list"> <?php } ?> <?php while (bp_activities()) { bp_the_activity(); ?> <?php bp_get_template_part('activity/entry'); ?> <?php } ?> <?php if (empty($_POST['page'])) { ?> </ul> <?php } ?> <?php if ($pagination) { ?> <div class="pagination"> <div class="pag-count"><?php bp_activity_pagination_count(); ?> </div> <div class="pagination-links"><?php bp_activity_pagination_links(); ?> </div> </div> <?php } ?> </div> <?php } else { ?> <div id="message" class="info"> <p><?php _e('Sorry, there was no activity found. Please try a different filter.', 'buddypress'); ?> </p> </div> <?php } ?> <?php do_action('bp_after_activity_loop'); ?> <form action="" name="activity-loop-form" id="activity-loop-form" method="post"> <?php wp_nonce_field('activity_filter', '_wpnonce_activity_filter'); ?> </form> <?php if ($use_compat) { ?> </div> <?php } ?> <?php $output = ob_get_clean(); return $output; }
?> </select> </li> </ul> </div><!-- .item-list-tabs --> <?php do_action('bp_before_link_activity_post_form'); ?> <?php if (is_user_logged_in()) { ?> <?php bp_links_locate_template(array('activity/post-form.php'), true); } ?> <?php do_action('bp_after_link_activity_post_form'); do_action('bp_before_link_activity_content'); ?> <div class="activity single-link"> <?php bp_locate_template(array('activity/activity-loop.php'), true); ?> </div><!-- .activity --> <?php do_action('bp_after_link_activity_content');
/** * Attempt to load a custom BP functions file, similar to each themes functions.php file. * * @since 1.7.0 * * @global string $pagenow * @uses bp_locate_template() */ function bp_load_theme_functions() { global $pagenow, $wp_query; // do not load our custom BP functions file if theme compat is disabled if (!bp_use_theme_compat_with_current_theme()) { return; } // Do not include on BuddyPress deactivation if (bp_is_deactivation()) { return; } // If the $wp_query global is empty (the main query has not been run, // or has been reset), load_template() will fail at setting certain // global values. This does not happen on a normal page load, but can // cause problems when running automated tests if (!is_a($wp_query, 'WP_Query')) { return; } // Only include if not installing or if activating via wp-activate.php if (!defined('WP_INSTALLING') || 'wp-activate.php' === $pagenow) { bp_locate_template('buddypress-functions.php', true); } }
/** * Loops through a level of activity comments and loads the template for each * * Note: The recursion itself used to happen entirely in this function. Now it is * split between here and the comment.php template. * * @since BuddyPress (1.2.0) * * @param object $comment The activity object currently being recursed * * @global object $activities_template {@link BP_Activity_Template} * @uses locate_template() */ function bp_activity_recurse_comments($comment) { global $activities_template; if (empty($comment)) { return false; } if (empty($comment->children)) { return false; } /** * Filters the opening tag for the template that lists activity comments. * * @since BuddyPress (1.6.0) * * @param string $value Opening tag for the HTML markup to use. */ echo apply_filters('bp_activity_recurse_comments_start_ul', '<ul>'); foreach ((array) $comment->children as $comment_child) { // Put the comment into the global so it's available to filters $activities_template->activity->current_comment = $comment_child; $template = bp_locate_template('activity/comment.php', false, false); // Backward compatibility. In older versions of BP, the markup was // generated in the PHP instead of a template. This ensures that // older themes (which are not children of bp-default and won't // have the new template) will still work. if (!$template) { $template = buddypress()->plugin_dir . '/bp-themes/bp-default/activity/comment.php'; } load_template($template, false); unset($activities_template->activity->current_comment); } /** * Filters the closing tag for the template that list activity comments. * * @since BuddyPress (1.6.0) * * @param string $value Closing tag for the HTML markup to use. */ echo apply_filters('bp_activity_recurse_comments_end_ul', '</ul>'); }
/** * Locate a custom group front template if it exists. * * @since 2.4.0 * * @param BP_Groups_Group|null $group Optional. Falls back to current group if not passed. * @return string|bool Path to front template on success; boolean false on failure. */ function bp_groups_get_front_template($group = null) { if (!is_a($group, 'BP_Groups_Group')) { $group = groups_get_current_group(); } if (!isset($group->id)) { return false; } if (isset($group->front_template)) { return $group->front_template; } $template_names = apply_filters('bp_groups_get_front_template', array('groups/single/front-id-' . sanitize_file_name($group->id) . '.php', 'groups/single/front-slug-' . sanitize_file_name($group->slug) . '.php', 'groups/single/front-status-' . sanitize_file_name($group->status) . '.php', 'groups/single/front.php')); return bp_locate_template($template_names, false, true); }
/** * 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; }
<div id="item-body" class="col-sm-12"> <?php do_action('bp_before_group_body'); /** * Does this next bit look familiar? If not, go check out WordPress's * /wp-includes/template-loader.php file. * * @todo A real template hierarchy? Gasp! */ // Group is visible if (bp_group_is_visible()) { // Looking at home location if (bp_is_group_home()) { // Use custom front if one exists $custom_front = bp_locate_template(array('groups/single/front.php'), false, true); if (!empty($custom_front)) { load_template($custom_front, true); // Default to activity } elseif (bp_is_active('activity')) { bp_get_template_part('groups/single/activity'); // Otherwise show members } elseif (bp_is_active('members')) { bp_get_template_part('groups/single/members'); } // Not looking at home } else { // Group Admin if (bp_is_group_admin_page()) { bp_get_template_part('groups/single/admin'); // Group Activity
/** * Locate a custom group front template if it exists. * * @since 2.4.0 * * @param BP_Groups_Group|null $group Optional. Falls back to current group if not passed. * @return string|bool Path to front template on success; boolean false on failure. */ function bp_groups_get_front_template($group = null) { if (!is_a($group, 'BP_Groups_Group')) { $group = groups_get_current_group(); } if (!isset($group->id)) { return false; } if (isset($group->front_template)) { return $group->front_template; } /** * Filters the hierarchy of group front templates corresponding to a specific group. * * @since 2.4.0 * @since 2.5.0 Added the `$group` parameter. * * @param array $template_names Array of template paths. * @param object $group Group object. */ $template_names = apply_filters('bp_groups_get_front_template', array('groups/single/front-id-' . sanitize_file_name($group->id) . '.php', 'groups/single/front-slug-' . sanitize_file_name($group->slug) . '.php', 'groups/single/front-status-' . sanitize_file_name($group->status) . '.php', 'groups/single/front.php')); return bp_locate_template($template_names, false, true); }
/** * Attempt to load a custom BuddyPress functions file, similar to each themes * functions.php file. * * @since BuddyPress (1.7) * * @global string $pagenow * @uses bp_locate_template() */ function bp_load_theme_functions() { global $pagenow; // Do not include on BuddyPress deactivation if (bp_is_deactivation()) { return; } // Only include if not installing or if activating via wp-activate.php if (!defined('WP_INSTALLING') || 'wp-activate.php' === $pagenow) { bp_locate_template('buddypress-functions.php', true); } }