diff --git a/wp-content/plugins/wp-super-cache/ossdl-cdn.php b/wp-content/plugins/wp-super-cache/ossdl-cdn.php
index 44c02f86b02582266aa8a2a975ec78d311ecb020..648bde078100a7d3d77fbd1df7c52c5f779850ca 100644
--- a/wp-content/plugins/wp-super-cache/ossdl-cdn.php
+++ b/wp-content/plugins/wp-super-cache/ossdl-cdn.php
@@ -2,36 +2,92 @@
 
 /* Taken from OSSDL CDN off-linker, a plugin by W-Mark Kubacki (http://mark.ossdl.de/) and used with permission */
 
-/* Set up some defaults */
-if ( get_option( 'ossdl_off_cdn_url' ) === false ) {
-	add_option( 'ossdl_off_cdn_url', get_option( 'siteurl' ) );
-}
-if ( get_option( 'ossdl_off_blog_url' ) === false ) {
-	add_option( 'ossdl_off_blog_url', apply_filters( 'ossdl_off_blog_url', untrailingslashit( get_option( 'siteurl' ) ) ) );
-}
-$ossdl_off_blog_url = get_option( 'ossdl_off_blog_url' );
-$ossdl_off_cdn_url  = trim( get_option( 'ossdl_off_cdn_url' ) );
-if ( get_option( 'ossdl_off_include_dirs' ) === false ) {
-	add_option( 'ossdl_off_include_dirs', 'wp-content,wp-includes' );
-}
-$ossdl_off_include_dirs = trim( get_option( 'ossdl_off_include_dirs' ) );
-if ( get_option( 'ossdl_off_exclude' ) === false ) {
-	add_option( 'ossdl_off_exclude', '.php' );
+if ( ! isset( $ossdlcdn ) ) {
+	$ossdlcdn = 1; // have to default to on for existing users.
 }
-$ossdl_off_exclude = trim( get_option( 'ossdl_off_exclude' ) );
-$arr_of_excludes   = array_map( 'trim', explode( ',', $ossdl_off_exclude ) );
-if ( ! is_array( $arr_of_excludes ) ) {
-	$arr_of_excludes = array();
+
+if ( 1 === $ossdlcdn && ! is_admin() ) {
+	add_action( 'init', 'do_scossdl_off_ob_start' );
 }
 
-if ( get_option( 'ossdl_cname' ) == false ) {
-	add_option( 'ossdl_cname', '' );
+/**
+ * Set up some defaults.
+ *
+ * @global string $ossdl_off_blog_url
+ * @global string $ossdl_off_cdn_url
+ * @global string $ossdl_cname
+ * @global int    $ossdl_https
+ * @global array  $ossdl_off_include_dirs
+ * @global array  $ossdl_off_excludes
+ * @global array  $ossdl_arr_of_cnames
+ *
+ * @return void
+ */
+function scossdl_off_get_options() {
+	global $ossdl_off_blog_url, $ossdl_off_cdn_url, $ossdl_cname, $ossdl_https;
+	global $ossdl_off_include_dirs, $ossdl_off_excludes, $ossdl_arr_of_cnames;
+
+	$ossdl_off_blog_url = get_option( 'ossdl_off_blog_url' );
+	if ( false === $ossdl_off_blog_url ) {
+		$ossdl_off_blog_url = untrailingslashit( get_site_url() );
+		add_option( 'ossdl_off_blog_url', $ossdl_off_blog_url );
+	}
+
+	if ( has_filter( 'ossdl_off_blog_url' ) ) {
+		$ossdl_off_blog_url = untrailingslashit( apply_filters( 'ossdl_off_blog_url', $ossdl_off_blog_url ) );
+	}
+
+	$ossdl_off_cdn_url = get_option( 'ossdl_off_cdn_url' );
+	if ( false === $ossdl_off_cdn_url ) {
+		$ossdl_off_cdn_url = untrailingslashit( get_site_url() );
+		add_option( 'ossdl_off_cdn_url', $ossdl_off_cdn_url );
+	}
+
+	$include_dirs = get_option( 'ossdl_off_include_dirs' );
+	if ( false !== $include_dirs ) {
+		$ossdl_off_include_dirs = array_filter( array_map( 'trim', explode( ',', $include_dirs ) ) );
+	} else {
+		$ossdl_off_include_dirs = scossdl_off_default_inc_dirs();
+		add_option( 'ossdl_off_include_dirs', implode( ',', $ossdl_off_include_dirs ) );
+	}
+
+	$exclude = get_option( 'ossdl_off_exclude' );
+	if ( false !== $exclude ) {
+		$ossdl_off_excludes = array_filter( array_map( 'trim', explode( ',', $exclude ) ) );
+	} else {
+		$ossdl_off_excludes = array( '.php' );
+		add_option( 'ossdl_off_exclude', implode( ',', $ossdl_off_excludes ) );
+	}
+
+	$ossdl_cname = get_option( 'ossdl_cname' );
+	if ( false !== $ossdl_cname ) {
+		$ossdl_cname = trim( $ossdl_cname );
+	} else {
+		$ossdl_cname = '';
+		add_option( 'ossdl_cname', $ossdl_cname );
+	}
+	$ossdl_arr_of_cnames = array_filter( array_map( 'trim', explode( ',', $ossdl_cname ) ) );
+
+	$ossdl_https = intval( get_option( 'ossdl_https' ) );
 }
-$ossdl_cname   = trim( get_option( 'ossdl_cname' ) );
-$ossdl_https   = intval( get_option( 'ossdl_https' ) );
-$arr_of_cnames = array_map( 'trim', explode( ',', $ossdl_cname ) );
-if ( $arr_of_cnames[0] == '' ) {
-	$arr_of_cnames = array();
+
+/**
+ * Get default directories.
+ *
+ * @return array
+ */
+function scossdl_off_default_inc_dirs() {
+
+	$home_path = trailingslashit( (string) parse_url( get_option( 'siteurl' ), PHP_URL_PATH ) );
+	$inc_dirs  = array();
+
+	foreach ( array( content_url(), includes_url() ) as $dir ) {
+		$dir        = wp_make_link_relative( $dir );
+		$dir        = preg_replace( '`^' . preg_quote( $home_path, '`' ) . '`', '', $dir );
+		$inc_dirs[] = trim( $dir, '/' );
+	}
+
+	return $inc_dirs;
 }
 
 /**
@@ -44,25 +100,29 @@ if ( $arr_of_cnames[0] == '' ) {
  */
 function scossdl_off_exclude_match( $match, $excludes ) {
 	foreach ( $excludes as $badword ) {
-		if ( ! empty( $badword ) && stripos( $match, $badword ) !== false ) {
+		if ( false !== stripos( $match, $badword ) ) {
 			return true;
 		}
 	}
+
 	return false;
 }
 
 /**
  * Compute string modulo, based on SHA1 hash
  *
- * @param string $str
- * @param int    $mod
+ * @param string $str The string.
+ * @param int    $mod The divisor.
  *
- * @return int
+ * @return int The remainder.
  */
 function scossdl_string_mod( $str, $mod ) {
-	/* The full SHA1 is too large for PHP integer types. This should be
-	 * enough for our purpose */
+	/**
+	 * The full SHA1 is too large for PHP integer types.
+	 * This should be enough for our purpose.
+	 */
 	$num = hexdec( substr( sha1( $str ), 0, 5 ) );
+
 	return $num % $mod;
 }
 
@@ -72,28 +132,26 @@ function scossdl_string_mod( $str, $mod ) {
  * Called by #scossdl_off_filter.
  */
 function scossdl_off_rewriter( $match ) {
-	global $ossdl_off_blog_url, $ossdl_off_cdn_url, $arr_of_excludes, $arr_of_cnames, $ossdl_https;
+	global $ossdl_off_blog_url, $ossdl_https, $ossdl_off_excludes, $ossdl_arr_of_cnames;
+	static $count_cnames = null, $include_dirs = null;
 
-	if ( $ossdl_off_cdn_url == '' ) {
-		return $match[0];
+	// Set up static variables. Run once only.
+	if ( ! isset( $count_cnames ) ) {
+		$count_cnames = count( $ossdl_arr_of_cnames );
+		$include_dirs = scossdl_off_additional_directories();
 	}
 
-	if ( $ossdl_https && 0 === strncmp( $match[0], 'https', 5 ) ) {
+	if ( $ossdl_https && 0 === strpos( $match[0], 'https' ) ) {
 		return $match[0];
 	}
 
-	if ( false === in_array( $ossdl_off_cdn_url, $arr_of_cnames ) ) {
-		$arr_of_cnames[] = $ossdl_off_cdn_url;
-	}
-
-	if ( scossdl_off_exclude_match( $match[0], $arr_of_excludes ) ) {
+	if ( scossdl_off_exclude_match( $match[0], $ossdl_off_excludes ) ) {
 		return $match[0];
 	}
 
-	$include_dirs = scossdl_off_additional_directories();
-	if ( preg_match( '/' . $include_dirs . '/', $match[0] ) ) {
-		$offset = scossdl_string_mod( $match[1], count( $arr_of_cnames ) );
-		return str_replace( $ossdl_off_blog_url, $arr_of_cnames[ $offset ], $match[0] );
+	if ( preg_match( '`(' . $include_dirs . ')`', $match[0] ) ) {
+		$offset = scossdl_string_mod( $match[1], $count_cnames );
+		return str_replace( $ossdl_off_blog_url, $ossdl_arr_of_cnames[ $offset ], $match[0] );
 	}
 
 	return $match[0];
@@ -105,28 +163,47 @@ function scossdl_off_rewriter( $match ) {
  * @return String with the pattern with {@literal |} as prefix, or empty
  */
 function scossdl_off_additional_directories() {
-        global $ossdl_off_include_dirs;
+	global $ossdl_off_include_dirs;
 
-        $arr_dirs = explode( ',', $ossdl_off_include_dirs );
-        if ( $ossdl_off_include_dirs == '' || count( $arr_dirs ) < 1 ) {
-               return 'wp\-content|wp\-includes';
-        }
+	$arr_dirs = array();
+	foreach ( $ossdl_off_include_dirs as $dir ) {
+		$arr_dirs[] = preg_quote( trim( $dir ), '`' );
+	}
 
-        return implode( '|', array_map( 'preg_quote', array_map( 'trim', $arr_dirs ) ) );
+	return implode( '|', $arr_dirs );
 }
 
 /**
  * Output filter which runs the actual plugin logic.
+ *
+ * @param  string $content The content of the output buffer.
+ *
+ * @return string The rewritten content.
  */
 function scossdl_off_filter( $content ) {
 	global $ossdl_off_blog_url, $ossdl_off_cdn_url;
+	global $ossdl_off_include_dirs, $ossdl_off_excludes, $ossdl_arr_of_cnames;
+
+	if ( empty( $content ) || empty( $ossdl_off_cdn_url ) ||
+		$ossdl_off_blog_url === $ossdl_off_cdn_url
+	) {
+		return $content; // no rewrite needed.
+	}
+
+	if ( empty( $ossdl_off_include_dirs ) || ! is_array( $ossdl_off_include_dirs ) ) {
+		$ossdl_off_include_dirs = scossdl_off_default_inc_dirs();
+	}
 
-	if ( $ossdl_off_blog_url == $ossdl_off_cdn_url ) { // no rewrite needed
-		return $content;
+	if ( empty( $ossdl_off_excludes ) || ! is_array( $ossdl_off_excludes ) ) {
+		$ossdl_off_excludes = array();
+	}
+
+	if ( ! in_array( $ossdl_off_cdn_url, (array) $ossdl_arr_of_cnames, true ) ) {
+		$ossdl_arr_of_cnames = array_merge( array( $ossdl_off_cdn_url ), (array) $ossdl_arr_of_cnames );
 	}
 
 	$dirs  = scossdl_off_additional_directories();
-	$regex = '#(?<=[(\"\'])' . preg_quote( $ossdl_off_blog_url ) . '/(?:((?:' . $dirs . ')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])#';
+	$regex = '`(?<=[(\"\'])' . preg_quote( $ossdl_off_blog_url, '`' ) . '/(?:((?:' . $dirs . ')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])`';
 	return preg_replace_callback( $regex, 'scossdl_off_rewriter', $content );
 }
 
@@ -135,28 +212,41 @@ function scossdl_off_filter( $content ) {
  */
 function do_scossdl_off_ob_start() {
 	global $ossdl_off_blog_url, $ossdl_off_cdn_url;
-	if ( $ossdl_off_blog_url != $ossdl_off_cdn_url ) {
+
+	if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
+		return;
+	}
+
+	scossdl_off_get_options();
+
+	if ( ! empty( $ossdl_off_cdn_url ) &&
+		$ossdl_off_blog_url !== $ossdl_off_cdn_url
+	) {
 		add_filter( 'wp_cache_ob_callback_filter', 'scossdl_off_filter' );
 	}
 }
-if ( false == isset( $ossdlcdn ) ) {
-	$ossdlcdn = 1; // have to default to on for existing users.
-}
-if ( $ossdlcdn == 1 ) {
-	add_action( 'init', 'do_scossdl_off_ob_start' );
-}
 
+/**
+ * Update CDN settings to the options database table.
+ */
 function scossdl_off_update() {
 
 	if ( isset( $_POST['action'], $_POST['_wpnonce'] )
-		&& 'update_ossdl_off' === $_POST['action']
+		&& 'update_ossdl_off' === $_POST['action'] // WPCS: sanitization ok.
 		&& wp_verify_nonce( $_POST['_wpnonce'], 'wp-cache' )
 	) {
-		update_option( 'ossdl_off_cdn_url', untrailingslashit( $_POST['ossdl_off_cdn_url'] ) );
-		update_option( 'ossdl_off_blog_url', untrailingslashit( $_POST['ossdl_off_blog_url'] ) );
-		update_option( 'ossdl_off_include_dirs', $_POST['ossdl_off_include_dirs'] == '' ? 'wp-content,wp-includes' : $_POST['ossdl_off_include_dirs'] );
-		update_option( 'ossdl_off_exclude', $_POST['ossdl_off_exclude'] );
-		update_option( 'ossdl_cname', $_POST['ossdl_cname'] );
+		update_option( 'ossdl_off_cdn_url', untrailingslashit( wp_unslash( $_POST['ossdl_off_cdn_url'] ) ) ); // WPSC: sanitization ok.
+		update_option( 'ossdl_off_blog_url', untrailingslashit( wp_unslash( $_POST['ossdl_off_blog_url'] ) ) ); // WPSC: sanitization ok.
+
+		if ( empty( $_POST['ossdl_off_include_dirs'] ) ) {
+			$include_dirs = implode( ',', scossdl_off_default_inc_dirs() );
+		} else {
+			$include_dirs = sanitize_text_field( wp_unslash( $_POST['ossdl_off_include_dirs'] ) ); // WPSC: validation ok,sanitization ok.
+		}
+		update_option( 'ossdl_off_include_dirs', $include_dirs );
+
+		update_option( 'ossdl_off_exclude', sanitize_text_field( wp_unslash( $_POST['ossdl_off_exclude'] ) ) ); // WPSC: sanitization ok.
+		update_option( 'ossdl_cname', sanitize_text_field( wp_unslash( $_POST['ossdl_cname'] ) ) ); // WPSC: sanitization ok.
 
 		$ossdl_https = empty( $_POST['ossdl_https'] ) ? 0 : 1;
 		$ossdlcdn    = empty( $_POST['ossdlcdn'] ) ? 0 : 1;
@@ -166,78 +256,119 @@ function scossdl_off_update() {
 	}
 }
 
+/**
+ * Show CDN settings.
+ */
 function scossdl_off_options() {
-	global $ossdlcdn, $ossdl_off_blog_url;
+	global $ossdlcdn, $ossdl_off_blog_url, $ossdl_off_cdn_url, $ossdl_cname, $ossdl_https;
+	global $ossdl_off_include_dirs, $ossdl_off_excludes;
 
 	scossdl_off_update();
 
-	$example_cdn_uri = str_replace( 'http://', 'http://cdn.', str_replace( 'www.', '', get_option( 'siteurl' ) ) );
-	$example_cnames  = str_replace( 'http://cdn.', 'http://cdn1.', $example_cdn_uri );
-	$example_cnames .= ',' . str_replace( 'http://cdn.', 'http://cdn2.', $example_cdn_uri );
-	$example_cnames .= ',' . str_replace( 'http://cdn.', 'http://cdn3.', $example_cdn_uri );
+	scossdl_off_get_options();
+
+	$example_cdn_uri = ( is_ssl() ? 'https' : 'http' ) . '://cdn.' . preg_replace( '`^(https?:)?//(www\.)?`', '', get_site_url() );
+	$example_cnames  = str_replace( '://cdn.', '://cdn1.', $example_cdn_uri );
+	$example_cnames .= ',' . str_replace( '://cdn.', '://cdn2.', $example_cdn_uri );
+	$example_cnames .= ',' . str_replace( '://cdn.', '://cdn3.', $example_cdn_uri );
 
-	$example_cdn_uri  = get_option( 'ossdl_off_cdn_url' ) == get_option( 'siteurl' ) ? $example_cdn_uri : get_option( 'ossdl_off_cdn_url' );
+	$example_cdn_uri  = ( get_site_url() === $ossdl_off_cdn_url ) ? $example_cdn_uri : $ossdl_off_cdn_url;
 	$example_cdn_uri .= '/wp-includes/js/jquery/jquery-migrate.js';
 	$example_cdn_uri  = esc_url( $example_cdn_uri );
 	?>
+		<h3><?php _e( 'Jetpack CDN' ); ?></h3>
+		<p><?php printf(
+			__( 'The free %1$sJetpack plugin%2$s has a %3$sSite Accelerator%2$s feature that is easier to use than the CDN functionality in this plugin. However files will be cached "forever" and will not update if you update the local file. Files will need to be renamed to refresh them. The %3$sJetpack documentation%2$s explains more about this.', 'wp-super-cache' ),
+			'<a href="https://jetpack.com/">',
+			'</a>',
+			'<a href="https://jetpack.com/support/site-accelerator/">'
+		); ?></p>
+	<?php
+	if ( class_exists( 'Jetpack' ) ) {
+		if ( Jetpack::is_module_active( 'photon' ) ) {
+			?><p><strong><?php printf(
+				__( 'You already have Jetpack installed and %1$sSite Accelerator%2$s enabled on this blog. The CDN here is disabled to avoid conflicts with Jetpack.', 'wp-super-cache' ),
+				'<a href="https://jetpack.com/support/site-accelerator/">',
+				'</a>'
+			); ?></strong></p><?php
+		} else {
+			?><p><?php printf(
+				__( 'You already have Jetpack installed but %1$sSite Accelerator%2$s is disabled on this blog. Enable it on the %3$sJetpack settings page%2$s.', 'wp-super-cache' ),
+				'<a href="https://jetpack.com/support/site-accelerator/">',
+				'</a>',
+				'<a href="' . admin_url( 'admin.php?page=jetpack#/settings' ) . '">'
+			); ?></p><?php
+		}
+	} else {
+			?><p><strong><?php printf(
+				__( '%1$sJetpack%2$s was not found on your site but %3$syou can install it%2$s. The Site Accelerator feature is free to use on any WordPress site and offers the same benefit as other CDN services. You should give it a try!', 'wp-super-cache' ),
+				'<a href="https://jetpack.com/">',
+				'</a>',
+				'<a href="' . admin_url( 'plugin-install.php?s=jetpack&tab=search&type=term' ) . '">'
+			); ?></strong></p><?php
+	}
+	if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
+		return;
+	}
+	?>
+		<h3><?php _e( 'Simple CDN' ); ?></h3>
 		<p><?php _e( 'Your website probably uses lots of static files. Image, Javascript and CSS files are usually static files that could just as easily be served from another site or CDN. Therefore, this plugin replaces any links in the <code>wp-content</code> and <code>wp-includes</code> directories (except for PHP files) on your site with the URL you provide below. That way you can either copy all the static content to a dedicated host or mirror the files to a CDN by <a href="https://knowledgelayer.softlayer.com/faq/how-does-origin-pull-work" target="_blank">origin pull</a>.', 'wp-super-cache' ); ?></p>
 		<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Test some static urls e.g., %s  to ensure your CDN service is fully working before saving changes.', 'wp-super-cache' ), '<code>' . esc_html( $example_cdn_uri ) . '</code>' ); ?></p>
 
-	<?php if ( $ossdl_off_blog_url != get_home_url() ) { ?>
+	<?php if ( get_home_url() !== $ossdl_off_blog_url ) { ?>
 		<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Your siteurl and homeurl are different. The plugin is using %s as the homepage URL of your site but if that is wrong please use the filter "ossdl_off_blog_url" to fix it.', 'wp-super-cache' ), '<code>' . esc_html( $ossdl_off_blog_url ) . '</code>' ); ?></p>
 	<?php } ?>
-
-		<p><?php _e( 'You can define different CDN URLs for each site on a multsite network.', 'wp-super-cache' ); ?></p>
+		<p><?php esc_html_e( 'You can define different CDN URLs for each site on a multsite network.', 'wp-super-cache' ); ?></p>
 		<p><form method="post" action="">
 		<?php wp_nonce_field( 'wp-cache' ); ?>
 		<table class="form-table"><tbody>
 			<tr valign="top">
 				<td style='text-align: right'>
-					<input id='ossdlcdn' type="checkbox" name="ossdlcdn" value="1" <?php if ( $ossdlcdn ) { echo "checked=1"; } ?> />
+					<input id='ossdlcdn' type="checkbox" name="ossdlcdn" value="1" <?php checked( $ossdlcdn ); ?> />
 				</td>
-				<th scope="row"><label for="ossdlcdn"><?php _e( 'Enable CDN Support', 'wp-super-cache' ); ?></label></th>
+				<th scope="row"><label for="ossdlcdn"><?php esc_html_e( 'Enable CDN Support', 'wp-super-cache' ); ?></label></th>
 			</tr>
 			<tr valign="top">
-				<th scope="row"><label for="ossdl_off_cdn_url"><?php _e( 'Site URL', 'wp-super-cache' ); ?></label></th>
+				<th scope="row"><label for="ossdl_off_cdn_url"><?php esc_html_e( 'Site URL', 'wp-super-cache' ); ?></label></th>
 				<td>
-					<input type="text" name="ossdl_off_blog_url" value="<?php echo esc_url( untrailingslashit( get_option( 'ossdl_off_blog_url' ) ) ); ?>" size="64" class="regular-text code" /><br />
+					<input type="text" name="ossdl_off_blog_url" value="<?php echo esc_attr( untrailingslashit( $ossdl_off_blog_url ) ); ?>" size="64" class="regular-text code" /><br />
 					<span class="description"><?php _e( 'The URL of your site. No trailing <code>/</code> please.', 'wp-super-cache' ); ?></span>
 				</td>
 			</tr>
 			<tr valign="top">
-				<th scope="row"><label for="ossdl_off_cdn_url"><?php _e( 'Off-site URL', 'wp-super-cache' ); ?></label></th>
+				<th scope="row"><label for="ossdl_off_cdn_url"><?php esc_html_e( 'Off-site URL', 'wp-super-cache' ); ?></label></th>
 				<td>
-					<input type="text" name="ossdl_off_cdn_url" value="<?php echo esc_url( get_option( 'ossdl_off_cdn_url' ) ); ?>" size="64" class="regular-text code" /><br />
-					<span class="description"><?php printf( __( 'The new URL to be used in place of %1$s for rewriting. No trailing <code>/</code> please.<br />Example: <code>%2$s</code>.', 'wp-super-cache' ), esc_html( get_option( 'siteurl' ) ), esc_html( $example_cdn_uri ) ); ?></span>
+					<input type="text" name="ossdl_off_cdn_url" value="<?php echo esc_attr( $ossdl_off_cdn_url ); ?>" size="64" class="regular-text code" /><br />
+					<span class="description"><?php printf( __( 'The new URL to be used in place of %1$s for rewriting. No trailing <code>/</code> please.<br />Example: <code>%2$s</code>.', 'wp-super-cache' ), esc_html( get_site_url() ), esc_html( $example_cdn_uri ) ); ?></span>
 				</td>
 			</tr>
 			<tr valign="top">
-				<th scope="row"><label for="ossdl_off_include_dirs"><?php _e( 'Include directories', 'wp-super-cache' ); ?></label></th>
+				<th scope="row"><label for="ossdl_off_include_dirs"><?php esc_html_e( 'Include directories', 'wp-super-cache' ); ?></label></th>
 				<td>
-					<input type="text" name="ossdl_off_include_dirs" value="<?php echo esc_attr( get_option( 'ossdl_off_include_dirs' ) ); ?>" size="64" class="regular-text code" /><br />
+					<input type="text" name="ossdl_off_include_dirs" value="<?php echo esc_attr( implode( ',', $ossdl_off_include_dirs ) ); ?>" size="64" class="regular-text code" /><br />
 					<span class="description"><?php _e( 'Directories to include in static file matching. Use a comma as the delimiter. Default is <code>wp-content, wp-includes</code>, which will be enforced if this field is left empty.', 'wp-super-cache' ); ?></span>
 				</td>
 			</tr>
 			<tr valign="top">
-				<th scope="row"><label for="ossdl_off_exclude"><?php _e( 'Exclude if substring', 'wp-super-cache' ); ?></label></th>
+				<th scope="row"><label for="ossdl_off_exclude"><?php esc_html_e( 'Exclude if substring', 'wp-super-cache' ); ?></label></th>
 				<td>
-					<input type="text" name="ossdl_off_exclude" value="<?php echo esc_attr( get_option( 'ossdl_off_exclude' ) ); ?>" size="64" class="regular-text code" /><br />
+					<input type="text" name="ossdl_off_exclude" value="<?php echo esc_attr( implode( ',', $ossdl_off_excludes ) ); ?>" size="64" class="regular-text code" /><br />
 					<span class="description"><?php _e( 'Excludes something from being rewritten if one of the above strings is found in the URL. Use a comma as the delimiter like this, <code>.php, .flv, .do</code>, and always include <code>.php</code> (default).', 'wp-super-cache' ); ?></span>
 				</td>
 			</tr>
 			<tr valign="top">
-				<th scope="row"><label for="ossdl_cname"><?php _e( 'Additional CNAMES', 'wp-super-cache' ); ?></label></th>
+				<th scope="row"><label for="ossdl_cname"><?php esc_html_e( 'Additional CNAMES', 'wp-super-cache' ); ?></label></th>
 				<td>
-					<input type="text" name="ossdl_cname" value="<?php echo esc_attr( get_option( 'ossdl_cname' ) ); ?>" size="64" class="regular-text code" /><br />
-					<span class="description"><?php printf( __( 'These <a href="http://en.wikipedia.org/wiki/CNAME_record">CNAMES</a> will be used in place of %1$s for rewriting (in addition to the off-site URL above). Use a comma as the delimiter. For pages with a large number of static files, this can improve browser performance. CNAMEs may also need to be configured on your CDN.<br />Example: %2$s', 'wp-super-cache' ), esc_html( get_option( 'siteurl' ) ), esc_html( $example_cnames ) ); ?></span>
+					<input type="text" name="ossdl_cname" value="<?php echo esc_attr( $ossdl_cname ); ?>" size="64" class="regular-text code" /><br />
+					<span class="description"><?php printf( __( 'These <a href="https://www.wikipedia.org/wiki/CNAME_record">CNAMES</a> will be used in place of %1$s for rewriting (in addition to the off-site URL above). Use a comma as the delimiter. For pages with a large number of static files, this can improve browser performance. CNAMEs may also need to be configured on your CDN.<br />Example: %2$s', 'wp-super-cache' ), esc_html( get_site_url() ), esc_html( $example_cnames ) ); ?></span>
 				</td>
 			</tr>
 			<tr valign="top">
-				<th scope="row" colspan='2'><label><input type='checkbox' name='ossdl_https' value='1' <?php if ( get_option( 'ossdl_https' ) ) { echo 'checked'; } ?> /> <?php _e( 'Skip https URLs to avoid "mixed content" errors', 'wp-super-cache' ); ?></label></th>
+				<th scope="row" colspan='2'><label><input type='checkbox' name='ossdl_https' value='1' <?php checked( $ossdl_https ); ?> /><?php esc_html_e( 'Skip https URLs to avoid "mixed content" errors', 'wp-super-cache' ); ?></label></th>
 			</tr>
 		</tbody></table>
 		<input type="hidden" name="action" value="update_ossdl_off" />
-		<p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'wp-super-cache' ); ?>" /></p>
+		<p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-super-cache' ); ?>" /></p>
 		</form></p>
 		<p><?php _e( 'CDN functionality provided by <a href="https://wordpress.org/plugins/ossdl-cdn-off-linker/">OSSDL CDN Off Linker</a> by <a href="http://mark.ossdl.de/">Mark Kubacki</a>', 'wp-super-cache' ); ?></p>
 	<?php
diff --git a/wp-content/plugins/wp-super-cache/plugins/domain-mapping.php b/wp-content/plugins/wp-super-cache/plugins/domain-mapping.php
index f1d9018e31dbb6c323f963e6f889843221d50a87..a6b2bcc230f629ed32db7faf606903b201ec9a65 100644
--- a/wp-content/plugins/wp-super-cache/plugins/domain-mapping.php
+++ b/wp-content/plugins/wp-super-cache/plugins/domain-mapping.php
@@ -4,16 +4,15 @@ function domain_mapping_gc_cache( $function, $directory ) {
 	global $cache_path;
 
 	if ( ! function_exists( 'domain_mapping_warning' ) ) {
-		return false;
+		return;
 	}
 
 	$siteurl = domain_mapping_siteurl( false );
 	if ( ! $siteurl ) {
-		return false;
+		return;
 	}
 
-	$protocol = ( isset( $_SERVER['HTTPS'] ) && 'on' === strtolower( $_SERVER['HTTPS'] ) ) ? 'https://' : 'http://';
-	$siteurl  = trailingslashit( str_replace( $protocol, '', $siteurl ) );
+	$sitedir = trailingslashit( preg_replace( '`^(https?:)?//`', '', $siteurl ) );
 
 	if ( 'homepage' === $directory ) {
 		$directory = '';
@@ -21,20 +20,17 @@ function domain_mapping_gc_cache( $function, $directory ) {
 
 	switch ( $function ) {
 		case 'rebuild':
-			@wp_cache_rebuild_or_delete( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html' );
-			@wp_cache_rebuild_or_delete( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz' );
+			wpsc_rebuild_files( $cache_path . 'supercache/' . $sitedir . $directory );
 			break;
 		case 'prune':
-			prune_super_cache( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html', true, true );
-			prune_super_cache( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz', true, true );
+			wpsc_delete_files( $cache_path . 'supercache/' . $sitedir . $directory );
 			break;
 	}
-
-	return $directory;
 }
 
 function domain_mapping_supercachedir( $dir ) {
 	global $cache_path;
+
 	if ( ! function_exists( 'domain_mapping_warning' ) ) {
 		return $dir;
 	}
@@ -44,56 +40,62 @@ function domain_mapping_supercachedir( $dir ) {
 		return $dir;
 	}
 
-	$protocol = ( isset( $_SERVER['HTTPS'] ) && 'on' === strtolower( $_SERVER['HTTPS'] ) ) ? 'https://' : 'http://';
-	$siteurl  = str_replace( $protocol, '', $siteurl );
-	return trailingslashit( $cache_path . 'supercache/' . $siteurl );
+	$sitedir = trailingslashit( preg_replace( '`^(https?:)?//`', '', $siteurl ) );
+
+	return trailingslashit( $cache_path . 'supercache/' . $sitedir );
 }
 
 function domain_mapping_actions() {
 	global $cache_domain_mapping;
-	if ( '1' === $cache_domain_mapping ) {
-		add_filter( 'wp_super_cache_supercachedir', 'domain_mapping_supercachedir' );
-		add_action( 'gc_cache', 'domain_mapping_gc_cache', 10, 2 );
+
+	$cache_domain_mapping = (int) $cache_domain_mapping;
+	if ( 1 !== $cache_domain_mapping ) {
+		return;
 	}
+
+	add_filter( 'wp_super_cache_supercachedir', 'domain_mapping_supercachedir' );
+	add_action( 'gc_cache', 'domain_mapping_gc_cache', 10, 2 );
 }
 add_cacheaction( 'add_cacheaction', 'domain_mapping_actions' );
 
 function wp_supercache_domain_mapping_admin() {
 	global $cache_domain_mapping, $wp_cache_config_file, $valid_nonce;
 
-	$cache_domain_mapping = '' === $cache_domain_mapping ? '0' : $cache_domain_mapping;
+	$requested_state      = isset( $_POST['cache_domain_mapping'] ) ? (int) $_POST['cache_domain_mapping'] : null;
+	$cache_domain_mapping = (int) $cache_domain_mapping;
 
-	if ( isset( $_POST['cache_domain_mapping'] ) && $valid_nonce ) {
-		if ( $cache_domain_mapping === (int) $_POST['cache_domain_mapping'] ) {
-			$changed = false;
-		} else {
-			$changed = true;
-		}
-		$cache_domain_mapping = (int) $_POST['cache_domain_mapping'];
-		wp_cache_replace_line( '^ *\$cache_domain_mapping', "\$cache_domain_mapping = '$cache_domain_mapping';", $wp_cache_config_file );
+	$changed = false;
+	if ( null !== $requested_state && $valid_nonce ) {
+		$cache_domain_mapping = $requested_state;
+
+		wp_cache_replace_line( '^\s*\$cache_domain_mapping\s*=', '$cache_domain_mapping = ' . intval( $cache_domain_mapping ) . ';', $wp_cache_config_file );
+		$changed = true;
 	}
+
 	$id = 'domain_mapping-section';
 	?>
-		<fieldset id="<?php echo $id; ?>" class="options">
-		<h4><?php _e( 'Domain Mapping', 'wp-super-cache' ); ?></h4>
+	<fieldset id="<?php echo esc_attr( $id ); ?>" class="options">
+
+		<h4><?php esc_html_e( 'Domain Mapping', 'wp-super-cache' ); ?></h4>
+
 		<form name="wp_manager" action="" method="post">
-		<label><input type="radio" name="cache_domain_mapping" value="1" <?php if ( $cache_domain_mapping ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
-		<label><input type="radio" name="cache_domain_mapping" value="0" <?php if ( ! $cache_domain_mapping ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
-		<p><?php _e( '', 'wp-super-cache' ); ?></p>
-	<?php
-	echo '<p>' . __( 'Provides support for <a href="https://wordpress.org/plugins/wordpress-mu-domain-mapping/">Domain Mapping</a> plugin to map multiple domains to a blog.', 'wp-super-cache' ) . '</p>';
-	if ( isset( $changed ) && $changed ) {
-		if ( $cache_domain_mapping ) {
-			$status = __( 'enabled', 'wp-super-cache' );
-		} else {
-			$status = __( 'disabled', 'wp-super-cache' );
+		<label><input type="radio" name="cache_domain_mapping" value="1" <?php checked( $cache_domain_mapping ); ?>/> <?php esc_html_e( 'Enabled', 'wp-super-cache' ); ?></label>
+		<label><input type="radio" name="cache_domain_mapping" value="0" <?php checked( ! $cache_domain_mapping ); ?>/> <?php esc_html_e( 'Disabled', 'wp-super-cache' ); ?></label>
+		<?php
+		echo '<p>' . __( 'Provides support for <a href="https://wordpress.org/plugins/wordpress-mu-domain-mapping/">Domain Mapping</a> plugin to map multiple domains to a blog.', 'wp-super-cache' ) . '</p>';
+
+		if ( $changed ) {
+			echo '<p><strong>' . sprintf(
+				esc_html__( 'Domain Mapping support is now %s', 'wp-super-cache' ),
+				esc_html( $cache_domain_mapping ? __( 'enabled', 'wp-super-cache' ) : __( 'disabled', 'wp-super-cache' ) )
+			) . '</strong></p>';
 		}
-		echo '<p><strong>' . sprintf( __( 'Domain Mapping support is now %s', 'wp-super-cache' ), $status ) . '</strong></p>';
-	}
-	echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
-	wp_nonce_field( 'wp-cache' );
-	?>
-	</form>
+
+		echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . ' type="submit" value="' . esc_html__( 'Update', 'wp-super-cache' ) . '" /></div>';
+		wp_nonce_field( 'wp-cache' );
+		?>
+		</form>
+
 	</fieldset>
 	<?php
 }
@@ -101,14 +103,17 @@ add_cacheaction( 'cache_admin_page', 'wp_supercache_domain_mapping_admin' );
 
 function wp_supercache_domain_mapping_notice() {
 	global $cache_enabled;
+
 	if ( $cache_enabled ) {
-		echo '<div class="error"><p><strong>' . __( 'Domain Mapping plugin detected! Please go to the Supercache plugins page and enable the domain mapping helper plugin.', 'wp-super-cache' ) . '</strong></p></div>';
+		echo '<div class="error"><p><strong>' . esc_html__( 'Domain Mapping plugin detected! Please go to the Supercache plugins page and enable the domain mapping helper plugin.', 'wp-super-cache' ) . '</strong></p></div>';
 	}
 }
 function wp_supercache_domain_mapping_exists() {
 	global $cache_domain_mapping;
-	if ( '1' === $cache_domain_mapping ) {
-		return false;
+
+	$cache_domain_mapping = (int) $cache_domain_mapping;
+	if ( 1 === $cache_domain_mapping ) {
+		return;
 	}
 
 	if ( is_admin() && function_exists( 'domain_mapping_warning' ) ) {
@@ -124,8 +129,8 @@ function wpsc_domain_mapping_list( $list ) {
 	$list['domain_mapping'] = array(
 		'key'   => 'domain_mapping',
 		'url'   => 'https://wordpress.org/plugins/wordpress-mu-domain-mapping/',
-		'title' => __( 'Domain Mapping', 'wp-super-cache' ),
-		'desc'  => __( 'Provides support for Domain Mapping plugin to map multiple domains to a blog.', 'wp-super-cache' ),
+		'title' => esc_html__( 'Domain Mapping', 'wp-super-cache' ),
+		'desc'  => esc_html__( 'Provides support for Domain Mapping plugin to map multiple domains to a blog.', 'wp-super-cache' ),
 	);
 	return $list;
 }
diff --git a/wp-content/plugins/wp-super-cache/plugins/multisite.php b/wp-content/plugins/wp-super-cache/plugins/multisite.php
index 6306a160e5952b1ace343c82265a31edd38771b2..df71f9ac4ba2396f8acb45ba6b2bf89d0b3d2c6a 100644
--- a/wp-content/plugins/wp-super-cache/plugins/multisite.php
+++ b/wp-content/plugins/wp-super-cache/plugins/multisite.php
@@ -1,6 +1,6 @@
 <?php
 
-if ( ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) === true ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) {
+if ( is_multisite() ) {
 	add_cacheaction( 'add_cacheaction', 'wp_super_cache_multisite_init' );
 }
 
diff --git a/wp-content/plugins/wp-super-cache/readme.txt b/wp-content/plugins/wp-super-cache/readme.txt
index 62aaedb57f3254d2578e44464db2357592936e28..24f4fa0e576542c2225e5d1ec450b0a54bd545ca 100644
--- a/wp-content/plugins/wp-super-cache/readme.txt
+++ b/wp-content/plugins/wp-super-cache/readme.txt
@@ -1,8 +1,8 @@
 # WP Super Cache #
 * Contributors: donncha, automattic, kraftbj
 * Tags: performance, caching, wp-cache, wp-super-cache, cache
-* Tested up to: 5.0.2
-* Stable tag: 1.6.4
+* Tested up to: 5.1.1
+* Stable tag: 1.6.5
 * Requires at least: 3.1
 * Requires PHP: 5.2.4
 * License: GPLv2 or later
@@ -266,6 +266,28 @@ Your theme is probably responsive which means it resizes the page to suit whatev
 
 ## Changelog ##
 
+### 1.6.5 ###
+* Check advanced-cache.php was created by the plugin before modifying/deleting it. (#666)
+* When saving settings, save blank lines. Fixes problems with WP_CACHE and WPCACHEHOME in wp-config.php. Related to #652. (#667)
+* Update outdated code and use is_multisite() (#600)
+* Fix the delete cache button in the admin bar. (#603)
+* Code cleanup in #602
+* Use get_post_status instead of post_status (#623)
+* Fixes button - Update Direct Pages (#622)
+* Removes apache_response_headers and uses only headers_list (#618)
+* Function is_site_admin has been deprecated (#611)
+* Fixes action urls in wp_cache_manager (#610)
+* Remove the link to the HibbsLupusTrust tweet. (#635)
+* Don't load wp-cache-config.php if it's already loaded (#605)
+* PHPCS fixes and optimization for plugins/domain-mapping.php (#615)
+* Introduces PHP_VERSION_ID for faster checking (#604)
+* Fixes regex and optimizes ossdl-cdn.php (#596)
+* Only update new settings and use a temporary file to avoid corruption. (#652)
+* Serve cached files to rejected user agents, don't cache them. (#658)
+* Combine multiple headers with the same name (#641)
+* Open ‘Delete Cache’ link in same window (#656)
+* Promote the Jetpack Site Accelerator on the CDN page. (#636)
+
 ### 1.6.4 ###
 * Changes between [1.6.3 and 1.6.4](https://github.com/Automattic/wp-super-cache/compare/1.6.3...1.6.4)
 * Fixes for WP-CLI (#587) (#592)
@@ -691,4 +713,4 @@ Your theme is probably responsive which means it resizes the page to suit whatev
 
 
 ## Upgrade Notice ##
-Bug fixes
+Many bug fixes
diff --git a/wp-content/plugins/wp-super-cache/wp-cache-base.php b/wp-content/plugins/wp-super-cache/wp-cache-base.php
index 5ee15c28cf4f70b2ef49ed50e949fb3b6b9e786b..df65196c4a75b308313c89da1ac1321af8719b31 100644
--- a/wp-content/plugins/wp-super-cache/wp-cache-base.php
+++ b/wp-content/plugins/wp-super-cache/wp-cache-base.php
@@ -1,8 +1,9 @@
 <?php
-global $WPSC_HTTP_HOST, $blogcacheid;
+global $WPSC_HTTP_HOST, $cache_enabled, $cache_path, $blogcacheid, $blog_cache_dir;
 
 if ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
-	$WPSC_HTTP_HOST = htmlentities( $_SERVER['HTTP_HOST'] );
+	$WPSC_HTTP_HOST = function_exists( 'mb_strtolower' ) ? mb_strtolower( $_SERVER['HTTP_HOST'] ) : strtolower( $_SERVER['HTTP_HOST'] );
+	$WPSC_HTTP_HOST = htmlentities( $WPSC_HTTP_HOST );
 } elseif ( PHP_SAPI === 'cli' && function_exists( 'get_option' ) ) {
 	$WPSC_HTTP_HOST = (string) parse_url( get_option( 'home' ), PHP_URL_HOST );
 } else {
@@ -11,29 +12,36 @@ if ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
 }
 
 // We want to be able to identify each blog in a WordPress MU install
-$blogcacheid = '';
-if ( ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) {
-	$blogcacheid = 'blog'; // main blog
-	if ( defined( 'SUBDOMAIN_INSTALL' ) && constant( 'SUBDOMAIN_INSTALL' ) == true ) {
+$blogcacheid    = '';
+$blog_cache_dir = $cache_path;
+
+if ( is_multisite() ) {
+	global $current_blog;
+
+	if ( is_object( $current_blog ) && function_exists( 'is_subdomain_install' ) ) {
+		$blogcacheid = is_subdomain_install() ? $current_blog->domain : trim( $current_blog->path, '/' );
+	} elseif ( ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) || ( defined( 'VHOST' ) && VHOST === 'yes' ) ) {
 		$blogcacheid = $WPSC_HTTP_HOST;
 	} else {
-		if ( isset( $base ) == false ) {
-			$base = '';
-		}
 		$request_uri = str_replace( '..', '', preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI'] ) );
-		if ( strlen( $request_uri ) > 0 && strpos( $request_uri, '/', 1 ) ) {
-			if ( $base == '/' ) {
-				$blogcacheid = substr( $request_uri, 1, strpos( $request_uri, '/', 1 ) - 1 );
-			} else {
-				$blogcacheid = str_replace( $base, '', $request_uri );
-				if ( $blogcacheid != '' ) {
-					$blogcacheid = substr( $blogcacheid, 0, strpos( $blogcacheid, '/', 1 ) );
-				}
-			}
-			if ( '/' == substr( $blogcacheid, -1 ) ) {
-				$blogcacheid = substr( $blogcacheid, 0, -1 );
-			}
+		$request_uri = str_replace( '//', '/', $request_uri );
+
+		$wpsc_path_segs  = array_filter( explode( '/', trim( $request_uri, '/' ) ) );
+		$wpsc_base_count = defined( 'PATH_CURRENT_SITE' ) ? count( array_filter( explode( '/', trim( PATH_CURRENT_SITE, '/' ) ) ) ) : 0;
+		if ( '/' !== substr( $request_uri, -1 ) ) {
+			$wpsc_path_segs = array_slice( $wpsc_path_segs, 0, -1 );
 		}
-		$blogcacheid = str_replace( '/', '', $blogcacheid );
+
+		if ( count( $wpsc_path_segs ) > $wpsc_base_count &&
+			( ! defined( 'PATH_CURRENT_SITE' ) || 0 === strpos( $request_uri, PATH_CURRENT_SITE ) )
+		) {
+			$blogcacheid = $wpsc_path_segs[ $wpsc_base_count ];
+		}
+	}
+
+	// If blogcacheid is empty then set it to main blog.
+	if ( empty( $blogcacheid ) ) {
+		$blogcacheid = 'blog';
 	}
+	$blog_cache_dir = str_replace( '//', '/', $cache_path . 'blogs/' . $blogcacheid . '/' );
 }
diff --git a/wp-content/plugins/wp-super-cache/wp-cache-config-sample.php b/wp-content/plugins/wp-super-cache/wp-cache-config-sample.php
index f943169cf27930e6b58e21dea45a1423b6bb7483..0112ad06ba63a3837cffc6730ce9ed2674b29387 100644
--- a/wp-content/plugins/wp-super-cache/wp-cache-config-sample.php
+++ b/wp-content/plugins/wp-super-cache/wp-cache-config-sample.php
@@ -76,7 +76,6 @@ $wp_cache_pages[ "author" ] = 0;
 $wp_cache_hide_donation = 0;
 $wp_cache_not_logged_in = 0;
 $wp_cache_clear_on_post_edit = 0;
-$wp_cache_hello_world = 0;
 $wp_cache_mobile_enabled = 0;
 $wp_cache_cron_check = 0;
 $wp_cache_mfunc_enabled = 0;
diff --git a/wp-content/plugins/wp-super-cache/wp-cache-phase2.php b/wp-content/plugins/wp-super-cache/wp-cache-phase2.php
index 41fb0c66101b710e08e444c7b1c88f9687603731..a81da50ac8147e420d63cbfa14da73225cbff370 100644
--- a/wp-content/plugins/wp-super-cache/wp-cache-phase2.php
+++ b/wp-content/plugins/wp-super-cache/wp-cache-phase2.php
@@ -52,11 +52,6 @@ function wp_cache_serve_cache_file() {
 		return false;
 	}
 
-	if ( wp_cache_user_agent_is_rejected() ) {
-		wp_cache_debug( 'No wp-cache file served as user agent rejected.', 5 );
-		return false;
-	}
-
 	if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) ) {
 		wp_cache_debug( 'Non empty GET request. Caching disabled on settings page. ' . wpsc_dump_get_request(), 1 );
 		return false;
@@ -226,10 +221,11 @@ function wp_cache_serve_cache_file() {
 	} else {
 		$ungzip = false;
 	}
-	foreach ($meta[ 'headers' ] as $t => $header) {
+	foreach ( $meta['headers'] as $t => $header ) {
 		// godaddy fix, via http://blog.gneu.org/2008/05/wp-supercache-on-godaddy/ and http://www.littleredrails.com/blog/2007/09/08/using-wp-cache-on-godaddy-500-error/
-		if( strpos( $header, 'Last-Modified:' ) === false )
-			header($header);
+		if ( strpos( $header, 'Last-Modified:' ) === false ) {
+			header( $header );
+		}
 	}
 	if ( isset( $wpsc_served_header ) && $wpsc_served_header ) {
 		header( 'X-WP-Super-Cache: Served WPCache cache file' );
@@ -825,7 +821,7 @@ function get_oc_key( $url = false ) {
 	global $wp_cache_gzip_encoding, $WPSC_HTTP_HOST;
 
 	if ( $url ) {
-		$key = intval( $_SERVER[ 'SERVER_PORT' ] ) . strtolower( preg_replace( '/:.*$/', '',  $WPSC_HTTP_HOST ) ) . $url;
+		$key = intval( $_SERVER[ 'SERVER_PORT' ] ) . preg_replace( '/:.*$/', '',  $WPSC_HTTP_HOST ) . $url;
 	} else {
 		$key = get_current_url_supercache_dir();
 	}
@@ -1109,13 +1105,23 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
 		}
 	}
 	foreach( (array) $lines as $line ) {
-		if ( preg_match("/$old/", $line)) {
+		if (
+			trim( $new ) != '' &&
+			trim( $new ) == trim( $line )
+		) {
+			wp_cache_debug( "wp_cache_replace_line: setting not changed - $new" );
+			return false;
+		} elseif ( preg_match( "/$old/", $line ) ) {
+			wp_cache_debug( "wp_cache_replace_line: changing line " . trim( $line ) . " to *$new*" );
 			$found = true;
-			break;
 		}
 	}
 
-	$fd = fopen( $my_file, 'w' );
+	$tmp_config_filename = tempnam( $GLOBALS['cache_path'], 'wpsc' );
+	rename( $tmp_config_filename, $tmp_wpcache_filename . ".php" );
+	$tmp_config_filename .= ".php";
+	wp_cache_debug( 'wp_cache_replace_line: writing to ' . $tmp_config_filename );
+	$fd = fopen( $tmp_config_filename, 'w' );
 	if ( ! $fd ) {
 		if ( function_exists( 'set_transient' ) ) {
 			set_transient( 'wpsc_config_error', 'config_file_ro', 10 );
@@ -1144,6 +1150,8 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
 		}
 	}
 	fclose( $fd );
+	rename( $tmp_config_filename, $my_file );
+	wp_cache_debug( 'wp_cache_replace_line: moved ' . $tmp_config_filename . ' to ' . $my_file );
 
 	if ( function_exists( "opcache_invalidate" ) ) {
 		@opcache_invalidate( $my_file );
@@ -1160,6 +1168,11 @@ function wp_cache_phase2() {
 		return false;
 	}
 
+	if ( wp_cache_user_agent_is_rejected() ) {
+		wp_cache_debug( 'wp_cache_phase2: No caching to do as user agent rejected.' );
+		return false;
+	}
+
 	wp_cache_debug( 'In WP Cache Phase 2', 5 );
 
 	$wp_cache_gmt_offset = get_option( 'gmt_offset' ); // caching for later use when wpdb is gone. https://wordpress.org/support/topic/224349
@@ -1374,79 +1387,83 @@ function wp_cache_user_agent_is_rejected() {
 
 function wp_cache_get_response_headers() {
 	static $known_headers = array(
-						'Access-Control-Allow-Origin',
-						'Accept-Ranges',
-						'Age',
-						'Allow',
-						'Cache-Control',
-						'Connection',
-						'Content-Encoding',
-						'Content-Language',
-						'Content-Length',
-						'Content-Location',
-						'Content-MD5',
-						'Content-Disposition',
-						'Content-Range',
-						'Content-Type',
-						'Date',
-						'ETag',
-						'Expires',
-						'Last-Modified',
-						'Link',
-						'Location',
-						'P3P',
-						'Pragma',
-						'Proxy-Authenticate',
-						"Referrer-Policy",
-						'Refresh',
-						'Retry-After',
-						'Server',
-						'Status',
-						'Strict-Transport-Security',
-						'Trailer',
-						'Transfer-Encoding',
-						'Upgrade',
-						'Vary',
-						'Via',
-						'Warning',
-						'WWW-Authenticate',
-						'X-Frame-Options',
-						'Public-Key-Pins',
-						'X-XSS-Protection',
-						'Content-Security-Policy',
-						"X-Pingback",
-						'X-Content-Security-Policy',
-						'X-WebKit-CSP',
-						'X-Content-Type-Options',
-						'X-Powered-By',
-						'X-UA-Compatible',
-						'X-Robots-Tag',
-					);
+		'Access-Control-Allow-Origin',
+		'Accept-Ranges',
+		'Age',
+		'Allow',
+		'Cache-Control',
+		'Connection',
+		'Content-Encoding',
+		'Content-Language',
+		'Content-Length',
+		'Content-Location',
+		'Content-MD5',
+		'Content-Disposition',
+		'Content-Range',
+		'Content-Type',
+		'Date',
+		'ETag',
+		'Expires',
+		'Last-Modified',
+		'Link',
+		'Location',
+		'P3P',
+		'Pragma',
+		'Proxy-Authenticate',
+		'Referrer-Policy',
+		'Refresh',
+		'Retry-After',
+		'Server',
+		'Status',
+		'Strict-Transport-Security',
+		'Trailer',
+		'Transfer-Encoding',
+		'Upgrade',
+		'Vary',
+		'Via',
+		'Warning',
+		'WWW-Authenticate',
+		'X-Frame-Options',
+		'Public-Key-Pins',
+		'X-XSS-Protection',
+		'Content-Security-Policy',
+		'X-Pingback',
+		'X-Content-Security-Policy',
+		'X-WebKit-CSP',
+		'X-Content-Type-Options',
+		'X-Powered-By',
+		'X-UA-Compatible',
+		'X-Robots-Tag',
+	);
+
+	if ( ! function_exists( 'headers_list' ) ) {
+		return array();
+	}
 
 	$known_headers = apply_filters( 'wpsc_known_headers', $known_headers );
 
-	if ( ! isset( $known_headers[ 'age' ] ) ) {
+	if ( ! isset( $known_headers['age'] ) ) {
 		$known_headers = array_map( 'strtolower', $known_headers );
 	}
 
 	$headers = array();
-	if ( function_exists( 'apache_response_headers' ) ) {
-		$headers = apache_response_headers();
-	}
-	if ( empty( $headers ) && function_exists( 'headers_list' ) ) {
-		$headers = array();
-		foreach( headers_list() as $hdr ) {
-			$header_parts = explode( ':', $hdr, 2 );
-			$header_name  = isset( $header_parts[0] ) ? trim( $header_parts[0] ) : '';
-			$header_value = isset( $header_parts[1] ) ? trim( $header_parts[1] ) : '';
+	foreach ( headers_list() as $hdr ) {
+		$ptr = strpos( $hdr, ':' );
 
-			$headers[$header_name] = $header_value;
+		if ( empty( $ptr ) ) {
+			continue;
 		}
-	}
 
-	foreach( $headers as $key => $value ) {
-		if ( ! in_array( strtolower( $key ), $known_headers ) ) {
-			unset( $headers[ $key ] );
+		$hdr_key = rtrim( substr( $hdr, 0, $ptr ) );
+
+		if ( in_array( strtolower( $hdr_key ), $known_headers, true ) ) {
+			$hdr_val = ltrim( substr( $hdr, $ptr + 1 ) );
+
+			if ( ! empty( $headers[ $hdr_key ] ) ) {
+				$hdr_val = $headers[ $hdr_key ] . ', ' . $hdr_val;
+			}
+
+			$headers[ $hdr_key ] = $hdr_val;
 		}
 	}
 
@@ -2760,7 +2777,7 @@ function wp_cache_post_edit( $post_id ) {
 
 	// Some users are inexplicibly seeing this error on scheduled posts.
 	// define this constant to disable the post status check.
-	if ( false == defined( 'WPSCFORCEUPDATE' ) && !in_array($post->post_status, array( 'publish', 'private' ) ) ) {
+	if ( ! defined( 'WPSCFORCEUPDATE' ) && ! in_array( get_post_status( $post ), array( 'publish', 'private' ), true ) ) {
 		wp_cache_debug( 'wp_cache_post_edit: draft post, not deleting any cache files. status: ' . $post->post_status, 4 );
 		return $post_id;
 	}
@@ -2825,17 +2842,24 @@ function wp_cache_post_change( $post_id ) {
 		wp_cache_debug( "wp_cache_post_change(${action}): Already processed post $post_id.", 4 );
 		return $post_id;
 	}
-	$post = get_post( $post_id );
+
+	$post  = get_post( $post_id );
+	$ptype = is_object( $post ) ? get_post_type_object( $post->post_type ) : null;
+	if ( empty( $ptype ) || ! $ptype->public ) {
+		return $post_id;
+	}
+
 	// Some users are inexplicibly seeing this error on scheduled posts.
 	// define this constant to disable the post status check.
-	if ( false == defined( 'WPSCFORCEUPDATE' ) && is_object( $post ) && !in_array($post->post_status, array( 'publish', 'private' ) ) ) {
+	if ( ! defined( 'WPSCFORCEUPDATE' ) && ! in_array( get_post_status( $post ), array( 'publish', 'private' ), true ) ) {
 		wp_cache_debug( 'wp_cache_post_change: draft post, not deleting any cache files.', 4 );
 		return $post_id;
 	}
 	$last_processed = $post_id;
 
-	if( !wp_cache_writers_entry() )
+	if ( ! wp_cache_writers_entry() ) {
 		return $post_id;
+	}
 
 	if (
 		isset( $wp_cache_refresh_single_only ) &&
diff --git a/wp-content/plugins/wp-super-cache/wp-cache.php b/wp-content/plugins/wp-super-cache/wp-cache.php
index 3a04cb1f8ebae2b7ba526000c9625d1c2ad4c0a6..4457f50665b84ca580b57a40559cf98c4a875046 100644
--- a/wp-content/plugins/wp-super-cache/wp-cache.php
+++ b/wp-content/plugins/wp-super-cache/wp-cache.php
@@ -3,7 +3,7 @@
 Plugin Name: WP Super Cache
 Plugin URI: https://wordpress.org/plugins/wp-super-cache/
 Description: Very fast caching plugin for WordPress.
-Version: 1.6.4
+Version: 1.6.5
 Author: Automattic
 Author URI: https://automattic.com/
 License: GPL2+
@@ -33,6 +33,13 @@ if ( ! function_exists( 'wp_cache_phase2' ) ) {
 	require_once( dirname( __FILE__ ) . '/wp-cache-phase2.php');
 }
 
+if ( ! defined( 'PHP_VERSION_ID' ) ) {
+	// For versions of PHP below 5.2.7, this constant doesn't exist.
+	$wpsc_php_version = explode( '.', PHP_VERSION );
+	define( 'PHP_VERSION_ID', intval( $wpsc_php_version[0] * 10000 + $wpsc_php_version[1] * 100 + $wpsc_php_version[2] ) );
+	unset( $wpsc_php_version );
+}
+
 function wpsc_init() {
 	global $wp_cache_config_file, $wp_cache_config_file_sample, $wp_cache_file, $wp_cache_check_wp_config, $wp_cache_link;
 
@@ -76,17 +83,13 @@ global $wp_cache_preload_email_me, $wp_cache_preload_email_volume;
 global $wp_cache_mobile, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes;
 global $wp_cache_config_file, $wp_cache_config_file_sample;
 
-// WP-CLI: Hotfix for $blog_cache_dir for single site. It'll be removed after merging #590
-if ( empty( $GLOBALS['blog_cache_dir'] ) && ! is_multisite() ) {
-	$GLOBALS['blog_cache_dir'] = $cache_path;
-}
-
-if( !@include($wp_cache_config_file) ) {
-	get_wpcachehome();
-	$wp_cache_config_file_sample = WPCACHEHOME . 'wp-cache-config-sample.php';
-	@include($wp_cache_config_file_sample);
-} else {
-	get_wpcachehome();
+// Check is cache config already loaded.
+if ( ! isset( $cache_enabled, $super_cache_enabled, $wp_cache_mod_rewrite, $cache_path ) &&
+	empty( $wp_cache_phase1_loaded ) &&
+	// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
+	! @include( $wp_cache_config_file )
+) {
+	@include $wp_cache_config_file_sample; // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
 }
 
 include(WPCACHEHOME . 'wp-cache-base.php');
@@ -116,25 +119,42 @@ add_action( 'template_redirect', 'wp_cache_set_home' );
 include_once( WPCACHEHOME . 'ossdl-cdn.php' );
 
 function get_wpcachehome() {
-	if( defined( 'WPCACHEHOME' ) == false ) {
-		if( is_file( dirname(__FILE__) . '/wp-cache-config-sample.php' ) ) {
-			define( 'WPCACHEHOME', trailingslashit( dirname(__FILE__) ) );
-		} elseif( is_file( dirname(__FILE__) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
-			define( 'WPCACHEHOME', dirname(__FILE__) . '/wp-super-cache/' );
+	if ( function_exists( '_deprecated_function' ) ) {
+		_deprecated_function( __FUNCTION__, 'WP Super Cache 1.6.5' );
+	}
+
+	if ( ! defined( 'WPCACHEHOME' ) ) {
+		if ( is_file( dirname( __FILE__ ) . '/wp-cache-config-sample.php' ) ) {
+			define( 'WPCACHEHOME', trailingslashit( dirname( __FILE__ ) ) );
+		} elseif ( is_file( dirname( __FILE__ ) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
+			define( 'WPCACHEHOME', dirname( __FILE__ ) . '/wp-super-cache/' );
 		} else {
-			die( sprintf( __( 'Please create %s /wp-cache-config.php from wp-super-cache/wp-cache-config-sample.php', 'wp-super-cache' ), WP_CONTENT_DIR ) );
+			die( sprintf( esc_html__( 'Please create %s /wp-cache-config.php from wp-super-cache/wp-cache-config-sample.php', 'wp-super-cache' ), esc_attr( WP_CONTENT_DIR ) ) );
 		}
 	}
 }
 
-function wpsupercache_uninstall() {
-	global $wp_cache_config_file, $wp_cache_link, $cache_path;
-	$files = array( $wp_cache_config_file, $wp_cache_link );
-	foreach( $files as $file ) {
-		if ( null !== $file && '' !== $file && file_exists( $file ) ) {
-			unlink( $file );
+function wpsc_remove_advanced_cache() {
+	global $wp_cache_link;
+	if ( file_exists( $wp_cache_link ) ) {
+		$file = file_get_contents( $wp_cache_link );
+		if (
+			strpos( $file, "WP SUPER CACHE 0.8.9.1" ) ||
+			strpos( $file, "WP SUPER CACHE 1.2" )
+		) {
+			unlink( $wp_cache_link );
 		}
 	}
+}
+
+function wpsupercache_uninstall() {
+	global $wp_cache_config_file, $cache_path;
+
+	wpsc_remove_advanced_cache();
+
+	if ( file_exists( $wp_cache_config_file ) ) {
+		unlink( $wp_cache_config_file );
+	}
 
 	wp_cache_remove_index();
 
@@ -157,9 +177,7 @@ if ( is_admin() ) {
 function wpsupercache_deactivate() {
 	global $wp_cache_config_file, $wp_cache_link, $cache_path;
 
-	if ( file_exists( $wp_cache_link ) ) {
-		unlink( $wp_cache_link );
-	}
+	wpsc_remove_advanced_cache();
 
 	if ( ! empty( $cache_path ) ) {
 		prune_super_cache( $cache_path, true );
@@ -202,29 +220,23 @@ register_activation_hook( __FILE__, 'wpsupercache_activate' );
 function wpsupercache_site_admin() {
 	global $wp_version;
 
-	if ( version_compare( "4.8", $wp_version, "<=" ) ) {
+	if ( version_compare( $wp_version, '4.8', '>=' ) ) {
 		return current_user_can( 'setup_network' );
 	}
 
-	if ( function_exists( 'is_super_admin' ) ) {
-		return is_super_admin();
-	} elseif ( function_exists( 'is_site_admin' ) ) {
-		return is_site_admin();
-	} else {
-		return true;
-	}
+	return is_super_admin();
 }
 
 function wp_cache_add_pages() {
-	global $wpmu_version;
-	if ( wpsupercache_site_admin() ) { // in single or MS mode add this menu item too, but only for superadmins in MS mode.
-		add_options_page( 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
+	if ( wpsupercache_site_admin() ) {
+		// In single or MS mode add this menu item too, but only for superadmins in MS mode.
+		add_options_page( 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager' );
 	}
 }
-add_action('admin_menu', 'wp_cache_add_pages');
+add_action( 'admin_menu', 'wp_cache_add_pages' );
 
 function wp_cache_network_pages() {
-	add_submenu_page('settings.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager');
+	add_submenu_page( 'settings.php', 'WP Super Cache', 'WP Super Cache', 'manage_options', 'wpsupercache', 'wp_cache_manager' );
 }
 add_action( 'network_admin_menu', 'wp_cache_network_pages' );
 
@@ -233,17 +245,18 @@ function wp_cache_manager_error_checks() {
 	global $dismiss_htaccess_warning, $dismiss_readable_warning, $dismiss_gc_warning, $wp_cache_shutdown_gc, $is_nginx;
 	global $htaccess_path;
 
-	if ( !wpsupercache_site_admin() )
+	if ( ! wpsupercache_site_admin() ) {
 		return false;
+	}
 
-	if ( version_compare( PHP_VERSION, '5.3.0', '<' ) && ( 1 == ini_get( 'safe_mode' ) || "on" == strtolower( ini_get( 'safe_mode' ) ) ) ) {
-		echo '<div class="notice notice-error"><h4>' . __( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ) . '</h4><p>' .
-			__( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' ) . '<br />';
-
+	if ( PHP_VERSION_ID < 50300 && ( ini_get( 'safe_mode' ) === '1' || strtolower( ini_get( 'safe_mode' ) ) === 'on' ) ) { // @codingStandardsIgnoreLine
+		echo '<div class="notice notice-error"><h4>' . esc_html__( 'Warning! PHP Safe Mode Enabled!', 'wp-super-cache' ) . '</h4>';
+		echo '<p>' . esc_html__( 'You may experience problems running this plugin because SAFE MODE is enabled.', 'wp-super-cache' ) . '<br />';
 
-		if( !ini_get( 'safe_mode_gid' ) ) {
-			echo __( 'Your server is set up to check the owner of PHP scripts before allowing them to read and write files.', 'wp-super-cache' ) . '<br />';
-			printf( __( 'You or an administrator may be able to make it work by changing the group owner of the plugin scripts to match that of the web server user. The group owner of the %s/cache/ directory must also be changed. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details.', 'wp-super-cache' ), WP_CONTENT_DIR );
+		if ( ! ini_get( 'safe_mode_gid' ) ) { // @codingStandardsIgnoreLine
+			esc_html_e( 'Your server is set up to check the owner of PHP scripts before allowing them to read and write files.', 'wp-super-cache' );
+			echo '<br />';
+			printf( __( 'You or an administrator may be able to make it work by changing the group owner of the plugin scripts to match that of the web server user. The group owner of the %s/cache/ directory must also be changed. See the  <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details.', 'wp-super-cache' ), esc_attr( WP_CONTENT_DIR ) );
 		} else {
 			_e( 'You or an administrator must disable this. See the <a href="http://php.net/features.safe-mode">safe mode manual page</a> for further details. This cannot be disabled in a .htaccess file unfortunately. It must be done in the php.ini config file.', 'wp-super-cache' );
 		}
@@ -481,21 +494,23 @@ add_filter( 'wp_super_cache_error_checking', 'wp_cache_manager_error_checks' );
  */
 function admin_bar_delete_page() {
 
-	if ( function_exists( 'current_user_can' ) && false == current_user_can( 'delete_others_posts' ) ) {
+	if ( ! current_user_can( 'delete_others_posts' ) ) {
 		return false;
 	}
 
-	$req_path    = filter_input( INPUT_GET, 'path' );
+	$req_path    = isset( $_GET['path'] ) ? sanitize_text_field( stripslashes( $_GET['path'] ) ) : '';
 	$referer     = wp_get_referer();
 	$valid_nonce = ( $req_path && isset( $_GET['_wpnonce'] ) ) ? wp_verify_nonce( $_GET['_wpnonce'], 'delete-cache' ) : false;
 
 	$path = $valid_nonce ? realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $req_path ) ) ) ) : false;
 
 	if ( $path ) {
-		$path = trailingslashit( $path );
+		$path           = trailingslashit( $path );
 		$supercachepath = realpath( get_supercache_dir() );
 
-		if ( false == wp_cache_confirm_delete( $path ) || substr( $path, 0, strlen( $supercachepath ) ) != $supercachepath ) {
+		if ( false === wp_cache_confirm_delete( $path ) ||
+			0 !== strpos( $path, $supercachepath )
+		) {
 			wp_die( 'Could not delete directory' );
 		}
 
@@ -503,7 +518,7 @@ function admin_bar_delete_page() {
 	}
 
 	if ( $referer && $req_path && ( false !== stripos( $referer, $req_path ) || 0 === stripos( $referer, wp_login_url() ) ) ) {
-		wp_redirect( site_url( preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $req_path ) ) );
+		wp_safe_redirect( esc_url_raw( home_url( $req_path ) ) );
 		exit;
 	}
 }
@@ -512,7 +527,7 @@ if ( 'delcachepage' === filter_input( INPUT_GET, 'action' ) ) {
 }
 
 function wp_cache_manager_updates() {
-	global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_hello_world, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_not_logged_in, $wp_cache_make_known_anon, $cache_path, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $cache_compression, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $cache_page_secret, $wp_cache_disable_utf8, $wp_cache_no_cache_for_get;
+	global $wp_cache_mobile_enabled, $wp_cache_mfunc_enabled, $wp_supercache_cache_list, $wp_cache_config_file, $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_not_logged_in, $wp_cache_make_known_anon, $cache_path, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $cache_compression, $wp_cache_mod_rewrite, $wp_supercache_304, $wp_super_cache_late_init, $wp_cache_front_page_checks, $cache_page_secret, $wp_cache_disable_utf8, $wp_cache_no_cache_for_get;
 	global $cache_schedule_type, $cache_max_time, $cache_time_interval, $wp_cache_shutdown_gc, $wpsc_save_headers;
 
 	if ( !wpsupercache_site_admin() )
@@ -557,7 +572,7 @@ function wp_cache_manager_updates() {
 			wp_clear_scheduled_hook( 'wp_cache_gc' );
 			wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
 		}
-		$advanced_settings = array( 'wp_super_cache_late_init', 'wp_cache_disable_utf8', 'wp_cache_no_cache_for_get', 'wp_supercache_304', 'wp_cache_mfunc_enabled', 'wp_cache_mobile_enabled', 'wp_cache_front_page_checks', 'wp_supercache_cache_list', 'wp_cache_hello_world', 'wp_cache_clear_on_post_edit', 'wp_cache_not_logged_in', 'wp_cache_make_known_anon','wp_cache_object_cache', 'wp_cache_refresh_single_only', 'cache_compression' );
+		$advanced_settings = array( 'wp_super_cache_late_init', 'wp_cache_disable_utf8', 'wp_cache_no_cache_for_get', 'wp_supercache_304', 'wp_cache_mfunc_enabled', 'wp_cache_mobile_enabled', 'wp_cache_front_page_checks', 'wp_supercache_cache_list', 'wp_cache_clear_on_post_edit', 'wp_cache_not_logged_in', 'wp_cache_make_known_anon','wp_cache_object_cache', 'wp_cache_refresh_single_only', 'cache_compression' );
 		foreach( $advanced_settings as $setting ) {
 			if ( isset( $GLOBALS[ $setting ] ) && $GLOBALS[ $setting ] == 1 ) {
 				$_POST[ $setting ] = 1;
@@ -661,13 +676,6 @@ function wp_cache_manager_updates() {
 		}
 		wp_cache_setting( 'wp_cache_mod_rewrite', $wp_cache_mod_rewrite );
 
-		if( isset( $_POST[ 'wp_cache_hello_world' ] ) ) {
-			$wp_cache_hello_world = 1;
-		} else {
-			$wp_cache_hello_world = 0;
-		}
-		wp_cache_replace_line('^ *\$wp_cache_hello_world', '$wp_cache_hello_world = ' . $wp_cache_hello_world . ";", $wp_cache_config_file);
-
 		if( isset( $_POST[ 'wp_cache_clear_on_post_edit' ] ) ) {
 			$wp_cache_clear_on_post_edit = 1;
 		} else {
@@ -760,7 +768,7 @@ if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' )
 	add_action( 'admin_init', 'wp_cache_manager_updates' );
 
 function wp_cache_manager() {
-	global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled, $wp_cache_hello_world;
+	global $wp_cache_config_file, $valid_nonce, $supercachedir, $cache_path, $cache_enabled, $cache_compression, $super_cache_enabled;
 	global $wp_cache_clear_on_post_edit, $cache_rebuild_files, $wp_cache_mutex_disabled, $wp_cache_mobile_enabled, $wp_cache_mobile_browsers, $wp_cache_no_cache_for_get;
 	global $wp_cache_not_logged_in, $wp_cache_make_known_anon, $wp_supercache_cache_list, $cache_page_secret;
 	global $wp_super_cache_front_page_check, $wp_cache_object_cache, $_wp_using_ext_object_cache, $wp_cache_refresh_single_only, $wp_cache_mobile_prefixes;
@@ -849,23 +857,25 @@ table.wpsc-settings-table {
 	echo '<div class="wrap">';
 	echo '<h3>' . __( 'WP Super Cache Settings', 'wp-super-cache' ) . '</h3>';
 
-	// set a default
-	if ( $cache_enabled == false && isset( $wp_cache_mod_rewrite ) == false ) {
+	// Set a default.
+	if ( false === $cache_enabled && ! isset( $wp_cache_mod_rewrite ) ) {
 		$wp_cache_mod_rewrite = 0;
-	} elseif ( !isset( $wp_cache_mod_rewrite ) && $cache_enabled && $super_cache_enabled ) {
+	} elseif ( ! isset( $wp_cache_mod_rewrite ) && $cache_enabled && $super_cache_enabled ) {
 		$wp_cache_mod_rewrite = 1;
 	}
 
-	if ( ! isset( $_GET[ 'tab' ] ) && $cache_enabled && ( $wp_cache_mod_rewrite || $super_cache_enabled == false ) ) {
-		$_GET[ 'tab' ] = 'settings';
-		echo '<div class="notice notice-info is-dismissible"><p>' .  __( 'Notice: <em>Expert mode caching enabled</em>. Showing Advanced Settings Page by default.', 'wp-super-cache' ) . '</p></div>';
-	}
-	if ( ! isset( $_GET[ 'tab' ] ) ) {
-		$_GET[ 'tab' ] = 'easy';
+	$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
+	$curr_tab  = ! empty( $_GET['tab'] ) ? sanitize_text_field( stripslashes( $_GET['tab'] ) ) : ''; // WPCS: sanitization ok.
+	if ( empty( $curr_tab ) ) {
+		$curr_tab = 'easy';
+		if ( $wp_cache_mod_rewrite ) {
+			$curr_tab = 'settings';
+			echo '<div class="notice notice-info is-dismissible"><p>' .  __( 'Notice: <em>Expert mode caching enabled</em>. Showing Advanced Settings Page by default.', 'wp-super-cache' ) . '</p></div>';
+		}
 	}
 
-	if ( $_GET[ 'tab' ] == 'preload' ) {
-		if ( $super_cache_enabled == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
+	if ( 'preload' === $curr_tab ) {
+		if ( true === $super_cache_enabled && ! defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
 			global $wp_cache_preload_interval, $wp_cache_preload_on, $wp_cache_preload_taxonomies, $wp_cache_preload_email_me, $wp_cache_preload_email_volume, $wp_cache_preload_posts, $wpdb;
 			$count = wpsc_post_count();
 			if ( $count > 1000 ) {
@@ -874,31 +884,33 @@ table.wpsc-settings-table {
 				$min_refresh_interval = 30;
 			}
 			$return = wpsc_preload_settings( $min_refresh_interval );
-			$msg = '';
+			$msg    = '';
 			if ( empty( $return ) == false ) {
-				foreach( $return as $message ) {
+				foreach ( $return as $message ) {
 					$msg .= $message;
 				}
 			}
 			$currently_preloading = false;
 
 			$preload_counter = get_option( 'preload_cache_counter' );
-			if ( isset( $preload_counter[ 'first' ] ) ) // converted from int to array
-				update_option( 'preload_cache_counter', array( 'c' => $preload_counter[ 'c' ], 't' => time() ) );
-			if ( is_array( $preload_counter ) && $preload_counter[ 'c' ] > 0 ) {
-				$msg .= '<p>' . sprintf( __( 'Currently caching from post %d to %d.', 'wp-super-cache' ), ( $preload_counter[ 'c' ] - 100 ), $preload_counter[ 'c' ] ) . '</p>';
+			if ( isset( $preload_counter['first'] ) ) { // converted from int to array
+				update_option( 'preload_cache_counter', array( 'c' => $preload_counter['c'], 't' => time() ) );
+			}
+
+			if ( is_array( $preload_counter ) && $preload_counter['c'] > 0 ) {
+				$msg .= '<p>' . sprintf( esc_html__( 'Currently caching from post %d to %d.', 'wp-super-cache' ), ( $preload_counter['c'] - 100 ), $preload_counter['c'] ) . '</p>';
 				$currently_preloading = true;
-				if ( @file_exists( $cache_path . "preload_permalink.txt" ) ) {
-					$url = file_get_contents( $cache_path . "preload_permalink.txt" );
-					$msg .="<p>" . sprintf( __( "<strong>Page last cached:</strong> %s", 'wp-super-cache' ), $url ) . "</p>";
+				if ( @file_exists( $cache_path . 'preload_permalink.txt' ) ) {
+					$url  = file_get_contents( $cache_path . 'preload_permalink.txt' );
+					$msg .= '<p>' . sprintf( __( '<strong>Page last cached:</strong> %s', 'wp-super-cache' ), $url ) . '</p>';
 				}
 				if ( $msg != '' ) {
-					echo '<div class="notice notice-warning"><h4>' . __( 'Preload Active', 'wp-super-cache' ) . '</h4>' . $msg;
-					echo '<form name="do_preload" action="" method="POST">';
+					echo '<div class="notice notice-warning"><h4>' . esc_html__( 'Preload Active', 'wp-super-cache' ) . '</h4>' . $msg;
+					echo '<form name="do_preload" action="' . esc_url_raw( add_query_arg( 'tab', 'preload', $admin_url ) ) . '" method="POST">';
 					echo '<input type="hidden" name="action" value="preload" />';
 					echo '<input type="hidden" name="page" value="wpsupercache" />';
-					echo '<p><input class="button-primary" type="submit" name="preload_off" value="' . __( 'Cancel Cache Preload', 'wp-super-cache' ) . '" /></p>';
-					wp_nonce_field('wp-cache');
+					echo '<p><input class="button-primary" type="submit" name="preload_off" value="' . esc_html__( 'Cancel Cache Preload', 'wp-super-cache' ) . '" /></p>';
+					wp_nonce_field( 'wp-cache' );
 					echo '</form>';
 					echo '</div>';
 				}
@@ -909,60 +921,63 @@ table.wpsc-settings-table {
 		}
 	}
 
+	wpsc_admin_tabs( $curr_tab );
 
-	wpsc_admin_tabs();
-
-	if ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 1 && !wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
-		wp_schedule_single_event( time() + 360 , 'wp_cache_check_site_hook' );
+	if ( isset( $wp_super_cache_front_page_check ) && $wp_super_cache_front_page_check == 1 && ! wp_next_scheduled( 'wp_cache_check_site_hook' ) ) {
+		wp_schedule_single_event( time() + 360, 'wp_cache_check_site_hook' );
 		wp_cache_debug( 'scheduled wp_cache_check_site_hook for 360 seconds time.', 2 );
 	}
 
-	if(isset($_REQUEST['wp_restore_config']) && $valid_nonce) {
-		unlink($wp_cache_config_file);
-		echo '<strong>' . __( 'Configuration file changed, some values might be wrong. Load the page again from the "Settings" menu to reset them.', 'wp-super-cache' ) . '</strong>';
+	if ( isset( $_REQUEST['wp_restore_config'] ) && $valid_nonce ) {
+		unlink( $wp_cache_config_file );
+		echo '<strong>' . esc_html__( 'Configuration file changed, some values might be wrong. Load the page again from the "Settings" menu to reset them.', 'wp-super-cache' ) . '</strong>';
 	}
 
 	if ( substr( get_option( 'permalink_structure' ), -1 ) == '/' ) {
-		wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 1;", $wp_cache_config_file);
+		wp_cache_replace_line( '^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 1;", $wp_cache_config_file );
 	} else {
-		wp_cache_replace_line('^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 0;", $wp_cache_config_file);
+		wp_cache_replace_line( '^ *\$wp_cache_slash_check', "\$wp_cache_slash_check = 0;", $wp_cache_config_file );
 	}
 	$home_path = parse_url( site_url() );
-	$home_path = trailingslashit( array_key_exists( 'path', $home_path ) ? $home_path[ 'path' ] : '' );
-	if (! isset( $wp_cache_home_path ) ) {
+	$home_path = trailingslashit( array_key_exists( 'path', $home_path ) ? $home_path['path'] : '' );
+	if ( ! isset( $wp_cache_home_path ) ) {
 		$wp_cache_home_path = '/';
 		wp_cache_setting( 'wp_cache_home_path', '/' );
 	}
-	if ( "$home_path" != "$wp_cache_home_path" )
+	if ( "$home_path" != "$wp_cache_home_path" ) {
 		wp_cache_setting( 'wp_cache_home_path', $home_path );
+	}
 
-
-	if( $wp_cache_mobile_enabled == 1 ) {
+	if ( $wp_cache_mobile_enabled == 1 ) {
 		update_cached_mobile_ua_list( $wp_cache_mobile_browsers, $wp_cache_mobile_prefixes, $mobile_groups );
 	}
 
-	?> <table class="wpsc-settings-table"><td valign='top'><?php
-	switch( $_GET[ 'tab' ] ) {
-		case "cdn":
-		scossdl_off_options();
-		break;
-		case "tester":
-		case "contents":
-		echo '<a name="test"></a>';
-		wp_cache_files();
-		break;
-		case "preload":
-		if ( !$cache_enabled )
-			wp_die( __( 'Caching must be enabled to use this feature', 'wp-super-cache' ) );
-		echo '<a name="preload"></a>';
+	?>
+	<table class="wpsc-settings-table"><td valign="top">
+	<?php
+
+	switch ( $curr_tab ) {
+		case 'cdn':
+			scossdl_off_options();
+			break;
+		case 'tester':
+		case 'contents':
+			echo '<a name="test"></a>';
+			wp_cache_files();
+			break;
+		case 'preload':
+			if ( ! $cache_enabled ) {
+				wp_die( esc_html__( 'Caching must be enabled to use this feature', 'wp-super-cache' ) );
+			}
+			echo '<a name="preload"></a>';
 		if ( $super_cache_enabled == true && false == defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
 			echo '<p>' . __( 'This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now.', 'wp-super-cache' ) . '</p>';
 			echo '<p>' . __( 'Preloading creates lots of files however. Caching is done from the newest post to the oldest so please consider only caching the newest if you have lots (10,000+) of posts. This is especially important on shared hosting.', 'wp-super-cache' ) . '</p>';
 			echo '<p>' . __( 'In &#8217;Preload Mode&#8217; regular garbage collection will be disabled so that old cache files are not deleted. This is a recommended setting when the cache is preloaded.', 'wp-super-cache' ) . '</p>';
-			echo '<form name="cache_filler" action="" method="POST">';
+			echo '<form name="cache_filler" action="' . esc_url_raw( add_query_arg( 'tab', 'preload', $admin_url ) ) . '" method="POST">';
 			echo '<input type="hidden" name="action" value="preload" />';
 			echo '<input type="hidden" name="page" value="wpsupercache" />';
-			echo '<p>' . sprintf( __( 'Refresh preloaded cache files every %s minutes. (0 to disable, minimum %d minutes.)', 'wp-super-cache' ), "<input type='text' size=4 name='wp_cache_preload_interval' value='" . (int)$wp_cache_preload_interval . "' />", $min_refresh_interval ) . '</p>';
+			echo '<p>' . sprintf( __( 'Refresh preloaded cache files every %s minutes. (0 to disable, minimum %d minutes.)', 'wp-super-cache' ), "<input type='text' size=4 name='wp_cache_preload_interval' value='" . (int) $wp_cache_preload_interval . "' />", $min_refresh_interval ) . '</p>';
 			if ( $count > 100 ) {
 				$step = (int)( $count / 10 );
 
@@ -1014,9 +1029,9 @@ table.wpsc-settings-table {
 			}
 			echo '<div class="submit"><input class="button-primary" type="submit" name="preload" value="' . __( 'Save Settings', 'wp-super-cache' ) . '" />';
 			echo '</div>';
-			wp_nonce_field('wp-cache');
+			wp_nonce_field( 'wp-cache' );
 			echo '</form>';
-			echo '<form name="do_preload" action="" method="POST">';
+			echo '<form name="do_preload" action="' . esc_url_raw( add_query_arg( 'tab', 'preload', $admin_url ) ) . '" method="POST">';
 			echo '<input type="hidden" name="action" value="preload" />';
 			echo '<input type="hidden" name="page" value="wpsupercache" />';
 			echo '<div class="submit">';
@@ -1026,25 +1041,27 @@ table.wpsc-settings-table {
 				echo '<input class="button-primary" type="submit" name="preload_off" value="' . __( 'Cancel Cache Preload', 'wp-super-cache' ) . '" />';
 			}
 			echo '</div>';
-			wp_nonce_field('wp-cache');
+			wp_nonce_field( 'wp-cache' );
 			echo '</form>';
 		} else {
 			echo '<div class="notice notice-warning"><p>' . __( 'Preloading of cache disabled. Please make sure simple or expert mode is enabled or talk to your host administrator.', 'wp-super-cache' ) . '</p></div>';
 		}
-		break;
+			break;
 		case 'plugins':
-		wpsc_plugins_tab();
-		break;
+			wpsc_plugins_tab();
+			break;
 		case 'debug':
-		wp_cache_debug_settings();
-		break;
+			wp_cache_debug_settings();
+			break;
 		case 'settings':
-		if ( isset( $wp_cache_front_page_checks ) == false )
-			$wp_cache_front_page_checks = true;
-		echo '<form name="wp_manager" action="' . esc_url( add_query_arg( array( 'page' => 'wpsupercache', 'tab' => 'settings' ) ) ) . '" method="post">';
-		wp_nonce_field('wp-cache');
-		echo '<input type="hidden" name="action" value="scupdates" />';
-		?><table class="form-table">
+			if ( isset( $wp_cache_front_page_checks ) == false ) {
+				$wp_cache_front_page_checks = true;
+			}
+			echo '<form name="wp_manager" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) ) . '" method="post">';
+			wp_nonce_field( 'wp-cache' );
+			echo '<input type="hidden" name="action" value="scupdates" />';
+			?>
+		<table class="form-table">
 		<tr valign="top">
 			<th scope="row"><label for="wp_cache_enabled"><?php _e( 'Caching', 'wp-super-cache' ); ?></label></th>
 			<td>
@@ -1067,44 +1084,44 @@ table.wpsc-settings-table {
 				</fieldset>
 			</td>
 		</tr>
-		<tr valign="top">
-			<th scope="row"><label for="wp_cache_status"><?php _e( 'Miscellaneous', 'wp-super-cache' ); ?></label></th>
-			<td>
-				<fieldset>
-				<legend class="hidden">Miscellaneous</legend>
-				<label><input type='checkbox' name='wp_cache_not_logged_in' <?php if ( $wp_cache_not_logged_in ) echo "checked"; ?> value='1'> <?php _e( 'Don&#8217;t cache pages for <acronym title="Logged in users and those that comment">known users</acronym>.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br />
-				<label><input type='checkbox' name='wp_cache_no_cache_for_get' <?php if( $wp_cache_no_cache_for_get ) echo "checked"; ?> value='1'> <?php _e( 'Don&#8217;t cache pages with GET parameters. (?x=y at the end of a url)', 'wp-super-cache' ); ?></label><br />
-				<?php if ( false == defined( 'WPSC_DISABLE_COMPRESSION' ) ) { ?>
-					<?php if ( false == function_exists( 'gzencode' ) ) { ?>
-						<em><?php _e( 'Warning! Compression is disabled as gzencode() function was not found.', 'wp-super-cache' ); ?></em><br />
-					<?php } else { ?>
-						<label><input type='checkbox' name='cache_compression' <?php if( $cache_compression ) echo "checked"; ?> value='1'> <?php _e( 'Compress pages so they&#8217;re served more quickly to visitors.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br />
-						<em><?php _e( 'Compression is disabled by default because some hosts have problems with compressed files. Switching it on and off clears the cache.', 'wp-super-cache' ); ?></em><br />
-					<?php }
-				}
-				?>
-				<label><input type='checkbox' name='wpsc_save_headers' <?php if ( $wpsc_save_headers ) echo "checked"; ?> value='1' /> <?php _e( 'Cache HTTP headers with page content.', 'wp-super-cache' ); ?></label><br />
-				<label><input type='checkbox' name='cache_rebuild_files' <?php if ( $cache_rebuild_files ) echo "checked"; ?> value='1'> <?php _e( 'Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br />
+			<tr valign="top">
+				<th scope="row"><label for="wp_cache_status"><?php esc_html_e( 'Miscellaneous', 'wp-super-cache' ); ?></label></th>
+				<td>
+					<fieldset>
+					<legend class="hidden">Miscellaneous</legend>
+					<label><input type='checkbox' name='wp_cache_not_logged_in' <?php checked( $wp_cache_not_logged_in ); ?> value='1'> <?php echo __( 'Don&#8217;t cache pages for <acronym title="Logged in users and those that comment">known users</acronym>.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
+					<label><input type='checkbox' name='wp_cache_no_cache_for_get' <?php checked( $wp_cache_no_cache_for_get ); ?> value='1'> <?php _e( 'Don&#8217;t cache pages with GET parameters. (?x=y at the end of a url)', 'wp-super-cache' ); ?></label><br />
+					<?php if ( ! defined( 'WPSC_DISABLE_COMPRESSION' ) ) : ?>
+						<?php if ( ! function_exists( 'gzencode' ) ) : ?>
+							<em><?php esc_html_e( 'Warning! Compression is disabled as gzencode() function was not found.', 'wp-super-cache' ); ?></em><br />
+						<?php else : ?>
+							<label><input type='checkbox' name='cache_compression' <?php checked( $cache_compression ); ?> value='1'> <?php echo __( 'Compress pages so they&#8217;re served more quickly to visitors.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
+							<em><?php esc_html_e( 'Compression is disabled by default because some hosts have problems with compressed files. Switching it on and off clears the cache.', 'wp-super-cache' ); ?></em><br />
+						<?php endif; ?>
+					<?php endif; ?>
+					<label><input type='checkbox' name='wpsc_save_headers' <?php checked( $wpsc_save_headers ); ?> value='1' /> <?php esc_html_e( 'Cache HTTP headers with page content.', 'wp-super-cache' ); ?></label><br />
+					<label><input type='checkbox' name='cache_rebuild_files' <?php checked( $cache_rebuild_files ); ?> value='1'> <?php echo esc_html__( 'Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
 				<?php
 				$disable_304 = true;
 				if ( 0 == $wp_cache_mod_rewrite )
 					$disable_304 = false;
 				if ( $disable_304 )
 					echo "<strike>";
-				?><label><input <?php if ( $disable_304 ) { echo "disabled"; } ?> type='checkbox' name='wp_supercache_304' <?php if( $wp_supercache_304 ) echo "checked"; ?> value='1'> <?php _e( '304 Not Modified browser caching. Indicate when a page has not been modified since it was last requested.', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br /><?php
-				if ( $disable_304 ) {
-					echo "</strike>";
-					echo "<p><strong>" . __( 'Warning! 304 browser caching is only supported when mod_rewrite caching is not used.', 'wp-super-cache' ) . "</strong></p>";
-				} else {
-					?><em><?php _e( '304 support is disabled by default because some hosts have had problems with the headers used in the past.', 'wp-super-cache' ); ?></em><br /><?php
-				}
-				?>
-				<label><input type='checkbox' name='wp_cache_make_known_anon' <?php if( $wp_cache_make_known_anon ) echo "checked"; ?> value='1'> <?php _e( 'Make known users anonymous so they&#8217;re served supercached static files.', 'wp-super-cache' ); ?></label><br />
-				<label><input type='checkbox' name='wp_cache_hello_world' <?php if( $wp_cache_hello_world ) echo "checked"; ?> value='1'> <?php printf( __( 'Proudly tell the world your server is <a href="%s">Stephen Fry proof</a>! (places a message in your blog&#8217;s footer)', 'wp-super-cache' ), 'https://twitter.com/#!/HibbsLupusTrust/statuses/136429993059291136' ); ?></label><br />
-				</legend>
-				</fieldset>
-			</td>
-		</tr>
+					?>
+					<label><input <?php disabled( $disable_304 ); ?> type='checkbox' name='wp_supercache_304' <?php checked( $wp_supercache_304 ); ?> value='1'> <?php echo esc_html__( '304 Not Modified browser caching. Indicate when a page has not been modified since it was last requested.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
+					<?php
+					if ( $disable_304 ) {
+						echo '</strike>';
+						echo '<p><strong>' . esc_html__( 'Warning! 304 browser caching is only supported when mod_rewrite caching is not used.', 'wp-super-cache' ) . '</strong></p>';
+					} else {
+						echo '<em>' . esc_html__( '304 support is disabled by default because some hosts have had problems with the headers used in the past.', 'wp-super-cache' ) . '</em><br />';
+					}
+					?>
+					<label><input type='checkbox' name='wp_cache_make_known_anon' <?php checked( $wp_cache_make_known_anon ); ?> value='1'> <?php _e( 'Make known users anonymous so they&#8217;re served supercached static files.', 'wp-super-cache' ); ?></label><br />
+					</legend>
+					</fieldset>
+				</td>
+			</tr>
 		<tr valign="top">
 			<th scope="row"><label for="wp_cache_status"><?php _e( 'Advanced', 'wp-super-cache' ); ?></label></th>
 			<td>
@@ -1162,85 +1179,90 @@ table.wpsc-settings-table {
 			</td>
 		</tr>
 		</table>
-		<h4><?php _e( 'Note:', 'wp-super-cache' ); ?></h4>
-		<ol>
-		<li><?php _e( 'Uninstall this plugin on the plugins page. It will automatically clean up after itself. If manual intervention is required, then simple instructions are provided.', 'wp-super-cache' ); ?></li>
-		<li><?php printf( __( 'If uninstalling this plugin, make sure the directory <em>%s</em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable is probably a good idea!)', 'wp-super-cache' ), WP_CONTENT_DIR ); ?></li>
-		<li><?php printf( __( 'Please see the <a href="%1$s/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script. Look for the heading, "How to uninstall WP Super Cache".', 'wp-super-cache' ), plugins_url() ); ?></li><?php
-		echo "<li><em>" . sprintf( __( 'Need help? Check the <a href="%1$s">Super Cache readme file</a>. It includes installation documentation, a FAQ and Troubleshooting tips. The <a href="%2$s">support forum</a> is also available. Your question may already have been answered.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-super-cache/', 'https://wordpress.org/support/topic-tag/wp-super-cache/?forum_id=10' ) . "</em></li>";
-		echo "</ol>";
+			<h4><?php esc_html_e( 'Note:', 'wp-super-cache' ); ?></h4>
+			<ol>
+				<li><?php esc_html_e( 'Uninstall this plugin on the plugins page. It will automatically clean up after itself. If manual intervention is required, then simple instructions are provided.', 'wp-super-cache' ); ?></li>
+				<li><?php printf( __( 'If uninstalling this plugin, make sure the directory <em>%s</em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable is probably a good idea!)', 'wp-super-cache' ), esc_attr( WP_CONTENT_DIR ) ); ?></li>
+				<li><?php printf( __( 'Please see the <a href="%1$s/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script. Look for the heading, "How to uninstall WP Super Cache".', 'wp-super-cache' ), plugins_url() ); ?></li>
+				<li><?php echo '<em>' . sprintf( __( 'Need help? Check the <a href="%1$s">Super Cache readme file</a>. It includes installation documentation, a FAQ and Troubleshooting tips. The <a href="%2$s">support forum</a> is also available. Your question may already have been answered.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-super-cache/', 'https://wordpress.org/support/topic-tag/wp-super-cache/?forum_id=10' ) . '</em>'; ?></li>
+			</ol>
 
-		echo "<div class='submit'><input class='button-primary' type='submit' " . SUBMITDISABLED . " value='" . __( 'Update Status', 'wp-super-cache' ) . "' /></div>";
-		wp_nonce_field('wp-cache');
-		?> </form> <?php
-		wsc_mod_rewrite();
+			<?php
+			echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_html__( 'Update Status', 'wp-super-cache' ) . '" /></div>';
+			wp_nonce_field( 'wp-cache' );
+
+			?></form><?php
+
+			wsc_mod_rewrite();
 
-		wp_cache_edit_max_time();
+			wp_cache_edit_max_time();
 
-		echo '<a name="files"></a><fieldset class="options"><h4>' . __( 'Accepted Filenames &amp; Rejected URIs', 'wp-super-cache' ) . '</h4>';
-		wp_cache_edit_rejected_pages();
-		echo "\n";
-		wp_cache_edit_rejected();
-		echo "\n";
-		wp_cache_edit_accepted();
-		echo '</fieldset>';
+			echo '<a name="files"></a><fieldset class="options"><h4>' . __( 'Accepted Filenames &amp; Rejected URIs', 'wp-super-cache' ) . '</h4>';
+			wp_cache_edit_rejected_pages();
+			echo "\n";
+			wp_cache_edit_rejected();
+			echo "\n";
+			wp_cache_edit_accepted();
+			echo '</fieldset>';
 
-		wp_cache_edit_rejected_ua();
+			wp_cache_edit_rejected_ua();
 
-		wp_lock_down();
+			wp_lock_down();
 
-		wp_cache_restore();
+			wp_cache_restore();
 
-		break;
-		case "easy":
+			break;
+		case 'easy':
 		default:
-			echo '<form name="wp_manager" action="" method="post">';
+			echo '<form name="wp_manager" action="' . esc_url_raw( add_query_arg( 'tab', 'easy', $admin_url ) ) . '" method="post">';
 			echo '<input type="hidden" name="action" value="easysetup" />';
-			wp_nonce_field('wp-cache');
-			?><table class="form-table">
+			wp_nonce_field( 'wp-cache' );
+			?>
+			<table class="form-table">
 				<tr valign="top">
-				<th scope="row"><label for="wp_cache_status"><?php _e( 'Caching', 'wp-super-cache' ); ?></label></th>
+				<th scope="row"><label for="wp_cache_status"><?php esc_html_e( 'Caching', 'wp-super-cache' ); ?></label></th>
 				<td>
 				<fieldset>
-				<label><input type='radio' name='wp_cache_easy_on' value='1' <?php if ( $cache_enabled == true ) { echo 'checked=checked'; } ?>> <?php _e( 'Caching On', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br />
-				<label><input type='radio' name='wp_cache_easy_on' value='0' <?php if ( $cache_enabled == false ) { echo 'checked=checked'; } ?>> <?php _e( 'Caching Off', 'wp-super-cache' ); ?></label><br />
+				<label><input type='radio' name='wp_cache_easy_on' value='1' <?php checked( $cache_enabled ); ?> ><?php echo esc_html__( 'Caching On', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
+				<label><input type='radio' name='wp_cache_easy_on' value='0' <?php checked( ! $cache_enabled ); ?> ><?php esc_html_e( 'Caching Off', 'wp-super-cache' ); ?></label><br />
 				</fieldset>
 				</td>
 				</tr>
-				</table>
+			</table>
 			<?php
-			if ( ! $is_nginx && $cache_enabled && !$wp_cache_mod_rewrite ) {
+			if ( ! $is_nginx && $cache_enabled && ! $wp_cache_mod_rewrite ) {
 				$scrules = trim( implode( "\n", extract_from_markers( trailingslashit( get_home_path() ) . '.htaccess', 'WPSuperCache' ) ) );
-				if ( $scrules != '' ) {
-					echo "<p><strong>" . __( 'Notice: Simple caching enabled but Supercache mod_rewrite rules from expert mode detected. Cached files will be served using those rules. If your site is working ok, please ignore this message. Otherwise, you can edit the .htaccess file in the root of your install and remove the SuperCache rules.', 'wp-super-cache' ) . '</strong></p>';
+				if ( ! empty( $scrules ) ) {
+					echo '<p><strong>' . esc_html__( 'Notice: Simple caching enabled but Supercache mod_rewrite rules from expert mode detected. Cached files will be served using those rules. If your site is working ok, please ignore this message. Otherwise, you can edit the .htaccess file in the root of your install and remove the SuperCache rules.', 'wp-super-cache' ) . '</strong></p>';
 				}
 			}
-			echo "<div class='submit'><input class='button-primary' type='submit' " . SUBMITDISABLED . " value='" . __( 'Update Status', 'wp-super-cache' ) . "' /></div></form>";
+			echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_html__( 'Update Status', 'wp-super-cache' ) . '" /></div></form>';
 			if ( $cache_enabled ) {
-				echo "<h4>" . __( 'Cache Tester', 'wp-super-cache' ) . "</h4>";
-				echo '<p>' . __( 'Test your cached website by clicking the test button below.', 'wp-super-cache' ) . '</p>';
+				echo '<h4>' . esc_html__( 'Cache Tester', 'wp-super-cache' ) . '</h4>';
+				echo '<p>' . esc_html__( 'Test your cached website by clicking the test button below.', 'wp-super-cache' ) . '</p>';
 				echo '<p>' . __( 'Note: if you use Cloudflare or other transparent front-end proxy service this test may fail.<ol><li> If you have Cloudflare minification enabled this plugin may detect differences in the pages and report an error.</li><li> Try using the development mode of Cloudflare to perform the test. You can disable development mode afterwards if the test succeeds.</li></ol>', 'wp-super-cache' ) . '</p>';
-				if ( array_key_exists('action', $_POST) && $_POST[ 'action' ] == 'test' && $valid_nonce ) {
+				if ( array_key_exists( 'action', $_POST ) && 'test' === $_POST['action'] && $valid_nonce ) {
 					$url = trailingslashit( get_bloginfo( 'url' ) );
-					if ( isset( $_POST[ 'httponly' ] ) )
+					if ( isset( $_POST['httponly'] ) ) {
 						$url = str_replace( 'https://', 'http://', $url );
-					$test_messages = array( __( 'Fetching %s to prime cache: ', 'wp-super-cache' ), __( 'Fetching first copy of %s: ', 'wp-super-cache' ), __( 'Fetching second copy of %s: ', 'wp-super-cache' ) );
-					$c = 0;
+					}
+					$test_messages    = array( esc_html__( 'Fetching %s to prime cache: ', 'wp-super-cache' ), esc_html__( 'Fetching first copy of %s: ', 'wp-super-cache' ), esc_html__( 'Fetching second copy of %s: ', 'wp-super-cache' ) );
+					$c                = 0;
 					$cache_test_error = false;
-					$page = array();
-					foreach( $test_messages as $message ) {
-						echo "<p>" . sprintf( $message, $url );
-						$page[ $c ] = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) );
-						if ( !is_wp_error( $page[ $c ] ) ) {
-							$fp = fopen( $cache_path . $c . ".html", "w" );
-							fwrite( $fp, $page[ $c ][ 'body' ] );
+					$page             = array();
+					foreach ( $test_messages as $message ) {
+						echo '<p>' . sprintf( $message, $url );
+						$page[ $c ] = wp_remote_get( $url, array( 'timeout' => 60, 'blocking' => true ) );
+						if ( ! is_wp_error( $page[ $c ] ) ) {
+							$fp = fopen( $cache_path . $c . '.html', 'w' );
+							fwrite( $fp, $page[ $c ]['body'] );
 							fclose( $fp );
-							echo '<span style="color: #0a0; font-weight: bold;">' . __( 'OK', 'wp-super-cache' ) . "</span> (<a href='" . WP_CONTENT_URL . "/cache/" . $c . ".html'>" . $c . ".html</a>)</p>";
+							echo '<span style="color: #0a0; font-weight: bold;">' . esc_html__( 'OK', 'wp-super-cache' ) . "</span> (<a href='" . esc_url_raw( WP_CONTENT_URL . '/cache/' . $c . '.html' ) . "'>" . $c . '.html</a>)</p>';
 							sleep( 1 );
 						} else {
 							$cache_test_error = true;
-							echo '<span style="color: #a00; font-weight: bold;">' . __( 'FAILED', 'wp-super-cache' ) . "</span></p>";
-							$errors = '';
+							echo '<span style="color: #a00; font-weight: bold;">' . esc_html__( 'FAILED', 'wp-super-cache' ) . '</span></p>';
+							$errors   = '';
 							$messages = '';
 							foreach ( $page[ $c ]->get_error_codes() as $code ) {
 								$severity = $page[ $c ]->get_error_data( $code );
@@ -1248,64 +1270,67 @@ table.wpsc-settings-table {
 									$errors .= $severity . ': ' . $err . "<br />\n";
 								}
 							}
-							if ( '' != $errors )
-								echo "<p>" . sprintf( __( '<strong>Errors:</strong> %s', 'wp-super-cache' ), $errors ) . "</p>";
+							if ( ! empty( $errors ) ) {
+								echo '<p>' . sprintf( __( '<strong>Errors:</strong> %s', 'wp-super-cache' ), $errors ) . '</p>';
+							}
 						}
 						$c ++;
 					}
 
 					if ( false == $cache_test_error ) {
-						echo '<ul><li>' . sprintf( __( 'Page %d: %d (%s)', 'wp-super-cache' ), 1, $page[ 1 ][ 'response' ][ 'code' ], $page[ 1 ][ 'response' ][ 'message' ] ) . '</li>';
-						echo '<li>' . sprintf( __( 'Page %d: %d (%s)', 'wp-super-cache' ), 2, $page[ 2 ][ 'response' ][ 'code' ], $page[ 2 ][ 'response' ][ 'message' ] ) . '</li></ul>';
+						echo '<ul><li>' . sprintf( esc_html__( 'Page %d: %d (%s)', 'wp-super-cache' ), 1, intval( $page[1]['response']['code'] ), esc_attr( $page[1]['response']['message'] ) ) . '</li>';
+						echo '<li>' . sprintf( esc_html__( 'Page %d: %d (%s)', 'wp-super-cache' ), 2, intval( $page[2]['response']['code'] ), esc_attr( $page[2]['response']['message'] ) ) . '</li></ul>';
 					}
 
-					if ( false == $cache_test_error && preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[ 1 ][ 'body' ], $matches1 ) &&
-							preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[ 2 ][ 'body' ], $matches2 ) && $matches1[2] == $matches2[2] ) {
-						echo '<p>' . sprintf( __( 'Page 1: %s', 'wp-super-cache' ), $matches1[ 2 ] ) . '</p>';
-						echo '<p>' . sprintf( __( 'Page 2: %s', 'wp-super-cache' ), $matches2[ 2 ] ) . '</p>';
-						echo '<p><span style="color: #0a0; font-weight: bold;">' . __( 'The timestamps on both pages match!', 'wp-super-cache' ) . '</span></p>';
+					if ( false == $cache_test_error && preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[1]['body'], $matches1 ) &&
+							preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[2]['body'], $matches2 ) && $matches1[2] == $matches2[2]
+					) {
+						echo '<p>' . sprintf( esc_html__( 'Page 1: %s', 'wp-super-cache' ), $matches1[2] ) . '</p>';
+						echo '<p>' . sprintf( esc_html__( 'Page 2: %s', 'wp-super-cache' ), $matches2[2] ) . '</p>';
+						echo '<p><span style="color: #0a0; font-weight: bold;">' . esc_html__( 'The timestamps on both pages match!', 'wp-super-cache' ) . '</span></p>';
 					} else {
-						echo '<p><strong>' . __( 'The pages do not match! Timestamps differ or were not found!', 'wp-super-cache' ) . '</strong></p>';
-						echo '<p>' . __( 'Things you can do:', 'wp-super-cache' ) . '</p>';
-						echo '<ol><li>' . __( 'Load your homepage in a logged out browser, check the timestamp at the end of the html source. Load the page again and compare the timestamp. Caching is working if the timestamps match.', 'wp-super-cache' ) . '</li>';
-						echo '<li>' . __( 'Enable logging on the Debug page here. That should help you track down the problem.', 'wp-super-cache' ) . '</li>';
-						echo '<li>' . __( 'You should check Page 1 and Page 2 above for errors. Your local server configuration may not allow your website to access itself.', 'wp-super-cache' ) . '</li>';
-						echo "</ol>";
+						echo '<p><strong>' . esc_html__( 'The pages do not match! Timestamps differ or were not found!', 'wp-super-cache' ) . '</strong></p>';
+						echo '<p>' . esc_html__( 'Things you can do:', 'wp-super-cache' ) . '</p>';
+						echo '<ol><li>' . esc_html__( 'Load your homepage in a logged out browser, check the timestamp at the end of the html source. Load the page again and compare the timestamp. Caching is working if the timestamps match.', 'wp-super-cache' ) . '</li>';
+						echo '<li>' . esc_html__( 'Enable logging on the Debug page here. That should help you track down the problem.', 'wp-super-cache' ) . '</li>';
+						echo '<li>' . esc_html__( 'You should check Page 1 and Page 2 above for errors. Your local server configuration may not allow your website to access itself.', 'wp-super-cache' ) . '</li>';
+						echo '</ol>';
 					}
 				}
-				echo '<form name="cache_tester" action="" method="post">';
+				echo '<form name="cache_tester" action="' . esc_url_raw( add_query_arg( 'tab', 'easy', $admin_url ) ) . '" method="post">';
 				echo '<input type="hidden" name="action" value="test" />';
-				if ( isset( $_SERVER['HTTPS' ] ) && 'on' == strtolower( $_SERVER['HTTPS' ] ) )
-					echo "<input type='checkbox' name='httponly' checked='checked' value='1' /> " . __( 'Send non-secure (non https) request for homepage', 'wp-super-cache' );
+				if ( ! empty( $_SERVER['HTTPS'] ) && 'on' === strtolower( $_SERVER['HTTPS'] ) ) {
+					echo '<input type="checkbox" name="httponly" checked="checked" value="1" /> ' . esc_html__( 'Send non-secure (non https) request for homepage', 'wp-super-cache' );
+				}
 
 				if ( isset( $wp_super_cache_comments ) && $wp_super_cache_comments == 0 ) {
-					echo "<p>" . __( '<strong>Warning!</strong> Cache comments are currently disabled. Please go to the Debug page and enable Cache Status Messages there. You should clear the cache before testing.', 'wp-super-cache' ) . "</p>";
-					echo '<div class="submit"><input disabled style="color: #aaa" class="button-secondary" type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
+					echo '<p>' . __( '<strong>Warning!</strong> Cache comments are currently disabled. Please go to the Debug page and enable Cache Status Messages there. You should clear the cache before testing.', 'wp-super-cache' ) . '</p>';
+					echo '<div class="submit"><input disabled style="color: #aaa" class="button-secondary" type="submit" name="test" value="' . esc_html__( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
 				} else {
 					echo '<div class="submit"><input class="button-secondary" type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
 				}
 
-				wp_nonce_field('wp-cache');
+				wp_nonce_field( 'wp-cache' );
 				echo '</form>';
 			}
-			echo "<h4>" . __( "Delete Cached Pages", 'wp-super-cache' ) . "</h4>";
-			echo "<p>" . __( "Cached pages are stored on your server as html and PHP files. If you need to delete them, use the button below.", 'wp-super-cache' ) . "</p>";
-			echo '<form name="wp_cache_content_delete" action="?page=wpsupercache&tab=contents" method="post">';
+			echo '<h4>' . esc_html__( 'Delete Cached Pages', 'wp-super-cache' ) . '</h4>';
+			echo '<p>' . esc_html__( 'Cached pages are stored on your server as html and PHP files. If you need to delete them, use the button below.', 'wp-super-cache' ) . '</p>';
+			echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) ) . '" method="post">';
 			echo '<input type="hidden" name="wp_delete_cache" />';
-			echo '<div class="submit"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache', 'wp-super-cache' ) . ' " /></div>';
-			wp_nonce_field('wp-cache');
+			echo '<div class="submit"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . esc_html__( 'Delete Cache', 'wp-super-cache' ) . ' " /></div>';
+			wp_nonce_field( 'wp-cache' );
 			echo "</form>\n";
 
-			if ( ( defined( 'VHOST' ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'SUNRISE' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true  ) ) && wpsupercache_site_admin() ) {
-				echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
+			if ( is_multisite() && wpsupercache_site_admin() ) {
+				echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
 				echo '<input type="hidden" name="wp_delete_all_cache" />';
-				echo '<div class="submit"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" /></div>';
-				wp_nonce_field('wp-cache');
+				echo '<div class="submit"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . esc_html__( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" /></div>';
+				wp_nonce_field( 'wp-cache' );
 				echo "</form><br />\n";
 			}
 			?>
-			<h4 class="clear"><?php _e( 'Recommended Links and Plugins', 'wp-super-cache' ); ?></h4>
-			<p><?php _e( 'Caching is only one part of making a website faster. Here are some other plugins that will help:', 'wp-super-cache' ); ?></p>
+			<h4 class="clear"><?php esc_html_e( 'Recommended Links and Plugins', 'wp-super-cache' ); ?></h4>
+			<p><?php esc_html_e( 'Caching is only one part of making a website faster. Here are some other plugins that will help:', 'wp-super-cache' ); ?></p>
 			<ul style="list-style: square; margin-left: 2em;">
 			<li><?php printf( __( '<a href="%s">Jetpack</a> provides everything you need to build a successful WordPress website including an image/photo CDN (free) and a video hosting service (paid).', 'wp-super-cache' ), 'https://jetpack.com/redirect/?source=jitm-wpsc-recommended' ); ?></li>
 			<li><?php printf( __( '<a href="%s">Yahoo! Yslow</a> analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages. Also try the performance tools online at <a href="%s">GTMetrix</a>.', 'wp-super-cache' ), 'http://yslow.org/', 'https://gtmetrix.com/' ); ?></li>
@@ -1313,12 +1338,12 @@ table.wpsc-settings-table {
 			<li><?php printf( __( '<strong>Advanced users only:</strong> Install an object cache. Choose from <a href="%s">Memcached</a>, <a href="%s">XCache</a>, <a href="%s">eAcccelerator</a> and others.', 'wp-super-cache' ), 'https://wordpress.org/plugins/memcached/', 'https://neosmart.net/WP/XCache/', 'https://neosmart.net/WP/eAccelerator/' ); ?></li>
 			<li><?php printf( __( '<a href="%s">WP Crontrol</a> is a useful plugin to use when trying to debug garbage collection and preload problems.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-crontrol/' ); ?></li>
 			</ul>
-
 			<?php
-		break;
-	}
 
+			break;
+	}
 	?>
+
 	</fieldset>
 	</td><td valign='top' style='width: 300px'>
 	<div style='background: #ffc; border: 1px solid #333; margin: 2px; padding: 3px 15px'>
@@ -1334,25 +1359,26 @@ table.wpsc-settings-table {
 	<li><?php printf( __( 'Visit the <a href="%1$s">plugin homepage</a>.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-super-cache/' ); ?></li>
 	<li><?php printf( __( 'Try out the <a href="%1$s">development version</a> for the latest fixes (<a href="%2$s">changelog</a>).', 'wp-super-cache' ), 'https://odd.blog/y/2o', 'https://plugins.trac.wordpress.org/log/wp-super-cache/' ); ?></li>
 	</ol>
-	<h4><?php _e( 'Rate This Plugin', 'wp-super-cache' ); ?></h4>
+	<h4><?php esc_html_e( 'Rate This Plugin', 'wp-super-cache' ); ?></h4>
 	<p><?php printf( __( 'Please <a href="%s">rate us</a> and give feedback.', 'wp-super-cache' ), 'https://wordpress.org/support/plugin/wp-super-cache/reviews?rate=5#new-post' ); ?></p>
 
 	<?php
 	if ( isset( $wp_supercache_cache_list ) && $wp_supercache_cache_list ) {
 		$start_date = get_option( 'wpsupercache_start' );
-		if ( !$start_date ) {
+		if ( ! $start_date ) {
 			$start_date = time();
 		}
 		?>
 		<p><?php printf( __( 'Cached pages since %1$s : <strong>%2$s</strong>', 'wp-super-cache' ), date( 'M j, Y', $start_date ), number_format( get_option( 'wpsupercache_count' ) ) ); ?></p>
 		<p><?php _e( 'Newest Cached Pages:', 'wp-super-cache' ); ?><ol>
-		<?php
-		foreach( array_reverse( (array)get_option( 'supercache_last_cached' ) ) as $url ) {
-			$since = time() - strtotime( $url[ 'date' ] );
-			echo "<li><a title='" . sprintf( __( 'Cached %s seconds ago', 'wp-super-cache' ), $since ) . "' href='" . site_url( $url[ 'url' ] ) . "'>" . substr( $url[ 'url' ], 0, 20 ) . "</a></li>\n";
-		}
-		?></ol>
-		<small><?php _e( '(may not always be accurate on busy sites)', 'wp-super-cache' ); ?></small>
+			<?php
+			foreach ( array_reverse( (array) get_option( 'supercache_last_cached' ) ) as $url ) {
+				$since = time() - strtotime( $url['date'] );
+				echo "<li><a title='" . sprintf( esc_html__( 'Cached %s seconds ago', 'wp-super-cache' ), (int) $since ) . "' href='" . site_url( $url['url'] ) . "'>" . substr( $url['url'], 0, 20 ) . "</a></li>\n";
+			}
+			?>
+			</ol>
+			<small><?php esc_html_e( '(may not always be accurate on busy sites)', 'wp-super-cache' ); ?></small>
 		</p><?php
 	} elseif ( false == get_option( 'wpsupercache_start' ) ) {
 			update_option( 'wpsupercache_start', time() );
@@ -1368,51 +1394,55 @@ table.wpsc-settings-table {
 }
 
 function wpsc_plugins_tab() {
-	echo '<p>' . __( 'Cache plugins are PHP scripts you\'ll find in a dedicated folder inside the WP Super Cache folder (wp-super-cache/plugins/). They load at the same time as WP Super Cache, and before regular WordPress plugins.', 'wp-super-cache' ) . '</p>';
-	echo '<p>' . __( 'Keep in mind that cache plugins are for advanced users only. To create and manage them, you\'ll need extensive knowledge of both PHP and WordPress actions.', 'wp-super-cache' ) . '</p>';
+	echo '<p>' . esc_html__( 'Cache plugins are PHP scripts you\'ll find in a dedicated folder inside the WP Super Cache folder (wp-super-cache/plugins/). They load at the same time as WP Super Cache, and before regular WordPress plugins.', 'wp-super-cache' ) . '</p>';
+	echo '<p>' . esc_html__( 'Keep in mind that cache plugins are for advanced users only. To create and manage them, you\'ll need extensive knowledge of both PHP and WordPress actions.', 'wp-super-cache' ) . '</p>';
 	echo '<p>' . sprintf( __( '<strong>Warning</strong>! Due to the way WordPress upgrades plugins, the ones you upload to the WP Super Cache folder (wp-super-cache/plugins/) will be deleted when you upgrade WP Super Cache. To avoid this loss, load your cache plugins from a different location. When you set <strong>$wp_cache_plugins_dir</strong> to the new location in wp-config.php, WP Super Cache will look there instead. <br />You can find additional details in the <a href="%s">developer documentation</a>.', 'wp-super-cache' ), 'https://odd.blog/wp-super-cache-developers/' ) . '</p>';
 	ob_start();
-	if( defined( 'WP_CACHE' ) ) {
-		if( function_exists( 'do_cacheaction' ) ) {
+	if ( defined( 'WP_CACHE' ) ) {
+		if ( function_exists( 'do_cacheaction' ) ) {
 			do_cacheaction( 'cache_admin_page' );
 		}
 	}
 	$out = ob_get_contents();
 	ob_end_clean();
-	if( SUBMITDISABLED == ' ' && $out != '' ) {
-		echo '<h4>' . __( 'Available Plugins', 'wp-super-cache' ) . '</h4>';
-		echo "<ol>";
+
+	if ( SUBMITDISABLED == ' ' && $out != '' ) {
+		echo '<h4>' . esc_html__( 'Available Plugins', 'wp-super-cache' ) . '</h4>';
+		echo '<ol>';
 		echo $out;
-		echo "</ol>";
+		echo '</ol>';
 	}
-
 }
 
-function wpsc_admin_tabs( $current = 0 ) {
-	global $wp_db_version;
-	if ( $current == 0 ) {
-		if ( isset( $_GET[ 'tab' ] ) ) {
-			$current = $_GET[ 'tab' ];
-		} else {
-			$current = 'easy';
-		}
-	}
-	$tabs = array( 'easy' => __( 'Easy', 'wp-super-cache' ), 'settings' => __( 'Advanced', 'wp-super-cache' ), 'cdn' => __( 'CDN', 'wp-super-cache' ), 'contents' => __( 'Contents', 'wp-super-cache' ), 'preload' => __( 'Preload', 'wp-super-cache' ), 'plugins' => __( 'Plugins', 'wp-super-cache' ), 'debug' => __( 'Debug', 'wp-super-cache' ) );
-	$links = array();
-	foreach( $tabs as $tab => $name ) {
-		if ( $current == $tab ) {
-			$links[] = "<a class='nav-tab nav-tab-active' href='?page=wpsupercache&tab=$tab'>$name</a>";
-		} else {
-			$links[] = "<a class='nav-tab' href='?page=wpsupercache&tab=$tab'>$name</a>";
-		}
+function wpsc_admin_tabs( $current = '' ) {
+	global $cache_enabled, $super_cache_enabled, $wp_cache_mod_rewrite;
+
+	if ( '' === $current ) {
+		$current = ! empty( $_GET['tab'] ) ? stripslashes( $_GET['tab'] ) : ''; // WPCS: CSRF ok, sanitization ok.
 	}
-	if ( $wp_db_version >= 15477 ) {
-		echo '<div id="nav"><h3 class="themes-php">';
-		echo implode( "", $links );
-		echo '</div></h3>';
-	} else {
-		echo implode( " | ", $links );
+
+	$admin_url  = admin_url( 'options-general.php?page=wpsupercache' );
+	$admin_tabs = array(
+		'easy'     => __( 'Easy', 'wp-super-cache' ),
+		'settings' => __( 'Advanced', 'wp-super-cache' ),
+		'cdn'      => __( 'CDN', 'wp-super-cache' ),
+		'contents' => __( 'Contents', 'wp-super-cache' ),
+		'preload'  => __( 'Preload', 'wp-super-cache' ),
+		'plugins'  => __( 'Plugins', 'wp-super-cache' ),
+		'debug'    => __( 'Debug', 'wp-super-cache' ),
+	);
+
+	echo '<div id="nav"><h3 class="themes-php">';
+
+	foreach ( $admin_tabs as $tab => $name ) {
+		printf( '<a class="%s" href="%s">%s</a>',
+			esc_attr( $tab === $current ? 'nav-tab nav-tab-active' : 'nav-tab' ),
+			esc_url_raw( add_query_arg( 'tab', $tab, $admin_url ) ),
+			esc_html( $name )
+		);
 	}
+
+	echo '</div></h3>';
 }
 
 function wsc_mod_rewrite() {
@@ -1482,8 +1512,9 @@ function wsc_mod_rewrite() {
 }
 
 function wp_cache_restore() {
+	$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
 	echo '<fieldset class="options"><h4>' . __( 'Fix Configuration', 'wp-super-cache' ) . '</h4>';
-	echo '<form name="wp_restore" action="#top" method="post">';
+	echo '<form name="wp_restore" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#top' ) . '" method="post">';
 	echo '<input type="hidden" name="wp_restore_config" />';
 	echo '<div class="submit"><input class="button-secondary" type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="' . __( 'Restore Default Configuration', 'wp-super-cache' ) . '" /></div>';
 	wp_nonce_field('wp-cache');
@@ -1596,6 +1627,7 @@ function wpsc_update_direct_pages() {
 function wp_lock_down() {
 	global $cached_direct_pages, $cache_enabled, $super_cache_enabled;
 
+	$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
 	$wp_lock_down = wp_update_lock_down();
 
 	?><a name='lockdown'></a>
@@ -1614,11 +1646,11 @@ function wp_lock_down() {
 	}
 	$new_lockdown =  $wp_lock_down == '1' ? '0' : '1';
 	$new_lockdown_desc =  $wp_lock_down == '1' ? __( 'Disable', 'wp-super-cache' ) : __( 'Enable', 'wp-super-cache' );
-	echo '<form name="wp_lock_down" action="#lockdown" method="post">';
+	echo '<form name="wp_lock_down" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#lockdown' ) . '" method="post">';
 	echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
-	echo "<div class='submit'><input class='button-primary' type='submit' " . SUBMITDISABLED . " value='{$new_lockdown_desc} " . __( 'Lock Down', 'wp-super-cache' ) . "' /></div>";
-	wp_nonce_field('wp-cache');
-	echo "</form>\n";
+	echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_attr( $new_lockdown_desc . ' ' . __( 'Lock Down', 'wp-super-cache' ) ) . '" /></div>';
+	wp_nonce_field( 'wp-cache' );
+	echo '</form>';
 
 	?></fieldset><?php
 	if( $cache_enabled == true && $super_cache_enabled == true ) {
@@ -1639,7 +1671,7 @@ function wp_lock_down() {
 			?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><strong><?php _e( 'Warning!', 'wp-super-cache' ); ?></strong> <?php printf( __( '%s is writable. Please make it readonly after your page is generated as this is a security risk.', 'wp-super-cache' ), ABSPATH ); ?></p><?php
 		}
 	}
-	echo '<form name="direct_page" action="#direct" method="post">';
+	echo '<form name="direct_page" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#direct' ) . '" method="post">';
 	if( is_array( $cached_direct_pages ) ) {
 		$out = '';
 		foreach( $cached_direct_pages as $page ) {
@@ -1655,20 +1687,27 @@ function wp_lock_down() {
 			echo "$out</table>";
 		}
 	}
-	if( $readonly != 'READONLY' )
-		echo __( "Add direct page:", 'wp-super-cache' ) . "<input type='text' $readonly name='new_direct_page' size='30' value='' />";
 
-	echo "<p>" . sprintf( __( "Directly cached files are files created directly off %s where your blog lives. This feature is only useful if you are expecting a major Digg or Slashdot level of traffic to one post or page.", 'wp-super-cache' ), ABSPATH ) . "</p>";
-	if( $readonly != 'READONLY' ) {
-		echo "<p>" . sprintf( __( 'For example: to cache <em>%1$sabout/</em>, you would enter %1$sabout/ or /about/. The cached file will be generated the next time an anonymous user visits that page.', 'wp-super-cache' ), trailingslashit( get_option( 'siteurl' ) ) ) . "</p>";
-		echo "<p>" . __( 'Make the textbox blank to remove it from the list of direct pages and delete the cached file.', 'wp-super-cache' ) . "</p>";
+	if ( 'READONLY' !== $readonly ) {
+		echo esc_html__( 'Add direct page:', 'wp-super-cache' ) . '<input type="text" name="new_direct_page" size="30" value="" />';
 	}
+	echo '<p>' . sprintf(
+		esc_html__( 'Directly cached files are files created directly off %s where your blog lives. This feature is only useful if you are expecting a major Digg or Slashdot level of traffic to one post or page.', 'wp-super-cache' ),
+		esc_attr( ABSPATH )
+	) . '</p>';
+	if ( 'READONLY' !== $readonly ) {
+		echo '<p>' . sprintf( __( 'For example: to cache <em>%1$sabout/</em>, you would enter %1$sabout/ or /about/. The cached file will be generated the next time an anonymous user visits that page.', 'wp-super-cache' ),
+			esc_attr( trailingslashit( get_option( 'siteurl' ) ) )
+		) . '</p>';
+		echo '<p>' . esc_html__( 'Make the textbox blank to remove it from the list of direct pages and delete the cached file.', 'wp-super-cache' ) . '</p>';
 
-	wp_nonce_field('wp-cache');
-	if( $readonly != 'READONLY' )
-		echo "<div class='submit'><input class='button-primary' type='submit' ' . SUBMITDISABLED . 'value='" . __( 'Update Direct Pages', 'wp-super-cache' ) . "' /></div>";
-	echo "</form>\n";
-	?></fieldset><?php
+		echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_attr__( 'Update Direct Pages', 'wp-super-cache' ) . '" /></div>';
+	}
+	wp_nonce_field( 'wp-cache' );
+	echo '</form>';
+	?>
+	</fieldset>
+	<?php
 	} // if $super_cache_enabled
 }
 
@@ -1769,6 +1808,7 @@ function wp_cache_time_update() {
 function wp_cache_edit_max_time() {
 	global $cache_max_time, $wp_cache_config_file, $valid_nonce, $super_cache_enabled, $cache_schedule_type, $cache_scheduled_time, $cache_schedule_interval, $cache_time_interval, $cache_gc_email_me, $wp_cache_preload_on;
 
+	$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
 	$timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
 
 	wp_cache_time_update();
@@ -1803,7 +1843,7 @@ function wp_cache_edit_max_time() {
 		});
 		});";
 	echo "</script>";
-	echo '<form name="wp_edit_max_time" action="#expirytime" method="post">';
+	echo '<form name="wp_edit_max_time" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#expirytime' ) . '" method="post">';
 	echo '<input name="action" value="expirytime" type="hidden" />';
 	echo '<table class="form-table">';
 	echo '<tr><td><label for="wp_max_time"><strong>' . __( 'Cache Timeout', 'wp-super-cache' ) . '</strong></label></td>';
@@ -1873,13 +1913,16 @@ function wp_cache_update_rejected_ua() {
 function wp_cache_edit_rejected_ua() {
 	global $cache_rejected_user_agent, $wp_cache_config_file, $valid_nonce;
 
-	if ( !function_exists( 'apache_request_headers' ) ) return;
+	if ( ! function_exists( 'apache_request_headers' ) ) {
+		return;
+	}
 
+	$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
 	wp_cache_update_rejected_ua();
 
 	echo '<a name="useragents"></a><fieldset class="options"><h4>' . __( 'Rejected User Agents', 'wp-super-cache' ) . '</h4>';
 	echo "<p>" . __( 'Strings in the HTTP &#8217;User Agent&#8217; header that prevent WP-Cache from caching bot, spiders, and crawlers&#8217; requests. Note that super cached files are still sent to these agents if they already exists.', 'wp-super-cache' ) . "</p>\n";
-	echo '<form name="wp_edit_rejected_user_agent" action="#useragents" method="post">';
+	echo '<form name="wp_edit_rejected_user_agent" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#useragents' ) . '" method="post">';
 	echo '<textarea name="wp_rejected_user_agent" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
 	foreach( $cache_rejected_user_agent as $ua ) {
 		echo esc_html( $ua ) . "\n";
@@ -1911,11 +1954,12 @@ function wp_cache_update_rejected_pages() {
 function wp_cache_edit_rejected_pages() {
 	global $wp_cache_config_file, $valid_nonce, $wp_cache_pages;
 
+	$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
 	wp_cache_update_rejected_pages();
 
 	echo '<a name="rejectpages"></a>';
 	echo '<p>' . __( 'Do not cache the following page types. See the <a href="https://codex.wordpress.org/Conditional_Tags">Conditional Tags</a> documentation for a complete discussion on each type.', 'wp-super-cache' ) . '</p>';
-	echo '<form name="wp_edit_rejected_pages" action="#rejectpages" method="post">';
+	echo '<form name="wp_edit_rejected_pages" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#rejectpages' ) . '" method="post">';
 	echo '<input type="hidden" name="wp_edit_rejected_pages" value="1" />';
 	echo '<label><input type="checkbox" value="1" name="wp_cache_pages[single]" ' . checked( 1, $wp_cache_pages[ 'single' ], false ) . ' /> ' . __( 'Single Posts', 'wp-super-cache' ) . ' (is_single)</label><br />';
 	echo '<label><input type="checkbox" value="1" name="wp_cache_pages[pages]" ' . checked( 1, $wp_cache_pages[ 'pages' ], false ) . ' /> ' . __( 'Pages', 'wp-super-cache' ) . ' (is_page)</label><br />';
@@ -1947,10 +1991,11 @@ function wp_cache_update_rejected_strings() {
 function wp_cache_edit_rejected() {
 	global $cache_rejected_uri;
 
+	$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
 	wp_cache_update_rejected_strings();
 
 	echo '<a name="rejecturi"></a>';
-	echo '<form name="wp_edit_rejected" action="#rejecturi" method="post">';
+	echo '<form name="wp_edit_rejected" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#rejecturi' ) . '" method="post">';
 	echo "<p>" . __( 'Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it&#8217;s enough to specify the year, i.e. &#8217;/2004/&#8217;. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.', 'wp-super-cache' ) . "</p>\n";
 	echo '<textarea name="wp_rejected_uri" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
 	foreach ($cache_rejected_uri as $file) {
@@ -1975,9 +2020,10 @@ function wp_cache_edit_accepted() {
 	global $cache_acceptable_files;
 
 	wp_cache_update_accepted_strings();
+	$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
 
 	echo '<a name="cancache"></a>';
-	echo '<div style="clear:both"></div><form name="wp_edit_accepted" action="#cancache" method="post">';
+	echo '<div style="clear:both"></div><form name="wp_edit_accepted" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#cancache' ) . '" method="post">';
 	echo "<p>" . __( 'Add here those filenames that can be cached, even if they match one of the rejected substring specified above.', 'wp-super-cache' ) . "</p>\n";
 	echo '<textarea name="wp_accepted_files" cols="40" rows="8" style="width: 50%; font-size: 12px;" class="code">';
 	foreach ($cache_acceptable_files as $file) {
@@ -2076,6 +2122,7 @@ function wp_cache_debug_settings() {
 	global $wp_cache_debug_username;
 
 	extract( wpsc_update_debug_settings() ); // $wp_super_cache_debug, $wp_cache_debug_log, $wp_cache_debug_ip, $wp_super_cache_comments, $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug, $wp_cache_debug_username
+	$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
 
 	echo '<a name="debug"></a>';
 	echo '<fieldset class="options">';
@@ -2092,12 +2139,13 @@ function wp_cache_debug_settings() {
 	}
 	echo "<p>" . sprintf( __( 'Username/Password: %s', 'wp-super-cache' ), $wp_cache_debug_username ) . "</p>";
 
-	echo '<form name="wpsc_delete" action="" method="post">';
+	echo '<form name="wpsc_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
 	wp_nonce_field('wp-cache');
 	echo "<input type='hidden' name='wpsc_delete_log' value='1' />";
 	submit_button( __( 'Delete', 'wp-super-cache' ), 'delete', 'wpsc_delete_log_form', false );
 	echo "</form>";
-	echo '<form name="wpsc_delete" action="" method="post">';
+
+	echo '<form name="wpsc_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
 	if ( ! isset( $wp_super_cache_debug ) || $wp_super_cache_debug == 0 ) {
 		$debug_status_message = __( 'Enable Logging', 'wp-super-cache' );
 		$not_status = 1;
@@ -2109,7 +2157,8 @@ function wp_cache_debug_settings() {
 	wp_nonce_field('wp-cache');
 	submit_button( $debug_status_message, 'primary', 'wpsc_log_status', true );
 	echo "</form>";
-	echo '<form name="wp_cache_debug" action="" method="post">';
+
+	echo '<form name="wp_cache_debug" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
 	echo "<input type='hidden' name='wp_cache_debug' value='1' /><br />";
 	echo "<table class='form-table'>";
 	echo "<tr><th>" . __( 'IP Address', 'wp-super-cache' ) . "</th><td> <input type='text' size='20' name='wp_cache_debug_ip' value='{$wp_cache_debug_ip}' /> " . sprintf( __( '(only log requests from this IP address. Your IP is %s)', 'wp-super-cache' ), $_SERVER[ 'REMOTE_ADDR' ] ) . "</td></tr>";
@@ -2120,15 +2169,15 @@ function wp_cache_debug_settings() {
 &lt;!-- super cache --></pre></td></tr>";
 	echo "</table>\n";
 	if ( isset( $wp_super_cache_advanced_debug ) ) {
-	echo "<h5>" . __( 'Advanced', 'wp-super-cache' ) . "</h5><p>" . __( 'In very rare cases two problems may arise on some blogs:<ol><li> The front page may start downloading as a zip file.</li><li> The wrong page is occasionally cached as the front page if your blog uses a static front page and the permalink structure is <em>/%category%/%postname%/</em>.</li></ol>', 'wp-super-cache' ) . '</p>';
-	echo "<p>" . __( 'I&#8217;m 99% certain that they aren&#8217;t bugs in WP Super Cache and they only happen in very rare cases but you can run a simple check once every 5 minutes to verify that your site is ok if you&#8217;re worried. You will be emailed if there is a problem.', 'wp-super-cache' ) . "</p>";
-	echo "<table class='form-table'>";
-	echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_check' value='1' " . checked( 1, $wp_super_cache_front_page_check, false ) . " /> " . __( 'Check front page every 5 minutes.', 'wp-super-cache' ) . "</td></tr>";
-	echo "<tr><td valign='top'>" . __( 'Front page text', 'wp-super-cache' ) . "</td><td> <input type='text' size='30' name='wp_super_cache_front_page_text' value='{$wp_super_cache_front_page_text}' /> (" . __( 'Text to search for on your front page. If this text is missing, the cache will be cleared. Leave blank to disable.', 'wp-super-cache' ) . ")</td></tr>";
-	echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_clear' value='1' " . checked( 1, $wp_super_cache_front_page_clear, false ) . " /> " . __( 'Clear cache on error.', 'wp-super-cache' ) . "</td></tr>";
-	echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_notification' value='1' " . checked( 1, $wp_super_cache_front_page_notification, false ) . " /> " . __( 'Email the blog admin when checks are made. (useful for testing)', 'wp-super-cache' ) . "</td></tr>";
+		echo "<h5>" . __( 'Advanced', 'wp-super-cache' ) . "</h5><p>" . __( 'In very rare cases two problems may arise on some blogs:<ol><li> The front page may start downloading as a zip file.</li><li> The wrong page is occasionally cached as the front page if your blog uses a static front page and the permalink structure is <em>/%category%/%postname%/</em>.</li></ol>', 'wp-super-cache' ) . '</p>';
+		echo "<p>" . __( 'I&#8217;m 99% certain that they aren&#8217;t bugs in WP Super Cache and they only happen in very rare cases but you can run a simple check once every 5 minutes to verify that your site is ok if you&#8217;re worried. You will be emailed if there is a problem.', 'wp-super-cache' ) . "</p>";
+		echo "<table class='form-table'>";
+		echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_check' value='1' " . checked( 1, $wp_super_cache_front_page_check, false ) . " /> " . __( 'Check front page every 5 minutes.', 'wp-super-cache' ) . "</td></tr>";
+		echo "<tr><td valign='top'>" . __( 'Front page text', 'wp-super-cache' ) . "</td><td> <input type='text' size='30' name='wp_super_cache_front_page_text' value='{$wp_super_cache_front_page_text}' /> (" . __( 'Text to search for on your front page. If this text is missing, the cache will be cleared. Leave blank to disable.', 'wp-super-cache' ) . ")</td></tr>";
+		echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_clear' value='1' " . checked( 1, $wp_super_cache_front_page_clear, false ) . " /> " . __( 'Clear cache on error.', 'wp-super-cache' ) . "</td></tr>";
+		echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_notification' value='1' " . checked( 1, $wp_super_cache_front_page_notification, false ) . " /> " . __( 'Email the blog admin when checks are made. (useful for testing)', 'wp-super-cache' ) . "</td></tr>";
 
-	echo "</table>\n";
+		echo "</table>\n";
 	}
 	echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Settings', 'wp-super-cache' ) . '" /></div>';
 	wp_nonce_field('wp-cache');
@@ -2523,6 +2572,16 @@ function wp_cache_create_advanced_cache() {
 	}
 	$ret = true;
 
+	if ( file_exists( $wp_cache_link ) ) {
+		$file = file_get_contents( $wp_cache_link );
+		if (
+			! strpos( $file, "WP SUPER CACHE 0.8.9.1" ) &&
+			! strpos( $file, "WP SUPER CACHE 1.2" )
+		) {
+			wp_die( '<div class="notice notice-error"><h4>' . __( 'Warning!', 'wp-super-cache' ) . "</h4><p>" . sprintf( __( 'The file %s already exists. Please manually delete it before using this plugin.', 'wp-super-cache' ), $wp_cache_link ) . "</p></div>" );
+		}
+	}
+
 	$file = file_get_contents( $wp_cache_file );
 	$fp = @fopen( $wp_cache_link, 'w' );
 	if( $fp ) {
@@ -2543,11 +2602,7 @@ function wp_cache_check_link() {
 		if( strpos( $file, "WP SUPER CACHE 0.8.9.1" ) || strpos( $file, "WP SUPER CACHE 1.2" ) ) {
 			return true;
 		} else {
-			if( !@unlink($wp_cache_link) ) {
-				$ret = false;
-			} else {
-				$ret = wp_cache_create_advanced_cache();
-			}
+			$ret = wp_cache_create_advanced_cache();
 		}
 	} else {
 		$ret = wp_cache_create_advanced_cache();
@@ -2845,19 +2900,21 @@ function wp_cache_files() {
 
 function wp_cache_delete_buttons() {
 
-	echo '<form name="wp_cache_content_expired" action="#listfiles" method="post">';
+	$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
+
+	echo '<form name="wp_cache_content_expired" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
 	echo '<input type="hidden" name="wp_delete_expired" />';
 	echo '<div class="submit" style="float:left"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Expired', 'wp-super-cache' ) . '" /></div>';
 	wp_nonce_field('wp-cache');
 	echo "</form>\n";
 
-	echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
+	echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
 	echo '<input type="hidden" name="wp_delete_cache" />';
 	echo '<div class="submit" style="float:left;margin-left:10px"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache', 'wp-super-cache' ) . '" /></div>';
 	wp_nonce_field('wp-cache');
 	echo "</form>\n";
-	if ( ( defined( 'VHOST' ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'SUNRISE' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && wpsupercache_site_admin() ) {
-		echo '<form name="wp_cache_content_delete" action="#listfiles" method="post">';
+	if ( is_multisite() && wpsupercache_site_admin() ) {
+		echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
 		echo '<input type="hidden" name="wp_delete_all_cache" />';
 		echo '<div class="submit" style="float:left;margin-left:10px"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" /></div>';
 		wp_nonce_field('wp-cache');
@@ -2992,6 +3049,8 @@ function wp_cache_clean_legacy_files( $dir, $file_prefix ) {
 		return false;
 
 	if ( $handle = @opendir( $dir ) ) {
+		$curr_blog_id = is_multisite() ? get_current_blog_id() : false;
+
 		while ( false !== ( $file = readdir( $handle ) ) ) {
 			if ( is_file( $dir . $file ) == false || $file == 'index.html' ) {
 				continue;
@@ -3004,8 +3063,9 @@ function wp_cache_clean_legacy_files( $dir, $file_prefix ) {
 					@unlink( $dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
 				} else {
 					$meta = json_decode( wp_cache_get_legacy_cache( $dir . 'meta/' . $file ), true );
-					if ( ( defined( 'VHOST' ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'SUNRISE' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) && $meta[ 'blog_id' ] != $wpdb->blogid )
+					if (  $curr_blog_id && $curr_blog_id !== (int)$meta['blog_id'] ) {
 						continue;
+					}
 					@unlink( $dir . $file);
 					@unlink( $dir . 'meta/' . $file);
 				}
@@ -3084,12 +3144,6 @@ function wpsc_remove_marker( $filename, $marker ) {
 	}
 }
 
-function wp_super_cache_footer() {
-	?><p id='supercache'><?php printf( __( '%1$s is Stephen Fry proof thanks to caching by %2$s', 'wp-super-cache' ), get_bloginfo( 'name', 'display' ), '<a href="https://odd.blog/wp-super-cache/">WP Super Cache</a>' ); ?></p><?php
-}
-if( isset( $wp_cache_hello_world ) && $wp_cache_hello_world )
-	add_action( 'wp_footer', 'wp_super_cache_footer' );
-
 if( get_option( 'gzipcompression' ) )
 	update_option( 'gzipcompression', 0 );
 
@@ -3144,8 +3198,9 @@ function wp_cache_admin_notice() {
 		echo '<div class="notice notice-info"><p><strong>' . sprintf( __('WP Super Cache is disabled. Please go to the <a href="%s">plugin admin page</a> to enable caching.', 'wp-super-cache' ), admin_url( 'options-general.php?page=wpsupercache' ) ) . '</strong></p></div>';
 
 	if ( defined( 'WP_CACHE' ) && WP_CACHE == true && ( defined( 'ADVANCEDCACHEPROBLEM' ) || ( $cache_enabled && false == isset( $wp_cache_phase1_loaded ) ) ) ) {
-		echo '<div class="notice notice-error"><p>' . sprintf( __( 'Warning! WP Super Cache caching <strong>was</strong> broken but has been <strong>fixed</strong>! The script advanced-cache.php could not load wp-cache-phase1.php.<br /><br />The file %1$s/advanced-cache.php has been recreated and WPCACHEHOME fixed in your wp-config.php. Reload to hide this message.', 'wp-super-cache' ), WP_CONTENT_DIR ) . '</p></div>';
-		wp_cache_create_advanced_cache();
+		if ( wp_cache_create_advanced_cache() ) {
+			echo '<div class="notice notice-error"><p>' . sprintf( __( 'Warning! WP Super Cache caching <strong>was</strong> broken but has been <strong>fixed</strong>! The script advanced-cache.php could not load wp-cache-phase1.php.<br /><br />The file %1$s/advanced-cache.php has been recreated and WPCACHEHOME fixed in your wp-config.php. Reload to hide this message.', 'wp-super-cache' ), WP_CONTENT_DIR ) . '</p></div>';
+		}
 	}
 }
 add_action( 'admin_notices', 'wp_cache_admin_notice' );
@@ -3218,6 +3273,7 @@ function wpsc_update_htaccess() {
 function wpsc_update_htaccess_form( $short_form = true ) {
 	global $wpmu_version;
 
+	$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
 	extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
 	if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
 		echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h5>" . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "</h5><p>" . sprintf( __( 'The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "</p><p>" . __( 'Refresh this page when the file permissions have been modified.' ) . "</p><p>" . sprintf( __( 'Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "</p>";
@@ -3236,7 +3292,7 @@ function wpsc_update_htaccess_form( $short_form = true ) {
 			echo "</div>";
 		}
 		if ( !isset( $wpmu_version ) || $wpmu_version == '' ) {
-			echo '<form name="updatehtaccess" action="#modrewrite" method="post">';
+			echo '<form name="updatehtaccess" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#modrewrite' ) . '" method="post">';
 			echo '<input type="hidden" name="updatehtaccess" value="1" />';
 			echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="' . __( 'Update Mod_Rewrite Rules', 'wp-super-cache' ) . '" /></div>';
 			wp_nonce_field('wp-cache');
@@ -3760,7 +3816,7 @@ function wpsc_admin_bar_render( $wp_admin_bar ) {
 					'id' => 'delete-cache',
 					'title' => __( 'Delete Cache', 'wp-super-cache' ),
 					'meta' => array( 'title' => __( 'Delete cache of the current page', 'wp-super-cache' ) ),
-					'href' => wp_nonce_url( admin_url( 'index.php?action=delcachepage&path=' . urlencode( $path ) ), 'delete-cache' )
+					'href' => wp_nonce_url( admin_url( 'index.php?action=delcachepage&path=' . rawurlencode( $path ) ), 'delete-cache' )
 					) );
 	}
 
@@ -3769,7 +3825,7 @@ function wpsc_admin_bar_render( $wp_admin_bar ) {
 					'parent' => '',
 					'id' => 'delete-cache',
 					'title' => __( 'Delete Cache', 'wp-super-cache' ),
-					'meta' => array( 'title' => __( 'Delete Super Cache cached files (opens in new window)', 'wp-super-cache' ), 'target' => '_blank' ),
+					'meta' => array( 'title' => __( 'Delete Super Cache cached files', 'wp-super-cache' ) ),
 					'href' => wp_nonce_url( admin_url( 'options-general.php?page=wpsupercache&tab=contents&wp_delete_cache=1' ), 'wp-cache' )
 					) );
 	}