Skip to:
Content

BuddyPress.org

Changeset 10183


Ignore:
Timestamp:
10/04/2015 07:29:24 AM (11 years ago)
Author:
tw2113
Message:

Initial documentation cleanup for the BP Forums Component.

See #6397.

Location:
trunk/src/bp-forums
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-forums/bp-forums-bbpress-sa.php

    r10096 r10183  
    5656        require( bp_get_option( 'bb-config-location' ) );
    5757
    58         // Setup the global database connection
     58        // Setup the global database connection.
    5959        $bbdb = new BPDB ( BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST );
    6060
    61         // Set the table names
     61        // Set the table names.
    6262        $bbdb->forums             = $bb_table_prefix . 'forums';
    6363        $bbdb->meta               = $bb_table_prefix . 'meta';
     
    116116        $wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' );
    117117
    118         // Set a site id if there isn't one already
     118        // Set a site id if there isn't one already.
    119119        if ( !isset( $bb->site_id ) )
    120120                $bb->site_id = bp_get_root_blog_id();
    121121
    122         // Check if the tables are installed, if not, install them
     122        // Check if the tables are installed, if not, install them.
    123123        if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) ) {
    124124                require( BB_PATH . 'bb-admin/includes/defaults.bb-schema.php' );
     
    130130                bb_update_db_version();
    131131
    132                 // Set the site admins as the keymasters
     132                // Set the site admins as the keymasters.
    133133                $site_admins = get_site_option( 'site_admins', array('admin') );
    134134                foreach ( (array) $site_admins as $site_admin )
     
    138138                bb_new_forum( array( 'forum_name' => 'Default Forum' ) );
    139139
    140                 // Set the site URI
     140                // Set the site URI.
    141141                bb_update_option( 'uri', BB_URL );
    142142        }
     
    173173 * Noop.
    174174 *
    175  * @param array $users
     175 * @param array $users Array of users.
    176176 */
    177177function bb_cache_users( $users ) {}
    178178
    179179/**
    180  * bbPress needs this class for its usermeta manipulation.
     180 * The bbPress plugin needs this class for its usermeta manipulation.
    181181 */
    182182class BP_Forums_BB_Auth {
     
    191191
    192192/**
    193  * bbPress needs the DB class to be BPDB, but we want to use WPDB, so we can extend it and use this.
     193 * The bbPress plugin needs the DB class to be BPDB, but we want to use WPDB, so we can extend it and use this.
    194194 *
    195195 * The class is pluggable, so that plugins that swap out WPDB with a custom
     
    202202
    203203                /**
    204                  * Constructor
     204                 * Constructor.
    205205                 *
    206206                 * @see WPDB::__construct() for description of parameters.
     
    247247                 *
    248248                 * @see BBDB::__construct() for a description of params.
     249                 *
     250                 * @param array $args Array of args to parse.
     251                 * @return array $args.
    249252                 */
    250253                function init( $args ) {
     
    286289                }
    287290        }
    288 endif; // class_exists( 'BPDB' )
     291endif; // End class_exists( 'BPDB' ).
    289292
    290293/**
    291294 * Convert object to given output format.
    292295 *
    293  * bbPress needs this to convert vars.
     296 * The bbPress plugin needs this to convert vars.
    294297 *
    295298 * @param object $object Object to convert.
     
    318321 *
    319322 * @param array $queries See {@link dbDelta()}.
    320  * @param bool $execute See {@link dbDelta()}.
     323 * @param bool  $execute See {@link dbDelta()}.
    321324 * @return array See {@link dbDelta()}.
    322325 */
     
    324327        global $wpdb;
    325328
    326         // Separate individual queries into an array
     329        // Separate individual queries into an array.
    327330        if ( !is_array($queries) ) {
    328331                $queries = explode( ';', $queries );
     
    330333        }
    331334
    332         $cqueries = array(); // Creation Queries
    333         $iqueries = array(); // Insertion Queries
     335        $cqueries = array(); // Creation Queries.
     336        $iqueries = array(); // Insertion Queries.
    334337        $for_update = array();
    335338
    336         // Create a tablename index for an array ($cqueries) of queries
     339        // Create a tablename index for an array ($cqueries) of queries.
    337340        foreach($queries as $qry) {
    338341                if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
     
    346349                        $iqueries[] = $qry;
    347350                } else {
    348                         // Unrecognized query type
    349                 }
    350         }
    351 
    352         // Check to see which tables and fields exist
     351                        // Unrecognized query type.
     352                }
     353        }
     354
     355        // Check to see which tables and fields exist.
    353356        if ($tables = $wpdb->get_col('SHOW TABLES;')) {
    354                 // For every table in the database
     357                // For every table in the database.
    355358                foreach ($tables as $table) {
    356359                        // Upgrade global tables only for the main site. Don't upgrade at all if DO_NOT_UPGRADE_GLOBAL_TABLES is defined.
     
    360363                        // If a table query exists for the database table...
    361364                        if ( array_key_exists(strtolower($table), $cqueries) ) {
    362                                 // Clear the field and index arrays
     365                                // Clear the field and index arrays.
    363366                                $cfields = $indices = array();
    364                                 // Get all of the field names in the query from between the parents
     367                                // Get all of the field names in the query from between the parents.
    365368                                preg_match("|\((.*)\)|ms", $cqueries[strtolower($table)], $match2);
    366369                                $qryline = trim($match2[1]);
    367370
    368                                 // Separate field lines into an array
     371                                // Separate field lines into an array.
    369372                                $flds = explode("\n", $qryline);
    370373
    371374                                //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
    372375
    373                                 // For every field line specified in the query
     376                                // For every field line specified in the query.
    374377                                foreach ($flds as $fld) {
    375                                         // Extract the field name
     378                                        // Extract the field name.
    376379                                        preg_match("|^([^ ]*)|", trim($fld), $fvals);
    377380                                        $fieldname = trim( $fvals[1], '`' );
    378381
    379                                         // Verify the found field name
     382                                        // Verify the found field name.
    380383                                        $validfield = true;
    381384                                        switch (strtolower($fieldname)) {
     
    392395                                        $fld = trim($fld);
    393396
    394                                         // If it's a valid field, add it to the field array
     397                                        // If it's a valid field, add it to the field array.
    395398                                        if ($validfield) {
    396399                                                $cfields[strtolower($fieldname)] = trim($fld, ", \n");
     
    398401                                }
    399402
    400                                 // Fetch the table column structure from the database
     403                                // Fetch the table column structure from the database.
    401404                                $tablefields = $wpdb->get_results("DESCRIBE {$table};");
    402405
    403                                 // For every field in the table
     406                                // For every field in the table.
    404407                                foreach ($tablefields as $tablefield) {
    405408                                        // If the table field exists in the field array...
    406409                                        if (array_key_exists(strtolower($tablefield->Field), $cfields)) {
    407                                                 // Get the field type from the query
     410                                                // Get the field type from the query.
    408411                                                preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
    409412                                                $fieldtype = $matches[1];
     
    411414                                                // Is actual field type different from the field type in query?
    412415                                                if ($tablefield->Type != $fieldtype) {
    413                                                         // Add a query to change the column type
     416                                                        // Add a query to change the column type.
    414417                                                        $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
    415418                                                        $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
    416419                                                }
    417420
    418                                                 // Get the default value from the array
     421                                                // Get the default value from the array.
    419422                                                        //echo "{$cfields[strtolower($tablefield->Field)]}<br>";
    420423                                                if (preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
    421424                                                        $default_value = $matches[1];
    422425                                                        if ($tablefield->Default != $default_value) {
    423                                                                 // Add a query to change the column's default value
     426                                                                // Add a query to change the column's default value.
    424427                                                                $cqueries[] = "ALTER TABLE {$table} ALTER COLUMN {$tablefield->Field} SET DEFAULT '{$default_value}'";
    425428                                                                $for_update[$table.'.'.$tablefield->Field] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}";
     
    427430                                                }
    428431
    429                                                 // Remove the field from the array (so it's not added)
     432                                                // Remove the field from the array (so it's not added).
    430433                                                unset($cfields[strtolower($tablefield->Field)]);
    431434                                        } else {
     
    434437                                }
    435438
    436                                 // For every remaining field specified for the table
     439                                // For every remaining field specified for the table.
    437440                                foreach ($cfields as $fieldname => $fielddef) {
    438                                         // Push a query line into $cqueries that adds the field to that table
     441                                        // Push a query line into $cqueries that adds the field to that table.
    439442                                        $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
    440443                                        $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
     
    442445
    443446                                // Index stuff goes here
    444                                 // Fetch the table index structure from the database
     447                                // Fetch the table index structure from the database.
    445448                                $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
    446449
    447450                                if ($tableindices) {
    448                                         // Clear the index array
     451                                        // Clear the index array.
    449452                                        unset($index_ary);
    450453
    451                                         // For every index in the table
     454                                        // For every index in the table.
    452455                                        foreach ($tableindices as $tableindex) {
    453                                                 // Add the index to the index data array
     456                                                // Add the index to the index data array.
    454457                                                $keyname = $tableindex->Key_name;
    455458                                                $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
     
    457460                                        }
    458461
    459                                         // For each actual index in the index array
     462                                        // For each actual index in the index array.
    460463                                        foreach ($index_ary as $index_name => $index_data) {
    461                                                 // Build a create string to compare to the query
     464                                                // Build a create string to compare to the query.
    462465                                                $index_string = '';
    463466                                                if ($index_name == 'PRIMARY') {
     
    471474                                                }
    472475                                                $index_columns = '';
    473                                                 // For each column in the index
     476                                                // For each column in the index.
    474477                                                foreach ($index_data['columns'] as $column_data) {
    475478                                                        if ($index_columns != '') $index_columns .= ',';
    476                                                         // Add the field to the column list string
     479                                                        // Add the field to the column list string.
    477480                                                        $index_columns .= $column_data['fieldname'];
    478481                                                        if ($column_data['subpart'] != '') {
     
    480483                                                        }
    481484                                                }
    482                                                 // Add the column list to the index create string
     485                                                // Add the column list to the index create string.
    483486                                                $index_string .= ' ('.$index_columns.')';
    484487                                                if (!(($aindex = array_search($index_string, $indices)) === false)) {
     
    490493                                }
    491494
    492                                 // For every remaining index specified for the table
     495                                // For every remaining index specified for the table.
    493496                                foreach ( (array) $indices as $index ) {
    494                                         // Push a query line into $cqueries that adds the index to that table
     497                                        // Push a query line into $cqueries that adds the index to that table.
    495498                                        $cqueries[] = "ALTER TABLE {$table} ADD $index";
    496499                                        $for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index;
    497500                                }
    498501
    499                                 // Remove the original table creation query from processing
     502                                // Remove the original table creation query from processing.
    500503                                unset($cqueries[strtolower($table)]);
    501504                                unset($for_update[strtolower($table)]);
  • trunk/src/bp-forums/bp-forums-filters.php

    r10096 r10183  
    9898 * Get a link for a forum topic tags directory.
    9999 *
    100  * @param string $link Link passed from filter.
    101  * @param string $tag Name of the tag.
    102  * @param string $page Page number, passed from the filter.
     100 * @param string $link    Link passed from filter.
     101 * @param string $tag     Name of the tag.
     102 * @param string $page    Page number, passed from the filter.
    103103 * @param string $context Passed from the filter but unused here.
    104104 * @return string Link of the form http://example.com/forums/tag/tagname/.
     
    142142 * @see bp_modify_page_title()
    143143 *
    144  * @param string $title New page title; see {@link bp_modify_page_title()}.
     144 * @param string $title          New page title; see {@link bp_modify_page_title()}.
    145145 * @param string $original_title Original page title.
    146  * @param string $sep How to separate the various items within the page title.
    147  * @param string $seplocation Direction to display title.
     146 * @param string $sep            How to separate the various items within the page title.
     147 * @param string $seplocation    Direction to display title.
    148148 * @return string Page title with forum topic title appended.
    149149 */
     
    232232        $sql .= $wpdb->prepare( " AND p.poster_id = %s ", bp_displayed_user_id() );
    233233
    234         // Remove any topic_author information
     234        // Remove any topic_author information.
    235235        $sql = str_replace( " AND t.topic_poster = '" . bp_displayed_user_id() . "'", '', $sql );
    236236
  • trunk/src/bp-forums/bp-forums-functions.php

    r10096 r10183  
    2121function bp_forums_is_bbpress_active() {
    2222
    23         // Single site
     23        // Single site.
    2424        if ( is_plugin_active( 'bbpress/bbpress.php' ) )
    2525                return true;
    2626
    27         // Network active
     27        // Network active.
    2828        if ( is_plugin_active_for_network( 'bbpress/bbpress.php' ) )
    2929                return true;
    3030
    31         // Nope
     31        // Nope.
    3232        return false;
    3333}
     
    5757 * Does the forums component have a directory page registered?
    5858 *
    59  * Checks $bp pages global and looks for directory page
     59 * Checks $bp pages global and looks for directory page.
    6060 *
    6161 * @since 1.5.0
     
    8181function bp_forums_get_forum( $forum_id ) {
    8282
    83         /** This action is documented in bp-forums/bp-forums-screens */
     83        /** This action is documented in bp-forums/bp-forums-screens.php */
    8484        do_action( 'bbpress_init' );
    8585        return bb_get_forum( $forum_id );
     
    9191 * Wrapper for {@link bb_new_forum()}.
    9292 *
    93  * @param array $args {
     93 * @param array|string $args {
    9494 *     Forum setup arguments.
    95  *     @type string $forum_name Name of the forum.
    96  *     @type string $forum_desc Description of the forum.
    97  *     @type int $forum_parent_id ID of the forum parent. Default: value of
    98  *           {@link bp_forums_parent_forums_id()}.
    99  *     @type bool $forum_order Order.
    100  *     @type int $forum_is_category Whether the forum is a category. Default: 0.
     95 *     @type string $forum_name        Name of the forum.
     96 *     @type string $forum_desc        Description of the forum.
     97 *     @type int    $forum_parent_id  ID of the forum parent. Default: value of
     98 *                                     {@link bp_forums_parent_forums_id()}.
     99 *     @type bool   $forum_order      Order.
     100 *     @type int    $forum_is_category Whether the forum is a category. Default: 0.
    101101 * }
    102102 * @return int ID of the newly created forum.
     
    104104function bp_forums_new_forum( $args = '' ) {
    105105
    106         /** This action is documented in bp-forums/bp-forums-screens */
     106        /** This action is documented in bp-forums/bp-forums-screens.php */
    107107        do_action( 'bbpress_init' );
    108108
     
    124124 * Wrapper for {@link bb_update_forum(}.
    125125 *
    126  * @param array $args {
     126 * @param array|string $args {
    127127 *     Forum setup arguments.
    128  *     @type int $forum_id ID of the forum to be updated.
    129  *     @type string $forum_name Name of the forum.
    130  *     @type string $forum_desc Description of the forum.
    131  *     @type int $forum_parent_id ID of the forum parent. Default: value of
    132  *           {@link bp_forums_parent_forums_id()}.
    133  *     @type bool $forum_order Order.
    134  *     @type int $forum_is_category Whether the forum is a category. Default: 0.
     128 *     @type int    $forum_id          ID of the forum to be updated.
     129 *     @type string $forum_name        Name of the forum.
     130 *     @type string $forum_desc        Description of the forum.
     131 *     @type int    $forum_parent_id  ID of the forum parent. Default: value of
     132 *                                     {@link bp_forums_parent_forums_id()}.
     133 *     @type bool   $forum_order      Order.
     134 *     @type int    $forum_is_category Whether the forum is a category. Default: 0.
    135135 * }
    136136 * @return bool True on success, false on failure.
     
    138138function bp_forums_update_forum( $args = '' ) {
    139139
    140         /** This action is documented in bp-forums/bp-forums-screens */
     140        /** This action is documented in bp-forums/bp-forums-screens.php */
    141141        do_action( 'bbpress_init' );
    142142
     
    165165        if ( !empty( $forum_id ) && is_int( $forum_id ) ) {
    166166
    167                 /** This action is documented in bp-forums/bp-forums-screens */
     167                /** This action is documented in bp-forums/bp-forums-screens.php */
    168168                do_action( 'bbpress_init' );
    169169                bb_delete_forum( $forum_id );
     
    177177 * Fetch a set of forum topics.
    178178 *
    179  * @param array $args {
    180  *     @type string @type Order or filter type. Default: 'newest'.
    181  *     @type int $forum_id Optional. Pass a forum ID to limit results to topics
    182  *           associated with that forum.
    183  *     @type int $user_id Optional. Pass a user ID to limit results to topics
    184  *           belonging to that user.
    185  *     @type int $page Optional. Number of the results page to return.
    186  *           Default: 1.
    187  *     @type int $per_page Optional. Number of results to return per page.
    188  *           Default: 15.
    189  *     @type int $offset Optional. Numeric offset for results.
    190  *     @type int $number
    191  *     @type array $exclude Optional. Topic IDs to exclude.
     179 * @param array|string $args {
     180 *     @type string $type          Order or filter type. Default: 'newest'.
     181 *     @type int    $forum_id      Optional. Pass a forum ID to limit results to topics
     182 *                                 associated with that forum.
     183 *     @type int    $user_id      Optional. Pass a user ID to limit results to topics
     184 *                                 belonging to that user.
     185 *     @type int    $page          Optional. Number of the results page to return.
     186 *                                 Default: 1.
     187 *     @type int    $per_page      Optional. Number of results to return per page.
     188 *                                 Default: 15.
     189 *     @type int    $offset        Optional. Numeric offset for results.
     190 *     @type int    $number        Amount to query for.
     191 *     @type array  $exclude      Optional. Topic IDs to exclude.
    192192 *     @type string $show_stickies Whether to show sticky topics.
    193  *     @type mixed $filter If $type = 'tag', filter is the tag name. Otherwise,
    194  *           $filter is terms to search on.
     193 *     @type mixed  $filter        If $type = 'tag', filter is the tag name. Otherwise,
     194 *                                 $filter is terms to search on.
    195195 * }
    196196 * @return array Found topics.
     
    198198function bp_forums_get_forum_topics( $args = '' ) {
    199199
    200         /** This action is documented in bp-forums/bp-forums-screens */
     200        /** This action is documented in bp-forums/bp-forums-screens.php */
    201201        do_action( 'bbpress_init' );
    202202
     
    211211                'exclude'       => false,
    212212                'show_stickies' => 'all',
    213                 'filter'        => false // if $type = tag then filter is the tag name, otherwise it's terms to search on.
     213                'filter'        => false // If $type = tag then filter is the tag name, otherwise it's terms to search on.
    214214        ) );
    215215        extract( $r, EXTR_SKIP );
     
    260260function bp_forums_get_topic_details( $topic_id ) {
    261261
    262         /** This action is documented in bp-forums/bp-forums-screens */
     262        /** This action is documented in bp-forums/bp-forums-screens.php */
    263263        do_action( 'bbpress_init' );
    264264
     
    278278function bp_forums_get_topic_id_from_slug( $topic_slug ) {
    279279
    280         /** This action is documented in bp-forums/bp-forums-screens */
     280        /** This action is documented in bp-forums/bp-forums-screens.php */
    281281        do_action( 'bbpress_init' );
    282282
     
    290290 * Create a new forum topic.
    291291 *
    292  * @param array $args {
    293  *     @type string $topic_title Title of the new topic.
    294  *     @type string $topic_slug Slug of the new topic.
    295  *     @type string $topic_text Text of the new topic.
    296  *     @type int $topic_poster ID of the user posting the topic. Default: ID of
    297  *           the logged-in user.
    298  *     @type string $topic_poster_name Display name of the user posting the
    299  *           topic. Default: 'fullname' of the logged-in user.
    300  *     @type id $topic_last_poster ID of the user who last posted to the topic.
    301  *           Default: ID of the logged-in user.
    302  *     @type string $topic_last_poster_name Display name of the user who last
    303  *           posted to the topic. Default: 'fullname' of the logged-in user.
    304  *     @type string $topic_start_time Date/time when the topic was created.
    305  *           Default: the current time, as reported by bp_core_current_time().
    306  *     @type string $topic_time Date/time when the topic was created.
    307  *           Default: the current time, as reported by bp_core_current_time().
    308  *     @type int $topic_open Whether the topic is open. Default: 1 (open).
    309  *     @type array|string|bool $topic_tags Array or comma-separated list of
    310  *           topic tags. False to leave empty. Default: false.
    311  *     @type int $forum_id ID of the forum to which the topic belongs.
    312  *           Default: 0.
     292 * @param array|string $args {
     293 *     @type string            $topic_title            Title of the new topic.
     294 *     @type string            $topic_slug            Slug of the new topic.
     295 *     @type string            $topic_text            Text of the new topic.
     296 *     @type int               $topic_poster          ID of the user posting the topic. Default: ID of
     297 *                                                     the logged-in user.
     298 *     @type string            $topic_poster_name      Display name of the user posting the
     299 *                                                     topic. Default: 'fullname' of the logged-in user.
     300 *     @type int               $topic_last_poster      ID of the user who last posted to the topic.
     301 *                                                     Default: ID of the logged-in user.
     302 *     @type string            $topic_last_poster_name Display name of the user who last
     303 *                                                     posted to the topic. Default: 'fullname' of the logged-in user.
     304 *     @type string            $topic_start_time      Date/time when the topic was created.
     305 *                                                     Default: the current time, as reported by bp_core_current_time().
     306 *     @type string            $topic_time            Date/time when the topic was created.
     307 *                                                     Default: the current time, as reported by bp_core_current_time().
     308 *     @type int               $topic_open            Whether the topic is open. Default: 1 (open).
     309 *     @type array|string|bool $topic_tags             Array or comma-separated list of
     310 *                                                     topic tags. False to leave empty. Default: false.
     311 *     @type int               $forum_id              ID of the forum to which the topic belongs.
     312 *                                                     Default: 0.
    313313 * }
    314314 * @return object Details about the new topic, as returned by
    315  *         {@link bp_forums_get_topic_details()}.
     315 *                {@link bp_forums_get_topic_details()}.
    316316 */
    317317function bp_forums_new_topic( $args = '' ) {
    318318        $bp = buddypress();
    319319
    320         /** This action is documented in bp-forums/bp-forums-screens */
     320        /** This action is documented in bp-forums/bp-forums-screens.php */
    321321        do_action( 'bbpress_init' );
    322322
     
    325325                'topic_slug'             => '',
    326326                'topic_text'             => '',
    327                 'topic_poster'           => bp_loggedin_user_id(),       // accepts ids
    328                 'topic_poster_name'      => $bp->loggedin_user->fullname, // accept names
    329                 'topic_last_poster'      => bp_loggedin_user_id(),       // accepts ids
    330                 'topic_last_poster_name' => $bp->loggedin_user->fullname, // accept names
     327                'topic_poster'           => bp_loggedin_user_id(),       // Accepts ids.
     328                'topic_poster_name'      => $bp->loggedin_user->fullname, // Accept names.
     329                'topic_last_poster'      => bp_loggedin_user_id(),       // Accepts ids.
     330                'topic_last_poster_name' => $bp->loggedin_user->fullname, // Accept names.
    331331                'topic_start_time'       => bp_core_current_time(),
    332332                'topic_time'             => bp_core_current_time(),
    333333                'topic_open'             => 1,
    334                 'topic_tags'             => false, // accepts array or comma delimited
    335                 'forum_id'               => 0      // accepts ids or slugs
     334                'topic_tags'             => false, // Accepts array or comma delimited.
     335                'forum_id'               => 0      // Accepts ids or slugs.
    336336        ) );
    337337        extract( $r, EXTR_SKIP );
     
    373373 * Update a topic's details.
    374374 *
    375  * @param array $args {
     375 * @param array|string $args {
    376376 *     Array of arguments.
    377  *     @type int $topic_id ID of the topic being updated.
    378  *     @type string $topic_title Updated title of the topic.
    379  *     @type string $topic_title Updated text of the topic.
    380  *     @type array|string|bool $topic_tags Array or comma-separated list of
    381  *           topic tags. False to leave empty. Default: false.
     377 *     @type int               $topic_id    ID of the topic being updated.
     378 *     @type string            $topic_title Updated title of the topic.
     379 *     @type string            $topic_text  Updated text of the topic.
     380 *     @type array|string|bool $topic_tags  Array or comma-separated list of
     381 *                                          topic tags. False to leave empty.
     382 *                                          Default false.
    382383 * }
    383384 * @return object Details about the new topic, as returned by
    384  *         {@link bp_forums_get_topic_details()}.
     385 *                {@link bp_forums_get_topic_details()}.
    385386 */
    386387function bp_forums_update_topic( $args = '' ) {
    387388
    388         /** This action is documented in bp-forums/bp-forums-screens */
     389        /** This action is documented in bp-forums/bp-forums-screens.php */
    389390        do_action( 'bbpress_init' );
    390391
     
    397398        extract( $r, EXTR_SKIP );
    398399
    399         // Check if the user is a spammer
     400        // Check if the user is a spammer.
    400401        if ( bp_is_user_inactive( bp_loggedin_user_id() ) )
    401402                return false;
    402403
    403         // bb_insert_topic() will append tags, but not remove them. So we remove all existing tags.
     404        // The bb_insert_topic() function will append tags, but not remove them. So we remove all existing tags.
    404405        bb_remove_topic_tags( $topic_id );
    405406
     
    410411                return false;
    411412
    412         // Update the first post
     413        // Update the first post.
    413414        if ( !$post = bp_forums_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) )
    414415                return false;
     
    419420function bp_forums_sticky_topic( $args = '' ) {
    420421
    421         /** This action is documented in bp-forums/bp-forums-screens */
     422        /** This action is documented in bp-forums/bp-forums-screens.php */
    422423        do_action( 'bbpress_init' );
    423424
    424425        $r = wp_parse_args( $args, array(
    425426                'topic_id' => false,
    426                 'mode'     => 'stick' // stick/unstick
     427                'mode'     => 'stick' // Stick/unstick.
    427428        ) );
    428429        extract( $r, EXTR_SKIP );
     
    439440 * Set a topic's open/closed status.
    440441 *
    441  * @param array $args {
    442  *     @type int $topic_id ID of the topic whose status is being changed.
    443  *     @type string $mode New status of the topic. 'open' or 'close'.
    444  *           Default: 'close'.
     442 * @param array|string $args {
     443 *     @type int    $topic_id ID of the topic whose status is being changed.
     444 *     @type string $mode     New status of the topic. 'open' or 'close'.
     445 *                            Default: 'close'.
    445446 * }
    446447 * @return bool True on success, false on failure.
     
    448449function bp_forums_openclose_topic( $args = '' ) {
    449450
    450         /** This action is documented in bp-forums/bp-forums-screens */
     451        /** This action is documented in bp-forums/bp-forums-screens.php */
    451452        do_action( 'bbpress_init' );
    452453
    453454        $r = wp_parse_args( $args, array(
    454455                'topic_id' => false,
    455                 'mode'     => 'close' // stick/unstick
     456                'mode'     => 'close' // Stick/unstick.
    456457        ) );
    457458        extract( $r, EXTR_SKIP );
     
    468469 * Delete a topic.
    469470 *
    470  * @param array $args {
     471 * @param array|string $args {
    471472 *     @type int $topic_id ID of the topic being deleted.
    472473 * }
     
    475476function bp_forums_delete_topic( $args = '' ) {
    476477
    477         /** This action is documented in bp-forums/bp-forums-screens */
     478        /** This action is documented in bp-forums/bp-forums-screens.php */
    478479        do_action( 'bbpress_init' );
    479480
     
    494495        global $bbdb;
    495496
    496         /** This action is documented in bp-forums/bp-forums-screens */
     497        /** This action is documented in bp-forums/bp-forums-screens.php */
    497498        do_action( 'bbpress_init' );
    498499
     
    528529 * @since 1.6.0
    529530 *
    530  * @param string $text The text of the comment.
    531  * @param int $topic_id The topic id.
    532  * @param int $user_id The user id.
     531 * @param string $text     The text of the comment.
     532 * @param int    $topic_id The topic id.
     533 * @param int    $user_id The user id.
    533534 * @return bool True if a duplicate reply exists, otherwise false.
    534535 */
     
    539540        if ( $text && $topic_id && $user_id ) {
    540541
    541                 /** This action is documented in bp-forums/bp-forums-screens */
     542                /** This action is documented in bp-forums/bp-forums-screens.php */
    542543                do_action( 'bbpress_init' );
    543544
     
    547548                );
    548549
    549                 // Set the reply_exists_text so we can check it in the filter below
     550                // Set the reply_exists_text so we can check it in the filter below.
    550551                buddypress()->forums->reply_exists_text = $text;
    551552
    552                 // BB_Query's post_text parameter does a MATCH, while we need exact matches
     553                // BB_Query's post_text parameter does a MATCH, while we need exact matches.
    553554                add_filter( 'get_posts_where', '_bp_forums_reply_exists_posts_where' );
    554555                $query = new BB_Query( 'post', $args );
    555556                remove_filter( 'get_posts_where', '_bp_forums_reply_exists_posts_where' );
    556557
    557                 // Cleanup
     558                // Cleanup.
    558559                unset( buddypress()->forums->reply_exists_text );
    559560
     
    574575}
    575576        /**
    576          * Private one-time-use function used in conjunction with bp_forums_reply_exists()
     577         * Private one-time-use function used in conjunction with bp_forums_reply_exists().
    577578         *
    578579         * @access private
     
    591592 * Get a total "Topics Started" count for a given user.
    592593 *
    593  * @param int $user_id ID of the user being queried. Falls back on displayed
    594  *        user, then loggedin.
    595  * @param string $type The current filter/sort type. 'active', 'popular',
    596  *        'unreplied'.
     594 * @param int    $user_id ID of the user being queried. Falls back on displayed
     595 *                        user, then loggedin.
     596 * @param string $type    The current filter/sort type. 'active', 'popular',
     597 *                        'unreplied'.
    597598 * @return int $count The topic count.
    598599 */
    599600function bp_forums_total_topic_count_for_user( $user_id = 0, $type = 'active' ) {
    600601
    601         /** This action is documented in bp-forums/bp-forums-screens */
     602        /** This action is documented in bp-forums/bp-forums-screens.php */
    602603        do_action( 'bbpress_init' );
    603604
     
    634635 * @since 1.5.0
    635636 *
    636  * @param int $user_id ID of the user whose replied topics are being counted.
    637  *        Defaults to displayed user, then to logged-in user.
     637 * @param int    $user_id ID of the user whose replied topics are being counted.
     638 *                        Defaults to displayed user, then to logged-in user.
     639 * @param string $type    Forum thread type.
    638640 * @return int $count Topic count.
    639641 */
    640642function bp_forums_total_replied_count_for_user( $user_id = 0, $type = 'active' ) {
    641643
    642         /** This action is documented in bp-forums/bp-forums-screens */
     644        /** This action is documented in bp-forums/bp-forums-screens.php */
    643645        do_action( 'bbpress_init' );
    644646
     
    652654                $query = new BB_Query( 'post', array( 'post_author_id' => $user_id, 'page' => 1, 'per_page' => -1, 'count' => true ) );
    653655
    654                 // Count the unique topics. No better way to do this in the bbPress query API
     656                // Count the unique topics. No better way to do this in the bbPress query API.
    655657                $topics = array();
    656658                foreach( $query->results as $result ) {
     
    659661                }
    660662
    661                 // Even more unfortunate. If this is filtered by 'unreplied', we have to requery
     663                // Even more unfortunate. If this is filtered by 'unreplied', we have to requery.
    662664                if ( 'unreplied' == $type ) {
    663665                        $topic_ids = implode( ',', $topics );
     
    702704        $bp = buddypress();
    703705
    704         // Get the topic ids
     706        // Get the topic ids.
    705707        foreach ( (array) $topics as $topic ) $topic_ids[] = $topic->topic_id;
    706708        $topic_ids = implode( ',', wp_parse_id_list( $topic_ids ) );
    707709
    708         // Fetch the topic's last poster details
     710        // Fetch the topic's last poster details.
    709711        $poster_details = $wpdb->get_results( "SELECT t.topic_id, t.topic_last_poster, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u, {$bbdb->topics} t WHERE u.ID = t.topic_last_poster AND t.topic_id IN ( {$topic_ids} )" );
    710712        for ( $i = 0, $count = count( $topics ); $i < $count; ++$i ) {
     
    719721        }
    720722
    721         // Fetch fullname for the topic's last poster
     723        // Fetch fullname for the topic's last poster.
    722724        if ( bp_is_active( 'xprofile' ) ) {
    723725                $poster_names = $wpdb->get_results( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" );
     
    731733
    732734        // Loop through to make sure that each topic has the proper values set. This covers the
    733         // case of deleted users
     735        // case of deleted users.
    734736        foreach ( (array) $topics as $key => $topic ) {
    735737                if ( !isset( $topic->topic_last_poster_email ) )
     
    754756 * Get the posts belonging to a topic.
    755757 *
    756  * @param array $args {
    757  *     @type int $topic_id ID of the topic for which posts are being fetched.
    758  *     @type int $page Optional. Page of results to return. Default: 1.
    759  *     @type int $page Optional. Number of results to return per page.
    760  *           Default: 15.
    761  *     @type string $order 'ASC' or 'DESC'. Default: 'ASC'.
     758 * @param array|string $args {
     759 *     @type int    $topic_id ID of the topic for which posts are being fetched.
     760 *     @type int    $page    Optional. Page of results to return. Default: 1.
     761 *     @type int    $page    Optional. Number of results to return per page.
     762 *                            Default: 15.
     763 *     @type string $order    'ASC' or 'DESC'. Default: 'ASC'.
    762764 * }
    763765 * @return array List of posts.
     
    765767function bp_forums_get_topic_posts( $args = '' ) {
    766768
    767         /** This action is documented in bp-forums/bp-forums-screens */
     769        /** This action is documented in bp-forums/bp-forums-screens.php */
    768770        do_action( 'bbpress_init' );
    769771
     
    791793function bp_forums_get_post( $post_id ) {
    792794
    793         /** This action is documented in bp-forums/bp-forums-screens */
     795        /** This action is documented in bp-forums/bp-forums-screens.php */
    794796        do_action( 'bbpress_init' );
    795797        return bb_get_post( $post_id );
     
    801803 * Wrapper for {@link bb_delete_post()}.
    802804 *
    803  * @param array $args {
     805 * @param array|string $args {
    804806 *     @type int $post_id ID of the post being deleted.
    805807 * }
     
    808810function bp_forums_delete_post( $args = '' ) {
    809811
    810         /** This action is documented in bp-forums/bp-forums-screens */
     812        /** This action is documented in bp-forums/bp-forums-screens.php */
    811813        do_action( 'bbpress_init' );
    812814
     
    823825 * Create a new post.
    824826 *
    825  * @param array $args {
    826  *     @type int $post_id Optional. ID of an existing post, if you want to
    827  *           update rather than create. Default: false.
    828  *     @type int $topic_id ID of the topic to which the post belongs.
    829  *     @type string $post_text Contents of the post.
    830  *     @type string $post_time Optional. Time when the post was recorded.
    831  *           Default: current time, as reported by {@link bp_core_current_time()}.
    832  *     @type int $poster_id Optional. ID of the user creating the post.
    833  *           Default: ID of the logged-in user.
    834  *     @type string $poster_ip Optional. IP address of the user creating the
    835  *           post. Default: the IP address found in $_SERVER['REMOTE_ADDR'].
    836  *     @type int $post_status Post status. Default: 0.
    837  *     @type int $post_position Optional. Default: false (auto).
     827 * @param array|string $args {
     828 *     @type int    $post_id      Optional. ID of an existing post, if you want to
     829 *                                 update rather than create. Default: false.
     830 *     @type int    $topic_id      ID of the topic to which the post belongs.
     831 *     @type string $post_text     Contents of the post.
     832 *     @type string $post_time     Optional. Time when the post was recorded.
     833 *                                 Default: current time, as reported by {@link bp_core_current_time()}.
     834 *     @type int    $poster_id    Optional. ID of the user creating the post.
     835 *                                 Default: ID of the logged-in user.
     836 *     @type string $poster_ip     Optional. IP address of the user creating the
     837 *                                 post. Default: the IP address found in $_SERVER['REMOTE_ADDR'].
     838 *     @type int    $post_status  Post status. Default: 0.
     839 *     @type int    $post_position Optional. Default: false (auto).
    838840 * }
    839841 * @return int|bool ID of the new post on success, false on failure.
     
    841843function bp_forums_insert_post( $args = '' ) {
    842844
    843         /** This action is documented in bp-forums/bp-forums-screens */
     845        /** This action is documented in bp-forums/bp-forums-screens.php */
    844846        do_action( 'bbpress_init' );
    845847
     
    849851                'post_text'     => '',
    850852                'post_time'     => bp_core_current_time(),
    851                 'poster_id'     => bp_loggedin_user_id(), // accepts ids or names
     853                'poster_id'     => bp_loggedin_user_id(), // Accepts ids or names.
    852854                'poster_ip'     => $_SERVER['REMOTE_ADDR'],
    853                 'post_status'   => 0, // use bb_delete_post() instead
     855                'post_status'   => 0, // Use bb_delete_post() instead.
    854856                'post_position' => false
    855857        );
     
    914916        $bp = buddypress();
    915917
    916         // Get the user ids
     918        // Get the user ids.
    917919        foreach ( (array) $posts as $post ) $user_ids[] = $post->poster_id;
    918920        $user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
    919921
    920         // Fetch the poster's user_email, user_nicename and user_login
     922        // Fetch the poster's user_email, user_nicename and user_login.
    921923        $poster_details = $wpdb->get_results( "SELECT u.ID as user_id, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u WHERE u.ID IN ( {$user_ids} )" );
    922924
     
    958960 * @param int $forum_id ID of the forum.
    959961 * @return object Object with properties $topics (topic count) and $posts
    960  *         (post count).
     962 *                (post count).
    961963 */
    962964function bp_forums_get_forum_topicpost_count( $forum_id ) {
    963965        global $wpdb, $bbdb;
    964966
    965         /** This action is documented in bp-forums/bp-forums-screens */
    966         do_action( 'bbpress_init' );
    967 
    968         // Need to find a bbPress function that does this
     967        /** This action is documented in bp-forums/bp-forums-screens.php */
     968        do_action( 'bbpress_init' );
     969
     970        // Need to find a bbPress function that does this.
    969971        return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) );
    970972}
     
    10231025 *
    10241026 * @return bool True if stickies should be displayed at the top of the global
    1025  *         directory, otherwise false.
     1027 *              directory, otherwise false.
    10261028 */
    10271029function bp_forums_enable_global_directory_stickies() {
     
    10451047 */
    10461048
    1047 // List actions to clear super cached pages on, if super cache is installed
     1049// List actions to clear super cached pages on, if super cache is installed.
    10481050add_action( 'bp_forums_new_forum', 'bp_core_clear_cache' );
    10491051add_action( 'bp_forums_new_topic', 'bp_core_clear_cache' );
     
    10771079 * Wrapper function for {@link bb_get_postmeta()}.
    10781080 *
    1079  * @package BuddyPress_Forums
    10801081 * @since 1.5.0
     1082 *
     1083 * @param object $cache    Cache object.
     1084 * @param int    $id       ID of the forum being cached.
     1085 * @param string $cachekey Key to use with forum embed cache.
    10811086 */
    10821087function bp_embed_forum_cache( $cache, $id, $cachekey ) {
     
    10901095 *
    10911096 * @since 1.5.0
     1097 *
     1098 * @param object $cache    Cache object.
     1099 * @param string $cachekey Key to use with forum embed cache.
     1100 * @param int    $id       ID of the forum being cached.
    10921101 */
    10931102function bp_embed_forum_save_cache( $cache, $cachekey, $id ) {
  • trunk/src/bp-forums/bp-forums-loader.php

    r10096 r10183  
    11<?php
    22/**
    3  * BuddyPress Forums Loader
     3 * BuddyPress Forums Loader.
    44 *
    55 * A discussion forums component. Comes bundled with bbPress stand-alone.
     
    4848                $bp = buddypress();
    4949
    50                 // Define the parent forum ID
     50                // Define the parent forum ID.
    5151                if ( ! defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) {
    5252                        define( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
    5353                }
    5454
    55                 // Define a slug, if necessary
     55                // Define a slug, if necessary.
    5656                if ( ! defined( 'BP_FORUMS_SLUG' ) ) {
    5757                        define( 'BP_FORUMS_SLUG', $this->id );
    5858                }
    5959
    60                 // The location of the bbPress stand-alone config file
     60                // The location of the bbPress stand-alone config file.
    6161                $bbconfig = bp_core_get_root_option( 'bb-config-location' );
    6262                if ( '' !== $bbconfig ) {
     
    8686        public function includes( $includes = array() ) {
    8787
    88                 // Files to include
     88                // Files to include.
    8989                $includes = array(
    9090                        'actions',
     
    9696                );
    9797
    98                 // bbPress stand-alone
     98                // bbPress stand-alone.
    9999                if ( ! defined( 'BB_PATH' ) ) {
    100100                        $includes[] = 'bbpress-sa';
    101101                }
    102102
    103                 // Admin-specific code
     103                // Admin-specific code.
    104104                if ( is_admin() ) {
    105105                        $includes[] = 'deprecated/1.6';
     
    118118         *
    119119         * @param array $main_nav Optional. See BP_Component::setup_nav() for
    120          *        description.
    121          * @param array $sub_nav Optional. See BP_Component::setup_nav() for
    122          *        description.
     120         *                        description.
     121         * @param array $sub_nav  Optional. See BP_Component::setup_nav() for
     122         *                        description.
    123123         */
    124124        public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    125125
    126                 // Stop if forums haven't been set up yet
     126                // Stop if forums haven't been set up yet.
    127127                if ( ! bp_forums_is_installed_correctly() ) {
    128128                        return;
    129129                }
    130130
    131                 // Stop if there is no user displayed or logged in
     131                // Stop if there is no user displayed or logged in.
    132132                if ( ! is_user_logged_in() && ! bp_displayed_user_id() ) {
    133133                        return;
    134134                }
    135135
    136                 // Determine user to use
     136                // Determine user to use.
    137137                if ( bp_displayed_user_domain() ) {
    138138                        $user_domain = bp_displayed_user_domain();
     
    143143                }
    144144
    145                 // User link
     145                // User link.
    146146                $slug        = bp_get_forums_slug();
    147147                $forums_link = trailingslashit( $user_domain . $slug );
    148148
    149                 // Add 'Forums' to the main navigation
     149                // Add 'Forums' to the main navigation.
    150150                $main_nav = array(
    151151                        'name'                => __( 'Forums', 'buddypress' ),
     
    157157                );
    158158
    159                 // Topics started
     159                // Topics started.
    160160                $sub_nav[] = array(
    161161                        'name'            => __( 'Topics Started', 'buddypress' ),
     
    168168                );
    169169
    170                 // Topics replied to
     170                // Topics replied to.
    171171                $sub_nav[] = array(
    172172                        'name'            => __( 'Replied To', 'buddypress' ),
     
    190190         *
    191191         * @param array $wp_admin_nav See BP_Component::setup_admin_bar()
    192          *        for description.
     192         *                            for description.
    193193         */
    194194        public function setup_admin_bar( $wp_admin_nav = array() ) {
    195195
    196                 // Menus for logged in user
     196                // Menus for logged in user.
    197197                if ( is_user_logged_in() ) {
    198198
    199                         // Setup the logged in user variables
     199                        // Setup the logged in user variables.
    200200                        $forums_link = trailingslashit( bp_loggedin_user_domain() . bp_get_forums_slug() );
    201201
    202                         // Add the "My Account" sub menus
     202                        // Add the "My Account" sub menus.
    203203                        $wp_admin_nav[] = array(
    204204                                'parent' => buddypress()->my_account_menu_id,
     
    208208                        );
    209209
    210                         // Topics
     210                        // Topics.
    211211                        $wp_admin_nav[] = array(
    212212                                'parent' => 'my-account-' . $this->id,
     
    216216                        );
    217217
    218                         // Replies
     218                        // Replies.
    219219                        $wp_admin_nav[] = array(
    220220                                'parent' => 'my-account-' . $this->id,
     
    224224                        );
    225225
    226                         // Favorites
     226                        // Favorites.
    227227                        $wp_admin_nav[] = array(
    228228                                'parent' => 'my-account-' . $this->id,
     
    241241        public function setup_title() {
    242242
    243                 // Adjust title based on view
     243                // Adjust title based on view.
    244244                if ( bp_is_forums_component() ) {
    245245                        $bp = buddypress();
  • trunk/src/bp-forums/bp-forums-screens.php

    r10096 r10183  
    1515function bp_forums_directory_forums_setup() {
    1616
    17         // Get BuddyPress once
     17        // Get BuddyPress once.
    1818        $bp = buddypress();
    1919
     
    4242                        $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) );
    4343                        if ( !empty( $bp->groups->current_group->id ) ) {
    44                                 // Auto join this user if they are not yet a member of this group
     44                                // Auto join this user if they are not yet a member of this group.
    4545                                if ( !bp_current_user_can( 'bp_moderate' ) && 'public' == $bp->groups->current_group->status && !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) )
    4646                                        groups_join_group( $bp->groups->current_group->id );
     
    7575                                }
    7676
    77                         }        else {
     77                        } else {
    7878                                bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );
    7979                                bp_core_redirect( add_query_arg( 'new', '', bp_get_forums_directory_permalink() ) );
     
    249249        public function is_legacy_forum() {
    250250
    251                 // Bail if not looking at a group
     251                // Bail if not looking at a group.
    252252                if ( ! bp_is_forums_component() )
    253253                        return;
    254254
    255                 // forum Directory
     255                // Forum Directory.
    256256                if ( ( ! bp_current_action() || ( 'tag' == bp_current_action() && bp_action_variables() ) ) && ! bp_current_item() ) {
    257257
     
    284284        public function directory_dummy_post() {
    285285
    286                 // Title based on ability to create groups
     286                // Title based on ability to create groups.
    287287                if ( is_user_logged_in() ) {
    288288                        $title = __( 'Forums', 'buddypress' ) . '&nbsp;<a class="button show-hide-new bp-title-button" href="#new-topic" id="new-topic-button">' . __( 'New Topic', 'buddypress' ) . '</a>';
  • trunk/src/bp-forums/bp-forums-template.php

    r10126 r10183  
    213213         * Constructor method.
    214214         *
    215          * @param string $type The 'type' is the sort order/kind. 'newest',
    216          *        'popular', 'unreplied', 'tags'.
    217          * @param int $forum_id The ID of the forum for which topics are being
    218          *        queried.
    219          * @param int $user_id The ID of the user to whom topics should be
    220          *        limited. Pass false to remove this filter.
    221          * @param int $page The number of the page being requested.
    222          * @param int $per_page The number of items being requested per page.
    223          * @param string $no_stickies Requested sticky format.
    224          * @param string $search_terms Filter results by a string.
    225          * @param int $offset Optional. Offset results by a given numeric value.
    226          * @param int $number Optional. Total number of items to retrieve.
     215         * @param string   $type         The 'type' is the sort order/kind. 'newest',
     216         *                               'popular', 'unreplied', 'tags'.
     217         * @param int      $forum_id     The ID of the forum for which topics are being
     218         *                               queried.
     219         * @param int      $user_id      The ID of the user to whom topics should be
     220         *                               limited. Pass false to remove this filter.
     221         * @param int      $page         The number of the page being requested.
     222         * @param int      $per_page     The number of items being requested per page.
     223         * @param int      $max          Max amount to retrieve.
     224         * @param string   $no_stickies  Requested sticky format.
     225         * @param string   $search_terms Filter results by a string.
     226         * @param int|bool $offset       Optional. Offset results by a given numeric value.
     227         * @param int|bool $number       Optional. Total number of items to retrieve.
    227228         */
    228229        function __construct( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $offset = false, $number = false ) {
     
    275276                } else {
    276277                        // Get a total topic count, for use in pagination. This value will differ
    277                         // depending on scope
     278                        // depending on scope.
    278279                        if ( !empty( $forum_id ) ) {
    279                                 // Group forums
     280                                // Group forums.
    280281                                $topic_count = bp_forums_get_forum( $forum_id );
    281282                                $topic_count = (int) $topic_count->topics;
     
    284285                        } else if ( bp_is_user_forums_started() || ( bp_is_directory() && $user_id ) ) {
    285286                                // This covers the case of Profile > Forums > Topics Started, as
    286                                 // well as Forum Directory > My Topics
     287                                // well as Forum Directory > My Topics.
    287288                                $topic_count = bp_forums_total_topic_count_for_user( bp_displayed_user_id(), $type );
    288289                        } else if ( bp_is_user_forums_replied_to() ) {
    289                                 // Profile > Forums > Replied To
     290                                // Profile > Forums > Replied To.
    290291                                $topic_count = bp_forums_total_replied_count_for_user( bp_displayed_user_id(), $type );
    291292                        } else if ( 'tags' == $type ) {
     
    294295                        } else {
    295296                                // For forum directories (All Topics), get a true count
    296                                 $status = bp_current_user_can( 'bp_moderate' ) ? 'all' : 'public'; // todo: member-of
     297                                $status = bp_current_user_can( 'bp_moderate' ) ? 'all' : 'public'; // @todo: member-of.
    297298                                $topic_count = (int)groups_total_forum_topic_count( $status, $search_terms );
    298299                        }
     
    348349                $this->total_topic_count = apply_filters_ref_array( 'bp_forums_template_total_topic_count', array( $this->total_topic_count, $this->topic_count, &$this->topics, $type, $forum_id, $per_page, $max, $no_stickies ) );
    349350
    350                 // Fetch extra information for topics, so we don't have to query inside the loop
     351                // Fetch extra information for topics, so we don't have to query inside the loop.
    351352                $this->topics = bp_forums_get_topic_extras( $this->topics );
    352353
     
    373374         */
    374375        function has_topics() {
    375                 if ( $this->topic_count )
     376                if ( $this->topic_count ) {
    376377                        return true;
     378                }
    377379
    378380                return false;
     
    423425                         */
    424426                        do_action('forum_loop_end');
    425                         // Do some cleaning up after the loop
     427                        // Do some cleaning up after the loop.
    426428                        $this->rewind_topics();
    427429                }
     
    466468 *       of has_topics().
    467469 *
    468  * @param array $args {
     470 * @param array|string $args {
    469471 *     Arguments for limiting the contents of the forum topics loop.
    470472 *
    471  *     @type string $type The 'type' is the sort order/kind. 'newest',
    472  *           'popular', 'unreplied', 'tags'. Default: 'newest'.
    473  *     @type int $forum_id The ID of the forum for which topics are being
    474  *           queried. Default: the ID of the forum belonging to the current
    475  *           group, if available.
    476  *     @type int $user_id The ID of a user to whom to limit results. If viewing
    477  *           a member's profile, defaults to that member's ID; otherwise
    478  *           defaults to 0.
    479  *     @type int $page The number of the page being requested. Default: 1, or
    480  *           the value of $_GET['p'].
    481  *     @type int $per_pag The number items to return per page. Default: 20, or
    482  *           the value of $_GET['n'].
    483  *     @type int $max Optional. Max records to return. Default: false (no max).
    484  *     @type int $number Optional. Number of records to return. Default: false.
    485  *     @type int $offset Optional. Offset results by a given value.
    486  *           Default: false.
    487  *     @type string $search_terms Optional. A string to which results should be
    488  *           limited. Default: false, or the value of $_GET['fs'].
    489  *     @type string|bool $do_stickies Whether to move stickies to the top of
    490  *           the sort order. Default: true if looking at a group forum,
    491  *           otherwise false.
     473 *     @type string      $type        The 'type' is the sort order/kind. 'newest',
     474 *                                     'popular', 'unreplied', 'tags'. Default: 'newest'.
     475 *     @type int         $forum_id    The ID of the forum for which topics are being
     476 *                                     queried. Default: the ID of the forum belonging to the current
     477 *                                     group, if available.
     478 *     @type int         $user_id      The ID of a user to whom to limit results. If viewing
     479 *                                     a member's profile, defaults to that member's ID; otherwise
     480 *                                     defaults to 0.
     481 *     @type int         $page        The number of the page being requested. Default: 1, or
     482 *                                     the value of $_GET['p'].
     483 *     @type int         $per_pag      The number items to return per page. Default: 20, or
     484 *                                     the value of $_GET['n'].
     485 *     @type int         $max          Optional. Max records to return. Default: false (no max).
     486 *     @type int         $number      Optional. Number of records to return. Default: false.
     487 *     @type int         $offset      Optional. Offset results by a given value.
     488 *                                     Default: false.
     489 *     @type string      $search_terms Optional. A string to which results should be
     490 *                                     limited. Default: false, or the value of $_GET['fs'].
     491 *     @type string|bool $do_stickies  Whether to move stickies to the top of
     492 *                                     the sort order. Default: true if looking at a group forum,
     493 *                                     otherwise false.
    492494 * }
    493495 * @return bool True when forum topics are found corresponding to the args,
     
    499501        $bp = buddypress();
    500502
    501         /***
     503        /*
    502504         * Set the defaults based on the current page. Any of these will be overridden
    503505         * if arguments are directly passed into the loop. Custom plugins should always
     
    510512        $do_stickies  = false;
    511513
    512         // User filtering
     514        // User filtering.
    513515        if ( bp_displayed_user_id() )
    514516                $user_id = bp_displayed_user_id();
     
    516518        // "Replied" query must be manually modified
    517519        if ( 'replies' == bp_current_action() ) {
    518                 $user_id = 0; // User id must be handled manually by the filter, not by BB_Query
     520                $user_id = 0; // User id must be handled manually by the filter, not by BB_Query.
    519521
    520522                add_filter( 'get_topics_distinct',   'bp_forums_add_replied_distinct_sql', 20 );
     
    523525        }
    524526
    525         // If we're in a single group, set this group's forum_id
     527        // If we're in a single group, set this group's forum_id.
    526528        if ( !$forum_id && !empty( $bp->groups->current_group ) ) {
    527529                $bp->groups->current_group->forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' );
    528530
    529531                // If it turns out there is no forum for this group, return false so
    530                 // we don't fetch all global topics
     532                // we don't fetch all global topics.
    531533                if ( empty( $bp->groups->current_group->forum_id ) )
    532534                        return false;
     
    535537        }
    536538
    537         // If $_GET['fs'] is set, let's auto populate the search_terms var
     539        // If $_GET['fs'] is set, let's auto populate the search_terms var.
    538540        if ( bp_is_directory() && !empty( $_GET['fs'] ) )
    539541                $search_terms = $_GET['fs'];
    540542
    541         // Get the pagination arguments from $_REQUEST
     543        // Get the pagination arguments from $_REQUEST.
    542544        $page     = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : 1;
    543545        $per_page = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : 20;
    544546
    545         // By default, stickies are only pushed to the top of the order on individual group forums
     547        // By default, stickies are only pushed to the top of the order on individual group forums.
    546548        if ( bp_is_group_forum() )
    547549                $do_stickies = true;
     
    564566
    565567        // If we're viewing a tag URL in the directory, let's override the type and
    566         // set it to tags and the filter to the tag name
     568        // set it to tags and the filter to the tag name.
    567569        if ( bp_is_current_action( 'tag' ) && $search_terms = bp_action_variable( 0 ) ) {
    568570                $type = 'tags';
     
    572574
    573575        if ( $do_stickies ) {
    574                 // Fetch the stickies
     576                // Fetch the stickies.
    575577                $stickies_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, 0, 0, $max, 'sticky', $search_terms );
    576578
    577                 // If stickies are found, try merging them
     579                // If stickies are found, try merging them.
    578580                if ( $stickies_template->has_topics() ) {
    579581
    580                         // If stickies are for current $page
     582                        // If stickies are for current $page.
    581583                        $page_start_num = ( ( $page - 1 ) * $per_page ) + 1;
    582584                        $page_end_num   = $page * $per_page <= $stickies_template->total_topic_count ? $page * $per_page : $stickies_template->total_topic_count;
    583585
    584                         // Calculate the number of sticky topics that will be shown on this page
     586                        // Calculate the number of sticky topics that will be shown on this page.
    585587                        if ( $stickies_template->topic_count < $page_start_num ) {
    586588                                $this_page_stickies = 0;
    587589                        } else {
    588                                 $this_page_stickies = $stickies_template->topic_count - $per_page * floor( $stickies_template->topic_count / $per_page ) * ( $page - 1 ); // Total stickies minus sticky count through this page
     590                                $this_page_stickies = $stickies_template->topic_count - $per_page * floor( $stickies_template->topic_count / $per_page ) * ( $page - 1 ); // Total stickies minus sticky count through this page.
    589591
    590592                                // $this_page_stickies cannot be more than $per_page or less than 0
     
    595597                        }
    596598
    597                         // Calculate the total number of topics that will be shown on this page
     599                        // Calculate the total number of topics that will be shown on this page.
    598600                        $this_page_topics = $stickies_template->total_topic_count >= ( $page * $per_page ) ? $per_page : $page_end_num - ( $page_start_num - 1 );
    599601
    600602                        // If the number of stickies to be shown is less than $per_page, fetch some
    601                         // non-stickies to fill in the rest
     603                        // non-stickies to fill in the rest.
    602604                        if ( $this_page_stickies < $this_page_topics ) {
    603605                                // How many non-stickies do we need?
     
    609611
    610612                                // The offset is the number of total non-stickies, less the number
    611                                 // to be shown on this page
     613                                // to be shown on this page.
    612614                                $non_sticky_offset = $non_sticky_total - $non_sticky_number;
    613615
    614                                 // Fetch the non-stickies
     616                                // Fetch the non-stickies.
    615617                                $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, 1, $per_page, $max, 'no', $search_terms, $non_sticky_offset, $non_sticky_number );
    616618
    617                                 // If there are stickies to merge on this page, do it now
     619                                // If there are stickies to merge on this page, do it now.
    618620                                if ( $this_page_stickies ) {
    619                                         // Correct the topic_count
     621                                        // Correct the topic_count.
    620622                                        $forum_template->topic_count += (int) $this_page_stickies;
    621623
    622                                         // Figure out which stickies need to be included
     624                                        // Figure out which stickies need to be included.
    623625                                        $this_page_sticky_topics = array_slice( $stickies_template->topics, 0 - $this_page_stickies );
    624626
    625                                         // Merge these topics into the forum template
     627                                        // Merge these topics into the forum template.
    626628                                        $forum_template->topics = array_merge( $this_page_sticky_topics, (array) $forum_template->topics );
    627629                                }
    628630                        } else {
    629                                 // This page has no non-stickies
     631                                // This page has no non-stickies.
    630632                                $forum_template = $stickies_template;
    631633
    632                                 // Adjust the topic count and trim the topics
     634                                // Adjust the topic count and trim the topics.
    633635                                $forum_template->topic_count = $this_page_stickies;
    634636                                $forum_template->topics      = array_slice( $forum_template->topics, $page - 1 );
     
    636638
    637639                        // Because we're using a manual offset and number for the topic query, we
    638                         // must set the page number manually, and recalculate the pagination links
     640                        // must set the page number manually, and recalculate the pagination links.
    639641                        $forum_template->pag_num     = $per_page;
    640642                        $forum_template->pag_page    = $page;
     
    652654
    653655                } else {
    654                         // Fetch the non-sticky topics if no stickies were found
     656                        // Fetch the non-sticky topics if no stickies were found.
    655657                        $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, 'all', $search_terms );
    656658                }
    657659        } else {
    658                 // When skipping the sticky logic, just pull up the forum topics like usual
     660                // When skipping the sticky logic, just pull up the forum topics like usual.
    659661                $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, 'all', $search_terms );
    660662        }
     
    822824 * @see bp_get_the_topic_poster_avatar() for a description of arguments.
    823825 *
    824  * @param array $args See {@link bp_get_the_topic_poster_avatar()}.
     826 * @param array|string $args See {@link bp_get_the_topic_poster_avatar()}.
    825827 */
    826828function bp_the_topic_poster_avatar( $args = '' ) {
     
    830832         * Return the avatar of the user who posted the current topic in the loop.
    831833         *
    832          * @param array $args {
     834         * @param array|string $args {
    833835         *     Arguments for building the avatar.
    834          *     @type string $type Avatar type. 'thumb' or 'full'. Default:
    835          *           'thumb'.
    836          *     @type int $width Width of the avatar, in pixels. Default: the
    837          *           width corresponding to $type.
    838          *           See {@link bp_core_fetch_avatar()}.
    839          *     @type int $height Height of the avatar, in pixels. Default: the
    840          *           height corresponding to $type.
    841          *           See {@link bp_core_fetch_avatar()}.
    842          *     @type string $alt The text of the image's 'alt' attribute.
    843          *           Default: 'Profile picture of [user name]'.
     836         *     @type string $type   Avatar type. 'thumb' or 'full'. Default:
     837         *                          'thumb'.
     838         *     @type int    $width Width of the avatar, in pixels. Default: the
     839         *                          width corresponding to $type.
     840         *                          See {@link bp_core_fetch_avatar()}.
     841         *     @type int    $height Height of the avatar, in pixels. Default: the
     842         *                          height corresponding to $type.
     843         *                          See {@link bp_core_fetch_avatar()}.
     844         *     @type string $alt    The text of the image's 'alt' attribute.
     845         *                          Default: 'Profile picture of [user name]'.
    844846         * }
    845847         * @return string HTML of user avatar.
     
    10061008        function bp_get_the_topic_object_permalink() {
    10071009
    1008                 // Currently this will only work with group forums, extended support in the future
     1010                // Currently this will only work with group forums, extended support in the future.
    10091011                if ( bp_is_active( 'groups' ) ) {
    10101012                        $permalink = trailingslashit( bp_get_groups_directory_permalink() . bp_get_the_topic_object_slug() . '/forum' );
     
    10361038         *
    10371039         * @return string HTML link to the profile of the user who last posted
    1038          *         to the current topic.
     1040         *                to the current topic.
    10391041         */
    10401042        function bp_get_the_topic_last_poster_name() {
     
    10441046
    10451047                // In the case where no user is found, bp_core_get_user_domain() may return the URL
    1046                 // of the Members directory
     1048                // of the Members directory.
    10471049                if ( empty( $domain ) || ( bp_get_members_directory_permalink() === $domain ) ) {
    10481050                        return __( 'Deleted User', 'buddypress' );
     
    10641066 * @see bp_get_the_topic_object_avatar() for description of arguments.
    10651067 *
    1066  * @param array $args See {@bp_get_the_topic_object_avatar()}.
     1068 * @param array|string $args See {@bp_get_the_topic_object_avatar()}.
    10671069 */
    10681070function bp_the_topic_object_avatar( $args = '' ) {
     
    10751077         * avatar of the group associated with the forum topic, if it exists.
    10761078         *
    1077          * @param array $args {
     1079         * @param array|string $args {
    10781080         *     Arguments for building the avatar.
    1079          *     @type string $type Avatar type. 'thumb' or 'full'. Default:
    1080          *           'thumb'.
    1081          *     @type int $width Width of the avatar, in pixels. Default: the
    1082          *           width corresponding to $type.
    1083          *           See {@link bp_core_fetch_avatar()}.
    1084          *     @type int $height Height of the avatar, in pixels. Default:
    1085          *           the height corresponding to $type.
    1086          *           See {@link bp_core_fetch_avatar()}.
    1087          *     @type string $alt The text of the image's 'alt' attribute.
    1088          *           Default: 'Group logo for [group name]'.
     1081         *     @type string $type   Avatar type. 'thumb' or 'full'. Default:
     1082         *                         'thumb'.
     1083         *     @type int    $width Width of the avatar, in pixels. Default: the
     1084         *                          width corresponding to $type.
     1085         *                          See {@link bp_core_fetch_avatar()}.
     1086         *     @type int    $height Height of the avatar, in pixels. Default:
     1087         *                          the height corresponding to $type.
     1088         *                          See {@link bp_core_fetch_avatar()}.
     1089         *     @type string $alt    The text of the image's 'alt' attribute.
     1090         *                          Default: 'Group logo for [group name]'.
    10891091         * }
    10901092         * @return string Object avatar.
     
    11211123 * @see bp_get_the_topic_last_poster_avatar() for description of arguments.
    11221124 *
    1123  * @param array $args See {@bp_get_the_topic_last_poster_avatar()}.
     1125 * @param array|string $args See {@bp_get_the_topic_last_poster_avatar()}.
    11241126 */
    11251127function bp_the_topic_last_poster_avatar( $args = '' ) {
     
    11291131         * Return the avatar for the user who last posted to the current topic in the loop.
    11301132         *
    1131          * @param array $args {
     1133         * @param array|string $args {
    11321134         *     Arguments for building the avatar.
    1133          *     @type string $type Avatar type. 'thumb' or 'full'. Default:
    1134          *           'thumb'.
    1135          *     @type int $width Width of the avatar, in pixels. Default: the
    1136          *           width corresponding to $type.
    1137          *           See {@link bp_core_fetch_avatar()}.
    1138          *     @type int $height Height of the avatar, in pixels. Default:
    1139          *           the height corresponding to $type.
    1140          *           See {@link bp_core_fetch_avatar()}.
    1141          *     @type string $alt The text of the image's 'alt' attribute.
    1142          *           Default: 'Profile picture of [group name]'.
     1135         *     @type string $type   Avatar type. 'thumb' or 'full'. Default:
     1136         *                          'thumb'.
     1137         *     @type int    $width Width of the avatar, in pixels. Default: the
     1138         *                          width corresponding to $type.
     1139         *                          See {@link bp_core_fetch_avatar()}.
     1140         *     @type int    $height Height of the avatar, in pixels. Default:
     1141         *                          the height corresponding to $type.
     1142         *                          See {@link bp_core_fetch_avatar()}.
     1143         *     @type string $alt    The text of the image's 'alt' attribute.
     1144         *                          Default: 'Profile picture of [group name]'.
    11431145         * }
    11441146         * @return string User avatar.
     
    12721274         * Return whether the current topic in the loop is open.
    12731275         *
    1274          * @return unknown
     1276         * @return string
    12751277         */
    12761278        function bp_get_the_topic_is_topic_open() {
     
    13201322         * Return whether the current topic in the loop is sticky.
    13211323         *
    1322          * @return unknown
     1324         * @return bool
    13231325         */
    13241326        function bp_get_the_topic_is_sticky() {
     
    14281430                global $forum_template;
    14291431
    1430                 // The topic is in a loop where its parent object is loaded
     1432                // The topic is in a loop where its parent object is loaded.
    14311433                if ( bp_get_the_topic_object_slug() ) {
    14321434                        $permalink = trailingslashit( bp_get_groups_directory_permalink() . bp_get_the_topic_object_slug() . '/forum' );
    14331435
    1434                 // We are viewing a single group topic, so use the current item
     1436                // We are viewing a single group topic, so use the current item.
    14351437                } elseif ( bp_is_group_forum_topic() ) {
    14361438                        $permalink = trailingslashit( bp_get_groups_directory_permalink() . bp_current_item() . '/forum' );
    14371439
    1438                 // We are unsure what the context is, so fallback to forum root slug
     1440                // We are unsure what the context is, so fallback to forum root slug.
    14391441                } elseif ( bp_is_single_item() ) {
    14401442                        $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/' . bp_current_item() );
    14411443
    1442                 // This is some kind of error situation, so use forum root
     1444                // This is some kind of error situation, so use forum root.
    14431445                } else {
    14441446                        $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() );
     
    14831485/**
    14841486 * Output an excerpt from the latest post of the current topic in the loop.
     1487 *
     1488 * @param array|string $args See {@bp_get_the_topic_latest_post_excerpt()}.
    14851489 */
    14861490function bp_the_topic_latest_post_excerpt( $args = '' ) {
     
    14901494         * Return an excerpt from the latest post of the current topic in the loop.
    14911495         *
    1492          * @param array $args {
     1496         * @param array|string $args {
    14931497         *     @type int $length The length of the excerpted text. Default: 225.
    14941498         * }
     
    15551559         *
    15561560         * @return bool True if the current topic in the loop was created by
    1557          *         the logged-in user, otherwise false.
     1561         *              the logged-in user, otherwise false.
    15581562         */
    15591563        function bp_get_the_topic_is_mine() {
     
    15681572 * @see bp_get_the_topic_admin_links() for a description of arguments.
    15691573 *
    1570  * @param array $args See {@link bp_get_the_topic_admin_links()}.
     1574 * @param array|string $args See {@link bp_get_the_topic_admin_links()}.
    15711575 */
    15721576function bp_the_topic_admin_links( $args = '' ) {
     
    15761580         * Return the admin links for the current topic in the loop.
    15771581         *
    1578          * @param array $args {
    1579          *     @type string $separator The character to use when separating
    1580          *           links. Default: '|'.
     1582         * @param array|string $args {
     1583         *     @type string $separator The character to use when separating links. Default: '|'.
    15811584         * }
    1582          * @return HTML string containing the admin links for the current topic.
     1585         * @return string HTML string containing the admin links for the current topic.
    15831586         */
    15841587        function bp_get_the_topic_admin_links( $args = '' ) {
     
    17851788         * @uses apply_filters() Filter bp_get_forum_topic_new_reply_link to
    17861789         *       modify.
     1790         *
    17871791         * @return string The URL for the New Reply link.
    17881792         */
     
    17911795
    17921796                if ( $topic_template->pag->total_pages == $topic_template->pag_page ) {
    1793                         // If we are on the last page, no need for a URL base
     1797                        // If we are on the last page, no need for a URL base.
    17941798                        $link = '';
    17951799                } else {
    1796                         // Create a link to the last page for the topic
     1800                        // Create a link to the last page for the topic.
    17971801                        $link = add_query_arg( array(
    17981802                                'topic_page' => $topic_template->pag->total_pages,
     
    19941998         *
    19951999         * @access public
    1996          * @var public
     2000         * @var int
    19972001         */
    19982002        public $pag_page;
     
    20022006         *
    20032007         * @access public
    2004          * @var public
     2008         * @var int
    20052009         */
    20062010        public $pag_num;
     
    20492053         * Constructor method.
    20502054         *
    2051          * @param int $topic_id ID of the topic whose posts are being requested.
    2052          * @param int $per_page Number of items to return per page.
    2053          * @param int $max Max records to return.
     2055         * @param int    $topic_id ID of the topic whose posts are being requested.
     2056         * @param int    $per_page Number of items to return per page.
     2057         * @param int    $max Max records to return.
    20542058         * @param string $order Direction to order results.
    20552059         */
     
    20922096                }
    20932097
    2094                 // Load topic tags
     2098                // Load topic tags.
    20952099                $this->topic_tags = bb_get_topic_tags( $this->topic_id );
    20962100
     
    21732177                         */
    21742178                        do_action('topic_loop_end');
    2175                         // Do some cleaning up after the loop
     2179                        // Do some cleaning up after the loop.
    21762180                        $this->rewind_posts();
    21772181                }
     
    22072211 * Initiate the loop for a single topic's posts.
    22082212 *
    2209  * @param array $args {
     2213 * @param array|string $args {
    22102214 *     Arguments for limiting the contents of the topic posts loop.
    2211  *     @type int $topic_id ID of the topic to which the posts belong.
    2212  *     @type int $per_page Number of items to return per page. Default: 15.
    2213  *     @type int $max Max items to return. Default: false.
    2214  *     @type string $order 'ASC' or 'DESC'.
     2215 *     @type int    $topic_id ID of the topic to which the posts belong.
     2216 *     @type int    $per_page Number of items to return per page. Default: 15.
     2217 *     @type int    $max      Max items to return. Default: false.
     2218 *     @type string $order   'ASC' or 'DESC'.
    22152219 * }
    22162220 * @return bool True when posts are found corresponding to the args,
    2217  *         otherwise false.
     2221 *              otherwise false.
    22182222 */
    22192223function bp_has_forum_topic_posts( $args = '' ) {
     
    22412245                $topic_template = new BP_Forums_Template_Topic( (int) $topic_id, $per_page, $max, $order );
    22422246
    2243                 // Current topic forum_id needs to match current_group forum_id
     2247                // Current topic forum_id needs to match current_group forum_id.
    22442248                if ( bp_is_groups_component() && $topic_template->forum_id != groups_get_groupmeta( bp_get_current_group_id(), 'forum_id' ) )
    22452249                        return false;
     
    23382342         *
    23392343         * @return string String to put in the 'class' attribute of the current
    2340          *         post.
     2344         *                post.
    23412345         */
    23422346        function bp_get_the_topic_post_css_class() {
     
    23722376 * @see bp_get_the_topic_post_poster_avatar() for a description of arguments.
    23732377 *
    2374  * @param array $args See {@link bp_get_the_topic_post_poster_avatar()}.
     2378 * @param array|string $args See {@link bp_get_the_topic_post_poster_avatar()}.
    23752379 */
    23762380function bp_the_topic_post_poster_avatar( $args = '' ) {
     
    23802384         * Return the avatar of the user who posted the current post in the loop.
    23812385         *
    2382          * @param array $args {
     2386         * @param array|string $args {
    23832387         *     Arguments for building the avatar.
    2384          *     @type string $type Avatar type. 'thumb' or 'full'. Default:
    2385          *           'thumb'.
    2386          *     @type int $width Width of the avatar, in pixels. Default: the
    2387          *           width corresponding to $type.
    2388          *           See {@link bp_core_fetch_avatar()}.
    2389          *     @type int $height Height of the avatar, in pixels. Default: the
    2390          *           height corresponding to $type.
    2391          *           See {@link bp_core_fetch_avatar()}.
    2392          *     @type string $alt The text of the image's 'alt' attribute.
    2393          *           Default: 'Profile picture of [user name]'.
     2388         *     @type string $type   Avatar type. 'thumb' or 'full'. Default:
     2389         *                          'thumb'.
     2390         *     @type int    $width Width of the avatar, in pixels. Default: the
     2391         *                          width corresponding to $type.
     2392         *                          See {@link bp_core_fetch_avatar()}.
     2393         *     @type int    $height Height of the avatar, in pixels. Default: the
     2394         *                          height corresponding to $type.
     2395         *                          See {@link bp_core_fetch_avatar()}.
     2396         *     @type string $alt    The text of the image's 'alt' attribute.
     2397         *                          Default: 'Profile picture of [user name]'.
    23942398         * }
    23952399         * @return string HTML of user avatar.
     
    24552459         *
    24562460         * @return string Link to the profile of the user who posted the
    2457          *         current post.
     2461         *                current post.
    24582462         */
    24592463        function bp_get_the_topic_post_poster_link() {
     
    25062510         *
    25072511         * @return bool True if the current post in the loop was created by
    2508          *         the logged-in user, otherwise false.
     2512         *              the logged-in user, otherwise false.
    25092513         */
    25102514        function bp_get_the_topic_post_is_mine() {
     
    25192523 * @see bp_get_the_post_admin_links() for a description of arguments.
    25202524 *
    2521  * @param array $args See {@link bp_get_the_post_admin_links()}.
     2525 * @param array|string $args See {@link bp_get_the_post_admin_links()}.
    25222526 */
    25232527function bp_the_topic_post_admin_links( $args = '' ) {
     
    25272531         * Return the admin links for the current post in the loop.
    25282532         *
    2529          * @param array $args {
     2533         * @param array|string $args {
    25302534         *     @type string $separator The character to use when separating
    2531          *           links. Default: '|'.
     2535         *                             links. Default: '|'.
    25322536         * }
    2533          * @return HTML string containing the admin links for the current post.
     2537         * @return string HTML string containing the admin links for the current post.
    25342538         */
    25352539        function bp_get_the_topic_post_admin_links( $args = '' ) {
     
    26182622 *
    26192623 * The "count" is a string of the form "Viewing x of y posts".
    2620  *
    2621  * @return string
    26222624 */
    26232625function bp_the_topic_pagination_count() {
     
    26582660         *
    26592661         * @return bool True if this is the last page of posts for the current
    2660          *         topic, otherwise false.
     2662         *              topic, otherwise false.
    26612663         */
    26622664        function bp_get_the_topic_is_last_page() {
     
    26902692         * @since 1.9.0
    26912693         *
    2692          * @param string HTML search form for the forums directory.
     2694         * @param string $search_form_html HTML search form for the forums directory.
    26932695         */
    26942696        echo apply_filters( 'bp_directory_forums_search_form', $search_form_html );
     
    27092711         *
    27102712         * @param int $forum_id Optional. Defaults to the current forum, if
    2711          *        there is one.
     2713         *                      there is one.
    27122714         * @return string|bool False on failure, a URL on success.
    27132715         */
     
    27532755         *
    27542756         * @param int $forum_id Optional. Defaults to the current forum, if
    2755          *        there is one.
     2757         *                      there is one.
    27562758         * @return string|bool False on failure, a name on success.
    27572759         */
     
    27862788 * defaults.
    27872789 *
    2788  * @param array $args {
     2790 * @param array|string $args {
    27892791 *     An array of optional arguments.
    2790  *     @type int $smallest Size of the smallest link. Default: 10.
    2791  *     @type int $largest Size of the largest link. Default: 42.
    2792  *     @type string $sizing Unit for $largest and $smallest. Default: 'px'.
    2793  *     @type int $limit Max number of tags to display. Default: 50.
     2792 *     @type int    $smallest Size of the smallest link. Default: 10.
     2793 *     @type int    $largest Size of the largest link. Default: 42.
     2794 *     @type string $sizing   Unit for $largest and $smallest. Default: 'px'.
     2795 *     @type int    $limit    Max number of tags to display. Default: 50.
    27942796 * }
    27952797 */
     
    28092811
    28102812/**
    2811  * Output the current topic's tag list, comma-separated
     2813 * Output the current topic's tag list, comma-separated.
    28122814 *
    28132815 * @since 1.5.0
     
    28222824         *
    28232825         * @param string $format 'string' returns comma-separated string;
    2824          *        otherwise returns array.
     2826         *                       otherwise returns array.
    28252827         * @return mixed $tags
    28262828         */
  • trunk/src/bp-forums/deprecated/1.6.php

    r9819 r10183  
    11<?php
    2 
    32/**
    4  * BuddyPress Forums Deprecated Functions
     3 * BuddyPress Forums Deprecated Functions.
    54 *
    65 * This file contains all the deprecated functions for BuddyPress forums since
     
    1211 */
    1312
    14 // Exit if accessed directly
     13// Exit if accessed directly.
    1514defined( 'ABSPATH' ) || exit;
    1615
     
    2120
    2221        // The text and URL of the Site Wide Forums button differs depending on whether bbPress
    23         // is running
     22        // is running.
    2423        if ( is_plugin_active( 'bbpress/bbpress.php' ) ) {
    2524                // The bbPress admin page will always be on the root blog. switch_to_blog() will
     
    5453                if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) :
    5554
    56                         // Delete the bb-config.php location option
     55                        // Delete the bb-config.php location option.
    5756                        bp_delete_option( 'bb-config-location' );
    5857
    59                         // Now delete the bb-config.php file
     58                        // Now delete the bb-config.php file.
    6059                        @unlink( ABSPATH . 'bb-config.php' );
    6160
    62                         // show the updated wizard
     61                        // Show the updated wizard.
    6362                        bp_forums_bbpress_install_wizard();
    6463
     
    121120
    122121        // The text and URL of the Site Wide Forums button differs depending on whether bbPress
    123         // is running
     122        // is running.
    124123        if ( is_plugin_active( 'bbpress/bbpress.php' ) ) {
    125124                $bbpress_plugin_is_active = true;
     
    172171                                                break;
    173172                                        default:
    174                                                 // Just write the contents to screen
     173                                                // Just write the contents to screen.
    175174                                                _e( '<p>A configuration file could not be created. No problem, but you will need to save the text shown below into a file named <code>bb-config.php</code> in the root directory of your WordPress installation before you can start using the forum functionality.</p>', 'buddypress' ); ?>
    176175
     
    200199                        <?php } else {
    201200
    202                                 // Include the plugin install
    203 
     201                                // Include the plugin install.
    204202                                add_thickbox();
    205203                                wp_enqueue_script( 'plugin-install' );
  • trunk/src/bp-forums/deprecated/1.7.php

    r9819 r10183  
    11<?php
    2 
    32/**
    4  * BuddyPress Forums Deprecated Functions
     3 * BuddyPress Forums Deprecated Functions.
    54 *
    65 * This file contains all the deprecated functions for BuddyPress forums since
     
    1211 */
    1312
    14 // Exit if accessed directly
     13// Exit if accessed directly.
    1514defined( 'ABSPATH' ) || exit;
    1615
     
    2221        $page  = bp_core_do_network_admin()  ? 'settings.php' : 'options-general.php';
    2322
    24         // Add the administration tab under the "Site Admin" tab for site administrators
     23        // Add the administration tab under the "Site Admin" tab for site administrators.
    2524        $hook = add_submenu_page( $page, __( 'Forums', 'buddypress' ), __( 'Forums', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" );
    2625
    27         // Fudge the highlighted subnav item when on the BuddyPress Forums admin page
     26        // Fudge the highlighted subnav item when on the BuddyPress Forums admin page.
    2827        add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );
    2928}
     
    3534        check_admin_referer( 'bp_forums_existing_install_init' );
    3635
    37         // Sanitize $_REQUEST['bbconfigloc']
     36        // Sanitize $_REQUEST['bbconfigloc'].
    3837        $_REQUEST['bbconfigloc'] = apply_filters( 'bp_forums_bbconfig_location', $_REQUEST['bbconfigloc'] );
    3938
     
    6564        $bp = buddypress();
    6665
    67         // Create the bb-config.php file
     66        // Create the bb-config.php file.
    6867        $initial_write = bp_forums_bbpress_write(
    6968                $bp->plugin_dir . '/bp-forums/bbpress/bb-config-sample.php',
     
    8584        );
    8685
    87         // Add the custom user and usermeta entries to the config file
     86        // Add the custom user and usermeta entries to the config file.
    8887        if ( $initial_write == 1 ) {
    8988                $file = file_get_contents( $location );
     
    147146        }
    148147
    149         // Get the existing lines in the file
     148        // Get the existing lines in the file.
    150149        $lines = file( $file_source );
    151150
    152         // Initialise an array to store the modified lines
     151        // Initialise an array to store the modified lines.
    153152        $modified_lines = array();
    154153
    155         // Loop through the lines and modify them
     154        // Loop through the lines and modify them.
    156155        foreach ( (array) $lines as $line ) {
    157156                if ( isset( $alterations[substr( $line, 0, 20 )] ) ) {
     
    184183        }
    185184
    186         // Open the file for writing - rewrites the whole file
     185        // Open the file for writing - rewrites the whole file.
    187186        $file_handle = fopen( $file_target, 'w' );
    188187
    189         // Write lines one by one to avoid OS specific newline hassles
     188        // Write lines one by one to avoid OS specific newline hassles.
    190189        foreach ( (array) $modified_lines as $modified_line ) {
    191190                if ( strlen( $modified_line ) - 2 === strrpos( $modified_line, '?>' ) ) {
     
    199198        }
    200199
    201         // Close the config file
     200        // Close the config file.
    202201        fclose( $file_handle );
    203202
Note: See TracChangeset for help on using the changeset viewer.