1
0
Fork 0
mirror of https://github.com/yunluo/gdk.git synced 2024-06-20 06:25:13 +02:00

增加代码高亮功能

This commit is contained in:
云落 2020-01-28 14:51:13 +08:00
parent 15d0b026f6
commit c3f8d5e822
8 changed files with 69 additions and 17 deletions

View file

@ -13,10 +13,10 @@ add_action('admin_enqueue_scripts', 'nc_optimizeup_enqueue_script');
function nc_optimizeup_enqueue_script_frontend() {
if (!is_admin()) {
wp_register_style( 'jimu-css', NC_BASE_URL . 'modules/jimu.css', array(), NC_OPTIMIZEUP_VERSION, 'all' );
wp_register_script('jimu-js', NC_BASE_URL . 'modules/jimu.js', array('jquery'), NC_OPTIMIZEUP_VERSION, true);
wp_enqueue_script('jimu-js');
wp_enqueue_style( 'jimu-css' );
wp_register_style( 'code_prettify_css', NC_BASE_URL.'assets/css/gdk.css', array(), NC_STORE_VER, 'all' );
wp_register_script('code_prettify_js', NC_BASE_URL.'assets/js/prettify.min.js', array('jquery'), NC_STORE_VER, true);
wp_enqueue_script('code_prettify_js');
wp_enqueue_style( 'code_prettify_css' );
}
}
add_action('wp_enqueue_scripts', 'nc_optimizeup_enqueue_script_frontend');

5
assets/css/gdk.css Normal file

File diff suppressed because one or more lines are too long

2
assets/js/prettify.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -519,6 +519,17 @@ $gdk_options = [
'title' => 'HTML5 桌面推送',
'type' => 'title'
],
[
'name' => 'HTML5 桌面推送',
'desc' => '该功能开启后会在浏览器进行信息推送,需要高级浏览器支持,默认关闭',
'id' => 'gdk_h5notice',
'type' => 'radio',
'options' => [
'0' => '禁用',
'1' => '开启'
],
'std' => '0'
],
[
'name' => 'HTML5推送标题【必选】',
'desc' => '显示在弹窗顶部',

View file

@ -339,7 +339,7 @@ jQuery(function ($) {
$.post(ajaxurl, ajax_data,
function(a) {
if (a == '1') {
alert('邮箱配置成功');
alert('邮箱配置成功');
}else{
alert('邮箱配置失败,请重新检查');
}
@ -348,12 +348,12 @@ jQuery(function ($) {
/* 配置文本框以隐藏显示功能*/
function depend(n, e, i, c, t, u) {
/* 配置文本框以隐藏显示功能,可以同时伸缩8个元素*/
function depend(n, e, i, c, t, u, v, g, d) {
$("input[name=" + n + "]:checked").val(function() {
"0" == this.value && $(e, i, c, t, u).hide();
}), $("input[name=" + n + "]").click(function() {
$(e, i, c, t, u).toggle();
"0" == this.value && $(e, i, c, t, u, v, g, d).hide();
}), $("input[name=" + n + "]").change(function() {
$(e, i, c, t, u, v, g, d).toggle();
});
}
//依赖关系,第一个是需要点击的name值,后面是需要伸缩的ID值,参照下面写
@ -362,7 +362,7 @@ depend('gdk_smtp','#row-gdk_smtp_username,#row-gdk_smtp_host,#row-gdk_smtp_port,
depend('gdk_baidu_push','#row-gdk_baidu_api');
depend('gdk_tag_link','#row-gdk_tag_num');
depend('gdk_cdn','#row-gdk_cdn_host,#row-gdk_cdn_ext,#row-gdk_cdn_dir,#row-gdk_cdn_style,#row-git_cdn_water');
depend('gdk_h5notice','#row-git_notification_title,#row-git_notification_days,#row-git_notification_cookie,#row-git_notification_icon,#row-git_notification_link,#row-git_notification_body');
});
</script>

View file

@ -72,6 +72,33 @@ if (gdk_option('gdk_diasble_wp_update')) {
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);
//强制阻止WordPress代码转义
function git_esc_html($content) {
$regex = '/(<pre\s+[^>]*?class\s*?=\s*?[",\'].*?prettyprint.*?[",\'].*?>)(.*?)(<\/pre>)/sim';
return preg_replace_callback($regex, 'git_esc_callback', $content);
}
function git_esc_callback($matches) {
$tag_open = $matches[1];
$content = $matches[2];
$tag_close = $matches[3];
$content = esc_html($content);
return $tag_open . $content . $tag_close;
}
add_filter('the_content', 'git_esc_html', 2);
add_filter('comment_text', 'git_esc_html', 2);
//强制兼容<pre>
function git_prettify_replace($text) {
$replace = array(
'<pre>' => '<pre class="prettyprint linenums" >'
);
$text = str_replace(array_keys($replace) , $replace, $text);
return $text;
}
add_filter('the_content', 'git_prettify_replace');
//禁用emoji功能
if (gdk_option('gdk_disable_emojis')) {
function gdk_disable_emojis_link() {

View file

@ -263,12 +263,18 @@ if(gdk_option('gdk_nofollow')){
function nc_baidu_auto_code(){
echo '<script>
(function(){
var bp = document.createElement(\'script\');
bp.src = \'https://zz.bdstatic.com/linksubmit/push.js\';
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
(function(){
var bp = document.createElement(\'script\');
var curProtocol = window.location.protocol.split(\':\')[0];
if (curProtocol === \'https\') {
bp.src = \'https://zz.bdstatic.com/linksubmit/push.js\';
}
else {
bp.src = \'http://push.zhanzhang.baidu.com/push.js\';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>';
}

View file

@ -29,4 +29,5 @@ define('NC_STORE_ROOT_PATH', plugin_dir_path( __FILE__ ) );//插件目录路径
include('class/clean-up.php');
include('framework/plugin-options.php');
include('functions/func_load.php');
include('assets/assets_load.php');