Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin name added #32

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/download.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// loop over all the versions for each theme and plugin
foreach ( $package['versions'] as $version ) {
// md5 timestamp of current and previous day and the file name
$tod_md5 = md5( $version['file_name'] . mktime( 0, 0, 0, date( "m" ), date( "d" ), date( "Y" ) ) );
$yes_md5 = md5( $version['file_name'] . mktime( 0, 0, 0, date( "m" ), date( "d" ) - 1, date( "Y" ) ) );
$tod_md5 = md5( $version['file_name'] . mktime( 0, 0, 0, date( "n" ), date( "j" ), date( "Y" ) ) );
$yes_md5 = md5( $version['file_name'] . mktime( 0, 0, 0, date( "n" ), date( "j" ) - 1, date( "Y" ) ) );
// test if the either of the md5 hashes match what was passed
if ( $_GET['key'] == $tod_md5 || $_GET['key'] == $yes_md5 ) {
$download = $update_folder . $version['file_name'];
Expand All @@ -29,4 +29,4 @@
}
}
}
?>
?>
1 change: 1 addition & 0 deletions api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
$data = new stdClass;

$data->slug = $args->slug;
$data->name = $latest_package['name'];
$data->version = $latest_package['version'];
$data->last_updated = $latest_package['date'];
$data->download_link = $latest_package['package'];
Expand Down
9 changes: 5 additions & 4 deletions api/packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'version' => '1.0', //Current version available
'date' => '2010-04-10', //Date version was released
//theme.zip is the same as file_name
'package' => 'http://url_to_your_site/download.php?key=' . md5('theme.zip' . mktime(0,0,0,date("m"),date("d"),date("Y"))),
'package' => 'http://url_to_your_site/download.php?key=' . md5('theme.zip' . mktime(0,0,0,date("n"),date("j"),date("Y"))),
//file_name is the name of the file in the update folder.
'file_name' => 'theme.zip', //File name of theme zip file
'author' => 'Author Name', //Author of theme
Expand All @@ -26,15 +26,16 @@
'versions' => array(
'1.0' => array( //Array name should be set to current version of update
'version' => '1.0', //Current version available
'name' => 'Plugin name', //Plugin name
'date' => '2010-04-10', //Date version was released
'author' => 'Author Name', //Author name - can be linked using html - <a href="http://link-to-site.com">Author Name</a>
'requires' => '2.8', // WP version required for plugin
'tested' => '3.0.1', // WP version tested with
'homepage' => 'http://your_plugin_website', // Site devoted to your plugin if available
'plugin_homepage' => 'http://your_plugin_website', // Site devoted to your plugin if available
'downloaded' => '1000', // Number of times downloaded
'external' => '', // Unused
//plugin.zip is the same as file_name
'package' => 'http://url_to_your_site/download.php?key=' . md5('plugin.zip' . mktime(0,0,0,date("m"),date("d"),date("Y"))),
'package' => 'http://url_to_your_site/download.php?key=' . md5('plugin.zip' . mktime(0,0,0,date("n"),date("j"),date("Y"))),
//file_name is the name of the file in the update folder.
'file_name' => 'plugin.zip',
'sections' => array(
Expand All @@ -55,4 +56,4 @@
'info' => array(
'url' => 'http://your_plugin_webiste' // Site devoted to your plugin if available
)
);
);
57 changes: 1 addition & 56 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,56 +1 @@
## Automatic Theme & Plugin Updater for Self-Hosted Themes/Plugins

**Support This Developer: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SE9ZVJUS324UC**

*Any amount is always appreciated*


## General Info

For themes and plugins that can't be submitted to official WordPress repository, ie ... commercial themes/plugins/, non-gpl licensed, written for one client.

### Folder structure
* api (Folder to upload to server where updates will be housed)
* .htaccess (set Options+Indexes to allow checking to work properly)
* index.php (holds code used to check request for new versions)
* packages.php (file containing all info about plugins and themes)
* download.php (validates md5 key of date and package zip file)
* update (folder to hold all zip file updates for url masking - protected by .htaccess to disallow file listings)


* update (default folder for holding theme and plugin zip files)
* .htaccess (prevents indexing and viewing of any zip files in directory)


* plugin (folder for adding plugin update checking)
* test-plugin-update (simple plugin folder to show how update functions work)
* test-plugin-update.php (example plugin that only checks for updates to server)


* theme (folder for theme update checking)
* update.php (file that can be included from functions.php of theme to check for updates)

---------------

**Important:**

*Change $api_url to your api server url in:*

/plugin/test-plugin-update/test-plugin-update.php
/theme/update.php

## Adding new versions

Edit the packages.php under api folder on your server. Commented thoroughly throughout with sections that need to be changed to reflect themes/plugins that are to be updated.

## Adding additional themes/plugins

Simply create another $package array with the key of the new theme/plugin slug and add all the appropriate info. When releasing the theme/plugin make sure that functions and variables are prefixed to prevent errors and allow multiple themes/plugins to be updated.

## Child theme support

Child themes are now supported. If the theme being updated is meant to be a parent theme the standard theme/update.php from the theme file will work. If the theme is a child theme of another theme comment out the parent theme section and uncomment the child theme section on the theme/update.php

## Securing Download location

Downloads are now always secured by a md5 hash of the package file_name and timestamp of current date. When downloading file current timestamp and timestamp of previous day are compared to key received from update request, if either match zip file is passed, and file can be downloaded.
TEST