Skip to:
Content

bbPress.org

Ticket #1476: register.patch

File register.patch, 41.7 KB (added by GautamGupta, 14 years ago)

Contains some unrelated docs changes too (in the same files)

  • bbp-includes/bbp-general-functions.php

     
    115115
    116116/**
    117117 * The plugin version of bbPress comes with two topic display options:
    118  *     ~ Traditional - Topics are included in the reply loop (default)
    119  *     ~ New Style   - Topics appear as "lead" posts, ahead of replies
     118 * - Traditional: Topics are included in the reply loop (default)
     119 * - New Style: Topics appear as "lead" posts, ahead of replies
    120120 *
    121121 * @since bbPress (r2954)
    122122 *
    123  * @global obj $bbp
    124123 * @param $show_lead Optional. Default false
    125  * @return bool
     124 * @return bool Yes if the topic appears as a lead, otherwise false
    126125 */
    127126function bbp_show_lead_topic( $show_lead = false ) {
    128127        return apply_filters( 'bbp_show_lead_topic', (bool) $show_lead );
     
    157156/**
    158157 * Append 'view=all' to query string if it's already there from referer
    159158 *
    160  * @param string $original_link
    161  * @return <type>
     159 * @param string $original_link Original Link to be modified
     160 * @uses current_user_can() To check if the current user can moderate
     161 * @uses add_query_arg() To add args to the url
     162 * @uses apply_filters() Calls 'bbp_add_view_all' with the link and original link
     163 * @return string The link with 'view=all' appended if necessary
    162164 */
    163165function bbp_add_view_all( $original_link ) {
    164166
     
    201203 *
    202204 * @param array $data Post data
    203205 * @param array $postarr Original post array (includes post id)
     206 * @uses bbp_get_topic_post_type() To get the topic post type
     207 * @uses bbp_get_reply_post_type() To get the reply post type
    204208 * @uses bbp_is_topic_anonymous() To check if the topic is by an anonymous user
    205209 * @uses bbp_is_reply_anonymous() To check if the reply is by an anonymous user
    206210 * @return array Data
     
    258262 *  - count_tags: Count tags? If set to false, empty tags are also not counted
    259263 *  - count_empty_tags: Count empty tags?
    260264 * @uses bbp_count_users() To count the number of registered users
     265 * @uses bbp_get_forum_post_type() To get the forum post type
     266 * @uses bbp_get_topic_post_type() To get the topic post type
     267 * @uses bbp_get_reply_post_type() To get the reply post type
    261268 * @uses wp_count_posts() To count the number of forums, topics and replies
    262269 * @uses wp_count_terms() To count the number of topic tags
    263270 * @uses current_user_can() To check if the user is capable of doing things
     
    536543
    537544        // Assign variables
    538545        $defaults = array (
    539                 'bbp_anonymous_name'    => $_POST['bbp_anonymous_name'],
    540                 'bbp_anonymous_email'   => $_POST['bbp_anonymous_email'],
    541                 'bbp_anonymous_website' => $_POST['bbp_anonymous_website'],
    542                 'bbp_anonymous_ip'      => $_SERVER['REMOTE_ADDR']
     546                'bbp_anonymous_name'    => isset( $_POST['bbp_anonymous_name']    ) ? $_POST['bbp_anonymous_name']    : false,
     547                'bbp_anonymous_email'   => isset( $_POST['bbp_anonymous_email']   ) ? $_POST['bbp_anonymous_email']   : false,
     548                'bbp_anonymous_website' => isset( $_POST['bbp_anonymous_website'] ) ? $_POST['bbp_anonymous_website'] : false,
     549                'bbp_anonymous_ip'      => isset( $_SERVER['REMOTE_ADDR']         ) ? $_SERVER['REMOTE_ADDR']         : false
    543550        );
    544551
    545552        $r = wp_parse_args( $args, $defaults );
     
    679686 * @since bbPress (r2753)
    680687 *
    681688 * @uses bbp_is_user_profile_page() To check if it's a profile page
     689 * @uses apply_filters() Calls 'bbp_profile_templates' with the profile
     690 *                        templates array
    682691 * @uses bbp_is_user_profile_edit() To check if it's a profile edit page
     692 * @uses apply_filters() Calls 'bbp_profile_edit_templates' with the profile
     693 *                        edit templates array
     694 * @uses bbp_is_view() To check if it's a view page
     695 * @uses bbp_get_view_id() To get the view id
     696 * @uses apply_filters() Calls 'bbp_view_templates' with the view templates array
    683697 * @uses bbp_is_topic_edit() To check if it's a topic edit page
     698 * @uses bbp_get_topic_post_type() To get the topic post type
     699 * @uses apply_filters() Calls 'bbp_topic_edit_templates' with the topic edit
     700 *                        templates array
    684701 * @uses bbp_is_reply_edit() To check if it's a reply edit page
     702 * @uses bbp_get_reply_post_type() To get the reply post type
     703 * @uses apply_filters() Calls 'bbp_reply_edit_templates' with the reply edit
     704 *                        templates array
    685705 * @uses apply_filters() Calls 'bbp_custom_template' with the template array
    686706 * @uses bbp_load_template() To load the template
    687707 */
     
    706726                        'forums/user-edit.php',
    707727                        'bbpress/user-edit.php',
    708728                        'user-edit.php',
     729                        'forums/user.php',
    709730                        'bbpress/user.php',
    710731                        'user.php',
    711732                        'author.php',
     
    716737        } elseif ( bbp_is_view() ) {
    717738                $template = apply_filters( 'bbp_view_templates', array(
    718739                        'forums/view-' . bbp_get_view_id(),
     740                        'bbpress/view-' . bbp_get_view_id(),
    719741                        'forums/view.php',
    720                         'bbpress/view-' . bbp_get_view_id(),
    721742                        'bbpress/view.php',
    722743                        'view-' . bbp_get_view_id(),
    723744                        'view.php',
     
    728749        } elseif ( bbp_is_topic_edit() ) {
    729750                $template = array(
    730751                        'forums/action-edit.php',
     752                        'bbpress/action-edit.php',
    731753                        'forums/single-' . bbp_get_topic_post_type(),
    732                         'bbpress/action-edit.php',
    733754                        'bbpress/single-' . bbp_get_topic_post_type(),
    734755                        'action-bbp-edit.php',
    735756                        'single-' . bbp_get_topic_post_type(),
     
    739760
    740761                // Add split/merge to front of array if present in _GET
    741762                if ( !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'merge', 'split' ) ) ) {
    742                         array_unshift( $template, array(
     763                        array_unshift( $template,
    743764                                'forums/action-split-merge.php',
    744765                                'bbpress/action-split-merge.php',
    745                                 'action-bbp-split-merge.php'
    746                         ) );
     766                                'action-split-merge.php'
     767                        );
    747768                }
    748769
    749770                $template = apply_filters( 'bbp_topic_edit_templates', $template );
     
    752773        } elseif ( bbp_is_reply_edit() ) {
    753774                $template = apply_filters( 'bbp_reply_edit_templates', array(
    754775                        'forums/action-edit.php',
     776                        'bbpress/action-edit.php',
    755777                        'forums/single-' . bbp_get_reply_post_type(),
    756                         'bbpress/action-edit.php',
    757778                        'bbpress/single-' . bbp_get_reply_post_type(),
    758779                        'action-bbp-edit.php',
    759780                        'single-' . bbp_get_reply_post_type(),
     
    810831 * @since bbPress (r2688)
    811832 *
    812833 * @uses get_query_var() To get {@link WP_Query} query var
     834 * @uses is_email() To check if the string is an email
     835 * @uses get_user_by() To try to get the user by email and nicename
    813836 * @uses WP_User to get the user data
    814837 * @uses WP_Query::set_404() To set a 404 status
    815  * @uses is_multisite() To check if it's a multisite
    816838 * @uses current_user_can() To check if the current user can edit the user
    817839 * @uses apply_filters() Calls 'enable_edit_any_user_configuration' with true
    818840 * @uses wp_die() To die
     841 * @uses bbp_get_query_name() To get the query name and check if it's 'bbp_widget'
     842 * @uses bbp_get_view_query_args() To get the view query args
     843 * @uses bbp_get_topic_post_type() To get the topic post type
     844 * @uses bbp_get_reply_post_type() To get the reply post type
     845 * @uses is_multisite() To check if it's a multisite
     846 * @uses remove_action() To remove the auto save post revision action
    819847 */
    820848function bbp_pre_get_posts( $wp_query ) {
    821849        global $bbp, $wp_version;
     
    929957 * @param string $seplocation Optional. Direction to display title, 'right'.
    930958 * @uses bbp_is_user_profile_page() To check if it's a user profile page
    931959 * @uses bbp_is_user_profile_edit() To check if it's a user profile edit page
     960 * @uses bbp_is_user_home() To check if the profile page is of the current user
    932961 * @uses get_query_var() To get the user id
    933962 * @uses get_userdata() To get the user data
     963 * @uses bbp_is_forum() To check if it's a forum
     964 * @uses bbp_get_forum_title() To get the forum title
     965 * @uses bbp_is_topic() To check if it's a topic
     966 * @uses bbp_get_topic_title() To get the topic title
     967 * @uses bbp_is_reply() To check if it's a reply
     968 * @uses bbp_get_reply_title() To get the reply title
     969 * @uses is_tax() To check if it's the tag page
     970 * @uses get_queried_object() To get the queried object
     971 * @uses bbp_is_view() To check if it's a view
     972 * @uses bbp_get_view_title() To get the view title
    934973 * @uses apply_filters() Calls 'bbp_raw_title' with the title
    935974 * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title,
    936975 *                        separator and separator location
     
    11381177        if ( empty( $redirect_to ) )
    11391178                $redirect_to = home_url( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '' );
    11401179
    1141         $url = add_query_arg( array( 'redirect_to' => esc_url( $redirect_to ) ), $url );
     1180        $redirect_to = esc_url( add_query_arg( array( 'loggedout' => '1' ), $redirect_to ) );
    11421181
     1182        $url = add_query_arg( array( 'redirect_to' => $redirect_to ), $url );
     1183
    11431184        return apply_filters( 'bbp_logout_url', $url, $redirect_to );
    11441185}
    11451186
     
    11481189/**
    11491190 * Query the DB and get the last public post_id that has parent_id as post_parent
    11501191 *
    1151  * @global db $wpdb
    1152  * @param int $parent_id
    1153  * @param string $post_type
     1192 * @param int $parent_id Parent id
     1193 * @param string $post_type Post type. Defaults to 'post'
     1194 * @uses bbp_get_topic_post_type() To get the topic post type
     1195 * @uses wp_cache_get() To check if there is a cache of the last child id
     1196 * @uses wpdb::prepare() To prepare the query
     1197 * @uses wpdb::get_var() To get the result of the query in a variable
     1198 * @uses wp_cache_set() To set the cache for future use
     1199 * @uses apply_filters() Calls 'bbp_get_public_child_last_id' with the child
     1200 *                        id, parent id and post type
    11541201 * @return int The last active post_id
    11551202 */
    11561203function bbp_get_public_child_last_id( $parent_id = 0, $post_type = 'post' ) {
     
    11601207                return false;
    11611208
    11621209        // The ID of the cached query
    1163         $cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_last_id';
     1210        $cache_id    = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_last_id';
     1211        $post_status = array( 'publish' );
    11641212
     1213        if ( $post_type == bbp_get_topic_post_type() )
     1214                $post_status[] = $bbp->closed_status_id;
     1215
     1216        $post_status = "'" . join( "', '", $post_status ) . "'";
     1217
    11651218        if ( !$child_id = wp_cache_get( $cache_id, 'bbpress' ) ) {
    1166                 $child_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status = 'publish' AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", $parent_id, $post_type ) );
     1219                $child_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", $parent_id, $post_type ) );
    11671220                wp_cache_set( $cache_id, $child_id, 'bbpress' );
    11681221        }
    11691222
     
    11731226/**
    11741227 * Query the DB and get a count of public children
    11751228 *
    1176  * @global db $wpdb
    1177  * @param int $parent_id
    1178  * @param string $post_type
     1229 * @param int $parent_id Parent id
     1230 * @param string $post_type Post type. Defaults to 'post'
     1231 * @uses bbp_get_topic_post_type() To get the topic post type
     1232 * @uses wp_cache_get() To check if there is a cache of the children count
     1233 * @uses wpdb::prepare() To prepare the query
     1234 * @uses wpdb::get_var() To get the result of the query in a variable
     1235 * @uses wp_cache_set() To set the cache for future use
     1236 * @uses apply_filters() Calls 'bbp_get_public_child_count' with the child
     1237 *                        count, parent id and post type
    11791238 * @return int The number of children
    11801239 */
    11811240function bbp_get_public_child_count( $parent_id = 0, $post_type = 'post' ) {
     
    11851244                return false;
    11861245
    11871246        // The ID of the cached query
    1188         $cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_count';
     1247        $cache_id    = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_count';
     1248        $post_status = array( 'publish' );
    11891249
     1250        if ( $post_type == bbp_get_topic_post_type() )
     1251                $post_status[] = $bbp->closed_status_id;
     1252
     1253        $post_status = "'" . join( "', '", $post_status ) . "'";
     1254
    11901255        if ( !$child_count = wp_cache_get( $cache_id, 'bbpress' ) ) {
    1191                 $child_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( "', '", array( 'publish', $bbp->closed_status_id ) ) . "' ) AND post_type = '%s';", $parent_id, $post_type ) );
     1256                $child_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';", $parent_id, $post_type ) );
    11921257                wp_cache_set( $cache_id, $child_count, 'bbpress' );
    11931258        }
    11941259
     
    11961261}
    11971262
    11981263/**
    1199  * Query the DB and get a the child ID's of public children
     1264 * Query the DB and get a the child id's of public children
    12001265 *
    1201  * @global db $wpdb
    1202  * @param int $parent_id
    1203  * @param string $post_type
    1204  * @return int The number of children
     1266 * @param int $parent_id Parent id
     1267 * @param string $post_type Post type. Defaults to 'post'
     1268 * @uses bbp_get_topic_post_type() To get the topic post type
     1269 * @uses wp_cache_get() To check if there is a cache of the children
     1270 * @uses wpdb::prepare() To prepare the query
     1271 * @uses wpdb::get_col() To get the result of the query in an array
     1272 * @uses wp_cache_set() To set the cache for future use
     1273 * @uses apply_filters() Calls 'bbp_get_public_child_ids' with the child ids,
     1274 *                        parent id and post type
     1275 * @return array The array of children
    12051276 */
    12061277function bbp_get_public_child_ids( $parent_id = 0, $post_type = 'post' ) {
    12071278        global $wpdb, $bbp;
     
    12101281                return false;
    12111282
    12121283        // The ID of the cached query
    1213         $cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_ids';
     1284        $cache_id    = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_ids';
     1285        $post_status = array( 'publish' );
    12141286
     1287        if ( $post_type == bbp_get_topic_post_type() )
     1288                $post_status[] = $bbp->closed_status_id;
     1289
     1290        $post_status = "'" . join( "', '", $post_status ) . "'";
     1291
    12151292        if ( !$child_ids = wp_cache_get( $cache_id, 'bbpress' ) ) {
    1216                 $child_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( "', '", array( 'publish', $bbp->closed_status_id ) ) . "' ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) );
     1293                $child_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) );
    12171294                wp_cache_set( $cache_id, $child_ids, 'bbpress' );
    12181295        }
    12191296
  • bbp-includes/bbp-general-template.php

     
    3838 *
    3939 * @since bbPress (r2549)
    4040 *
    41  * @uses WP_Query
    42  *
    4341 * @param int $post_id Possible post_id to check
    44  * @return bool
     42 * @uses bbp_get_forum_post_type() To get the forum post type
     43 * @uses is_singular() To check if it's the single post page
     44 * @uses get_post_field() To get the post type of the post id
     45 * @uses WP_Query To make some checks
     46 * @return bool True if it's a forum page, false if not
    4547 */
    4648function bbp_is_forum( $post_id = 0 ) {
    4749        global $wp_query, $bbp;
     
    6870 *
    6971 * @since bbPress (r2549)
    7072 *
    71  * @uses WP_Query
    72  * @uses bbp_is_topic_edit() To check if it's a topic edit page
    73  *
    7473 * @param int $post_id Possible post_id to check
    75  * @return bool
     74 * @uses bbp_is_topic_edit() To return false if it's a topic edit page
     75 * @uses bbp_get_topic_post_type() To get the topic post type
     76 * @uses is_singular() To check if it's the single post page
     77 * @uses get_post_field() To get the post type of the post id
     78 * @uses WP_Query To make some checks
     79 * @return bool True if it's a topic page, false if not
    7680 */
    7781function bbp_is_topic( $post_id = 0 ) {
    7882        global $wp_query, $bbp;
     
    104108 * @since bbPress (r2753)
    105109 *
    106110 * @uses WP_Query Checks if WP_Query::bbp_is_topic_edit is true
    107  * @return bool
     111 * @return bool True if it's the topic edit page, false if not
    108112 */
    109113function bbp_is_topic_edit() {
    110114        global $wp_query;
     
    121125 * @since bbPress (r2756)
    122126 *
    123127 * @uses bbp_is_topic_edit() To check if it's a topic edit page
    124  * @return bool
     128 * @return bool True if it's the topic merge page, false if not
    125129 */
    126130function bbp_is_topic_merge() {
    127131
     
    137141 * @since bbPress (r2756)
    138142 *
    139143 * @uses bbp_is_topic_edit() To check if it's a topic edit page
    140  * @return bool
     144 * @return bool True if it's the topic split page, false if not
    141145 */
    142146function bbp_is_topic_split() {
    143147
     
    147151        return false;
    148152}
    149153
     154
    150155/**
    151156 * Check if current page is a bbPress reply
    152157 *
    153158 * @since bbPress (r2549)
    154159 *
    155  * @uses WP_Query
    156  * @uses bbp_is_reply_edit() To check if it's a reply edit page
    157  *
    158160 * @param int $post_id Possible post_id to check
    159  * @return bool
     161 * @uses bbp_is_reply_edit() To return false if it's a reply edit page
     162 * @uses bbp_get_reply_post_type() To get the reply post type
     163 * @uses is_singular() To check if it's the single post page
     164 * @uses get_post_field() To get the post type of the post id
     165 * @uses WP_Query To make some checks
     166 * @return bool True if it's a reply page, false if not
    160167 */
    161168function bbp_is_reply( $post_id = 0 ) {
    162169        global $wp_query, $bbp;
     
    188195 * @since bbPress (r2753)
    189196 *
    190197 * @uses WP_Query Checks if WP_Query::bbp_is_reply_edit is true
    191  * @return bool
     198 * @return bool True if it's the reply edit page, false if not
    192199 */
    193200function bbp_is_reply_edit() {
    194201        global $wp_query;
     
    210217 *                                to true.
    211218 * @uses bbp_is_user_profile_page() To check if it's the user profile page
    212219 * @uses bbp_get_query_name() To get the query name
    213  * @return bool
     220 * @return bool True if it's the favorites page, false if not
    214221 */
    215222function bbp_is_favorites( $query_name_check = true ) {
    216223        if ( !bbp_is_user_profile_page() )
     
    233240 *                                to true.
    234241 * @uses bbp_is_user_profile_page() To check if it's the user profile page
    235242 * @uses bbp_get_query_name() To get the query name
    236  * @return bool
     243 * @return bool True if it's the subscriptions page, false if not
    237244 */
    238245function bbp_is_subscriptions( $query_name_check = true ) {
    239246        if ( !bbp_is_user_profile_page() )
     
    257264 *                                to true.
    258265 * @uses bbp_is_user_profile_page() To check if it's the user profile page
    259266 * @uses bbp_get_query_name() To get the query name
    260  * @return bool
     267 * @return bool True if it's the topics created page, false if not
    261268 */
    262269function bbp_is_topics_created( $query_name_check = true ) {
    263270        if ( !bbp_is_user_profile_page() )
     
    275282 * @uses bbPres Checks if bbPress::displayed_user is set and if
    276283 *               bbPress::displayed_user::ID equals bbPress::current_user::ID
    277284 *               or not
    278  * @return bool
     285 * @return bool True if it's the user's home, false if not
    279286 */
    280287function bbp_is_user_home() {
    281288        global $bbp;
     
    292299 * @since bbPress (r2688)
    293300 *
    294301 * @uses WP_Query Checks if WP_Query::bbp_is_user_profile_page is set to true
    295  * @return bool
     302 * @return bool True if it's a user's profile page, false if not
    296303 */
    297304function bbp_is_user_profile_page() {
    298305        global $wp_query;
     
    309316 * @since bbPress (r2688)
    310317 *
    311318 * @uses WP_Query Checks if WP_Query::bbp_is_user_profile_edit is set to true
    312  * @return bool
     319 * @return bool True if it's a user's profile edit page, false if not
    313320 */
    314321function bbp_is_user_profile_edit() {
    315322        global $wp_query;
     
    360367 * @uses bbp_is_subscriptions()
    361368 * @uses bbp_is_favorites()
    362369 * @uses bbp_is_topics_created()
    363  *
    364  * @return array
     370 * @return array Body Classes
    365371 */
    366372function bbp_body_class( $wp_classes, $custom_classes = false ) {
    367373
     
    477483        if ( empty( $url ) && ( !$url = wp_get_referer() ) && ( !empty( $_SERVER['REQUEST_URI'] ) ) )
    478484                $url = $_SERVER['REQUEST_URI'];
    479485
    480         $url = (string) esc_attr( $url );
     486        // Remove loggedout query arg if it's there
     487        $url = (string) esc_attr( remove_query_arg( 'loggedout', $url ) );
    481488
    482489        $referer_field = '<input type="hidden" name="redirect_to" value="' . $url . '" />';
    483490
     
    630637         *                              dropdown
    631638         * @uses current_user_can() To check if the current user can read
    632639         *                           private forums
     640         * @uses bbp_get_forum_post_type() To get the forum post type
     641         * @uses bbp_get_topic_post_type() To get the topic post type
    633642         * @uses walk_page_dropdown_tree() To generate the dropdown using the
    634643         *                                  walker
    635644         * @uses apply_filters() Calls 'bbp_get_dropdown' with the dropdown
     
    10081017 *
    10091018 * @since bbPress (r2692)
    10101019 *
    1011  * @uses bbp_set_query_name() To set the query var '_bbp_query_name' to ''
     1020 * @uses bbp_set_query_name() To set the query var '_bbp_query_name' value to ''
    10121021 */
    10131022function bbp_reset_query_name() {
    10141023        bbp_set_query_name();
     
    10501059         * @uses bbp_get_topic_permalink() To get the topic link
    10511060         * @uses bbp_get_reply_permalink() To get the reply link
    10521061         * @uses get_permalink() To get the permalink
     1062         * @uses bbp_get_forum_post_type() To get the forum post type
     1063         * @uses bbp_get_topic_post_type() To get the topic post type
     1064         * @uses bbp_get_reply_post_type() To get the reply post type
    10531065         * @uses bbp_get_forum_title() To get the forum title
    10541066         * @uses bbp_get_topic_title() To get the topic title
    10551067         * @uses bbp_get_reply_title() To get the reply title
     
    11411153                return apply_filters( 'bbp_get_allowed_tags', allowed_tags() );
    11421154        }
    11431155
    1144 /** Errors ********************************************************************/
     1156/** Errors & Messages *********************************************************/
    11451157
    11461158/**
    1147  * Display possible error messages inside a template file
     1159 * Display possible errors & messages inside a template file
    11481160 *
    11491161 * @since bbPress (r2688)
    11501162 *
     
    11531165 *                                                       messages
    11541166 * @uses is_wp_error() To check if it's a {@link WP_Error}
    11551167 */
    1156 function bbp_error_messages() {
     1168function bbp_template_notices() {
    11571169        global $bbp;
    11581170
    1159         if ( isset( $bbp->errors ) && is_wp_error( $bbp->errors ) && $bbp->errors->get_error_codes() ) : ?>
     1171        if ( !isset( $bbp->errors ) || !is_wp_error( $bbp->errors ) || !$bbp->errors->get_error_codes() )
     1172                return;
    11601173
     1174        $errors = $messages = array();
     1175
     1176        foreach ( $bbp->errors->get_error_codes() as $code ) {
     1177                $severity = $bbp->errors->get_error_data( $code );
     1178                foreach ( $bbp->errors->get_error_messages( $code ) as $error ) {
     1179                        if ( 'message' == $severity )
     1180                                $messages[] = $error;
     1181                        else
     1182                                $errors[]   = $error;
     1183                }
     1184        }
     1185
     1186        if ( !empty( $errors ) ) : ?>
     1187
    11611188                <div class="bbp-template-notice error">
    11621189                        <p>
    1163                                 <?php echo implode( "</p>\n<p>", $bbp->errors->get_error_messages() ); ?>
     1190                                <?php echo implode( "</p>\n<p>", $errors ); ?>
    11641191                        </p>
    11651192                </div>
    11661193
    1167 <?php endif;
     1194        <?php endif;
     1195
     1196        if ( !empty( $messages ) ) : ?>
     1197
     1198                <div class="bbp-template-notice">
     1199                        <p>
     1200                                <?php echo implode( "</p>\n<p>", $messages ); ?>
     1201                        </p>
     1202                </div>
     1203
     1204        <?php endif;
    11681205}
    11691206
    11701207/** Login/logout/register/lost pass *******************************************/
     
    11921229         * @return string The logout link
    11931230         */
    11941231        function bbp_get_logout_link( $redirect_to = '' ) {
    1195                 return apply_filters( 'bbp_get_logout_link', '<a href="' . wp_logout_url() . '" class="button logout-link">' . __( 'Log Out', 'bbpress' ) . '</a>', $redirect_to );
     1232                if ( empty( $redirect_to ) )
     1233                        $redirect_to = add_query_arg( array( 'loggedout' => '1' ) );
     1234
     1235                return apply_filters( 'bbp_get_logout_link', '<a href="' . wp_logout_url( $redirect_to ) . '" class="button logout-link">' . __( 'Log Out', 'bbpress' ) . '</a>', $redirect_to );
    11961236        }
    11971237
    11981238?>
  • bbp-includes/bbp-hooks.php

     
    7575add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Topics_Widget");'  ) );
    7676add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Replies_Widget");' ) );
    7777
    78 // Template - Head, foot, errors and notices
    79 add_action( 'wp_head',              'bbp_head'                  );
    80 add_filter( 'wp_title',             'bbp_title',          10, 3 );
    81 add_action( 'wp_footer',            'bbp_footer'                );
    82 add_action( 'bbp_template_notices', 'bbp_error_messages'        );
    83 add_action( 'bbp_template_notices', 'bbp_topic_notices'         );
     78// Template - Head, foot, errors and messages
     79add_action( 'wp_head',              'bbp_head'                    );
     80add_filter( 'wp_title',             'bbp_title',            10, 3 );
     81add_action( 'wp_footer',            'bbp_footer'                  );
     82add_action( 'bbp_loaded',           'bbp_login_notices'           );
     83add_action( 'bbp_head',             'bbp_topic_notices'           );
     84add_action( 'bbp_template_notices', 'bbp_template_notices'        );
    8485
    8586// Add to body class
    8687add_filter( 'body_class', 'bbp_body_class', 10, 2 );
     
    299300bbp_pre_anonymous_filters();
    300301
    301302/**
    302  * On multiblog installations you must first allow themes to be activated and show
    303  * up on the theme selection screen. This function will let the bbPress bundled
    304  * themes show up and bypass this step.
     303 * On multiblog installations you must first allow themes to be activated and
     304 * show up on the theme selection screen. This function will let the bbPress
     305 * bundled themes show up and bypass this step.
    305306 *
    306307 * @since bbPress (r2944)
    307308 *
    308  * @uses is_super_admin()
    309  * @uses apply_filters()
     309 * @uses is_super_admin() To check if the user is site admin
     310 * @uses apply_filters() Calls 'bbp_allowed_themes' with the allowed themes list
    310311 */
    311312function bbp_allowed_themes( $themes ) {
    312313        if ( !is_super_admin() )
  • bbp-includes/bbp-topic-template.php

     
    1010/** Post Type *****************************************************************/
    1111
    1212/**
    13  * Return the unique ID of the custom post type for topics
     13 * Output the unique id of the custom post type for topics
    1414 *
    1515 * @since bbPress (r2857)
    1616 *
    17  * @global bbPress $bbp
    18  * @return string
     17 * @uses bbp_get_topic_post_type() To get the topic post type
    1918 */
    2019function bbp_topic_post_type() {
    2120        echo bbp_get_topic_post_type();
    2221}
    2322        /**
    24          * Return the unique ID of the custom post type for topics
     23         * Return the unique id of the custom post type for topics
    2524         *
    2625         * @since bbPress (r2857)
    2726         *
    28          * @global bbPress $bbp
    29          * @return string
     27         * @uses apply_filters() Calls 'bbp_get_topic_post_type' with the topic
     28         *                        post type id
     29         * @return string The unique topic post type id
    3030         */
    3131        function bbp_get_topic_post_type() {
    3232                global $bbp;
     33
    3334                return apply_filters( 'bbp_get_topic_post_type', $bbp->topic_post_type );
    3435        }
    3536
     
    4142 * @since bbPress (r2485)
    4243 *
    4344 * @param mixed $args All the arguments supported by {@link WP_Query}
    44  * @uses bbp_is_user_profile_page() To check if it's the profile page
    45  * @uses get_the_ID() To get the id
     45 * @uses current_user_can() To check if the current user can edit other's topics
     46 * @uses bbp_get_topic_post_type() To get the topic post type
    4647 * @uses WP_Query To make query and get the topics
    4748 * @uses is_page() To check if it's a page
    4849 * @uses bbp_is_forum() To check if it's a forum
     50 * @uses bbp_get_forum_id() To get the forum id
    4951 * @uses bbp_get_paged() To get the current page value
    5052 * @uses bbp_get_super_stickies() To get the super stickies
    5153 * @uses bbp_get_stickies() To get the forum stickies
     
    283285         * @uses bbp_is_reply() To check if it it's a reply page
    284286         * @uses bbp_is_reply_edit() To check if it's a reply edit page
    285287         * @uses bbp_get_reply_topic_edit() To get the reply topic id
     288         * @uses get_post_field() To get the post's post type
    286289         * @uses WP_Query::post::ID To get the topic id
    287          * @uses apply_filters() Calls 'bbp_get_topic_id' with the topic id
     290         * @uses apply_filters() Calls 'bbp_get_topic_id' with the topic id and
     291         *                        supplied topic id
     292         * @return int The topic id
    288293         */
    289294        function bbp_get_topic_id( $topic_id = 0 ) {
    290295                global $bbp, $wp_query, $bbp;
     
    529534         * @uses bbp_get_topic_revisions() To get the topic revisions
    530535         * @uses bbp_get_topic_raw_revision_log() To get the raw revision log
    531536         * @uses bbp_get_topic_author_display_name() To get the topic author
    532          * @uses bbp_get_topic_author_link() To get the topic author link
     537         * @uses bbp_get_author_link() To get the topic author link
    533538         * @uses bbp_convert_date() To convert the date
    534539         * @uses bbp_get_time_since() To get the time in since format
    535540         * @uses apply_filters() Calls 'bbp_get_topic_revision_log' with the
     
    758763 * @param int $topic_id Optional. Topic id
    759764 * @uses bbp_get_topic_id() To get the topic id
    760765 * @uses bbp_get_topic_status() To get the topic status
    761  * @return bool True if spam, false if not.
     766 * @return bool True if trashed, false if not.
    762767 */
    763768function bbp_is_topic_trash( $topic_id = 0 ) {
    764769        global $bbp;
     
    814819         * @uses bbp_get_topic_id() To get the topic id
    815820         * @uses bbp_is_topic_anonymous() To check if the topic is by an
    816821         *                                 anonymous user
     822         * @uses bbp_get_topic_author_id() To get the topic author id
     823         * @uses get_the_author_meta() To get the display name of the author
     824         * @uses get_post_meta() To get the name of the anonymous poster
    817825         * @uses apply_filters() Calls 'bbp_get_topic_author' with the author
    818826         *                        and topic id
    819827         * @return string Author of topic
     
    11161124         *
    11171125         * @param int $topic_id Optional. Topic id
    11181126         * @uses bbp_get_topic_id() To get topic id
    1119          * @uses get_post_field() To get get topic's parent
     1127         * @uses get_post_meta() To retrieve get topic's forum id meta
     1128         * @uses get_post_field() To get the topic's parent, i.e. forum id
     1129         * @uses bbp_update_topic_forum_id() To update the topic forum id
    11201130         * @uses apply_filters() Calls 'bbp_get_topic_forum_id' with the forum
    1121          *  id and topic id
     1131         *                        id and topic id
    11221132         * @return int Topic forum id
    11231133         */
    11241134        function bbp_get_topic_forum_id( $topic_id = 0 ) {
     
    11391149 *
    11401150 * @since bbPress (r2860)
    11411151 *
     1152 * @param int $topic_id Optional. Forum id
    11421153 * @uses bbp_get_topic_last_active_id() To get the topic's last active id
    1143  * @param int $topic_id Optional. Forum id
    11441154 */
    11451155function bbp_topic_last_active_id( $topic_id = 0 ) {
    11461156        echo bbp_get_topic_last_active_id( $topic_id );
     
    14831493         * @uses get_post_meta() To get the topic post count meta
    14841494         * @uses apply_filters() Calls 'bbp_get_topic_post_count' with the
    14851495         *                        post count and topic id
    1486          * @return int post count
     1496         * @return int Post count
    14871497         */
    14881498        function bbp_get_topic_post_count( $topic_id = 0 ) {
    14891499                $topic_id = bbp_get_topic_id( $topic_id );
     
    18461856         * @uses bbp_get_topic() To get the topic
    18471857         * @uses current_user_can() To check if the current user can delete the
    18481858         *                           topic
     1859         * @uses bbp_is_topic_trash() To check if the topic is trashed
    18491860         * @uses bbp_get_topic_status() To get the topic status
    18501861         * @uses add_query_arg() To add custom args to the url
    18511862         * @uses wp_nonce_url() To nonce the url
     
    22192230 *
    22202231 * @uses bbp_is_topic() To check if it's a topic page
    22212232 * @uses bbp_get_topic_status() To get the topic status
     2233 * @uses bbp_get_topic_id() To get the topic id
     2234 * @uses apply_filters() Calls 'bbp_topic_notices' with the notice text, topic
     2235 *                        status and topic id
     2236 * @uses bbPress::errors::add() To add the notices to the error handler
    22222237 */
    22232238function bbp_topic_notices() {
    22242239        global $bbp;
     
    22502265        }
    22512266
    22522267        // Filter notice text and bail if empty
    2253         if ( ! $notice_text = apply_filters( 'bbp_topic_notices', $notice_text, $topic_status, bbp_get_topic_id() ) )
    2254                 return; ?>
     2268        if ( !$notice_text = apply_filters( 'bbp_topic_notices', $notice_text, $topic_status, bbp_get_topic_id() ) )
     2269                return;
    22552270
    2256         <div class="bbp-template-notice error">
    2257                 <p><?php echo $notice_text; ?></p>
    2258         </div>
    2259 
    2260         <?php
     2271        $bbp->errors->add( 'topic_notice', $notice_text, 'message' );
    22612272}
    22622273
    22632274/**
     
    23352346 *
    23362347 * @since bbPress (r2860)
    23372348 *
     2349 * @param array $args See {@link bbp_get_single_topic_description()}
    23382350 * @uses bbp_get_single_topic_description() Return the eventual output
    2339  *
    2340  * @param arr $args Arguments passed to alter output
    23412351 */
    23422352function bbp_single_topic_description( $args = '' ) {
    23432353        echo bbp_get_single_topic_description( $args );
     
    23482358         *
    23492359         * @since bbPress (r2860)
    23502360         *
    2351          * @uses wp_parse_args()
    2352          * @uses bbp_get_topic_id()
    2353          * @uses bbp_get_topic_topic_count()
    2354          * @uses bbp_get_topic_reply_count()
    2355          * @uses bbp_get_topic_subtopic_count()
    2356          * @uses bbp_get_topic_freshness_link()
    2357          * @uses bbp_get_topic_last_reply_id()
    2358          * @uses bbp_get_reply_author_avatar()
    2359          * @uses bbp_get_reply_author_link()
    2360          * @uses apply_filters()
    2361          *
    2362          * @param arr $args Arguments passed to alter output
    2363          *
     2361         * @param mixed $args This function supports these arguments:
     2362         *  - topic_id: Topic id
     2363         *  - before: Before the text
     2364         *  - after: After the text
     2365         *  - size: Size of the avatar
     2366         * @uses bbp_get_topic_id() To get the topic id
     2367         * @uses bbp_get_topic_voice_count() To get the topic voice count
     2368         * @uses bbp_get_topic_reply_count() To get the topic reply count
     2369         * @uses bbp_get_topic_freshness_link() To get the topic freshness link
     2370         * @uses bbp_get_topic_last_active_id() To get the topic last active id
     2371         * @uses bbp_get_reply_author_link() To get the reply author link
     2372         * @uses apply_filters() Calls 'bbp_get_single_topic_description' with
     2373         *                        the description and args
    23642374         * @return string Filtered topic description
    23652375         */
    23662376        function bbp_get_single_topic_description( $args = '' ) {
  • bbp-includes/bbp-user-template.php

     
    537537         *
    538538         * @param int $user_id Optional. User id
    539539         * @uses bbp_get_user_profile_url() To get the user profile url
    540          * @uses apply_filters() Calls 'bbp_get_favorites_permalink' with the
    541          *                        user profile url and user id
     540         * @uses apply_filters() Calls 'bbp_get_subscriptions_permalink' with
     541         *                        the user profile url and user id
    542542         * @return string Permanent link to user subscriptions page
    543543         */
    544544        function bbp_get_subscriptions_permalink( $user_id = 0 ) {
     
    763763
    764764/** Login *********************************************************************/
    765765
     766function bbp_login_notices() {
     767        global $bbp;
     768
     769        if ( !empty( $_GET['loggedout'] ) && true == $_GET['loggedout'] ) {
     770                $bbp->errors->add( 'loggedout', __( 'You are now logged out.', 'bbpress' ), 'message' );
     771        } elseif ( !empty( $_GET['registration'] ) && 'disabled' == $_GET['registration'] ) {
     772                $bbp->errors->add( 'registerdisabled', __( 'User registration is currently not allowed.', 'bbpress' ) );
     773        } elseif ( !empty( $_GET['checkemail'] ) && in_array( $_GET['checkemail'], array( 'confirm', 'newpass', 'registered' ) ) ) {
     774                switch ( $_GET['checkemail'] ) {
     775                        case 'confirm' :
     776                                $bbp->errors->add( 'confirm',    __( 'Check your e-mail for the confirmation link.',     'bbpress' ), 'message' );
     777                                break;
     778                        case 'newpass' :
     779                                $bbp->errors->add( 'newpass',    __( 'Check your e-mail for your new password.',         'bbpress' ), 'message' );
     780                                break;
     781                        case 'registered' :
     782                                $bbp->errors->add( 'registered', __( 'Registration complete. Please check your e-mail.', 'bbpress' ), 'message' );
     783                                break;
     784                }
     785        }
     786}
     787
    766788/**
    767789 * Redirect a user back to their profile if they are already logged in.
    768790 *
     
    812834 *
    813835 * @since bbPress (r2815)
    814836 *
     837 * @uses bbp_login_url() To get the login url
     838 * @uses bbp_redirect_to_field() To output the redirect to field
    815839 * @uses wp_nonce_field() To generate hidden nonce fields
    816840 */
    817841function bbp_user_register_fields() {
    818842?>
    819843
    820                 <input type="hidden" name="action"      value="bbp-user-register" id="bbp_user_register" />
     844                <input type="hidden" name="action"      value="register" />
    821845                <input type="hidden" name="user-cookie" value="1" />
    822846
     847                <?php bbp_redirect_to_field( add_query_arg( array( 'checkemail' => 'registered' ), bbp_login_url() ) ); ?>
     848
    823849                <?php wp_nonce_field( 'bbp-user-register' );
    824850}
    825851
     
    861887         * @since bbPress (r2875)
    862888         *
    863889         * @param mixed $args Optional. If an integer, it is used as reply id.
    864          * @uses bbp_get_reply_id() To get the reply id
    865890         * @uses bbp_is_topic() To check if it's a topic page
     891         * @uses bbp_get_topic_author_link() To get the topic author link
    866892         * @uses bbp_is_reply() To check if it's a reply page
     893         * @uses bbp_get_reply_author_link() To get the reply author link
     894         * @uses get_post_field() To get the post author
    867895         * @uses bbp_is_reply_anonymous() To check if the reply is by an
    868896         *                                 anonymous user
    869          * @uses bbp_get_reply_author() To get the reply author name
    870          * @uses bbp_get_reply_author_url() To get the reply author url
    871          * @uses bbp_get_reply_author_avatar() To get the reply author avatar
     897         * @uses get_the_author_meta() To get the author name
     898         * @uses bbp_get_user_profile_url() To get the author profile url
     899         * @uses get_avatar() To get the author avatar
    872900         * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the
    873901         *                        author link and args
    874902         * @return string Author link of reply
  • bbp-includes/bbp-widgets.php

     
    6565                                <fieldset>
    6666                                        <legend><?php _e( 'Login', 'bbpress' ); ?></legend>
    6767
    68                                         <?php do_action( 'bbp_template_notices' ); ?>
    69 
    7068                                        <div class="bbp-username">
    7169                                                <label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label>
    7270                                                <input type="text" name="log" value="<?php bbp_sanitize_val( 'user_login', 'text' ); ?>" size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?>" />
     
    182180         * @param mixed $args Arguments
    183181         * @param array $instance Instance
    184182         * @uses apply_filters() Calls 'bbp_forum_widget_title' with the title
     183         * @uses get_option() To get the forums per page option
     184         * @uses current_user_can() To check if the current user can read
     185         *                           private() To resety name
     186         * @uses bbp_set_query_name() To set the query name to 'bbp_widget'
     187         * @uses bbp_reset_query_name() To reset the query name
    185188         * @uses bbp_has_forums() The main forum loop
    186189         * @uses bbp_forums() To check whether there are more forums available
    187190         *                     in the loop
     
    314317         * @param mixed $args
    315318         * @param array $instance
    316319         * @uses apply_filters() Calls 'bbp_topic_widget_title' with the title
     320         * @uses bbp_set_query_name() To set the query name to 'bbp_widget'
     321         * @uses bbp_reset_query_name() To reset the query name
    317322         * @uses bbp_has_topics() The main topic loop
    318323         * @uses bbp_topics() To check whether there are more topics available
    319324         *                     in the loop
    320325         * @uses bbp_the_topic() Loads up the current topic in the loop
    321326         * @uses bbp_topic_permalink() To display the topic permalink
    322327         * @uses bbp_topic_title() To display the topic title
    323          * @uses bbp_get_topic_last_active_time() To get the topic last active time
     328         * @uses bbp_get_topic_last_active_time() To get the topic last active
     329         *                                         time
    324330         * @uses bbp_get_topic_id() To get the topic id
    325331         * @uses bbp_get_topic_reply_count() To get the topic reply count
    326332         */
  • bbp-themes/bbp-twentyten/bbpress/form-user-login.php

     
    1313                <fieldset>
    1414                        <legend><?php _e( 'Login', 'bbpress' ); ?></legend>
    1515
    16                         <?php do_action( 'bbp_template_notices' ); ?>
    17 
    1816                        <div class="bbp-username">
    1917                                <label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label>
    2018                                <input type="text" name="log" value="<?php bbp_sanitize_val( 'user_login', 'text' ); ?>" size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?>" />
  • bbp-themes/bbp-twentyten/bbpress/form-user-register.php

     
    99
    1010?>
    1111
    12         <form method="post" action="<?php bbp_wp_login_action( array( 'action' => 'register', 'context' => 'login_post' ) ); ?>" class="bbp-login-form">
     12        <form method="post" action="<?php bbp_wp_login_action( array( 'context' => 'login_post' ) ); ?>" class="bbp-login-form">
    1313                <fieldset>
    1414                        <legend><?php _e( 'Register', 'bbpress' ); ?></legend>
    1515
    16                         <?php do_action( 'bbp_template_notices' ); ?>
    17 
    1816                        <div class="bbp-username">
    1917                                <label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label>
    2018                                <input type="text" name="user_login" value="<?php bbp_sanitize_val( 'user_login' ); ?>" size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?>" />
     
    2523                                <input type="text" name="user_email" value="<?php bbp_sanitize_val( 'user_email' ); ?>" size="20" id="user_email" tabindex="<?php bbp_tab_index(); ?>" />
    2624                        </div>
    2725
     26                        <?php do_action( 'register_form' ); ?>
     27
     28                        <p id="reg_passmail"><?php _e( 'A password will be e-mailed to you.', 'bbpress' ) ?></p>
     29
    2830                        <div class="bbp-submit-wrapper">
    2931
    30                                 <?php do_action( 'register_form' ); ?>
    31 
    3232                                <button type="submit" name="user-submit" tabindex="<?php bbp_tab_index(); ?>" class="user-submit"><?php _e( 'Register', 'bbpress' ); ?></button>
    3333
    3434                                <?php bbp_user_register_fields(); ?>