Skip to:
Content

bbPress.org


Ignore:
Timestamp:
10/31/2011 12:38:06 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Introduce shortcode, rewrite rule, template file, and theme-compatibility code for front-end Forum editing. See #1669.

File:
1 edited

Legend:

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

    r3550 r3566  
    516516
    517517/**
     518 * Get the forum edit template
     519 *
     520 * @since bbPress (r3566)
     521 *
     522 * @uses bbp_get_topic_post_type()
     523 * @uses apply_filters()
     524 *
     525 * @return array
     526 */
     527function bbp_get_forum_edit_template() {
     528
     529    $post_type = bbp_get_forum_post_type();
     530    $templates = array(
     531
     532        // Single Topic Edit
     533        'single-'         . $post_type . '-edit.php',
     534        'bbpress/single-' . $post_type . '-edit.php',
     535        'forums/single-'  . $post_type . '-edit.php',
     536
     537        // Single Action Edit Topic
     538        'single-action-edit-'         . $post_type . '.php',
     539        'bbpress/single-action-edit-' . $post_type . '.php',
     540        'forums/single-action-edit-'  . $post_type . '.php',
     541
     542        // Single Action Edit
     543        'single-action-edit.php',
     544        'bbpress/single-action-edit.php',
     545        'forums/single-action-edit.php',
     546
     547        // Action Edit
     548        'action-edit.php',
     549        'bbpress/action-edit.php',
     550        'forums/action-edit.php',
     551
     552        // Single Topic
     553        'single-'         . $post_type . '.php',
     554        'forums/single-'  . $post_type . '.php',
     555        'bbpress/single-' . $post_type . '.php',
     556    );
     557
     558    $templates = apply_filters( 'bbp_get_forum_edit_template', $templates );
     559    $templates = bbp_set_theme_compat_templates( $templates );
     560
     561    $template  = locate_template( $templates, false, false );
     562    $template  = bbp_set_theme_compat_template( $template );
     563
     564    return $template;
     565}
     566
     567/**
    518568 * Get the topic edit template
    519569 *
     
    809859 * @uses bbp_is_single_view() To check if page is single view
    810860 * @uses bbp_get_single_view_template() To get view template
     861 * @uses bbp_is_forum_edit() To check if page is forum edit
     862 * @uses bbp_get_forum_edit_template() To get forum edit template
    811863 * @uses bbp_is_topic_merge() To check if page is topic merge
    812864 * @uses bbp_get_topic_merge_template() To get topic merge template
     
    835887        elseif ( bbp_is_single_view()      && ( $new_template = bbp_get_single_view_template()      ) ) :
    836888
     889        // Topic edit
     890        elseif ( bbp_is_forum_edit()       && ( $new_template = bbp_get_forum_edit_template()       ) ) :
     891
    837892        // Topic merge
    838893        elseif ( bbp_is_topic_merge()      && ( $new_template = bbp_get_topic_merge_template()      ) ) :
     
    881936
    882937        /** Forums ************************************************************/
     938
     939        // Single forum edit
     940        } elseif ( bbp_is_forum_edit() ) {
     941
     942            // Reset post
     943            bbp_theme_compat_reset_post( array(
     944                'ID'           => bbp_get_forum_id(),
     945                'post_title'   => bbp_get_forum_title(),
     946                //'post_author'  => bbp_get_forum_author_id(),
     947                'post_date'    => 0,
     948                'post_content' => get_post_field( 'post_content', bbp_get_forum_id() ),
     949                'post_type'    => bbp_get_forum_post_type(),
     950                'post_status'  => bbp_get_forum_status(),
     951                'is_single'    => true
     952            ) );
    883953
    884954        // Forum archive
     
    10911161
    10921162        /** Forums ************************************************************/
     1163
     1164        // Reply Edit
     1165        } elseif ( bbp_is_forum_edit() ) {
     1166            $new_content = $bbp->shortcodes->display_forum_form();
    10931167
    10941168        // Forum archive
     
    16351709    } elseif ( !empty( $is_edit ) ) {
    16361710
    1637         // We are editing a forum
    1638         if ( $posts_query->get( 'post_type' ) == bbp_get_forum_post_type() ) {
    1639             $posts_query->bbp_is_forum_edit = true;
    1640 
    1641         // We are editing a topic
    1642         } elseif ( $posts_query->get( 'post_type' ) == bbp_get_topic_post_type() ) {
    1643             $posts_query->bbp_is_topic_edit = true;
    1644 
    1645         // We are editing a reply
    1646         } elseif ( $posts_query->get( 'post_type' ) == bbp_get_reply_post_type() ) {
    1647             $posts_query->bbp_is_reply_edit = true;
     1711        // Get the post type from the main query loop
     1712        $post_type = $posts_query->get( 'post_type' );
     1713       
     1714        // Check which post_type we are editing, if any
     1715        if ( !empty( $post_type ) ) {
     1716            switch( $post_type ) {
     1717
     1718                // We are editing a forum
     1719                case bbp_get_forum_post_type() :
     1720                    $posts_query->bbp_is_forum_edit = true;
     1721                    break;
     1722
     1723                // We are editing a topic
     1724                case bbp_get_topic_post_type() :
     1725                    $posts_query->bbp_is_topic_edit = true;
     1726                    break;
     1727
     1728                // We are editing a reply
     1729                case bbp_get_reply_post_type() :
     1730                    $posts_query->bbp_is_reply_edit = true;
     1731                    break;
     1732            }
    16481733
    16491734        // We are editing a topic tag
Note: See TracChangeset for help on using the changeset viewer.