Version Description
- ADDED: Extra update checks, updates will now occur as soon as is humanly possible
- ADDED: Much nicer notification emails when upgrades occur
- ADDED: Option to display debug inforamtion in the notification email
- FIXED: Use ouput buffering to ensure nothing is printed during upgrades
Download this release
Release Info
Developer | pento |
Plugin | Advanced Automatic Updates |
Version | 0.3 |
Comparing to | |
See all releases |
Code changes from version 0.2 to 0.3
- admin.php +11 -0
- automatic-updater.php +119 -27
- readme.txt +7 -1
- updater-skin.php +11 -2
admin.php
CHANGED
@@ -63,7 +63,13 @@ function auto_updater_settings() {
|
|
63 |
|
64 |
echo "<p><input type='checkbox' id='$type' name='$type' value='1'$checked> <label for='$type'>{$messages[$type]}</label></p>";
|
65 |
}
|
|
|
|
|
|
|
|
|
66 |
?>
|
|
|
|
|
67 |
<p><input class="button button-primary" type="submit" name="submit" id="submit" value="<?php esc_attr_e( 'Save Changes', 'automatic-updater' ); ?>" /></p>
|
68 |
</form>
|
69 |
</div>
|
@@ -81,5 +87,10 @@ function auto_updater_save_settings() {
|
|
81 |
$options['update'][$type] = false;
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
84 |
update_option( 'automatic-updater', $options );
|
85 |
}
|
63 |
|
64 |
echo "<p><input type='checkbox' id='$type' name='$type' value='1'$checked> <label for='$type'>{$messages[$type]}</label></p>";
|
65 |
}
|
66 |
+
|
67 |
+
$checked = '';
|
68 |
+
if ( $option['debug'] )
|
69 |
+
$checked = ' checked="checked"';
|
70 |
?>
|
71 |
+
<br/><br/>
|
72 |
+
<p input type="checkbox" id="debug" name="debug" value="1"<?php echo $checked; ?>> <label for="debug"><?php _e( 'Show debug inforamtion in the notification email.', 'automatic-updater' ); ?></label></p>
|
73 |
<p><input class="button button-primary" type="submit" name="submit" id="submit" value="<?php esc_attr_e( 'Save Changes', 'automatic-updater' ); ?>" /></p>
|
74 |
</form>
|
75 |
</div>
|
87 |
$options['update'][$type] = false;
|
88 |
}
|
89 |
|
90 |
+
if ( ! empty( $_REQUEST['debug'] ) )
|
91 |
+
$options['debug'] = true;
|
92 |
+
else
|
93 |
+
$options['debug'] = false;
|
94 |
+
|
95 |
update_option( 'automatic-updater', $options );
|
96 |
}
|
automatic-updater.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin URI: http://pento.net/
|
5 |
* Description: Automatically update your WordPress site, as soon as updates are released! Never worry about falling behing on updating again!
|
6 |
* Author: pento
|
7 |
-
* Version: 0.
|
8 |
* Author URI: http://pento.net
|
9 |
* License: GPL2+
|
10 |
* Text Domain: automatic-updater
|
@@ -27,30 +27,41 @@ function auto_updater_init() {
|
|
27 |
'plugins' => false,
|
28 |
'themes' => false,
|
29 |
),
|
|
|
30 |
);
|
31 |
update_option( 'automatic-updater', $options );
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
global $auto_updater_running;
|
35 |
// If the update check was one we called manually, don't get into a crazy recusive loop.
|
36 |
if ( $auto_updater_running )
|
37 |
return;
|
38 |
|
39 |
-
|
40 |
-
if (
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
add_action( 'set_site_transient_update_plugins', 'auto_updater_plugins' );
|
49 |
-
add_action( 'set_site_transient__site_transient_update_plugins', 'auto_updater_plugins' );
|
50 |
}
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
}
|
56 |
add_action( 'init', 'auto_updater_init' );
|
@@ -61,7 +72,6 @@ function auto_updater_core() {
|
|
61 |
return;
|
62 |
|
63 |
// Forgive me father, for I have sinned. I have included wp-admin files in a plugin.
|
64 |
-
// It's behind a DOING_CRON check, so won't cause much trouble.
|
65 |
include_once( ABSPATH . 'wp-admin/includes/update.php' );
|
66 |
include_once( ABSPATH . 'wp-admin/includes/file.php' );
|
67 |
|
@@ -75,22 +85,35 @@ function auto_updater_core() {
|
|
75 |
if ( empty( $update ) )
|
76 |
return;
|
77 |
|
|
|
|
|
78 |
$auto_updater_running = true;
|
79 |
|
80 |
do_action( 'auto_updater_before_update', 'core' );
|
81 |
|
82 |
$skin = new Auto_Updater_Skin();
|
83 |
$upgrader = new Core_Upgrader( $skin );
|
84 |
-
$upgrader->upgrade( $update );
|
85 |
|
86 |
do_action( 'auto_updater_after_update', 'core' );
|
87 |
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
-
|
91 |
|
92 |
wp_version_check();
|
93 |
}
|
|
|
94 |
|
95 |
function auto_updater_plugins() {
|
96 |
global $auto_updater_running;
|
@@ -98,11 +121,12 @@ function auto_updater_plugins() {
|
|
98 |
return;
|
99 |
|
100 |
include_once( ABSPATH . 'wp-admin/includes/update.php' );
|
|
|
101 |
include_once( ABSPATH . 'wp-admin/includes/file.php' );
|
102 |
|
103 |
include_once( dirname( __FILE__ ) . '/updater-skin.php' );
|
104 |
|
105 |
-
$plugins = apply_filters( 'auto_updater_plugin_updates',
|
106 |
if ( empty( $plugins ) )
|
107 |
return;
|
108 |
|
@@ -112,16 +136,38 @@ function auto_updater_plugins() {
|
|
112 |
|
113 |
$skin = new Auto_Updater_Skin();
|
114 |
$upgrader = new Plugin_Upgrader( $skin );
|
115 |
-
$upgrader->bulk_upgrade( $plugins );
|
116 |
|
117 |
do_action( 'auto_updater_after_update', 'plugins' );
|
118 |
|
119 |
-
$message =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
-
|
122 |
|
123 |
wp_update_plugins();
|
124 |
}
|
|
|
125 |
|
126 |
function auto_updater_themes() {
|
127 |
global $auto_updater_running;
|
@@ -133,7 +179,7 @@ function auto_updater_themes() {
|
|
133 |
|
134 |
include_once( dirname( __FILE__ ) . '/updater-skin.php' );
|
135 |
|
136 |
-
$themes = apply_filters( 'auto_updater_theme_updates',
|
137 |
if ( empty( $themes ) )
|
138 |
return;
|
139 |
|
@@ -143,14 +189,60 @@ function auto_updater_themes() {
|
|
143 |
|
144 |
$skin = new Auto_Updater_Skin();
|
145 |
$upgrader = new Theme_Upgrader( $skin );
|
146 |
-
$upgrader->bulk_upgrade( $themes );
|
147 |
|
148 |
do_action( 'auto_updater_after_update', 'themes' );
|
149 |
|
150 |
-
$message =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
-
|
153 |
|
154 |
wp_update_themes();
|
155 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
|
4 |
* Plugin URI: http://pento.net/
|
5 |
* Description: Automatically update your WordPress site, as soon as updates are released! Never worry about falling behing on updating again!
|
6 |
* Author: pento
|
7 |
+
* Version: 0.3
|
8 |
* Author URI: http://pento.net
|
9 |
* License: GPL2+
|
10 |
* Text Domain: automatic-updater
|
27 |
'plugins' => false,
|
28 |
'themes' => false,
|
29 |
),
|
30 |
+
'debug' => false,
|
31 |
);
|
32 |
update_option( 'automatic-updater', $options );
|
33 |
}
|
34 |
|
35 |
+
// 'debug' option added in version 0.3
|
36 |
+
if ( ! array_key_exists( 'debug', $options ) ) {
|
37 |
+
$options['debug'] = false;
|
38 |
+
update_option( 'automatic-updater', $options );
|
39 |
+
}
|
40 |
+
|
41 |
global $auto_updater_running;
|
42 |
// If the update check was one we called manually, don't get into a crazy recusive loop.
|
43 |
if ( $auto_updater_running )
|
44 |
return;
|
45 |
|
46 |
+
$types = array( 'wordpress' => 'core', 'plugins' => 'plugins', 'themes' => 'themes' );
|
47 |
+
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
|
48 |
+
// We're in a cron, do updates now
|
49 |
+
foreach ( $types as $type ) {
|
50 |
+
if ( ! empty( $options['update'][$type] ) ) {
|
51 |
+
add_action( "set_site_transient_update_$type", "auto_updater_$type" );
|
52 |
+
add_action( "set_site_transient__site_transient_update_$type", "auto_updater_$type" );
|
53 |
+
}
|
54 |
+
}
|
|
|
|
|
55 |
}
|
56 |
+
else {
|
57 |
+
include_once( ABSPATH . 'wp-admin/includes/update.php' );
|
58 |
+
$update_data = wp_get_update_data();
|
59 |
+
// Not in a cron, schedule updates to happen in the next cron run
|
60 |
+
foreach ( $types as $internal => $type ) {
|
61 |
+
if ( ! empty( $options['update'][$type] ) && $update_data['counts'][$internal] > 0 ) {
|
62 |
+
wp_schedule_single_event( time(), "auto_updater_{$type}_event" );
|
63 |
+
}
|
64 |
+
}
|
65 |
}
|
66 |
}
|
67 |
add_action( 'init', 'auto_updater_init' );
|
72 |
return;
|
73 |
|
74 |
// Forgive me father, for I have sinned. I have included wp-admin files in a plugin.
|
|
|
75 |
include_once( ABSPATH . 'wp-admin/includes/update.php' );
|
76 |
include_once( ABSPATH . 'wp-admin/includes/file.php' );
|
77 |
|
85 |
if ( empty( $update ) )
|
86 |
return;
|
87 |
|
88 |
+
$old_version = get_bloginfo( 'version' );
|
89 |
+
|
90 |
$auto_updater_running = true;
|
91 |
|
92 |
do_action( 'auto_updater_before_update', 'core' );
|
93 |
|
94 |
$skin = new Auto_Updater_Skin();
|
95 |
$upgrader = new Core_Upgrader( $skin );
|
96 |
+
$result = $upgrader->upgrade( $update );
|
97 |
|
98 |
do_action( 'auto_updater_after_update', 'core' );
|
99 |
|
100 |
+
if ( is_wp_error( $result ) ) {
|
101 |
+
$message = __( "While trying to upgrade WordPress, we ran into the following error:", 'automatic-updater' );
|
102 |
+
$message .= "\r\n\r\n" . $result->get_error_message() . "\r\n\r\n";
|
103 |
+
$message .= __( "We're sorry it didn't work out. Please try upgrading manually, instead.", 'automatic-updater' );
|
104 |
+
}
|
105 |
+
else {
|
106 |
+
$message = sprintf( __( "We've successfully upgraded WordPress from version %1s to version %2s!", 'automatic-updater' ), $old_version, $update->current );
|
107 |
+
$message .= "\r\n\r\n" . __( 'Have fun!', 'automatic-updater' );
|
108 |
+
}
|
109 |
+
|
110 |
+
$debug = join( "\r\n", $skin->messages );
|
111 |
|
112 |
+
auto_updater_notification( $message, $debug );
|
113 |
|
114 |
wp_version_check();
|
115 |
}
|
116 |
+
add_action( 'auto_updater_core_event', 'auto_updater_core' );
|
117 |
|
118 |
function auto_updater_plugins() {
|
119 |
global $auto_updater_running;
|
121 |
return;
|
122 |
|
123 |
include_once( ABSPATH . 'wp-admin/includes/update.php' );
|
124 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
125 |
include_once( ABSPATH . 'wp-admin/includes/file.php' );
|
126 |
|
127 |
include_once( dirname( __FILE__ ) . '/updater-skin.php' );
|
128 |
|
129 |
+
$plugins = apply_filters( 'auto_updater_plugin_updates', get_plugin_updates() );
|
130 |
if ( empty( $plugins ) )
|
131 |
return;
|
132 |
|
136 |
|
137 |
$skin = new Auto_Updater_Skin();
|
138 |
$upgrader = new Plugin_Upgrader( $skin );
|
139 |
+
$result = $upgrader->bulk_upgrade( array_keys( $plugins ) );
|
140 |
|
141 |
do_action( 'auto_updater_after_update', 'plugins' );
|
142 |
|
143 |
+
$message = _n( 'We found a plugin upgrade!', 'We found upgrades for some plugins!', count( $plugins ), 'automatic-updater' );
|
144 |
+
$message .= "\r\n\r\n";
|
145 |
+
|
146 |
+
foreach ( $plugins as $id => $plugin ) {
|
147 |
+
if ( is_wp_error( $result[$id] ) ) {
|
148 |
+
/* translators: First argument is the Plugin name, second argument is the error encountered while upgrading */
|
149 |
+
$message .= sprintf( __( "%1s: We encounted an error upgrading this plugin: %2s", 'automatic-updater' ),
|
150 |
+
$plugin->Name,
|
151 |
+
$result[$id]->get_error_message() );
|
152 |
+
}
|
153 |
+
else {
|
154 |
+
/* tranlators: First argument is the Plugin name, second argument is the old version number, third argument is the new version number */
|
155 |
+
$message .= sprintf( __( "%1s: Successfully upgraded from version %2s to %3s!", 'automatic-updater' ),
|
156 |
+
$plugin->Name,
|
157 |
+
$plugin->Version,
|
158 |
+
$plugin->update->new_version );
|
159 |
+
}
|
160 |
+
|
161 |
+
$message .= "\r\n";
|
162 |
+
}
|
163 |
+
|
164 |
+
$debug = join( "\r\n", $skin->messages );
|
165 |
|
166 |
+
auto_updater_notification( $message, $debug );
|
167 |
|
168 |
wp_update_plugins();
|
169 |
}
|
170 |
+
add_action( 'auto_updater_plugins_event', 'auto_updater_plugins' );
|
171 |
|
172 |
function auto_updater_themes() {
|
173 |
global $auto_updater_running;
|
179 |
|
180 |
include_once( dirname( __FILE__ ) . '/updater-skin.php' );
|
181 |
|
182 |
+
$themes = apply_filters( 'auto_updater_theme_updates', get_theme_updates() );
|
183 |
if ( empty( $themes ) )
|
184 |
return;
|
185 |
|
189 |
|
190 |
$skin = new Auto_Updater_Skin();
|
191 |
$upgrader = new Theme_Upgrader( $skin );
|
192 |
+
$result = $upgrader->bulk_upgrade( array_keys( $themes ) );
|
193 |
|
194 |
do_action( 'auto_updater_after_update', 'themes' );
|
195 |
|
196 |
+
$message = _n( 'We found a theme upgrade!', 'We found upgrades for some themes!', count( $themes ), 'automatic-updater' );
|
197 |
+
$message .= "\r\n\r\n";
|
198 |
+
|
199 |
+
foreach ( $themes as $id => $theme ) {
|
200 |
+
if ( is_wp_error( $result[$id] ) ) {
|
201 |
+
/* translators: First argument is the Theme name, second argument is the error encountered while upgrading */
|
202 |
+
$message .= sprintf( __( "%1s: We encounted an error upgrading this theme: %2s", 'automatic-updater' ),
|
203 |
+
$theme->name,
|
204 |
+
$result[$id]->get_error_message() );
|
205 |
+
}
|
206 |
+
else {
|
207 |
+
/* tranlators: First argument is the Theme name, second argument is the old version number, third argument is the new version number */
|
208 |
+
$message .= sprintf( __( "%1s: Successfully upgraded from version %2s to %3s!", 'automatic-updater' ),
|
209 |
+
$theme->name,
|
210 |
+
$theme->version,
|
211 |
+
$theme->update['new_version'] );
|
212 |
+
}
|
213 |
+
|
214 |
+
$message .= "\r\n";
|
215 |
+
}
|
216 |
+
|
217 |
+
$debug = join( "\r\n", $skin->messages );
|
218 |
|
219 |
+
auto_updater_notification( $message, $debug );
|
220 |
|
221 |
wp_update_themes();
|
222 |
}
|
223 |
+
add_action( 'auto_updater_themes_event', 'auto_updater_themes' );
|
224 |
+
|
225 |
+
function auto_updater_notification( $info = '', $debug = '' ) {
|
226 |
+
$options = get_option( 'automatic-updater', array() );
|
227 |
+
$site = get_home_url();
|
228 |
+
$subject = sprintf( __( 'WordPress Update: %1s', 'automatic-updater' ), $site );
|
229 |
+
|
230 |
+
$message = __( 'Howdy!', 'automatic-updater' );
|
231 |
+
$message .= "\r\n\r\n";
|
232 |
+
$message .= sprintf( __( 'Automatic Updater just ran on your site, %1s, with the following result:', 'automatic-updater' ), $site );
|
233 |
+
$message .= "\r\n\r\n";
|
234 |
+
|
235 |
+
$message .= $info;
|
236 |
+
|
237 |
+
$message .= "\r\n";
|
238 |
+
$message .= __( 'Thanks for using the Automatic Updater plugin!', 'automatic-updater' );
|
239 |
+
|
240 |
+
if ( ! empty( $options['debug'] ) ) {
|
241 |
+
$message .= "\r\n\r\n\r\n\r\n";
|
242 |
+
$message .= __( 'Debug Information:', 'automatic-updater' );
|
243 |
+
$message .= "\r\n\r\n$debug";
|
244 |
+
}
|
245 |
+
|
246 |
+
wp_mail( get_option( 'admin_email' ), $subject, $message );
|
247 |
+
}
|
248 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://pento.net/donate/
|
|
4 |
Tags: updates, core, plugins, themes
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 3.5
|
7 |
-
Stable tag: 0.
|
8 |
|
9 |
Automatically update WordPress, your themes and plugins! Never have to click the update button again!
|
10 |
|
@@ -40,6 +40,12 @@ There are some Actions and Filters provided, check the [Documentation](http://pe
|
|
40 |
|
41 |
== Changelog ==
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
= 0.2 =
|
44 |
* ADDED: Some useful filters and actions. See the [Documentation](http://pento.net/projects/automatic-updater-for-wordpress/) for details
|
45 |
* FIXED: s/automattic/automatic/g
|
4 |
Tags: updates, core, plugins, themes
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 3.5
|
7 |
+
Stable tag: 0.3
|
8 |
|
9 |
Automatically update WordPress, your themes and plugins! Never have to click the update button again!
|
10 |
|
40 |
|
41 |
== Changelog ==
|
42 |
|
43 |
+
= 0.3 =
|
44 |
+
* ADDED: Extra update checks, updates will now occur as soon as is humanly possible
|
45 |
+
* ADDED: Much nicer notification emails when upgrades occur
|
46 |
+
* ADDED: Option to display debug inforamtion in the notification email
|
47 |
+
* FIXED: Use ouput buffering to ensure nothing is printed during upgrades
|
48 |
+
|
49 |
= 0.2 =
|
50 |
* ADDED: Some useful filters and actions. See the [Documentation](http://pento.net/projects/automatic-updater-for-wordpress/) for details
|
51 |
* FIXED: s/automattic/automatic/g
|
updater-skin.php
CHANGED
@@ -34,8 +34,17 @@ class Auto_Updater_Skin extends WP_Upgrader_Skin {
|
|
34 |
$this->messages[] = $string;
|
35 |
}
|
36 |
|
37 |
-
function header() {
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
function bulk_header() {}
|
40 |
function bulk_footer() {}
|
41 |
function before() {}
|
34 |
$this->messages[] = $string;
|
35 |
}
|
36 |
|
37 |
+
function header() {
|
38 |
+
ob_start();
|
39 |
+
}
|
40 |
+
|
41 |
+
function footer() {
|
42 |
+
$output = ob_get_contents();
|
43 |
+
if ( ! empty( $output ) )
|
44 |
+
$this->feedback( $output );
|
45 |
+
ob_end_clean();
|
46 |
+
}
|
47 |
+
|
48 |
function bulk_header() {}
|
49 |
function bulk_footer() {}
|
50 |
function before() {}
|