From 6b84ad77651f49b1d3ef9674bc4df42b1ab31a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E8=90=BD?= Date: Sat, 25 Jan 2020 20:22:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/widget_cache.php | 55 ++++++++++++++++++++++++++ functions/optimization.php | 81 ++------------------------------------ route.php | 1 + 3 files changed, 60 insertions(+), 77 deletions(-) create mode 100644 class/widget_cache.php diff --git a/class/widget_cache.php b/class/widget_cache.php new file mode 100644 index 0000000..be3d29c --- /dev/null +++ b/class/widget_cache.php @@ -0,0 +1,55 @@ + +get_widget_key($instance, $args); + if (false === ($cached_widget = get_transient($transient_name))) { + ob_start(); + $widget->widget($args, $instance); + $cached_widget = ob_get_clean(); + set_transient($transient_name, $cached_widget, $this->cache_time); + } + echo $cached_widget; + echo ''; + return false; + } + function in_widget_form($t, $return, $instance) { + $instance = wp_parse_args((array)$instance, array('title' => '', 'text' => '', 'wc_cache' => null)); + if (!isset($instance['wc_cache'])) $instance['wc_cache'] = null; +?> +

+ /> + +

+ $link) if (0 === strpos($link, $home)) unset($links[$l]); } -if (git_get_option('git_pingback_b')){ - add_action('pre_ping', 'deel_noself_ping'); -} +add_action('pre_ping', 'deel_noself_ping'); + //移除自动保存和修订版本 @@ -232,82 +231,9 @@ add_filter( 'wp_update_attachment_metadata', 'git_rips_unlink_tempfix' ); add_filter('the_content', 'content_autospace'); -//小工具缓存 -class GIT_Widget_cache { - public $cache_time = 18000; - /* - MINUTE_IN_SECONDS = 60 seconds - HOUR_IN_SECONDS = 3600 seconds - DAY_IN_SECONDS = 86400 seconds - WEEK_IN_SECONDS = 604800 seconds - YEAR_IN_SECONDS = 3153600 seconds - */ - function __construct() { - add_filter('widget_display_callback', array( - $this, - '_cache_widget_output' - ) , 10, 3); - add_action('in_widget_form', array( - $this, - 'in_widget_form' - ) , 5, 3); - add_filter('widget_update_callback', array( - $this, - 'widget_update_callback' - ) , 5, 3); - } - function get_widget_key($i, $a) { - return 'WC-' . md5(serialize(array( - $i, - $a - ))); - } - function _cache_widget_output($instance, $widget, $args) { - if (false === $instance) return $instance; - if (isset($instance['wc_cache']) && $instance['wc_cache'] == true) return $instance; - $timer_start = microtime(true); - $transient_name = $this->get_widget_key($instance, $args); - if (false === ($cached_widget = get_transient($transient_name))) { - ob_start(); - $widget->widget($args, $instance); - $cached_widget = ob_get_clean(); - set_transient($transient_name, $cached_widget, $this->cache_time); - } - echo $cached_widget; - echo ''; - return false; - } - function in_widget_form($t, $return, $instance) { - $instance = wp_parse_args((array)$instance, array( - 'title' => '', - 'text' => '', - 'wc_cache' => null - )); - if (!isset($instance['wc_cache'])) $instance['wc_cache'] = null; -?> -

- /> - -

- =')) { } include('modules/base/main.php'); + include('functions/func_load.php'); function nc_store_pluggable_include() {