本文整理汇总了PHP中do_cacheaction函数的典型用法代码示例。如果您正苦于以下问题:PHP do_cacheaction函数的具体用法?PHP do_cacheaction怎么用?PHP do_cacheaction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了do_cacheaction函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_cache_manager
//.........这里部分代码省略.........
<input type="hidden" name="cmd" value="_s-xclick"/>
<input type="hidden" name="hosted_button_id" value="3244504"/>
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt=""/>
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"/><br />
</form>
<p><?php
_e('Don’t show me this again.', 'wp-super-cache');
?>
<form action="#top" method="post"><input type='hidden' name='wp_cache_hide_donation' value='1' /><input type='submit' value='<?php
_e('Hide', 'wp-super-cache');
?>
' /><?php
wp_nonce_field('wp-cache');
?>
</form></p>
</div>
<?php
} else {
?>
<p><?php
printf(__('%1$s is maintained and developed by %2$s with contributions from many others.', 'wp-super-cache'), '<a href="http://ocaoimh.ie/wp-super-cache/?r=supercache">WP Super Cache</a>', '<a href="http://ocaoimh.ie/?r=supercache">Donncha O Caoimh</a>');
?>
</p>
<p><?php
printf(__('He blogs at %1$s, posts photos at %2$s and <a href="%3$s">wishes</a> he had more time to read and relax.', 'wp-super-cache'), '<a href="http://ocaoimh.ie/?r=supercache">Holy Shmoly</a>', '<a href="http://inphotos.org/?r=supercache">In Photos.org</a>', 'http://ocaoimh.ie/gad');
?>
</p>
<p><?php
printf(__('Please say hi to him on %s too!', 'wp-super-cache'), '<a href="http://twitter.com/donncha/">Twitter</a>');
?>
</p>
<?php
}
if (isset($wp_supercache_cache_list) && $wp_supercache_cache_list) {
$start_date = get_option('wpsupercache_start');
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']) . "'>{$url['url']}</a></li>\n";
}
?>
</ol>
<small><?php
_e('(may not always be accurate on busy sites)', 'wp-super-cache');
?>
</small>
</p><?php
} else {
$start_date = get_option('wpsupercache_start');
if ($start_date) {
update_option('wpsupercache_start', $start_date);
update_option('wpsupercache_count', 0);
}
}
?>
</div>
</td></table>
<?php
wp_cache_files();
wsc_mod_rewrite();
wp_cache_edit_max_time();
echo '<a name="files"></a><fieldset class="options"><h3>' . __('Accepted Filenames & Rejected URIs', 'wp-super-cache') . '</h3>';
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_debug_settings();
wp_lock_down();
wp_cache_restore();
ob_start();
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 '<fieldset class="options"><h3>' . __('Cache Plugins', 'wp-super-cache') . '</h3>';
echo $out;
echo '</fieldset>';
}
echo "</div>\n";
}
示例2: wp_cache_manager
//.........这里部分代码省略.........
case 'wpcache':
wp_cache_enable();
wp_super_cache_disable();
break;
}
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 = ' . (int) $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 {
$wp_cache_clear_on_post_edit = 0;
}
wp_cache_replace_line('^ *\\$wp_cache_clear_on_post_edit', "\$wp_cache_clear_on_post_edit = " . $wp_cache_clear_on_post_edit . ";", $wp_cache_config_file);
}
if (isset($_POST['cache_compression']) && $_POST['cache_compression'] != $cache_compression) {
$cache_compression_changed = true;
$cache_compression = intval($_POST['cache_compression']);
wp_cache_replace_line('^ *\\$cache_compression', "\$cache_compression = " . $cache_compression . ";", $wp_cache_config_file);
if (function_exists('prune_super_cache')) {
prune_super_cache($cache_path, true);
}
delete_option('super_cache_meta');
}
}
?>
<fieldset class="options">
<h3>WP Super Cache Status</h3><?php
echo '<form name="wp_manager" action="' . $_SERVER["REQUEST_URI"] . '" method="post">';
?>
<label><input type='radio' name='wp_cache_status' value='all' <?php
if ($cache_enabled == true && $super_cache_enabled == true) {
echo 'checked=checked';
}
?>
> <strong>ON</strong> (WP Cache and Super Cache enabled)</label><br />
<label><input type='radio' name='wp_cache_status' value='wpcache' <?php
if ($cache_enabled == true && $super_cache_enabled == false) {
echo 'checked=checked';
}
?>
> <strong>HALF ON</strong> (Super Cache Disabled, only legacy WP-Cache caching.)</label><br />
<label><input type='radio' name='wp_cache_status' value='none' <?php
if ($cache_enabled == false) {
echo 'checked=checked';
}
?>
> <strong>OFF</strong> (WP Cache and Super Cache disabled)</label><br />
<p><label><input type='checkbox' name='wp_cache_hello_world' <?php
if ($wp_cache_hello_world) {
echo "checked";
}
?>
value='1'> Proudly tell the world your server is Digg proof! (places a message in your blog's footer)</label></p>
<p><label><input type='checkbox' name='wp_cache_clear_on_post_edit' <?php
if ($wp_cache_clear_on_post_edit) {
echo "checked";
}
?>
value='1'> Clear all cache files when a post or page is published. (This may significantly slow down saving of posts.)</label></p>
<p>Note: if uninstalling this plugin, make sure the directory <em><?php
echo WP_CONTENT_DIR;
?>
</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 too is probably a good idea!)</p>
<?php
echo "<div><input type='submit' " . SUBMITDISABLED . " value='Update Status »' /></div>";
wp_nonce_field('wp-cache');
?>
</form>
</fieldset>
<?php
wsc_mod_rewrite();
wp_cache_edit_max_time();
echo '<br /><a name="files"></a><fieldset class="options"><h3>Accepted filenames, rejected URIs</h3>';
wp_cache_edit_rejected();
echo "<br />\n";
wp_cache_edit_accepted();
echo '</fieldset>';
wp_cache_edit_rejected_ua();
wp_cache_files();
wp_lock_down();
wp_cache_restore();
ob_start();
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 '<fieldset class="options"><h3>Cache Plugins</h3>';
echo $out;
echo '</fieldset>';
}
echo "</div>\n";
}
示例3: wp_cache_phase2
function wp_cache_phase2()
{
global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_gmt_offset, $wp_cache_blog_charset, $wp_cache_last_gc;
global $cache_max_time;
$wp_cache_gmt_offset = get_option('gmt_offset');
// caching for later use when wpdb is gone. http://wordpress.org/support/topic/224349
$wp_cache_blog_charset = get_option('blog_charset');
wp_cache_mutex_init();
if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) {
// Post ID is received
add_action('publish_post', 'wp_cache_post_edit', 0);
add_action('edit_post', 'wp_cache_post_change', 0);
// leaving a comment called edit_post
add_action('delete_post', 'wp_cache_post_edit', 0);
add_action('publish_phone', 'wp_cache_post_edit', 0);
// Coment ID is received
add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99);
add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99);
add_action('comment_post', 'wp_cache_get_postid_from_comment', 99);
add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99);
add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99);
// No post_id is available
add_action('delete_comment', 'wp_cache_no_postid', 99);
add_action('switch_theme', 'wp_cache_no_postid', 99);
add_action('wp_cache_gc', 'wp_cache_gc_cron');
do_cacheaction('add_cacheaction');
}
if ($_SERVER["REQUEST_METHOD"] == 'POST' || get_option('gzipcompression')) {
return;
}
$script = basename($_SERVER['PHP_SELF']);
if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($_SERVER["REQUEST_URI"])) {
return;
}
if (wp_cache_user_agent_is_rejected()) {
return;
}
if ($wp_cache_gzip_encoding) {
header('Vary: Accept-Encoding, Cookie');
} else {
header('Vary: Cookie');
}
ob_start('wp_cache_ob_callback');
// restore old supercache file temporarily
if ($super_cache_enabled && $cache_rebuild_files) {
$user_info = wp_cache_get_cookies_values();
$do_cache = apply_filters('do_createsupercache', $user_info);
if ($user_info == '' || $do_cache === true) {
$dir = get_current_url_supercache_dir();
$files_to_check = array($dir . 'index.html', $dir . 'index.html.gz');
foreach ($files_to_check as $cache_file) {
if (!@file_exists($cache_file . '.needs-rebuild')) {
continue;
}
$mtime = @filemtime($cache_file . '.needs-rebuild');
if ($mtime && time() - $mtime < 30) {
@rename($cache_file . '.needs-rebuild', $cache_file);
}
// cleanup old files or if rename fails
if (@file_exists($cache_file . '.needs-rebuild')) {
@unlink($cache_file . '.needs-rebuild');
}
}
}
}
if (!isset($cache_max_time)) {
$cache_max_time = 600;
}
$last_gc = get_option("wpsupercache_gc_time");
if (!$last_gc) {
update_option('wpsupercache_gc_time', time());
}
$next_gc = $cache_max_time < 1800 ? $cache_max_time : 600;
if ($last_gc < time() - $next_gc) {
update_option('wpsupercache_gc_time', time());
global $wp_cache_shutdown_gc;
if (!isset($wp_cache_shutdown_gc) || $wp_cache_shutdown_gc == 0) {
if (!wp_next_scheduled('wp_cache_gc')) {
wp_schedule_single_event(time() + 10, 'wp_cache_gc');
}
} else {
global $time_to_gc_cache;
$time_to_gc_cache = 1;
// tell the "shutdown gc" to run!
}
}
}
示例4: wp_cache_phase2
function wp_cache_phase2()
{
global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_gmt_offset, $wp_cache_blog_charset, $wp_cache_last_gc;
global $cache_max_time, $wp_cache_not_logged_in, $wp_cache_request_uri, $super_cache_enabled;
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
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. http://wordpress.org/support/topic/224349
$wp_cache_blog_charset = get_option('blog_charset');
wp_cache_mutex_init();
if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Setting up WordPress actions', 5);
}
// Post ID is received
add_action('publish_post', 'wp_cache_post_edit', 0);
add_action('edit_post', 'wp_cache_post_change', 0);
// leaving a comment called edit_post
add_action('delete_post', 'wp_cache_post_edit', 0);
add_action('publish_phone', 'wp_cache_post_edit', 0);
// Coment ID is received
add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99);
add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99);
add_action('comment_post', 'wp_cache_get_postid_from_comment', 99);
add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99);
add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99, 2);
// No post_id is available
add_action('switch_theme', 'wp_cache_no_postid', 99);
add_action('edit_user_profile_update', 'wp_cache_no_postid', 99);
add_action('wp_cache_gc', 'wp_cache_gc_cron');
do_cacheaction('add_cacheaction');
}
if (is_admin()) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Not caching wp-admin requests.', 5);
}
return false;
}
if ($_SERVER["REQUEST_METHOD"] == 'POST' || !empty($_POST) || get_option('gzipcompression')) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Not caching POST request.', 5);
}
return false;
}
if (isset($_GET['preview'])) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Not caching preview post.', 2);
}
return false;
}
if (!empty($_GET)) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Supercache caching disabled. Non empty GET request.', 5);
}
$super_cache_enabled = false;
}
if ($wp_cache_not_logged_in && is_user_logged_in() && !is_feed() && !is_admin()) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('not caching for logged in user', 5);
register_shutdown_function('wpcache_logged_in_message');
}
return false;
}
$script = basename($_SERVER['PHP_SELF']);
if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('URI rejected. Not Caching', 2);
}
return false;
}
if (wp_cache_user_agent_is_rejected()) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("USER AGENT ({$_SERVER['HTTP_USER_AGENT']}) rejected. Not Caching", 4);
}
return;
}
if ($wp_cache_gzip_encoding) {
header('Vary: Accept-Encoding, Cookie');
} else {
header('Vary: Cookie');
}
ob_start('wp_cache_ob_callback');
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Created output buffer', 4);
}
// restore old supercache file temporarily
if ($super_cache_enabled && $cache_rebuild_files) {
$user_info = wp_cache_get_cookies_values();
$do_cache = apply_filters('do_createsupercache', $user_info);
if ($user_info == '' || $do_cache === true) {
$dir = get_current_url_supercache_dir();
$files_to_check = array($dir . 'index.html', $dir . 'index.html.gz');
foreach ($files_to_check as $cache_file) {
if (!@file_exists($cache_file . '.needs-rebuild')) {
continue;
}
$mtime = @filemtime($cache_file . '.needs-rebuild');
if ($mtime && time() - $mtime < 30) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
//.........这里部分代码省略.........
示例5: wp_cache_manager
//.........这里部分代码省略.........
}
?>
value='0'> Coarse file locking. You probably don't need this but it may help if your server is underpowered. Warning! <em>May cause your server to lock up in very rare cases!</em></label></p>
<p><label><input type='checkbox' name='wp_cache_mobile_enabled' <?php
if ($wp_cache_mobile_enabled) {
echo "checked";
}
?>
value='1'> Mobile device support. Plugin will enter "Half-On" mode.</label></p>
<p><strong>Note:</strong> If uninstalling this plugin, make sure the directory <em><?php
echo WP_CONTENT_DIR;
?>
</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 too is probably a good idea!)</p>
<?php
echo "<div class='submit'><input type='submit' " . SUBMITDISABLED . " value='Update Status »' /></div>";
wp_nonce_field('wp-cache');
?>
</form>
<?php
if ($super_cache_enabled && function_exists('apache_get_modules')) {
$mods = apache_get_modules();
$required_modules = array('mod_mime' => 'Required to serve compressed supercache files properly.', 'mod_headers' => 'Required to set caching information on supercache pages. IE7 users will see old pages without this module.', 'mod_expires' => 'Set the expiry date on supercached pages. Visitors may not see new pages when they refresh or leave comments without this module.');
foreach ($required_modules as $req => $desc) {
if (!in_array($req, $mods)) {
$missing_mods[$req] = $desc;
}
}
if (is_array($missing_mods)) {
echo "<h3>Missing Apache Modules</h3>";
echo "<p>The following Apache modules are missing. The plugin will work in half-on mode without them. In full Supercache mode, your visitors may see corrupted pages or out of date content however.</p>";
echo "<ul>";
foreach ($missing_mods as $req => $desc) {
echo "<li> {$req} - {$desc}</li>";
}
echo "</ul>";
}
}
?>
</fieldset>
</td><td valign='top'>
<div style='background: #ffc; border: 1px solid #333; margin: 2px; padding: 5px'>
<h3 align='center'>Make WordPress Faster</h3>
<?php
if ($wp_cache_hide_donation != 1) {
?>
<p><a href="http://ocaoimh.ie/wp-super-cache/?r=wpsc">WP Super Cache</a> makes your blog go faster. Think that's worth $10? Click the "Donate" button below.</p>
<p>Thanks!<br />Donncha O Caoimh.<br /></p>
<div align='center'>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick"/>
<input type="hidden" name="hosted_button_id" value="3244504"/>
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt=""/>
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"/><br />
</form>
<p>Don't show me this again. <form action="<?php
echo $_SERVER["REQUEST_URI"];
?>
" method="post"><input type='hidden' name='wp_cache_hide_donation' value='1' /><input type='submit' value='Hide' /><?php
wp_nonce_field('wp-cache');
?>
</form></p>
</div>
<?php
} else {
?>
<p><a href="http://ocaoimh.ie/wp-super-cache/?r=supercache">WP Super Cache</a> is maintained and developed by <a href="http://ocaoimh.ie/?r=supercache">Donncha O Caoimh</a> with contributions from many others thanks to the GPL.</p>
<p>He blogs at <a href="http://ocaoimh.ie/?r=supercache">Holy Shmoly</a> and posts photos at <a href="http://inphotos.org/?r=supercache">In Photos.org</a>. You can say hi to him on <a href="http://twitter.com/donncha/">Twitter</a> too!</p>
<?php
}
?>
</div>
</td></table>
<?php
wp_cache_files();
wsc_mod_rewrite();
wp_cache_edit_max_time();
echo '<a name="files"></a><fieldset class="options"><h3>Accepted Filenames & Rejected URIs</h3>';
wp_cache_edit_rejected();
echo "\n";
wp_cache_edit_accepted();
echo '</fieldset>';
wp_cache_edit_rejected_ua();
wp_lock_down();
wp_cache_restore();
ob_start();
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 '<fieldset class="options"><h3>Cache Plugins</h3>';
echo $out;
echo '</fieldset>';
}
echo "</div>\n";
}
示例6: wpsc_plugins_tab
function wpsc_plugins_tab()
{
echo '<p>' . __('Cache plugins are PHP scripts that live in a plugins folder inside the wp-super-cache folder. They are loaded when Supercache loads, much sooner than regular WordPress plugins.', 'wp-super-cache') . '</p>';
echo '<p>' . __('This is strictly an advanced feature only and knowledge of both PHP and WordPress actions is required to create them.', 'wp-super-cache') . '</p>';
ob_start();
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 '<h3>' . __('Available Plugins', 'wp-super-cache') . '</h3>';
echo "<ol>";
echo $out;
echo "</ol>";
}
}
示例7: wp_cache_manager
//.........这里部分代码省略.........
<input type="hidden" name="cmd" value="_s-xclick"/>
<input type="hidden" name="hosted_button_id" value="3244504"/>
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" border="0" name="submit" alt=""/>
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"/><br />
</form>
<p><?php
_e('Don’t show me this again.', 'wp-super-cache');
?>
<form action="#top" method="post"><input type='hidden' name='wp_cache_hide_donation' value='1' /><input type='submit' value='<?php
_e('Hide', 'wp-super-cache');
?>
' /><?php
wp_nonce_field('wp-cache');
?>
</form></p>
</div>
<?php
} else {
?>
<p><?php
printf(__('%1$s is maintained and developed by %2$s with contributions from many others.', 'wp-super-cache'), '<a href="http://ocaoimh.ie/wp-super-cache/?r=supercache">WP Super Cache</a>', '<a href="http://ocaoimh.ie/?r=supercache">Donncha O Caoimh</a>');
?>
</p>
<p><?php
printf(__('He blogs at %1$s and posts photos at %2$s. He would really appreciate a <a href="%3$s">donation</a> to encourage development of this plugin.<br />Even a penny will help.', 'wp-super-cache'), '<a href="http://ocaoimh.ie/?r=supercache">Holy Shmoly</a>', '<a href="http://inphotos.org/?r=supercache">In Photos.org</a>', 'http://ocaoimh.ie/gad');
?>
</p>
<p><?php
printf(__('Please say hi to him on %s too!', 'wp-super-cache'), '<a href="http://twitter.com/donncha/">Twitter</a>');
?>
</p>
<?php
}
if (isset($wp_supercache_cache_list) && $wp_supercache_cache_list) {
$start_date = get_option('wpsupercache_start');
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']) . "'>{$url['url']}</a></li>\n";
}
?>
</ol>
<small><?php
_e('(may not always be accurate on busy sites)', 'wp-super-cache');
?>
</small>
</p><?php
} else {
$start_date = get_option('wpsupercache_start');
if ($start_date) {
update_option('wpsupercache_start', $start_date);
update_option('wpsupercache_count', 0);
}
}
?>
</div>
</td></table>
<?php
wp_cache_files();
wsc_mod_rewrite();
wp_cache_edit_max_time();
echo '<a name="files"></a><fieldset class="options"><h3>' . __('Accepted Filenames & Rejected URIs', 'wp-super-cache') . '</h3>';
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_debug_settings();
wp_lock_down();
wp_cache_restore();
ob_start();
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 '<fieldset class="options"><h3>' . __('Cache Plugins', 'wp-super-cache') . '</h3>';
echo $out;
echo '</fieldset>';
}
echo "</div>\n";
}
示例8: wp_supercache_cache_for_admins
function wp_supercache_cache_for_admins()
{
if (isset($_GET['preview']) || function_exists("is_admin") && is_admin()) {
return true;
}
if (false == do_cacheaction('wp_supercache_remove_cookies', true)) {
return true;
}
$cookie_keys = array('wordpress_logged_in', 'comment_author_');
if (defined('LOGGED_IN_COOKIE')) {
$cookie_keys[] = constant('LOGGED_IN_COOKIE');
}
reset($_COOKIE);
foreach ($_COOKIE as $cookie => $val) {
reset($cookie_keys);
foreach ($cookie_keys as $key) {
if (strpos($cookie, $key) !== FALSE) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Removing auth from $_COOKIE to allow caching for logged in user (' . $cookie . ')', 5);
}
unset($_COOKIE[$cookie]);
}
}
}
}
示例9: wp_cache_phase2
function wp_cache_phase2()
{
global $wpsc_settings;
global $cache_filename, $cache_acceptable_files, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files, $wp_cache_last_gc;
global $cache_max_time, $wp_cache_request_uri, $super_cache_enabled, $wp_cache_object_cache, $cache_time_interval;
global $cache_enabled, $wp_cache_gmt_offset, $wp_cache_blog_charset, $cache_schedule_type, $cache_scheduled_time, $cache_schedule_interval;
if ($cache_enabled == false) {
return false;
}
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
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. http://wordpress.org/support/topic/224349
$wp_cache_blog_charset = get_option('blog_charset');
wp_cache_mutex_init();
if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Setting up WordPress actions', 5);
}
// Post ID is received
add_action('publish_post', 'wp_cache_post_edit', 0);
add_action('edit_post', 'wp_cache_post_change', 0);
// leaving a comment called edit_post
add_action('delete_post', 'wp_cache_post_edit', 0);
add_action('publish_phone', 'wp_cache_post_edit', 0);
// Coment ID is received
add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99);
add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99);
add_action('comment_post', 'wp_cache_get_postid_from_comment', 99);
add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99);
add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99, 2);
// No post_id is available
add_action('switch_theme', 'wp_cache_no_postid', 99);
add_action('edit_user_profile_update', 'wp_cache_no_postid', 99);
add_action('wp_update_nav_menu', 'wp_cache_clear_cache');
add_action('wp_cache_gc', 'wp_cache_gc_cron');
add_filter('supercache_filename_str', 'wp_cache_check_mobile');
do_cacheaction('add_cacheaction');
}
if (is_admin()) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Not caching wp-admin requests.', 5);
}
return false;
}
if ($_SERVER["REQUEST_METHOD"] == 'POST' || !empty($_POST) || get_option('gzipcompression')) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Not caching POST request.', 5);
}
return false;
}
if ($wp_cache_object_cache && !empty($_GET)) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Not caching GET request while object cache storage enabled.', 5);
}
return false;
}
if (isset($_GET['preview'])) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Not caching preview post.', 2);
}
return false;
}
if (!empty($_GET)) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Supercache caching disabled. Only using wp-cache. Non empty GET request.', 5);
}
$super_cache_enabled = false;
}
$script = basename($_SERVER['PHP_SELF']);
if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($wp_cache_request_uri)) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('URI rejected. Not Caching', 2);
}
return false;
}
if (wp_cache_user_agent_is_rejected()) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("USER AGENT ({$_SERVER['HTTP_USER_AGENT']}) rejected. Not Caching", 4);
}
return;
}
if ($wp_cache_gzip_encoding) {
header('Vary: Accept-Encoding, Cookie');
} else {
header('Vary: Cookie');
}
ob_start('wp_cache_ob_callback');
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug('Created output buffer', 4);
}
// restore old supercache file temporarily
if ($super_cache_enabled && $cache_rebuild_files) {
$user_info = wp_cache_get_cookies_values();
$do_cache = apply_filters('do_createsupercache', $user_info);
if ($user_info == '' || $do_cache === true) {
wpcache_do_rebuild(get_current_url_supercache_dir());
}
}
//.........这里部分代码省略.........
示例10: wpsc_plugins_tab
function wpsc_plugins_tab()
{
echo '<p>' . __('Cache plugins are PHP scripts that live in a plugins folder inside the wp-super-cache folder. They are loaded when Supercache loads, much sooner than regular WordPress plugins.', 'wp-super-cache') . '</p>';
echo '<p>' . __('This is strictly an advanced feature only and knowledge of both PHP and WordPress actions is required to create them.', 'wp-super-cache') . '</p>';
echo '<p>' . __('<strong>Warning</strong>! Due to the way WordPress upgrades plugins, the plugins you upload to wp-super-cache/plugins/ will be deleted when you upgrade WP Super Cache. You can avoid this by loading the plugins from elsewhere. Set <strong>$wp_cache_plugins_dir</strong> to the new location in wp-config.php and WP Super Cache will look there instead.<br />More info available in the <a href="http://ocaoimh.ie/wp-super-cache-developers/">developer documentation</a>.', 'wp-super-cache') . '</p>';
ob_start();
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 '<h3>' . __('Available Plugins', 'wp-super-cache') . '</h3>';
echo "<ol>";
echo $out;
echo "</ol>";
}
}
示例11: wp_cache_get_cookies_values
function wp_cache_get_cookies_values()
{
$string = '';
while ($key = key($_COOKIE)) {
if (preg_match("/^wp-postpass|^wordpress_logged_in|^comment_author_/", $key)) {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Cookie detected: {$key}", 5);
}
$string .= $_COOKIE[$key] . ",";
}
next($_COOKIE);
}
reset($_COOKIE);
// If you use this hook, make sure you update your .htaccess rules with the same conditions
$string = do_cacheaction('wp_cache_get_cookies_values', $string);
return $string;
}
示例12: wp_cache_get_cookies_values
function wp_cache_get_cookies_values()
{
$string = '';
while ($key = key($_COOKIE)) {
if (preg_match("/^wp-postpass|^wordpress|^comment_author_/", $key)) {
$string .= $_COOKIE[$key] . ",";
}
next($_COOKIE);
}
reset($_COOKIE);
// If you use this hook, make sure you update your .htaccess rules with the same conditions
$string = do_cacheaction('wp_cache_get_cookies_values', $string);
return $string;
}
示例13: supercache_filename
function supercache_filename()
{
//Add support for https and http caching
$is_https = 'on' == strtolower($_SERVER['HTTPS']) || 'https' == strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']);
//Also supports https requests coming from an nginx reverse proxy
$extra_str = $is_https ? '-https' : '';
if (function_exists("apply_filters")) {
$extra_str = apply_filters('supercache_filename_str', $extra_str);
} else {
$extra_str = do_cacheaction('supercache_filename_str', $extra_str);
}
$filename = 'index' . $extra_str . '.html';
return $filename;
}
示例14: wp_cache_get_ob
//.........这里部分代码省略.........
}
$added_cache = 0;
$oc_key = get_oc_key();
$buffer = apply_filters('wpsupercache_buffer', $buffer);
wp_cache_append_tag($buffer);
/*
* Dynamic content enabled: write the buffer to a file and then process any templates found using
* the wpsc_cachedata filter. Buffer is then returned to the visitor.
*/
if ($wp_cache_mfunc_enabled == 1) {
if (preg_match('/<!--mclude|<!--mfunc|<!--dynamic-cached-content-->/', $buffer)) {
//Dynamic content
wp_cache_debug("mfunc/mclude/dynamic-cached-content tags have been retired. Please update your theme. See docs for updates.");
wp_cache_add_to_buffer($buffer, "Warning! Obsolete mfunc/mclude/dynamic-cached-content tags found. Please update your theme. See http://ocaoimh.ie/y/5b for more information.");
}
global $wp_super_cache_late_init;
if (false == isset($wp_super_cache_late_init) || isset($wp_super_cache_late_init) && $wp_super_cache_late_init == 0) {
wp_cache_add_to_buffer($buffer, 'Super Cache dynamic page detected but late init not set. See the readme.txt for further details.');
}
if ($fr) {
// legacy caching
wp_cache_debug("Writing dynamic buffer to legacy file.");
wp_cache_add_to_buffer($buffer, "Dynamic Legacy Super Cache");
fputs($fr, $buffer);
} elseif (isset($fr2)) {
// supercache active
wp_cache_debug("Writing dynamic buffer to supercache file.");
wp_cache_add_to_buffer($buffer, "Dynamic Super Cache");
fputs($fr2, $buffer);
} elseif (true == $wp_cache_object_cache) {
wp_cache_set($oc_key, $buffer, 'supercache', $cache_max_time);
}
$wp_cache_meta['dynamic'] = true;
if (do_cacheaction('wpsc_cachedata_safety', 0) === 1) {
$buffer = do_cacheaction('wpsc_cachedata', $buffer);
}
// dynamic content for display
if ($cache_compression && $wp_cache_gzip_encoding) {
wp_cache_debug("Gzipping dynamic buffer for display.", 5);
wp_cache_add_to_buffer($buffer, "Compression = gzip");
$gzdata = gzencode($buffer, 6, FORCE_GZIP);
$gzsize = function_exists('mb_strlen') ? mb_strlen($gzdata, '8bit') : strlen($gzdata);
}
} else {
if ($gz || $wp_cache_gzip_encoding) {
wp_cache_debug("Gzipping buffer.", 5);
wp_cache_add_to_buffer($buffer, "Compression = gzip");
$gzdata = gzencode($buffer, 6, FORCE_GZIP);
$gzsize = function_exists('mb_strlen') ? mb_strlen($gzdata, '8bit') : strlen($gzdata);
$wp_cache_meta['headers']['Content-Encoding'] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
$wp_cache_meta['headers']['Vary'] = 'Vary: Accept-Encoding, Cookie';
// Return uncompressed data & store compressed for later use
if ($fr) {
wp_cache_debug("Writing gzipped buffer to wp-cache cache file.", 5);
fputs($fr, $gzdata);
} elseif ($cache_enabled && $wp_cache_object_cache) {
wp_cache_set($oc_key . ".gz", $gzdata, 'supercache', $cache_max_time);
$added_cache = 1;
}
} else {
// no compression
$wp_cache_meta['headers']['Vary'] = 'Vary: Cookie';
if ($cache_enabled && $wp_cache_object_cache) {
wp_cache_set($oc_key, $buffer, 'supercache', $cache_max_time);
$added_cache = 1;
} elseif ($fr) {
示例15: wp_cache_phase2
function wp_cache_phase2()
{
global $cache_filename, $cache_acceptable_files, $wp_cache_meta_object, $wp_cache_gzip_encoding, $super_cache_enabled, $cache_rebuild_files;
wp_cache_mutex_init();
if (function_exists('add_action') && (!defined('WPLOCKDOWN') || defined('WPLOCKDOWN') && constant('WPLOCKDOWN') == '0')) {
// Post ID is received
add_action('publish_post', 'wp_cache_post_edit', 0);
add_action('edit_post', 'wp_cache_post_change', 0);
// leaving a comment called edit_post
add_action('delete_post', 'wp_cache_post_edit', 0);
add_action('publish_phone', 'wp_cache_post_edit', 0);
// Coment ID is received
add_action('trackback_post', 'wp_cache_get_postid_from_comment', 0);
add_action('pingback_post', 'wp_cache_get_postid_from_comment', 0);
add_action('comment_post', 'wp_cache_get_postid_from_comment', 0);
add_action('edit_comment', 'wp_cache_get_postid_from_comment', 0);
add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 0);
// No post_id is available
add_action('delete_comment', 'wp_cache_no_postid', 0);
add_action('switch_theme', 'wp_cache_no_postid', 0);
add_action('wp_cache_gc', 'wp_cache_gc_cron');
do_cacheaction('add_cacheaction');
}
if ($_SERVER["REQUEST_METHOD"] == 'POST' || get_option('gzipcompression')) {
return;
}
$script = basename($_SERVER['PHP_SELF']);
if (!in_array($script, $cache_acceptable_files) && wp_cache_is_rejected($_SERVER["REQUEST_URI"])) {
return;
}
if (wp_cache_user_agent_is_rejected()) {
return;
}
if (!is_object($wp_cache_meta_object)) {
$wp_cache_meta_object = new CacheMeta();
}
if ($wp_cache_gzip_encoding) {
header('Vary: Accept-Encoding, Cookie');
} else {
header('Vary: Cookie');
}
ob_start('wp_cache_ob_callback');
// restore old supercache file temporarily
if ($super_cache_enabled && $cache_rebuild_files) {
$user_info = wp_cache_get_cookies_values();
$do_cache = apply_filters('do_createsupercache', $user_info);
if ($user_info == '' || $do_cache === true) {
$dir = get_current_url_supercache_dir();
$files_to_check = array($dir . 'index.html', $dir . 'index.html.gz');
foreach ($files_to_check as $cache_file) {
if (!file_exists($cache_file . '.needs-rebuild')) {
continue;
}
$mtime = @filemtime($cache_file . '.needs-rebuild');
if ($mtime && time() - $mtime < 30) {
@rename($cache_file . '.needs-rebuild', $cache_file);
}
// cleanup old files or if rename fails
if (@file_exists($cache_file . '.needs-rebuild')) {
@unlink($cache_file . '.needs-rebuild');
}
}
}
}
register_shutdown_function('wp_cache_shutdown_callback');
}