Automatic Plugin Updates - Version 1.0

Version Description

  • Initial release
Download this release

Release Info

Developer WhiteFirDesign
Plugin Icon wp plugin Automatic Plugin Updates
Version 1.0
Comparing to
See all releases

Version 1.0

automatic-plugin-updates.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Automatic Plugin Updates
4
+ Plugin URI: http://www.whitefirdesign.com/automatic-plugin-updates
5
+ Description: Enables automatic background updates of plugins. Supports excluding selected plugins from being automatically updated.
6
+ Version: 1.0
7
+ Author: White Fir Design
8
+ Author URI: http://www.whitefirdesign.com/
9
+ License: GPLv2
10
+ Text Domain: automatic-plugin-updates
11
+ Domain Path: /languages
12
+
13
+ Copyright 2014 White Fir Design
14
+
15
+ This program is free software; you can redistribute it and/or
16
+ modify it under the terms of the GNU General Public License
17
+ as published by the Free Software Foundation; only version 2 of the License is applicable.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ */
28
+
29
+ //Block direct access to the file
30
+ if ( !function_exists( 'add_action' ) ) {
31
+ exit;
32
+ }
33
+
34
+
35
+ //Initiate localization
36
+ function automatic_plugin_updates_init() {
37
+ load_plugin_textdomain( 'automatic-plugin-updates', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
38
+ }
39
+ add_action('init', 'automatic_plugin_updates_init');
40
+
41
+
42
+ //Check if plugin to be automatically updated is set to be excluded from automatic updates
43
+ function check_if_excluded_plugin ($update,$item) {
44
+
45
+ if (get_option('automatic_plugin_updates_excluded_plugins'))
46
+ $excluded_plugins = get_option('automatic_plugin_updates_excluded_plugins');
47
+ else
48
+ return true;
49
+
50
+ //WordPress 3.9 includes all plugin data in $item
51
+ if (version_compare(get_bloginfo('version'),'3.9','>='))
52
+ $plugin_to_check = $item->plugin;
53
+ else
54
+ $plugin_to_check = $item;
55
+
56
+ if (in_array($plugin_to_check,$excluded_plugins))
57
+ return false;
58
+ else
59
+ return true;
60
+ }
61
+
62
+ //Enable automatic plugin updates while checking for execlude plugin
63
+ add_filter( 'auto_update_plugin', 'check_if_excluded_plugin', 10, 2 );
64
+
65
+ //Send email on plugin update
66
+ if ( (!get_option('automatic_plugin_updates_send_emails')) || ( get_option('automatic_plugin_updates_send_emails') && (get_option('automatic_plugin_updates_send_emails')=='enabled') ) )
67
+ add_filter( 'automatic_updates_send_debug_email', '__return_true' );
68
+
69
+ //Adds settings link to menu
70
+ function automatic_plugin_updates_add_pages() {
71
+ add_options_page( 'Automatic Plugin Updates', 'Automatic Plugin Updates', 10, 'automatic-plugin-updates', 'automatic_plugin_updates_page' );
72
+ }
73
+ add_action( 'admin_menu', 'automatic_plugin_updates_add_pages' );
74
+
75
+
76
+ //Setting page
77
+ function automatic_plugin_updates_page() {
78
+
79
+ //Store submitted data
80
+ if ( ($_SERVER['REQUEST_METHOD'] === 'POST') && wp_verify_nonce($_POST['automatic_plugin_updates'],'automatic_plugin_updates') ) {
81
+
82
+ //Store excluded plugins
83
+ $excluded_plugins = array();
84
+ foreach ($_POST as $key => $val) {
85
+ if (strpos($key,'_php'))
86
+ $excluded_plugins[] = str_replace ('_php','.php',$key);
87
+ }
88
+ update_option( 'automatic_plugin_updates_excluded_plugins', $excluded_plugins, '', 'yes' );
89
+
90
+ //Store email preference
91
+ update_option( 'automatic_plugin_updates_send_emails', $_POST['send-email'], '', 'yes' );
92
+ }
93
+ else if (get_option('automatic_plugin_updates_excluded_plugins')) {
94
+ $excluded_plugins = get_option('automatic_plugin_updates_excluded_plugins');
95
+ }
96
+
97
+ $current_plugins = get_plugins( $plugin_folder);
98
+
99
+ echo '<div class="wrap">';
100
+ echo '<h2>Automatic Plugin Updates</h2><p>';
101
+
102
+ echo '<table class="form-table">';
103
+ echo '<tr valign="top">';
104
+ echo '<th scope="row">'.__('Disable Automatic Plugin Updates For', 'automatic-plugin-updates').'</th>';
105
+ echo '<td><fieldset>';
106
+ echo '<form action="options-general.php?page=automatic-plugin-updates" method="post">';
107
+ foreach ($current_plugins as $key => $val) {
108
+ echo '<input type="checkbox" name="';
109
+ echo $key;
110
+ echo '"';
111
+ if (isset($excluded_plugins) && in_array ($key, $excluded_plugins))
112
+ echo 'checked ';
113
+ echo '><label for="';
114
+ echo $key;
115
+ echo '">';
116
+ echo $val[Name];
117
+ echo '</label><br><br>';
118
+ }
119
+ echo '</fieldset></td>';
120
+ echo '</tr>';
121
+ echo '</table>';
122
+
123
+ echo '<table class="form-table">';
124
+ echo '<tr valign="top">';
125
+ echo '<th scope="row"><label for="send-email">'.__('Send Email for Automatic Updates', 'automatic-plugin-updates' ).'</label></th>';
126
+ echo '<td><fieldset>';
127
+ echo '<select name="send-email"><option value="enabled">';
128
+ echo __('Enabled', 'automatic-plugin-updates' );
129
+ echo '</option><option value="disabled"';
130
+ if ( get_option('automatic_plugin_updates_send_emails') && (get_option('automatic_plugin_updates_send_emails')=='disabled') )
131
+ echo 'selected';
132
+ echo '>';
133
+ echo __('Disabled', 'automatic-plugin-updates' );
134
+ echo '</option></select>';
135
+ echo '</fieldset></td>';
136
+ echo '</tr>';
137
+ echo '</table>';
138
+
139
+
140
+ wp_nonce_field('automatic_plugin_updates','automatic_plugin_updates');
141
+ echo '<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes" /></p>';
142
+ echo '</form> ';
143
+
144
+ }
145
+
146
+ //Adds settings link on Installed Plugins page
147
+ function automatic_plugin_updates_settings_link($links) {
148
+ $diagnostic_test = '<a href="options-general.php?page=automatic-plugin-updates">'.__( 'Settings', 'automatic-plugin-updates' ).'</a>';
149
+ array_unshift( $links, $diagnostic_test );
150
+ return $links;
151
+ }
152
+
153
+ $plugin = plugin_basename(__FILE__);
154
+ add_filter( "plugin_action_links_$plugin", 'automatic_plugin_updates_settings_link' );
languages/automatic-plugin-updates.pot ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Automatic Plugin Updates\n"
4
+ "Report-Msgid-Bugs-To: http://www.whitefirdesign.com/automatic-plugin-updates\n"
5
+ "POT-Creation-Date: 2014-04-07 13:30-0700\n"
6
+ "PO-Revision-Date: 2014-04-07 15:43-0300\n"
7
+ "Last-Translator: White Fir Design <contact@whitefirdesign.com>\n"
8
+ "Language-Team: White Fir Design <contact@whitefirdesign.com>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+
13
+ #. Description of the plugin/theme
14
+ msgid "Enables automatic background updates of plugins. Supports excluding selected plugins from being automatically updated."
15
+ msgstr ""
16
+
17
+ #: automatic-plugin-updates.php:104
18
+ msgid "Disable Automatic Plugin Updates For"
19
+ msgstr ""
20
+
21
+ #: automatic-plugin-updates.php:125
22
+ msgid "Send Email for Automatic Updates"
23
+ msgstr ""
24
+
25
+ #: automatic-plugin-updates.php:128
26
+ msgid "Enabled"
27
+ msgstr ""
28
+
29
+ #: automatic-plugin-updates.php:133
30
+ msgid "Disabled"
31
+ msgstr ""
32
+
readme.txt ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Automatic Plugin Updates ===
2
+ Contributors: WhiteFirDesign
3
+ Tags: plugins, updates, automatic updates
4
+ Requires at least: 3.8
5
+ Tested up to: 3.9
6
+ Stable tag: trunk
7
+ License: GPLv2
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Enables automatic background updates of plugins. Supports excluding selected plugins from being automatically updated.
11
+
12
+ == Description ==
13
+ This plugin turns on automatic background updates for plugins.
14
+
15
+ If you have plugins that you don't want automatically updated those can be excluded from being automatically updated on the settings page for this plugin. The plugin also enables email alerts being sent for automatic plugin updates.
16
+
17
+ == Installation ==
18
+
19
+ 1. Copy plugin files to the plugins folder.
20
+
21
+ 2. Activate the plugin.
22
+
23
+ == Screenshots ==
24
+
25
+ 1. Settings Page
26
+
27
+ == Changelog ==
28
+
29
+ = 1.0 =
30
+ * Initial release
screenshot-1.png ADDED
Binary file
uninstall.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ if( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') )
3
+ exit;
4
+ delete_option('automatic_plugin_updates_excluded_plugins');
5
+ delete_option('automatic_plugin_updates_send_emails');