Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6058273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:34:53+00:00 2026-05-23T08:34:53+00:00

I am writing a script where it checks for an updated version from an

  • 0

I am writing a script where it checks for an updated version from an external server. I use this code in the config.php file to check for latest version.

$data = get_theme_data('http://externalhost.com/style.css');
$latest_version = $data['Version'];
define('LATEST_VERSION', $latest_version);

This is fine and I can fetch the latest version (get_theme_data is WordPress function) but the problem is that it will be executed on every single load which I do not want. I also do not want to only check when a form is submitted for example. Alternatively I was looking into some sort of method to cache the result or maybe check the version every set amount of hours? Is such thing possible and how?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:34:54+00:00Added an answer on May 23, 2026 at 8:34 am

    Here, gonna make it easy for you. Store the time you last checked for the update in a file.

    function checkForUpdate() {
        $file = file_get_contents('./check.cfg', true);
        if ($file === "") {
            $fp = fopen('./check.cfg', 'w+');
            fwrite($fp, time() + 86400);
            fclose($fp);
        }
        if ((int)$file > time()) {
            echo "Do not updatE";
        } else {
            echo "Update";
            $fp = fopen('./check.cfg', 'w+');
            fwrite($fp, time() + 86400);
            fclose($fp);
        }
    }
    

    You can obviously make this much more secure/efficient if you want to.

    Edit: This function will check for update once every day.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I suspect this is a very trivial question. I'm writing a PHP script to
I am writing some BASH shell script that will continuously check a file to
I am writing a script that checks if given domain is parked or not.
I'm writing a script to check RSS feeds on regular intervals and need to
I am writing a DB upgrade script that will check to see if an
I'm writing script in remote.ini The script looks like on 1:start:{ server some.irc.server server
I am writing a script for MS PowerShell. This script uses the Copy-Item command.
I am writing a script at the moment that will grab certain information from
I am the process of writing an update script, which pulls the latest version
Okay so I'm writing a SQL Server 2008 Stored Procedure (maintenance script). In doing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.