<!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][6779] trunk/bp-forums/bp-forums-functions.php: Variable cleanup to bp-forums-functions.php.</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, #logmsg > ol { margin-left: 0; 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/6779">6779</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2013-02-08 18:36:14 +0000 (Fri, 08 Feb 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Variable cleanup to bp-forums-functions.php.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpforumsbpforumsfunctionsphp">trunk/bp-forums/bp-forums-functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpforumsbpforumsfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-forums/bp-forums-functions.php (6778 => 6779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-forums/bp-forums-functions.php        2013-02-08 09:33:37 UTC (rev 6778)
+++ trunk/bp-forums/bp-forums-functions.php        2013-02-08 18:36:14 UTC (rev 6779)
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx"> * @return boolean True if option exists, false if not
</span><span class="cx"> */
</span><span class="cx"> function bp_forums_is_installed_correctly() {
</span><del>-        global $bp;
</del><ins>+        $bp = buddypress();
</ins><span class="cx">
</span><span class="cx">         if ( isset( $bp->forums->bbconfig ) && is_file( $bp->forums->bbconfig ) )
</span><span class="cx">                 return true;
</span><span class="lines">@@ -51,9 +51,7 @@
</span><span class="cx"> * @return bool True if set, False if empty
</span><span class="cx"> */
</span><span class="cx"> function bp_forums_has_directory() {
</span><del>-        global $bp;
-
-        return (bool) !empty( $bp->pages->forums->id );
</del><ins>+        return (bool) !empty( buddypress()->pages->forums->id );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /** Forum Functions ***********************************************************/
</span><span class="lines">@@ -66,15 +64,13 @@
</span><span class="cx"> function bp_forums_new_forum( $args = '' ) {
</span><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><del>-        $defaults = array(
</del><ins>+        $r = wp_parse_args( $args, array(
</ins><span class="cx">                 'forum_name' => '',
</span><span class="cx">                 'forum_desc' => '',
</span><span class="cx">                 'forum_parent_id' => bp_forums_parent_forum_id(),
</span><span class="cx">                 'forum_order' => false,
</span><span class="cx">                 'forum_is_category' => 0
</span><del>-        );
-
-        $r = wp_parse_args( $args, $defaults );
</del><ins>+        ) );
</ins><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><span class="cx">         return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
</span><span class="lines">@@ -83,7 +79,7 @@
</span><span class="cx"> function bp_forums_update_forum( $args = '' ) {
</span><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><del>-        $defaults = array(
</del><ins>+        $r = wp_parse_args( $args, array(
</ins><span class="cx">                 'forum_id' => '',
</span><span class="cx">                 'forum_name' => '',
</span><span class="cx">                 'forum_desc' => '',
</span><span class="lines">@@ -91,9 +87,7 @@
</span><span class="cx">                 'forum_parent_id' => bp_forums_parent_forum_id(),
</span><span class="cx">                 'forum_order' => false,
</span><span class="cx">                 'forum_is_category' => 0
</span><del>-        );
-
-        $r = wp_parse_args( $args, $defaults );
</del><ins>+        ) );
</ins><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><span class="cx">         return bb_update_forum( array( 'forum_id' => (int) $forum_id, 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_slug' => stripslashes( $forum_slug ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
</span><span class="lines">@@ -112,11 +106,9 @@
</span><span class="cx"> /** Topic Functions ***********************************************************/
</span><span class="cx">
</span><span class="cx"> function bp_forums_get_forum_topics( $args = '' ) {
</span><del>-        global $bp;
-
</del><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><del>-        $defaults = array(
</del><ins>+        $r = wp_parse_args( $args, array(
</ins><span class="cx">                 'type' => 'newest',
</span><span class="cx">                 'forum_id' => false,
</span><span class="cx">                 'user_id' => false,
</span><span class="lines">@@ -127,9 +119,7 @@
</span><span class="cx">                 'exclude' => false,
</span><span class="cx">                 'show_stickies' => 'all',
</span><span class="cx">                 'filter' => false // if $type = tag then filter is the tag name, otherwise it's terms to search on.
</span><del>-        );
-
-        $r = wp_parse_args( $args, $defaults );
</del><ins>+        ) );
</ins><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><span class="cx">         if ( class_exists( 'BB_Query' ) ) {
</span><span class="lines">@@ -183,7 +173,7 @@
</span><span class="cx">
</span><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><del>-        $defaults = array(
</del><ins>+        $r = wp_parse_args( $args, array(
</ins><span class="cx">                 'topic_title' => '',
</span><span class="cx">                 'topic_slug' => '',
</span><span class="cx">                 'topic_text' => '',
</span><span class="lines">@@ -196,9 +186,7 @@
</span><span class="cx">                 'topic_open' => 1,
</span><span class="cx">                 'topic_tags' => false, // accepts array or comma delim
</span><span class="cx">                 'forum_id' => 0 // accepts ids or slugs
</span><del>-        );
-
-        $r = wp_parse_args( $args, $defaults );
</del><ins>+        ) );
</ins><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><span class="cx">         $topic_title = strip_tags( $topic_title );
</span><span class="lines">@@ -228,18 +216,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_forums_update_topic( $args = '' ) {
</span><del>-        global $bp;
-
</del><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><del>-        $defaults = array(
</del><ins>+        $r = wp_parse_args( $args, array(
</ins><span class="cx">                 'topic_id' => false,
</span><span class="cx">                 'topic_title' => '',
</span><span class="cx">                 'topic_text' => '',
</span><span class="cx">                 'topic_tags' => false
</span><del>-        );
-
-        $r = wp_parse_args( $args, $defaults );
</del><ins>+        ) );
</ins><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><span class="cx">         // Check if the user is a spammer
</span><span class="lines">@@ -263,16 +247,12 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_forums_sticky_topic( $args = '' ) {
</span><del>-        global $bp;
-
</del><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><del>-        $defaults = array(
</del><ins>+        $r = wp_parse_args( $args, array(
</ins><span class="cx">                 'topic_id' => false,
</span><span class="cx">                 'mode' => 'stick' // stick/unstick
</span><del>-        );
-
-        $r = wp_parse_args( $args, $defaults );
</del><ins>+        ) );
</ins><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><span class="cx">         if ( 'stick' == $mode )
</span><span class="lines">@@ -284,16 +264,12 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_forums_openclose_topic( $args = '' ) {
</span><del>-        global $bp;
-
</del><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><del>-        $defaults = array(
</del><ins>+        $r = wp_parse_args( $args, array(
</ins><span class="cx">                 'topic_id' => false,
</span><span class="cx">                 'mode' => 'close' // stick/unstick
</span><del>-        );
-
-        $r = wp_parse_args( $args, $defaults );
</del><ins>+        ) );
</ins><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><span class="cx">         if ( 'close' == $mode )
</span><span class="lines">@@ -305,15 +281,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_forums_delete_topic( $args = '' ) {
</span><del>-        global $bp;
-
</del><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><del>-        $defaults = array(
</del><ins>+        $r = wp_parse_args( $args, array(
</ins><span class="cx">                 'topic_id' => false
</span><del>-        );
-
-        $r = wp_parse_args( $args, $defaults );
</del><ins>+        ) );
</ins><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><span class="cx">         return bb_delete_topic( $topic_id, 1 );
</span><span class="lines">@@ -402,8 +374,6 @@
</span><span class="cx"> * @return int $count The topic count
</span><span class="cx"> */
</span><span class="cx"> function bp_forums_total_topic_count_for_user( $user_id = 0, $type = 'active' ) {
</span><del>-        global $bp;
-
</del><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><span class="cx">         if ( !$user_id )
</span><span class="lines">@@ -442,8 +412,6 @@
</span><span class="cx"> * @return int $count
</span><span class="cx"> */
</span><span class="cx"> function bp_forums_total_replied_count_for_user( $user_id = 0, $type = 'active' ) {
</span><del>-        global $bp;
-
</del><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><span class="cx">         if ( !$user_id )
</span><span class="lines">@@ -479,11 +447,13 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_forums_get_topic_extras( $topics ) {
</span><del>-        global $bp, $wpdb, $bbdb;
</del><ins>+        global $wpdb, $bbdb;
</ins><span class="cx">
</span><span class="cx">         if ( empty( $topics ) )
</span><span class="cx">                 return $topics;
</span><span class="cx">
</span><ins>+        $bp = buddypress();
+
</ins><span class="cx">         // Get the topic ids
</span><span class="cx">         foreach ( (array) $topics as $topic ) $topic_ids[] = $topic->topic_id;
</span><span class="cx">         $topic_ids = $wpdb->escape( join( ',', (array) $topic_ids ) );
</span><span class="lines">@@ -555,23 +525,18 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_forums_delete_post( $args = '' ) {
</span><del>-        global $bp;
-
</del><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><del>-        $defaults = array(
</del><ins>+        $r = wp_parse_args( $args, array(
</ins><span class="cx">                 'post_id' => false
</span><del>-        );
</del><ins>+        ) );
</ins><span class="cx">
</span><del>-        $r = wp_parse_args( $args, $defaults );
</del><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><span class="cx">         return bb_delete_post( $post_id, 1 );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_forums_insert_post( $args = '' ) {
</span><del>-        global $bp;
-
</del><span class="cx">         do_action( 'bbpress_init' );
</span><span class="cx">
</span><span class="cx">         $defaults = array(
</span><span class="lines">@@ -665,7 +630,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_forums_filter_caps( $allcaps ) {
</span><del>-        global $bp, $wp_roles, $bb_table_prefix;
</del><ins>+        global $wp_roles, $bb_table_prefix;
</ins><span class="cx">
</span><span class="cx">         if ( !bp_loggedin_user_id() )
</span><span class="cx">                 return $allcaps;
</span></span></pre>
</div>
</div>
</body>
</html>