使用php和json检查Interval的最新版本

I want that WordPress will display a notice when new version is available after checking on json file.. But problem is i want all this function only run on time interval like in every 2 days or 1 week ..don't want put extra burden server.

function myfun_notice() {
$my_theme = wp_get_theme();
$a=$my_theme->get( 'Version' );
// Read 14 characters starting from the 21st character
$section = file_get_contents('http://www.example.com/file.json', NULL, NULL, 16, 5);
if ($a !== $section){


        $return = '<div class="updated activation"><p><strong>';
        $my_theme = wp_get_theme();
        {
            $return .= sprintf( __( '%s New Version is available.', 'textdomain' ), $my_theme->get( 'Name' ) );
        }
        $return .= '</strong> <a href="' . home_url( '/' ) . '">' . __( 'Visit site', 'textdomain' ) . '</a></p>';

        $return .= '</p></div>';
        echo $return;
    }
}
add_action( 'admin_notices', 'textdomain_notice' );

There is another code i found here but doesn't seem to work. So any one have idea of code that could work ?

<?php
$interval=60; //minutes
set_time_limit(0);
while (true)
{
$now=time();
include("the_script.php");
sleep($interval*60-(time()-$now));
}
?>
  1. WordPress already shows when core update are available, by default. Are you trying to override the core behavior or just unaware it exists?

enter image description here

  1. As of WordPress 3.7 it will even automatically update the site for you.

  2. Even if you ran one request per minute you would not be "putting burden on the server".

If you want to control how automatic updates are handled by WordPress, see Configuring Automatic Background Updates in the Code. You can completely disable, if desired, but this is not recommended lest you run your site on code with known security vulnerabilities.