Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/01/2011 01:33:09 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Adjustments to login and register forms to improve behavior and functionality.
Various documentation fixes.
Rename _bbp_topic_status meta to _bbp_status, and add migration routine to updater.
Sanity checks on $wp_query in bbp_pre_get_posts.

Fixes #1476, #1493. Props GautamGupta for original diff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-general-template.php

    r2927 r2970  
    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 ) {
     
    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 *
     75 * @uses bbp_is_topic_edit() To return false if it's a topic edit page
     76 * @uses bbp_get_topic_post_type() To get the topic post type
     77 * @uses is_singular() To check if it's the single post page
     78 * @uses get_post_field() To get the post type of the post id
     79 * @uses WP_Query To make some checks
     80 * @return bool True if it's a topic page, false if not
    7681 */
    7782function bbp_is_topic( $post_id = 0 ) {
     
    105110 *
    106111 * @uses WP_Query Checks if WP_Query::bbp_is_topic_edit is true
    107  * @return bool
     112 * @return bool True if it's the topic edit page, false if not
    108113 */
    109114function bbp_is_topic_edit() {
     
    122127 *
    123128 * @uses bbp_is_topic_edit() To check if it's a topic edit page
    124  * @return bool
     129 * @return bool True if it's the topic merge page, false if not
    125130 */
    126131function bbp_is_topic_merge() {
     
    138143 *
    139144 * @uses bbp_is_topic_edit() To check if it's a topic edit page
    140  * @return bool
     145 * @return bool True if it's the topic split page, false if not
    141146 */
    142147function bbp_is_topic_split() {
     
    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 ) {
     
    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() {
     
    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 ) {
     
    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 ) {
     
    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 ) {
     
    273280 * Check if current page is the currently logged in users author page
    274281 *
     282 * @since bbPress (r2688)
     283 *
    275284 * @uses bbPres Checks if bbPress::displayed_user is set and if
    276285 *               bbPress::displayed_user::ID equals bbPress::current_user::ID
    277286 *               or not
    278  * @return bool
     287 * @return bool True if it's the user's home, false if not
    279288 */
    280289function bbp_is_user_home() {
     
    293302 *
    294303 * @uses WP_Query Checks if WP_Query::bbp_is_user_profile_page is set to true
    295  * @return bool
     304 * @return bool True if it's a user's profile page, false if not
    296305 */
    297306function bbp_is_user_profile_page() {
     
    310319 *
    311320 * @uses WP_Query Checks if WP_Query::bbp_is_user_profile_edit is set to true
    312  * @return bool
     321 * @return bool True if it's a user's profile edit page, false if not
    313322 */
    314323function bbp_is_user_profile_edit() {
     
    345354 * @param array $wp_classes
    346355 * @param array $custom_classes
    347  *
    348356 * @uses bbp_is_forum()
    349357 * @uses bbp_is_topic()
     
    361369 * @uses bbp_is_favorites()
    362370 * @uses bbp_is_topics_created()
    363  *
    364  * @return array
     371 * @return array Body Classes
    365372 */
    366373function bbp_body_class( $wp_classes, $custom_classes = false ) {
     
    478485        $url = $_SERVER['REQUEST_URI'];
    479486
    480     $url = (string) esc_attr( $url );
     487    // Remove loggedout query arg if it's there
     488    $url = (string) esc_attr( remove_query_arg( 'loggedout', $url ) );
    481489
    482490    $referer_field = '<input type="hidden" name="redirect_to" value="' . $url . '" />';
     
    631639     * @uses current_user_can() To check if the current user can read
    632640     *                           private forums
     641     * @uses bbp_get_forum_post_type() To get the forum post type
     642     * @uses bbp_get_topic_post_type() To get the topic post type
    633643     * @uses walk_page_dropdown_tree() To generate the dropdown using the
    634644     *                                  walker
     
    10091019 * @since bbPress (r2692)
    10101020 *
    1011  * @uses bbp_set_query_name() To set the query var '_bbp_query_name' to ''
     1021 * @uses bbp_set_query_name() To set the query var '_bbp_query_name' value to ''
    10121022 */
    10131023function bbp_reset_query_name() {
     
    10511061     * @uses bbp_get_reply_permalink() To get the reply link
    10521062     * @uses get_permalink() To get the permalink
     1063     * @uses bbp_get_forum_post_type() To get the forum post type
     1064     * @uses bbp_get_topic_post_type() To get the topic post type
     1065     * @uses bbp_get_reply_post_type() To get the reply post type
    10531066     * @uses bbp_get_forum_title() To get the forum title
    10541067     * @uses bbp_get_topic_title() To get the topic title
     
    11421155    }
    11431156
    1144 /** Errors ********************************************************************/
    1145 
    1146 /**
    1147  * Display possible error messages inside a template file
     1157/** Errors & Messages *********************************************************/
     1158
     1159/**
     1160 * Display possible errors & messages inside a template file
    11481161 *
    11491162 * @since bbPress (r2688)
     
    11541167 * @uses is_wp_error() To check if it's a {@link WP_Error}
    11551168 */
    1156 function bbp_error_messages() {
     1169function bbp_template_notices() {
    11571170    global $bbp;
    11581171
    1159     if ( isset( $bbp->errors ) && is_wp_error( $bbp->errors ) && $bbp->errors->get_error_codes() ) : ?>
     1172    // Bail if no notices or errors
     1173    if ( !isset( $bbp->errors ) || !is_wp_error( $bbp->errors ) || !$bbp->errors->get_error_codes() )
     1174        return;
     1175
     1176    // Prevent debug notices
     1177    $errors = $messages = array();
     1178
     1179    // Loop through notices
     1180    foreach ( $bbp->errors->get_error_codes() as $code ) {
     1181
     1182        // Get notice severity
     1183        $severity = $bbp->errors->get_error_data( $code );
     1184
     1185        // Loop through notices and separate errors from messages
     1186        foreach ( $bbp->errors->get_error_messages( $code ) as $error ) {
     1187            if ( 'message' == $severity ) {
     1188                $messages[] = $error;
     1189            } else {
     1190                $errors[]   = $error;
     1191            }
     1192        }
     1193    }
     1194
     1195    // Display errors first...
     1196    if ( !empty( $errors ) ) : ?>
    11601197
    11611198        <div class="bbp-template-notice error">
    11621199            <p>
    1163                 <?php echo implode( "</p>\n<p>", $bbp->errors->get_error_messages() ); ?>
     1200                <?php echo implode( "</p>\n<p>", $errors ); ?>
    11641201            </p>
    11651202        </div>
    11661203
    1167 <?php endif;
     1204    <?php endif;
     1205
     1206    // ...and messages last
     1207    if ( !empty( $messages ) ) : ?>
     1208
     1209        <div class="bbp-template-notice">
     1210            <p>
     1211                <?php echo implode( "</p>\n<p>", $messages ); ?>
     1212            </p>
     1213        </div>
     1214
     1215    <?php endif;
    11681216}
    11691217
     
    11931241     */
    11941242    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 );
     1243        return apply_filters( 'bbp_get_logout_link', '<a href="' . wp_logout_url( $redirect_to ) . '" class="button logout-link">' . __( 'Log Out', 'bbpress' ) . '</a>', $redirect_to );
    11961244    }
    11971245
Note: See TracChangeset for help on using the changeset viewer.