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 .....