diff --git a/defines.php b/defines.php index bdbcd173..9cf0bea1 100644 --- a/defines.php +++ b/defines.php @@ -1,7 +1,7 @@ ` and `
  • ` tags. - * - * @since 1.0 - * - * @param (array) $msgs An array of messages. - * @param (string) $test_name The scanner name. - * - * @return (string) An HTML list of formatted messages. - */ -function secupress_format_message( $msgs, $test_name ) { - $classname = 'SecuPress_Scan_' . $test_name; - $messages = $classname::get_instance()->get_messages(); - - $output = array(); - - if ( empty( $msgs ) ) { - return implode( '
    ', $output ); - } - - foreach ( $msgs as $id => $atts ) { - - if ( ! isset( $messages[ $id ] ) ) { - - $string = __( 'Fix done.', 'secupress' ); - - } elseif ( is_array( $messages[ $id ] ) ) { - - $count = array_shift( $atts ); - $string = translate_nooped_plural( $messages[ $id ], $count ); - - } else { - - $string = $messages[ $id ]; - - } - - if ( $atts ) { - foreach ( $atts as $i => $att ) { - if ( is_array( $att ) ) { - $atts[ $i ] = wp_sprintf_l( '%l', $att ); - } - } - } - - $output[] = ! empty( $atts ) ? vsprintf( $string, $atts ) : $string; - } - - return implode( '
    ', $output ); -} +} \ No newline at end of file diff --git a/free/admin/settings.php b/free/admin/settings.php index 1d0c4de1..9e73fcd0 100644 --- a/free/admin/settings.php +++ b/free/admin/settings.php @@ -511,12 +511,19 @@ function secupress_scanners() {
  • + 0 ) : ?> +
  • + + + +
  • +
  • - + 0 ) : ?>
  • diff --git a/free/classes/scanners/class-secupress-scan-bad-vuln-plugins.php b/free/classes/scanners/class-secupress-scan-bad-vuln-plugins.php index f85b179b..325c6ba9 100755 --- a/free/classes/scanners/class-secupress-scan-bad-vuln-plugins.php +++ b/free/classes/scanners/class-secupress-scan-bad-vuln-plugins.php @@ -86,6 +86,7 @@ public static function get_messages( $message_id = null ) { 104 => __( 'No plugins selected for deactivation.', 'secupress' ), 105 => _n_noop( 'Selected plugin has been deactivated (but some are still there).', 'All selected plugins have been deactivated (but some are still there).', 'secupress' ), 106 => _n_noop( 'Sorry, the following plugin could not be deactivated: %s.', 'Sorry, the following plugins could not be deactivated: %s.', 'secupress' ), + 107 => __( 'Your installation may contain vulnerable plugins. The PRO version will be more accurate.', 'secupress' ), // "bad" /** Translators: 1 is a number, 2 is a plugin name (or a list of plugin names). */ 200 => _n_noop( '%1$d plugin is known to be vulnerable: %2$s.', '%1$d plugins are known to be vulnerable: %2$s.', 'secupress' ), @@ -94,7 +95,6 @@ public static function get_messages( $message_id = null ) { 203 => _n_noop( 'Sorry, this plugin could not be deleted.', 'Sorry, those plugins could not be deleted.', 'secupress' ), 204 => _n_noop( 'The following plugin should be deactivated if you don’t need it: %s.', 'The following plugins should be deactivated if you don’t need them: %s.', 'secupress' ), 205 => _n_noop( 'Sorry, this plugin could not be deactivated.', 'Sorry, those plugins could not be deactivated.', 'secupress' ), - 206 => __( 'Your installation may contain vulnerable plugins. The PRO version will be more accurate.', 'secupress' ), // "cantfix" /** Translators: %d is a number. */ 300 => _n_noop( '%d plugin can be deleted.', '%d plugins can be deleted.', 'secupress' ), @@ -152,7 +152,7 @@ public function scan() { $bad_plugins = $this->get_installed_plugins_vulnerables(); if ( is_numeric( $bad_plugins ) ) { - $this->add_message( 206 ); + $this->add_message( 107 ); } elseif ( $count = count( $bad_plugins ) ) { // "bad" $this->add_message( 200, array( $count, $count, self::wrap_in_tag( $bad_plugins ) ) ); diff --git a/free/classes/scanners/class-secupress-scan-discloses.php b/free/classes/scanners/class-secupress-scan-discloses.php index 3a1d949f..77bd5084 100755 --- a/free/classes/scanners/class-secupress-scan-discloses.php +++ b/free/classes/scanners/class-secupress-scan-discloses.php @@ -167,6 +167,7 @@ public function scan() { if ( $has_response ) { $powered_by = wp_remote_retrieve_header( $response, 'x-powered-by' ); + $powered_by = is_array( $powered_by ) ? reset( $powered_by ) : $powered_by; $body = wp_remote_retrieve_body( $response ); } @@ -289,6 +290,14 @@ public function fix() { if ( $has_response ) { $powered_by = wp_remote_retrieve_header( $response, 'x-powered-by' ); + if ( is_array( $powered_by ) ) { + foreach( $powered_by as $p ) { + if ( strpos( $p, 'PHP/' ) === 0 ) { + $powered_by = $p; + break; + } + } + } $body = wp_remote_retrieve_body( $response ); } diff --git a/free/classes/scanners/class-secupress-scan-https.php b/free/classes/scanners/class-secupress-scan-https.php index e4dc15fc..a024984a 100755 --- a/free/classes/scanners/class-secupress-scan-https.php +++ b/free/classes/scanners/class-secupress-scan-https.php @@ -148,7 +148,7 @@ public static function get_messages( $message_id = null ) { // "bad" 200 => __( 'Your site is not totally using HTTPS/SSL: %s', 'secupress' ), 201 => __( 'Your site does not use HTTPS/SSL. Error: %s', 'secupress' ), - 202 => __( 'Your website seems to run under maintenance mode, rescan this later when you set it off.', 'secupress' ), + 202 => __( 'Your website seems to run under maintenance mode, relaunch the HTTPS scanner later when you set it off.', 'secupress' ), // "cantfix" 300 => __( 'Cannot be fixed automatically. You have to contact you host provider to ask him to upgrade your site with HTTPS/SSL.', 'secupress' ), 301 => __( 'Update your HOME url and SITE url with https://.', 'secupress' ), diff --git a/free/classes/settings/class-secupress-settings.php b/free/classes/settings/class-secupress-settings.php index 1d7d6ffd..d6cb50b1 100644 --- a/free/classes/settings/class-secupress-settings.php +++ b/free/classes/settings/class-secupress-settings.php @@ -1554,8 +1554,8 @@ protected function print_sideads() { if ( 'secupress_ad_before' !== $sidead['hook'] ) { continue; } - if ( ( 'free' === $sidead['when'] && ! secupress_is_pro() ) - || ( 'pro' === $sidead['when'] && secupress_is_pro() ) + if ( ( 'free' === $sidead['when'] && ! secupress_has_pro() ) + || ( 'pro' === $sidead['when'] && secupress_has_pro() ) || 'both' === $sidead['when'] ) { $content_locale = 'content-' . get_user_locale(); diff --git a/free/functions/common.php b/free/functions/common.php index a467abe4..18c59faf 100644 --- a/free/functions/common.php +++ b/free/functions/common.php @@ -369,6 +369,7 @@ function secupress_die( $message = '', $title = '', $args = array() ) { $message = '

    ' . SECUPRESS_PLUGIN_NAME . '

    ' . $message; $url = secupress_get_current_url( 'raw' ); $force_die = ! empty( $args['force_die'] ); + $context = ! empty( $args['context'] ) ? $args['context'] : ''; $is_scan_request = secupress_is_scan_request(); // Used to bypass the whitelist for scans. /** @@ -381,7 +382,7 @@ function secupress_die( $message = '', $title = '', $args = array() ) { * @param (array) $args Facultative arguments. * @param (bool) $is_scan_request Tell if the request comes from one of our scans. */ - $message = apply_filters( 'secupress.die.message', $message, $url, $args, $is_scan_request ); + $message = apply_filters( 'secupress.die.message', $message, $url, $args, $is_scan_request, $context ); /** * Fires right before `wp_die()`. @@ -393,7 +394,7 @@ function secupress_die( $message = '', $title = '', $args = array() ) { * @param (array) $args Facultative arguments. * @param (bool) $is_scan_request Tell if the request comes from one of our scans. */ - do_action( 'secupress.before.die', $message, $url, $args, $is_scan_request ); + do_action( 'secupress.before.die', $message, $url, $args, $is_scan_request, $context ); if ( $force_die || $is_scan_request ) { // Die. @@ -1663,9 +1664,60 @@ function secupress_status( $status ) { $statuses = []; $statuses['bad'] = __( 'Bad', 'secupress' ); $statuses['good'] = __( 'Good', 'secupress' ); - $statuses['warning'] = __( 'Warning', 'secupress' ); + $statuses['warning'] = __( 'Pending', 'secupress' ); $statuses['cantfix'] = __( 'Error', 'secupress' ); return isset( $statuses[ $status ] ) ? $statuses[ $status ] : __( 'New', 'secupress' ); } + +/** + * Retrieve messages by their ID and format them by wrapping them in `