Version Description
Download this release
Release Info
Developer | l3rady |
Plugin | WP Updates Notifier |
Version | 1.4.4 |
Comparing to | |
See all releases |
Code changes from version 1.4.3 to 1.4.4
- readme.txt +8 -3
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
- wp-updates-notifier.php +123 -119
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: l3rady, eherman24
|
|
3 |
Donate link: http://l3rady.com/donate
|
4 |
Tags: admin, theme, monitor, plugin, notification, upgrade, security
|
5 |
Requires at least: 3.1
|
6 |
-
Tested up to: 4.3
|
7 |
-
Stable tag: 1.4.
|
8 |
License: GPLv3 or later
|
9 |
|
10 |
Sends email to notify you if there are any updates for your WordPress site. Can notify about core, plugin and theme updates.
|
@@ -54,6 +54,11 @@ This plugin is a fork of [Update Notifier](http://wordpress.org/extend/plugins/u
|
|
54 |
|
55 |
== Changelog ==
|
56 |
|
|
|
|
|
|
|
|
|
|
|
57 |
= 1.4.3 =
|
58 |
* Repaired all PHP errors being thrown
|
59 |
* Two new filters added to allow you to alter the email content (sc_wpun_email_subject, sc_wpun_email_content - see readme.txt for examples)
|
@@ -142,4 +147,4 @@ function alter_wp_updates_notifier_email_content( $message ) {
|
|
142 |
return $message;
|
143 |
}
|
144 |
add_filter( 'sc_wpun_email_content', 'alter_wp_updates_notifier_email_content' );
|
145 |
-
`
|
3 |
Donate link: http://l3rady.com/donate
|
4 |
Tags: admin, theme, monitor, plugin, notification, upgrade, security
|
5 |
Requires at least: 3.1
|
6 |
+
Tested up to: 4.5.3
|
7 |
+
Stable tag: 1.4.4
|
8 |
License: GPLv3 or later
|
9 |
|
10 |
Sends email to notify you if there are any updates for your WordPress site. Can notify about core, plugin and theme updates.
|
54 |
|
55 |
== Changelog ==
|
56 |
|
57 |
+
= 1.4.4=
|
58 |
+
* Avoid PHP Strict notices
|
59 |
+
* PHP 7 compatibility
|
60 |
+
* Minor cleanup on some internal code
|
61 |
+
|
62 |
= 1.4.3 =
|
63 |
* Repaired all PHP errors being thrown
|
64 |
* Two new filters added to allow you to alter the email content (sc_wpun_email_subject, sc_wpun_email_content - see readme.txt for examples)
|
147 |
return $message;
|
148 |
}
|
149 |
add_filter( 'sc_wpun_email_content', 'alter_wp_updates_notifier_email_content' );
|
150 |
+
`
|
screenshot-1.jpg
DELETED
Binary file
|
screenshot-2.jpg
DELETED
Binary file
|
wp-updates-notifier.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP Updates Notifier
|
|
4 |
Plugin URI: https://github.com/l3rady/wp-updates-notifier
|
5 |
Description: Sends email to notify you if there are any updates for your WordPress site. Can notify about core, plugin and theme updates.
|
6 |
Contributors: l3rady, eherman24
|
7 |
-
Version: 1.4.
|
8 |
Author: Scott Cariss
|
9 |
Author URI: http://l3rady.com/
|
10 |
Text Domain: wp-updates-notifier
|
@@ -39,29 +39,38 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
39 |
const OPT_VERSION = "5.0";
|
40 |
const CRON_NAME = "sc_wpun_update_check";
|
41 |
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
// Check settings are up to date
|
44 |
-
|
45 |
// Create Activation and Deactivation Hooks
|
46 |
-
register_activation_hook( __FILE__, array(
|
47 |
-
register_deactivation_hook( __FILE__, array(
|
48 |
// Internationalization
|
49 |
load_plugin_textdomain( 'wp-updates-notifier', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
50 |
// Add Filters
|
51 |
-
add_filter( 'plugin_action_links', array(
|
52 |
-
add_filter( 'sc_wpun_plugins_need_update', array(
|
53 |
-
add_filter( 'sc_wpun_themes_need_update', array(
|
54 |
-
add_filter( 'auto_core_update_email', array(
|
55 |
// Add Actions
|
56 |
-
add_action( 'admin_menu', array(
|
57 |
-
add_action( 'admin_init', array(
|
58 |
-
add_action( 'admin_init', array(
|
59 |
-
add_action( 'admin_init', array(
|
60 |
-
add_action( 'sc_wpun_enable_cron', array(
|
61 |
-
add_action( 'sc_wpun_disable_cron', array(
|
62 |
-
add_action( self::CRON_NAME, array(
|
63 |
-
add_action( 'wp_ajax_sc_wpun_check', array(
|
64 |
-
add_action( 'wp_ajax_nopriv_sc_wpun_check', array(
|
65 |
}
|
66 |
|
67 |
/**
|
@@ -71,8 +80,8 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
71 |
*
|
72 |
* @return void
|
73 |
*/
|
74 |
-
private
|
75 |
-
$current_ver =
|
76 |
if ( self::OPT_VERSION != $current_ver ) { // is the version the same as this plugin?
|
77 |
$options = (array) get_option( self::OPT_FIELD ); // get current settings from DB
|
78 |
$defaults = array( // Here are our default values for this plugin
|
@@ -96,8 +105,8 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
96 |
$options = array_intersect_key( $options, $defaults );
|
97 |
// Merge current settings with defaults. Basically adding any new settings with defaults that we dont have.
|
98 |
$options = array_merge( $defaults, $options );
|
99 |
-
|
100 |
-
|
101 |
}
|
102 |
}
|
103 |
|
@@ -110,7 +119,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
110 |
*
|
111 |
* @return bool|mixed True or false if setting or an array of settings if getting
|
112 |
*/
|
113 |
-
private
|
114 |
if ( $settings === false ) {
|
115 |
return apply_filters( 'sc_wpun_get_options_filter', get_option( $field ), $field );
|
116 |
}
|
@@ -124,7 +133,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
124 |
*
|
125 |
* @return void
|
126 |
*/
|
127 |
-
public
|
128 |
do_action( "sc_wpun_enable_cron" ); // Enable cron
|
129 |
}
|
130 |
|
@@ -134,7 +143,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
134 |
*
|
135 |
* @return void
|
136 |
*/
|
137 |
-
public
|
138 |
do_action( "sc_wpun_disable_cron" ); // Disable cron
|
139 |
}
|
140 |
|
@@ -147,7 +156,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
147 |
* @return void
|
148 |
*/
|
149 |
public function enable_cron( $manual_interval = false ) {
|
150 |
-
$options =
|
151 |
$currentSchedule = wp_get_schedule( self::CRON_NAME ); // find if a schedule already exists
|
152 |
|
153 |
// if a manual cron interval is set, use this
|
@@ -165,7 +174,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
165 |
}
|
166 |
|
167 |
// check the cron setting is valid
|
168 |
-
if ( !in_array( $options['frequency'],
|
169 |
return;
|
170 |
}
|
171 |
|
@@ -196,12 +205,8 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
196 |
*
|
197 |
* @return array $links
|
198 |
*/
|
199 |
-
public
|
200 |
-
|
201 |
-
if ( !$this_plugin ) {
|
202 |
-
$this_plugin = plugin_basename( __FILE__ );
|
203 |
-
}
|
204 |
-
if ( $file == $this_plugin ) {
|
205 |
$settings_link = '<a href="' . admin_url( 'options-general.php?page=wp-updates-notifier' ) . '">' . __( "Settings", "wp-updates-notifier" ) . '</a>';
|
206 |
array_unshift( $links, $settings_link );
|
207 |
}
|
@@ -216,17 +221,17 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
216 |
* @return void
|
217 |
*/
|
218 |
public function do_update_check() {
|
219 |
-
$options =
|
220 |
$message = ""; // start with a blank message
|
221 |
-
$core_updated =
|
222 |
if ( 0 != $options['notify_plugins'] ) { // are we to check for plugin updates?
|
223 |
-
$plugins_updated =
|
224 |
}
|
225 |
else {
|
226 |
$plugins_updated = false; // no plugin updates
|
227 |
}
|
228 |
if ( 0 != $options['notify_themes'] ) { // are we to check for theme updates?
|
229 |
-
$themes_updated =
|
230 |
}
|
231 |
else {
|
232 |
$themes_updated = false; // no theme updates
|
@@ -234,10 +239,10 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
234 |
if ( $core_updated || $plugins_updated || $themes_updated ) { // Did anything come back as need updating?
|
235 |
$message = __( "There are updates available for your WordPress site:", "wp-updates-notifier" ) . "\n" . $message . "\n";
|
236 |
$message .= sprintf( __( "Please visit %s to update.", "wp-updates-notifier" ), admin_url( 'update-core.php' ) );
|
237 |
-
|
238 |
}
|
239 |
|
240 |
-
|
241 |
}
|
242 |
|
243 |
|
@@ -248,9 +253,9 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
248 |
*
|
249 |
* @return bool
|
250 |
*/
|
251 |
-
private
|
252 |
global $wp_version;
|
253 |
-
$settings =
|
254 |
do_action( "wp_version_check" ); // force WP to check its core for updates
|
255 |
$update_core = get_site_transient( "update_core" ); // get information of updates
|
256 |
if ( 'upgrade' == $update_core->updates[0]->response ) { // is WP core update available?
|
@@ -260,7 +265,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
260 |
$old_core_ver = $wp_version; // the old WP core version
|
261 |
$message .= "\n" . sprintf( __( "WP-Core: WordPress is out of date. Please update from version %s to %s", "wp-updates-notifier" ), $old_core_ver, $new_core_ver ) . "\n";
|
262 |
$settings['notified']['core'] = $new_core_ver; // set core version we are notifying about
|
263 |
-
|
264 |
return true; // we have updates so return true
|
265 |
}
|
266 |
else {
|
@@ -268,7 +273,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
268 |
}
|
269 |
}
|
270 |
$settings['notified']['core'] = ""; // no updates lets set this nothing
|
271 |
-
|
272 |
return false; // no updates return false
|
273 |
}
|
274 |
|
@@ -281,10 +286,10 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
281 |
*
|
282 |
* @return bool
|
283 |
*/
|
284 |
-
private
|
285 |
global $wp_version;
|
286 |
$cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
|
287 |
-
$settings =
|
288 |
do_action( "wp_update_plugins" ); // force WP to check plugins for updates
|
289 |
$update_plugins = get_site_transient( 'update_plugins' ); // get information of updates
|
290 |
if ( !empty( $update_plugins->response ) ) { // any plugin updates available?
|
@@ -316,14 +321,14 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
316 |
$message .= "\t" . sprintf( __( "Compatibility: %s", "wp-updates-notifier" ), $compat ) . "\n";
|
317 |
$settings['notified']['plugin'][$key] = $data->new_version; // set plugin version we are notifying about
|
318 |
}
|
319 |
-
|
320 |
return true; // we have plugin updates return true
|
321 |
}
|
322 |
}
|
323 |
else {
|
324 |
if ( 0 != count( $settings['notified']['plugin'] ) ) { // is there any plugin notifications?
|
325 |
$settings['notified']['plugin'] = array(); // set plugin notifications to empty as all plugins up-to-date
|
326 |
-
|
327 |
}
|
328 |
}
|
329 |
return false; // No plugin updates so return false
|
@@ -339,7 +344,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
339 |
* @return bool
|
340 |
*/
|
341 |
private function themes_update_check( &$message, $allOrActive ) {
|
342 |
-
$settings =
|
343 |
do_action( "wp_update_themes" ); // force WP to check for theme updates
|
344 |
$update_themes = get_site_transient( 'update_themes' ); // get information of updates
|
345 |
if ( !empty( $update_themes->response ) ) { // any theme updates available?
|
@@ -355,14 +360,14 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
355 |
$message .= "\n" . sprintf( __( "Theme: %s is out of date. Please update from version %s to %s", "wp-updates-notifier" ), $theme_info['Name'], $theme_info['Version'], $data['new_version'] ) . "\n";
|
356 |
$settings['notified']['theme'][$key] = $data['new_version']; // set theme version we are notifying about
|
357 |
}
|
358 |
-
|
359 |
return true; // we have theme updates return true
|
360 |
}
|
361 |
}
|
362 |
else {
|
363 |
if ( 0 != count( $settings['notified']['theme'] ) ) { // is there any theme notifications?
|
364 |
$settings['notified']['theme'] = array(); // set theme notifications to empty as all themes up-to-date
|
365 |
-
|
366 |
}
|
367 |
}
|
368 |
return false; // No theme updates so return false
|
@@ -377,7 +382,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
377 |
* @return array $plugins_need_update
|
378 |
*/
|
379 |
public function check_plugins_against_notified( $plugins_need_update ) {
|
380 |
-
$settings =
|
381 |
foreach ( $plugins_need_update as $key => $data ) { // loop through plugins that need update
|
382 |
if ( isset( $settings['notified']['plugin'][$key] ) ) { // has this plugin been notified before?
|
383 |
if ( $data->new_version == $settings['notified']['plugin'][$key] ) { // does this plugin version match that of the one that's been notified?
|
@@ -397,7 +402,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
397 |
* @return array $themes_need_update
|
398 |
*/
|
399 |
public function check_themes_against_notified( $themes_need_update ) {
|
400 |
-
$settings =
|
401 |
foreach ( $themes_need_update as $key => $data ) { // loop through themes that need update
|
402 |
if ( isset( $settings['notified']['theme'][$key] ) ) { // has this theme been notified before?
|
403 |
if ( $data['new_version'] == $settings['notified']['theme'][$key] ) { // does this theme version match that of the one that's been notified?
|
@@ -417,35 +422,35 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
417 |
* @return void
|
418 |
*/
|
419 |
public function send_notification_email( $message ) {
|
420 |
-
$settings =
|
421 |
$subject = sprintf( __( "WP Updates Notifier: Updates Available @ %s", "wp-updates-notifier" ), home_url() );
|
422 |
-
add_filter( 'wp_mail_from', array(
|
423 |
-
add_filter( 'wp_mail_from_name', array(
|
424 |
-
add_filter( 'wp_mail_content_type', array(
|
425 |
wp_mail( $settings['notify_to'], apply_filters( 'sc_wpun_email_subject', $subject ), apply_filters( 'sc_wpun_email_content', $message ) ); // send email
|
426 |
-
remove_filter( 'wp_mail_from', array(
|
427 |
-
remove_filter( 'wp_mail_from_name', array(
|
428 |
-
remove_filter( 'wp_mail_content_type', array(
|
429 |
}
|
430 |
|
431 |
public function sc_wpun_wp_mail_from() {
|
432 |
-
$settings =
|
433 |
return $settings['notify_from'];
|
434 |
}
|
435 |
|
436 |
-
public
|
437 |
return __( "WP Updates Notifier", "wp-updates-notifier" );
|
438 |
}
|
439 |
|
440 |
-
public
|
441 |
return "text/plain";
|
442 |
}
|
443 |
|
444 |
|
445 |
private function log_last_check_time() {
|
446 |
-
$options =
|
447 |
$options['last_check_time'] = current_time( "timestamp" );
|
448 |
-
|
449 |
}
|
450 |
|
451 |
/**
|
@@ -456,7 +461,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
456 |
* @return array Modified array containing the new email address.
|
457 |
*/
|
458 |
public function filter_auto_core_update_email( $email ) {
|
459 |
-
$options =
|
460 |
|
461 |
if ( 0 != $options['notify_automatic'] ) {
|
462 |
if ( ! empty( $options['notify_to'] ) ) { // If an email address has been set, override the WordPress default.
|
@@ -464,7 +469,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
464 |
}
|
465 |
|
466 |
if ( ! empty( $options['notify_from'] ) ) { // If an email address has been set, override the WordPress default.
|
467 |
-
$email['headers'][] = 'From: ' .
|
468 |
}
|
469 |
}
|
470 |
|
@@ -477,8 +482,8 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
477 |
*
|
478 |
* @return void
|
479 |
*/
|
480 |
-
public
|
481 |
-
$settings =
|
482 |
if ( 1 == $settings['hide_updates'] ) { // is this enabled?
|
483 |
if ( !current_user_can( 'update_plugins' ) ) { // can the current user update plugins?
|
484 |
remove_action( 'admin_notices', 'update_nag', 3 ); // no they cannot so remove the nag for them.
|
@@ -490,39 +495,39 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
490 |
/**
|
491 |
* Adds JS to admin settings screen for this plugin
|
492 |
*/
|
493 |
-
public
|
494 |
wp_register_script( 'wp_updates_monitor_js_function', plugins_url( 'js/function.js', __FILE__ ), array( 'jquery' ), '1.0', true );
|
495 |
}
|
496 |
|
497 |
|
498 |
-
|
499 |
-
$options =
|
500 |
|
501 |
if ( !isset( $_GET['sc_wpun_key'] ) || $options['security_key'] != $_GET['sc_wpun_key'] || "other" != $options['cron_method'] ) {
|
502 |
return;
|
503 |
}
|
504 |
|
505 |
-
|
506 |
|
507 |
die( __( "Successfully checked for updates.", "wp-updates-notifier" ) );
|
508 |
}
|
509 |
|
510 |
|
511 |
-
private
|
512 |
$schedules = wp_get_schedules();
|
513 |
-
uasort( $schedules, array(
|
514 |
return $schedules;
|
515 |
}
|
516 |
|
517 |
|
518 |
-
private
|
519 |
-
$intervals = array_keys(
|
520 |
$intervals[] = "manual";
|
521 |
return $intervals;
|
522 |
}
|
523 |
|
524 |
|
525 |
-
private
|
526 |
return $a['interval'] - $b['interval'];
|
527 |
}
|
528 |
|
@@ -533,17 +538,17 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
533 |
* I'm not going to comment any of this as its all pretty
|
534 |
* much straight forward use of the WordPress Settings API.
|
535 |
*/
|
536 |
-
public
|
537 |
-
$page = add_options_page( 'Updates Notifier', 'Updates Notifier', 'manage_options', 'wp-updates-notifier', array(
|
538 |
-
add_action( "admin_print_scripts-{$page}", array(
|
539 |
}
|
540 |
|
541 |
-
public
|
542 |
wp_enqueue_script( 'wp_updates_monitor_js_function' );
|
543 |
}
|
544 |
|
545 |
-
public
|
546 |
-
$options =
|
547 |
$date_format = get_option( 'date_format' );
|
548 |
$time_format = get_option( 'time_format' );
|
549 |
?>
|
@@ -583,21 +588,21 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
583 |
<?php
|
584 |
}
|
585 |
|
586 |
-
public
|
587 |
-
register_setting( self::OPT_FIELD, self::OPT_FIELD, array(
|
588 |
-
add_settings_section( "sc_wpun_settings_main", __( "Settings", "wp-updates-notifier" ), array(
|
589 |
-
add_settings_field( "sc_wpun_settings_main_cron_method", __( "Cron Method", "wp-updates-notifier" ), array(
|
590 |
-
add_settings_field( "sc_wpun_settings_main_frequency", __( "Frequency to check", "wp-updates-notifier" ), array(
|
591 |
-
add_settings_field( "sc_wpun_settings_main_notify_to", __( "Notify email to", "wp-updates-notifier" ), array(
|
592 |
-
add_settings_field( "sc_wpun_settings_main_notify_from", __( "Notify email from", "wp-updates-notifier" ), array(
|
593 |
-
add_settings_field( "sc_wpun_settings_main_notify_plugins", __( "Notify about plugin updates?", "wp-updates-notifier" ), array(
|
594 |
-
add_settings_field( "sc_wpun_settings_main_notify_themes", __( "Notify about theme updates?", "wp-updates-notifier" ), array(
|
595 |
-
add_settings_field( "sc_wpun_settings_main_notify_automatic", __( "Notify automatic core updates to this address?", "wp-updates-notifier" ), array(
|
596 |
-
add_settings_field( "sc_wpun_settings_main_hide_updates", __( "Hide core WP update nag from non-admin users?", "wp-updates-notifier" ), array(
|
597 |
}
|
598 |
|
599 |
public function sc_wpun_settings_validate( $input ) {
|
600 |
-
$valid =
|
601 |
|
602 |
if ( isset( $input['cron_method'] ) && in_array( $input['cron_method'], array( "wordpress", "other" ) ) ) {
|
603 |
$valid['cron_method'] = $input['cron_method'];
|
@@ -610,7 +615,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
610 |
$input['frequency'] = "manual";
|
611 |
}
|
612 |
|
613 |
-
if ( in_array( $input['frequency'],
|
614 |
$valid['frequency'] = $input['frequency'];
|
615 |
do_action( "sc_wpun_enable_cron", $input['frequency'] );
|
616 |
}
|
@@ -680,7 +685,7 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
680 |
}
|
681 |
|
682 |
if ( isset( $_POST['submitwithemail'] ) ) {
|
683 |
-
add_filter( 'pre_set_transient_settings_errors', array(
|
684 |
}
|
685 |
|
686 |
if ( isset( $input['cron_method'] ) && in_array( $input['cron_method'], array( "wordpress", "other" ) ) ) {
|
@@ -693,17 +698,17 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
693 |
return $valid;
|
694 |
}
|
695 |
|
696 |
-
public
|
697 |
if ( isset( $settings_errors[0]['type'] ) && $settings_errors[0]['type'] == "updated" ) {
|
698 |
-
|
699 |
}
|
700 |
}
|
701 |
|
702 |
-
public
|
703 |
}
|
704 |
|
705 |
-
public
|
706 |
-
$options =
|
707 |
?>
|
708 |
<select name="<?php echo self::OPT_FIELD; ?>[cron_method]">
|
709 |
<option value="wordpress" <?php selected( $options['cron_method'], "wordpress" ); ?>><?php _e( "WordPress Cron", "wp-updates-notifier" ); ?></option>
|
@@ -717,32 +722,32 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
717 |
<?php
|
718 |
}
|
719 |
|
720 |
-
public
|
721 |
-
$options =
|
722 |
?>
|
723 |
<select id="sc_wpun_settings_main_frequency" name="<?php echo self::OPT_FIELD; ?>[frequency]">
|
724 |
-
<?php foreach (
|
725 |
<option value="<?php echo $k; ?>" <?php selected( $options['frequency'], $k ); ?>><?php echo $v['display']; ?></option>
|
726 |
<?php endforeach; ?>
|
727 |
<select>
|
728 |
<?php
|
729 |
}
|
730 |
|
731 |
-
public
|
732 |
-
$options =
|
733 |
?>
|
734 |
<input id="sc_wpun_settings_main_notify_to" class="regular-text" name="<?php echo self::OPT_FIELD; ?>[notify_to]" value="<?php echo $options['notify_to']; ?>" />
|
735 |
<span class="description"><?php _e( "Separate multiple email address with a comma (,)", "wp-updates-notifier" ); ?></span><?php
|
736 |
}
|
737 |
|
738 |
-
public
|
739 |
-
$options =
|
740 |
?>
|
741 |
<input id="sc_wpun_settings_main_notify_from" class="regular-text" name="<?php echo self::OPT_FIELD; ?>[notify_from]" value="<?php echo $options['notify_from']; ?>" /><?php
|
742 |
}
|
743 |
|
744 |
-
public
|
745 |
-
$options =
|
746 |
?>
|
747 |
<label><input name="<?php echo self::OPT_FIELD; ?>[notify_plugins]" type="radio" value="0" <?php checked( $options['notify_plugins'], 0 ); ?> /> <?php _e( "No", "wp-updates-notifier" ); ?>
|
748 |
</label><br />
|
@@ -753,8 +758,8 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
753 |
<?php
|
754 |
}
|
755 |
|
756 |
-
public
|
757 |
-
$options =
|
758 |
?>
|
759 |
<label><input name="<?php echo self::OPT_FIELD; ?>[notify_themes]" type="radio" value="0" <?php checked( $options['notify_themes'], 0 ); ?> /> <?php _e( "No", "wp-updates-notifier" ); ?>
|
760 |
</label><br />
|
@@ -765,16 +770,16 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
765 |
<?php
|
766 |
}
|
767 |
|
768 |
-
public
|
769 |
-
$options =
|
770 |
?>
|
771 |
<label><input name="<?php echo self::OPT_FIELD; ?>[notify_automatic]" type="checkbox" value="1" <?php checked( $options['notify_automatic'], 1 ); ?> /> <?php _e( "Yes", "wp-updates-notifier" ); ?>
|
772 |
</label>
|
773 |
<?php
|
774 |
}
|
775 |
|
776 |
-
public
|
777 |
-
$options =
|
778 |
?>
|
779 |
<select id="sc_wpun_settings_main_hide_updates" name="<?php echo self::OPT_FIELD; ?>[hide_updates]">
|
780 |
<option value="1" <?php selected( $options['hide_updates'], 1 ); ?>><?php _e( "Yes", "wp-updates-notifier" ); ?></option>
|
@@ -786,5 +791,4 @@ if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
|
|
786 |
}
|
787 |
}
|
788 |
|
789 |
-
sc_WPUpdatesNotifier
|
790 |
-
?>
|
4 |
Plugin URI: https://github.com/l3rady/wp-updates-notifier
|
5 |
Description: Sends email to notify you if there are any updates for your WordPress site. Can notify about core, plugin and theme updates.
|
6 |
Contributors: l3rady, eherman24
|
7 |
+
Version: 1.4.4
|
8 |
Author: Scott Cariss
|
9 |
Author URI: http://l3rady.com/
|
10 |
Text Domain: wp-updates-notifier
|
39 |
const OPT_VERSION = "5.0";
|
40 |
const CRON_NAME = "sc_wpun_update_check";
|
41 |
|
42 |
+
static $didInit = false;
|
43 |
+
|
44 |
+
public function __construct() {
|
45 |
+
if (!self::$didInit) {
|
46 |
+
$this->init();
|
47 |
+
self::$didInit = true;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
private function init() {
|
52 |
// Check settings are up to date
|
53 |
+
$this->settingsUpToDate();
|
54 |
// Create Activation and Deactivation Hooks
|
55 |
+
register_activation_hook( __FILE__, array( $this, 'activate' ) );
|
56 |
+
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
|
57 |
// Internationalization
|
58 |
load_plugin_textdomain( 'wp-updates-notifier', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
59 |
// Add Filters
|
60 |
+
add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 ); // Add settings link to plugin in plugin list
|
61 |
+
add_filter( 'sc_wpun_plugins_need_update', array( $this, 'check_plugins_against_notified' ) ); // Filter out plugins that need update if already been notified
|
62 |
+
add_filter( 'sc_wpun_themes_need_update', array( $this, 'check_themes_against_notified' ) ); // Filter out themes that need update if already been notified
|
63 |
+
add_filter( 'auto_core_update_email', array( $this, 'filter_auto_core_update_email' ), 1 ); // Filter the background update notification email.
|
64 |
// Add Actions
|
65 |
+
add_action( 'admin_menu', array( $this, 'admin_settings_menu' ) ); // Add menu to options
|
66 |
+
add_action( 'admin_init', array( $this, 'admin_settings_init' ) ); // Add admin init functions
|
67 |
+
add_action( 'admin_init', array( $this, 'remove_update_nag_for_nonadmins' ) ); // See if we remove update nag for non admins
|
68 |
+
add_action( 'admin_init', array( $this, 'admin_register_scripts_styles' ) );
|
69 |
+
add_action( 'sc_wpun_enable_cron', array( $this, 'enable_cron' ) ); // action to enable cron
|
70 |
+
add_action( 'sc_wpun_disable_cron', array( $this, 'disable_cron' ) ); // action to disable cron
|
71 |
+
add_action( self::CRON_NAME, array( $this, 'do_update_check' ) ); // action to link cron task to actual task
|
72 |
+
add_action( 'wp_ajax_sc_wpun_check', array( $this, 'sc_wpun_check' ) ); // Admin ajax hook for remote cron method.
|
73 |
+
add_action( 'wp_ajax_nopriv_sc_wpun_check', array( $this, 'sc_wpun_check' ) ); // Admin ajax hook for remote cron method.
|
74 |
}
|
75 |
|
76 |
/**
|
80 |
*
|
81 |
* @return void
|
82 |
*/
|
83 |
+
private function settingsUpToDate() {
|
84 |
+
$current_ver = $this->getSetOptions( self::OPT_VERSION_FIELD ); // Get current plugin version
|
85 |
if ( self::OPT_VERSION != $current_ver ) { // is the version the same as this plugin?
|
86 |
$options = (array) get_option( self::OPT_FIELD ); // get current settings from DB
|
87 |
$defaults = array( // Here are our default values for this plugin
|
105 |
$options = array_intersect_key( $options, $defaults );
|
106 |
// Merge current settings with defaults. Basically adding any new settings with defaults that we dont have.
|
107 |
$options = array_merge( $defaults, $options );
|
108 |
+
$this->getSetOptions( self::OPT_FIELD, $options ); // update settings
|
109 |
+
$this->getSetOptions( self::OPT_VERSION_FIELD, self::OPT_VERSION ); // update settings version
|
110 |
}
|
111 |
}
|
112 |
|
119 |
*
|
120 |
* @return bool|mixed True or false if setting or an array of settings if getting
|
121 |
*/
|
122 |
+
private function getSetOptions( $field, $settings = false ) {
|
123 |
if ( $settings === false ) {
|
124 |
return apply_filters( 'sc_wpun_get_options_filter', get_option( $field ), $field );
|
125 |
}
|
133 |
*
|
134 |
* @return void
|
135 |
*/
|
136 |
+
public function activate() {
|
137 |
do_action( "sc_wpun_enable_cron" ); // Enable cron
|
138 |
}
|
139 |
|
143 |
*
|
144 |
* @return void
|
145 |
*/
|
146 |
+
public function deactivate() {
|
147 |
do_action( "sc_wpun_disable_cron" ); // Disable cron
|
148 |
}
|
149 |
|
156 |
* @return void
|
157 |
*/
|
158 |
public function enable_cron( $manual_interval = false ) {
|
159 |
+
$options = $this->getSetOptions( self::OPT_FIELD ); // Get settings
|
160 |
$currentSchedule = wp_get_schedule( self::CRON_NAME ); // find if a schedule already exists
|
161 |
|
162 |
// if a manual cron interval is set, use this
|
174 |
}
|
175 |
|
176 |
// check the cron setting is valid
|
177 |
+
if ( !in_array( $options['frequency'], $this->get_intervals() ) ) {
|
178 |
return;
|
179 |
}
|
180 |
|
205 |
*
|
206 |
* @return array $links
|
207 |
*/
|
208 |
+
public function plugin_action_links( $links, $file ) {
|
209 |
+
if ( $file == plugin_basename( __FILE__ ) ) {
|
|
|
|
|
|
|
|
|
210 |
$settings_link = '<a href="' . admin_url( 'options-general.php?page=wp-updates-notifier' ) . '">' . __( "Settings", "wp-updates-notifier" ) . '</a>';
|
211 |
array_unshift( $links, $settings_link );
|
212 |
}
|
221 |
* @return void
|
222 |
*/
|
223 |
public function do_update_check() {
|
224 |
+
$options = $this->getSetOptions( self::OPT_FIELD ); // get settings
|
225 |
$message = ""; // start with a blank message
|
226 |
+
$core_updated = $this->core_update_check( $message ); // check the WP core for updates
|
227 |
if ( 0 != $options['notify_plugins'] ) { // are we to check for plugin updates?
|
228 |
+
$plugins_updated = $this->plugins_update_check( $message, $options['notify_plugins'] ); // check for plugin updates
|
229 |
}
|
230 |
else {
|
231 |
$plugins_updated = false; // no plugin updates
|
232 |
}
|
233 |
if ( 0 != $options['notify_themes'] ) { // are we to check for theme updates?
|
234 |
+
$themes_updated = $this->themes_update_check( $message, $options['notify_themes'] ); // check for theme updates
|
235 |
}
|
236 |
else {
|
237 |
$themes_updated = false; // no theme updates
|
239 |
if ( $core_updated || $plugins_updated || $themes_updated ) { // Did anything come back as need updating?
|
240 |
$message = __( "There are updates available for your WordPress site:", "wp-updates-notifier" ) . "\n" . $message . "\n";
|
241 |
$message .= sprintf( __( "Please visit %s to update.", "wp-updates-notifier" ), admin_url( 'update-core.php' ) );
|
242 |
+
$this->send_notification_email( $message ); // send our notification email.
|
243 |
}
|
244 |
|
245 |
+
$this->log_last_check_time();
|
246 |
}
|
247 |
|
248 |
|
253 |
*
|
254 |
* @return bool
|
255 |
*/
|
256 |
+
private function core_update_check( &$message ) {
|
257 |
global $wp_version;
|
258 |
+
$settings = $this->getSetOptions( self::OPT_FIELD ); // get settings
|
259 |
do_action( "wp_version_check" ); // force WP to check its core for updates
|
260 |
$update_core = get_site_transient( "update_core" ); // get information of updates
|
261 |
if ( 'upgrade' == $update_core->updates[0]->response ) { // is WP core update available?
|
265 |
$old_core_ver = $wp_version; // the old WP core version
|
266 |
$message .= "\n" . sprintf( __( "WP-Core: WordPress is out of date. Please update from version %s to %s", "wp-updates-notifier" ), $old_core_ver, $new_core_ver ) . "\n";
|
267 |
$settings['notified']['core'] = $new_core_ver; // set core version we are notifying about
|
268 |
+
$this->getSetOptions( self::OPT_FIELD, $settings ); // update settings
|
269 |
return true; // we have updates so return true
|
270 |
}
|
271 |
else {
|
273 |
}
|
274 |
}
|
275 |
$settings['notified']['core'] = ""; // no updates lets set this nothing
|
276 |
+
$this->getSetOptions( self::OPT_FIELD, $settings ); // update settings
|
277 |
return false; // no updates return false
|
278 |
}
|
279 |
|
286 |
*
|
287 |
* @return bool
|
288 |
*/
|
289 |
+
private function plugins_update_check( &$message, $allOrActive ) {
|
290 |
global $wp_version;
|
291 |
$cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
|
292 |
+
$settings = $this->getSetOptions( self::OPT_FIELD ); // get settings
|
293 |
do_action( "wp_update_plugins" ); // force WP to check plugins for updates
|
294 |
$update_plugins = get_site_transient( 'update_plugins' ); // get information of updates
|
295 |
if ( !empty( $update_plugins->response ) ) { // any plugin updates available?
|
321 |
$message .= "\t" . sprintf( __( "Compatibility: %s", "wp-updates-notifier" ), $compat ) . "\n";
|
322 |
$settings['notified']['plugin'][$key] = $data->new_version; // set plugin version we are notifying about
|
323 |
}
|
324 |
+
$this->getSetOptions( self::OPT_FIELD, $settings ); // save settings
|
325 |
return true; // we have plugin updates return true
|
326 |
}
|
327 |
}
|
328 |
else {
|
329 |
if ( 0 != count( $settings['notified']['plugin'] ) ) { // is there any plugin notifications?
|
330 |
$settings['notified']['plugin'] = array(); // set plugin notifications to empty as all plugins up-to-date
|
331 |
+
$this->getSetOptions( self::OPT_FIELD, $settings ); // save settings
|
332 |
}
|
333 |
}
|
334 |
return false; // No plugin updates so return false
|
344 |
* @return bool
|
345 |
*/
|
346 |
private function themes_update_check( &$message, $allOrActive ) {
|
347 |
+
$settings = $this->getSetOptions( self::OPT_FIELD ); // get settings
|
348 |
do_action( "wp_update_themes" ); // force WP to check for theme updates
|
349 |
$update_themes = get_site_transient( 'update_themes' ); // get information of updates
|
350 |
if ( !empty( $update_themes->response ) ) { // any theme updates available?
|
360 |
$message .= "\n" . sprintf( __( "Theme: %s is out of date. Please update from version %s to %s", "wp-updates-notifier" ), $theme_info['Name'], $theme_info['Version'], $data['new_version'] ) . "\n";
|
361 |
$settings['notified']['theme'][$key] = $data['new_version']; // set theme version we are notifying about
|
362 |
}
|
363 |
+
$this->getSetOptions( self::OPT_FIELD, $settings ); // save settings
|
364 |
return true; // we have theme updates return true
|
365 |
}
|
366 |
}
|
367 |
else {
|
368 |
if ( 0 != count( $settings['notified']['theme'] ) ) { // is there any theme notifications?
|
369 |
$settings['notified']['theme'] = array(); // set theme notifications to empty as all themes up-to-date
|
370 |
+
$this->getSetOptions( self::OPT_FIELD, $settings ); // save settings
|
371 |
}
|
372 |
}
|
373 |
return false; // No theme updates so return false
|
382 |
* @return array $plugins_need_update
|
383 |
*/
|
384 |
public function check_plugins_against_notified( $plugins_need_update ) {
|
385 |
+
$settings = $this->getSetOptions( self::OPT_FIELD ); // get settings
|
386 |
foreach ( $plugins_need_update as $key => $data ) { // loop through plugins that need update
|
387 |
if ( isset( $settings['notified']['plugin'][$key] ) ) { // has this plugin been notified before?
|
388 |
if ( $data->new_version == $settings['notified']['plugin'][$key] ) { // does this plugin version match that of the one that's been notified?
|
402 |
* @return array $themes_need_update
|
403 |
*/
|
404 |
public function check_themes_against_notified( $themes_need_update ) {
|
405 |
+
$settings = $this->getSetOptions( self::OPT_FIELD ); // get settings
|
406 |
foreach ( $themes_need_update as $key => $data ) { // loop through themes that need update
|
407 |
if ( isset( $settings['notified']['theme'][$key] ) ) { // has this theme been notified before?
|
408 |
if ( $data['new_version'] == $settings['notified']['theme'][$key] ) { // does this theme version match that of the one that's been notified?
|
422 |
* @return void
|
423 |
*/
|
424 |
public function send_notification_email( $message ) {
|
425 |
+
$settings = $this->getSetOptions( self::OPT_FIELD ); // get settings
|
426 |
$subject = sprintf( __( "WP Updates Notifier: Updates Available @ %s", "wp-updates-notifier" ), home_url() );
|
427 |
+
add_filter( 'wp_mail_from', array( $this, 'sc_wpun_wp_mail_from' ) ); // add from filter
|
428 |
+
add_filter( 'wp_mail_from_name', array( $this, 'sc_wpun_wp_mail_from_name' ) ); // add from name filter
|
429 |
+
add_filter( 'wp_mail_content_type', array( $this, 'sc_wpun_wp_mail_content_type' ) ); // add content type filter
|
430 |
wp_mail( $settings['notify_to'], apply_filters( 'sc_wpun_email_subject', $subject ), apply_filters( 'sc_wpun_email_content', $message ) ); // send email
|
431 |
+
remove_filter( 'wp_mail_from', array( $this, 'sc_wpun_wp_mail_from' ) ); // remove from filter
|
432 |
+
remove_filter( 'wp_mail_from_name', array( $this, 'sc_wpun_wp_mail_from_name' ) ); // remove from name filter
|
433 |
+
remove_filter( 'wp_mail_content_type', array( $this, 'sc_wpun_wp_mail_content_type' ) ); // remove content type filter
|
434 |
}
|
435 |
|
436 |
public function sc_wpun_wp_mail_from() {
|
437 |
+
$settings = $this->getSetOptions( self::OPT_FIELD );
|
438 |
return $settings['notify_from'];
|
439 |
}
|
440 |
|
441 |
+
public function sc_wpun_wp_mail_from_name() {
|
442 |
return __( "WP Updates Notifier", "wp-updates-notifier" );
|
443 |
}
|
444 |
|
445 |
+
public function sc_wpun_wp_mail_content_type() {
|
446 |
return "text/plain";
|
447 |
}
|
448 |
|
449 |
|
450 |
private function log_last_check_time() {
|
451 |
+
$options = $this->getSetOptions( self::OPT_FIELD );
|
452 |
$options['last_check_time'] = current_time( "timestamp" );
|
453 |
+
$this->getSetOptions( self::OPT_FIELD, $options );
|
454 |
}
|
455 |
|
456 |
/**
|
461 |
* @return array Modified array containing the new email address.
|
462 |
*/
|
463 |
public function filter_auto_core_update_email( $email ) {
|
464 |
+
$options = $this->getSetOptions( self::OPT_FIELD ); // Get settings
|
465 |
|
466 |
if ( 0 != $options['notify_automatic'] ) {
|
467 |
if ( ! empty( $options['notify_to'] ) ) { // If an email address has been set, override the WordPress default.
|
469 |
}
|
470 |
|
471 |
if ( ! empty( $options['notify_from'] ) ) { // If an email address has been set, override the WordPress default.
|
472 |
+
$email['headers'][] = 'From: ' . $this->sc_wpun_wp_mail_from_name() . ' <' . $options['notify_from'] . '>';
|
473 |
}
|
474 |
}
|
475 |
|
482 |
*
|
483 |
* @return void
|
484 |
*/
|
485 |
+
public function remove_update_nag_for_nonadmins() {
|
486 |
+
$settings = $this->getSetOptions( self::OPT_FIELD ); // get settings
|
487 |
if ( 1 == $settings['hide_updates'] ) { // is this enabled?
|
488 |
if ( !current_user_can( 'update_plugins' ) ) { // can the current user update plugins?
|
489 |
remove_action( 'admin_notices', 'update_nag', 3 ); // no they cannot so remove the nag for them.
|
495 |
/**
|
496 |
* Adds JS to admin settings screen for this plugin
|
497 |
*/
|
498 |
+
public function admin_register_scripts_styles() {
|
499 |
wp_register_script( 'wp_updates_monitor_js_function', plugins_url( 'js/function.js', __FILE__ ), array( 'jquery' ), '1.0', true );
|
500 |
}
|
501 |
|
502 |
|
503 |
+
public function sc_wpun_check() {
|
504 |
+
$options = $this->getSetOptions( self::OPT_FIELD ); // get settings
|
505 |
|
506 |
if ( !isset( $_GET['sc_wpun_key'] ) || $options['security_key'] != $_GET['sc_wpun_key'] || "other" != $options['cron_method'] ) {
|
507 |
return;
|
508 |
}
|
509 |
|
510 |
+
$this->do_update_check();
|
511 |
|
512 |
die( __( "Successfully checked for updates.", "wp-updates-notifier" ) );
|
513 |
}
|
514 |
|
515 |
|
516 |
+
private function get_schedules() {
|
517 |
$schedules = wp_get_schedules();
|
518 |
+
uasort( $schedules, array( $this, 'sort_by_interval' ) );
|
519 |
return $schedules;
|
520 |
}
|
521 |
|
522 |
|
523 |
+
private function get_intervals() {
|
524 |
+
$intervals = array_keys( $this->get_schedules() );
|
525 |
$intervals[] = "manual";
|
526 |
return $intervals;
|
527 |
}
|
528 |
|
529 |
|
530 |
+
private function sort_by_interval( $a, $b ) {
|
531 |
return $a['interval'] - $b['interval'];
|
532 |
}
|
533 |
|
538 |
* I'm not going to comment any of this as its all pretty
|
539 |
* much straight forward use of the WordPress Settings API.
|
540 |
*/
|
541 |
+
public function admin_settings_menu() {
|
542 |
+
$page = add_options_page( 'Updates Notifier', 'Updates Notifier', 'manage_options', 'wp-updates-notifier', array( $this, 'settings_page' ) );
|
543 |
+
add_action( "admin_print_scripts-{$page}", array( $this, 'enqueue_plugin_script' ) );
|
544 |
}
|
545 |
|
546 |
+
public function enqueue_plugin_script() {
|
547 |
wp_enqueue_script( 'wp_updates_monitor_js_function' );
|
548 |
}
|
549 |
|
550 |
+
public function settings_page() {
|
551 |
+
$options = $this->getSetOptions( self::OPT_FIELD );
|
552 |
$date_format = get_option( 'date_format' );
|
553 |
$time_format = get_option( 'time_format' );
|
554 |
?>
|
588 |
<?php
|
589 |
}
|
590 |
|
591 |
+
public function admin_settings_init() {
|
592 |
+
register_setting( self::OPT_FIELD, self::OPT_FIELD, array( $this, "sc_wpun_settings_validate" ) ); // Register Main Settings
|
593 |
+
add_settings_section( "sc_wpun_settings_main", __( "Settings", "wp-updates-notifier" ), array( $this, "sc_wpun_settings_main_text" ), "wp-updates-notifier" ); // Make settings main section
|
594 |
+
add_settings_field( "sc_wpun_settings_main_cron_method", __( "Cron Method", "wp-updates-notifier" ), array( $this, "sc_wpun_settings_main_field_cron_method" ), "wp-updates-notifier", "sc_wpun_settings_main" );
|
595 |
+
add_settings_field( "sc_wpun_settings_main_frequency", __( "Frequency to check", "wp-updates-notifier" ), array( $this, "sc_wpun_settings_main_field_frequency" ), "wp-updates-notifier", "sc_wpun_settings_main" );
|
596 |
+
add_settings_field( "sc_wpun_settings_main_notify_to", __( "Notify email to", "wp-updates-notifier" ), array( $this, "sc_wpun_settings_main_field_notify_to" ), "wp-updates-notifier", "sc_wpun_settings_main" );
|
597 |
+
add_settings_field( "sc_wpun_settings_main_notify_from", __( "Notify email from", "wp-updates-notifier" ), array( $this, "sc_wpun_settings_main_field_notify_from" ), "wp-updates-notifier", "sc_wpun_settings_main" );
|
598 |
+
add_settings_field( "sc_wpun_settings_main_notify_plugins", __( "Notify about plugin updates?", "wp-updates-notifier" ), array( $this, "sc_wpun_settings_main_field_notify_plugins" ), "wp-updates-notifier", "sc_wpun_settings_main" );
|
599 |
+
add_settings_field( "sc_wpun_settings_main_notify_themes", __( "Notify about theme updates?", "wp-updates-notifier" ), array( $this, "sc_wpun_settings_main_field_notify_themes" ), "wp-updates-notifier", "sc_wpun_settings_main" );
|
600 |
+
add_settings_field( "sc_wpun_settings_main_notify_automatic", __( "Notify automatic core updates to this address?", "wp-updates-notifier" ), array( $this, "sc_wpun_settings_main_field_notify_automatic" ), "wp-updates-notifier", "sc_wpun_settings_main" );
|
601 |
+
add_settings_field( "sc_wpun_settings_main_hide_updates", __( "Hide core WP update nag from non-admin users?", "wp-updates-notifier" ), array( $this, "sc_wpun_settings_main_field_hide_updates" ), "wp-updates-notifier", "sc_wpun_settings_main" );
|
602 |
}
|
603 |
|
604 |
public function sc_wpun_settings_validate( $input ) {
|
605 |
+
$valid = $this->getSetOptions( self::OPT_FIELD );
|
606 |
|
607 |
if ( isset( $input['cron_method'] ) && in_array( $input['cron_method'], array( "wordpress", "other" ) ) ) {
|
608 |
$valid['cron_method'] = $input['cron_method'];
|
615 |
$input['frequency'] = "manual";
|
616 |
}
|
617 |
|
618 |
+
if ( in_array( $input['frequency'], $this->get_intervals() ) ) {
|
619 |
$valid['frequency'] = $input['frequency'];
|
620 |
do_action( "sc_wpun_enable_cron", $input['frequency'] );
|
621 |
}
|
685 |
}
|
686 |
|
687 |
if ( isset( $_POST['submitwithemail'] ) ) {
|
688 |
+
add_filter( 'pre_set_transient_settings_errors', array( $this, "send_test_email" ) );
|
689 |
}
|
690 |
|
691 |
if ( isset( $input['cron_method'] ) && in_array( $input['cron_method'], array( "wordpress", "other" ) ) ) {
|
698 |
return $valid;
|
699 |
}
|
700 |
|
701 |
+
public function send_test_email( $settings_errors ) {
|
702 |
if ( isset( $settings_errors[0]['type'] ) && $settings_errors[0]['type'] == "updated" ) {
|
703 |
+
$this->send_notification_email( __( "This is a test message from WP Updates Notifier.", "wp-updates-notifier" ) );
|
704 |
}
|
705 |
}
|
706 |
|
707 |
+
public function sc_wpun_settings_main_text() {
|
708 |
}
|
709 |
|
710 |
+
public function sc_wpun_settings_main_field_cron_method() {
|
711 |
+
$options = $this->getSetOptions( self::OPT_FIELD );
|
712 |
?>
|
713 |
<select name="<?php echo self::OPT_FIELD; ?>[cron_method]">
|
714 |
<option value="wordpress" <?php selected( $options['cron_method'], "wordpress" ); ?>><?php _e( "WordPress Cron", "wp-updates-notifier" ); ?></option>
|
722 |
<?php
|
723 |
}
|
724 |
|
725 |
+
public function sc_wpun_settings_main_field_frequency() {
|
726 |
+
$options = $this->getSetOptions( self::OPT_FIELD );
|
727 |
?>
|
728 |
<select id="sc_wpun_settings_main_frequency" name="<?php echo self::OPT_FIELD; ?>[frequency]">
|
729 |
+
<?php foreach ( $this->get_schedules() as $k => $v ): ?>
|
730 |
<option value="<?php echo $k; ?>" <?php selected( $options['frequency'], $k ); ?>><?php echo $v['display']; ?></option>
|
731 |
<?php endforeach; ?>
|
732 |
<select>
|
733 |
<?php
|
734 |
}
|
735 |
|
736 |
+
public function sc_wpun_settings_main_field_notify_to() {
|
737 |
+
$options = $this->getSetOptions( self::OPT_FIELD );
|
738 |
?>
|
739 |
<input id="sc_wpun_settings_main_notify_to" class="regular-text" name="<?php echo self::OPT_FIELD; ?>[notify_to]" value="<?php echo $options['notify_to']; ?>" />
|
740 |
<span class="description"><?php _e( "Separate multiple email address with a comma (,)", "wp-updates-notifier" ); ?></span><?php
|
741 |
}
|
742 |
|
743 |
+
public function sc_wpun_settings_main_field_notify_from() {
|
744 |
+
$options = $this->getSetOptions( self::OPT_FIELD );
|
745 |
?>
|
746 |
<input id="sc_wpun_settings_main_notify_from" class="regular-text" name="<?php echo self::OPT_FIELD; ?>[notify_from]" value="<?php echo $options['notify_from']; ?>" /><?php
|
747 |
}
|
748 |
|
749 |
+
public function sc_wpun_settings_main_field_notify_plugins() {
|
750 |
+
$options = $this->getSetOptions( self::OPT_FIELD );
|
751 |
?>
|
752 |
<label><input name="<?php echo self::OPT_FIELD; ?>[notify_plugins]" type="radio" value="0" <?php checked( $options['notify_plugins'], 0 ); ?> /> <?php _e( "No", "wp-updates-notifier" ); ?>
|
753 |
</label><br />
|
758 |
<?php
|
759 |
}
|
760 |
|
761 |
+
public function sc_wpun_settings_main_field_notify_themes() {
|
762 |
+
$options = $this->getSetOptions( self::OPT_FIELD );
|
763 |
?>
|
764 |
<label><input name="<?php echo self::OPT_FIELD; ?>[notify_themes]" type="radio" value="0" <?php checked( $options['notify_themes'], 0 ); ?> /> <?php _e( "No", "wp-updates-notifier" ); ?>
|
765 |
</label><br />
|
770 |
<?php
|
771 |
}
|
772 |
|
773 |
+
public function sc_wpun_settings_main_field_notify_automatic() {
|
774 |
+
$options = $this->getSetOptions( self::OPT_FIELD );
|
775 |
?>
|
776 |
<label><input name="<?php echo self::OPT_FIELD; ?>[notify_automatic]" type="checkbox" value="1" <?php checked( $options['notify_automatic'], 1 ); ?> /> <?php _e( "Yes", "wp-updates-notifier" ); ?>
|
777 |
</label>
|
778 |
<?php
|
779 |
}
|
780 |
|
781 |
+
public function sc_wpun_settings_main_field_hide_updates() {
|
782 |
+
$options = $this->getSetOptions( self::OPT_FIELD );
|
783 |
?>
|
784 |
<select id="sc_wpun_settings_main_hide_updates" name="<?php echo self::OPT_FIELD; ?>[hide_updates]">
|
785 |
<option value="1" <?php selected( $options['hide_updates'], 1 ); ?>><?php _e( "Yes", "wp-updates-notifier" ); ?></option>
|
791 |
}
|
792 |
}
|
793 |
|
794 |
+
new sc_WPUpdatesNotifier;
|
|