mirror of
https://github.com/yunluo/gdk.git
synced 2024-06-16 12:35:08 +02:00
修改
This commit is contained in:
parent
187a8344c0
commit
6b84ad7765
55
class/widget_cache.php
Normal file
55
class/widget_cache.php
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class Auto_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 '<!-- From widget cache in ' . number_format(microtime(true) - $timer_start, 5) . ' seconds -->';
|
||||||
|
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;
|
||||||
|
?>
|
||||||
|
<p>
|
||||||
|
<input id="<?php
|
||||||
|
echo $t->get_field_id('wc_cache'); ?>" name="<?php
|
||||||
|
echo $t->get_field_name('wc_cache'); ?>" type="checkbox" <?php
|
||||||
|
checked(isset($instance['wc_cache']) ? $instance['wc_cache'] : 0); ?> />
|
||||||
|
<label for="<?php
|
||||||
|
echo $t->get_field_id('wc_cache'); ?>">禁止缓存本工具?</label>
|
||||||
|
</p>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
function widget_update_callback($instance, $new_instance, $old_instance) {
|
||||||
|
$instance['wc_cache'] = isset($new_instance['wc_cache']);
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$GLOBALS['Auto_Widget_cache'] = new Auto_Widget_cache();
|
|
@ -24,9 +24,8 @@ function deel_noself_ping(&$links) {
|
||||||
$home = home_url();
|
$home = home_url();
|
||||||
foreach ($links as $l => $link) if (0 === strpos($link, $home)) unset($links[$l]);
|
foreach ($links as $l => $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');
|
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 '<!-- From widget cache in ' . number_format(microtime(true) - $timer_start, 5) . ' seconds -->';
|
|
||||||
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;
|
|
||||||
?>
|
|
||||||
<p>
|
|
||||||
<input id="<?php
|
|
||||||
echo $t->get_field_id('wc_cache'); ?>" name="<?php
|
|
||||||
echo $t->get_field_name('wc_cache'); ?>" type="checkbox" <?php
|
|
||||||
checked(isset($instance['wc_cache']) ? $instance['wc_cache'] : 0); ?> />
|
|
||||||
<label for="<?php
|
|
||||||
echo $t->get_field_id('wc_cache'); ?>">禁止缓存本工具?</label>
|
|
||||||
</p>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
function widget_update_callback($instance, $new_instance, $old_instance) {
|
|
||||||
$instance['wc_cache'] = isset($new_instance['wc_cache']);
|
|
||||||
return $instance;
|
|
||||||
}
|
|
||||||
} //end GIT_Widget_cache class
|
|
||||||
if (git_get_option('git_sidebar_cache')) {
|
|
||||||
$GLOBALS['GIT_Widget_cache'] = new GIT_Widget_cache();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
修复4.2表情bug
|
|
||||||
下面代码来自:http://www.9sep.org/remove-emoji-in-wordpress
|
|
||||||
*/
|
|
||||||
function disable_emoji9s_tinymce($plugins) {
|
function disable_emoji9s_tinymce($plugins) {
|
||||||
if (is_array($plugins)) {
|
if (is_array($plugins)) {
|
||||||
return array_diff($plugins, array(
|
return array_diff($plugins, array(
|
||||||
|
@ -381,6 +307,7 @@ function init_gitsmilie() {
|
||||||
add_filter('smilies_src', 'custom_gitsmilie_src', 10, 2);
|
add_filter('smilies_src', 'custom_gitsmilie_src', 10, 2);
|
||||||
}
|
}
|
||||||
add_action('init', 'init_gitsmilie', 5);
|
add_action('init', 'init_gitsmilie', 5);
|
||||||
|
*/
|
||||||
|
|
||||||
//分类,标签描述添加图片
|
//分类,标签描述添加图片
|
||||||
remove_filter('pre_term_description', 'wp_filter_kses');
|
remove_filter('pre_term_description', 'wp_filter_kses');
|
||||||
|
|
|
@ -37,6 +37,7 @@ if (version_compare(PHP_VERSION, '7.2.26', '>=')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
include('modules/base/main.php');
|
include('modules/base/main.php');
|
||||||
|
|
||||||
include('functions/func_load.php');
|
include('functions/func_load.php');
|
||||||
|
|
||||||
function nc_store_pluggable_include() {
|
function nc_store_pluggable_include() {
|
||||||
|
|
Loading…
Reference in a new issue