Skip to:
Content

bbPress.org


Ignore:
Timestamp:
12/05/2025 02:27:53 AM (6 months ago)
Author:
johnjamesjacoby
Message:

Tools - Code Improvement: docs & code formatting improvements.

Props johnjamesjacoby, noruzzaman.

Fixes #3659.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/forums/functions.php

    r7379 r7380  
    1919 * @since 2.0.0 bbPress (r3349)
    2020 *
    21  * @param array $forum_data Forum post data
    22  * @param array $forum_meta Forum meta data
     21 * @param array $forum_data Forum post data.
     22 * @param array $forum_meta Forum meta data.
     23 *
     24 * @return int|false Forum ID on success, false on failure.
    2325 */
    2426function bbp_insert_forum( $forum_data = array(), $forum_meta = array() ) {
     
    121123
    122124/**
    123  * Handles the front end forum submission
    124  *
    125  * @param string $action The requested action to compare this function to
     125 * Handles the front end forum submission.
     126 *
     127 * @param string $action The requested action to compare this function to.
    126128 */
    127129function bbp_new_forum_handler( $action = '' ) {
     
    387389
    388390/**
    389  * Handles the front end edit forum submission
    390  *
    391  * @param string $action The requested action to compare this function to
     391 * Handles the front end edit forum submission.
     392 *
     393 * @param string $action The requested action to compare this function to.
    392394 */
    393395function bbp_edit_forum_handler( $action = '' ) {
     
    642644
    643645/**
    644  * Handle the saving of core forum metadata (Status, Visibility, and Type)
     646 * Handle the saving of core forum metadata (Status, Visibility, and Type).
    645647 *
    646648 * @since 2.1.0 bbPress (r3678)
    647649 *
    648  * @param int $forum_id
    649  * @return If forum ID is empty
     650 * @param int $forum_id.
     651 * @return If forum ID is empty.
    650652 */
    651653function bbp_save_forum_extras( $forum_id = 0 ) {
     
    714716
    715717        /**
    716          * Allow custom forum visibility save actions
     718         * Allow custom forum visibility save actions.
    717719         *
    718720         * @since 2.6.0 bbPress (r5855)
    719721         *
    720          * @param int    $forum_id       The forum ID
    721          * @param string $old_visibility The current forum visibility
    722          * @param string $new_visibility The new forum visibility
     722         * @param int    $forum_id       The forum ID.
     723         * @param string $old_visibility The current forum visibility.
     724         * @param string $new_visibility The new forum visibility.
    723725         */
    724726        do_action( 'bbp_update_forum_visibility', $forum_id, $old_visibility, $new_visibility );
     
    757759
    758760/**
    759  * Closes a forum
     761 * Closes a forum.
    760762 *
    761763 * @since 2.0.0 bbPress (r2746)
    762764 *
    763  * @param int $forum_id forum id
    764  * @return mixed False or {@link WP_Error} on failure, forum id on success
     765 * @param int $forum_id forum id.
     766 * @return mixed False or {@link WP_Error} on failure, forum id on success.
    765767 */
    766768function bbp_close_forum( $forum_id = 0 ) {
     
    778780
    779781/**
    780  * Opens a forum
     782 * Opens a forum.
    781783 *
    782784 * @since 2.0.0 bbPress (r2746)
    783785 *
    784  * @param int $forum_id forum id
    785  * @return mixed False or {@link WP_Error} on failure, forum id on success
     786 * @param int $forum_id forum id.
     787 * @return mixed False or {@link WP_Error} on failure, forum id on success.
    786788 */
    787789function bbp_open_forum( $forum_id = 0 ) {
     
    801803
    802804/**
    803  * Make the forum a category
     805 * Make the forum a category.
    804806 *
    805807 * @since 2.0.0 bbPress (r2746)
    806808 *
    807  * @param int $forum_id Optional. Forum id
    808  * @return bool False on failure, true on success
     809 * @param int $forum_id Optional. Forum id.
     810 * @return bool False on failure, true on success.
    809811 */
    810812function bbp_categorize_forum( $forum_id = 0 ) {
     
    822824
    823825/**
    824  * Remove the category status from a forum
     826 * Remove the category status from a forum.
    825827 *
    826828 * @since 2.0.0 bbPress (r2746)
    827829 *
    828  * @param int $forum_id Optional. Forum id
    829  * @return bool False on failure, true on success
     830 * @param int $forum_id Optional. Forum id.
     831 * @return bool False on failure, true on success.
    830832 */
    831833function bbp_normalize_forum( $forum_id = 0 ) {
     
    845847
    846848/**
    847  * Mark the forum as public
     849 * Mark the forum as public.
    848850 *
    849851 * @since 2.0.0 bbPress (r2746)
    850852 *
    851  * @param int $forum_id Optional. Forum id
    852  * @return bool False on failure, true on success
     853 * @param int $forum_id Optional. Forum id.
     854 * @return bool False on failure, true on success.
    853855 */
    854856function bbp_publicize_forum( $forum_id = 0, $current_visibility = '' ) {
     
    902904
    903905/**
    904  * Mark the forum as private
     906 * Mark the forum as private.
    905907 *
    906908 * @since 2.0.0 bbPress (r2746)
    907909 *
    908  * @param int $forum_id Optional. Forum id
    909  * @return bool False on failure, true on success
     910 * @param int $forum_id Optional. Forum id.
     911 * @return bool False on failure, true on success.
    910912 */
    911913function bbp_privatize_forum( $forum_id = 0, $current_visibility = '' ) {
     
    951953
    952954/**
    953  * Mark the forum as hidden
     955 * Mark the forum as hidden.
    954956 *
    955957 * @since 2.0.0 bbPress (r2996)
    956958 *
    957  * @param int $forum_id Optional. Forum id
    958  * @return bool False on failure, true on success
     959 * @param int $forum_id Optional. Forum id.
     960 * @return bool False on failure, true on success.
    959961 */
    960962function bbp_hide_forum( $forum_id = 0, $current_visibility = '' ) {
     
    10001002
    10011003/**
    1002  * Recaches the private and hidden forums
     1004 * Re-caches the private and hidden forums.
    10031005 *
    10041006 * @since 2.4.0 bbPress (r5017)
    10051007 *
    1006  * @return array An array of the status code and the message
     1008 * @return array An array of the status code and the message.
    10071009 */
    10081010function bbp_repair_forum_visibility() {
     
    10801082
    10811083/**
    1082  * Remove a deleted forum from all user subscriptions
     1084 * Remove a deleted forum from all user subscriptions.
    10831085 *
    10841086 * @since 2.5.0 bbPress (r5156)
    10851087 *
    1086  * @param int $forum_id Get the forum ID to remove
     1088 * @param int $forum_id Get the forum ID to remove.
    10871089 */
    10881090function bbp_remove_forum_from_all_subscriptions( $forum_id = 0 ) {
     
    11061108
    11071109/**
    1108  * Bump the total topic count of a forum
     1110 * Bump the total topic count of a forum.
    11091111 *
    11101112 * @since 2.1.0 bbPress (r3825)
     
    11701172 *
    11711173 * @param int $forum_id The forum id.
    1172  * @return void
    11731174 */
    11741175function bbp_increase_forum_topic_count( $forum_id = 0 ) {
     
    12011202 *
    12021203 * @param int $forum_id The forum id.
    1203  *
    1204  * @return void
    12051204 */
    12061205function bbp_decrease_forum_topic_count( $forum_id = 0 ) {
     
    12281227
    12291228/**
    1230  * Bump the total topic count of a forum
     1229 * Bump the total topic count of a forum.
    12311230 *
    12321231 * @since 2.1.0 bbPress (r3825)
     
    12921291 *
    12931292 * @param int $forum_id The forum id.
    1294  *
    1295  * @return void
    12961293 */
    12971294function bbp_increase_forum_topic_count_hidden( $forum_id = 0 ) {
     
    13241321 *
    13251322 * @param int $forum_id The forum id.
    1326  *
    1327  * @return void
    13281323 */
    13291324function bbp_decrease_forum_topic_count_hidden( $forum_id = 0 ) {
     
    13511346
    13521347/**
    1353  * Bump the total topic count of a forum
     1348 * Bump the total topic count of a forum.
    13541349 *
    13551350 * @since 2.1.0 bbPress (r3825)
    13561351 *
    13571352 * @param int $forum_id Optional. Forum id.
    1358  * @param int $difference Optional. Default 1
    1359  * @param bool $update_ancestors Optional. Default true
     1353 * @param int $difference Optional. Default 1.
     1354 * @param bool $update_ancestors Optional. Default true.
    13601355 *
    13611356 * @return int Forum topic count
     
    14101405
    14111406/**
    1412  * Bump the total topic count of a forum
     1407 * Bump the total topic count of a forum.
    14131408 *
    14141409 * @since 2.6.0 bbPress (r6922)
    14151410 *
    14161411 * @param int $forum_id Optional. Forum id.
    1417  * @param int $difference Optional. Default 1
    1418  * @param bool $update_ancestors Optional. Default true
     1412 * @param int $difference Optional. Default 1.
     1413 * @param bool $update_ancestors Optional. Default true.
    14191414 *
    14201415 * @return int Forum topic count
     
    14741469 *
    14751470 * @param int $forum_id The forum id.
    1476  *
    1477  * @return void
    14781471 */
    14791472function bbp_increase_forum_reply_count( $forum_id = 0 ) {
     
    15061499 *
    15071500 * @param int $forum_id The forum id.
    1508  *
    1509  * @return void
    15101501 */
    15111502function bbp_decrease_forum_reply_count( $forum_id = 0 ) {
     
    15381529 *
    15391530 * @param int $forum_id The forum id.
    1540  *
    1541  * @return void
    15421531 */
    15431532function bbp_increase_forum_reply_count_hidden( $forum_id = 0 ) {
     
    15701559 *
    15711560 * @param int $forum_id The forum id.
    1572  *
    1573  * @return void
    15741561 */
    15751562function bbp_decrease_forum_reply_count_hidden( $forum_id = 0 ) {
     
    16021589 *
    16031590 * @param int $topic_id The topic id.
    1604  *
    1605  * @return void
    16061591 */
    16071592function bbp_approved_unapproved_topic_update_forum_reply_count( $topic_id = 0 ) {
     
    16271612
    16281613/**
    1629  * Update the forum last topic id
     1614 * Update the forum last topic id.
    16301615 *
    16311616 * @since 2.0.0 bbPress (r2625)
     
    16331618 * @param int $forum_id Optional. Forum id.
    16341619 * @param int $topic_id Optional. Topic id.
    1635  * @return int Id of the forums most recent topic
     1620 * @return int Id of the forums most recent topic.
    16361621 */
    16371622function bbp_update_forum_last_topic_id( $forum_id = 0, $topic_id = 0 ) {
     
    16861671
    16871672/**
    1688  * Update the forum last reply id
     1673 * Update the forum last reply id.
    16891674 *
    16901675 * @since 2.0.0 bbPress (r2625)
     
    16921677 * @param int $forum_id Optional. Forum id.
    16931678 * @param int $reply_id Optional. Reply id.
    1694  * @return int Id of the forums most recent reply
     1679 * @return int Id of the forums most recent reply.
    16951680 */
    16961681function bbp_update_forum_last_reply_id( $forum_id = 0, $reply_id = 0 ) {
     
    17421727
    17431728/**
    1744  * Update the forum last active post id
     1729 * Update the forum last active post id.
    17451730 *
    17461731 * @since 2.0.0 bbPress (r2860)
     
    17481733 * @param int $forum_id Optional. Forum id.
    17491734 * @param int $active_id Optional. Active post id.
    1750  * @return int Id of the forums last active post
     1735 * @return int Id of the forums last active post.
    17511736 */
    17521737function bbp_update_forum_last_active_id( $forum_id = 0, $active_id = 0 ) {
     
    18001785
    18011786/**
    1802  * Update the forums last active date/time (aka freshness)
     1787 * Update the forums last active date/time (aka freshness).
    18031788 *
    18041789 * @since 2.0.0 bbPress (r2680)
     
    18071792 * @param string $new_time Optional. New time in mysql format.
    18081793 *
    1809  * @return string MySQL timestamp of last active topic or reply
     1794 * @return string MySQL timestamp of last active topic or reply.
    18101795 */
    18111796function bbp_update_forum_last_active_time( $forum_id = 0, $new_time = '' ) {
     
    18271812
    18281813/**
    1829  * Update the forum sub-forum count
     1814 * Update the forum sub-forum count.
    18301815 *
    18311816 * @since 2.0.0 bbPress (r2625)
    18321817 *
    1833  * @param int $forum_id Optional. Forum id
    1834  * @param int $subforums Optional. Number of subforums
    1835  * @return bool True on success, false on failure
     1818 * @param int $forum_id Optional. Forum id.
     1819 * @param int $subforums Optional. Number of subforums.
     1820 * @return bool True on success, false on failure.
    18361821 */
    18371822function bbp_update_forum_subforum_count( $forum_id = 0, $subforums = false ) {
     
    18501835
    18511836/**
    1852  * Adjust the total topic count of a forum
     1837 * Adjust the total topic count of a forum.
    18531838 *
    18541839 * @since 2.0.0 bbPress (r2464)
     
    18571842 *                       is a topic or a forum. If it's a topic, its parent,
    18581843 *                       i.e. the forum is automatically retrieved.
    1859  * @param bool $total_count Optional. To return the total count or normal count?
    1860  * @return int Forum topic count
     1844 * @param bool $total_count Optional. To return the total count or normal count.
     1845 * @return int Forum topic count.
    18611846 */
    18621847function bbp_update_forum_topic_count( $forum_id = 0 ) {
     
    18881873/**
    18891874 * Adjust the total hidden topic count of a forum (hidden includes trashed,
    1890  * spammed and pending topics)
     1875 * spammed and pending topics).
    18911876 *
    18921877 * @since 2.0.0 bbPress (r2888)
     
    18961881 * @param int $topic_count Optional. Set the topic count manually.
    18971882 *
    1898  * @return int Topic hidden topic count
     1883 * @return int Topic hidden topic count.
    18991884 */
    19001885function bbp_update_forum_topic_count_hidden( $forum_id = 0, $topic_count = false ) {
     
    19491934
    19501935/**
    1951  * Adjust the total reply count of a forum
     1936 * Adjust the total reply count of a forum.
    19521937 *
    19531938 * @since 2.0.0 bbPress (r2464)
    1954  * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects
     1939 * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects.
    19551940 *
    19561941 * @param int  $forum_id Optional. Forum id or topic id. It is checked whether it
     
    19581943 *                       i.e. the forum is automatically retrieved.
    19591944 *
    1960  * @return int Forum reply count
     1945 * @return int Forum reply count.
    19611946 */
    19621947function bbp_update_forum_reply_count( $forum_id = 0 ) {
     
    19901975
    19911976/**
    1992  * Adjust the total hidden reply count of a forum
     1977 * Adjust the total hidden reply count of a forum.
    19931978 *
    19941979 * @since 2.6.0 bbPress (r6922)
     
    19981983 *                       i.e. the forum is automatically retrieved.
    19991984 *
    2000  * @return int Forum reply count
     1985 * @return int Forum reply count.
    20011986 */
    20021987function bbp_update_forum_reply_count_hidden( $forum_id = 0 ) {
     
    21092094
    21102095/**
    2111  * Return an associative array of available topic statuses
     2096 * Return an associative array of available topic statuses.
    21122097 *
    21132098 * Developers note: these statuses are actually stored as meta data, and
     
    21162101 * @since 2.4.0 bbPress (r5059)
    21172102 *
    2118  * @param int $forum_id   Optional. Forum id.
     2103 * @param int $forum_id Optional. Forum id.
    21192104 *
    21202105 * @return array
     
    21342119
    21352120/**
    2136  * Return an associative array of forum types
     2121 * Return an associative array of forum type.
    21372122 *
    21382123 * @since 2.4.0 bbPress (r5059)
    21392124 *
    2140  * @param int $forum_id   Optional. Forum id.
     2125 * @param int $forum_id Optional. Forum id.
    21412126 *
    21422127 * @return array
     
    21632148 * @since 2.4.0 bbPress (r5059)
    21642149 *
    2165  * @param int $forum_id   Optional. Forum id.
     2150 * @param int $forum_id Optional. Forum id.
    21662151 *
    21672152 * @return array
     
    22172202
    22182203/**
    2219  * Returns the hidden forum ids
     2204 * Returns the hidden forum ids.
    22202205 *
    22212206 * Only hidden forum ids are returned. Public and private ids are not.
     
    22342219
    22352220/**
    2236  * Returns the private forum ids
     2221 * Returns the private forum ids.
    22372222 *
    22382223 * Only private forum ids are returned. Public and hidden ids are not.
     
    22562241 * @since 2.6.0 bbPress (r6425)
    22572242 *
    2258  * @return array Forum IDs to exclude, or an empty array
     2243 * @return array Forum IDs to exclude, or an empty array.
    22592244 */
    22602245function bbp_get_excluded_forum_ids() {
     
    22852270 * @since 2.0.0 bbPress (r3291)
    22862271 *
    2287  * @param string Optional. The type of value to return. (string|array|meta_query)
     2272 * @param string Optional. The type of value to return (string|array|meta_query).
    22882273 */
    22892274function bbp_exclude_forum_ids( $type = 'string' ) {
     
    24212406
    24222407/**
    2423  * Returns the forum's topic ids
    2424  *
    2425  * Only topics with published and closed statuses are returned
     2408 * Returns the forum's topic ids.
     2409 *
     2410 * Only topics with published and closed statuses are returned.
    24262411 *
    24272412 * @since 2.0.0 bbPress (r2908)
    24282413 *
    2429  * @param int $forum_id Forum id
     2414 * @param int $forum_id Forum id.
    24302415 */
    24312416function bbp_forum_query_topic_ids( $forum_id ) {
     
    24372422
    24382423/**
    2439  * Returns the forum's subforum ids
    2440  *
    2441  * Only forums with published status are returned
     2424 * Returns the forum's subforum ids.
     2425 *
     2426 * Only forums with published status are returned.
    24422427 *
    24432428 * @since 2.0.0 bbPress (r2908)
    24442429 *
    2445  * @param int $forum_id Forum id
     2430 * @param int $forum_id Forum id.
    24462431 */
    24472432function bbp_forum_query_subforum_ids( $forum_id ) {
     
    24532438
    24542439/**
    2455  * Returns the forum's last reply id
     2440 * Returns the forum's last reply id.
    24562441 *
    24572442 * @since 2.0.0 bbPress (r2908)
    2458  * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects
     2443 * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects.
    24592444 *
    24602445 * @param int $forum_id Forum id.
     
    25042489/**
    25052490 * Check if it's a hidden forum or a topic or reply of a hidden forum and if
    2506  * the user can't view it, then sets a 404
     2491 * the user can't view it, then sets a 404.
    25072492 *
    25082493 * @since 2.0.0 bbPress (r2996)
     
    25512536/**
    25522537 * Check if it's a private forum or a topic or reply of a private forum and if
    2553  * the user can't view it, then sets a 404
     2538 * the user can't view it, then sets a 404.
    25542539 *
    25552540 * @since 2.0.0 bbPress (r2996)
     
    25992584
    26002585/**
    2601  * Redirect if unauthorized user is attempting to edit a forum
     2586 * Redirect if unauthorized user is attempting to edit a forum.
    26022587 *
    26032588 * @since 2.1.0 bbPress (r3607)
     
    26172602
    26182603/**
    2619  * Delete all topics (and their replies) for a specific forum ID
     2604 * Delete all topics (and their replies) for a specific forum ID.
    26202605 *
    26212606 * @since 2.1.0 bbPress (r3668)
    26222607 *
    26232608 * @param int $forum_id
    2624  * @return If forum is not valid
    26252609 */
    26262610function bbp_delete_forum_topics( $forum_id = 0 ) {
     
    26682652
    26692653/**
    2670  * Trash all topics inside a forum
     2654 * Trash all topics inside a forum.
    26712655 *
    26722656 * @since 2.1.0 bbPress (r3668)
    26732657 *
    26742658 * @param int $forum_id
    2675  * @return If forum is not valid
    26762659 */
    26772660function bbp_trash_forum_topics( $forum_id = 0 ) {
     
    27362719
    27372720/**
    2738  * Untrash all topics inside a forum
     2721 * Untrash all topics inside a forum.
    27392722 *
    27402723 * @since 2.1.0 bbPress (r3668)
    27412724 *
    27422725 * @param int $forum_id
    2743  * @return If forum is not valid
    27442726 */
    27452727function bbp_untrash_forum_topics( $forum_id = 0 ) {
     
    27922774
    27932775/**
    2794  * Called before trashing a forum
     2776 * Called before trashing a forum.
    27952777 *
    27962778 * This function is supplemental to the actual forum being trashed which is
     
    28112793
    28122794/**
    2813  * Called before untrashing a forum
     2795 * Called before untrashing a forum.
    28142796 *
    28152797 * @since 2.1.0 bbPress (r3668)
     
    28282810
    28292811/**
    2830  * Called after deleting a forum
     2812 * Called after deleting a forum.
    28312813 *
    28322814 * Try not to use this action. All meta & taxonomy terms have already been
     
    28472829
    28482830/**
    2849  * Called after trashing a forum
     2831 * Called after trashing a forum.
    28502832 *
    28512833 * @since 2.1.0 bbPress (r3668)
     
    28622844
    28632845/**
    2864  * Called after untrashing a forum
     2846 * Called after untrashing a forum.
    28652847 *
    28662848 * @since 2.1.0 bbPress (r3668)
Note: See TracChangeset for help on using the changeset viewer.