WordPress.org

Make WordPress Core

Changeset 8892


Ignore:
Timestamp:
09/15/08 16:26:37 (6 years ago)
Author:
ryan
Message:

Close comments for old posts. see #7741

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/schema.php

    r8740 r8892  
    262262    add_option('large_size_w', 1024); 
    263263    add_option('large_size_h', 1024); 
    264  
    265     // 2.7 
    266     add_option('large_size_w', 1024); 
    267     add_option('large_size_h', 1024); 
    268264    add_option('image_default_link_type', 'file'); 
    269265    add_option('image_default_size', ''); 
    270266    add_option('image_default_align', ''); 
    271      
     267    add_option('close_comments_for_old_posts', 0); 
     268    add_option('close_comments_days_old', 14); 
     269 
    272270    // Delete unused options 
    273271    $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins'); 
  • trunk/wp-admin/options-discussion.php

    r8855 r8892  
    3636<input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> /> 
    3737<?php _e('Allow people to post comments on the article') ?></label> 
     38<br /> 
     39<label for="close_comments_for_old_posts"> 
     40<input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', get_option('close_comments_for_old_posts')); ?> /> 
     41<?php _e('Close comments on articles older than') ?></label> <?php printf(__('%s days'), '<input name="close_comments_days_old" type="text" id="close_comments_days_old" value="' . attribute_escape(get_option('close_comments_days_old')) . '" size="3" />') ?> 
    3842<br /> 
    3943<small><em><?php echo '(' . __('These settings may be overridden for individual articles.') . ')'; ?></em></small> 
  • trunk/wp-admin/options.php

    r8818 r8892  
    2424$whitelist_options = array( 
    2525    'general' => array('blogname', 'blogdescription', 'admin_email', 'users_can_register', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'comment_registration', 'default_role'), 
    26     'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating' ), 
     26    'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'close_comments_for_old_posts', 'close_comments_days_old' ), 
    2727    'misc' => array( 'hack_file', 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path', 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'large_size_w', 'large_size_h' ), 
    2828    'privacy' => array( 'blog_public' ), 
  • trunk/wp-includes/comment.php

    r8833 r8892  
    14071407} 
    14081408 
     1409// 
     1410// Internal 
     1411// 
     1412 
     1413/** 
     1414 * Close comments on old posts on the fly, without any extra DB queries. 
     1415 * 
     1416 * @since 2.7 
     1417 * @package WordPress 
     1418 * @subpackage Internal 
     1419 */ 
     1420function _close_comments_for_old_posts( $posts ) { 
     1421    if ( !is_single() || !get_option('close_comments_for_old_posts') ) 
     1422        return $posts; 
     1423 
     1424    $days_old = (int) get_option('close_comments_days_old'); 
     1425    if ( !$days_old ) 
     1426        return $posts; 
     1427 
     1428    if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) { 
     1429        $posts[0]->comment_status = 'closed'; 
     1430        $posts[0]->ping_status = 'closed'; 
     1431    } 
     1432 
     1433    return $posts; 
     1434} 
     1435 
    14091436?> 
  • trunk/wp-includes/default-filters.php

    r8854 r8892  
    156156add_filter('option_tag_base', '_wp_filter_taxonomy_base'); 
    157157add_filter('option_category_base', '_wp_filter_taxonomy_base'); 
     158add_filter( 'the_posts', '_close_comments_for_old_posts' ); 
    158159 
    159160//Atom SSL support 
  • trunk/wp-includes/version.php

    r8691 r8892  
    1616 * @global int $wp_db_version 
    1717 */ 
    18 $wp_db_version = 8645; 
     18$wp_db_version = 8890; 
    1919 
    2020?> 
Note: See TracChangeset for help on using the changeset viewer.