WordPress theme-added "auto update" prompt instance

Source: Internet
Author: User
Tags json

Step 2: Add the remote detection version function for the topic

Decompress the downloaded file, put the theme-updates folder in the topic root directory, and open the topic functions. Php file.

Add:

The code is as follows: Copy code

// Initialize the update checker.
Require 'theme-updates/theme-update-checker.php ';
$ Example_update_checker = new ThemeUpdateChecker (
'Example-theme ', // Theme folder name, AKA

"Slug ".
'Http: // your URL/info. Json' // URL of the metadata file.
);

Where:

The name of the example-theme topic is not necessarily the same as the topic name.

Http: // the storage location of the info. json file downloaded from your website/files/example-theme-updates/info. json.

You can create a folder in the space and modify the corresponding link address.

Step 3: modify remote data update

Edit the info. json file

The code is as follows: Copy code

"Version": "2.0 ",
"Details_url": "http: // your URL/files/example-theme-updates/details.html ",
"Download_url": "http: // your URL/files/example-theme-updates/example-theme.zip"

Where:

Version number of the topic in line 1

Link to the 3rd update instruction file

Download link for Line 1 topic

Modify the link to point to the location where the file is stored.

When the version number of the topic used is lower than the version number in the info. json file, the background will prompt an update and you can implement the same theme as the official website.

One-click upgrade. The prompt function is only applicable to topics in use. Disabled topics are invalid.

 

The above method is successfully tested on the HotNews topic, but it is not added to the published topic, because it may take several months or even a year or a half to upgrade.

Level 1 theme, I feel this function is a little chicken.


In addition, automatic remote download not only increases the stress on the host space of the topic publisher, but may also be exploited by malicious users .....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.