Use constant instead of DB option for setting autosave_interval. Props mdawaffe. fixes #6075

git-svn-id: http://svn.automattic.com/wordpress/trunk@7165 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-06 06:07:53 +00:00
parent 607ef8887d
commit feb0644005
4 changed files with 13 additions and 13 deletions

View File

@ -1,5 +1,8 @@
<?php
if ( !defined( 'AUTOSAVE_INTERVAL' ) )
define( 'AUTOSAVE_INTERVAL', 60 );
require_once(ABSPATH . 'wp-admin/includes/bookmark.php');
require_once(ABSPATH . 'wp-admin/includes/comment.php');
require_once(ABSPATH . 'wp-admin/includes/file.php');

View File

@ -18,7 +18,7 @@ function edit_post() {
$post =& get_post( $post_ID );
$now = time();
$then = strtotime($post->post_date_gmt . ' +0000');
$delta = get_option( 'autosave_interval' ) / 2;
$delta = AUTOSAVE_INTERVAL / 2;
if ( ($now - $then) < $delta )
return $post_ID;
}
@ -654,7 +654,7 @@ function wp_check_post_lock( $post_id ) {
$lock = get_post_meta( $post->ID, '_edit_lock', true );
$last = get_post_meta( $post->ID, '_edit_last', true );
$time_window = apply_filters( 'wp_check_post_lock_window', get_option( 'autosave_interval' ) * 2 );
$time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 );
if ( $lock && $lock > time() - $time_window && $last != $current_user->ID )
return $last;

View File

@ -249,10 +249,9 @@ function populate_options() {
add_option('thumbnail_crop', 1);
add_option('medium_size_w', 300);
add_option('medium_size_h', 300);
add_option('autosave_interval', 60);
// Delete unused options
$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');
$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');
foreach ($unusedoptions as $option) :
delete_option($option);
endforeach;

View File

@ -48,15 +48,6 @@ class WP_Scripts {
) );
$this->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080221' . mt_rand());
if ( ! $autosave_interval = get_option( 'autosave_interval' ) )
$autosave_interval = 60;
$this->localize( 'autosave', 'autosaveL10n', array(
'autosaveInterval' => $autosave_interval,
'previewPageText' => __('View this Page'),
'previewPostText' => __('View this Post'),
'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
'savingText' => __('Saving Draft&#8230;')
) );
$this->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306');
$this->localize( 'wp-ajax', 'WPAjaxL10n', array(
@ -487,6 +478,13 @@ function wp_prototype_before_jquery( $js_array ) {
// These localizations require information that may not be loaded even by init
function wp_just_in_time_script_localization() {
wp_localize_script( 'tiny_mce', 'wpTinyMCEConfig', array( 'defaultEditor' => wp_default_editor() ) );
wp_localize_script( 'autosave', 'autosaveL10n', array(
'autosaveInterval' => AUTOSAVE_INTERVAL,
'previewPageText' => __('View this Page'),
'previewPostText' => __('View this Post'),
'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
'savingText' => __('Saving Draft&#8230;')
) );
}
add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );