Skip to:
Content

bbPress.org

Changeset 3265


Ignore:
Timestamp:
05/29/2011 01:51:02 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Improve the current title area of breadcrumbs.
Improve behavior of redirect field.
Allow single topic shortcodes to use pagination, and properly redirect on new replies.
Use wp_safe_redirect() in places where redirect_to fields are used.
Move theme compatibility setup function out of main bbPress class and into bbp-core-compatibility.php.
Move bbp_setup_theme_compat action off of after_setup_theme and into bbp_init.
Add supplemental functions to get and set if theme compatibility is currently helping load pieces of the current page.

Location:
branches/plugin
Files:
9 edited

Legend:

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

    r3253 r3265  
    2222 * Don't try anything you're about to witness here, at home. Ever.
    2323 */
     24
     25/**
     26 * If not using a bbPress compatable theme, enqueue some basic styling and js
     27 *
     28 * @since bbPress (r3029)
     29 *
     30 * @global bbPress $bbp
     31 * @uses bbp_set_theme_compat() Set the compatable theme to bbp-twentyten
     32 * @uses current_theme_supports() Check bbPress theme support
     33 * @uses wp_enqueue_style() Enqueue the bbp-twentyten default CSS
     34 * @uses wp_enqueue_script() Enqueue the bbp-twentyten default topic JS
     35 */
     36function bbp_add_theme_compat() {
     37    global $bbp;
     38
     39    // Check if current theme supports bbPress
     40    if ( !current_theme_supports( 'bbpress' ) ) {
     41
     42        // Set the compat_theme global for help with loading template parts
     43        bbp_set_theme_compat( $bbp->themes_dir . '/bbp-twentyten' );
     44
     45        /** Default CSS ***************************************************/
     46
     47        // Do not enqueue CSS in admin
     48        if ( !is_admin() ) {
     49
     50            // Right to left
     51            if ( is_rtl() ) {
     52                wp_enqueue_style( 'bbpress-style', $bbp->themes_url . '/bbp-twentyten/css/bbpress-rtl.css' );
     53
     54            // Left to right
     55            } else {
     56                wp_enqueue_style( 'bbpress-style', $bbp->themes_url . '/bbp-twentyten/css/bbpress.css' );
     57            }
     58        }
     59    }
     60}
    2461
    2562/**
     
    97134
    98135    return apply_filters( 'bbp_get_theme_compat', $bbp->theme_compat );
     136}
     137
     138/**
     139 * Gets true/false if page is currently inside theme compatibility
     140 *
     141 * @since bbPress (r3265)
     142 *
     143 * @global bbPress $bbp
     144 *
     145 * @return bool
     146 */
     147function bbp_in_theme_compat() {
     148    global $bbp;
     149
     150    return $bbp->in_theme_compat;
     151}
     152
     153/**
     154 * Sets true/false if page is currently inside theme compatibility
     155 *
     156 * @since bbPress (r3265)
     157 *
     158 * @global bbPress $bbp
     159 *
     160 * @param bool $set
     161 *
     162 * @return bool
     163 */
     164function bbp_set_in_theme_compat( $set = true ) {
     165    global $bbp;
     166
     167    $bbp->in_theme_compat = $set;
     168
     169    return (bool) $bbp->in_theme_compat;
    99170}
    100171
     
    542613
    543614        // Assume we are not in theme compat
    544         $in_theme_compat = false; $forum_id = 0;
     615        $forum_id = 0;
    545616
    546617        /** Users *************************************************************/
     
    549620
    550621            // In Theme Compat
    551             $in_theme_compat = true;
     622            bbp_set_in_theme_compat();
     623
     624            // Reset post
    552625            bbp_theme_compat_reset_post( array(
    553626                'post_title' => esc_attr( bbp_get_displayed_user_field( 'display_name' ) )
     
    560633
    561634            // In Theme Compat
    562             $in_theme_compat = true;
     635            bbp_set_in_theme_compat();
     636
     637            // Reset post
    563638            bbp_theme_compat_reset_post( array(
    564639                'ID'           => 0,
     
    577652
    578653            // In Theme Compat
    579             $in_theme_compat = true;
     654            bbp_set_in_theme_compat();
     655
     656            // Reset post
    580657            bbp_theme_compat_reset_post( array(
    581658                'ID'           => 0,
     
    592669
    593670            // In Theme Compat
    594             $in_theme_compat = true;
     671            bbp_set_in_theme_compat();
     672
     673            // Reset post
    595674            bbp_theme_compat_reset_post( array(
    596675                'ID'           => bbp_get_topic_id(),
     
    609688
    610689            // In Theme Compat
    611             $in_theme_compat = true;
     690            bbp_set_in_theme_compat();
     691
     692            // Reset post
    612693            bbp_theme_compat_reset_post( array(
    613694                'ID'           => 0,
     
    624705
    625706            // In Theme Compat
    626             $in_theme_compat = true;
     707            bbp_set_in_theme_compat();
     708
     709            // Reset post
    627710            bbp_theme_compat_reset_post( array(
    628711                'ID'           => bbp_get_reply_id(),
     
    640723
    641724            // In Theme Compat
    642             $in_theme_compat = true;
     725            bbp_set_in_theme_compat();
     726
     727            // Reset post
    643728            bbp_theme_compat_reset_post( array(
    644729                'ID'           => 0,
     
    657742
    658743            // In Theme Compat
    659             $in_theme_compat = true;
     744            bbp_set_in_theme_compat();
    660745
    661746            // Stash the current term in a new var
     
    676761                // Single Forum
    677762                case bbp_get_forum_post_type() :
    678                     $forum_id        = bbp_get_forum_id( get_the_ID() );
    679                     $in_theme_compat = true;
     763                    bbp_set_in_theme_compat();
     764                    $forum_id = bbp_get_forum_id( get_the_ID() );
    680765                    break;
    681766
    682767                // Single Topic
    683768                case bbp_get_topic_post_type() :
    684                     $forum_id        = bbp_get_topic_forum_id( get_the_ID() );
    685                     $in_theme_compat = true;
     769                    bbp_set_in_theme_compat();
     770                    $forum_id = bbp_get_topic_forum_id( get_the_ID() );
    686771                    break;
    687772
    688773                // Single Reply
    689774                case bbp_get_reply_post_type() :
    690                     $forum_id        = bbp_get_reply_forum_id( get_the_ID() );
    691                     $in_theme_compat = true;
     775                    bbp_set_in_theme_compat();
     776                    $forum_id = bbp_get_reply_forum_id( get_the_ID() );
    692777                    break;
    693778            }
     
    709794         * the 'bbp_template_include' filter to override page.php.
    710795         */
    711         if ( true === $in_theme_compat ) {
     796        if ( bbp_in_theme_compat() ) {
    712797
    713798            // Remove all filters from the_content
  • branches/plugin/bbp-includes/bbp-core-hooks.php

    r3243 r3265  
    3535add_action( 'init',                   'bbp_init',                   10 );
    3636add_action( 'generate_rewrite_rules', 'bbp_generate_rewrite_rules', 12 );
    37 add_action( 'after_setup_theme',      'bbp_setup_theme_compat',     12 );
    3837
    3938/**
     
    5958add_action( 'bbp_init', 'bbp_register_textdomain',    2   );
    6059add_action( 'bbp_init', 'bbp_setup_current_user',     4   );
    61 add_action( 'bbp_init', 'bbp_register_post_types',    6   );
    62 add_action( 'bbp_init', 'bbp_register_post_statuses', 8   );
    63 add_action( 'bbp_init', 'bbp_register_taxonomies',    10  );
    64 add_action( 'bbp_init', 'bbp_register_views',         12  );
    65 add_action( 'bbp_init', 'bbp_register_shortcodes',    14  );
    66 add_action( 'bbp_init', 'bbp_add_rewrite_tags',       16  );
     60add_action( 'bbp_init', 'bbp_setup_theme_compat',     6   );
     61add_action( 'bbp_init', 'bbp_register_post_types',    8   );
     62add_action( 'bbp_init', 'bbp_register_post_statuses', 10  );
     63add_action( 'bbp_init', 'bbp_register_taxonomies',    12  );
     64add_action( 'bbp_init', 'bbp_register_views',         14  );
     65add_action( 'bbp_init', 'bbp_register_shortcodes',    16  );
     66add_action( 'bbp_init', 'bbp_add_rewrite_tags',       18  );
    6767add_action( 'bbp_init', 'bbp_ready',                  999 );
     68
     69// Theme Compat
     70add_action( 'bbp_setup_theme_compat', 'bbp_add_theme_compat' );
    6871
    6972// Admin
  • branches/plugin/bbp-includes/bbp-core-shortcodes.php

    r3250 r3265  
    421421        $this->_unset_globals();
    422422
    423         // Reset necessary forum_query attributes for topics loop to function
    424         $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type();
    425         $bbp->forum_query->in_the_loop             = true;
    426         $bbp->forum_query->post                    = get_post( $forum_id );
    427 
    428         // Reset necessary topic_query attributes for topics loop to function
    429         $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type();
    430         $bbp->topic_query->in_the_loop             = true;
    431         $bbp->topic_query->post                    = get_post( $topic_id );
     423        // Reset the queries if not in theme compat
     424        if ( !bbp_in_theme_compat() ) {
     425
     426            // Reset necessary forum_query attributes for topics loop to function
     427            $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type();
     428            $bbp->forum_query->in_the_loop             = true;
     429            $bbp->forum_query->post                    = get_post( $forum_id );
     430
     431            // Reset necessary topic_query attributes for topics loop to function
     432            $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type();
     433            $bbp->topic_query->in_the_loop             = true;
     434            $bbp->topic_query->post                    = get_post( $topic_id );
     435        }
    432436
    433437        // Start output buffer
  • branches/plugin/bbp-includes/bbp-general-template.php

    r3259 r3265  
    546546 *                        and url
    547547 */
    548 function bbp_redirect_to_field( $url = '' ) {
    549     // If no URL is passed, try to get the referer and then the request uri
    550     if ( empty( $url ) && ( !$url = wp_get_referer() ) && ( !empty( $_SERVER['REQUEST_URI'] ) ) )
    551         $url = $_SERVER['REQUEST_URI'];
     548function bbp_redirect_to_field( $redirect_to = '' ) {
     549
     550    // Rejig the $redirect_to
     551    if ( !isset( $_SERVER['REDIRECT_URL'] ) || ( !$redirect_to = home_url( $_SERVER['REDIRECT_URL'] ) ) )
     552        $redirect_to = wp_get_referer();
     553
     554    // Make sure we are directing somewhere
     555    if ( empty( $redirect_to ) )
     556        $redirect_to = home_url( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '' );
    552557
    553558    // Remove loggedout query arg if it's there
    554     $url = (string) esc_attr( remove_query_arg( 'loggedout', $url ) );
    555 
    556     $referer_field = '<input type="hidden" name="redirect_to" value="' . $url . '" />';
    557 
    558     echo apply_filters( 'bbp_redirect_to_field', $referer_field, $url );
     559    $redirect_to    = (string) esc_attr( remove_query_arg( 'loggedout', $redirect_to ) );
     560    $redirect_field = '<input type="hidden" name="redirect_to" value="' . $redirect_to . '" />';
     561
     562    echo apply_filters( 'bbp_redirect_to_field', $redirect_field, $redirect_to );
    559563}
    560564
     
    920924        ?>
    921925
    922         <?php wp_nonce_field( 'bbp-new-reply' );
     926        <?php
     927       
     928        wp_nonce_field( 'bbp-new-reply' );
     929
     930        // Show redirect field if not viewing a specific topic
     931        if ( !bbp_is_topic() ) : ?>
     932
     933            <input type="hidden" name="redirect_to" id="bbp_redirect_to" value="<?php the_permalink(); ?>" />
     934
     935        <?php endif;
     936           
    923937    }
    924938}
     
    12591273        /** Current Text ******************************************************/
    12601274       
    1261         $pre_current_text = ( bbp_is_view() ) ? bbp_get_view_title() : get_the_title();
    1262        
     1275        // Forum archive
     1276        if ( bbp_is_forum_archive() )
     1277            $pre_current_text = bbp_get_forum_archive_title();
     1278
     1279        // Topic archive
     1280        elseif ( bbp_is_topic_archive() )
     1281            $pre_current_text = bbp_get_topic_archive_title();
     1282
     1283        // View
     1284        elseif ( bbp_is_view() )
     1285            $pre_current_text = bbp_get_view_title();
     1286
     1287        // Single Forum
     1288        elseif ( bbp_is_forum() )
     1289            $pre_current_text = bbp_get_forum_title();
     1290
     1291        // Single Topic
     1292        elseif ( bbp_is_topic() )
     1293            $pre_current_text = bbp_get_topic_title();
     1294
     1295        // Single Topic
     1296        elseif ( bbp_is_reply() )
     1297            $pre_current_text = bbp_get_reply_title();
     1298
     1299        // Single
     1300        else
     1301            $pre_current_text = get_the_title();
     1302
    12631303        /** Parse Args ********************************************************/
    12641304
     
    12891329
    12901330        // Get post ancestors
    1291         if ( is_page() || is_single() )
     1331        if ( is_page() || is_single() || bbp_is_topic_edit() || bbp_is_reply_edit() )
    12921332            $ancestors = array_reverse( get_post_ancestors( get_the_ID() ) );
    12931333
    12941334        // Do we want to include a link to home?
    1295         if ( !empty( $include_home ) )
     1335        if ( !empty( $include_home ) || empty( $home_text ) )
    12961336            $breadcrumbs[] = '<a href="' . trailingslashit( home_url() ) . '" class="bbp-breadcrumb-home">' . $home_text . '</a>';
    12971337
    12981338        // Do we want to include a link to the forum root?
    1299         if ( !empty( $include_root ) )
     1339        if ( !empty( $include_root ) || empty( $root_text ) )
    13001340            $breadcrumbs[] = '<a href="' . trailingslashit( home_url( $bbp->root_slug ) ) . '" class="bbp-breadcrumb-root">' . $root_text . '</a>';
    13011341
     
    13371377
    13381378        // Add current page to breadcrumb
    1339         if ( !empty( $include_current ) )
     1379        if ( !empty( $include_current ) || empty( $pre_current_text ) )
    13401380            $breadcrumbs[] = '<span class="bbp-breadcrumb-current">' . $current_text . '</span>';
    13411381
  • branches/plugin/bbp-includes/bbp-reply-functions.php

    r3255 r3265  
    134134 *                    id, anonymous data and reply author
    135135 * @uses bbp_get_reply_url() To get the paginated url to the reply
    136  * @uses wp_redirect() To redirect to the reply url
     136 * @uses wp_safe_redirect() To redirect to the reply url
    137137 * @uses bbPress::errors::get_error_message() To get the {@link WP_Error} error
    138138 *                                              message
     
    304304                /** Redirect **************************************************/
    305305
    306                 $reply_url = bbp_get_reply_url( $reply_id );
    307 
    308                 if ( ( !empty( $_GET['view'] ) && ( 'all' === $_GET['view'] ) ) || ( $reply_data['post_status'] == $bbp->trash_status_id ) )
     306                // Redirect to
     307                $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
     308
     309                // View all?
     310                $count_hidden = (bool) ( !empty( $_GET['view'] ) && ( 'all' == $_GET['view'] ) || ( $reply_data['post_status'] == $bbp->trash_status_id ) );
     311
     312                // Get the reply URL
     313                $reply_url = bbp_get_reply_url( $reply_id, $count_hidden, $redirect_to );
     314
     315                // Add view all?
     316                if ( !empty( $count_hidden ) )
    309317                    $reply_url = add_query_arg( array( 'view' => 'all' ), $reply_url );
    310318
    311                 $reply_url = apply_filters( 'bbp_new_reply_redirect_to', $reply_url );
     319                // Allow to be filtered
     320                $reply_url = apply_filters( 'bbp_new_reply_redirect_to', $reply_url, $count_hidden, $redirect_to );
    312321
    313322                /** Successful Save *******************************************/
    314323
    315324                // Redirect back to new reply
    316                 wp_redirect( $reply_url );
     325                wp_safe_redirect( $reply_url );
    317326
    318327                // For good measure
     
    355364 *                    id, anonymous data, reply author and bool true (for edit)
    356365 * @uses bbp_get_reply_url() To get the paginated url to the reply
    357  * @uses wp_redirect() To redirect to the reply url
     366 * @uses wp_safe_redirect() To redirect to the reply url
    358367 * @uses bbPress::errors::get_error_message() To get the {@link WP_Error} error
    359368 *                                             message
     
    525534                do_action( 'bbp_edit_reply_post_extras', $reply_id );
    526535
     536                /** Redirect **************************************************/
     537
     538                // Redirect to
     539                $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
     540
     541                // View all?
     542                $count_hidden = (bool) ( !empty( $_GET['view'] ) && ( 'all' == $_GET['view'] ) );
     543
     544                // Get the reply URL
     545                $reply_url = bbp_get_reply_url( $reply_id, $count_hidden, $redirect_to );
     546
     547                // Add view all?
     548                if ( !empty( $count_hidden ) )
     549                    $reply_url = add_query_arg( array( 'view' => 'all' ), $reply_url );
     550
     551                // Allow to be filtered
     552                $reply_url = apply_filters( 'bbp_edit_reply_redirect_to', $reply_url, $count_hidden, $redirect_to );
     553
    527554                /** Successful Edit *******************************************/
    528555
    529556                // Redirect back to new reply
    530                 wp_redirect( bbp_get_reply_url( $reply_id ) );
     557                wp_safe_redirect( $reply_url );
    531558
    532559                // For good measure
  • branches/plugin/bbp-includes/bbp-reply-template.php

    r3243 r3265  
    141141        // If pretty permalinks are enabled, make our pagination pretty
    142142        if ( $wp_rewrite->using_permalinks() )
    143             $base = user_trailingslashit( trailingslashit( get_permalink( bbp_get_topic_id() ) ) . 'page/%#%/' );
     143               
     144            // Page or single
     145            if ( is_page() || is_single() )
     146                $base = user_trailingslashit( trailingslashit( get_permalink() ) . 'page/%#%/' );
     147
     148            // Topic
     149            else
     150                $base = user_trailingslashit( trailingslashit( get_permalink( bbp_get_topic_id() ) ) . 'page/%#%/' );
     151
    144152        else
    145153            $base = add_query_arg( 'paged', '%#%' );
     
    340348     *                            automatically set to true. To override
    341349     *                            this, set $count_hidden = (int) -1
     350     * @param $string $redirect_to Optional. Pass a redirect value for use with
     351     *                              shortcodes and other fun things.
    342352     * @uses bbp_get_reply_id() To get the reply id
    343353     * @uses bbp_get_reply_topic_id() To get the reply topic id
     
    352362     * @return string Link to reply relative to paginated topic
    353363     */
    354     function bbp_get_reply_url( $reply_id = 0, $count_hidden = false ) {
     364    function bbp_get_reply_url( $reply_id = 0, $count_hidden = false, $redirect_to = '' ) {
    355365        global $bbp, $wp_rewrite;
    356366
    357367        // Set needed variables
    358         $reply_id       = bbp_get_reply_id       ( $reply_id );
    359         $topic_id       = bbp_get_reply_topic_id ( $reply_id );
    360         $topic_url      = bbp_get_topic_permalink( $topic_id );
    361         $reply_position = bbp_get_reply_position ( $reply_id );
     368        $reply_id       = bbp_get_reply_id       ( $reply_id               );
     369        $topic_id       = bbp_get_reply_topic_id ( $reply_id               );
     370        $topic_url      = bbp_get_topic_permalink( $topic_id, $redirect_to );
     371        $reply_position = bbp_get_reply_position ( $reply_id               );
    362372
    363373        // Check if in query with pagination
  • branches/plugin/bbp-includes/bbp-topic-functions.php

    r3243 r3265  
    4141 * @uses bbp_unstick_topic() To unstick the topic
    4242 * @uses bbp_get_topic_permalink() To get the topic permalink
    43  * @uses wp_redirect() To redirect to the topic link
     43 * @uses wp_safe_redirect() To redirect to the topic link
    4444 * @uses bbPress::errors::get_error_messages() To get the {@link WP_Error} error
    4545 *                                              messages
     
    240240                /** Redirect **************************************************/
    241241
    242                 $topic_url = bbp_get_topic_permalink( $topic_id );
    243 
    244                 if ( $bbp->trash_status_id == $topic_data['post_status'] )
     242                // Redirect to
     243                $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
     244
     245                // View all?
     246                $count_hidden = (bool) ( !empty( $_GET['view'] ) && ( 'all' == $_GET['view'] ) || ( $topic_data['post_status'] == $bbp->trash_status_id ) );
     247
     248                // Get the topic URL
     249                $topic_url = bbp_get_topic_permalink( $topic_id, $redirect_to );
     250
     251                // Add view all?
     252                if ( !empty( $count_hidden ) )
    245253                    $topic_url = add_query_arg( array( 'view' => 'all' ), $topic_url );
    246254
    247                 $topic_url = apply_filters( 'bbp_new_topic_redirect_to', $topic_url );
     255                // Allow to be filtered
     256                $topic_url = apply_filters( 'bbp_new_topic_redirect_to', $topic_url, $count_hidden, $redirect_to );
    248257
    249258                /** Successful Save *******************************************/
    250259
    251260                // Redirect back to new topic
    252                 wp_redirect( $topic_url );
     261                wp_safe_redirect( $topic_url );
    253262
    254263                // For good measure
     
    294303 *                                 to another
    295304 * @uses bbp_get_topic_permalink() To get the topic permalink
    296  * @uses wp_redirect() To redirect to the topic link
     305 * @uses wp_safe_redirect() To redirect to the topic link
    297306 * @uses bbPress::errors::get_error_messages() To get the {@link WP_Error} error
    298307 *                                              messages
     
    504513                do_action( 'bbp_edit_topic_post_extras', $topic_id );
    505514
     515                /** Redirect **************************************************/
     516
     517                // Redirect to
     518                $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
     519
     520                // View all?
     521                $count_hidden = (bool) ( !empty( $_GET['view'] ) && ( 'all' == $_GET['view'] ) );
     522
     523                // Get the topic URL
     524                $topic_url = bbp_get_topic_permalink( $topic_id, $redirect_to );
     525
     526                // Add view all?
     527                if ( !empty( $count_hidden ) )
     528                    $topic_url = add_query_arg( array( 'view' => 'all' ), $topic_url );
     529
     530                // Allow to be filtered
     531                $topic_url = apply_filters( 'bbp_edit_topic_redirect_to', $topic_url, $count_hidden, $redirect_to );
     532
    506533                /** Successful Edit *******************************************/
    507534
    508535                // Redirect back to new topic
    509                 wp_redirect( bbp_get_topic_permalink( $topic_id ) );
     536                wp_safe_redirect( $topic_url );
    510537
    511538                // For good measure
  • branches/plugin/bbp-includes/bbp-topic-template.php

    r3254 r3265  
    422422     *
    423423     * @param int $topic_id Optional. Topic id
     424     * @param $string $redirect_to Optional. Pass a redirect value for use with
     425     *                              shortcodes and other fun things.
    424426     * @uses bbp_get_topic_id() To get the topic id
    425427     * @uses get_permalink() To get the topic permalink
     428     * @uses sanitize_url() To clean the redirect_to url
    426429     * @uses apply_filters() Calls 'bbp_get_topic_permalink' with the link
    427430     *                        and topic id
    428431     * @return string Permanent link to topic
    429432     */
    430     function bbp_get_topic_permalink( $topic_id = 0 ) {
     433    function bbp_get_topic_permalink( $topic_id = 0, $redirect_to = '' ) {
    431434        $topic_id = bbp_get_topic_id( $topic_id );
    432435
    433         return apply_filters( 'bbp_get_topic_permalink', get_permalink( $topic_id ), $topic_id );
     436        // Use the redirect address
     437        if ( !empty( $redirect_to ) )
     438            $topic_permalink = sanitize_url( $redirect_to );
     439
     440        // Use the topic permalink
     441        else
     442            $topic_permalink = get_permalink( $topic_id );
     443
     444        return apply_filters( 'bbp_get_topic_permalink', $topic_permalink, $topic_id );
    434445    }
    435446
  • branches/plugin/bbpress.php

    r3249 r3265  
    240240    var $tab_index;
    241241
     242    /** Theme Compat **********************************************************/
     243
     244    /**
     245     * @var string Theme to use for theme compatibility
     246     */
     247    var $theme_compat = '';
     248
     249    /**
     250     * @var bool If we are currently in theme compatibility
     251     */
     252    var $in_theme_compat = false;
     253
    242254    /** Functions *************************************************************/
    243255
     
    425437        // Generate rewrite rules
    426438        add_action( 'bbp_generate_rewrite_rules',   array( $this, 'generate_rewrite_rules'   ), 10 );
    427 
    428         // Check theme compatability
    429         add_action( 'bbp_setup_theme_compat',       array( $this, 'theme_compat'             ), 10 );
    430439    }
    431440
     
    889898        return $wp_rewrite;
    890899    }
    891 
    892     /**
    893      * If not using a bbPress compatable theme, enqueue some basic styling and js
    894      *
    895      * @since bbPress (r3029)
    896      *
    897      * @global bbPress $bbp
    898      * @uses bbp_set_theme_compat() Set the compatable theme to bbp-twentyten
    899      * @uses current_theme_supports() Check bbPress theme support
    900      * @uses wp_enqueue_style() Enqueue the bbp-twentyten default CSS
    901      * @uses wp_enqueue_script() Enqueue the bbp-twentyten default topic JS
    902      */
    903     function theme_compat() {
    904         global $bbp;
    905 
    906         // Check if current theme supports bbPress
    907         if ( !current_theme_supports( 'bbpress' ) ) {
    908 
    909             // Set the compat_theme global for help with loading template parts
    910             bbp_set_theme_compat( $bbp->themes_dir . '/bbp-twentyten' );
    911 
    912             /** Default CSS ***************************************************/
    913 
    914             // Do not enqueue CSS in admin
    915             if ( !is_admin() ) {
    916 
    917                 // Right to left
    918                 if ( is_rtl() ) {
    919                     wp_enqueue_style( 'bbpress-style', $bbp->themes_url . '/bbp-twentyten/css/bbpress-rtl.css' );
    920 
    921                 // Left to right
    922                 } else {
    923                     wp_enqueue_style( 'bbpress-style', $bbp->themes_url . '/bbp-twentyten/css/bbpress.css' );
    924                 }
    925             }
    926         }
    927     }
    928900}
    929901
Note: See TracChangeset for help on using the changeset viewer.