WP Updates Notifier - Version 1.6

Version Description

  • Added slack notifications and testing button
  • Separated notifications so they can be email, slack, or both
  • Reorganized settings page
  • Changed validation to not turn on notifications for email or slack unless required fields are valid
  • Test email or slack message are now triggered with a temporary transient
  • Removed javascript functions
Download this release

Release Info

Developer l3rady
Plugin Icon wp plugin WP Updates Notifier
Version 1.6
Comparing to
See all releases

Code changes from version 1.4.4 to 1.6

.travis.yml ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Travis CI (MIT License) configuration file for WP Updates Notifier Plugin
2
+ # @link https://travis-ci.org/
3
+
4
+ # Xenial image has PHP versions 5.6,7.1,7.2 pre-installed
5
+ dist: xenial
6
+
7
+ # Xenial does not start mysql or memcached by default
8
+ services:
9
+ - mysql
10
+ - memcached
11
+
12
+ # Declare project language.
13
+ # @link http://about.travis-ci.org/docs/user/languages/php/
14
+ language: php
15
+
16
+ # Specify when Travis should build.
17
+ branches:
18
+ only:
19
+ - master
20
+
21
+ cache:
22
+ directories:
23
+ - $HOME/.composer/cache
24
+
25
+ matrix:
26
+ fast_finish: true
27
+ include:
28
+ - php: 7.3
29
+ env: WP_VERSION=latest PHP_LINT=1 WP_PHPCS=1
30
+ - php: 7.2
31
+ env: WP_VERSION=latest PHP_LINT=1
32
+ - php: 7.1
33
+ env: WP_VERSION=latest PHP_LINT=1
34
+ - php: 7.0
35
+ env: WP_VERSION=latest PHP_LINT=1
36
+ - php: 5.6
37
+ env: WP_VERSION=latest PHP_LINT=1
38
+ - php: 7.3
39
+ env: WP_VERSION=nightly
40
+
41
+ # Use this to prepare your build for testing.
42
+ # e.g. copy database configurations, environment variables, etc.
43
+ # Failures in this section will result in build status 'errored'.
44
+ before_script:
45
+ # Turn off Xdebug. See https://core.trac.wordpress.org/changeset/40138.
46
+ - phpenv config-rm xdebug.ini || echo "Xdebug not available"
47
+
48
+ # This path addition is needed for phpcs.
49
+ - export PATH="$HOME/.composer/vendor/bin:$PATH"
50
+
51
+ # Couple the PHPUnit version to the PHP version.
52
+ - |
53
+ case "$TRAVIS_PHP_VERSION" in
54
+ 7.*)
55
+ echo "Using PHPUnit 6.1"
56
+ composer global require "phpunit/phpunit=6.1.*"
57
+ ;;
58
+ *)
59
+ echo "Using PHPUnit 4.8"
60
+ composer global require "phpunit/phpunit=4.8.*"
61
+ ;;
62
+ esac
63
+
64
+ # # Set up WordPress installation.
65
+ - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
66
+
67
+ # Set up phpcs.
68
+ - |
69
+ if [[ "$WP_PHPCS" == "1" ]] ; then
70
+ composer global require automattic/vipwpcs
71
+ phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/automattic/vipwpcs
72
+ phpcs --config-show
73
+ fi
74
+
75
+ # Run test script commands.
76
+ # Default is specific to project language.
77
+ # All commands must exit with code 0 on success. Anything else is considered failure.
78
+ script:
79
+ # Search for PHP syntax errors.
80
+ #
81
+ # Only need to run this once per PHP version.
82
+ - |
83
+ if [[ "$PHP_LINT" == "1" ]] ; then
84
+ find . -type "f" -iname "*.php" -not -path "./vendor/*" | xargs -L "1" php -l
85
+ fi
86
+ #
87
+ # WordPress Coding Standards.
88
+ #
89
+ # These are the same across PHP and WordPress, so we need to run them only once.
90
+ #
91
+ # @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
92
+ # @link http://pear.php.net/package/PHP_CodeSniffer/
93
+ - |
94
+ if [[ "$WP_PHPCS" == "1" ]] ; then
95
+ phpcs
96
+ fi
97
+
98
+ # Run phpunit and phpunit multi-site.
99
+ - |
100
+ if [[ ! -z "$WP_VERSION" ]] ; then
101
+ phpunit
102
+ WP_MULTISITE=1 phpunit
103
+ fi
104
+
105
+ # Receive notifications for build results.
106
+ # @link http://docs.travis-ci.com/user/notifications/#Email-notifications
107
+ notifications:
108
+ email: false
bin/install-wp-tests.sh ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ if [ $# -lt 3 ]; then
4
+ echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
5
+ exit 1
6
+ fi
7
+
8
+ DB_NAME=$1
9
+ DB_USER=$2
10
+ DB_PASS=$3
11
+ DB_HOST=${4-localhost}
12
+ WP_VERSION=${5-latest}
13
+ SKIP_DB_CREATE=${6-false}
14
+
15
+ TMPDIR=${TMPDIR-/tmp}
16
+ TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
17
+ WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
18
+ WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}
19
+
20
+ download() {
21
+ if [ `which curl` ]; then
22
+ curl --retry 5 --retry-delay 1 -s "$1" > "$2";
23
+ elif [ `which wget` ]; then
24
+ wget -nv -O "$2" "$1"
25
+ fi
26
+ }
27
+
28
+ if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
29
+ WP_TESTS_TAG="branches/$WP_VERSION"
30
+ elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
31
+ if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
32
+ # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
33
+ WP_TESTS_TAG="tags/${WP_VERSION%??}"
34
+ else
35
+ WP_TESTS_TAG="tags/$WP_VERSION"
36
+ fi
37
+ elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
38
+ WP_TESTS_TAG="trunk"
39
+ else
40
+ # http serves a single offer, whereas https serves multiple. we only want one
41
+ download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
42
+ grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
43
+ LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
44
+ if [[ -z "$LATEST_VERSION" ]]; then
45
+ echo "Latest WordPress version could not be found"
46
+ exit 1
47
+ fi
48
+ WP_TESTS_TAG="tags/$LATEST_VERSION"
49
+ fi
50
+
51
+ set -ex
52
+
53
+ install_wp() {
54
+
55
+ if [ -d $WP_CORE_DIR ]; then
56
+ return;
57
+ fi
58
+
59
+ mkdir -p $WP_CORE_DIR
60
+
61
+ if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
62
+ mkdir -p $TMPDIR/wordpress-nightly
63
+ download https://wordpress.org/nightly-builds/wordpress-latest.zip $TMPDIR/wordpress-nightly/wordpress-nightly.zip
64
+ unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/
65
+ mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR
66
+ else
67
+ if [ $WP_VERSION == 'latest' ]; then
68
+ local ARCHIVE_NAME='latest'
69
+ elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then
70
+ # https serves multiple offers, whereas http serves single.
71
+ download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json
72
+ if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
73
+ # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
74
+ LATEST_VERSION=${WP_VERSION%??}
75
+ else
76
+ # otherwise, scan the releases and get the most up to date minor version of the major release
77
+ local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'`
78
+ LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1)
79
+ fi
80
+ if [[ -z "$LATEST_VERSION" ]]; then
81
+ local ARCHIVE_NAME="wordpress-$WP_VERSION"
82
+ else
83
+ local ARCHIVE_NAME="wordpress-$LATEST_VERSION"
84
+ fi
85
+ else
86
+ local ARCHIVE_NAME="wordpress-$WP_VERSION"
87
+ fi
88
+ download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz
89
+ tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR
90
+ fi
91
+
92
+ download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
93
+ }
94
+
95
+ install_test_suite() {
96
+ # portable in-place argument for both GNU sed and Mac OSX sed
97
+ if [[ $(uname -s) == 'Darwin' ]]; then
98
+ local ioption='-i.bak'
99
+ else
100
+ local ioption='-i'
101
+ fi
102
+
103
+ # set up testing suite if it doesn't yet exist
104
+ if [ ! -d $WP_TESTS_DIR ]; then
105
+ # set up testing suite
106
+ mkdir -p $WP_TESTS_DIR
107
+ svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
108
+ svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
109
+ fi
110
+
111
+ if [ ! -f wp-tests-config.php ]; then
112
+ download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
113
+ # remove all forward slashes in the end
114
+ WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
115
+ sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
116
+ sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
117
+ sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
118
+ sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
119
+ sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
120
+ fi
121
+
122
+ }
123
+
124
+ install_db() {
125
+
126
+ if [ ${SKIP_DB_CREATE} = "true" ]; then
127
+ return 0
128
+ fi
129
+
130
+ # parse DB_HOST for port or socket references
131
+ local PARTS=(${DB_HOST//\:/ })
132
+ local DB_HOSTNAME=${PARTS[0]};
133
+ local DB_SOCK_OR_PORT=${PARTS[1]};
134
+ local EXTRA=""
135
+
136
+ if ! [ -z $DB_HOSTNAME ] ; then
137
+ if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
138
+ EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
139
+ elif ! [ -z $DB_SOCK_OR_PORT ] ; then
140
+ EXTRA=" --socket=$DB_SOCK_OR_PORT"
141
+ elif ! [ -z $DB_HOSTNAME ] ; then
142
+ EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
143
+ fi
144
+ fi
145
+
146
+ # create database
147
+ mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
148
+ }
149
+
150
+ install_wp
151
+ install_test_suite
152
+ install_db
class-sc-wp-updates-notifier.php ADDED
@@ -0,0 +1,1059 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Entry point for the plugin.
4
+ *
5
+ * This file is read by WordPress to generate the plugin information in the
6
+ * admin panel.
7
+ *
8
+ * @link https://github.com/l3rady/wp-updates-notifier
9
+ * @since 1.5.0
10
+ * @package SC_WP_Updates_Notifier
11
+ */
12
+
13
+ /*
14
+ * Plugin Name: WP Updates Notifier
15
+ * Plugin URI: https://github.com/l3rady/wp-updates-notifier
16
+ * Description: Sends email or Slack message to notify you if there are any updates for your WordPress site. Can notify about core, plugin and theme updates.
17
+ * Contributors: l3rady, alleyinteractive
18
+ * Version: 1.6.0
19
+ * Author: Scott Cariss
20
+ * Author URI: https://scott.cariss.dev/
21
+ * Text Domain: wp-updates-notifier
22
+ * Domain Path: /languages
23
+ * License: GPL3+
24
+ */
25
+
26
+ /*
27
+ Copyright 2020 Scott Cariss (email:scott@cariss.dev)
28
+
29
+ This program is free software; you can redistribute it and/or modify
30
+ it under the terms of the GNU General Public License as published by
31
+ the Free Software Foundation; either version 2 of the License, or
32
+ (at your option) any later version.
33
+
34
+ This program is distributed in the hope that it will be useful,
35
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
36
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37
+ GNU General Public License for more details.
38
+
39
+ You should have received a copy of the GNU General Public License
40
+ along with this program; if not, write to the Free Software
41
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
42
+ */
43
+
44
+ // Only load class if it hasn't already been loaded
45
+ if ( ! class_exists( 'SC_WP_Updates_Notifier' ) ) {
46
+
47
+ /**
48
+ * WP Updates Notifier - All the magic happens here!
49
+ */
50
+ class SC_WP_Updates_Notifier {
51
+ const OPT_FIELD = 'sc_wpun_settings';
52
+ const OPT_VERSION_FIELD = 'sc_wpun_settings_ver';
53
+ const OPT_VERSION = '7.0';
54
+ const CRON_NAME = 'sc_wpun_update_check';
55
+
56
+ public static $did_init = false;
57
+
58
+ public function __construct() {
59
+ add_action( 'plugins_loaded', array( $this, 'run_init' ) );
60
+ }
61
+
62
+ public function run_init() {
63
+ if ( ! self::$did_init ) {
64
+ $this->init();
65
+ self::$did_init = true;
66
+ }
67
+ }
68
+
69
+ private function init() {
70
+ // Check settings are up to date
71
+ $this->settings_up_to_date();
72
+ // Create Activation and Deactivation Hooks
73
+ register_activation_hook( __FILE__, array( $this, 'activate' ) );
74
+ register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
75
+ // Internationalization
76
+ load_plugin_textdomain( 'wp-updates-notifier', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
77
+ // Add Filters
78
+ add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 ); // Add settings link to plugin in plugin list
79
+ add_filter( 'sc_wpun_plugins_need_update', array( $this, 'check_plugins_against_notified' ) ); // Filter out plugins that need update if already been notified
80
+ add_filter( 'sc_wpun_themes_need_update', array( $this, 'check_themes_against_notified' ) ); // Filter out themes that need update if already been notified
81
+ add_filter( 'auto_core_update_email', array( $this, 'filter_auto_core_update_email' ), 1 ); // Filter the background update notification email.
82
+ // Add Actions
83
+ add_action( 'admin_menu', array( $this, 'admin_settings_menu' ) ); // Add menu to options
84
+ add_action( 'admin_init', array( $this, 'admin_settings_init' ) ); // Add admin init functions
85
+ add_action( 'admin_init', array( $this, 'remove_update_nag_for_nonadmins' ) ); // See if we remove update nag for non admins
86
+ add_action( 'sc_wpun_enable_cron', array( $this, 'enable_cron' ) ); // action to enable cron
87
+ add_action( 'sc_wpun_disable_cron', array( $this, 'disable_cron' ) ); // action to disable cron
88
+ add_action( self::CRON_NAME, array( $this, 'do_update_check' ) ); // action to link cron task to actual task
89
+ }
90
+
91
+ /**
92
+ * Check if this plugin settings are up to date. Firstly check the version in
93
+ * the DB. If they don't match then load in defaults but don't override values
94
+ * already set. Also this will remove obsolete settings that are not needed.
95
+ *
96
+ * @return void
97
+ */
98
+ private function settings_up_to_date() {
99
+ $current_ver = $this->get_set_options( self::OPT_VERSION_FIELD ); // Get current plugin version
100
+ if ( self::OPT_VERSION !== $current_ver ) { // is the version the same as this plugin?
101
+ $options = (array) get_option( self::OPT_FIELD ); // get current settings from DB
102
+ $defaults = array( // Here are our default values for this plugin
103
+ 'frequency' => 'hourly',
104
+ 'email_notifications' => 0,
105
+ 'notify_to' => get_option( 'admin_email' ),
106
+ 'notify_from' => get_option( 'admin_email' ),
107
+ 'slack_notifications' => 0,
108
+ 'slack_webhook_url' => '',
109
+ 'slack_channel_override' => '',
110
+ 'notify_plugins' => 1,
111
+ 'notify_themes' => 1,
112
+ 'notify_automatic' => 1,
113
+ 'hide_updates' => 1,
114
+ 'notified' => array(
115
+ 'core' => '',
116
+ 'plugin' => array(),
117
+ 'theme' => array(),
118
+ ),
119
+ 'last_check_time' => false,
120
+ );
121
+
122
+ // If we are upgrading from settings before settings version 7, turn on email notifications by default.
123
+ if ( intval( $current_ver ) < 7 ) {
124
+ $defaults['email_notifications'] = 1;
125
+ }
126
+
127
+ // Intersect current options with defaults. Basically removing settings that are obsolete
128
+ $options = array_intersect_key( $options, $defaults );
129
+ // Merge current settings with defaults. Basically adding any new settings with defaults that we dont have.
130
+ $options = array_merge( $defaults, $options );
131
+ $this->get_set_options( self::OPT_FIELD, $options ); // update settings
132
+ $this->get_set_options( self::OPT_VERSION_FIELD, self::OPT_VERSION ); // update settings version
133
+ }
134
+ }
135
+
136
+
137
+ /**
138
+ * Filter for when getting or settings this plugins settings
139
+ *
140
+ * @param string $field Option field name of where we are getting or setting plugin settings.
141
+ * @param bool|mixed $settings False if getting settings else an array with settings you are saving.
142
+ *
143
+ * @return bool|mixed True or false if setting or an array of settings if getting
144
+ */
145
+ private function get_set_options( $field, $settings = false ) {
146
+ if ( false === $settings ) {
147
+ return apply_filters( 'sc_wpun_get_options_filter', get_option( $field ), $field );
148
+ }
149
+
150
+ return update_option( $field, apply_filters( 'sc_wpun_put_options_filter', $settings, $field ) );
151
+ }
152
+
153
+
154
+ /**
155
+ * Function that deals with activation of this plugin
156
+ *
157
+ * @return void
158
+ */
159
+ public function activate() {
160
+ do_action( 'sc_wpun_enable_cron' ); // Enable cron
161
+ }
162
+
163
+
164
+ /**
165
+ * Function that deals with de-activation of this plugin
166
+ *
167
+ * @return void
168
+ */
169
+ public function deactivate() {
170
+ do_action( 'sc_wpun_disable_cron' ); // Disable cron
171
+ }
172
+
173
+
174
+ /**
175
+ * Enable cron for this plugin. Check if a cron should be scheduled.
176
+ *
177
+ * @param bool|string $manual_interval For setting a manual cron interval.
178
+ *
179
+ * @return void
180
+ */
181
+ public function enable_cron( $manual_interval = false ) {
182
+ $options = $this->get_set_options( self::OPT_FIELD ); // Get settings
183
+ $current_schedule = wp_get_schedule( self::CRON_NAME ); // find if a schedule already exists
184
+
185
+ // if a manual cron interval is set, use this
186
+ if ( false !== $manual_interval ) {
187
+ $options['frequency'] = $manual_interval;
188
+ }
189
+
190
+ if ( 'manual' === $options['frequency'] ) {
191
+ do_action( 'sc_wpun_disable_cron' ); // Make sure no cron is setup as we are manual
192
+ } else {
193
+ // check if the current schedule matches the one set in settings
194
+ if ( $current_schedule === $options['frequency'] ) {
195
+ return;
196
+ }
197
+
198
+ // check the cron setting is valid
199
+ if ( ! in_array( $options['frequency'], $this->get_intervals(), true ) ) {
200
+ return;
201
+ }
202
+
203
+ // Remove any cron's for this plugin first so we don't end up with multiple cron's doing the same thing.
204
+ do_action( 'sc_wpun_disable_cron' );
205
+
206
+ // Schedule cron for this plugin.
207
+ wp_schedule_event( time(), $options['frequency'], self::CRON_NAME );
208
+ }
209
+ }
210
+
211
+
212
+ /**
213
+ * Removes cron for this plugin.
214
+ *
215
+ * @return void
216
+ */
217
+ public function disable_cron() {
218
+ wp_clear_scheduled_hook( self::CRON_NAME ); // clear cron
219
+ }
220
+
221
+
222
+ /**
223
+ * Adds the settings link under the plugin on the plugin screen.
224
+ *
225
+ * @param array $links Links to list on the plugin screen.
226
+ * @param string $file Filename.
227
+ *
228
+ * @return array $links
229
+ */
230
+ public function plugin_action_links( $links, $file ) {
231
+ if ( plugin_basename( __FILE__ ) === $file ) {
232
+ $settings_link = '<a href="' . admin_url( 'options-general.php?page=wp-updates-notifier' ) . '">' . __( 'Settings', 'wp-updates-notifier' ) . '</a>';
233
+ array_unshift( $links, $settings_link );
234
+ }
235
+ return $links;
236
+ }
237
+
238
+
239
+ /**
240
+ * This is run by the cron. The update check checks the core always, the
241
+ * plugins and themes if asked. If updates found email notification sent.
242
+ *
243
+ * @return void
244
+ */
245
+ public function do_update_check() {
246
+ $options = $this->get_set_options( self::OPT_FIELD ); // get settings
247
+ $message = ''; // start with a blank message
248
+ $core_updated = $this->core_update_check( $message ); // check the WP core for updates
249
+ if ( 0 !== $options['notify_plugins'] ) { // are we to check for plugin updates?
250
+ $plugins_updated = $this->plugins_update_check( $message, $options['notify_plugins'] ); // check for plugin updates
251
+ } else {
252
+ $plugins_updated = false; // no plugin updates
253
+ }
254
+ if ( 0 !== $options['notify_themes'] ) { // are we to check for theme updates?
255
+ $themes_updated = $this->themes_update_check( $message, $options['notify_themes'] ); // check for theme updates
256
+ } else {
257
+ $themes_updated = false; // no theme updates
258
+ }
259
+ if ( $core_updated || $plugins_updated || $themes_updated ) { // Did anything come back as need updating?
260
+ $message = __( 'There are updates available for your WordPress site:', 'wp-updates-notifier' ) . ' ' . esc_html( get_bloginfo() ) . ' @ ' . esc_url( home_url() ) . "\n" . $message . "\n";
261
+ $message .= sprintf( __( 'Please visit %s to update.', 'wp-updates-notifier' ), admin_url( 'update-core.php' ) );
262
+
263
+ // Send email notification.
264
+ if ( 1 === $options['email_notifications'] ) {
265
+ $this->send_email_message( $message );
266
+ }
267
+
268
+ // Send slack notification.
269
+ if ( 1 === $options['slack_notifications'] ) {
270
+ $this->send_slack_message( $message );
271
+ }
272
+ }
273
+
274
+ $this->log_last_check_time();
275
+ }
276
+
277
+
278
+ /**
279
+ * Checks to see if any WP core updates
280
+ *
281
+ * @param string $message holds message to be sent via notification.
282
+ *
283
+ * @return bool
284
+ */
285
+ private function core_update_check( &$message ) {
286
+ global $wp_version;
287
+ $settings = $this->get_set_options( self::OPT_FIELD ); // get settings
288
+ do_action( 'wp_version_check' ); // force WP to check its core for updates
289
+ $update_core = get_site_transient( 'update_core' ); // get information of updates
290
+ if ( 'upgrade' === $update_core->updates[0]->response ) { // is WP core update available?
291
+ if ( $update_core->updates[0]->current !== $settings['notified']['core'] ) { // have we already notified about this version?
292
+ require_once ABSPATH . WPINC . '/version.php'; // Including this because some plugins can mess with the real version stored in the DB.
293
+ $new_core_ver = $update_core->updates[0]->current; // The new WP core version
294
+ $old_core_ver = $wp_version; // the old WP core version
295
+ $message .= "\n" . sprintf( __( 'WP-Core: WordPress is out of date. Please update from version %1$s to %2$s', 'wp-updates-notifier' ), $old_core_ver, $new_core_ver ) . "\n";
296
+ $settings['notified']['core'] = $new_core_ver; // set core version we are notifying about
297
+ $this->get_set_options( self::OPT_FIELD, $settings ); // update settings
298
+ return true; // we have updates so return true
299
+ } else {
300
+ return false; // There are updates but we have already notified in the past.
301
+ }
302
+ }
303
+ $settings['notified']['core'] = ''; // no updates lets set this nothing
304
+ $this->get_set_options( self::OPT_FIELD, $settings ); // update settings
305
+ return false; // no updates return false
306
+ }
307
+
308
+
309
+ /**
310
+ * Check to see if any plugin updates.
311
+ *
312
+ * @param string $message Holds message to be sent via notification.
313
+ * @param int $all_or_active Should we look for all plugins or just active ones.
314
+ *
315
+ * @return bool
316
+ */
317
+ private function plugins_update_check( &$message, $all_or_active ) {
318
+ global $wp_version;
319
+ $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
320
+ $settings = $this->get_set_options( self::OPT_FIELD ); // get settings
321
+ do_action( 'wp_update_plugins' ); // force WP to check plugins for updates
322
+ $update_plugins = get_site_transient( 'update_plugins' ); // get information of updates
323
+ if ( ! empty( $update_plugins->response ) ) { // any plugin updates available?
324
+ $plugins_need_update = $update_plugins->response; // plugins that need updating
325
+ if ( 2 === $all_or_active ) { // are we to check just active plugins?
326
+ $active_plugins = array_flip( get_option( 'active_plugins' ) ); // find which plugins are active
327
+ $plugins_need_update = array_intersect_key( $plugins_need_update, $active_plugins ); // only keep plugins that are active
328
+ }
329
+ $plugins_need_update = apply_filters( 'sc_wpun_plugins_need_update', $plugins_need_update ); // additional filtering of plugins need update
330
+ if ( count( $plugins_need_update ) >= 1 ) { // any plugins need updating after all the filtering gone on above?
331
+ require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; // Required for plugin API
332
+ require_once ABSPATH . WPINC . '/version.php'; // Required for WP core version
333
+ foreach ( $plugins_need_update as $key => $data ) { // loop through the plugins that need updating
334
+ $plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $key ); // get local plugin info
335
+ $info = plugins_api( 'plugin_information', array( 'slug' => $data->slug ) ); // get repository plugin info
336
+ $message .= "\n" . sprintf( __( 'Plugin: %1$s is out of date. Please update from version %2$s to %3$s', 'wp-updates-notifier' ), $plugin_info['Name'], $plugin_info['Version'], $data->new_version ) . "\n";
337
+ $message .= "\t" . sprintf( __( 'Details: %s', 'wp-updates-notifier' ), $data->url ) . "\n";
338
+ $message .= "\t" . sprintf( __( 'Changelog: %1$s%2$s', 'wp-updates-notifier' ), $data->url, 'changelog/' ) . "\n";
339
+ if ( isset( $info->tested ) && version_compare( $info->tested, $wp_version, '>=' ) ) {
340
+ $compat = sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)', 'wp-updates-notifier' ), $cur_wp_version );
341
+ } elseif ( isset( $info->compatibility[ $wp_version ][ $data->new_version ] ) ) {
342
+ $compat = $info->compatibility[ $wp_version ][ $data->new_version ];
343
+ $compat = sprintf( __( 'Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)', 'wp-updates-notifier' ), $wp_version, $compat[0], $compat[2], $compat[1] );
344
+ } else {
345
+ $compat = sprintf( __( 'Compatibility with WordPress %1$s: Unknown', 'wp-updates-notifier' ), $wp_version );
346
+ }
347
+ $message .= "\t" . sprintf( __( 'Compatibility: %s', 'wp-updates-notifier' ), $compat ) . "\n";
348
+ $settings['notified']['plugin'][ $key ] = $data->new_version; // set plugin version we are notifying about
349
+ }
350
+ $this->get_set_options( self::OPT_FIELD, $settings ); // save settings
351
+ return true; // we have plugin updates return true
352
+ }
353
+ } else {
354
+ if ( 0 !== count( $settings['notified']['plugin'] ) ) { // is there any plugin notifications?
355
+ $settings['notified']['plugin'] = array(); // set plugin notifications to empty as all plugins up-to-date
356
+ $this->get_set_options( self::OPT_FIELD, $settings ); // save settings
357
+ }
358
+ }
359
+ return false; // No plugin updates so return false
360
+ }
361
+
362
+
363
+ /**
364
+ * Check to see if any theme updates.
365
+ *
366
+ * @param string $message Holds message to be sent via notification.
367
+ * @param int $all_or_active Should we look for all themes or just active ones.
368
+ *
369
+ * @return bool
370
+ */
371
+ private function themes_update_check( &$message, $all_or_active ) {
372
+ $settings = $this->get_set_options( self::OPT_FIELD ); // get settings
373
+ do_action( 'wp_update_themes' ); // force WP to check for theme updates
374
+ $update_themes = get_site_transient( 'update_themes' ); // get information of updates
375
+ if ( ! empty( $update_themes->response ) ) { // any theme updates available?
376
+ $themes_need_update = $update_themes->response; // themes that need updating
377
+ if ( 2 === $all_or_active ) { // are we to check just active themes?
378
+ $active_theme = array( get_option( 'template' ) => array() ); // find current theme that is active
379
+ $themes_need_update = array_intersect_key( $themes_need_update, $active_theme ); // only keep theme that is active
380
+ }
381
+ $themes_need_update = apply_filters( 'sc_wpun_themes_need_update', $themes_need_update ); // additional filtering of themes need update
382
+ if ( count( $themes_need_update ) >= 1 ) { // any themes need updating after all the filtering gone on above?
383
+ foreach ( $themes_need_update as $key => $data ) { // loop through the themes that need updating
384
+ $theme_info = wp_get_theme( $key ); // get theme info
385
+ $message .= "\n" . sprintf( __( 'Theme: %1$s is out of date. Please update from version %2$s to %3$s', 'wp-updates-notifier' ), $theme_info['Name'], $theme_info['Version'], $data['new_version'] ) . "\n";
386
+ $settings['notified']['theme'][ $key ] = $data['new_version']; // set theme version we are notifying about
387
+ }
388
+ $this->get_set_options( self::OPT_FIELD, $settings ); // save settings
389
+ return true; // we have theme updates return true
390
+ }
391
+ } else {
392
+ if ( 0 !== count( $settings['notified']['theme'] ) ) { // is there any theme notifications?
393
+ $settings['notified']['theme'] = array(); // set theme notifications to empty as all themes up-to-date
394
+ $this->get_set_options( self::OPT_FIELD, $settings ); // save settings
395
+ }
396
+ }
397
+ return false; // No theme updates so return false
398
+ }
399
+
400
+
401
+ /**
402
+ * Filter for removing plugins from update list if already been notified about
403
+ *
404
+ * @param array $plugins_need_update Array of plugins that need an update.
405
+ *
406
+ * @return array $plugins_need_update
407
+ */
408
+ public function check_plugins_against_notified( $plugins_need_update ) {
409
+ $settings = $this->get_set_options( self::OPT_FIELD ); // get settings
410
+ foreach ( $plugins_need_update as $key => $data ) { // loop through plugins that need update
411
+ if ( isset( $settings['notified']['plugin'][ $key ] ) ) { // has this plugin been notified before?
412
+ if ( $data->new_version === $settings['notified']['plugin'][ $key ] ) { // does this plugin version match that of the one that's been notified?
413
+ unset( $plugins_need_update[ $key ] ); // don't notify this plugin as has already been notified
414
+ }
415
+ }
416
+ }
417
+ return $plugins_need_update;
418
+ }
419
+
420
+
421
+ /**
422
+ * Filter for removing themes from update list if already been notified about
423
+ *
424
+ * @param array $themes_need_update Array of themes that need an update.
425
+ *
426
+ * @return array $themes_need_update
427
+ */
428
+ public function check_themes_against_notified( $themes_need_update ) {
429
+ $settings = $this->get_set_options( self::OPT_FIELD ); // get settings
430
+ foreach ( $themes_need_update as $key => $data ) { // loop through themes that need update
431
+ if ( isset( $settings['notified']['theme'][ $key ] ) ) { // has this theme been notified before?
432
+ if ( $data['new_version'] === $settings['notified']['theme'][ $key ] ) { // does this theme version match that of the one that's been notified?
433
+ unset( $themes_need_update[ $key ] ); // don't notify this theme as has already been notified
434
+ }
435
+ }
436
+ }
437
+ return $themes_need_update;
438
+ }
439
+
440
+
441
+ /**
442
+ * Sends email message.
443
+ *
444
+ * @param string $message Holds message to be sent in body of email.
445
+ *
446
+ * @return bool Whether the email contents were sent successfully.
447
+ */
448
+ public function send_email_message( $message ) {
449
+ $settings = $this->get_set_options( self::OPT_FIELD ); // get settings
450
+
451
+ $subject = sprintf( __( 'WP Updates Notifier: Updates Available @ %s', 'wp-updates-notifier' ), home_url() );
452
+ add_filter( 'wp_mail_from', array( $this, 'sc_wpun_wp_mail_from' ) ); // add from filter
453
+ add_filter( 'wp_mail_from_name', array( $this, 'sc_wpun_wp_mail_from_name' ) ); // add from name filter
454
+ add_filter( 'wp_mail_content_type', array( $this, 'sc_wpun_wp_mail_content_type' ) ); // add content type filter
455
+ // phpcs:disable WordPressVIPMinimum.Functions.RestrictedFunctions.wp_mail_wp_mail
456
+ $response = wp_mail( $settings['notify_to'], apply_filters( 'sc_wpun_email_subject', $subject ), apply_filters( 'sc_wpun_email_content', esc_html( $message ) ) ); // send email
457
+ // phpcs:enable
458
+ remove_filter( 'wp_mail_from', array( $this, 'sc_wpun_wp_mail_from' ) ); // remove from filter
459
+ remove_filter( 'wp_mail_from_name', array( $this, 'sc_wpun_wp_mail_from_name' ) ); // remove from name filter
460
+ remove_filter( 'wp_mail_content_type', array( $this, 'sc_wpun_wp_mail_content_type' ) ); // remove content type filter
461
+
462
+ return $response;
463
+ }
464
+
465
+
466
+ /**
467
+ * Sends slack post.
468
+ *
469
+ * @param string $message Holds message to be posted to slack.
470
+ *
471
+ * @return bool Success or failure.
472
+ */
473
+ public function send_slack_message( $message ) {
474
+ $settings = $this->get_set_options( self::OPT_FIELD ); // get settings
475
+
476
+ $payload = array(
477
+ 'username' => __( 'WP Updates Notifier', 'wp-updates-notifier' ),
478
+ 'icon_emoji' => ':robot_face:',
479
+ 'text' => esc_html( $message ),
480
+ );
481
+
482
+ if ( ! empty( $settings['slack_channel_override'] ) && '' !== $settings['slack_channel_override'] ) {
483
+ $payload['channel'] = $settings['slack_channel_override'];
484
+ }
485
+
486
+ $response = wp_remote_post(
487
+ $settings['slack_webhook_url'],
488
+ array(
489
+ 'method' => 'POST',
490
+ 'body' => array(
491
+ 'payload' => wp_json_encode( $payload ),
492
+ ),
493
+ )
494
+ );
495
+
496
+ return is_wp_error( $response );
497
+ }
498
+
499
+ /**
500
+ * Get the from email address.
501
+ *
502
+ * @return String email address.
503
+ */
504
+ public function sc_wpun_wp_mail_from() {
505
+ $settings = $this->get_set_options( self::OPT_FIELD );
506
+ return $settings['notify_from'];
507
+ }
508
+
509
+ /**
510
+ * Get the name to send email from.
511
+ *
512
+ * @return String From Name.
513
+ */
514
+ public function sc_wpun_wp_mail_from_name() {
515
+ return __( 'WP Updates Notifier', 'wp-updates-notifier' );
516
+ }
517
+
518
+ /**
519
+ * Email type.
520
+ *
521
+ * @return String email type.
522
+ */
523
+ public function sc_wpun_wp_mail_content_type() {
524
+ return 'text/plain';
525
+ }
526
+
527
+ /**
528
+ * Change the last time checked.
529
+ *
530
+ * @return void
531
+ */
532
+ private function log_last_check_time() {
533
+ $options = $this->get_set_options( self::OPT_FIELD );
534
+ $options['last_check_time'] = time();
535
+ $this->get_set_options( self::OPT_FIELD, $options );
536
+ }
537
+
538
+ /**
539
+ * Filter the background update notification email
540
+ *
541
+ * @param array $email Array of email arguments that will be passed to wp_mail().
542
+ *
543
+ * @return array Modified array containing the new email address.
544
+ */
545
+ public function filter_auto_core_update_email( $email ) {
546
+ $options = $this->get_set_options( self::OPT_FIELD ); // Get settings
547
+
548
+ if ( 0 !== $options['notify_automatic'] ) {
549
+ if ( ! empty( $options['notify_to'] ) ) { // If an email address has been set, override the WordPress default.
550
+ $email['to'] = $options['notify_to'];
551
+ }
552
+
553
+ if ( ! empty( $options['notify_from'] ) ) { // If an email address has been set, override the WordPress default.
554
+ $email['headers'][] = 'From: ' . $this->sc_wpun_wp_mail_from_name() . ' <' . $options['notify_from'] . '>';
555
+ }
556
+ }
557
+
558
+ return $email;
559
+ }
560
+
561
+
562
+ /**
563
+ * Removes the update nag for non admin users.
564
+ *
565
+ * @return void
566
+ */
567
+ public function remove_update_nag_for_nonadmins() {
568
+ $settings = $this->get_set_options( self::OPT_FIELD ); // get settings
569
+ if ( 1 === $settings['hide_updates'] ) { // is this enabled?
570
+ if ( ! current_user_can( 'update_plugins' ) ) { // can the current user update plugins?
571
+ remove_action( 'admin_notices', 'update_nag', 3 ); // no they cannot so remove the nag for them.
572
+ }
573
+ }
574
+ }
575
+
576
+ /**
577
+ * Get cron schedules.
578
+ *
579
+ * @return Array cron schedules.
580
+ */
581
+ private function get_schedules() {
582
+ $schedules = wp_get_schedules();
583
+ uasort( $schedules, array( $this, 'sort_by_interval' ) );
584
+ return $schedules;
585
+ }
586
+
587
+ /**
588
+ * Get cron intervals.
589
+ *
590
+ * @return Array cron intervals.
591
+ */
592
+ private function get_intervals() {
593
+ $intervals = array_keys( $this->get_schedules() );
594
+ $intervals[] = 'manual';
595
+ return $intervals;
596
+ }
597
+
598
+ /**
599
+ * Simple sort function.
600
+ *
601
+ * @param int $a Integer for sorting.
602
+ * @param int $b Integer for sorting.
603
+ *
604
+ * @return int Frequency internval.
605
+ */
606
+ private function sort_by_interval( $a, $b ) {
607
+ return $a['interval'] - $b['interval'];
608
+ }
609
+
610
+ /**
611
+ * Add admin menu.
612
+ *
613
+ * @return void
614
+ */
615
+ public function admin_settings_menu() {
616
+ add_options_page( __( 'Updates Notifier', 'wp-updates-notifier' ), __( 'Updates Notifier', 'wp-updates-notifier' ), 'manage_options', 'wp-updates-notifier', array( $this, 'settings_page' ) );
617
+ }
618
+
619
+ /**
620
+ * Output settings page and trigger sending tests.
621
+ *
622
+ * @return void
623
+ */
624
+ public function settings_page() {
625
+ // Trigger tests if they are ready to be sent.
626
+ $sc_wpun_send_test_slack = get_transient( 'sc_wpun_send_test_slack' );
627
+ if ( $sc_wpun_send_test_slack ) {
628
+ delete_transient( 'sc_wpun_send_test_slack' );
629
+ $this->send_test_slack();
630
+ }
631
+ $sc_wpun_send_test_email = get_transient( 'sc_wpun_send_test_email' );
632
+ if ( $sc_wpun_send_test_email ) {
633
+ delete_transient( 'sc_wpun_send_test_email' );
634
+ $this->send_test_email();
635
+ }
636
+
637
+ $options = $this->get_set_options( self::OPT_FIELD );
638
+ $date_format = get_option( 'date_format' );
639
+ $time_format = get_option( 'time_format' );
640
+ ?>
641
+ <div class="wrap">
642
+ <h2><?php esc_html_e( 'Updates Notifier', 'wp-updates-notifier' ); ?></h2>
643
+
644
+ <p>
645
+ <span class="description">
646
+ <?php
647
+ if ( empty( $options['last_check_time'] ) ) {
648
+ $scan_date = __( 'Never', 'wp-updates-notifier' );
649
+ } else {
650
+ $scan_date = sprintf(
651
+ __( '%1$1s @ %2$2s', 'wp-updates-notifier' ),
652
+ gmdate( $date_format, $options['last_check_time'] ),
653
+ gmdate( $time_format, $options['last_check_time'] )
654
+ );
655
+ }
656
+
657
+ echo esc_html( __( 'Last scanned: ', 'wp-updates-notifier' ) . $scan_date );
658
+ ?>
659
+ </span>
660
+ </p>
661
+
662
+ <form action="<?php echo esc_attr( admin_url( 'options.php' ) ); ?>" method="post">
663
+ <?php
664
+ settings_fields( 'sc_wpun_settings' );
665
+ do_settings_sections( 'wp-updates-notifier' );
666
+ ?>
667
+ <p>&nbsp;</p>
668
+ <input class="button-primary" name="Submit" type="submit" value="<?php esc_html_e( 'Save settings', 'wp-updates-notifier' ); ?>" />
669
+ <input class="button" name="submitwithemail" type="submit" value="<?php esc_html_e( 'Save settings with test email', 'wp-updates-notifier' ); ?>" />
670
+ <input class="button" name="submitwithslack" type="submit" value="<?php esc_html_e( 'Save settings with test slack post', 'wp-updates-notifier' ); ?>" />
671
+ </form>
672
+ </div>
673
+ <?php
674
+ }
675
+
676
+ /**
677
+ * Add all of the settings for the settings page.
678
+ *
679
+ * @return void
680
+ */
681
+ public function admin_settings_init() {
682
+ register_setting( self::OPT_FIELD, self::OPT_FIELD, array( $this, 'sc_wpun_settings_validate' ) ); // Register Settings
683
+
684
+ 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
685
+ 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' );
686
+ 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' );
687
+ 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' );
688
+ 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' );
689
+ 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' );
690
+
691
+ // Email notification settings.
692
+ add_settings_section( 'sc_wpun_settings_email_notifications', __( 'Email Notifications', 'wp-updates-notifier' ), array( $this, 'sc_wpun_settings_email_notifications_text' ), 'wp-updates-notifier' );
693
+ add_settings_field( 'sc_wpun_settings_email_notifications_email_notifications', __( 'Send email notifications?', 'wp-updates-notifier' ), array( $this, 'sc_wpun_settings_email_notifications_field_email_notifications' ), 'wp-updates-notifier', 'sc_wpun_settings_email_notifications' );
694
+ add_settings_field( 'sc_wpun_settings_email_notifications_notify_to', __( 'Notify email to', 'wp-updates-notifier' ), array( $this, 'sc_wpun_settings_email_notifications_field_notify_to' ), 'wp-updates-notifier', 'sc_wpun_settings_email_notifications' );
695
+ add_settings_field( 'sc_wpun_settings_email_notifications_notify_from', __( 'Notify email from', 'wp-updates-notifier' ), array( $this, 'sc_wpun_settings_email_notifications_field_notify_from' ), 'wp-updates-notifier', 'sc_wpun_settings_email_notifications' );
696
+
697
+ // Slack notification settings.
698
+ add_settings_section( 'sc_wpun_settings_slack_notifications', __( 'Slack Notifications', 'wp-updates-notifier' ), array( $this, 'sc_wpun_settings_slack_notifications_text' ), 'wp-updates-notifier' );
699
+ add_settings_field( 'sc_wpun_settings_slack_notifications_slack_notifications', __( 'Send slack notifications?', 'wp-updates-notifier' ), array( $this, 'sc_wpun_settings_slack_notifications_field_slack_notifications' ), 'wp-updates-notifier', 'sc_wpun_settings_slack_notifications' );
700
+ add_settings_field( 'sc_wpun_settings_slack_notifications_slack_webhook_url', __( 'Webhook url', 'wp-updates-notifier' ), array( $this, 'sc_wpun_settings_slack_notifications_field_slack_webhook_url' ), 'wp-updates-notifier', 'sc_wpun_settings_slack_notifications' );
701
+ add_settings_field( 'sc_wpun_settings_slack_notifications_slack_channel_override', __( 'Channel to notify', 'wp-updates-notifier' ), array( $this, 'sc_wpun_settings_slack_notifications_field_slack_channel_override' ), 'wp-updates-notifier', 'sc_wpun_settings_slack_notifications' );
702
+ }
703
+
704
+ /**
705
+ * Validate and sanitize all of the settings from the page form.
706
+ *
707
+ * @param array $input Array of unsanitized options from the page form.
708
+ *
709
+ * @return array Array of sanitized and validated settings.
710
+ */
711
+ public function sc_wpun_settings_validate( $input ) {
712
+ check_admin_referer( 'sc_wpun_settings-options' );
713
+ $valid = $this->get_set_options( self::OPT_FIELD );
714
+
715
+ // Validate main settings.
716
+ if ( in_array( $input['frequency'], $this->get_intervals(), true ) ) {
717
+ $valid['frequency'] = $input['frequency'];
718
+ do_action( 'sc_wpun_enable_cron', $input['frequency'] );
719
+ } else {
720
+ add_settings_error( 'sc_wpun_settings_main_frequency', 'sc_wpun_settings_main_frequency_error', __( 'Invalid frequency entered', 'wp-updates-notifier' ), 'error' );
721
+ }
722
+
723
+ $sanitized_notify_plugins = absint( isset( $input['notify_plugins'] ) ? $input['notify_plugins'] : 0 );
724
+ if ( $sanitized_notify_plugins >= 0 && $sanitized_notify_plugins <= 2 ) {
725
+ $valid['notify_plugins'] = $sanitized_notify_plugins;
726
+ } else {
727
+ add_settings_error( 'sc_wpun_settings_main_notify_plugins', 'sc_wpun_settings_main_notify_plugins_error', __( 'Invalid plugin updates value entered', 'wp-updates-notifier' ), 'error' );
728
+ }
729
+
730
+ $sanitized_notify_themes = absint( isset( $input['notify_themes'] ) ? $input['notify_themes'] : 0 );
731
+ if ( $sanitized_notify_themes >= 0 && $sanitized_notify_themes <= 2 ) {
732
+ $valid['notify_themes'] = $sanitized_notify_themes;
733
+ } else {
734
+ add_settings_error( 'sc_wpun_settings_main_notify_themes', 'sc_wpun_settings_main_notify_themes_error', __( 'Invalid theme updates value entered', 'wp-updates-notifier' ), 'error' );
735
+ }
736
+
737
+ $sanitized_notify_automatic = absint( isset( $input['notify_automatic'] ) ? $input['notify_automatic'] : 0 );
738
+ if ( $sanitized_notify_automatic >= 0 && $sanitized_notify_automatic <= 1 ) {
739
+ $valid['notify_automatic'] = $sanitized_notify_automatic;
740
+ } else {
741
+ add_settings_error( 'sc_wpun_settings_main_notify_automatic', 'sc_wpun_settings_main_notify_automatic_error', __( 'Invalid automatic updates value entered', 'wp-updates-notifier' ), 'error' );
742
+ }
743
+
744
+ $sanitized_hide_updates = absint( isset( $input['hide_updates'] ) ? $input['hide_updates'] : 0 );
745
+ if ( $sanitized_hide_updates <= 1 ) {
746
+ $valid['hide_updates'] = $sanitized_hide_updates;
747
+ } else {
748
+ add_settings_error( 'sc_wpun_settings_main_hide_updates', 'sc_wpun_settings_main_hide_updates_error', __( 'Invalid hide updates value entered', 'wp-updates-notifier' ), 'error' );
749
+ }
750
+
751
+ // Validate email notification settings.
752
+ if ( ! empty( $input['notify_to'] ) ) {
753
+ $emails_to = explode( ',', $input['notify_to'] );
754
+ if ( $emails_to ) {
755
+ $sanitized_emails = array();
756
+ $was_error = false;
757
+ foreach ( $emails_to as $email_to ) {
758
+ $address = sanitize_email( trim( $email_to ) );
759
+ if ( ! is_email( $address ) ) {
760
+ add_settings_error( 'sc_wpun_settings_email_notifications_notify_to', 'sc_wpun_settings_email_notifications_notify_to_error', __( 'One or more email to addresses are invalid', 'wp-updates-notifier' ), 'error' );
761
+ $was_error = true;
762
+ break;
763
+ }
764
+ $sanitized_emails[] = $address;
765
+ }
766
+ if ( ! $was_error ) {
767
+ $valid['notify_to'] = implode( ',', $sanitized_emails );
768
+ }
769
+ }
770
+ } else {
771
+ $valid['notify_to'] = '';
772
+ }
773
+
774
+ if ( ! empty( $input['notify_from'] ) ) {
775
+ $sanitized_email_from = sanitize_email( $input['notify_from'] );
776
+ if ( is_email( $sanitized_email_from ) ) {
777
+ $valid['notify_from'] = $sanitized_email_from;
778
+ } else {
779
+ add_settings_error( 'sc_wpun_settings_email_notifications_notify_from', 'sc_wpun_settings_email_notifications_notify_from_error', __( 'Invalid email from entered', 'wp-updates-notifier' ), 'error' );
780
+ }
781
+ } else {
782
+ $valid['notify_from'] = '';
783
+ }
784
+
785
+ $email_notifications = absint( isset( $input['email_notifications'] ) ? $input['email_notifications'] : 0 );
786
+ if ( 1 < $email_notifications ) {
787
+ add_settings_error( 'sc_wpun_settings_email_notifications_email_notifications', 'sc_wpun_settings_email_notifications_email_notifications_error', __( 'Invalid notification email value entered', 'wp-updates-notifier' ), 'error' );
788
+ }
789
+
790
+ if ( 1 === $email_notifications ) {
791
+ if ( ! empty( $valid['notify_to'] ) && ! empty( $valid['notify_from'] ) ) {
792
+ $email_notifications = 1;
793
+ } else {
794
+ add_settings_error( 'sc_wpun_settings_email_notifications_notify_from', 'sc_wpun_settings_email_notifications_notify_to_error', __( 'Can not enable email notifications, addresses are not valid', 'wp-updates-notifier' ), 'error' );
795
+ $email_notifications = 0;
796
+ }
797
+ }
798
+ $valid['email_notifications'] = $email_notifications;
799
+
800
+ // Validate slack settings.
801
+ if ( ! empty( $input['slack_webhook_url'] ) ) {
802
+ if ( false === filter_var( $input['slack_webhook_url'], FILTER_VALIDATE_URL ) ) {
803
+ add_settings_error( 'sc_wpun_settings_slack_notifications_slack_webhook_url', 'sc_wpun_settings_slack_notifications_slack_webhook_url_error', __( 'Invalid webhook url entered', 'wp-updates-notifier' ), 'error' );
804
+ } else {
805
+ $valid['slack_webhook_url'] = $input['slack_webhook_url'];
806
+ }
807
+ } else {
808
+ $valid['slack_webhook_url'] = '';
809
+ }
810
+
811
+ if ( ! empty( $input['slack_channel_override'] ) ) {
812
+ if ( '#' !== substr( $input['slack_channel_override'], 0, 1 ) && '@' !== substr( $input['slack_channel_override'], 0, 1 ) ) {
813
+ add_settings_error( 'sc_wpun_settings_slack_notifications_slack_channel_override', 'sc_wpun_settings_slack_notifications_slack_channel_override_error', __( 'Channel name must start with a # or @', 'wp-updates-notifier' ), 'error' );
814
+ } elseif ( strpos( $input['slack_channel_override'], ' ' ) ) {
815
+ add_settings_error( 'sc_wpun_settings_slack_notifications_slack_channel_override', 'sc_wpun_settings_slack_notifications_slack_channel_override_error', __( 'Channel name must not contain a space', 'wp-updates-notifier' ), 'error' );
816
+ } else {
817
+ $valid['slack_channel_override'] = $input['slack_channel_override'];
818
+ }
819
+ } else {
820
+ $valid['slack_channel_override'] = '';
821
+ }
822
+
823
+ $slack_notifications = absint( isset( $input['slack_notifications'] ) ? $input['slack_notifications'] : 0 );
824
+ if ( $slack_notifications > 1 ) {
825
+ add_settings_error( 'sc_wpun_settings_slack_notifications_slack_notifications', 'sc_wpun_settings_slack_notifications_slack_notifications_error', __( 'Invalid notification slack value entered', 'wp-updates-notifier' ), 'error' );
826
+ }
827
+
828
+ if ( 1 === $slack_notifications ) {
829
+ if ( '' === $valid['slack_webhook_url'] ) {
830
+ add_settings_error( 'sc_wpun_settings_slack_notifications_slack_webhook_url', 'sc_wpun_settings_slack_notifications_slack_webhook_url_error', __( 'No to slack webhoook url entered', 'wp-updates-notifier' ), 'error' );
831
+ $slack_notifications = 0;
832
+ } else {
833
+ $slack_notifications = 1;
834
+ }
835
+ } else {
836
+ $slack_notifications = 0;
837
+ }
838
+ $valid['slack_notifications'] = $slack_notifications;
839
+
840
+ // Parse sending test notifiations.
841
+
842
+ if ( isset( $_POST['submitwithemail'] ) ) {
843
+ if ( '' !== $valid['notify_to'] && '' !== $valid['notify_from'] ) {
844
+ set_transient( 'sc_wpun_send_test_email', 1 );
845
+ } else {
846
+ add_settings_error( 'sc_wpun_settings_email_notifications_email_notifications', 'sc_wpun_settings_email_notifications_email_notifications_error', __( 'Can not send test email. Email settings are invalid.', 'wp-updates-notifier' ), 'error' );
847
+ }
848
+ }
849
+
850
+ if ( isset( $_POST['submitwithslack'] ) ) {
851
+ if ( '' !== $valid['slack_webhook_url'] ) {
852
+ set_transient( 'sc_wpun_send_test_slack', 1 );
853
+ } else {
854
+ add_settings_error( 'sc_wpun_settings_email_notifications_slack_notifications', 'sc_wpun_settings_email_notifications_slack_notifications_error', __( 'Can not post test slack message. Slack settings are invalid.', 'wp-updates-notifier' ), 'error' );
855
+ }
856
+ }
857
+
858
+ return $valid;
859
+ }
860
+
861
+ /**
862
+ * Send a test email.
863
+ *
864
+ * @return void
865
+ */
866
+ public function send_test_email() {
867
+ $this->send_email_message( __( 'This is a test message from WP Updates Notifier.', 'wp-updates-notifier' ) );
868
+ }
869
+
870
+ /**
871
+ * Send a test slack message.
872
+ *
873
+ * @return void
874
+ */
875
+ public function send_test_slack() {
876
+ $this->send_slack_message( __( 'This is a test message from WP Updates Notifier.', 'wp-updates-notifier' ) );
877
+ }
878
+
879
+ /**
880
+ * Output the text at the top of the main settings section (function is required even if it outputs nothing).
881
+ *
882
+ * @return void
883
+ */
884
+ public function sc_wpun_settings_main_text() {
885
+ }
886
+
887
+ /**
888
+ * Settings field for frequency.
889
+ *
890
+ * @return void
891
+ */
892
+ public function sc_wpun_settings_main_field_frequency() {
893
+ $options = $this->get_set_options( self::OPT_FIELD );
894
+ ?>
895
+ <select id="sc_wpun_settings_main_frequency" name="<?php echo esc_attr( self::OPT_FIELD ); ?>[frequency]">
896
+ <?php foreach ( $this->get_schedules() as $k => $v ) : ?>
897
+ <option value="<?php echo esc_attr( $k ); ?>" <?php selected( $options['frequency'], $k ); ?>><?php echo esc_html( $v['display'] ); ?></option>
898
+ <?php endforeach; ?>
899
+ <select>
900
+ <?php
901
+ }
902
+
903
+ /**
904
+ * Settings field for notify plugins.
905
+ *
906
+ * @return void
907
+ */
908
+ public function sc_wpun_settings_main_field_notify_plugins() {
909
+ $options = $this->get_set_options( self::OPT_FIELD );
910
+ ?>
911
+ <label><input name="<?php echo esc_attr( self::OPT_FIELD ); ?>[notify_plugins]" type="radio" value="0" <?php checked( $options['notify_plugins'], 0 ); ?> /> <?php esc_html_e( 'No', 'wp-updates-notifier' ); ?>
912
+ </label><br />
913
+ <label><input name="<?php echo esc_attr( self::OPT_FIELD ); ?>[notify_plugins]" type="radio" value="1" <?php checked( $options['notify_plugins'], 1 ); ?> /> <?php esc_html_e( 'Yes', 'wp-updates-notifier' ); ?>
914
+ </label><br />
915
+ <label><input name="<?php echo esc_attr( self::OPT_FIELD ); ?>[notify_plugins]" type="radio" value="2" <?php checked( $options['notify_plugins'], 2 ); ?> /> <?php esc_html_e( 'Yes but only active plugins', 'wp-updates-notifier' ); ?>
916
+ </label>
917
+ <?php
918
+ }
919
+
920
+ /**
921
+ * Settings field for notify themes.
922
+ *
923
+ * @return void
924
+ */
925
+ public function sc_wpun_settings_main_field_notify_themes() {
926
+ $options = $this->get_set_options( self::OPT_FIELD );
927
+ ?>
928
+ <label><input name="<?php echo esc_attr( self::OPT_FIELD ); ?>[notify_themes]" type="radio" value="0" <?php checked( $options['notify_themes'], 0 ); ?> /> <?php esc_html_e( 'No', 'wp-updates-notifier' ); ?>
929
+ </label><br />
930
+ <label><input name="<?php echo esc_attr( self::OPT_FIELD ); ?>[notify_themes]" type="radio" value="1" <?php checked( $options['notify_themes'], 1 ); ?> /> <?php esc_html_e( 'Yes', 'wp-updates-notifier' ); ?>
931
+ </label><br />
932
+ <label><input name="<?php echo esc_attr( self::OPT_FIELD ); ?>[notify_themes]" type="radio" value="2" <?php checked( $options['notify_themes'], 2 ); ?> /> <?php esc_html_e( 'Yes but only active themes', 'wp-updates-notifier' ); ?>
933
+ </label>
934
+ <?php
935
+ }
936
+
937
+ /**
938
+ * Settings field for notify automatic.
939
+ *
940
+ * @return void
941
+ */
942
+ public function sc_wpun_settings_main_field_notify_automatic() {
943
+ $options = $this->get_set_options( self::OPT_FIELD );
944
+ ?>
945
+ <label><input name="<?php echo esc_attr( self::OPT_FIELD ); ?>[notify_automatic]" type="checkbox" value="1" <?php checked( $options['notify_automatic'], 1 ); ?> /> <?php esc_html_e( 'Yes', 'wp-updates-notifier' ); ?>
946
+ </label>
947
+ <?php
948
+ }
949
+
950
+ /**
951
+ * Settings field for hiding updates.
952
+ *
953
+ * @return void
954
+ */
955
+ public function sc_wpun_settings_main_field_hide_updates() {
956
+ $options = $this->get_set_options( self::OPT_FIELD );
957
+ ?>
958
+ <select id="sc_wpun_settings_main_hide_updates" name="<?php echo esc_attr( self::OPT_FIELD ); ?>[hide_updates]">
959
+ <option value="1" <?php selected( $options['hide_updates'], 1 ); ?>><?php esc_html_e( 'Yes', 'wp-updates-notifier' ); ?></option>
960
+ <option value="0" <?php selected( $options['hide_updates'], 0 ); ?>><?php esc_html_e( 'No', 'wp-updates-notifier' ); ?></option>
961
+ </select>
962
+ <?php
963
+ }
964
+
965
+ /**
966
+ * Output the text at the top of the email settings section (function is required even if it outputs nothing).
967
+ *
968
+ * @return void
969
+ */
970
+ public function sc_wpun_settings_email_notifications_text() {
971
+ }
972
+
973
+ /**
974
+ * Settings field for email notifications.
975
+ *
976
+ * @return void
977
+ */
978
+ public function sc_wpun_settings_email_notifications_field_email_notifications() {
979
+ $options = $this->get_set_options( self::OPT_FIELD );
980
+ ?>
981
+ <label><input name="<?php echo esc_attr( self::OPT_FIELD ); ?>[email_notifications]" type="checkbox" value="1" <?php checked( $options['email_notifications'], 1 ); ?> /> <?php esc_html_e( 'Yes', 'wp-updates-notifier' ); ?>
982
+ </label>
983
+ <?php
984
+ }
985
+
986
+ /**
987
+ * Settings field for email to field.
988
+ *
989
+ * @return void
990
+ */
991
+ public function sc_wpun_settings_email_notifications_field_notify_to() {
992
+ $options = $this->get_set_options( self::OPT_FIELD );
993
+ ?>
994
+ <input id="sc_wpun_settings_email_notifications_notify_to" class="regular-text" name="<?php echo esc_attr( self::OPT_FIELD ); ?>[notify_to]" value="<?php echo esc_attr( $options['notify_to'] ); ?>" />
995
+ <span class="description"><?php esc_html_e( 'Separate multiple email address with a comma (,)', 'wp-updates-notifier' ); ?></span>
996
+ <?php
997
+ }
998
+
999
+ /**
1000
+ * Settings field for email from field.
1001
+ *
1002
+ * @return void
1003
+ */
1004
+ public function sc_wpun_settings_email_notifications_field_notify_from() {
1005
+ $options = $this->get_set_options( self::OPT_FIELD );
1006
+ ?>
1007
+ <input id="sc_wpun_settings_email_notifications_notify_from" class="regular-text" name="<?php echo esc_attr( self::OPT_FIELD ); ?>[notify_from]" value="<?php echo esc_attr( $options['notify_from'] ); ?>" />
1008
+ <?php
1009
+ }
1010
+
1011
+ /**
1012
+ * Output the text at the top of the slack settings section (function is required even if it outputs nothing).
1013
+ *
1014
+ * @return void
1015
+ */
1016
+ public function sc_wpun_settings_slack_notifications_text() {
1017
+ }
1018
+
1019
+ /**
1020
+ * Settings field for slack notifications.
1021
+ *
1022
+ * @return void
1023
+ */
1024
+ public function sc_wpun_settings_slack_notifications_field_slack_notifications() {
1025
+ $options = $this->get_set_options( self::OPT_FIELD );
1026
+ ?>
1027
+ <label><input name="<?php echo esc_attr( self::OPT_FIELD ); ?>[slack_notifications]" type="checkbox" value="1" <?php checked( $options['slack_notifications'], 1 ); ?> /> <?php esc_html_e( 'Yes', 'wp-updates-notifier' ); ?>
1028
+ </label>
1029
+ <?php
1030
+ }
1031
+
1032
+ /**
1033
+ * Settings field for slack webhook url.
1034
+ *
1035
+ * @return void
1036
+ */
1037
+ public function sc_wpun_settings_slack_notifications_field_slack_webhook_url() {
1038
+ $options = $this->get_set_options( self::OPT_FIELD );
1039
+ ?>
1040
+ <input id="sc_wpun_settings_slack_notifications_slack_webhook_url" class="regular-text" name="<?php echo esc_attr( self::OPT_FIELD ); ?>[slack_webhook_url]" value="<?php echo esc_attr( $options['slack_webhook_url'] ); ?>" />
1041
+ <?php
1042
+ }
1043
+
1044
+ /**
1045
+ * Settings field for slack channel override.
1046
+ *
1047
+ * @return void
1048
+ */
1049
+ public function sc_wpun_settings_slack_notifications_field_slack_channel_override() {
1050
+ $options = $this->get_set_options( self::OPT_FIELD );
1051
+ ?>
1052
+ <input id="sc_wpun_settings_slack_notifications_slack_channel_override" class="regular-text" name="<?php echo esc_attr( self::OPT_FIELD ); ?>[slack_channel_override]" value="<?php echo esc_attr( $options['slack_channel_override'] ); ?>" />
1053
+ <span class="description"><?php esc_html_e( 'Not requred.', 'wp-updates-notifier' ); ?></span>
1054
+ <?php
1055
+ }
1056
+ }
1057
+ }
1058
+
1059
+ new SC_WP_Updates_Notifier();
languages/wp-updates-notifier-de_DE.po CHANGED
@@ -20,240 +20,240 @@ msgstr ""
20
  "X-Textdomain-Support: yes"
21
 
22
  #. translators: plugin header field 'Name'
23
- #: wp-updates-notifier.php:0
24
- #: wp-updates-notifier.php:367
25
- #: wp-updates-notifier.php:400
26
  #@ wp-updates-notifier
27
  msgid "WP Updates Notifier"
28
  msgstr "Aktualisierungsalarm"
29
 
30
  #. translators: plugin header field 'PluginURI'
31
- #: wp-updates-notifier.php:0
32
  #@ wp-updates-notifier
33
  msgid "http://l3rady.com/projects/wp-updates-notifier/"
34
  msgstr ""
35
 
36
  #. translators: plugin header field 'Description'
37
- #: wp-updates-notifier.php:0
38
  #@ wp-updates-notifier
39
  msgid "Sends email to notify you if there are any updates for your WordPress site. Can notify about core, plugin and theme updates."
40
  msgstr "Sendet E-Mails, um Sie zu benachrichtigen, wenn es irgendwelche Aktualisierungen für Ihre WordPress-Website gibt. Kann über Aktualisierungen für WordPress, Plugins und Themes benachrichtigen."
41
 
42
  #. translators: plugin header field 'Author'
43
- #: wp-updates-notifier.php:0
44
  #@ wp-updates-notifier
45
  msgid "Scott Cariss"
46
  msgstr ""
47
 
48
  #. translators: plugin header field 'AuthorURI'
49
- #: wp-updates-notifier.php:0
50
  #@ wp-updates-notifier
51
  msgid "http://l3rady.com/"
52
  msgstr ""
53
 
54
- #: wp-updates-notifier.php:159
55
- #: wp-updates-notifier.php:414
56
  #@ wp-updates-notifier
57
  msgid "Settings"
58
  msgstr "Einstellungen"
59
 
60
- #: wp-updates-notifier.php:187
61
  #@ wp-updates-notifier
62
  msgid "There are updates available for your WordPress site:"
63
  msgstr "Es sind Aktualisierungen für Ihre WordPress-Webseite verfügbar:"
64
 
65
- #: wp-updates-notifier.php:188
66
  #, php-format
67
  #@ wp-updates-notifier
68
  msgid "Please visit %s to update."
69
  msgstr "Bitte besuche %s um zu updaten."
70
 
71
- #: wp-updates-notifier.php:209
72
  #, php-format
73
  #@ wp-updates-notifier
74
  msgid "WP-Core: WordPress is out of date. Please update from version %s to %s"
75
  msgstr "WordPress: WordPress ist veraltet. Bitte update von Version %s auf %s"
76
 
77
- #: wp-updates-notifier.php:247
78
  #, php-format
79
  #@ wp-updates-notifier
80
  msgid "Plugin: %s is out of date. Please update from version %s to %s"
81
  msgstr "Plugin: %s ist veraltet. Bitte aktualisiere von Version %s auf %s"
82
 
83
- #: wp-updates-notifier.php:248
84
  #, php-format
85
  #@ wp-updates-notifier
86
  msgid "Details: %s"
87
  msgstr "Details: %s"
88
 
89
- #: wp-updates-notifier.php:249
90
  #, php-format
91
  #@ wp-updates-notifier
92
  msgid "Changelog: %s%s"
93
  msgstr "Änderungen: %s%s"
94
 
95
- #: wp-updates-notifier.php:251
96
  #, php-format
97
  #@ default
98
  msgid "Compatibility with WordPress %1$s: 100%% (according to its author)"
99
  msgstr ""
100
 
101
- #: wp-updates-notifier.php:254
102
  #, php-format
103
  #@ default
104
  msgid "Compatibility with WordPress %1$s: %2$d%% (%3$d \"works\" votes out of %4$d total)"
105
  msgstr ""
106
 
107
- #: wp-updates-notifier.php:256
108
  #, php-format
109
  #@ default
110
  msgid "Compatibility with WordPress %1$s: Unknown"
111
  msgstr ""
112
 
113
- #: wp-updates-notifier.php:258
114
  #, php-format
115
  #@ wp-updates-notifier
116
  msgid "Compatibility: %s"
117
  msgstr "Kompatibilität: %s"
118
 
119
- #: wp-updates-notifier.php:295
120
  #, php-format
121
  #@ wp-updates-notifier
122
  msgid "Theme: %s is out of date. Please update from version %s to %s"
123
  msgstr "Theme: %s ist veraltet. Bitte aktualisiere von Version %s auf %s"
124
 
125
- #: wp-updates-notifier.php:357
126
  #, php-format
127
  #@ wp-updates-notifier
128
  msgid "WP Updates Notifier: Updates Available @ %s"
129
  msgstr "WP Updates Notifier: Aktualisierungen stehen bereit @ %s"
130
 
131
- #: wp-updates-notifier.php:406
132
  #@ wp-updates-notifier
133
  msgid "Save settings"
134
  msgstr "Einstellungen speichern"
135
 
136
- #: wp-updates-notifier.php:407
137
  #@ wp-updates-notifier
138
  msgid "Save settings with test email"
139
  msgstr "Einstellungen speichern und Test-E-Mail versenden"
140
 
141
- #: wp-updates-notifier.php:415
142
  #@ wp-updates-notifier
143
  msgid "Frequency to check"
144
  msgstr "Check-Häufigkeit"
145
 
146
- #: wp-updates-notifier.php:416
147
  #@ wp-updates-notifier
148
  msgid "Notify email to"
149
  msgstr "Benachrichtigungs-E-Mail an"
150
 
151
- #: wp-updates-notifier.php:417
152
  #@ wp-updates-notifier
153
  msgid "Notify email from"
154
  msgstr "Benachrichtigungs-E-Mail-Absender"
155
 
156
- #: wp-updates-notifier.php:418
157
  #@ wp-updates-notifier
158
  msgid "Notify about plugin updates?"
159
  msgstr "Über Plugin-Aktualisierungen benachrichtigen?"
160
 
161
- #: wp-updates-notifier.php:419
162
  #@ wp-updates-notifier
163
  msgid "Notify about theme updates?"
164
  msgstr "Über Theme-Aktualisierungen benachrichtigen?"
165
 
166
- #: wp-updates-notifier.php:420
167
  #@ wp-updates-notifier
168
  msgid "Hide core WP update nag from non-admin users?"
169
  msgstr "WordPress-Aktualisierungen vor Nicht-Admins verstecken?"
170
 
171
- #: wp-updates-notifier.php:429
172
  #@ wp-updates-notifier
173
  msgid "Invalid frequency entered"
174
  msgstr "Ungültige Häufigkeit eingegeben"
175
 
176
- #: wp-updates-notifier.php:439
177
  #@ wp-updates-notifier
178
  msgid "One or more email to addresses are invalid"
179
  msgstr "Eine oder mehrere E-Mail-Adressen sind ungültig"
180
 
181
- #: wp-updates-notifier.php:449
182
  #@ wp-updates-notifier
183
  msgid "No email to address entered"
184
  msgstr "Keine E-Mail-Adresse eingegeben"
185
 
186
- #: wp-updates-notifier.php:456
187
  #@ wp-updates-notifier
188
  msgid "Invalid email from entered"
189
  msgstr "Ungültige Absender-E-Mail-Adresse eingegeben"
190
 
191
- #: wp-updates-notifier.php:463
192
  #@ wp-updates-notifier
193
  msgid "Invalid plugin updates value entered"
194
  msgstr "Ungültiger Wert für Plugin-Updates eingegeben"
195
 
196
- #: wp-updates-notifier.php:470
197
  #@ wp-updates-notifier
198
  msgid "Invalid theme updates value entered"
199
  msgstr "Ungültiger Wert für Theme-Updates eingegeben"
200
 
201
- #: wp-updates-notifier.php:477
202
  #@ wp-updates-notifier
203
  msgid "Invalid hide updates value entered"
204
  msgstr "Ungültiger Wert für \\\"Updates verstecken\\\" eingegeben"
205
 
206
- #: wp-updates-notifier.php:488
207
  #@ wp-updates-notifier
208
  msgid "This is a test message from WP Updates Notifier."
209
  msgstr "Dies ist eine Test-Nachricht von WP Updates Notifier."
210
 
211
- #: wp-updates-notifier.php:496
212
  #@ wp-updates-notifier
213
  msgid "Hourly"
214
  msgstr "Stündlich"
215
 
216
- #: wp-updates-notifier.php:497
217
  #@ wp-updates-notifier
218
  msgid "Twice Daily"
219
  msgstr "Zweimal täglich"
220
 
221
- #: wp-updates-notifier.php:498
222
  #@ wp-updates-notifier
223
  msgid "Daily"
224
  msgstr "Täglich"
225
 
226
- #: wp-updates-notifier.php:504
227
  #@ wp-updates-notifier
228
  msgid "Separate multiple email address with a comma (,)"
229
  msgstr "Trenne mehrere E-Mail-Adressen durch Komma (,)"
230
 
231
- #: wp-updates-notifier.php:513
232
- #: wp-updates-notifier.php:521
233
- #: wp-updates-notifier.php:531
234
  #@ wp-updates-notifier
235
  msgid "No"
236
  msgstr "Nein"
237
 
238
- #: wp-updates-notifier.php:514
239
- #: wp-updates-notifier.php:522
240
- #: wp-updates-notifier.php:530
241
  #@ wp-updates-notifier
242
  msgid "Yes"
243
  msgstr "Ja"
244
 
245
- #: wp-updates-notifier.php:515
246
  #@ wp-updates-notifier
247
  msgid "Yes but only active plugins"
248
  msgstr "Ja, aber nur aktive Plugins"
249
 
250
- #: wp-updates-notifier.php:523
251
  #@ wp-updates-notifier
252
  msgid "Yes but only active themes"
253
  msgstr "Ja, aber nur aktives Theme"
254
 
255
  #. translators: plugin header field 'Version'
256
- #: wp-updates-notifier.php:0
257
  #@ wp-updates-notifier
258
  msgid "1.3.1"
259
  msgstr ""
20
  "X-Textdomain-Support: yes"
21
 
22
  #. translators: plugin header field 'Name'
23
+ #: class-sc-wp-updates-notifier.php:0
24
+ #: class-sc-wp-updates-notifier.php:367
25
+ #: class-sc-wp-updates-notifier.php:400
26
  #@ wp-updates-notifier
27
  msgid "WP Updates Notifier"
28
  msgstr "Aktualisierungsalarm"
29
 
30
  #. translators: plugin header field 'PluginURI'
31
+ #: class-sc-wp-updates-notifier.php:0
32
  #@ wp-updates-notifier
33
  msgid "http://l3rady.com/projects/wp-updates-notifier/"
34
  msgstr ""
35
 
36
  #. translators: plugin header field 'Description'
37
+ #: class-sc-wp-updates-notifier.php:0
38
  #@ wp-updates-notifier
39
  msgid "Sends email to notify you if there are any updates for your WordPress site. Can notify about core, plugin and theme updates."
40
  msgstr "Sendet E-Mails, um Sie zu benachrichtigen, wenn es irgendwelche Aktualisierungen für Ihre WordPress-Website gibt. Kann über Aktualisierungen für WordPress, Plugins und Themes benachrichtigen."
41
 
42
  #. translators: plugin header field 'Author'
43
+ #: class-sc-wp-updates-notifier.php:0
44
  #@ wp-updates-notifier
45
  msgid "Scott Cariss"
46
  msgstr ""
47
 
48
  #. translators: plugin header field 'AuthorURI'
49
+ #: class-sc-wp-updates-notifier.php:0
50
  #@ wp-updates-notifier
51
  msgid "http://l3rady.com/"
52
  msgstr ""
53
 
54
+ #: class-sc-wp-updates-notifier.php:159
55
+ #: class-sc-wp-updates-notifier.php:414
56
  #@ wp-updates-notifier
57
  msgid "Settings"
58
  msgstr "Einstellungen"
59
 
60
+ #: class-sc-wp-updates-notifier.php:187
61
  #@ wp-updates-notifier
62
  msgid "There are updates available for your WordPress site:"
63
  msgstr "Es sind Aktualisierungen für Ihre WordPress-Webseite verfügbar:"
64
 
65
+ #: class-sc-wp-updates-notifier.php:188
66
  #, php-format
67
  #@ wp-updates-notifier
68
  msgid "Please visit %s to update."
69
  msgstr "Bitte besuche %s um zu updaten."
70
 
71
+ #: class-sc-wp-updates-notifier.php:209
72
  #, php-format
73
  #@ wp-updates-notifier
74
  msgid "WP-Core: WordPress is out of date. Please update from version %s to %s"
75
  msgstr "WordPress: WordPress ist veraltet. Bitte update von Version %s auf %s"
76
 
77
+ #: class-sc-wp-updates-notifier.php:247
78
  #, php-format
79
  #@ wp-updates-notifier
80
  msgid "Plugin: %s is out of date. Please update from version %s to %s"
81
  msgstr "Plugin: %s ist veraltet. Bitte aktualisiere von Version %s auf %s"
82
 
83
+ #: class-sc-wp-updates-notifier.php:248
84
  #, php-format
85
  #@ wp-updates-notifier
86
  msgid "Details: %s"
87
  msgstr "Details: %s"
88
 
89
+ #: class-sc-wp-updates-notifier.php:249
90
  #, php-format
91
  #@ wp-updates-notifier
92
  msgid "Changelog: %s%s"
93
  msgstr "Änderungen: %s%s"
94
 
95
+ #: class-sc-wp-updates-notifier.php:251
96
  #, php-format
97
  #@ default
98
  msgid "Compatibility with WordPress %1$s: 100%% (according to its author)"
99
  msgstr ""
100
 
101
+ #: class-sc-wp-updates-notifier.php:254
102
  #, php-format
103
  #@ default
104
  msgid "Compatibility with WordPress %1$s: %2$d%% (%3$d \"works\" votes out of %4$d total)"
105
  msgstr ""
106
 
107
+ #: class-sc-wp-updates-notifier.php:256
108
  #, php-format
109
  #@ default
110
  msgid "Compatibility with WordPress %1$s: Unknown"
111
  msgstr ""
112
 
113
+ #: class-sc-wp-updates-notifier.php:258
114
  #, php-format
115
  #@ wp-updates-notifier
116
  msgid "Compatibility: %s"
117
  msgstr "Kompatibilität: %s"
118
 
119
+ #: class-sc-wp-updates-notifier.php:295
120
  #, php-format
121
  #@ wp-updates-notifier
122
  msgid "Theme: %s is out of date. Please update from version %s to %s"
123
  msgstr "Theme: %s ist veraltet. Bitte aktualisiere von Version %s auf %s"
124
 
125
+ #: class-sc-wp-updates-notifier.php:357
126
  #, php-format
127
  #@ wp-updates-notifier
128
  msgid "WP Updates Notifier: Updates Available @ %s"
129
  msgstr "WP Updates Notifier: Aktualisierungen stehen bereit @ %s"
130
 
131
+ #: class-sc-wp-updates-notifier.php:406
132
  #@ wp-updates-notifier
133
  msgid "Save settings"
134
  msgstr "Einstellungen speichern"
135
 
136
+ #: class-sc-wp-updates-notifier.php:407
137
  #@ wp-updates-notifier
138
  msgid "Save settings with test email"
139
  msgstr "Einstellungen speichern und Test-E-Mail versenden"
140
 
141
+ #: class-sc-wp-updates-notifier.php:415
142
  #@ wp-updates-notifier
143
  msgid "Frequency to check"
144
  msgstr "Check-Häufigkeit"
145
 
146
+ #: class-sc-wp-updates-notifier.php:416
147
  #@ wp-updates-notifier
148
  msgid "Notify email to"
149
  msgstr "Benachrichtigungs-E-Mail an"
150
 
151
+ #: class-sc-wp-updates-notifier.php:417
152
  #@ wp-updates-notifier
153
  msgid "Notify email from"
154
  msgstr "Benachrichtigungs-E-Mail-Absender"
155
 
156
+ #: class-sc-wp-updates-notifier.php:418
157
  #@ wp-updates-notifier
158
  msgid "Notify about plugin updates?"
159
  msgstr "Über Plugin-Aktualisierungen benachrichtigen?"
160
 
161
+ #: class-sc-wp-updates-notifier.php:419
162
  #@ wp-updates-notifier
163
  msgid "Notify about theme updates?"
164
  msgstr "Über Theme-Aktualisierungen benachrichtigen?"
165
 
166
+ #: class-sc-wp-updates-notifier.php:420
167
  #@ wp-updates-notifier
168
  msgid "Hide core WP update nag from non-admin users?"
169
  msgstr "WordPress-Aktualisierungen vor Nicht-Admins verstecken?"
170
 
171
+ #: class-sc-wp-updates-notifier.php:429
172
  #@ wp-updates-notifier
173
  msgid "Invalid frequency entered"
174
  msgstr "Ungültige Häufigkeit eingegeben"
175
 
176
+ #: class-sc-wp-updates-notifier.php:439
177
  #@ wp-updates-notifier
178
  msgid "One or more email to addresses are invalid"
179
  msgstr "Eine oder mehrere E-Mail-Adressen sind ungültig"
180
 
181
+ #: class-sc-wp-updates-notifier.php:449
182
  #@ wp-updates-notifier
183
  msgid "No email to address entered"
184
  msgstr "Keine E-Mail-Adresse eingegeben"
185
 
186
+ #: class-sc-wp-updates-notifier.php:456
187
  #@ wp-updates-notifier
188
  msgid "Invalid email from entered"
189
  msgstr "Ungültige Absender-E-Mail-Adresse eingegeben"
190
 
191
+ #: class-sc-wp-updates-notifier.php:463
192
  #@ wp-updates-notifier
193
  msgid "Invalid plugin updates value entered"
194
  msgstr "Ungültiger Wert für Plugin-Updates eingegeben"
195
 
196
+ #: class-sc-wp-updates-notifier.php:470
197
  #@ wp-updates-notifier
198
  msgid "Invalid theme updates value entered"
199
  msgstr "Ungültiger Wert für Theme-Updates eingegeben"
200
 
201
+ #: class-sc-wp-updates-notifier.php:477
202
  #@ wp-updates-notifier
203
  msgid "Invalid hide updates value entered"
204
  msgstr "Ungültiger Wert für \\\"Updates verstecken\\\" eingegeben"
205
 
206
+ #: class-sc-wp-updates-notifier.php:488
207
  #@ wp-updates-notifier
208
  msgid "This is a test message from WP Updates Notifier."
209
  msgstr "Dies ist eine Test-Nachricht von WP Updates Notifier."
210
 
211
+ #: class-sc-wp-updates-notifier.php:496
212
  #@ wp-updates-notifier
213
  msgid "Hourly"
214
  msgstr "Stündlich"
215
 
216
+ #: class-sc-wp-updates-notifier.php:497
217
  #@ wp-updates-notifier
218
  msgid "Twice Daily"
219
  msgstr "Zweimal täglich"
220
 
221
+ #: class-sc-wp-updates-notifier.php:498
222
  #@ wp-updates-notifier
223
  msgid "Daily"
224
  msgstr "Täglich"
225
 
226
+ #: class-sc-wp-updates-notifier.php:504
227
  #@ wp-updates-notifier
228
  msgid "Separate multiple email address with a comma (,)"
229
  msgstr "Trenne mehrere E-Mail-Adressen durch Komma (,)"
230
 
231
+ #: class-sc-wp-updates-notifier.php:513
232
+ #: class-sc-wp-updates-notifier.php:521
233
+ #: class-sc-wp-updates-notifier.php:531
234
  #@ wp-updates-notifier
235
  msgid "No"
236
  msgstr "Nein"
237
 
238
+ #: class-sc-wp-updates-notifier.php:514
239
+ #: class-sc-wp-updates-notifier.php:522
240
+ #: class-sc-wp-updates-notifier.php:530
241
  #@ wp-updates-notifier
242
  msgid "Yes"
243
  msgstr "Ja"
244
 
245
+ #: class-sc-wp-updates-notifier.php:515
246
  #@ wp-updates-notifier
247
  msgid "Yes but only active plugins"
248
  msgstr "Ja, aber nur aktive Plugins"
249
 
250
+ #: class-sc-wp-updates-notifier.php:523
251
  #@ wp-updates-notifier
252
  msgid "Yes but only active themes"
253
  msgstr "Ja, aber nur aktives Theme"
254
 
255
  #. translators: plugin header field 'Version'
256
+ #: class-sc-wp-updates-notifier.php:0
257
  #@ wp-updates-notifier
258
  msgid "1.3.1"
259
  msgstr ""
languages/wp-updates-notifier-fr_FR.po CHANGED
@@ -17,240 +17,240 @@ msgstr ""
17
 
18
  #@ wp-updates-notifier
19
  #. translators: plugin header field 'Name'
20
- #: wp-updates-notifier.php:0
21
- #: wp-updates-notifier.php:367
22
- #: wp-updates-notifier.php:400
23
  msgid "WP Updates Notifier"
24
  msgstr "WP Updates Notifier"
25
 
26
  #@ wp-updates-notifier
27
  #. translators: plugin header field 'PluginURI'
28
- #: wp-updates-notifier.php:0
29
  msgid "http://l3rady.com/projects/wp-updates-notifier/"
30
  msgstr "http://wordpress.org/extend/plugins/wp-updates-notifier/"
31
 
32
  #@ wp-updates-notifier
33
  #. translators: plugin header field 'Description'
34
- #: wp-updates-notifier.php:0
35
  msgid "Sends email to notify you if there are any updates for your WordPress site. Can notify about core, plugin and theme updates."
36
  msgstr "Vous envoie un courriel s'il existe des mises à jour disponibles pour votre site WordPress. Peut vous avertir à propos de mises à jour sur le CMS, les extensions ou les thèmes."
37
 
38
  #@ wp-updates-notifier
39
  #. translators: plugin header field 'Author'
40
- #: wp-updates-notifier.php:0
41
  msgid "Scott Cariss"
42
  msgstr ""
43
 
44
  #@ wp-updates-notifier
45
  #. translators: plugin header field 'AuthorURI'
46
- #: wp-updates-notifier.php:0
47
  msgid "http://l3rady.com/"
48
  msgstr ""
49
 
50
  #@ wp-updates-notifier
51
- #: wp-updates-notifier.php:159
52
- #: wp-updates-notifier.php:414
53
  msgid "Settings"
54
  msgstr "Configuration"
55
 
56
  #@ wp-updates-notifier
57
- #: wp-updates-notifier.php:187
58
  msgid "There are updates available for your WordPress site:"
59
  msgstr "Il y a des mises à jour disponibles pour votre site WordPress :"
60
 
61
  #@ wp-updates-notifier
62
- #: wp-updates-notifier.php:188
63
  #, php-format
64
  msgid "Please visit %s to update."
65
  msgstr "Rendez vous sur %s pour effectuer les mises à jour."
66
 
67
  #@ wp-updates-notifier
68
- #: wp-updates-notifier.php:209
69
  #, php-format
70
  msgid "WP-Core: WordPress is out of date. Please update from version %s to %s"
71
  msgstr "WordPress : Le cœur du CMS n'est plus à jour. Veuillez passer de la version %s à la version %s"
72
 
73
  #@ wp-updates-notifier
74
- #: wp-updates-notifier.php:247
75
  #, php-format
76
  msgid "Plugin: %s is out of date. Please update from version %s to %s"
77
  msgstr "Extension : %s n'est plus à jour. Veuillez passer de la version %s à la version %s"
78
 
79
  #@ wp-updates-notifier
80
- #: wp-updates-notifier.php:248
81
  #, php-format
82
  msgid "Details: %s"
83
  msgstr "Détails : %s"
84
 
85
  #@ wp-updates-notifier
86
- #: wp-updates-notifier.php:249
87
  #, php-format
88
  msgid "Changelog: %s%s"
89
  msgstr "Changelog : %s%s"
90
 
91
  #@ default
92
- #: wp-updates-notifier.php:251
93
  #, php-format
94
  msgid "Compatibility with WordPress %1$s: 100%% (according to its author)"
95
  msgstr ""
96
 
97
  #@ default
98
- #: wp-updates-notifier.php:254
99
  #, php-format
100
  msgid "Compatibility with WordPress %1$s: %2$d%% (%3$d \"works\" votes out of %4$d total)"
101
  msgstr ""
102
 
103
  #@ default
104
- #: wp-updates-notifier.php:256
105
  #, php-format
106
  msgid "Compatibility with WordPress %1$s: Unknown"
107
  msgstr ""
108
 
109
  #@ wp-updates-notifier
110
- #: wp-updates-notifier.php:258
111
  #, php-format
112
  msgid "Compatibility: %s"
113
  msgstr "Compatibilité : %s"
114
 
115
  #@ wp-updates-notifier
116
- #: wp-updates-notifier.php:295
117
  #, php-format
118
  msgid "Theme: %s is out of date. Please update from version %s to %s"
119
  msgstr "Thème : %s n'est plus à jour. Veuillez passer de la version %s à la version %s"
120
 
121
  #@ wp-updates-notifier
122
- #: wp-updates-notifier.php:357
123
  #, php-format
124
  msgid "WP Updates Notifier: Updates Available @ %s"
125
  msgstr "WP Updates Notifier : Des mises à jour sont disponibles @ %s"
126
 
127
  #@ wp-updates-notifier
128
- #: wp-updates-notifier.php:406
129
  msgid "Save settings"
130
  msgstr "Enregistrer les paramètres"
131
 
132
  #@ wp-updates-notifier
133
- #: wp-updates-notifier.php:407
134
  msgid "Save settings with test email"
135
  msgstr "Enregistrer et envoyer un courriel de test"
136
 
137
  #@ wp-updates-notifier
138
- #: wp-updates-notifier.php:415
139
  msgid "Frequency to check"
140
  msgstr "Fréquence de contrôle"
141
 
142
  #@ wp-updates-notifier
143
- #: wp-updates-notifier.php:416
144
  msgid "Notify email to"
145
  msgstr "Envoyer un courriel à"
146
 
147
  #@ wp-updates-notifier
148
- #: wp-updates-notifier.php:417
149
  msgid "Notify email from"
150
  msgstr "Envoyer le courriel en tant que"
151
 
152
  #@ wp-updates-notifier
153
- #: wp-updates-notifier.php:418
154
  msgid "Notify about plugin updates?"
155
  msgstr "Prévenir pour les mises à jour d'extensions ?"
156
 
157
  #@ wp-updates-notifier
158
- #: wp-updates-notifier.php:419
159
  msgid "Notify about theme updates?"
160
  msgstr "Prévenir pour les mises à jour de thèmes ?"
161
 
162
  #@ wp-updates-notifier
163
- #: wp-updates-notifier.php:420
164
  msgid "Hide core WP update nag from non-admin users?"
165
  msgstr "Masquer les notifications de mises à jour aux simples utilisateurs ?"
166
 
167
  #@ wp-updates-notifier
168
- #: wp-updates-notifier.php:429
169
  msgid "Invalid frequency entered"
170
  msgstr "Fréquence de contrôle incorrecte"
171
 
172
  #@ wp-updates-notifier
173
- #: wp-updates-notifier.php:439
174
  msgid "One or more email to addresses are invalid"
175
  msgstr "Une adresse de courriel est invalide, ou plusieurs"
176
 
177
  #@ wp-updates-notifier
178
- #: wp-updates-notifier.php:449
179
  msgid "No email to address entered"
180
  msgstr "Aucune adresse de courriel saisie"
181
 
182
  #@ wp-updates-notifier
183
- #: wp-updates-notifier.php:456
184
  msgid "Invalid email from entered"
185
  msgstr "Adresse de courriel saisie invalide"
186
 
187
  #@ wp-updates-notifier
188
- #: wp-updates-notifier.php:463
189
  msgid "Invalid plugin updates value entered"
190
  msgstr "Valeur invalide pour les mises à jour d'extensions"
191
 
192
  #@ wp-updates-notifier
193
- #: wp-updates-notifier.php:470
194
  msgid "Invalid theme updates value entered"
195
  msgstr "Valeur invalide pour les mises à jour de thèmes"
196
 
197
  #@ wp-updates-notifier
198
- #: wp-updates-notifier.php:477
199
  msgid "Invalid hide updates value entered"
200
  msgstr "Valeur invalide pour le masquage de l'alerte"
201
 
202
  #@ wp-updates-notifier
203
- #: wp-updates-notifier.php:488
204
  msgid "This is a test message from WP Updates Notifier."
205
  msgstr "Ceci est un courriel de test provenant de WP Updates Notifier."
206
 
207
  #@ wp-updates-notifier
208
- #: wp-updates-notifier.php:496
209
  msgid "Hourly"
210
  msgstr "Toutes les heures"
211
 
212
  #@ wp-updates-notifier
213
- #: wp-updates-notifier.php:497
214
  msgid "Twice Daily"
215
  msgstr "2 fois par jour"
216
 
217
  #@ wp-updates-notifier
218
- #: wp-updates-notifier.php:498
219
  msgid "Daily"
220
  msgstr "1 fois par jour"
221
 
222
  #@ wp-updates-notifier
223
- #: wp-updates-notifier.php:504
224
  msgid "Separate multiple email address with a comma (,)"
225
  msgstr "Séparer les adresses de courriel multiples par une virgule (,)"
226
 
227
  #@ wp-updates-notifier
228
- #: wp-updates-notifier.php:513
229
- #: wp-updates-notifier.php:521
230
- #: wp-updates-notifier.php:531
231
  msgid "No"
232
  msgstr "Non"
233
 
234
  #@ wp-updates-notifier
235
- #: wp-updates-notifier.php:514
236
- #: wp-updates-notifier.php:522
237
- #: wp-updates-notifier.php:530
238
  msgid "Yes"
239
  msgstr "Oui"
240
 
241
  #@ wp-updates-notifier
242
- #: wp-updates-notifier.php:515
243
  msgid "Yes but only active plugins"
244
  msgstr "Oui, mais seulement les extensions activées"
245
 
246
  #@ wp-updates-notifier
247
- #: wp-updates-notifier.php:523
248
  msgid "Yes but only active themes"
249
  msgstr "Oui, mais seulement le thème activé"
250
 
251
  #@ wp-updates-notifier
252
  #. translators: plugin header field 'Version'
253
- #: wp-updates-notifier.php:0
254
  msgid "1.3.1"
255
  msgstr ""
256
 
17
 
18
  #@ wp-updates-notifier
19
  #. translators: plugin header field 'Name'
20
+ #: class-sc-wp-updates-notifier.php:0
21
+ #: class-sc-wp-updates-notifier.php:367
22
+ #: class-sc-wp-updates-notifier.php:400
23
  msgid "WP Updates Notifier"
24
  msgstr "WP Updates Notifier"
25
 
26
  #@ wp-updates-notifier
27
  #. translators: plugin header field 'PluginURI'
28
+ #: class-sc-wp-updates-notifier.php:0
29
  msgid "http://l3rady.com/projects/wp-updates-notifier/"
30
  msgstr "http://wordpress.org/extend/plugins/wp-updates-notifier/"
31
 
32
  #@ wp-updates-notifier
33
  #. translators: plugin header field 'Description'
34
+ #: class-sc-wp-updates-notifier.php:0
35
  msgid "Sends email to notify you if there are any updates for your WordPress site. Can notify about core, plugin and theme updates."
36
  msgstr "Vous envoie un courriel s'il existe des mises à jour disponibles pour votre site WordPress. Peut vous avertir à propos de mises à jour sur le CMS, les extensions ou les thèmes."
37
 
38
  #@ wp-updates-notifier
39
  #. translators: plugin header field 'Author'
40
+ #: class-sc-wp-updates-notifier.php:0
41
  msgid "Scott Cariss"
42
  msgstr ""
43
 
44
  #@ wp-updates-notifier
45
  #. translators: plugin header field 'AuthorURI'
46
+ #: class-sc-wp-updates-notifier.php:0
47
  msgid "http://l3rady.com/"
48
  msgstr ""
49
 
50
  #@ wp-updates-notifier
51
+ #: class-sc-wp-updates-notifier.php:159
52
+ #: class-sc-wp-updates-notifier.php:414
53
  msgid "Settings"
54
  msgstr "Configuration"
55
 
56
  #@ wp-updates-notifier
57
+ #: class-sc-wp-updates-notifier.php:187
58
  msgid "There are updates available for your WordPress site:"
59
  msgstr "Il y a des mises à jour disponibles pour votre site WordPress :"
60
 
61
  #@ wp-updates-notifier
62
+ #: class-sc-wp-updates-notifier.php:188
63
  #, php-format
64
  msgid "Please visit %s to update."
65
  msgstr "Rendez vous sur %s pour effectuer les mises à jour."
66
 
67
  #@ wp-updates-notifier
68
+ #: class-sc-wp-updates-notifier.php:209
69
  #, php-format
70
  msgid "WP-Core: WordPress is out of date. Please update from version %s to %s"
71
  msgstr "WordPress : Le cœur du CMS n'est plus à jour. Veuillez passer de la version %s à la version %s"
72
 
73
  #@ wp-updates-notifier
74
+ #: class-sc-wp-updates-notifier.php:247
75
  #, php-format
76
  msgid "Plugin: %s is out of date. Please update from version %s to %s"
77
  msgstr "Extension : %s n'est plus à jour. Veuillez passer de la version %s à la version %s"
78
 
79
  #@ wp-updates-notifier
80
+ #: class-sc-wp-updates-notifier.php:248
81
  #, php-format
82
  msgid "Details: %s"
83
  msgstr "Détails : %s"
84
 
85
  #@ wp-updates-notifier
86
+ #: class-sc-wp-updates-notifier.php:249
87
  #, php-format
88
  msgid "Changelog: %s%s"
89
  msgstr "Changelog : %s%s"
90
 
91
  #@ default
92
+ #: class-sc-wp-updates-notifier.php:251
93
  #, php-format
94
  msgid "Compatibility with WordPress %1$s: 100%% (according to its author)"
95
  msgstr ""
96
 
97
  #@ default
98
+ #: class-sc-wp-updates-notifier.php:254
99
  #, php-format
100
  msgid "Compatibility with WordPress %1$s: %2$d%% (%3$d \"works\" votes out of %4$d total)"
101
  msgstr ""
102
 
103
  #@ default
104
+ #: class-sc-wp-updates-notifier.php:256
105
  #, php-format
106
  msgid "Compatibility with WordPress %1$s: Unknown"
107
  msgstr ""
108
 
109
  #@ wp-updates-notifier
110
+ #: class-sc-wp-updates-notifier.php:258
111
  #, php-format
112
  msgid "Compatibility: %s"
113
  msgstr "Compatibilité : %s"
114
 
115
  #@ wp-updates-notifier
116
+ #: class-sc-wp-updates-notifier.php:295
117
  #, php-format
118
  msgid "Theme: %s is out of date. Please update from version %s to %s"
119
  msgstr "Thème : %s n'est plus à jour. Veuillez passer de la version %s à la version %s"
120
 
121
  #@ wp-updates-notifier
122
+ #: class-sc-wp-updates-notifier.php:357
123
  #, php-format
124
  msgid "WP Updates Notifier: Updates Available @ %s"
125
  msgstr "WP Updates Notifier : Des mises à jour sont disponibles @ %s"
126
 
127
  #@ wp-updates-notifier
128
+ #: class-sc-wp-updates-notifier.php:406
129
  msgid "Save settings"
130
  msgstr "Enregistrer les paramètres"
131
 
132
  #@ wp-updates-notifier
133
+ #: class-sc-wp-updates-notifier.php:407
134
  msgid "Save settings with test email"
135
  msgstr "Enregistrer et envoyer un courriel de test"
136
 
137
  #@ wp-updates-notifier
138
+ #: class-sc-wp-updates-notifier.php:415
139
  msgid "Frequency to check"
140
  msgstr "Fréquence de contrôle"
141
 
142
  #@ wp-updates-notifier
143
+ #: class-sc-wp-updates-notifier.php:416
144
  msgid "Notify email to"
145
  msgstr "Envoyer un courriel à"
146
 
147
  #@ wp-updates-notifier
148
+ #: class-sc-wp-updates-notifier.php:417
149
  msgid "Notify email from"
150
  msgstr "Envoyer le courriel en tant que"
151
 
152
  #@ wp-updates-notifier
153
+ #: class-sc-wp-updates-notifier.php:418
154
  msgid "Notify about plugin updates?"
155
  msgstr "Prévenir pour les mises à jour d'extensions ?"
156
 
157
  #@ wp-updates-notifier
158
+ #: class-sc-wp-updates-notifier.php:419
159
  msgid "Notify about theme updates?"
160
  msgstr "Prévenir pour les mises à jour de thèmes ?"
161
 
162
  #@ wp-updates-notifier
163
+ #: class-sc-wp-updates-notifier.php:420
164
  msgid "Hide core WP update nag from non-admin users?"
165
  msgstr "Masquer les notifications de mises à jour aux simples utilisateurs ?"
166
 
167
  #@ wp-updates-notifier
168
+ #: class-sc-wp-updates-notifier.php:429
169
  msgid "Invalid frequency entered"
170
  msgstr "Fréquence de contrôle incorrecte"
171
 
172
  #@ wp-updates-notifier
173
+ #: class-sc-wp-updates-notifier.php:439
174
  msgid "One or more email to addresses are invalid"
175
  msgstr "Une adresse de courriel est invalide, ou plusieurs"
176
 
177
  #@ wp-updates-notifier
178
+ #: class-sc-wp-updates-notifier.php:449
179
  msgid "No email to address entered"
180
  msgstr "Aucune adresse de courriel saisie"
181
 
182
  #@ wp-updates-notifier
183
+ #: class-sc-wp-updates-notifier.php:456
184
  msgid "Invalid email from entered"
185
  msgstr "Adresse de courriel saisie invalide"
186
 
187
  #@ wp-updates-notifier
188
+ #: class-sc-wp-updates-notifier.php:463
189
  msgid "Invalid plugin updates value entered"
190
  msgstr "Valeur invalide pour les mises à jour d'extensions"
191
 
192
  #@ wp-updates-notifier
193
+ #: class-sc-wp-updates-notifier.php:470
194
  msgid "Invalid theme updates value entered"
195
  msgstr "Valeur invalide pour les mises à jour de thèmes"
196
 
197
  #@ wp-updates-notifier
198
+ #: class-sc-wp-updates-notifier.php:477
199
  msgid "Invalid hide updates value entered"
200
  msgstr "Valeur invalide pour le masquage de l'alerte"
201
 
202
  #@ wp-updates-notifier
203
+ #: class-sc-wp-updates-notifier.php:488
204
  msgid "This is a test message from WP Updates Notifier."
205
  msgstr "Ceci est un courriel de test provenant de WP Updates Notifier."
206
 
207
  #@ wp-updates-notifier
208
+ #: class-sc-wp-updates-notifier.php:496
209
  msgid "Hourly"
210
  msgstr "Toutes les heures"
211
 
212
  #@ wp-updates-notifier
213
+ #: class-sc-wp-updates-notifier.php:497
214
  msgid "Twice Daily"
215
  msgstr "2 fois par jour"
216
 
217
  #@ wp-updates-notifier
218
+ #: class-sc-wp-updates-notifier.php:498
219
  msgid "Daily"
220
  msgstr "1 fois par jour"
221
 
222
  #@ wp-updates-notifier
223
+ #: class-sc-wp-updates-notifier.php:504
224
  msgid "Separate multiple email address with a comma (,)"
225
  msgstr "Séparer les adresses de courriel multiples par une virgule (,)"
226
 
227
  #@ wp-updates-notifier
228
+ #: class-sc-wp-updates-notifier.php:513
229
+ #: class-sc-wp-updates-notifier.php:521
230
+ #: class-sc-wp-updates-notifier.php:531
231
  msgid "No"
232
  msgstr "Non"
233
 
234
  #@ wp-updates-notifier
235
+ #: class-sc-wp-updates-notifier.php:514
236
+ #: class-sc-wp-updates-notifier.php:522
237
+ #: class-sc-wp-updates-notifier.php:530
238
  msgid "Yes"
239
  msgstr "Oui"
240
 
241
  #@ wp-updates-notifier
242
+ #: class-sc-wp-updates-notifier.php:515
243
  msgid "Yes but only active plugins"
244
  msgstr "Oui, mais seulement les extensions activées"
245
 
246
  #@ wp-updates-notifier
247
+ #: class-sc-wp-updates-notifier.php:523
248
  msgid "Yes but only active themes"
249
  msgstr "Oui, mais seulement le thème activé"
250
 
251
  #@ wp-updates-notifier
252
  #. translators: plugin header field 'Version'
253
+ #: class-sc-wp-updates-notifier.php:0
254
  msgid "1.3.1"
255
  msgstr ""
256
 
languages/wp-updates-notifier-ja.po CHANGED
@@ -14,175 +14,175 @@ msgstr ""
14
  "Language: ja\n"
15
  "Plural-Forms: nplurals=1; plural=0;\n"
16
 
17
- #: wp-updates-notifier.php:194 wp-updates-notifier.php:551
18
  msgid "Settings"
19
  msgstr "設定"
20
 
21
- #: wp-updates-notifier.php:224
22
  msgid "There are updates available for your WordPress site:"
23
  msgstr "お使いの WordPress に更新があります:"
24
 
25
- #: wp-updates-notifier.php:225
26
  msgid "Please visit %s to update."
27
  msgstr "更新するには %s を開いてください。"
28
 
29
- #: wp-updates-notifier.php:250
30
  msgid "WP-Core: WordPress is out of date. Please update from version %s to %s"
31
  msgstr "WP 本体: WordPress に新しいバージョンがあります。バージョン %s から %s へ更新してください"
32
 
33
- #: wp-updates-notifier.php:292
34
  msgid "Plugin: %s is out of date. Please update from version %s to %s"
35
  msgstr "プラグイン: %s に新しいバージョンがあります。バージョン %s から %s へ更新してください"
36
 
37
- #: wp-updates-notifier.php:293
38
  msgid "Details: %s"
39
  msgstr "説明: %s"
40
 
41
- #: wp-updates-notifier.php:294
42
  msgid "Changelog: %s%s"
43
  msgstr "更新履歴: %s%s"
44
 
45
- #: wp-updates-notifier.php:303
46
  msgid "Compatibility with WordPress %1$s: Unknown"
47
  msgstr "WordPress %1$s との互換性: 不明"
48
 
49
- #: wp-updates-notifier.php:305
50
  msgid "Compatibility: %s"
51
  msgstr "互換性: %s"
52
 
53
- #: wp-updates-notifier.php:344
54
  msgid "Theme: %s is out of date. Please update from version %s to %s"
55
  msgstr "テーマ: に新しいバージョンがあります。バージョン %s から %s へ更新してください"
56
 
57
- #: wp-updates-notifier.php:410
58
  msgid "WP Updates Notifier: Updates Available @ %s"
59
  msgstr "WP Updates Notifier: %s に更新があります"
60
 
61
  #. #-#-#-#-# wp-updates-notifier.pot (WP Updates Notifier 1.4) #-#-#-#-#
62
  #. Plugin Name of the plugin/theme
63
- #: wp-updates-notifier.php:426
64
  msgid "WP Updates Notifier"
65
  msgstr "WP Updates Notifier"
66
 
67
- #: wp-updates-notifier.php:515
68
  msgid "Updates Notifier"
69
  msgstr "更新通知"
70
 
71
- #: wp-updates-notifier.php:521
72
  msgid "Never"
73
  msgstr "なし"
74
 
75
- #: wp-updates-notifier.php:525
76
  msgid "%1s @ %2s"
77
  msgstr "%1s %2s"
78
 
79
- #: wp-updates-notifier.php:531
80
  msgid "Last scanned: %s"
81
  msgstr "最終チェック日時: %s"
82
 
83
- #: wp-updates-notifier.php:542
84
  msgid "Save settings"
85
  msgstr "変更を保存"
86
 
87
- #: wp-updates-notifier.php:543
88
  msgid "Save settings with test email"
89
  msgstr "変更を保存してテストメールを送信"
90
 
91
- #: wp-updates-notifier.php:552
92
  msgid "Cron Method"
93
  msgstr "Cron ツール"
94
 
95
- #: wp-updates-notifier.php:553
96
  msgid "Frequency to check"
97
  msgstr "更新チェックの頻度"
98
 
99
- #: wp-updates-notifier.php:554
100
  msgid "Notify email to"
101
  msgstr "更新情報の通知先"
102
 
103
- #: wp-updates-notifier.php:555
104
  msgid "Notify email from"
105
  msgstr "更新通知の送信元"
106
 
107
- #: wp-updates-notifier.php:556
108
  msgid "Notify about plugin updates?"
109
  msgstr "プラグインの更新を通知しますか?"
110
 
111
- #: wp-updates-notifier.php:557
112
  msgid "Notify about theme updates?"
113
  msgstr "テーマの更新を通知しますか?"
114
 
115
- #: wp-updates-notifier.php:558
116
  msgid "Hide core WP update nag from non-admin users?"
117
  msgstr "WP 本体が表示する更新通知を、管理者以外のユーザーから隠しますか?"
118
 
119
- #: wp-updates-notifier.php:568
120
  msgid "Invalid cron method selected"
121
  msgstr "Cron ツールの入力値が正しくありません"
122
 
123
- #: wp-updates-notifier.php:579
124
  msgid "Invalid frequency entered"
125
  msgstr "更新チェックの頻度の形式が正しくありません"
126
 
127
- #: wp-updates-notifier.php:589
128
  msgid "One or more email to addresses are invalid"
129
  msgstr "通知先メールアドレスの形式が正しくありません"
130
 
131
- #: wp-updates-notifier.php:600
132
  msgid "No email to address entered"
133
  msgstr "通知先を入力してください"
134
 
135
- #: wp-updates-notifier.php:608
136
  msgid "Invalid email from entered"
137
  msgstr "送信元メールアドレスの形式が正しくありません"
138
 
139
- #: wp-updates-notifier.php:616
140
  msgid "Invalid plugin updates value entered"
141
  msgstr "プラグインの更新通知の入力値が正しくありません"
142
 
143
- #: wp-updates-notifier.php:624
144
  msgid "Invalid theme updates value entered"
145
  msgstr "テーマの更新通知の入力値が正しくありません"
146
 
147
- #: wp-updates-notifier.php:632
148
  msgid "Invalid hide updates value entered"
149
  msgstr "本体からの更新通知を隠すかどうかの入力値が正しくありません"
150
 
151
- #: wp-updates-notifier.php:644
152
  msgid "This is a test message from WP Updates Notifier."
153
  msgstr "WP Updates Notifier からのテストメールです。"
154
 
155
- #: wp-updates-notifier.php:655
156
  msgid "WordPress Cron"
157
  msgstr "WordPress Cron"
158
 
159
- #: wp-updates-notifier.php:656
160
  msgid "Other Cron"
161
  msgstr "その他の Cron"
162
 
163
- #: wp-updates-notifier.php:660
164
  msgid "Cron Command: "
165
  msgstr "Cron コマンド: "
166
 
167
- #: wp-updates-notifier.php:681
168
  msgid "Separate multiple email address with a comma (,)"
169
  msgstr "複数送信の場合はメールアドレスを半角コンマで区切る"
170
 
171
- #: wp-updates-notifier.php:693 wp-updates-notifier.php:705
172
- #: wp-updates-notifier.php:719
173
  msgid "No"
174
  msgstr "いいえ"
175
 
176
- #: wp-updates-notifier.php:695 wp-updates-notifier.php:707
177
- #: wp-updates-notifier.php:718
178
  msgid "Yes"
179
  msgstr "はい"
180
 
181
- #: wp-updates-notifier.php:697
182
  msgid "Yes but only active plugins"
183
  msgstr "有効化されているプラグインのみ"
184
 
185
- #: wp-updates-notifier.php:709
186
  msgid "Yes but only active themes"
187
  msgstr "使用中のテーマのみ"
188
 
14
  "Language: ja\n"
15
  "Plural-Forms: nplurals=1; plural=0;\n"
16
 
17
+ #: class-sc-wp-updates-notifier.php:194 class-sc-wp-updates-notifier.php:551
18
  msgid "Settings"
19
  msgstr "設定"
20
 
21
+ #: class-sc-wp-updates-notifier.php:224
22
  msgid "There are updates available for your WordPress site:"
23
  msgstr "お使いの WordPress に更新があります:"
24
 
25
+ #: class-sc-wp-updates-notifier.php:225
26
  msgid "Please visit %s to update."
27
  msgstr "更新するには %s を開いてください。"
28
 
29
+ #: class-sc-wp-updates-notifier.php:250
30
  msgid "WP-Core: WordPress is out of date. Please update from version %s to %s"
31
  msgstr "WP 本体: WordPress に新しいバージョンがあります。バージョン %s から %s へ更新してください"
32
 
33
+ #: class-sc-wp-updates-notifier.php:292
34
  msgid "Plugin: %s is out of date. Please update from version %s to %s"
35
  msgstr "プラグイン: %s に新しいバージョンがあります。バージョン %s から %s へ更新してください"
36
 
37
+ #: class-sc-wp-updates-notifier.php:293
38
  msgid "Details: %s"
39
  msgstr "説明: %s"
40
 
41
+ #: class-sc-wp-updates-notifier.php:294
42
  msgid "Changelog: %s%s"
43
  msgstr "更新履歴: %s%s"
44
 
45
+ #: class-sc-wp-updates-notifier.php:303
46
  msgid "Compatibility with WordPress %1$s: Unknown"
47
  msgstr "WordPress %1$s との互換性: 不明"
48
 
49
+ #: class-sc-wp-updates-notifier.php:305
50
  msgid "Compatibility: %s"
51
  msgstr "互換性: %s"
52
 
53
+ #: class-sc-wp-updates-notifier.php:344
54
  msgid "Theme: %s is out of date. Please update from version %s to %s"
55
  msgstr "テーマ: に新しいバージョンがあります。バージョン %s から %s へ更新してください"
56
 
57
+ #: class-sc-wp-updates-notifier.php:410
58
  msgid "WP Updates Notifier: Updates Available @ %s"
59
  msgstr "WP Updates Notifier: %s に更新があります"
60
 
61
  #. #-#-#-#-# wp-updates-notifier.pot (WP Updates Notifier 1.4) #-#-#-#-#
62
  #. Plugin Name of the plugin/theme
63
+ #: class-sc-wp-updates-notifier.php:426
64
  msgid "WP Updates Notifier"
65
  msgstr "WP Updates Notifier"
66
 
67
+ #: class-sc-wp-updates-notifier.php:515
68
  msgid "Updates Notifier"
69
  msgstr "更新通知"
70
 
71
+ #: class-sc-wp-updates-notifier.php:521
72
  msgid "Never"
73
  msgstr "なし"
74
 
75
+ #: class-sc-wp-updates-notifier.php:525
76
  msgid "%1s @ %2s"
77
  msgstr "%1s %2s"
78
 
79
+ #: class-sc-wp-updates-notifier.php:531
80
  msgid "Last scanned: %s"
81
  msgstr "最終チェック日時: %s"
82
 
83
+ #: class-sc-wp-updates-notifier.php:542
84
  msgid "Save settings"
85
  msgstr "変更を保存"
86
 
87
+ #: class-sc-wp-updates-notifier.php:543
88
  msgid "Save settings with test email"
89
  msgstr "変更を保存してテストメールを送信"
90
 
91
+ #: class-sc-wp-updates-notifier.php:552
92
  msgid "Cron Method"
93
  msgstr "Cron ツール"
94
 
95
+ #: class-sc-wp-updates-notifier.php:553
96
  msgid "Frequency to check"
97
  msgstr "更新チェックの頻度"
98
 
99
+ #: class-sc-wp-updates-notifier.php:554
100
  msgid "Notify email to"
101
  msgstr "更新情報の通知先"
102
 
103
+ #: class-sc-wp-updates-notifier.php:555
104
  msgid "Notify email from"
105
  msgstr "更新通知の送信元"
106
 
107
+ #: class-sc-wp-updates-notifier.php:556
108
  msgid "Notify about plugin updates?"
109
  msgstr "プラグインの更新を通知しますか?"
110
 
111
+ #: class-sc-wp-updates-notifier.php:557
112
  msgid "Notify about theme updates?"
113
  msgstr "テーマの更新を通知しますか?"
114
 
115
+ #: class-sc-wp-updates-notifier.php:558
116
  msgid "Hide core WP update nag from non-admin users?"
117
  msgstr "WP 本体が表示する更新通知を、管理者以外のユーザーから隠しますか?"
118
 
119
+ #: class-sc-wp-updates-notifier.php:568
120
  msgid "Invalid cron method selected"
121
  msgstr "Cron ツールの入力値が正しくありません"
122
 
123
+ #: class-sc-wp-updates-notifier.php:579
124
  msgid "Invalid frequency entered"
125
  msgstr "更新チェックの頻度の形式が正しくありません"
126
 
127
+ #: class-sc-wp-updates-notifier.php:589
128
  msgid "One or more email to addresses are invalid"
129
  msgstr "通知先メールアドレスの形式が正しくありません"
130
 
131
+ #: class-sc-wp-updates-notifier.php:600
132
  msgid "No email to address entered"
133
  msgstr "通知先を入力してください"
134
 
135
+ #: class-sc-wp-updates-notifier.php:608
136
  msgid "Invalid email from entered"
137
  msgstr "送信元メールアドレスの形式が正しくありません"
138
 
139
+ #: class-sc-wp-updates-notifier.php:616
140
  msgid "Invalid plugin updates value entered"
141
  msgstr "プラグインの更新通知の入力値が正しくありません"
142
 
143
+ #: class-sc-wp-updates-notifier.php:624
144
  msgid "Invalid theme updates value entered"
145
  msgstr "テーマの更新通知の入力値が正しくありません"
146
 
147
+ #: class-sc-wp-updates-notifier.php:632
148
  msgid "Invalid hide updates value entered"
149
  msgstr "本体からの更新通知を隠すかどうかの入力値が正しくありません"
150
 
151
+ #: class-sc-wp-updates-notifier.php:644
152
  msgid "This is a test message from WP Updates Notifier."
153
  msgstr "WP Updates Notifier からのテストメールです。"
154
 
155
+ #: class-sc-wp-updates-notifier.php:655
156
  msgid "WordPress Cron"
157
  msgstr "WordPress Cron"
158
 
159
+ #: class-sc-wp-updates-notifier.php:656
160
  msgid "Other Cron"
161
  msgstr "その他の Cron"
162
 
163
+ #: class-sc-wp-updates-notifier.php:660
164
  msgid "Cron Command: "
165
  msgstr "Cron コマンド: "
166
 
167
+ #: class-sc-wp-updates-notifier.php:681
168
  msgid "Separate multiple email address with a comma (,)"
169
  msgstr "複数送信の場合はメールアドレスを半角コンマで区切る"
170
 
171
+ #: class-sc-wp-updates-notifier.php:693 class-sc-wp-updates-notifier.php:705
172
+ #: class-sc-wp-updates-notifier.php:719
173
  msgid "No"
174
  msgstr "いいえ"
175
 
176
+ #: class-sc-wp-updates-notifier.php:695 class-sc-wp-updates-notifier.php:707
177
+ #: class-sc-wp-updates-notifier.php:718
178
  msgid "Yes"
179
  msgstr "はい"
180
 
181
+ #: class-sc-wp-updates-notifier.php:697
182
  msgid "Yes but only active plugins"
183
  msgstr "有効化されているプラグインのみ"
184
 
185
+ #: class-sc-wp-updates-notifier.php:709
186
  msgid "Yes but only active themes"
187
  msgstr "使用中のテーマのみ"
188
 
phpcs.xml.dist ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <ruleset name="WP Updates Notifier">
3
+ <description>PHP_CodeSniffer standard for WP Updates Notifier.</description>
4
+
5
+ <!--
6
+ Pass some flags to PHPCS:
7
+ p flag: Show progress of the run.
8
+ s flag: Show sniff codes in all reports.
9
+ -->
10
+ <arg value="ps" />
11
+
12
+ <!-- Strip the filepaths down to the relevant bit. -->
13
+ <arg name="basepath" value="./" />
14
+
15
+ <!-- Check up to 8 files simultaneously. -->
16
+ <arg name="parallel" value="8" />
17
+
18
+ <!-- Check both PHP and JS files. -->
19
+ <arg name="extensions" value="php,js" />
20
+
21
+ <!-- Set severity to 1 to see everything that isn't effectively turned off. -->
22
+ <arg name="severity" value="1" />
23
+
24
+ <!-- Check all files in this directory and the directories below it. -->
25
+ <file>.</file>
26
+
27
+ <!-- Exclude a few directories and autogenerated files. -->
28
+ <exclude-pattern>*.min.js</exclude-pattern>
29
+ <exclude-pattern>bin/</exclude-pattern>
30
+ <exclude-pattern>tests/</exclude-pattern>
31
+ <exclude-pattern>vendor/</exclude-pattern>
32
+
33
+ <!-- Use the WordPress ruleset, with some customizations. -->
34
+ <rule ref="WordPress">
35
+ <!-- Ignore JS files in the main WordPress standard, since we use ESLint instead. -->
36
+ <exclude-pattern>*.js</exclude-pattern>
37
+
38
+ <!-- Turn off some rules that we don't like. -->
39
+ <exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
40
+ </rule>
41
+
42
+ <!-- Use the VIP Go ruleset. -->
43
+ <rule ref="WordPress-VIP-Go" />
44
+
45
+ <!-- The version set here matches the minimum version tested in .travis.yml. -->
46
+ <config name="minimum_supported_wp_version" value="4.9" />
47
+
48
+ <rule ref="Squiz.Commenting.FileComment.SpacingAfterComment">
49
+ <!--
50
+ Downgrade while so many PHP files are empty to start with.
51
+ The empty file makes it difficult to comply with this rule
52
+ and the trailing newline rule at the same time.
53
+ -->
54
+ <type>warning</type>
55
+
56
+ <!--
57
+ Once your PHP files have been filled in, you might be able
58
+ to start checking for compliance again with an
59
+ exclude-pattern like these:
60
+
61
+ <exclude-pattern>themes(/vip)?/[^/]+/[^/]+\.php$</exclude-pattern>
62
+ <exclude-pattern>themes(/vip)?/[^/]+/template-parts/*</exclude-pattern>
63
+ -->
64
+ </rule>
65
+
66
+ <rule ref="Generic.Files.OneObjectStructurePerFile">
67
+ <!--
68
+ Increase severity. If it becomes a problem for this sniff to trigger an
69
+ error, then we might want to provide feedback to the WPCS maintainers.
70
+ See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/1111.
71
+ -->
72
+ <type>error</type>
73
+ </rule>
74
+
75
+ <rule ref="WordPress.WP.I18n">
76
+ <properties>
77
+ <!--
78
+ Verify that the text_domain is set to the desired text-domain.
79
+ Multiple valid text domains can be provided as a comma-delimited list.
80
+ -->
81
+ <property name="text_domain" type="array" value="wp-updates-notifier" />
82
+ </properties>
83
+ </rule>
84
+
85
+ <rule ref="WordPress.Files.FileName">
86
+ <properties>
87
+ <!--
88
+ Allow for theme-specific exceptions to the file name rules based
89
+ on the theme hierarchy.
90
+ -->
91
+ <property name="is_theme" value="true" />
92
+ </properties>
93
+ </rule>
94
+
95
+ <rule ref="WordPress.NamingConventions.PrefixAllGlobals">
96
+ <properties>
97
+ <property name="prefixes" type="array" value="sc_,ai_,_ai" />
98
+ </properties>
99
+ </rule>
100
+
101
+ <rule ref="Generic.PHP.ForbiddenFunctions">
102
+ <properties>
103
+ <!--
104
+ WordPress.com VIP does not propagate wp_cache_set data across datacenters,
105
+ largely to avoid attempting to propagate large (>50k) data for batcache.
106
+ -->
107
+ <property name="forbiddenFunctions" type="array" value="wp_cache_add=>wp_cache_set" />
108
+ <!-- This is the newer format, only supported in PHPCS 3.3.0+
109
+ <property name="forbiddenFunctions" type="array">
110
+ <element key="wp_cache_add" value="wp_cache_set"/>
111
+ </property> -->
112
+ </properties>
113
+ </rule>
114
+
115
+ <rule ref="Squiz.Commenting.InlineComment.InvalidEndChar">
116
+ <!--
117
+ TODO: Turn this back on and add end characters to inline comments.
118
+ -->
119
+ <severity>0</severity>
120
+ </rule>
121
+
122
+ <rule ref="Squiz.Commenting.FunctionComment.Missing">
123
+ <!--
124
+ TODO: Turn this back on and add comments.
125
+ -->
126
+ <severity>0</severity>
127
+ </rule>
128
+
129
+ <rule ref="Squiz.Commenting.VariableComment.Missing">
130
+ <!--
131
+ TODO: Turn this back on and add comments.
132
+ -->
133
+ <severity>0</severity>
134
+ </rule>
135
+
136
+ <rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
137
+ <!--
138
+ TODO: Turn this back on and add comments.
139
+ -->
140
+ <severity>0</severity>
141
+ </rule>
142
+
143
+ <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound">
144
+ <!--
145
+ TODO: Turn this back on and add comments.
146
+ -->
147
+ <severity>0</severity>
148
+ </rule>
149
+
150
+ </ruleset>
phpunit.xml.dist ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <phpunit
2
+ bootstrap="tests/bootstrap.php"
3
+ backupGlobals="false"
4
+ colors="true"
5
+ convertErrorsToExceptions="true"
6
+ convertNoticesToExceptions="true"
7
+ convertWarningsToExceptions="true"
8
+ >
9
+ <php>
10
+ <const name="WP_UPDATES_NOTIFIER_UNIT_TESTS" value="1" />
11
+ </php>
12
+ <testsuites>
13
+ <testsuite>
14
+ <directory prefix="test-" suffix=".php">./tests/</directory>
15
+ </testsuite>
16
+ </testsuites>
17
+ </phpunit>
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Plugin Name ===
2
- 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.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,7 +54,24 @@ This plugin is a fork of [Update Notifier](http://wordpress.org/extend/plugins/u
54
 
55
  == Changelog ==
56
 
57
- = 1.4.4=
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  * Avoid PHP Strict notices
59
  * PHP 7 compatibility
60
  * Minor cleanup on some internal code
1
  === Plugin Name ===
2
+ Contributors: l3rady, alleyinteractive
3
+ Donate link: https://scott.cariss.dev/donate
4
  Tags: admin, theme, monitor, plugin, notification, upgrade, security
5
  Requires at least: 3.1
6
+ Tested up to: 5.3
7
+ Stable tag: 1.6
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.6 =
58
+ * Added slack notifications and testing button
59
+ * Separated notifications so they can be email, slack, or both
60
+ * Reorganized settings page
61
+ * Changed validation to not turn on notifications for email or slack unless required fields are valid
62
+ * Test email or slack message are now triggered with a temporary transient
63
+ * Removed javascript functions
64
+
65
+ = 1.5.1 =
66
+ * Removed ability to trigger with external cron job (a potential security risk)
67
+
68
+ = 1.5 =
69
+ * Bring up to WordPress coding standards
70
+ * PHPCS ruleset
71
+ * Travis testing
72
+ * Base for unit testing
73
+
74
+ = 1.4.4 =
75
  * Avoid PHP Strict notices
76
  * PHP 7 compatibility
77
  * Minor cleanup on some internal code
tests/bootstrap.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $_tests_dir = getenv( 'WP_TESTS_DIR' );
4
+ if ( ! $_tests_dir ) {
5
+ $_tests_dir = '/tmp/wordpress-tests-lib';
6
+ }
7
+
8
+ require_once $_tests_dir . '/includes/functions.php';
9
+
10
+ /**
11
+ * Manually load the plugin for tests.
12
+ */
13
+ function _manually_load_plugin() {
14
+ require dirname( dirname( __FILE__ ) ) . '/class-sc-wp-updates-notifier.php';
15
+ }
16
+ tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
17
+
18
+ require $_tests_dir . '/includes/bootstrap.php';
tests/test-class-wp-updates-notifier.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Publish to WP Updates Notifier Tests: SC_WP_Updates_Notifier class
4
+ *
5
+ * Contains a class which is used to test the SC_WP_Updates_Notifier class.
6
+ *
7
+ * @package SC_WP_Updates_Notifier
8
+ * @subpackage Tests
9
+ */
10
+
11
+ /**
12
+ * A class which is used to test the SC_WP_Updates_Notifier class.
13
+ */
14
+ class SC_WP_Updates_Notifier_Tests extends WP_UnitTestCase {
15
+
16
+ /**
17
+ * A function containing operations to be run before each test function.
18
+ *
19
+ * @access public
20
+ */
21
+ public function setUp() {
22
+ parent::setup();
23
+ }
24
+
25
+ /**
26
+ * Ensures that the basic email functions return the correct values.
27
+ *
28
+ * @see SC_WP_Updates_Notifier::sc_wpun_wp_mail_*
29
+ *
30
+ * @access public
31
+ */
32
+ public function testEmailInfo() {
33
+ $sc_wp_updates_notifier = new SC_WP_Updates_Notifier();
34
+
35
+ // Test email content type.
36
+ $this->assertEquals(
37
+ 'WP Updates Notifier',
38
+ $sc_wp_updates_notifier->sc_wpun_wp_mail_from_name()
39
+ );
40
+
41
+ // Test email content type.
42
+ $this->assertEquals(
43
+ 'text/plain',
44
+ $sc_wp_updates_notifier->sc_wpun_wp_mail_content_type()
45
+ );
46
+ }
47
+ }
uninstall.php CHANGED
@@ -1,24 +1,38 @@
1
  <?php
2
- /* Copyright 2015 Scott Cariss (email : scott@l3rady.com)
 
 
 
 
 
 
 
 
 
3
 
4
- This program is free software; you can redistribute it and/or modify
5
- it under the terms of the GNU General Public License as published by
6
- the Free Software Foundation; either version 2 of the License, or
7
- (at your option) any later version.
8
 
9
- This program is distributed in the hope that it will be useful,
10
- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- GNU General Public License for more details.
13
 
14
- You should have received a copy of the GNU General Public License
15
- along with this program; if not, write to the Free Software
16
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
 
19
- if ( !defined( "WP_UNINSTALL_PLUGIN" ) ) {
 
 
 
 
 
 
 
20
  exit();
21
  }
22
 
23
- delete_option( "sc_wpun_settings" );
24
- delete_option( "sc_wpun_settings_ver" );
1
  <?php
2
+ /**
3
+ * Uninstall function for plugin.
4
+ *
5
+ * This file is read by WordPress to generate the plugin information in the
6
+ * admin panel.
7
+ *
8
+ * @link https://github.com/l3rady/wp-updates-notifier
9
+ * @since 1.5.0
10
+ * @package SC_WP_Updates_Notifier
11
+ */
12
 
13
+ /**
14
+ Copyright 2020 Scott Cariss (email:scott@cariss.dev)
 
 
15
 
16
+ This program is free software; you can redistribute it and/or modify
17
+ it under the terms of the GNU General Public License as published by
18
+ the Free Software Foundation; either version 2 of the License, or
19
+ (at your option) any later version.
20
 
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
 
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program; if not, write to the Free Software
28
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29
+
30
+ @package
31
+ */
32
+
33
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
34
  exit();
35
  }
36
 
37
+ delete_option( 'sc_wpun_settings' );
38
+ delete_option( 'sc_wpun_settings_ver' );
wp-updates-notifier.php DELETED
@@ -1,794 +0,0 @@
1
- <?php
2
- /*
3
- 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.4
8
- Author: Scott Cariss
9
- Author URI: http://l3rady.com/
10
- Text Domain: wp-updates-notifier
11
- Domain Path: /languages
12
- License: GPL3+
13
- */
14
-
15
- /* Copyright 2015 Scott Cariss (email : scott@l3rady.com)
16
-
17
- This program is free software; you can redistribute it and/or modify
18
- it under the terms of the GNU General Public License as published by
19
- the Free Software Foundation; either version 2 of the License, or
20
- (at your option) any later version.
21
-
22
- This program is distributed in the hope that it will be useful,
23
- but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
- GNU General Public License for more details.
26
-
27
- You should have received a copy of the GNU General Public License
28
- along with this program; if not, write to the Free Software
29
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
- */
31
-
32
- // Only load class if it hasn't already been loaded
33
- if ( !class_exists( 'sc_WPUpdatesNotifier' ) ) {
34
-
35
- // WP Updates Notifier - All the magic happens here!
36
- class sc_WPUpdatesNotifier {
37
- const OPT_FIELD = "sc_wpun_settings";
38
- const OPT_VERSION_FIELD = "sc_wpun_settings_ver";
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
- /**
77
- * Check if this plugin settings are up to date. Firstly check the version in
78
- * the DB. If they don't match then load in defaults but don't override values
79
- * already set. Also this will remove obsolete settings that are not needed.
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
88
- 'cron_method' => 'wordpress', // Cron method to be used for scheduling scans
89
- 'frequency' => 'hourly',
90
- 'notify_to' => get_option( 'admin_email' ),
91
- 'notify_from' => get_option( 'admin_email' ),
92
- 'notify_plugins' => 1,
93
- 'notify_themes' => 1,
94
- 'notify_automatic' => 1,
95
- 'hide_updates' => 1,
96
- 'notified' => array(
97
- 'core' => "",
98
- 'plugin' => array(),
99
- 'theme' => array(),
100
- ),
101
- 'security_key' => sha1( microtime( true ) . mt_rand( 10000, 90000 ) ), // Generate a random key to be used for Other Cron Method,
102
- 'last_check_time' => false
103
- );
104
- // Intersect current options with defaults. Basically removing settings that are obsolete
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
-
113
-
114
- /**
115
- * Filter for when getting or settings this plugins settings
116
- *
117
- * @param string $field Option field name of where we are getting or setting plugin settings
118
- * @param bool|mixed $settings False if getting settings else an array with settings you are saving
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
- }
126
-
127
- return update_option( $field, apply_filters( 'sc_wpun_put_options_filter', $settings, $field ) );
128
- }
129
-
130
-
131
- /**
132
- * Function that deals with activation of this plugin
133
- *
134
- * @return void
135
- */
136
- public function activate() {
137
- do_action( "sc_wpun_enable_cron" ); // Enable cron
138
- }
139
-
140
-
141
- /**
142
- * Function that deals with de-activation of this plugin
143
- *
144
- * @return void
145
- */
146
- public function deactivate() {
147
- do_action( "sc_wpun_disable_cron" ); // Disable cron
148
- }
149
-
150
-
151
- /**
152
- * Enable cron for this plugin. Check if a cron should be scheduled.
153
- *
154
- * @param bool|string $manual_interval For setting a manual cron interval.
155
- *
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
163
- if ( false !== $manual_interval ) {
164
- $options['frequency'] = $manual_interval;
165
- }
166
-
167
- if ( "manual" == $options['frequency'] ) {
168
- do_action( "sc_wpun_disable_cron" ); // Make sure no cron is setup as we are manual
169
- }
170
- else {
171
- // check if the current schedule matches the one set in settings
172
- if ( $currentSchedule == $options['frequency'] ) {
173
- return;
174
- }
175
-
176
- // check the cron setting is valid
177
- if ( !in_array( $options['frequency'], $this->get_intervals() ) ) {
178
- return;
179
- }
180
-
181
- // Remove any cron's for this plugin first so we don't end up with multiple cron's doing the same thing.
182
- do_action( "sc_wpun_disable_cron" );
183
-
184
- // Schedule cron for this plugin.
185
- wp_schedule_event( time(), $options['frequency'], self::CRON_NAME );
186
- }
187
- }
188
-
189
-
190
- /**
191
- * Removes cron for this plugin.
192
- *
193
- * @return void
194
- */
195
- public function disable_cron() {
196
- wp_clear_scheduled_hook( self::CRON_NAME ); // clear cron
197
- }
198
-
199
-
200
- /**
201
- * Adds the settings link under the plugin on the plugin screen.
202
- *
203
- * @param array $links
204
- * @param string $file
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
- }
213
- return $links;
214
- }
215
-
216
-
217
- /**
218
- * This is run by the cron. The update check checks the core always, the
219
- * plugins and themes if asked. If updates found email notification sent.
220
- *
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
238
- }
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
-
249
- /**
250
- * Checks to see if any WP core updates
251
- *
252
- * @param string $message holds message to be sent via notification
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?
262
- if ( $update_core->updates[0]->current != $settings['notified']['core'] ) { // have we already notified about this version?
263
- require_once( ABSPATH . WPINC . '/version.php' ); // Including this because some plugins can mess with the real version stored in the DB.
264
- $new_core_ver = $update_core->updates[0]->current; // The new WP core version
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 {
272
- return false; // There are updates but we have already notified in the past.
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
-
280
-
281
- /**
282
- * Check to see if any plugin updates.
283
- *
284
- * @param string $message holds message to be sent via notification
285
- * @param int $allOrActive should we look for all plugins or just active ones
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?
296
- $plugins_need_update = $update_plugins->response; // plugins that need updating
297
- if ( 2 == $allOrActive ) { // are we to check just active plugins?
298
- $active_plugins = array_flip( get_option( 'active_plugins' ) ); // find which plugins are active
299
- $plugins_need_update = array_intersect_key( $plugins_need_update, $active_plugins ); // only keep plugins that are active
300
- }
301
- $plugins_need_update = apply_filters( 'sc_wpun_plugins_need_update', $plugins_need_update ); // additional filtering of plugins need update
302
- if ( count( $plugins_need_update ) >= 1 ) { // any plugins need updating after all the filtering gone on above?
303
- require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); // Required for plugin API
304
- require_once( ABSPATH . WPINC . '/version.php' ); // Required for WP core version
305
- foreach ( $plugins_need_update as $key => $data ) { // loop through the plugins that need updating
306
- $plugin_info = get_plugin_data( WP_PLUGIN_DIR . "/" . $key ); // get local plugin info
307
- $info = plugins_api( 'plugin_information', array( 'slug' => $data->slug ) ); // get repository plugin info
308
- $message .= "\n" . sprintf( __( "Plugin: %s is out of date. Please update from version %s to %s", "wp-updates-notifier" ), $plugin_info['Name'], $plugin_info['Version'], $data->new_version ) . "\n";
309
- $message .= "\t" . sprintf( __( "Details: %s", "wp-updates-notifier" ), $data->url ) . "\n";
310
- $message .= "\t" . sprintf( __( "Changelog: %s%s", "wp-updates-notifier" ), $data->url, "changelog/" ) . "\n";
311
- if ( isset( $info->tested ) && version_compare( $info->tested, $wp_version, '>=' ) ) {
312
- $compat = sprintf( __( 'Compatibility with WordPress %1$s: 100%% (according to its author)' ), $cur_wp_version );
313
- }
314
- elseif ( isset( $info->compatibility[$wp_version][$data->new_version] ) ) {
315
- $compat = $info->compatibility[$wp_version][$data->new_version];
316
- $compat = sprintf( __( 'Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)' ), $wp_version, $compat[0], $compat[2], $compat[1] );
317
- }
318
- else {
319
- $compat = sprintf( __( 'Compatibility with WordPress %1$s: Unknown' ), $wp_version );
320
- }
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
335
- }
336
-
337
-
338
- /**
339
- * Check to see if any theme updates.
340
- *
341
- * @param string $message holds message to be sent via notification
342
- * @param int $allOrActive should we look for all themes or just active ones
343
- *
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?
351
- $themes_need_update = $update_themes->response; // themes that need updating
352
- if ( 2 == $allOrActive ) { // are we to check just active themes?
353
- $active_theme = array( get_option( 'template' ) => array() ); // find current theme that is active
354
- $themes_need_update = array_intersect_key( $themes_need_update, $active_theme ); // only keep theme that is active
355
- }
356
- $themes_need_update = apply_filters( 'sc_wpun_themes_need_update', $themes_need_update ); // additional filtering of themes need update
357
- if ( count( $themes_need_update ) >= 1 ) { // any themes need updating after all the filtering gone on above?
358
- foreach ( $themes_need_update as $key => $data ) { // loop through the themes that need updating
359
- $theme_info = wp_get_theme( $key ); // get theme info
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
374
- }
375
-
376
-
377
- /**
378
- * Filter for removing plugins from update list if already been notified about
379
- *
380
- * @param array $plugins_need_update
381
- *
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?
389
- unset( $plugins_need_update[$key] ); // don't notify this plugin as has already been notified
390
- }
391
- }
392
- }
393
- return $plugins_need_update;
394
- }
395
-
396
-
397
- /**
398
- * Filter for removing themes from update list if already been notified about
399
- *
400
- * @param array $themes_need_update
401
- *
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?
409
- unset( $themes_need_update[$key] ); // don't notify this theme as has already been notified
410
- }
411
- }
412
- }
413
- return $themes_need_update;
414
- }
415
-
416
-
417
- /**
418
- * Sends email notification.
419
- *
420
- * @param string $message holds message to be sent in body of email
421
- *
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
- /**
457
- * Filter the background update notification email
458
- *
459
- * @param array $email Array of email arguments that will be passed to wp_mail().
460
- *
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.
468
- $email['to'] = $options['notify_to'];
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
-
476
- return $email;
477
- }
478
-
479
-
480
- /**
481
- * Removes the update nag for non admin users.
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.
490
- }
491
- }
492
- }
493
-
494
-
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
-
534
-
535
- /*
536
- * EVERYTHING SETTINGS
537
- *
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
- ?>
555
- <div class="wrap">
556
- <?php screen_icon(); ?>
557
- <h2><?php _e( "Updates Notifier", "wp-updates-notifier" ); ?></h2>
558
-
559
- <p>
560
- <span class="description">
561
- <?php
562
- if ( false === $options["last_check_time"] ) {
563
- $scan_date = __( "Never", "wp-updates-notifier" );
564
- }
565
- else {
566
- $scan_date = sprintf(
567
- __( "%1s @ %2s", "wp-updates-notifier" ),
568
- date( $date_format, $options["last_check_time"] ),
569
- date( $time_format, $options['last_check_time'] )
570
- );
571
- }
572
-
573
- echo sprintf( __( "Last scanned: %s", "wp-updates-notifier" ), $scan_date );
574
- ?>
575
- </span>
576
- </p>
577
-
578
- <form action="<?php echo admin_url( "options.php" ); ?>" method="post">
579
- <?php
580
- settings_fields( "sc_wpun_settings" );
581
- do_settings_sections( "wp-updates-notifier" );
582
- ?>
583
- <p>&nbsp;</p>
584
- <input class="button-primary" name="Submit" type="submit" value="<?php _e( "Save settings", "wp-updates-notifier" ); ?>" />
585
- <input class="button" name="submitwithemail" type="submit" value="<?php _e( "Save settings with test email", "wp-updates-notifier" ); ?>" />
586
- </form>
587
- </div>
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'];
609
- }
610
- else {
611
- add_settings_error( "sc_wpun_settings_main_cron_method", "sc_wpun_settings_main_cron_method_error", __( "Invalid cron method selected", "wp-updates-notifier" ), "error" );
612
- }
613
-
614
- if ( "other" == $valid['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
- }
622
- else {
623
- add_settings_error( "sc_wpun_settings_main_frequency", "sc_wpun_settings_main_frequency_error", __( "Invalid frequency entered", "wp-updates-notifier" ), "error" );
624
- }
625
-
626
- $emails_to = explode( ",", $input['notify_to'] );
627
- if ( $emails_to ) {
628
- $sanitized_emails = array();
629
- $was_error = false;
630
- foreach ( $emails_to as $email_to ) {
631
- $address = sanitize_email( trim( $email_to ) );
632
- if ( !is_email( $address ) ) {
633
- add_settings_error( "sc_wpun_settings_main_notify_to", "sc_wpun_settings_main_notify_to_error", __( "One or more email to addresses are invalid", "wp-updates-notifier" ), "error" );
634
- $was_error = true;
635
- break;
636
- }
637
- $sanitized_emails[] = $address;
638
- }
639
- if ( !$was_error ) {
640
- $valid['notify_to'] = implode( ',', $sanitized_emails );
641
- }
642
- }
643
- else {
644
- add_settings_error( "sc_wpun_settings_main_notify_to", "sc_wpun_settings_main_notify_to_error", __( "No email to address entered", "wp-updates-notifier" ), "error" );
645
- }
646
-
647
- $sanitized_email_from = sanitize_email( $input['notify_from'] );
648
- if ( is_email( $sanitized_email_from ) ) {
649
- $valid['notify_from'] = $sanitized_email_from;
650
- }
651
- else {
652
- add_settings_error( "sc_wpun_settings_main_notify_from", "sc_wpun_settings_main_notify_from_error", __( "Invalid email from entered", "wp-updates-notifier" ), "error" );
653
- }
654
-
655
- $sanitized_notify_plugins = absint( isset( $input['notify_plugins'] ) ? $input['notify_plugins'] : 0 );
656
- if ( $sanitized_notify_plugins >= 0 && $sanitized_notify_plugins <= 2 ) {
657
- $valid['notify_plugins'] = $sanitized_notify_plugins;
658
- }
659
- else {
660
- add_settings_error( "sc_wpun_settings_main_notify_plugins", "sc_wpun_settings_main_notify_plugins_error", __( "Invalid plugin updates value entered", "wp-updates-notifier" ), "error" );
661
- }
662
-
663
- $sanitized_notify_themes = absint( isset( $input['notify_themes'] ) ? $input['notify_themes'] : 0 );
664
- if ( $sanitized_notify_themes >= 0 && $sanitized_notify_themes <= 2 ) {
665
- $valid['notify_themes'] = $sanitized_notify_themes;
666
- }
667
- else {
668
- add_settings_error( "sc_wpun_settings_main_notify_themes", "sc_wpun_settings_main_notify_themes_error", __( "Invalid theme updates value entered", "wp-updates-notifier" ), "error" );
669
- }
670
-
671
- $sanitized_notify_automatic = absint( isset( $input['notify_automatic'] ) ? $input['notify_automatic'] : 0 );
672
- if ( $sanitized_notify_automatic >= 0 && $sanitized_notify_automatic <= 1 ) {
673
- $valid['notify_automatic'] = $sanitized_notify_automatic;
674
- }
675
- else {
676
- add_settings_error( "sc_wpun_settings_main_notify_automatic", "sc_wpun_settings_main_notify_automatic_error", __( "Invalid automatic updates value entered", "wp-updates-notifier" ), "error" );
677
- }
678
-
679
- $sanitized_hide_updates = absint( isset( $input['hide_updates'] ) ? $input['hide_updates'] : 0 );
680
- if ( $sanitized_hide_updates <= 1 ) {
681
- $valid['hide_updates'] = $sanitized_hide_updates;
682
- }
683
- else {
684
- add_settings_error( "sc_wpun_settings_main_hide_updates", "sc_wpun_settings_main_hide_updates_error", __( "Invalid hide updates value entered", "wp-updates-notifier" ), "error" );
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" ) ) ) {
692
- $valid['cron_method'] = $input['cron_method'];
693
- }
694
- else {
695
- add_settings_error( "sc_wpun_settings_main_cron_method", "sc_wpun_settings_main_cron_method_error", __( "Invalid cron method selected", "wp-updates-notifier" ), "error" );
696
- }
697
-
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>
715
- <option value="other" <?php selected( $options['cron_method'], "other" ); ?>><?php _e( "Other Cron", "wp-updates-notifier" ); ?></option>
716
- </select>
717
- <div>
718
- <br />
719
- <span class="description"><?php _e( "Cron Command: ", "wp-updates-notifier" ); ?></span>
720
- <pre>wget -q "<?php echo admin_url( "/admin-ajax.php?action=sc_wpun_check&sc_wpun_key=" . $options['security_key'] ); ?>" -O /dev/null >/dev/null 2>&amp;1</pre>
721
- </div>
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 />
754
- <label><input name="<?php echo self::OPT_FIELD; ?>[notify_plugins]" type="radio" value="1" <?php checked( $options['notify_plugins'], 1 ); ?> /> <?php _e( "Yes", "wp-updates-notifier" ); ?>
755
- </label><br />
756
- <label><input name="<?php echo self::OPT_FIELD; ?>[notify_plugins]" type="radio" value="2" <?php checked( $options['notify_plugins'], 2 ); ?> /> <?php _e( "Yes but only active plugins", "wp-updates-notifier" ); ?>
757
- </label>
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 />
766
- <label><input name="<?php echo self::OPT_FIELD; ?>[notify_themes]" type="radio" value="1" <?php checked( $options['notify_themes'], 1 ); ?> /> <?php _e( "Yes", "wp-updates-notifier" ); ?>
767
- </label><br />
768
- <label><input name="<?php echo self::OPT_FIELD; ?>[notify_themes]" type="radio" value="2" <?php checked( $options['notify_themes'], 2 ); ?> /> <?php _e( "Yes but only active themes", "wp-updates-notifier" ); ?>
769
- </label>
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>
786
- <option value="0" <?php selected( $options['hide_updates'], 0 ); ?>><?php _e( "No", "wp-updates-notifier" ); ?></option>
787
- </select>
788
- <?php
789
- }
790
- /**** END EVERYTHING SETTINGS ****/
791
- }
792
- }
793
-
794
- new sc_WPUpdatesNotifier;