Version Description
Download this release
Release Info
Developer | chrisbliss18 |
Plugin | Easy Theme and Plugin Upgrades |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- history.txt +2 -0
- init.php +16 -0
- maintenance-page.html +46 -0
- modify-installer.php +232 -0
- readme.txt +47 -0
- show-maintenance-message.php +23 -0
history.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
1.0.0 - 2011-07-06 - Chris Jean
|
2 |
+
Release-ready
|
init.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
Plugin Name: Easy Theme and Plugin Upgrades
|
5 |
+
Plugin URI: http://ithemes.com/
|
6 |
+
Description: This plugin allows for installed themes to be upgraded by using the Appearance > Add New Themes > Upload feature of WordPress. Without this plugin, themes can only be installed using this method, requiring you to first delete the theme before installing the newer version. Now features the same easy upgrading for plugins via the Plugins > Add New > Upload page.
|
7 |
+
Author: Chris Jean
|
8 |
+
Version: 1.0.0
|
9 |
+
Author URI: http://ithemes.com/
|
10 |
+
*/
|
11 |
+
|
12 |
+
|
13 |
+
if ( is_admin() )
|
14 |
+
require_once( dirname( __FILE__ ) . '/modify-installer.php' );
|
15 |
+
else
|
16 |
+
require_once( dirname( __FILE__ ) . '/show-maintenance-message.php' );
|
maintenance-page.html
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2 |
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
3 |
+
|
4 |
+
<head profile="http://gmpg.org/xfn/11">
|
5 |
+
<style>
|
6 |
+
* {
|
7 |
+
padding: 0;
|
8 |
+
margin: 0;
|
9 |
+
}
|
10 |
+
html, body {
|
11 |
+
height: 100%;
|
12 |
+
}
|
13 |
+
body {
|
14 |
+
font-size: 1.5em;
|
15 |
+
background-color: #C0C0C0;
|
16 |
+
}
|
17 |
+
.pusher {
|
18 |
+
width: 1px;
|
19 |
+
height: 50%;
|
20 |
+
margin-bottom: -2.7em;
|
21 |
+
float: left;
|
22 |
+
}
|
23 |
+
.content {
|
24 |
+
height: 3.8em;
|
25 |
+
width: 16em;
|
26 |
+
clear: left;
|
27 |
+
margin: 0 auto;
|
28 |
+
position: relative;
|
29 |
+
border: 0.2em solid #369;
|
30 |
+
background-color: #FFF;
|
31 |
+
padding: 1.2em 1em 0 1em;
|
32 |
+
-moz-border-radius: 1em;
|
33 |
+
-webkit-border-radius: 1em;
|
34 |
+
text-align: center;
|
35 |
+
}
|
36 |
+
</style>
|
37 |
+
</head>
|
38 |
+
|
39 |
+
<body>
|
40 |
+
<div class="pusher"><!-- centers next div --></div>
|
41 |
+
<div class="content">
|
42 |
+
The site is being updated and will be back in a few minutes.
|
43 |
+
</div>
|
44 |
+
</body>
|
45 |
+
|
46 |
+
</html>
|
modify-installer.php
ADDED
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
if ( ! class_exists( 'ETUModifyInstaller' ) ) {
|
5 |
+
class ETUModifyInstaller {
|
6 |
+
var $_errors = array();
|
7 |
+
var $_type = '';
|
8 |
+
|
9 |
+
|
10 |
+
function ETUModifyInstaller() {
|
11 |
+
if ( preg_match( '|update.php|', $_SERVER['REQUEST_URI'] ) && isset( $_REQUEST['action'] ) ) {
|
12 |
+
if ( 'upload-theme' === $_REQUEST['action'] )
|
13 |
+
$this->_type = 'theme';
|
14 |
+
else if ( 'upload-plugin' === $_REQUEST['action'] )
|
15 |
+
$this->_type = 'plugin';
|
16 |
+
|
17 |
+
if ( ! empty( $this->_type ) )
|
18 |
+
add_action( 'admin_init', array( &$this, 'handle_upgrades' ), 100 );
|
19 |
+
}
|
20 |
+
|
21 |
+
add_action( "install_themes_upload", array( &$this, 'start_theme_output_buffering' ), 0 );
|
22 |
+
add_action( "install_themes_upload", array( &$this, 'end_output_buffering' ), 20 );
|
23 |
+
add_action( "install_plugins_upload", array( &$this, 'start_plugin_output_buffering' ), 0 );
|
24 |
+
add_action( "install_plugins_upload", array( &$this, 'end_output_buffering' ), 20 );
|
25 |
+
}
|
26 |
+
|
27 |
+
function filter_output( $output ) {
|
28 |
+
$text = "<div style='width:600px;'>\n";
|
29 |
+
$text .= "<p><i>By default, the installer will not overwrite an existing {$this->_type}. Change the following option to \"Yes\" to allow this installer to perform upgrades as well.</i></p>";
|
30 |
+
$text .= "<p>Upgrade existing {$this->_type}? <select name='upgrade_existing'><option value=''>No</option><option value='yes'>Yes</option></select></p>\n";
|
31 |
+
$text .= "<i><p>If a {$this->_type} is upgraded, the following process will be used:</p>\n";
|
32 |
+
$text .= "<ol>\n";
|
33 |
+
$text .= "<li>A backup zip of the existing {$this->_type} will be created and added to the <a href='" . admin_url( 'upload.php' ) . "'>Media Library</a>.</li>\n";
|
34 |
+
$text .= "<li>If the selected {$this->_type} is active, the site will display a 'Site being updated' message until the upgrade has finished. This typically lasts a few seconds at most.</li>\n";
|
35 |
+
$text .= "<li>The existing {$this->_type} directory will be deleted in order for the installer to install the new version.</li>\n";
|
36 |
+
$text .= "<li>The {$this->_type} installer will install the new {$this->_type}.</li>\n";
|
37 |
+
$text .= "<li>The site update message will be removed from the site.</li>\n";
|
38 |
+
$text .= "</ol><br />\n";
|
39 |
+
$text .= "</div>\n";
|
40 |
+
|
41 |
+
$output = preg_replace( '|(<input type="file".+?\n)|', "\$1$text", $output );
|
42 |
+
|
43 |
+
return $output;
|
44 |
+
}
|
45 |
+
|
46 |
+
function start_theme_output_buffering() {
|
47 |
+
$this->_type = 'theme';
|
48 |
+
ob_start( array( &$this, 'filter_output' ) );
|
49 |
+
}
|
50 |
+
|
51 |
+
function start_plugin_output_buffering() {
|
52 |
+
$this->_type = 'plugin';
|
53 |
+
ob_start( array( &$this, 'filter_output' ) );
|
54 |
+
}
|
55 |
+
|
56 |
+
function end_output_buffering() {
|
57 |
+
ob_end_flush();
|
58 |
+
}
|
59 |
+
|
60 |
+
function _get_theme_data( $directory ) {
|
61 |
+
$data = array();
|
62 |
+
|
63 |
+
$themes = get_themes();
|
64 |
+
$active_theme = current_theme_info();
|
65 |
+
$current_theme = array();
|
66 |
+
|
67 |
+
foreach ( (array) $themes as $theme_name => $theme_data ) {
|
68 |
+
if ( $directory === $theme_data['Stylesheet'] )
|
69 |
+
$current_theme = $theme_data;
|
70 |
+
}
|
71 |
+
|
72 |
+
if ( empty( $current_theme ) )
|
73 |
+
return $data;
|
74 |
+
|
75 |
+
$data['version'] = $current_theme['Version'];
|
76 |
+
$data['name'] = $current_theme['Name'];
|
77 |
+
$data['directory'] = $current_theme['Stylesheet Dir'];
|
78 |
+
|
79 |
+
$data['is_active'] = false;
|
80 |
+
if ( ( $active_theme->template_dir === $current_theme['Template Dir'] ) || ( $active_theme->template_dir === $current_theme['Template Dir'] ) )
|
81 |
+
$data['is_active'] = true;
|
82 |
+
|
83 |
+
global $wp_version;
|
84 |
+
if ( version_compare( '2.8.6', $wp_version, '>' ) )
|
85 |
+
$data['directory'] = WP_CONTENT_DIR . $current_theme['Stylesheet Dir'];
|
86 |
+
|
87 |
+
return $data;
|
88 |
+
}
|
89 |
+
|
90 |
+
function _get_plugin_data( $directory ) {
|
91 |
+
$data = array();
|
92 |
+
|
93 |
+
$plugins = get_plugins();
|
94 |
+
$active_plugins = get_option('active_plugins');
|
95 |
+
$current_plugin = array();
|
96 |
+
|
97 |
+
foreach ( (array) $plugins as $plugin_path_file => $plugin_data ) {
|
98 |
+
if ( $directory === reset( explode( '/', $plugin_path_file ) ) )
|
99 |
+
$current_plugin = array( 'path' => $plugin_path_file, 'data' => $plugin_data );
|
100 |
+
}
|
101 |
+
|
102 |
+
if ( empty( $current_plugin ) )
|
103 |
+
return $data;
|
104 |
+
|
105 |
+
$data['version'] = $current_plugin['data']['Version'];
|
106 |
+
$data['name'] = $current_plugin['data']['Name'];
|
107 |
+
$data['directory'] = WP_PLUGIN_DIR . '/' . $directory;
|
108 |
+
$data['is_active'] = ( is_plugin_active( $current_plugin['path'] ) ) ? true : false;
|
109 |
+
|
110 |
+
return $data;
|
111 |
+
}
|
112 |
+
|
113 |
+
function handle_upgrades() {
|
114 |
+
if ( 'yes' !== $_POST['upgrade_existing'] ) {
|
115 |
+
$this->_errors[] = "You must select \"Yes\" from the \"Upgrade existing {$this->_type}?\" dropdown option in order to upgrade an existing {$this->_type}. <a href=\"" . admin_url( "{$this->_type}-install.php?tab=upload" ) . '">Try again</a>.';
|
116 |
+
add_action( 'admin_notices', array( &$this, 'show_upgrade_option_error_message' ) );
|
117 |
+
|
118 |
+
return;
|
119 |
+
}
|
120 |
+
|
121 |
+
remove_action( 'admin_print_styles', 'builder_add_global_admin_styles' );
|
122 |
+
|
123 |
+
|
124 |
+
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
125 |
+
require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
|
126 |
+
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
127 |
+
|
128 |
+
check_admin_referer( "{$this->_type}-upload" );
|
129 |
+
@set_time_limit( 300 );
|
130 |
+
|
131 |
+
$archive = new PclZip( $_FILES["{$this->_type}zip"]['tmp_name'] );
|
132 |
+
|
133 |
+
$directory = '';
|
134 |
+
$contents = $archive->listContent();
|
135 |
+
|
136 |
+
foreach ( (array) $contents as $content ) {
|
137 |
+
if ( preg_match( '|^([^/]+)/$|', $content['filename'], $matches ) ) {
|
138 |
+
$directory = $matches[1];
|
139 |
+
break;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
if ( 'theme' === $this->_type )
|
144 |
+
$data = $this->_get_theme_data( $directory );
|
145 |
+
else if ( 'plugin' === $this->_type )
|
146 |
+
$data = $this->_get_plugin_data( $directory );
|
147 |
+
|
148 |
+
if ( empty( $data ) )
|
149 |
+
return;
|
150 |
+
|
151 |
+
|
152 |
+
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
153 |
+
$rand_string = '';
|
154 |
+
$length = rand( 10, 20 );
|
155 |
+
for ( $count = 0; $count < $length; $count++ )
|
156 |
+
$rand_string .= $characters[rand( 0, strlen( $characters ) - 1 )];
|
157 |
+
|
158 |
+
$zip_file = "$directory-{$data['version']}-$rand_string.zip";
|
159 |
+
|
160 |
+
$wp_upload_dir = wp_upload_dir();
|
161 |
+
$zip_path = $wp_upload_dir['path'] . '/' . $zip_file;
|
162 |
+
$zip_url = $wp_upload_dir['url'] . '/' . $zip_file;
|
163 |
+
|
164 |
+
$archive = new PclZip( $zip_path );
|
165 |
+
|
166 |
+
$zip_result = $archive->create( $data['directory'], PCLZIP_OPT_REMOVE_PATH, dirname( $data['directory'] ) );
|
167 |
+
|
168 |
+
if ( 0 == $zip_result ) {
|
169 |
+
$this->_errors[] = "Unable to make a backup of the existing {$this->_type}. Will not proceed with the upgrade.";
|
170 |
+
add_action( 'admin_notices', array( &$this, 'show_upgrade_option_error_message' ) );
|
171 |
+
|
172 |
+
return;
|
173 |
+
}
|
174 |
+
|
175 |
+
|
176 |
+
$attachment = array(
|
177 |
+
'post_mime_type' => 'application/zip',
|
178 |
+
'guid' => $zip_url,
|
179 |
+
'post_title' => ucfirst( $this->_type ) . " Backup - {$data['name']} - {$data['version']}",
|
180 |
+
'post_content' => '',
|
181 |
+
);
|
182 |
+
|
183 |
+
$id = wp_insert_attachment( $attachment, $zip_path );
|
184 |
+
if ( !is_wp_error( $id ) )
|
185 |
+
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $zip_path ) );
|
186 |
+
|
187 |
+
|
188 |
+
if ( $data['is_active'] )
|
189 |
+
set_transient( 'etu-in-maintenance-mode', '1', 300 );
|
190 |
+
|
191 |
+
|
192 |
+
global $wp_filesystem;
|
193 |
+
|
194 |
+
if ( ! WP_Filesystem() ) {
|
195 |
+
$this->_errors[] = 'Unable to initialize WP_Filesystem. Will not proceed with the upgrade.';
|
196 |
+
add_action( 'admin_notices', array( &$this, 'show_upgrade_option_error_message' ) );
|
197 |
+
|
198 |
+
return;
|
199 |
+
}
|
200 |
+
|
201 |
+
if ( ! $wp_filesystem->delete( $data['directory'], true ) ) {
|
202 |
+
$this->_errors[] = "Unable to remove the existing {$this->_type} directory. Will not proceed with the upgrade.";
|
203 |
+
add_action( 'admin_notices', array( &$this, 'show_upgrade_option_error_message' ) );
|
204 |
+
|
205 |
+
return;
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
$this->_zip_url = $zip_url;
|
210 |
+
add_action( 'admin_notices', array( &$this, 'show_message' ) );
|
211 |
+
}
|
212 |
+
|
213 |
+
function show_message() {
|
214 |
+
echo "<div id=\"message\" class=\"updated fade\"><p><strong>A backup zip file of the old {$this->_type} version can be downloaded <a href='$this->_zip_url'>here</a>.</strong></p></div>\n";
|
215 |
+
|
216 |
+
delete_transient( 'etu-in-maintenance-mode' );
|
217 |
+
}
|
218 |
+
|
219 |
+
function show_upgrade_option_error_message() {
|
220 |
+
if ( ! isset( $this->_errors ) )
|
221 |
+
return;
|
222 |
+
|
223 |
+
if ( ! is_array( $this->_errors ) )
|
224 |
+
$this->_errors = array( $this->_errors );
|
225 |
+
|
226 |
+
foreach ( (array) $this->_errors as $error )
|
227 |
+
echo "<div id=\"message\" class=\"error\"><p><strong>$error</strong></p></div>\n";
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
new ETUModifyInstaller();
|
232 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Easy Theme and Plugin Upgrades ===
|
2 |
+
Contributors: chrisbliss18
|
3 |
+
Tags: upload, plugins, themes, upgrade
|
4 |
+
Requires at least: 3.0
|
5 |
+
Tested up to: 3.2
|
6 |
+
Stable tag: 1.0.0
|
7 |
+
|
8 |
+
This plugin allows for installed themes to be upgraded by using the Appearance Add New Themes > Upload feature of WordPress. Without this plugin, themes can only be installed using this method, requiring you to first delete the theme before installing the newer version. Now features the same easy upgrading for plugins via the Plugins > Add New > Upload page.
|
9 |
+
|
10 |
+
== Description ==
|
11 |
+
|
12 |
+
__Easy Theme and Plugin Upgrades__ was created to make the life of WordPress users easier. Without this plugin, the only upgrade path you have for download zip plugins and themes is to deactivate the theme/plugin, delete it, upload, and reactivate. With this plugin, upgrading is as simple as selecting the zip file to upload, selecting "Yes" from a drop-down, and clicking "Install Now".
|
13 |
+
|
14 |
+
= Upgrading a Theme =
|
15 |
+
|
16 |
+
1. Download the latest zip file for your theme.
|
17 |
+
1. Log into your WordPress site.
|
18 |
+
1. Go to Appearance > Themes.
|
19 |
+
1. Click the "Install Themes" tab.
|
20 |
+
1. Click the Upload link below the main page tabs.
|
21 |
+
1. Select the zip file with the new theme version to install.
|
22 |
+
1. Select "Yes" from the "Upgrade existing theme?" option.
|
23 |
+
1. Click "Install Now".
|
24 |
+
|
25 |
+
= Upgrading a Plugin =
|
26 |
+
|
27 |
+
1. Download the latest zip file for your plugin.
|
28 |
+
1. Log into your WordPress site.
|
29 |
+
1. Go to Plugins > Add New and click the Upload tab at the top of the page.
|
30 |
+
1. Select the zip file with the new plugin version to install.
|
31 |
+
1. Select "Yes" from the "Upgrade existing plugin?" option.
|
32 |
+
1. Click "Install Now".
|
33 |
+
|
34 |
+
== Installation ==
|
35 |
+
|
36 |
+
1. Download and unzip the latest release zip file
|
37 |
+
1. Upload the entire easy-theme-and-plugin-upgrades directory to your `/wp-content/plugins/` directory
|
38 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
39 |
+
|
40 |
+
== Requirements ==
|
41 |
+
|
42 |
+
* PHP 4+
|
43 |
+
* WordPress 3.0+
|
44 |
+
|
45 |
+
== Version History ==
|
46 |
+
|
47 |
+
* 1.0.0 - 2011-07-06 - Initial release version
|
show-maintenance-message.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
if ( ! class_exists( 'ETUShowMaintenanceMessage' ) ) {
|
5 |
+
class ETUShowMaintenanceMessage {
|
6 |
+
function ETUShowMaintenanceMessage() {
|
7 |
+
if ( false !== get_transient( 'etu-in-maintenance-mode' ) )
|
8 |
+
add_action( 'template_redirect', array( &$this, 'show_message' ) );
|
9 |
+
}
|
10 |
+
|
11 |
+
function show_message() {
|
12 |
+
$file = dirname( __FILE__ ) . '/maintenance-page.html';
|
13 |
+
if ( file_exists( dirname( __FILE__ ) . '/custom-maintenance-page.html' ) )
|
14 |
+
$file = dirname( __FILE__ ) . '/custom-maintenance-page.html';
|
15 |
+
|
16 |
+
echo file_get_contents( $file );
|
17 |
+
|
18 |
+
exit;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
new ETUShowMaintenanceMessage();
|
23 |
+
}
|