本文整理汇总了PHP中add_cacheaction函数的典型用法代码示例。如果您正苦于以下问题:PHP add_cacheaction函数的具体用法?PHP add_cacheaction怎么用?PHP add_cacheaction使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_cacheaction函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _e
<label><input type="radio" name="cache_no_adverts_for_friends" value="0" <?php
if ($cache_no_adverts_for_friends == 'no') {
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="http://ocaoimh.ie/no-adverts-for-friends/">No Adverts for Friends</a>.', 'wp-super-cache') . '</p>';
if (isset($changed) && $changed) {
if ('yes' == $cache_no_adverts_for_friends) {
$status = __("enabled");
} else {
$status = __("disabled");
}
echo "<p><strong>" . sprintf(__("No Adverts for Friends support is now %s", 'wp-super-cache'), $status) . "</strong></p>";
}
echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __('Update', 'wp-super-cache') . '" /></div>';
wp_nonce_field('wp-cache');
?>
</form>
</fieldset>
<?php
}
add_cacheaction('cache_admin_page', 'wp_supercache_searchengine_admin');
示例2: _e
<label><input type="radio" name="cache_awaitingmoderation" value="0" <?php
if (!$cache_awaitingmoderation) {
echo 'checked="checked" ';
}
?>
/> <?php
_e('Disabled', 'wp-super-cache');
?>
</label>
<p><?php
_e('Enables or disables plugin to Remove the text "Your comment is awaiting moderation." when someone leaves a moderated comment.', 'wp-super-cache');
?>
</p>
<?php
if ($changed) {
if ($cache_awaitingmoderation) {
$status = __("enabled");
} else {
$status = __("disabled");
}
echo "<p><strong>" . sprintf(__("Awaiting Moderation is now %s", 'wp-super-cache'), $status) . "</strong></p>";
}
echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __('Update', 'wp-super-cache') . '" /></div>';
wp_nonce_field('wp-cache');
?>
</form>
</fieldset>
<?php
}
add_cacheaction('cache_admin_page', 'wp_supercache_awaitingmoderation_admin');
示例3: sprintf
}
echo '<strong>' . sprintf(__('<a href="http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/">Domain Mapping</a> support plugin is %s', 'wp-super-cache'), $status);
echo '.</strong> ' . __('(support for multiple domains on multisite websites) ', 'wp-super-cache');
if ($cache_domain_mapping == '0') {
echo '<input type="submit" name="cache_domain_mapping" value="' . __('Enable', 'wp-super-cache') . '" />';
} else {
echo '<input type="submit" name="cache_domain_mapping" value="' . __('Disable', 'wp-super-cache') . '" />';
}
echo "</form></li>\n";
}
add_cacheaction('cache_admin_page', 'wp_supercache_domain_mapping_admin');
function wp_supercache_domain_mapping_notice()
{
global $cache_enabled, $cache_domain_mapping;
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>';
}
}
function wp_supercache_domain_mapping_exists()
{
global $cache_domain_mapping;
if ($cache_domain_mapping == 1) {
return false;
}
if (is_admin() && function_exists('domain_mapping_warning')) {
add_action('admin_notices', 'wp_supercache_domain_mapping_notice');
}
}
if (isset($_GET['page']) && $_GET['page'] == 'wpsupercache') {
add_cacheaction('add_cacheaction', 'wp_supercache_domain_mapping_exists');
}
示例4: gzip_accepted
$gzsize = 0;
function gzip_accepted()
{
if (1 == ini_get('zlib.output_compression') || "on" == strtolower(ini_get('zlib.output_compression'))) {
// don't compress WP-Cache data files when PHP is already doing it
return false;
}
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) || isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === false) {
return false;
}
return 'gzip';
}
if ($cache_compression) {
$wp_cache_gzip_encoding = gzip_accepted();
}
add_cacheaction('supercache_filename_str', 'wp_cache_check_mobile');
$wp_cache_request_uri = $_SERVER['REQUEST_URI'];
// Cache this in case any plugin modifies it.
if ($wp_cache_object_cache) {
if (!(include_once WP_CONTENT_DIR . '/object-cache.php')) {
return;
}
wp_cache_init();
// Note: wp-settings.php calls wp_cache_init() which clobbers the object made here.
if (!is_object($wp_object_cache)) {
return;
}
}
function setup_blog_cache_dir()
{
global $blog_cache_dir, $cache_path;
示例5: _e
}
?>
/> <?php
_e('Disabled', 'wp-super-cache');
?>
</label>
<p><?php
_e('', 'wp-super-cache');
?>
</p><?php
echo '<p>' . sprintf(__('(Only legacy caching supported, disabled compression and requires <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> in "%s/plugins/bad-behavior/") ', 'wp-super-cache'), WP_CONTENT_DIR) . '</p>';
if (isset($changed) && $changed) {
if ($cache_badbehaviour) {
$status = __("enabled");
} else {
$status = __("disabled");
}
echo "<p><strong>" . sprintf(__("Bad Behavior 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>
</fieldset>
<?php
if ($err) {
echo "<p><strong>" . __('Warning!', 'wp-super-cache') . "</strong> {$err}</p>";
}
}
add_cacheaction('cache_admin_page', 'wp_supercache_badbehaviour_admin');
示例6: add_action
if (file_exists($theme_functions_persist = str_replace('/', DIRECTORY_SEPARATOR, get_theme_root()) . DIRECTORY_SEPARATOR . 'mobile_pack_base' . DIRECTORY_SEPARATOR . 'functions_persist.php')) {
include_once $theme_functions_persist;
}
add_action('init', 'wpmp_switcher_init');
add_action('admin_menu', 'wpmp_switcher_admin_menu');
add_action('wp_footer', 'wpmp_switcher_wp_footer');
add_filter('stylesheet', 'wpmp_switcher_stylesheet');
add_filter('template', 'wpmp_switcher_template');
add_filter('option_home', 'wpmp_switcher_option_home_siteurl');
add_filter('option_siteurl', 'wpmp_switcher_option_home_siteurl');
if (function_exists('add_cacheaction')) {
// WP Super Cache integration
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("Adding hook for wpmp mobile detection", 5);
}
add_cacheaction('wp_cache_get_cookies_values', 'wpmp_switcher_wp_cache_check_mobile');
}
function wpmp_switcher_init()
{
wp_register_sidebar_widget('wpmp_switcher_widget_link', __('Mobile Switcher Link', 'wpmp'), 'wpmp_switcher_widget_link', array('classname' => 'wpmp_switcher_widget_link', 'description' => __("A link that allows users to toggle between desktop and mobile sites (when a switcher mode is enabled)", 'wpmp')));
switch ($switcher_outcome = wpmp_switcher_outcome()) {
case WPMP_SWITCHER_NO_SWITCH:
break;
case WPMP_SWITCHER_DESKTOP_PAGE:
wpmp_switcher_hit('desktop');
wpmp_switcher_set_cookie('desktop');
break;
case WPMP_SWITCHER_MOBILE_PAGE:
wpmp_switcher_hit('mobile');
wpmp_switcher_set_cookie('mobile');
if (strpos(strtolower($_SERVER['REQUEST_URI']), '/wp-login.php') !== false) {
示例7: add_cacheaction
<?php
if (defined('WP_ALLOW_MULTISITE')) {
add_cacheaction('add_cacheaction', 'wp_super_cache_multisite_init');
}
function wp_super_cache_multisite_init()
{
add_filter('wpmu_blogs_columns', 'wp_super_cache_blogs_col');
add_action('manage_sites_custom_column', 'wp_super_cache_blogs_field', 10, 2);
add_action('init', 'wp_super_cache_override_on_flag');
}
function wp_super_cache_blogs_col($col)
{
$col['wp_super_cache'] = __('Cached', 'wp-super-cache');
return $col;
}
function wp_super_cache_blogs_field($name, $blog_id)
{
if ($name != 'wp_super_cache') {
return false;
}
if (isset($_GET['id']) && $blog_id == $_GET['id']) {
$valid_nonce = isset($_GET['_wpnonce']) ? wp_verify_nonce($_GET['_wpnonce'], 'wp-cache' . $_GET['id']) : false;
if ($valid_nonce && isset($_GET['action']) && $_GET['action'] == 'disable_cache') {
add_blog_option($_GET['id'], 'wp_super_cache_disabled', 1);
} elseif ($valid_nonce && isset($_GET['action']) && $_GET['action'] == 'enable_cache') {
delete_blog_option($_GET['id'], 'wp_super_cache_disabled');
}
}
if (get_blog_option($blog_id, 'wp_super_cache_disabled') == 1) {
echo "<a href='" . wp_nonce_url(add_query_arg(array('action' => 'enable_cache', 'id' => $blog_id)), 'wp-cache' . $blog_id) . "'>" . __('Enable', 'wp-super-cache') . "</a>";
示例8: wp_nonce_field
wp_nonce_field('wp-cache');
?>
</form>
<?php
}
?>
</fieldset>
<?php
}
add_cacheaction('cache_admin_page', 'wp_super_cache_jetpack_admin');
function wp_super_cache_jetpack_cookie_check($cache_key)
{
if (file_exists(dirname(WPCACHEHOME) . '/jetpack/class.jetpack-user-agent.php')) {
if (function_exists("jetpack_is_mobile") == false) {
include dirname(WPCACHEHOME) . '/jetpack/class.jetpack-user-agent.php';
}
if (jetpack_is_mobile()) {
return 'mobile';
} else {
return 'normal';
}
} else {
if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
wp_cache_debug("wp_super_cache_jetpack_cookie_check: jetpack UA file not found.");
}
return "normal";
}
}
if (isset($cache_jetpack) && $cache_jetpack == 1) {
add_cacheaction('wp_cache_check_mobile', 'wp_super_cache_jetpack_cookie_check');
}
示例9: gzip_accepted
$gzsize = 0;
function gzip_accepted()
{
if (ini_get('zlib.output_compression')) {
// don't compress WP-Cache data files when PHP is already doing it
return false;
}
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === false) {
return false;
}
return 'gzip';
}
if ($cache_compression) {
$wp_cache_gzip_encoding = gzip_accepted();
}
add_cacheaction('wp_cache_key', 'wp_cache_check_mobile');
$key = $blogcacheid . md5(do_cacheaction('wp_cache_key', $_SERVER['HTTP_HOST'] . preg_replace('/#.*$/', '', str_replace('/index.php', '/', $_SERVER['REQUEST_URI'])) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values()));
if (false == @is_dir($blog_cache_dir)) {
@mkdir($cache_path . "blogs");
@mkdir($blog_cache_dir);
}
if (false == @is_dir($blog_cache_dir . 'meta')) {
@mkdir($blog_cache_dir . 'meta');
}
$cache_filename = $file_prefix . $key . '.html';
$meta_file = $file_prefix . $key . '.meta';
$cache_file = realpath($blog_cache_dir . $cache_filename);
$meta_pathname = realpath($blog_cache_dir . 'meta/' . $meta_file);
$wp_start_time = microtime();
if (file_exists($cache_file) && ($mtime = @filemtime($meta_pathname))) {
if ($mtime + $cache_max_time > time()) {
示例10: ob_start
ob_start();
// call the sidebar function, do something dynamic
echo "<p>This is a test. The current time on the server is: " . date('H:i:s') . "</p>";
$text = ob_get_contents();
ob_end_clean();
if ($cachedata === 0) {
// called directly from the theme so store the output
define('DYNAMIC_OB_TEXT', $text);
} else {
// called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php
return str_replace(DYNAMIC_OUTPUT_BUFFER_TAG, $text, $cachedata);
}
}
add_cacheaction('wpsc_cachedata', 'dynamic_output_buffer_test');
function dynamic_output_buffer_init()
{
add_action('wp_footer', 'dynamic_output_buffer_test');
}
add_cacheaction('add_cacheaction', 'dynamic_output_buffer_init');
function dynamic_output_buffer_test_safety($safety)
{
if (defined('DYNAMIC_OB_TEXT')) {
// this is set when you call dynamic_output_buffer_test() from the theme
return 1;
} else {
return 0;
}
// tag cannot be replaced.
}
add_cacheaction('wpsc_cachedata_safety', 'dynamic_output_buffer_test_safety');
}
示例11: wp_cache_replace_line
wp_cache_replace_line('^ *\\$orig_wp_cache_mobile_browsers', "\$orig_wp_cache_mobile_browsers = '{$wp_cache_mobile_browsers}';", $wp_cache_config_file);
}
wp_cache_replace_line('^ *\\$wp_cache_mobile_browsers ', "\$wp_cache_mobile_browsers = '{$ktaistyle_browsers}';", $wp_cache_config_file);
} elseif (isset($orig_wp_cache_mobile_browsers) && $orig_wp_cache_mobile_browsers != $ktaistyle_browsers) {
wp_cache_replace_line('^ *\\$wp_cache_mobile_browsers ', "\$wp_cache_mobile_browsers = '{$orig_wp_cache_mobile_browsers}';", $wp_cache_config_file);
wp_cache_replace_line('^ *\\$orig_wp_cache_mobile_browsers', '', $wp_cache_config_file);
}
}
echo '<form name="wp_supercache_ktaistyle_admin" action="' . $_SERVER["REQUEST_URI"] . '" method="post">';
wp_nonce_field('wp-cache');
if ($cache_ktaistyle == 0) {
$ks_status = __('disabled', 'wp-super-cache');
} else {
$ks_status = __('enabled', 'wp-super-cache');
wp_super_cache_disable();
}
echo '<strong>' . sprintf(__('Ktai Style support is %s', 'wp-super-cache'), $ks_status);
echo '.</strong>';
printf(__('(Changing supporting mobile devices. Requires <a href="http://wppluginsj.sourceforge.jp/ktai_style/">Ktai Style</a>.) ', 'wp-super-cache'));
if ($cache_ktaistyle == 0) {
echo '<input type="submit" name="cache_ktaistyle" value="' . __('Enable', 'wp-super-cache') . '" />';
} else {
echo '<input type="submit" name="cache_ktaistyle" value="' . __('Disable', 'wp-super-cache') . '" />';
}
echo "</form>\n";
if ($err) {
echo "<p><strong>" . __('Warning!', 'wp-super-cache') . "</strong> {$err}</p>";
}
}
add_cacheaction('cache_admin_page', 'wp_supercache_ktaistyle_admin');
}
示例12: presscore_sc_cachedata_filter
*/
function presscore_sc_cachedata_filter(&$cachedata)
{
if (!class_exists('Mobile_Detect')) {
include get_template_directory() . '/inc/extensions/mobile-detect.php';
}
$detect = new Mobile_Detect();
$device_type = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer';
$stylesheet = get_template_directory_uri();
$dynamic_scripts = array('desktop-tablet' => '<script type=\'text/javascript\' src=\'' . $stylesheet . '/js/desktop-tablet.js\'></script>', 'phone' => '<script type=\'text/javascript\' src=\'' . $stylesheet . '/js/phone.js\'></script>', 'desktop' => '<script type=\'text/javascript\' src=\'' . $stylesheet . '/js/desktop.js\'></script>');
$main = '<script type=\'text/javascript\' src=\'' . $stylesheet . '/js/main.js\'></script>';
$output = '';
// enqueue device specific scripts
switch ($device_type) {
case 'tablet':
$output .= $dynamic_scripts['desktop-tablet'];
break;
case 'phone':
$output .= $dynamic_scripts['phone'];
break;
default:
$output .= $dynamic_scripts['desktop-tablet'];
$output .= $dynamic_scripts['desktop'];
}
$output .= $main;
// remove cached scripts
$cachedata = str_replace(array_values($dynamic_scripts), '', $cachedata);
return str_replace($main, $output, $cachedata);
}
add_cacheaction('wpsc_cachedata', 'presscore_sc_cachedata_filter');
示例13: bnc_wptouch_get_user_agents
$wptouch_exclude_ua = $browsers;
}
return bnc_wptouch_get_user_agents();
}
function wp_super_cache_wptouch_prefixes($prefixes)
{
return array();
// wptouch doesn't support UA prefixes
}
function wp_super_cache_wptouch_cookie_check($cache_key)
{
if (false == isset($_COOKIE['wptouch_switch_toggle'])) {
return $cache_key;
}
if ($_COOKIE['wptouch_switch_toggle'] == 'normal' || $_COOKIE['wptouch_switch_toggle'] == 'mobile') {
return $_COOKIE['wptouch_switch_toggle'];
}
if (isset($_COOKIE['wptouch-pro-view'])) {
if ($_COOKIE['wptouch-pro-view'] == 'desktop') {
return 'normal';
} else {
return $_COOKIE['wptouch-pro-view'];
}
}
return $cache_key;
}
if (isset($cache_wptouch) && $cache_wptouch == 1) {
add_cacheaction('wp_super_cache_mobile_browsers', 'wp_super_cache_wptouch_browsers');
add_cacheaction('wp_super_cache_mobile_prefixes', 'wp_super_cache_wptouch_prefixes');
add_cacheaction('wp_cache_check_mobile', 'wp_super_cache_wptouch_cookie_check');
}