WordPress.org

Make WordPress Core

Ticket #27111: 27111.1.diff

File 27111.1.diff, 2.9 KB (added by obenland, 6 years ago)
  • src/wp-admin/options-discussion.php

     
    5050<br />
    5151<label for="default_comment_status">
    5252<input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> />
    53 <?php _e('Allow people to post comments on new articles'); ?></label>
     53<?php _e('Allow people to post comments on articles'); ?></label>
    5454<br />
    5555<p class="description"><?php echo '(' . __( 'These settings may be overridden for individual articles.' ) . ')'; ?></p>
    5656</fieldset></td>
  • src/wp-includes/comment.php

     
    23952395 * @return object
    23962396 */
    23972397function _close_comments_for_old_posts( $posts, $query ) {
    2398         if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) )
     2398        if ( empty( $posts ) || ! $query->is_singular() )
    23992399                return $posts;
    24002400
    2401         /**
    2402          * Filter the list of post types to automatically close comments for.
    2403          *
    2404          * @since 3.2.0
    2405          *
    2406          * @param array $post_types An array of registered post types. Default array with 'post'.
    2407          */
    2408         $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
    2409         if ( ! in_array( $posts[0]->post_type, $post_types ) )
    2410                 return $posts;
     2401        if ( 'closed' == get_option( 'default_comment_status' ) ) {
     2402                $posts[0]->comment_status = 'closed';
     2403                $posts[0]->ping_status    = 'closed';
     2404        }
     2405        elseif ( get_option( 'close_comments_for_old_posts' ) ) {
     2406                /**
     2407                 * Filter the list of post types to automatically close comments for.
     2408                 *
     2409                 * @since 3.2.0
     2410                 *
     2411                 * @param array $post_types An array of registered post types. Default array with 'post'.
     2412                 */
     2413                $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
     2414                if ( ! in_array( $posts[0]->post_type, $post_types ) )
     2415                        return $posts;
    24112416
    2412         $days_old = (int) get_option( 'close_comments_days_old' );
    2413         if ( ! $days_old )
    2414                 return $posts;
     2417                $days_old = (int) get_option( 'close_comments_days_old' );
     2418                if ( ! $days_old )
     2419                        return $posts;
    24152420
    2416         if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
    2417                 $posts[0]->comment_status = 'closed';
    2418                 $posts[0]->ping_status = 'closed';
     2421                if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
     2422                        $posts[0]->comment_status = 'closed';
     2423                        $posts[0]->ping_status    = 'closed';
     2424                }
    24192425        }
    24202426
    24212427        return $posts;
     
    24322438 * @return bool $open
    24332439 */
    24342440function _close_comments_for_old_post( $open, $post_id ) {
     2441        if ( 'closed' == get_option( 'default_comment_status' ) ) {
     2442                return false;
     2443        }
     2444
    24352445        if ( ! $open )
    24362446                return $open;
    24372447