Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fix php notices in WordPress Hyper Cache
diff --git a/wp-content/plugins/hyper-cache/cache.php b/wp-content/plugins/hyper-cache/cache.php
index e3e1dbf..647fa55 100644
--- a/wp-content/plugins/hyper-cache/cache.php
+++ b/wp-content/plugins/hyper-cache/cache.php
@@ -125,7 +125,7 @@ if ($hyper_data['type'] == 'home' || $hyper_data['type'] == 'archive') {
// Valid cache file check ends here
-if ($hyper_data['location']) {
+if (isset($hyper_data['location']) && $hyper_data['location']) {
header('Location: ' . $hyper_data['location']);
flush();
die();
@@ -151,7 +151,7 @@ if (!$hyper_cache_lastmodified) {
}
header('Content-Type: ' . $hyper_data['mime']);
-if ($hyper_data['status'] == 404) header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
+if (isset($hyper_data['status']) && $hyper_data['status'] == 404) header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
// Send the cached html
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false &&
@@ -205,7 +205,7 @@ function hyper_cache_callback($buffer) {
global $hyper_cache_notfound, $hyper_cache_stop, $hyper_cache_charset, $hyper_cache_home, $hyper_cache_redirects, $hyper_redirect, $hc_file, $hyper_cache_name, $hyper_cache_browsercache, $hyper_cache_timeout, $hyper_cache_lastmodified, $hyper_cache_gzip, $hyper_cache_gzip_on_the_fly;
if (!function_exists('is_home')) return $buffer;
-
+
if (function_exists('apply_filters')) $buffer = apply_filters('hyper_cache_buffer', $buffer);
if ($hyper_cache_stop) return $buffer;
@@ -269,7 +269,7 @@ function hyper_cache_callback($buffer) {
if (!$hyper_cache_lastmodified) {
header('Last-Modified: ' . gmdate("D, d M Y H:i:s", @filemtime($hc_file)). " GMT");
}
-
+
if (($hyper_cache_gzip && !empty($data['gz'])) || ($hyper_cache_gzip_on_the_fly && !empty($data['html']) && function_exists('gzencode'))) {
header('Content-Encoding: gzip');
header('Vary: Accept-Encoding');
@@ -313,7 +313,7 @@ function hyper_mobile_type() {
}
}
- if (!isset($hyper_cache_mobile) || $hyper_cache_mobile_agents === false) return '';
+ if (!isset($hyper_cache_mobile) || $hyper_cache_mobile_agents === false || empty($hyper_cache_mobile_agents)) return '';
$hyper_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
foreach ($hyper_cache_mobile_agents as $hyper_a) {
diff --git a/wp-content/plugins/hyper-cache/options.php b/wp-content/plugins/hyper-cache/options.php
index f6ded82..9daa572 100644
--- a/wp-content/plugins/hyper-cache/options.php
+++ b/wp-content/plugins/hyper-cache/options.php
@@ -2,7 +2,7 @@
$options = get_option('hyper');
-if (!$options['notranslation'])
+if (!isset($options['notranslation']) || !$options['notranslation'])
{
$plugin_dir = basename(dirname(__FILE__));
load_plugin_textdomain('hyper-cache', 'wp-content/plugins/' . $plugin_dir, $plugin_dir);
@@ -15,27 +15,27 @@ if (isset($_POST['clean']))
}
$error = false;
-if (isset($_POST['save']))
+if (isset($_POST['save']))
{
- if (!check_admin_referer()) die('No hacking please');
-
+ if (!check_admin_referer('hypercache')) die('No hacking please');
+
$tmp = stripslashes_deep($_POST['options']);
- if ($options['gzip'] != $tmp['gzip'])
+ if (isset($options['gzip']) && $options['gzip'] != $tmp['gzip'])
{
hyper_delete_path(WP_CONTENT_DIR . '/cache/hyper-cache');
}
$options = $tmp;
-
- if (!is_numeric($options['timeout'])) $options['timeout'] = 60;
+
+ if (!isset($options['timeout']) || !is_numeric($options['timeout'])) $options['timeout'] = 60;
$options['timeout'] = (int)$options['timeout'];
- if (!is_numeric($options['clean_interval'])) $options['clean_interval'] = 60;
+ if (!isset($options['clean_interval']) || !is_numeric($options['clean_interval'])) $options['clean_interval'] = 60;
$options['clean_interval'] = (int)$options['clean_interval'];
$buffer = hyper_generate_config($options);
-
+
$file = @fopen(ABSPATH . 'wp-content/advanced-cache.php', 'w');
if ($file) {
@fwrite($file, $buffer);
@@ -47,15 +47,15 @@ if (isset($_POST['save']))
update_option('hyper', $options);
// When the cache does not expire
- if ($options['expire_type'] == 'none')
+ if (isset($options['expire_type']) && $options['expire_type'] == 'none')
{
@unlink(WP_CONTENT_DIR . '/cache/hyper-cache/_global.dat');
@unlink(WP_CONTENT_DIR . '/cache/hyper-cache/_archives.dat');
}
-}
-else
+}
+else
{
- if ($options['mobile_agents'] == '')
+ if (isset($options['mobile_agents']) && $options['mobile_agents'] == '')
{
$options['mobile_agents'] = "elaine/3.0\niphone\nipod\npalm\neudoraweb\nblazer\navantgo\nwindows ce\ncellphone\nsmall\nmmef20\ndanger\nhiptop\nproxinet\nnewt\npalmos\nnetfront\nsharp-tq-gx10\nsonyericsson\nsymbianos\nup.browser\nup.link\nts21i-10\nmot-v\nportalmmm\ndocomo\nopera mini\npalm\nhandspring\nnokia\nkyocera\nsamsung\nmotorola\nmot\nsmartphone\nblackberry\nwap\nplaystation portable\nlg\nmmp\nopwv\nsymbian\nepoc";
}
@@ -97,7 +97,7 @@ else
<p>Thank you to Florian Höch (<a href="http://hoech.net" target="_blank">hoech.net</a>) for his great contribution to version 2.9.0.</p>
-<?php include dirname(__FILE__) . '/header.php'; ?>
+<?php if (!defined('HIDE_DONATION_NAGS')) { include dirname(__FILE__) . '/header.php'; } ?>
<?php
if ($error)
@@ -119,7 +119,7 @@ else
<form method="post" action="">
-<?php wp_nonce_field(); ?>
+<?php wp_nonce_field('hypercache'); ?>
<p class="submit">
<input class="button" type="submit" name="clean" value="<?php _e('Clear cache', 'hyper-cache'); ?>">
@@ -155,7 +155,7 @@ else
<tr valign="top">
<th><?php _e('Cached pages timeout', 'hyper-cache'); ?></th>
<td>
- <input type="text" size="5" name="options[timeout]" value="<?php echo htmlspecialchars($options['timeout']); ?>"/>
+ <input type="text" size="5" name="options[timeout]" value="<?php echo isset($options['timeout']) ? htmlspecialchars($options['timeout']) : '0'; ?>"/>
(<?php _e('minutes', 'hyper-cache'); ?>)
<div class="hints">
<?php _e('Minutes a cached page is valid and served to users. A zero value means a cached page is
@@ -171,13 +171,13 @@ else
<th><?php _e('Cache invalidation mode', 'hyper-cache'); ?></th>
<td>
<select name="options[expire_type]">
- <option value="all" <?php echo ($options['expire_type'] == 'all')?'selected':''; ?>><?php _e('All cached pages', 'hyper-cache'); ?></option>
- <option value="post" <?php echo ($options['expire_type'] == 'post')?'selected':''; ?>><?php _e('Only modified posts', 'hyper-cache'); ?></option>
- <!--<option value="post_strictly" <?php echo ($options['expire_type'] == 'post_strictly')?'selected':''; ?>><?php _e('Only modified pages', 'hyper-cache'); ?></option>-->
- <option value="none" <?php echo ($options['expire_type'] == 'none')?'selected':''; ?>><?php _e('Nothing', 'hyper-cache'); ?></option>
+ <option value="all" <?php echo (isset($options['expire_type']) && $options['expire_type'] == 'all')?'selected':''; ?>><?php _e('All cached pages', 'hyper-cache'); ?></option>
+ <option value="post" <?php echo (isset($options['expire_type']) && $options['expire_type'] == 'post')?'selected':''; ?>><?php _e('Only modified posts', 'hyper-cache'); ?></option>
+ <!--<option value="post_strictly" <?php echo (isset($options['expire_type']) && $options['expire_type'] == 'post_strictly')?'selected':''; ?>><?php _e('Only modified pages', 'hyper-cache'); ?></option>-->
+ <option value="none" <?php echo (isset($options['expire_type']) && $options['expire_type'] == 'none')?'selected':''; ?>><?php _e('Nothing', 'hyper-cache'); ?></option>
</select>
<br />
- <input type="checkbox" name="options[archive]" value="1" <?php echo $options['archive']?'checked':''; ?>/>
+ <input type="checkbox" name="options[archive]" value="1" <?php checked(isset($options['archive']) && $options['archive']); ?>/>
<?php _e('Invalidate home, archives, categories on single post invalidation', 'hyper-cache'); ?>
<br />
<div class="hints">
@@ -193,7 +193,7 @@ else
<tr valign="top">
<th><?php _e('Disable cache for commenters', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[comment]" value="1" <?php echo $options['comment']?'checked':''; ?>/>
+ <input type="checkbox" name="options[comment]" value="1" <?php checked(isset($options['comment']) && $options['comment']); ?>/>
<div class="hints">
<?php _e('When users leave comments, WordPress show pages with their comments even if in moderation
(and not visible to others) and pre-fills the comment form.', 'hyper-cache'); ?>
@@ -207,19 +207,19 @@ else
<tr valign="top">
<th><?php _e('Feeds caching', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[feed]" value="1" <?php echo $options['feed']?'checked':''; ?>/>
+ <input type="checkbox" name="options[feed]" value="1" <?php checked(isset($options['feed']) && $options['feed']); ?>/>
<div class="hints">
<?php _e('When enabled the blog feeds will be cache as well.', 'hyper-cache'); ?>
<?php _e('Usually this options has to be left unchecked but if your blog is rather static,
you can enable it and have a bit more efficiency', 'hyper-cache'); ?>
</div>
- </td>
+ </td>
</tr>
<tr valign="top">
<th><?php _e('Allow browser caching', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[browsercache]" value="1" <?php echo $options['browsercache']?'checked':''; ?>/>
+ <input type="checkbox" name="options[browsercache]" value="1" <?php checked(isset($options['browsercache']) && $options['browsercache']); ?>/>
<div class="hints">
<?php _e('Allow browser caching.','hyper-cache'); ?>
</div>
@@ -235,7 +235,7 @@ else
<tr valign="top">
<th><?php _e('WordPress Mobile Pack', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[plugin_mobile_pack]" value="1" <?php echo $options['plugin_mobile_pack']?'checked':''; ?>/>
+ <input type="checkbox" name="options[plugin_mobile_pack]" value="1" <?php checked(isset($options['plugin_mobile_pack']) && $options['plugin_mobile_pack']); ?>/>
<div class="hints">
<?php _e('Enbale integration with <a href="http://wordpress.org/extend/plugins/wordpress-mobile-pack/">WordPress Mobile Pack</a> plugin. If you have that plugin, Hyper Cache use it to detect mobile devices and caches saparately
the different pages generated.', 'hyper-cache'); ?>
@@ -245,7 +245,7 @@ else
<tr valign="top">
<th><?php _e('Detect mobile devices', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[mobile]" value="1" <?php echo $options['mobile']?'checked':''; ?>/>
+ <input type="checkbox" name="options[mobile]" value="1" <?php checked(isset($options['mobile']) && $options['mobile']); ?>/>
<div class="hints">
<?php _e('When enabled mobile devices will be detected and the cached page stored under different name.', 'hyper-cache'); ?>
<?php _e('This makes blogs with different themes for mobile devices to work correctly.', 'hyper-cache'); ?>
@@ -281,7 +281,7 @@ else
<tr valign="top">
<th><?php _e('Store compressed pages', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[store_compressed]" value="1" <?php echo $options['store_compressed']?'checked':''; ?>
+ <input type="checkbox" name="options[store_compressed]" value="1" <?php checked(isset($options['store_compressed']) && $options['store_compressed']); ?>
onchange="jQuery('input[name=&quot;options[gzip]&quot;]').attr('disabled', !this.checked)" />
<div class="hints">
<?php _e('Enable this option to minimize disk space usage and make sending of compressed pages possible with the option below.', 'hyper-cache'); ?>
@@ -296,8 +296,8 @@ else
<tr valign="top">
<th><?php _e('Send compressed pages', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[gzip]" value="1" <?php echo $options['gzip']?'checked':''; ?>
- <?php echo $options['store_compressed']?'':'disabled'; ?> />
+ <input type="checkbox" name="options[gzip]" value="1" <?php checked(isset($options['gzip']) && $options['gzip']); ?>
+ <?php echo (isset($options['store_compressed']) && $options['store_compressed'])?'':'disabled'; ?> />
<div class="hints">
<?php _e('When possible (i.e. if the browser accepts compression and the page was cached compressed) the page will be sent compressed to save bandwidth.', 'hyper-cache'); ?>
<?php _e('Only the textual part of a page can be compressed, not images, so a photo
@@ -312,7 +312,7 @@ else
<tr valign="top">
<th><?php _e('On-the-fly compression', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[gzip_on_the_fly]" value="1" <?php echo $options['gzip_on_the_fly']?'checked':''; ?> />
+ <input type="checkbox" name="options[gzip_on_the_fly]" value="1" <?php checked(isset($options['gzip_on_the_fly']) && $options['gzip_on_the_fly']); ?> />
<div class="hints">
<?php _e('When possible (i.e. if the browser accepts compression) use on-the-fly compression to save bandwidth when sending pages which are not compressed.', 'hyper-cache'); ?>
<?php _e('Serving of such pages will be a little less performant.', 'hyper-cache'); ?>
@@ -333,7 +333,7 @@ else
<tr valign="top">
<th><?php _e('Translation', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[notranslation]" value="1" <?php echo $options['notranslation']?'checked':''; ?>/>
+ <input type="checkbox" name="options[notranslation]" value="1" <?php checked(isset($options['notranslation']) && $options['notranslation']); ?>/>
<div class="hints">
<?php _e('DO NOT show this panel translated.', 'hyper-cache'); ?>
</div>
@@ -343,7 +343,7 @@ else
<tr valign="top">
<th><?php _e('Disable Last-Modified header', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[lastmodified]" value="1" <?php echo $options['lastmodified']?'checked':''; ?>/>
+ <input type="checkbox" name="options[lastmodified]" value="1" <?php checked(isset($options['lastmodified']) && $options['lastmodified']); ?>/>
<div class="hints">
<?php _e('Disable some HTTP headers (Last-Modified) which improve performances but some one is reporting they create problems which some hosting configurations.','hyper-cache'); ?>
</div>
@@ -353,7 +353,7 @@ else
<tr valign="top">
<th><?php _e('Home caching', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[home]" value="1" <?php echo $options['home']?'checked':''; ?>/>
+ <input type="checkbox" name="options[home]" value="1" <?php checked(isset($options['home']) && $options['home']); ?>/>
<div class="hints">
<?php _e('DO NOT cache the home page so it is always fresh.','hyper-cache'); ?>
</div>
@@ -363,7 +363,7 @@ else
<tr valign="top">
<th><?php _e('Redirect caching', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[redirects]" value="1" <?php echo $options['redirects']?'checked':''; ?>/>
+ <input type="checkbox" name="options[redirects]" value="1" <?php checked(isset($options['redirects']) && $options['redirects']); ?>/>
<br />
<?php _e('Cache WordPress redirects.', 'hyper-cache'); ?>
<?php _e('WordPress sometime sends back redirects that can be cached to avoid further processing time.', 'hyper-cache'); ?>
@@ -373,14 +373,14 @@ else
<tr valign="top">
<th><?php _e('Page not found caching (HTTP 404)', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[notfound]" value="1" <?php echo $options['notfound']?'checked':''; ?>/>
+ <input type="checkbox" name="options[notfound]" value="1" <?php checked(isset($options['notfound']) && $options['notfound']); ?>/>
</td>
</tr>
<tr valign="top">
<th><?php _e('Strip query string', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[strip_qs]" value="1" <?php echo $options['strip_qs']?'checked':''; ?>/>
+ <input type="checkbox" name="options[strip_qs]" value="1" <?php checked(isset($options['strip_qs']) && $options['strip_qs']); ?>/>
<div class="hints">
<?php _e('This is a really special case, usually you have to kept it disabled. When enabled, URL with query string will be
reduced removing the query string. So the URL http://www.domain.com/post-title and
@@ -396,7 +396,7 @@ else
<tr valign="top">
<th><?php _e('URL with parameters', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[cache_qs]" value="1" <?php echo $options['cache_qs']?'checked':''; ?>/>
+ <input type="checkbox" name="options[cache_qs]" value="1" <?php checked(isset($options['cache_qs']) && $options['cache_qs']); ?>/>
<div class="hints">
<?php _e('Cache requests with query string (parameters).', 'hyper-cache'); ?>
<?php _e('This option has to be enabled for blogs which have post URLs with a question mark on them.', 'hyper-cache'); ?>
@@ -411,7 +411,7 @@ else
<tr valign="top">
<th><?php _e('Allow browser to bypass cache', 'hyper-cache'); ?></th>
<td>
- <input type="checkbox" name="options[nocache]" value="1" <?php echo $options['nocache']?'checked':''; ?>/>
+ <input type="checkbox" name="options[nocache]" value="1" <?php checked(isset($options['nocache']) && $options['nocache']); ?>/>
<div class="hints">
<?php _e('Do not use cache if browser sends no-cache header (e.g. on explicit page reload).','hyper-cache'); ?>
</div>
@@ -430,7 +430,7 @@ else
<tr valign="top">
<th><?php _e('URI to reject', 'hyper-cache'); ?></th>
<td>
- <textarea wrap="off" rows="5" cols="70" name="options[reject]"><?php echo htmlspecialchars($options['reject']); ?></textarea>
+ <textarea wrap="off" rows="5" cols="70" name="options[reject]"><?php echo isset($options['reject'])?htmlspecialchars($options['reject']):''; ?></textarea>
<div class="hints">
<?php _e('Write one URI per line, each URI has to start with a slash.', 'hyper-cache'); ?>
<?php _e('A specified URI will match the requested URI if the latter starts with the former.', 'hyper-cache'); ?>
@@ -456,7 +456,7 @@ else
<tr valign="top">
<th><?php _e('Agents to reject', 'hyper-cache'); ?></th>
<td>
- <textarea wrap="off" rows="5" cols="70" name="options[reject_agents]"><?php echo htmlspecialchars($options['reject_agents']); ?></textarea>
+ <textarea wrap="off" rows="5" cols="70" name="options[reject_agents]"><?php echo isset($options['reject_agents'])?htmlspecialchars($options['reject_agents']):''; ?></textarea>
<div class="hints">
<?php _e('Write one agent per line.', 'hyper-cache'); ?>
<?php _e('A specified agent will match the client agent if the latter contains the former. The matching is case insensitive.', 'hyper-cache'); ?>
@@ -467,7 +467,7 @@ else
<tr valign="top">
<th><?php _e('Cookies matching', 'hyper-cache'); ?></th>
<td>
- <textarea wrap="off" rows="5" cols="70" name="options[reject_cookies]"><?php echo htmlspecialchars($options['reject_cookies']); ?></textarea>
+ <textarea wrap="off" rows="5" cols="70" name="options[reject_cookies]"><?php echo isset($options['reject_cookies'])?htmlspecialchars($options['reject_cookies']):''; ?></textarea>
<div class="hints">
<?php _e('Write one cookie name per line.', 'hyper-cache'); ?>
<?php _e('When a specified cookie will match one of the cookie names sent bby the client the cache stops.', 'hyper-cache'); ?>
diff --git a/wp-content/plugins/hyper-cache/plugin.php b/wp-content/plugins/hyper-cache/plugin.php
index 566ab6d..dd70acf 100644
--- a/wp-content/plugins/hyper-cache/plugin.php
+++ b/wp-content/plugins/hyper-cache/plugin.php
@@ -10,7 +10,7 @@ Author URI: http://www.satollo.net
Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
Copyright 2011 Satollo (email : info@satollo.net)
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -318,7 +318,7 @@ function hyper_generate_config(&$options)
// Do not cache for commenters
$buffer .= '$hyper_cache_comment = ' . (isset($options['comment'])?'true':'false') . ";\n";
// Ivalidate archives on post invalidation
- $buffer .= '$hyper_cache_archive = ' . ($options['archive']?'true':'false') . ";\n";
+ $buffer .= '$hyper_cache_archive = ' . (isset($options['archive'])&&$options['archive']?'true':'false') . ";\n";
// Single page timeout
$buffer .= '$hyper_cache_timeout = ' . ($timeout) . ";\n";
// Cache redirects?
@@ -344,7 +344,7 @@ function hyper_generate_config(&$options)
// Do not use cache if browser sends no-cache header?
$buffer .= '$hyper_cache_nocache = ' . (isset($options['nocache'])?'true':'false') . ";\n";
- if ($options['gzip']) $options['store_compressed'] = 1;
+ if (isset($options['gzip']) && $options['gzip']) $options['store_compressed'] = 1;
$buffer .= '$hyper_cache_gzip = ' . (isset($options['gzip'])?'true':'false') . ";\n";
$buffer .= '$hyper_cache_gzip_on_the_fly = ' . (isset($options['gzip_on_the_fly'])?'true':'false') . ";\n";
@@ -444,7 +444,7 @@ function hyper_generate_config(&$options)
$buffer .= '$hyper_cache_mobile_agents = false;' . "\n";
}
}
-
+
$buffer .= "include(ABSPATH . 'wp-content/plugins/hyper-cache/cache.php');\n";
$buffer .= '?>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.