Skip to content

Commit 597aab7

Browse files
committed
Change and option-ize update check frequency
1 parent 6b99ab3 commit 597aab7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

functions.php

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
define( 'FICTIONEER_AUTHOR_KEYWORD_SEARCH_LIMIT', 100 );
8080
}
8181

82+
// Integer: Update check timeout
83+
if ( ! defined( 'FICTIONEER_UPDATE_CHECK_TIMEOUT' ) ) {
84+
define( 'FICTIONEER_UPDATE_CHECK_TIMEOUT', 3600 );
85+
}
86+
8287
/*
8388
* Booleans
8489
*/

includes/functions/_theme_setup.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,8 @@ function fictioneer_check_for_updates() {
912912
$latest_version = get_option( 'fictioneer_latest_version', FICTIONEER_RELEASE_TAG );
913913
$is_updates_page = $pagenow == 'update-core.php';
914914

915-
// Only call API every 30 minutes, otherwise check database
916-
if ( ! empty( $latest_version ) && time() < $last_check + 1800 && ! $is_updates_page ) {
915+
// Only call API every n seconds, otherwise check database
916+
if ( ! empty( $latest_version ) && time() < $last_check + FICTIONEER_UPDATE_CHECK_TIMEOUT && ! $is_updates_page ) {
917917
return version_compare( $latest_version, FICTIONEER_RELEASE_TAG, '>' );
918918
}
919919

@@ -961,8 +961,8 @@ function fictioneer_admin_update_notice() {
961961
// Abort if...
962962
if ( ! current_user_can( 'manage_options' ) ) return;
963963

964-
// Show only once every 30 minutes
965-
if ( $last_notice + 1800 > time() && ! $is_updates_page ) return;
964+
// Show only once every n seconds
965+
if ( $last_notice + FICTIONEER_UPDATE_CHECK_TIMEOUT > time() && ! $is_updates_page ) return;
966966

967967
// Update?
968968
if ( ! fictioneer_check_for_updates() ) return;

0 commit comments

Comments
 (0)