Skip to:
Content

bbPress.org

Changeset 3192


Ignore:
Timestamp:
05/21/2011 09:50:56 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Move a few theme compatibility helper functions out of bbp-general-functions.php and into bbp-core-compatibility.php

Location:
branches/plugin/bbp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-core-compatibility.php

    r3190 r3192  
    800800}
    801801
     802/** Helpers *******************************************************************/
     803
     804/**
     805 * Remove the canonical redirect to allow pretty pagination
     806 *
     807 * @since bbPress (r2628)
     808 *
     809 * @param string $redirect_url Redirect url
     810 * @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
     811 * @uses bbp_is_topic() To check if it's a topic page
     812 * @uses bbp_get_paged() To get the current page number
     813 * @uses bbp_is_forum() To check if it's a forum page
     814 * @return bool|string False if it's a topic/forum and their first page,
     815 *                      otherwise the redirect url
     816 */
     817function bbp_redirect_canonical( $redirect_url ) {
     818    global $wp_rewrite;
     819
     820    if ( $wp_rewrite->using_permalinks() ) {
     821        if ( bbp_is_topic() && 1 < bbp_get_paged() )
     822            $redirect_url = false;
     823        elseif ( bbp_is_forum() && 1 < bbp_get_paged() )
     824            $redirect_url = false;
     825    }
     826
     827    return $redirect_url;
     828}
     829
     830/**
     831 * Sets the 404 status.
     832 *
     833 * Used primarily with topics/replies inside hidden forums.
     834 *
     835 * @since bbPress (r3051)
     836 *
     837 * @global WP_Query $wp_query
     838 * @uses WP_Query::set_404()
     839 */
     840function bbp_set_404() {
     841    global $wp_query;
     842
     843    if ( ! isset( $wp_query ) ) {
     844        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
     845        return false;
     846    }
     847
     848    $wp_query->set_404();
     849}
     850
     851
    802852?>
  • branches/plugin/bbp-includes/bbp-general-functions.php

    r3181 r3192  
    7878 */
    7979function bbp_number_format( $number, $decimals = false ) {
     80
    8081    // If empty, set $number to '0'
    8182    if ( empty( $number ) || !is_numeric( $number ) )
     
    158159
    159160    // We add our own full stop.
    160     while ( substr( $reason, -1 ) == '.' ) {
     161    while ( substr( $reason, -1 ) == '.' )
    161162        $reason = substr( $reason, 0, -1 );
    162     }
    163163
    164164    // Trim again
     
    182182function bbp_show_lead_topic( $show_lead = false ) {
    183183    return apply_filters( 'bbp_show_lead_topic', (bool) $show_lead );
    184 }
    185 
    186 /**
    187  * Remove the canonical redirect to allow pretty pagination
    188  *
    189  * @since bbPress (r2628)
    190  *
    191  * @param string $redirect_url Redirect url
    192  * @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
    193  * @uses bbp_is_topic() To check if it's a topic page
    194  * @uses bbp_get_paged() To get the current page number
    195  * @uses bbp_is_forum() To check if it's a forum page
    196  * @return bool|string False if it's a topic/forum and their first page,
    197  *                      otherwise the redirect url
    198  */
    199 function bbp_redirect_canonical( $redirect_url ) {
    200     global $wp_rewrite;
    201 
    202     if ( $wp_rewrite->using_permalinks() ) {
    203         if ( bbp_is_topic() && 1 < bbp_get_paged() )
    204             $redirect_url = false;
    205         elseif ( bbp_is_forum() && 1 < bbp_get_paged() )
    206             $redirect_url = false;
    207     }
    208 
    209     return $redirect_url;
    210 }
    211 
    212 /**
    213  * Sets the 404 status.
    214  *
    215  * Used primarily with topics/replies inside hidden forums.
    216  *
    217  * @since bbPress (r3051)
    218  *
    219  * @global WP_Query $wp_query
    220  * @uses WP_Query::set_404()
    221  */
    222 function bbp_set_404() {
    223     global $wp_query;
    224 
    225     if ( ! isset( $wp_query ) ) {
    226         _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
    227         return false;
    228     }
    229 
    230     $wp_query->set_404();
    231184}
    232185
Note: See TracChangeset for help on using the changeset viewer.