<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][7434] trunk/bp-core: Improve inline docs in bp-core.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/7434">7434</a></dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2013-10-16 17:41:34 +0000 (Wed, 16 Oct 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Improve inline docs in bp-core. See <a href="http://buddypress.trac.wordpress.org/ticket/5022">#5022</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcorebuddybarphp">trunk/bp-core/bp-core-buddybar.php</a></li>
<li><a href="#trunkbpcorebpcorecachephp">trunk/bp-core/bp-core-cache.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcorebuddybarphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-buddybar.php (7433 => 7434)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-buddybar.php 2013-10-16 13:36:51 UTC (rev 7433)
+++ trunk/bp-core/bp-core-buddybar.php 2013-10-16 17:41:34 UTC (rev 7434)
</span><span class="lines">@@ -1,21 +1,41 @@
</span><span class="cx"> <?php
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Core BuddyPress Navigational Functions
</del><ins>+ * Core BuddyPress Navigational Functions.
</ins><span class="cx"> *
</span><span class="cx"> * @package BuddyPress
</span><span class="cx"> * @subpackage Core
</span><del>- * @todo Deprecate BuddyBar functions
</del><ins>+ * @todo Deprecate BuddyBar functions.
</ins><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Adds a navigation item to the main navigation array used in BuddyPress themes.
</del><ins>+ * Add an item to the main BuddyPress navigation array.
</ins><span class="cx"> *
</span><del>- * @package BuddyPress Core
- * @global BuddyPress $bp The one true BuddyPress instance
</del><ins>+ * @global BuddyPress $bp The one true BuddyPress instance.
+ *
+ * @param array $args {
+ * Array describing the new nav item.
+ * @type string $name Display name for the nav item.
+ * @type string $slug Unique URL slug for the nav item.
+ * @type bool|string $item_css_id Optional. 'id' attribute for the nav
+ * item. Default: the value of $slug.
+ * @type bool $show_for_displayed_user Optional. Whether the nav item
+ * should be visible when viewing a member profile other than your
+ * own. Default: true.
+ * @type bool $site_admin_only Optional. Whether the nav item should be
+ * visible only to site admins (those with the 'bp_moderate' cap).
+ * Default: false.
+ * @type int $position Optional. Numerical index specifying where the item
+ * should appear in the nav array. Default: 99.
+ * @type callable $screen_function The callback function that will run
+ * when the nav item is clicked.
+ * @type bool|string $default_subnav_slug Optional. The slug of the default
+ * subnav item to select when the nav item is clicked.
+ * }
+ * @return bool|null Returns false on failure.
</ins><span class="cx"> */
</span><span class="cx"> function bp_core_new_nav_item( $args = '' ) {
</span><span class="cx"> global $bp;
</span><span class="lines">@@ -97,10 +117,17 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Modify the default subnav item to load when a top level nav item is clicked.
</del><ins>+ * Modify the default subnav item that loads when a top level nav item is clicked.
</ins><span class="cx"> *
</span><del>- * @package BuddyPress Core
- * @global BuddyPress $bp The one true BuddyPress instance
</del><ins>+ * @global BuddyPress $bp The one true BuddyPress instance.
+ *
+ * @param array $args {
+ * @type string $parent_slug The slug of the nav item whose default is
+ * being changed.
+ * @type callable $screen_function The new default callback function that
+ * will run when the nav item is clicked.
+ * @type string $subnav_slug The slug of the new default subnav item.
+ * }
</ins><span class="cx"> */
</span><span class="cx"> function bp_core_new_nav_default( $args = '' ) {
</span><span class="cx"> global $bp;
</span><span class="lines">@@ -163,11 +190,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * We can only sort nav items by their position integer at a later point in time, once all
- * plugins have registered their navigation items.
</del><ins>+ * Sort the navigation menu items.
</ins><span class="cx"> *
</span><del>- * @package BuddyPress Core
</del><ins>+ * The sorting is split into a separate function because it can only happen
+ * after all plugins have had a chance to register their navigation items.
+ *
</ins><span class="cx"> * @global BuddyPress $bp The one true BuddyPress instance
</span><ins>+ *
+ * @return bool|null Returns false on failure.
</ins><span class="cx"> */
</span><span class="cx"> function bp_core_sort_nav_items() {
</span><span class="cx"> global $bp;
</span><span class="lines">@@ -197,10 +227,34 @@
</span><span class="cx"> add_action( 'admin_head', 'bp_core_sort_nav_items' );
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Adds a navigation item to the sub navigation array used in BuddyPress themes.
</del><ins>+ * Add a subnav item to the BuddyPress navigation.
</ins><span class="cx"> *
</span><del>- * @package BuddyPress Core
- * @global BuddyPress $bp The one true BuddyPress instance
</del><ins>+ * @global BuddyPress $bp The one true BuddyPress instance.
+ *
+ * @param array $args {
+ * Array describing the new subnav item.
+ * @type string $name Display name for the subnav item.
+ * @type string $slug Unique URL slug for the subnav item.
+ * @type string $parent_slug Slug of the top-level nav item under which the
+ * new subnav item should be added.
+ * @type string $parent_url URL of the parent nav item.
+ * @type bool|string $item_css_id Optional. 'id' attribute for the nav
+ * item. Default: the value of $slug.
+ * @type bool $user_has_access Optional. True if the logged-in user has
+ * access to the subnav item, otherwise false. Can be set dynamically
+ * when registering the subnav; eg, use bp_is_my_profile() to restrict
+ * access to profile owners only. Default: true.
+ * @type bool $site_admin_only Optional. Whether the nav item should be
+ * visible only to site admins (those with the 'bp_moderate' cap).
+ * Default: false.
+ * @type int $position Optional. Numerical index specifying where the item
+ * should appear in the subnav array. Default: 90.
+ * @type callable $screen_function The callback function that will run
+ * when the nav item is clicked.
+ * @type string $link Optional. The URL that the subnav item should point
+ * to. Defaults to a value generated from the $parent_url + $slug.
+ * }
+ * @return bool|null Returns false on failure.
</ins><span class="cx"> */
</span><span class="cx"> function bp_core_new_subnav_item( $args = '' ) {
</span><span class="cx"> global $bp;
</span><span class="lines">@@ -318,6 +372,13 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Sort all subnavigation arrays.
+ *
+ * @global BuddyPress $bp The one true BuddyPress instance
+ *
+ * @return bool|null Returns false on failure.
+ */
</ins><span class="cx"> function bp_core_sort_subnav_items() {
</span><span class="cx"> global $bp;
</span><span class="cx">
</span><span class="lines">@@ -349,13 +410,14 @@
</span><span class="cx"> add_action( 'admin_head', 'bp_core_sort_subnav_items' );
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Determines whether a given nav item has subnav items
</del><ins>+ * Check whether a given nav item has subnav items.
</ins><span class="cx"> *
</span><del>- * @package BuddyPress
- * @since BuddyPress (1.5)
</del><ins>+ * @since BuddyPress (1.5.0)
</ins><span class="cx"> *
</span><del>- * @param string $nav_item The id of the top-level nav item whose nav items you're checking
- * @return bool $has_subnav True if the nav item is found and has subnav items; false otherwise
</del><ins>+ * @param string $nav_item The slug of the top-level nav item whose subnav
+ * items you're checking. Default: the current component slug.
+ * @return bool $has_subnav True if the nav item is found and has subnav
+ * items; false otherwise.
</ins><span class="cx"> */
</span><span class="cx"> function bp_nav_item_has_subnav( $nav_item = '' ) {
</span><span class="cx"> global $bp;
</span><span class="lines">@@ -369,11 +431,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Removes a navigation item from the sub navigation array used in BuddyPress themes.
</del><ins>+ * Remove a nav item from the navigation array.
</ins><span class="cx"> *
</span><del>- * @package BuddyPress Core
- * @param int $parent_id The id of the parent navigation item.
- * @param bool|string false if the parent item doesn't exist or $slug the slug of the sub navigation item.
</del><ins>+ * @param int $parent_id The slug of the parent navigation item.
+ * @param bool Returns false on failure, ie if the nav item can't be found.
</ins><span class="cx"> */
</span><span class="cx"> function bp_core_remove_nav_item( $parent_id ) {
</span><span class="cx"> global $bp;
</span><span class="lines">@@ -399,11 +460,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Removes a navigation item from the sub navigation array used in BuddyPress themes.
</del><ins>+ * Remove a subnav item from the navigation array.
</ins><span class="cx"> *
</span><del>- * @package BuddyPress Core
- * @param string $parent_id The id of the parent navigation item.
- * @param string $slug The slug of the sub navigation item.
</del><ins>+ * @param string $parent_id The slug of the parent navigation item.
+ * @param string $slug The slug of the subnav item to be removed.
</ins><span class="cx"> */
</span><span class="cx"> function bp_core_remove_subnav_item( $parent_id, $slug ) {
</span><span class="cx"> global $bp;
</span><span class="lines">@@ -424,11 +484,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Clear the subnav items for a specific nav item.
</del><ins>+ * Clear all subnav items from a specific nav item.
</ins><span class="cx"> *
</span><del>- * @package BuddyPress Core
- * @param string $parent_id The id of the parent navigation item.
- * @global BuddyPress $bp The one true BuddyPress instance
</del><ins>+ * @global BuddyPress $bp The one true BuddyPress instance.
+ *
+ * @param string $parent_slug The slug of the parent navigation item.
</ins><span class="cx"> */
</span><span class="cx"> function bp_core_reset_subnav_items( $parent_slug ) {
</span><span class="cx"> global $bp;
</span><span class="lines">@@ -436,8 +496,13 @@
</span><span class="cx"> unset( $bp->bp_options_nav[$parent_slug] );
</span><span class="cx"> }
</span><span class="cx">
</span><del>-/** Template functions ********************************************************/
</del><ins>+/** BuddyBar Template functions ***********************************************/
</ins><span class="cx">
</span><ins>+/**
+ * Wrapper function for rendering the BuddyBar.
+ *
+ * @return bool|null Returns false if the BuddyBar is disabled.
+ */
</ins><span class="cx"> function bp_core_admin_bar() {
</span><span class="cx"> global $bp;
</span><span class="cx">
</span><span class="lines">@@ -465,12 +530,20 @@
</span><span class="cx"> $bp->doing_admin_bar = false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// **** Default BuddyPress Toolbar logo ********
</del><ins>+/**
+ * Output the BuddyBar logo.
+ */
</ins><span class="cx"> function bp_adminbar_logo() {
</span><span class="cx"> echo '<a href="' . bp_get_root_domain() . '" id="admin-bar-logo">' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . '</a>';
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// **** "Log In" and "Sign Up" links (Visible when not logged in) ********
</del><ins>+/**
+ * Output the "Log In" and "Sign Up" names to the BuddyBar.
+ *
+ * Visible only to visitors who are not logged in.
+ *
+ * @return bool|null Returns false if the current user is logged in.
+ */
</ins><span class="cx"> function bp_adminbar_login_menu() {
</span><span class="cx">
</span><span class="cx"> if ( is_user_logged_in() )
</span><span class="lines">@@ -483,8 +556,11 @@
</span><span class="cx"> echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page() . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
</span><span class="cx"> }
</span><span class="cx">
</span><del>-
-// **** "My Account" Menu ******
</del><ins>+/**
+ * Output the My Account BuddyBar menu.
+ *
+ * @return bool|null Returns false on failure.
+ */
</ins><span class="cx"> function bp_adminbar_account_menu() {
</span><span class="cx"> global $bp;
</span><span class="cx">
</span><span class="lines">@@ -557,8 +633,11 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-
-// **** "Random" Menu (visible when not logged in) ********
</del><ins>+/**
+ * Output the Random BuddyBar menu.
+ *
+ * Not visible for logged-in users.
+ */
</ins><span class="cx"> function bp_adminbar_random_menu() {
</span><span class="cx"> ?>
</span><span class="cx">
</span><span class="lines">@@ -592,14 +671,14 @@
</span><span class="cx"> *
</span><span class="cx"> * This is a direct copy of WP's private _get_admin_bar_pref()
</span><span class="cx"> *
</span><del>- * @since BuddyPress (1.5)
</del><ins>+ * @since BuddyPress (1.5.0)
</ins><span class="cx"> *
</span><del>- * @param string $context Context of this preference check, either 'admin' or 'front'.
- * @param int $user Optional. ID of the user to check, defaults to 0 for current user.
- *
</del><span class="cx"> * @uses get_user_option()
</span><span class="cx"> *
</span><del>- * @return bool Whether the Toolbar should be showing for this user.
</del><ins>+ * @param string $context Context of this preference check. 'admin' or 'front'.
+ * @param int $user Optional. ID of the user to check. Default: 0 (which falls
+ * back to the logged-in user's ID).
+ * @return bool True if the toolbar should be showing for this user.
</ins><span class="cx"> */
</span><span class="cx"> function bp_get_admin_bar_pref( $context, $user = 0 ) {
</span><span class="cx"> $pref = get_user_option( "show_admin_bar_{$context}", $user );
</span><span class="lines">@@ -610,7 +689,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Handle the BuddyBar CSS
</del><ins>+ * Enqueue the BuddyBar CSS.
</ins><span class="cx"> */
</span><span class="cx"> function bp_core_load_buddybar_css() {
</span><span class="cx"> global $wp_styles;
</span></span></pre></div>
<a id="trunkbpcorebpcorecachephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-cache.php (7433 => 7434)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-cache.php 2013-10-16 13:36:51 UTC (rev 7433)
+++ trunk/bp-core/bp-core-cache.php 2013-10-16 17:41:34 UTC (rev 7434)
</span><span class="lines">@@ -1,5 +1,7 @@
</span><span class="cx"> <?php
</span><span class="cx"> /**
</span><ins>+ * BuddyPress Core Caching Functions.
+ *
</ins><span class="cx"> * Caching functions handle the clearing of cached objects and pages on specific
</span><span class="cx"> * actions throughout BuddyPress.
</span><span class="cx"> */
</span><span class="lines">@@ -8,12 +10,12 @@
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * REQUIRES WP-SUPER-CACHE
</del><ins>+ * Prune the WP Super Cache.
</ins><span class="cx"> *
</span><ins>+ * @see prune_super_cache()
+ *
</ins><span class="cx"> * When wp-super-cache is installed this function will clear cached pages
</span><span class="cx"> * so that success/error messages are not cached, or time sensitive content.
</span><del>- *
- * @package BuddyPress Core
</del><span class="cx"> */
</span><span class="cx"> function bp_core_clear_cache() {
</span><span class="cx"> global $cache_path;
</span><span class="lines">@@ -25,9 +27,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Add's 'bp' to global group of network wide cachable objects
- *
- * @package BuddyPress Core
</del><ins>+ * Add 'bp' to global group of network wide cachable objects.
</ins><span class="cx"> */
</span><span class="cx"> function bp_core_add_global_group() {
</span><span class="cx"> if ( function_exists( 'wp_cache_add_global_groups' ) ) {
</span><span class="lines">@@ -37,16 +37,14 @@
</span><span class="cx"> add_action( 'bp_loaded', 'bp_core_add_global_group' );
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Clears all cached objects for a user, or a user is part of.
- *
- * @package BuddyPress Core
</del><ins>+ * Clear all cached objects for a user, or those that a user is part of.
</ins><span class="cx"> */
</span><span class="cx"> function bp_core_clear_user_object_cache( $user_id ) {
</span><span class="cx"> wp_cache_delete( 'bp_user_' . $user_id, 'bp' );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Clears member count caches and transients
</del><ins>+ * Clear member count caches and transients.
</ins><span class="cx"> */
</span><span class="cx"> function bp_core_clear_member_count_caches() {
</span><span class="cx"> wp_cache_delete( 'bp_total_member_count', 'bp' );
</span><span class="lines">@@ -61,10 +59,29 @@
</span><span class="cx"> /**
</span><span class="cx"> * Update the metadata cache for the specified objects.
</span><span class="cx"> *
</span><del>- * @since BuddyPress (1.6)
- * @global $wpdb WordPress database object for queries.
- * @param array $args See $defaults definition for more details
- * @return mixed Metadata cache for the specified objects, or false on failure.
</del><ins>+ * Based on WordPress's {@link update_meta_cache()}, this function primes the
+ * cache with metadata related to a set of objects. This is typically done when
+ * querying for a loop of objects; pre-fetching metadata for each queried
+ * object can lead to dramatic performance improvements when using metadata
+ * in the context of template loops.
+ *
+ * @since BuddyPress (1.6.0)
+ *
+ * @global $wpdb WordPress database object for queries..
+ *
+ * @param array $args {
+ * Array of arguments.
+ * @type array|string $object_ids List of object IDs to fetch metadata for.
+ * Accepts an array or a comma-separated list of numeric IDs.
+ * @type string $object_type The type of object, eg 'groups' or 'activity'.
+ * @type string $meta_table The name of the metadata table being queried.
+ * @type string $object_column Optional. The name of the database column
+ * where IDs (those provided by $object_ids) are found. Eg, 'group_id'
+ * for the groups metadata tables. Default: $object_type . '_id'.
+ * @type string $cache_key_prefix Optional. The prefix to use when creating
+ * cache key names. Default: the value of $meta_table.
+ * }
+ * @return array|bool Metadata cache for the specified objects, or false on failure.
</ins><span class="cx"> */
</span><span class="cx"> function bp_update_meta_cache( $args = array() ) {
</span><span class="cx"> global $wpdb;
</span></span></pre>
</div>
</div>
</body>
</html>