Skip to:
Content

bbPress.org

Changeset 3589


Ignore:
Timestamp:
11/04/2011 08:36:45 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Force comment_status to 'closed' for forums, topics, and replies. Fixes #1676.

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

Legend:

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

    r3585 r3589  
    931931            // Reset post
    932932            bbp_theme_compat_reset_post( array(
    933                 'post_title' => esc_attr( bbp_get_displayed_user_field( 'display_name' ) )
     933                'post_title'     => esc_attr( bbp_get_displayed_user_field( 'display_name' ) ),
     934                'comment_status' => 'closed'
    934935            ) );
    935936
     
    941942            // Reset post
    942943            bbp_theme_compat_reset_post( array(
    943                 'ID'           => bbp_get_forum_id(),
    944                 'post_title'   => bbp_get_forum_title(),
     944                'ID'             => bbp_get_forum_id(),
     945                'post_title'     => bbp_get_forum_title(),
    945946                //'post_author'  => bbp_get_forum_author_id(),
    946                 'post_date'    => 0,
    947                 'post_content' => get_post_field( 'post_content', bbp_get_forum_id() ),
    948                 'post_type'    => bbp_get_forum_post_type(),
    949                 'post_status'  => bbp_get_forum_status(),
    950                 'is_single'    => true
     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                'comment_status' => 'closed'
    951953            ) );
    952954
     
    956958            // Reset post
    957959            bbp_theme_compat_reset_post( array(
    958                 'ID'           => 0,
    959                 'post_title'   => bbp_get_forum_archive_title(),
    960                 'post_author'  => 0,
    961                 'post_date'    => 0,
    962                 'post_content' => '',
    963                 'post_type'    => bbp_get_forum_post_type(),
    964                 'post_status'  => bbp_get_public_status_id(),
    965                 'is_archive'   => true
     960                'ID'             => 0,
     961                'post_title'     => bbp_get_forum_archive_title(),
     962                'post_author'    => 0,
     963                'post_date'      => 0,
     964                'post_content'   => '',
     965                'post_type'      => bbp_get_forum_post_type(),
     966                'post_status'    => bbp_get_public_status_id(),
     967                'is_archive'     => true,
     968                'comment_status' => 'closed'
    966969            ) );
    967970
     
    973976            // Reset post
    974977            bbp_theme_compat_reset_post( array(
    975                 'ID'           => 0,
    976                 'post_title'   => bbp_get_topic_archive_title(),
    977                 'post_author'  => 0,
    978                 'post_date'    => 0,
    979                 'post_content' => '',
    980                 'post_type'    => bbp_get_topic_post_type(),
    981                 'post_status'  => bbp_get_public_status_id(),
    982                 'is_archive'   => true
     978                'ID'             => 0,
     979                'post_title'     => bbp_get_topic_archive_title(),
     980                'post_author'    => 0,
     981                'post_date'      => 0,
     982                'post_content'   => '',
     983                'post_type'      => bbp_get_topic_post_type(),
     984                'post_status'    => bbp_get_public_status_id(),
     985                'is_archive'     => true,
     986                'comment_status' => 'closed'
    983987            ) );
    984988
     
    988992            // Reset post
    989993            bbp_theme_compat_reset_post( array(
    990                 'ID'           => bbp_get_topic_id(),
    991                 'post_title'   => bbp_get_topic_title(),
    992                 'post_author'  => bbp_get_topic_author_id(),
    993                 'post_date'    => 0,
    994                 'post_content' => get_post_field( 'post_content', bbp_get_topic_id() ),
    995                 'post_type'    => bbp_get_topic_post_type(),
    996                 'post_status'  => bbp_get_topic_status(),
    997                 'is_single'    => true
     994                'ID'             => bbp_get_topic_id(),
     995                'post_title'     => bbp_get_topic_title(),
     996                'post_author'    => bbp_get_topic_author_id(),
     997                'post_date'      => 0,
     998                'post_content'   => get_post_field( 'post_content', bbp_get_topic_id() ),
     999                'post_type'      => bbp_get_topic_post_type(),
     1000                'post_status'    => bbp_get_topic_status(),
     1001                'is_single'      => true,
     1002                'comment_status' => 'closed'
    9981003            ) );
    9991004
     
    10051010            // Reset post
    10061011            bbp_theme_compat_reset_post( array(
    1007                 'ID'           => 0,
    1008                 'post_title'   => __( 'Replies', 'bbpress' ),
    1009                 'post_author'  => 0,
    1010                 'post_date'    => 0,
    1011                 'post_content' => '',
    1012                 'post_type'    => bbp_get_reply_post_type(),
    1013                 'post_status'  => bbp_get_public_status_id()
     1012                'ID'             => 0,
     1013                'post_title'     => __( 'Replies', 'bbpress' ),
     1014                'post_author'    => 0,
     1015                'post_date'      => 0,
     1016                'post_content'   => '',
     1017                'post_type'      => bbp_get_reply_post_type(),
     1018                'post_status'    => bbp_get_public_status_id(),
     1019                'comment_status' => 'closed'
    10141020            ) );
    10151021
     
    10191025            // Reset post
    10201026            bbp_theme_compat_reset_post( array(
    1021                 'ID'           => bbp_get_reply_id(),
    1022                 'post_title'   => bbp_get_reply_title(),
    1023                 'post_author'  => bbp_get_reply_author_id(),
    1024                 'post_date'    => 0,
    1025                 'post_content' => get_post_field( 'post_content', bbp_get_reply_id() ),
    1026                 'post_type'    => bbp_get_reply_post_type(),
    1027                 'post_status'  => bbp_get_reply_status()
     1027                'ID'             => bbp_get_reply_id(),
     1028                'post_title'     => bbp_get_reply_title(),
     1029                'post_author'    => bbp_get_reply_author_id(),
     1030                'post_date'      => 0,
     1031                'post_content'   => get_post_field( 'post_content', bbp_get_reply_id() ),
     1032                'post_type'      => bbp_get_reply_post_type(),
     1033                'post_status'    => bbp_get_reply_status(),
     1034                'comment_status' => 'closed'
    10281035            ) );
    10291036
     
    10341041            // Reset post
    10351042            bbp_theme_compat_reset_post( array(
    1036                 'ID'           => 0,
    1037                 'post_title'   => bbp_get_view_title(),
    1038                 'post_author'  => 0,
    1039                 'post_date'    => 0,
    1040                 'post_content' => '',
    1041                 'post_type'    => '',
    1042                 'post_status'  => bbp_get_public_status_id()
     1043                'ID'             => 0,
     1044                'post_title'     => bbp_get_view_title(),
     1045                'post_author'    => 0,
     1046                'post_date'      => 0,
     1047                'post_content'   => '',
     1048                'post_type'      => '',
     1049                'post_status'    => bbp_get_public_status_id(),
     1050                'comment_status' => 'closed'
    10431051            ) );
    10441052
     
    15561564
    15571565/**
     1566 * Force comments_status to 'closed' for bbPress post types
     1567 *
     1568 * @since bbPress (r3589)
     1569 *
     1570 * @param bool $open True if open, false if closed
     1571 * @param int $post_id ID of the post to check
     1572 * @return bool True if open, false if closed
     1573 */
     1574function bbp_force_comment_status( $open, $post_id = 0 ) {
     1575
     1576    // Get the post type of the post ID
     1577    $post_type = get_post_type( $post_id );
     1578
     1579    // Default return value is what is passed in $open
     1580    $retval = $open;
     1581
     1582    // Only force for bbPress post types
     1583    switch ( $post_type ) {
     1584        case bbp_get_forum_post_type() :
     1585        case bbp_get_topic_post_type() :
     1586        case bbp_get_reply_post_type() :
     1587            $retval = false;
     1588            break;
     1589    }
     1590
     1591    // Allow override of the override
     1592    return apply_filters( 'bbp_force_comment_status', $retval, $open, $post_id, $post_type );
     1593}
     1594
     1595/**
    15581596 * Add checks for view page, user page, user edit, topic edit and reply edit
    15591597 * pages.
  • branches/plugin/bbp-includes/bbp-core-hooks.php

    r3552 r3589  
    389389add_filter( 'bbp_get_reply_author_link',    'bbp_suppress_private_author_link', 10, 2 );
    390390
     391// Force comments_status on bbPress post types
     392add_filter( 'comments_open', 'bbp_force_comment_status' );
     393
    391394/**
    392395 * Add filters to anonymous post author data
  • branches/plugin/bbp-includes/bbp-forum-functions.php

    r3516 r3589  
    3131    // Forum
    3232    $default_forum = array(
    33         'post_parent'   => 0, // forum ID
    34         'post_status'   => bbp_get_public_status_id(),
    35         'post_type'     => bbp_get_forum_post_type(),
    36         'post_author'   => 0,
    37         'post_password' => '',
    38         'post_content'  => '',
    39         'post_title'    => '',
    40         'menu_order'    => 0,
     33        'post_parent'    => 0, // forum ID
     34        'post_status'    => bbp_get_public_status_id(),
     35        'post_type'      => bbp_get_forum_post_type(),
     36        'post_author'    => 0,
     37        'post_password'  => '',
     38        'post_content'   => '',
     39        'post_title'     => '',
     40        'menu_order'     => 0,
     41        'comment_status' => 'closed'
    4142    );
    4243
  • branches/plugin/bbp-includes/bbp-reply-functions.php

    r3581 r3589  
    3131    // Forum
    3232    $default_reply = array(
    33         'post_parent'   => 0, // topic ID
    34         'post_status'   => bbp_get_public_status_id(),
    35         'post_type'     => bbp_get_reply_post_type(),
    36         'post_author'   => 0,
    37         'post_password' => '',
    38         'post_content'  => '',
    39         'post_title'    => '',
    40         'menu_order'    => 0,
     33        'post_parent'    => 0, // topic ID
     34        'post_status'    => bbp_get_public_status_id(),
     35        'post_type'      => bbp_get_reply_post_type(),
     36        'post_author'    => 0,
     37        'post_password'  => '',
     38        'post_content'   => '',
     39        'post_title'     => '',
     40        'menu_order'     => 0,
     41        'comment_status' => 'closed'
    4142    );
    4243
     
    232233        // Add the content of the form to $post as an array
    233234        $reply_data = array(
    234             'post_author'  => $reply_author,
    235             'post_title'   => $reply_title,
    236             'post_content' => $reply_content,
    237             'post_parent'  => $topic_id,
    238             'post_status'  => $post_status,
    239             'post_type'    => bbp_get_reply_post_type()
     235            'post_author'    => $reply_author,
     236            'post_title'     => $reply_title,
     237            'post_content'   => $reply_content,
     238            'post_parent'    => $topic_id,
     239            'post_status'    => $post_status,
     240            'post_type'      => bbp_get_reply_post_type(),
     241            'comment_status' => 'closed'
    240242        );
    241243
  • branches/plugin/bbp-includes/bbp-topic-functions.php

    r3581 r3589  
    3131    // Forum
    3232    $default_topic = array(
    33         'post_parent'   => 0, // forum ID
    34         'post_status'   => bbp_get_public_status_id(),
    35         'post_type'     => bbp_get_topic_post_type(),
    36         'post_author'   => 0,
    37         'post_password' => '',
    38         'post_content'  => '',
    39         'post_title'    => '',
    40         'menu_order'    => 0,
     33        'post_parent'    => 0, // forum ID
     34        'post_status'    => bbp_get_public_status_id(),
     35        'post_type'      => bbp_get_topic_post_type(),
     36        'post_author'    => 0,
     37        'post_password'  => '',
     38        'post_content'   => '',
     39        'post_title'     => '',
     40        'comment_status' => 'closed',
     41        'menu_order'     => 0,
    4142    );
    4243
     
    267268        // Add the content of the form to $post as an array
    268269        $topic_data = array(
    269             'post_author'  => $topic_author,
    270             'post_title'   => $topic_title,
    271             'post_content' => $topic_content,
    272             'post_parent'  => $forum_id,
    273             'tax_input'    => $terms,
    274             'post_status'  => $post_status,
    275             'post_type'    => bbp_get_topic_post_type()
     270            'post_author'    => $topic_author,
     271            'post_title'     => $topic_title,
     272            'post_content'   => $topic_content,
     273            'post_parent'    => $forum_id,
     274            'post_status'    => $post_status,
     275            'post_type'      => bbp_get_topic_post_type(),
     276            'tax_input'      => $terms,
     277            'comment_status' => 'closed'
    276278        );
    277279
Note: See TracChangeset for help on using the changeset viewer.