PluginProbe ʕ •ᴥ•ʔ
SiteGuard WP Plugin / 1.8.9
SiteGuard WP Plugin v1.8.9
1.8.9 1.8.8 1.8.7 1.8.6 1.8.6-beta1 1.8.6-beta2 1.8.4 1.8.5 1.8.3 1.8.2 1.8.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.4.3 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.7.0 1.7.1 1.7.10 1.7.11 1.7.12 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.0-beta1 1.8.0-beta2 1.8.0-beta3 1.8.0-beta4
siteguard / admin / siteguard-menu-updates-notify.php
siteguard / admin Last commit date
siteguard-login-history-table.php 2 months ago siteguard-menu-admin-filter.php 2 months ago siteguard-menu-author-query.php 2 months ago siteguard-menu-captcha.php 2 months ago siteguard-menu-dashboard.php 2 months ago siteguard-menu-fail-once.php 2 months ago siteguard-menu-init.php 2 months ago siteguard-menu-login-alert.php 2 months ago siteguard-menu-login-history.php 2 months ago siteguard-menu-login-lock.php 2 months ago siteguard-menu-protect-xmlrpc.php 2 months ago siteguard-menu-rename-login.php 3 weeks ago siteguard-menu-same-error.php 2 months ago siteguard-menu-updates-notify.php 1 week ago siteguard-menu-waf-tuning-support.php 2 months ago siteguard-waf-exclude-rule-table.php 3 months ago
siteguard-menu-updates-notify.php
177 lines
1 <?php
2
3 class SiteGuard_Menu_Updates_Notify extends SiteGuard_Base {
4 const OPT_NAME_ENABLE = 'updates_notify_enable';
5 const OPT_NAME_WPCORE = 'notify_wpcore';
6 const OPT_NAME_PLUGINS = 'notify_plugins';
7 const OPT_NAME_THEMES = 'notify_themes';
8
9 function __construct() {
10 $this->render_page();
11 }
12 function is_notify_value( $value ) {
13 $items = array( '0', '1', '2' );
14 if ( in_array( $value, $items ) ) {
15 return true;
16 }
17 return false;
18 }
19 function render_page() {
20 global $siteguard_config, $siteguard_updates_notify;
21
22 $opt_val_enable = $siteguard_config->get( self::OPT_NAME_ENABLE );
23 $opt_val_wpcore = $siteguard_config->get( self::OPT_NAME_WPCORE );
24 $opt_val_plugins = $siteguard_config->get( self::OPT_NAME_PLUGINS );
25 $opt_val_themes = $siteguard_config->get( self::OPT_NAME_THEMES );
26 if ( isset( $_POST['update'] ) && check_admin_referer( 'siteguard-menu-updates-notify-submit' ) ) {
27 $error = false;
28 $errors = siteguard_check_multisite();
29 if ( is_wp_error( $errors ) ) {
30 echo '<div class="error settings-error"><p><strong>';
31 echo esc_html( $errors->get_error_message() );
32 echo '</strong></p></div>';
33 $error = true;
34 }
35 // A radio group renders with nothing checked when its stored value is
36 // missing or unrecognized, and a group with no selection is not sent
37 // with the form. Reading $_POST directly then failed the validation
38 // below, so the one page that can turn the feature off -- and clear
39 // its cron event -- could not be saved on exactly the configurations
40 // that need it. An absent value means the disabled choice: a group the
41 // user did select is always posted, so nothing can be enabled by this.
42 $post_enable = isset( $_POST[ self::OPT_NAME_ENABLE ] ) ? sanitize_text_field( $_POST[ self::OPT_NAME_ENABLE ] ) : '0';
43 $post_wpcore = isset( $_POST[ self::OPT_NAME_WPCORE ] ) ? sanitize_text_field( $_POST[ self::OPT_NAME_WPCORE ] ) : '0';
44 $post_plugins = isset( $_POST[ self::OPT_NAME_PLUGINS ] ) ? sanitize_text_field( $_POST[ self::OPT_NAME_PLUGINS ] ) : '0';
45 $post_themes = isset( $_POST[ self::OPT_NAME_THEMES ] ) ? sanitize_text_field( $_POST[ self::OPT_NAME_THEMES ] ) : '0';
46 if ( ( false === $error )
47 && ( ( false === $this->is_switch_value( $post_enable ) )
48 || ( false === $this->is_switch_value( $post_wpcore ) )
49 || ( false === $this->is_notify_value( $post_plugins ) )
50 || ( false === $this->is_notify_value( $post_themes ) ) ) ) {
51 echo '<div class="error settings-error"><p><strong>';
52 esc_html_e( 'ERROR: Invalid input value.', 'siteguard' );
53 echo '</strong></p></div>';
54 $error = true;
55 }
56 if ( false === $error && '1' === $post_enable ) {
57 $ret = $siteguard_updates_notify->check_requirements();
58 if ( is_wp_error( $ret ) ) {
59 echo '<div class="error settings-error"><p><strong>' . esc_html( $ret->get_error_message() ) . '</strong></p></div>';
60 $error = true;
61 $siteguard_config->set( self::OPT_NAME_ENABLE, '0' );
62 $siteguard_config->update();
63 // The stored setting now says OFF, so the cron event goes with
64 // it. Without this an event from an earlier ON state keeps
65 // sending notifications on a site whose settings page shows the
66 // feature as off and refuses to turn it on.
67 SiteGuard_UpdatesNotify::feature_off();
68 }
69 }
70 if ( false === $error ) {
71 $opt_val_enable = $post_enable;
72 $opt_val_wpcore = $post_wpcore;
73 $opt_val_plugins = $post_plugins;
74 $opt_val_themes = $post_themes;
75 $siteguard_config->set( self::OPT_NAME_ENABLE, $opt_val_enable );
76 $siteguard_config->set( self::OPT_NAME_WPCORE, $opt_val_wpcore );
77 $siteguard_config->set( self::OPT_NAME_PLUGINS, $opt_val_plugins );
78 $siteguard_config->set( self::OPT_NAME_THEMES, $opt_val_themes );
79 $siteguard_config->update();
80 if ( '1' === $opt_val_enable ) {
81 SiteGuard_UpdatesNotify::feature_on();
82 } else {
83 SiteGuard_UpdatesNotify::feature_off();
84 }
85 ?>
86 <div class="updated"><p><strong><?php esc_html_e( 'Options saved.', 'siteguard' ); ?></strong></p></div>
87 <?php
88 }
89 }
90
91 echo '<div class="wrap">';
92 echo '<img src="' . SITEGUARD_URL_PATH . 'images/sg_wp_plugin_logo_40.png" alt="SiteGuard Logo" />';
93 echo '<h2>' . esc_html__( 'Update Notifications', 'siteguard' ) . '</h2>';
94 $documentation_link = '<a href="' . esc_url( __( 'https://www.jp-secure.com/siteguard_wp_plugin_en/howto/updates_notify/', 'siteguard' ) ) . '" target="_blank">' . esc_html__( 'online documentation', 'siteguard' ) . '</a>';
95 echo '<div class="siteguard-description">'
96 . sprintf(
97 /* translators: %1$s: Link to the online documentation. */
98 esc_html__( 'See the %1$s.', 'siteguard' ),
99 $documentation_link
100 )
101 . '</div>';
102 ?>
103 <form name="form1" method="post" action="">
104 <table class="form-table">
105 <tr>
106 <th scope="row" colspan="2">
107 <ul class="siteguard-radios">
108 <li>
109 <input type="radio" name="<?php echo self::OPT_NAME_ENABLE; ?>" id="<?php echo self::OPT_NAME_ENABLE . '_on'; ?>" value="1" <?php checked( $opt_val_enable, '1' ); ?> >
110 <label for="<?php echo self::OPT_NAME_ENABLE . '_on'; ?>"><?php esc_html_e( 'ON', 'siteguard' ); ?></label>
111 </li><li>
112 <input type="radio" name="<?php echo self::OPT_NAME_ENABLE; ?>" id="<?php echo self::OPT_NAME_ENABLE . '_off'; ?>" value="0" <?php checked( $opt_val_enable, '0' ); ?> >
113 <label for="<?php echo self::OPT_NAME_ENABLE . '_off'; ?>"><?php esc_html_e( 'OFF', 'siteguard' ); ?></label>
114 </li>
115 </ul>
116 <?php
117 $error = $siteguard_updates_notify->check_requirements();
118 if ( is_wp_error( $error ) ) {
119 echo '<p class="description">';
120 echo esc_html( $error->get_error_message() );
121 echo '</p>';
122 }
123 ?>
124 </th>
125 </tr><tr>
126 <th scope="row"><?php esc_html_e( 'WordPress updates', 'siteguard' ); ?></th>
127 <td>
128 <input type="radio" name="<?php echo self::OPT_NAME_WPCORE; ?>" id="<?php echo self::OPT_NAME_WPCORE . '_0'; ?>" value="0" <?php checked( $opt_val_wpcore, '0' ); ?> >
129 <label for="<?php echo self::OPT_NAME_WPCORE . '_0'; ?>"><?php esc_html_e( 'Disable', 'siteguard' ); ?></label>
130 <br />
131 <input type="radio" name="<?php echo self::OPT_NAME_WPCORE; ?>" id="<?php echo self::OPT_NAME_WPCORE . '_1'; ?>" value="1" <?php checked( $opt_val_wpcore, '1' ); ?> >
132 <label for="<?php echo self::OPT_NAME_WPCORE . '_1'; ?>"><?php esc_html_e( 'Enable', 'siteguard' ); ?></label>
133 </td>
134 </tr><tr>
135 <th scope="row"><?php esc_html_e( 'Plugin updates', 'siteguard' ); ?></th>
136 <td>
137 <input type="radio" name="<?php echo self::OPT_NAME_PLUGINS; ?>" id="<?php echo self::OPT_NAME_PLUGINS . '_0'; ?>" value="0" <?php checked( $opt_val_plugins, '0' ); ?> >
138 <label for="<?php echo self::OPT_NAME_PLUGINS . '_0'; ?>"><?php esc_html_e( 'Disable', 'siteguard' ); ?></label>
139 <br />
140 <input type="radio" name="<?php echo self::OPT_NAME_PLUGINS; ?>" id="<?php echo self::OPT_NAME_PLUGINS . '_1'; ?>" value="1" <?php checked( $opt_val_plugins, '1' ); ?> >
141 <label for="<?php echo self::OPT_NAME_PLUGINS . '_1'; ?>"><?php esc_html_e( 'All plugins', 'siteguard' ); ?></label>
142 <br />
143 <input type="radio" name="<?php echo self::OPT_NAME_PLUGINS; ?>" id="<?php echo self::OPT_NAME_PLUGINS . '_2'; ?>" value="2" <?php checked( $opt_val_plugins, '2' ); ?> >
144 <label for="<?php echo self::OPT_NAME_PLUGINS . '_2'; ?>"><?php esc_html_e( 'Active plugins only', 'siteguard' ); ?></label>
145 </td>
146 </tr><tr>
147 <th scope="row"><?php esc_html_e( 'Theme updates', 'siteguard' ); ?></th>
148 <td>
149 <input type="radio" name="<?php echo self::OPT_NAME_THEMES; ?>" id="<?php echo self::OPT_NAME_THEMES . '_0'; ?>" value="0" <?php checked( $opt_val_themes, '0' ); ?> >
150 <label for="<?php echo self::OPT_NAME_THEMES . '_0'; ?>"><?php esc_html_e( 'Disable', 'siteguard' ); ?></label>
151 <br />
152 <input type="radio" name="<?php echo self::OPT_NAME_THEMES; ?>" id="<?php echo self::OPT_NAME_THEMES . '_1'; ?>" value="1" <?php checked( $opt_val_themes, '1' ); ?> >
153 <label for="<?php echo self::OPT_NAME_THEMES . '_1'; ?>"><?php esc_html_e( 'All themes', 'siteguard' ); ?></label>
154 <br />
155 <input type="radio" name="<?php echo self::OPT_NAME_THEMES; ?>" id="<?php echo self::OPT_NAME_THEMES . '_2'; ?>" value="2" <?php checked( $opt_val_themes, '2' ); ?> >
156 <label for="<?php echo self::OPT_NAME_THEMES . '_2'; ?>"><?php esc_html_e( 'Active themes only', 'siteguard' ); ?></label>
157 </td>
158 </tr>
159 </table>
160 <div class="siteguard-description">
161 <?php esc_html_e( 'Keeping WordPress core, plugins, and themes up to date is a basic security practice. This feature checks for updates every 24 hours and emails administrators when updates are available.', 'siteguard' ); ?>
162 </div>
163 <hr />
164 <input type="hidden" name="update" value="Y">
165
166 <?php
167 wp_nonce_field( 'siteguard-menu-updates-notify-submit' );
168 submit_button();
169 ?>
170
171 </form>
172 </div>
173
174 <?php
175 }
176 }
177