Skip to:
Content

bbPress.org


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.

File:
1 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.
Note: See TracChangeset for help on using the changeset viewer.