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-02-01 00:04:39 +08:00
parent a52358eacb
commit 535aee6732
6 changed files with 106 additions and 39 deletions

View file

@ -2,7 +2,7 @@
function gdk_admin_script() {
?>
<style>.shortcodes-wrap{background:#fff;border: 1px solid #ccc;box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.24);padding: 10px;position: absolute;top: 60px;width: 375px;display:none}.is-active.shortcodes-wrap{display:block}.insert-shortcodes{padding-left:35px!important}#insert-shortcode-button {background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj4gPHBhdGggZD0iTTI5MC41OSAxOTJjLTIwLjE4IDAtMTA2LjgyIDEuOTgtMTYyLjU5IDg1Ljk1VjE5MmMwLTUyLjk0LTQzLjA2LTk2LTk2LTk2LTE3LjY3IDAtMzIgMTQuMzMtMzIgMzJzMTQuMzMgMzIgMzIgMzJjMTcuNjQgMCAzMiAxNC4zNiAzMiAzMnYyNTZjMCAzNS4zIDI4LjcgNjQgNjQgNjRoMTc2YzguODQgMCAxNi03LjE2IDE2LTE2di0xNmMwLTE3LjY3LTE0LjMzLTMyLTMyLTMyaC0zMmwxMjgtOTZ2MTQ0YzAgOC44NCA3LjE2IDE2IDE2IDE2aDMyYzguODQgMCAxNi03LjE2IDE2LTE2VjI4OS44NmMtMTAuMjkgMi42Ny0yMC44OSA0LjU0LTMyIDQuNTQtNjEuODEgMC0xMTMuNTItNDQuMDUtMTI1LjQxLTEwMi40ek00NDggOTZoLTY0bC02NC02NHYxMzQuNGMwIDUzLjAyIDQyLjk4IDk2IDk2IDk2czk2LTQyLjk4IDk2LTk2VjMybC02NCA2NHptLTcyIDgwYy04Ljg0IDAtMTYtNy4xNi0xNi0xNnM3LjE2LTE2IDE2LTE2IDE2IDcuMTYgMTYgMTYtNy4xNiAxNi0xNiAxNnptODAgMGMtOC44NCAwLTE2LTcuMTYtMTYtMTZzNy4xNi0xNiAxNi0xNiAxNiA3LjE2IDE2IDE2LTcuMTYgMTYtMTYgMTZ6Ij48L3BhdGg+IDwvc3ZnPg==) no-repeat left/30%;background-position: 10% 40%;}</style>
<style>.shortcodes-wrap{background:#fff;border: 1px solid #ccc;box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.24);padding: 10px;position: absolute;top:54px;width:500px;display:none}.is-active.shortcodes-wrap{display:block}.insert-shortcodes{padding-left:35px!important}#insert-shortcode-button {background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj4gPHBhdGggZD0iTTI5MC41OSAxOTJjLTIwLjE4IDAtMTA2LjgyIDEuOTgtMTYyLjU5IDg1Ljk1VjE5MmMwLTUyLjk0LTQzLjA2LTk2LTk2LTk2LTE3LjY3IDAtMzIgMTQuMzMtMzIgMzJzMTQuMzMgMzIgMzIgMzJjMTcuNjQgMCAzMiAxNC4zNiAzMiAzMnYyNTZjMCAzNS4zIDI4LjcgNjQgNjQgNjRoMTc2YzguODQgMCAxNi03LjE2IDE2LTE2di0xNmMwLTE3LjY3LTE0LjMzLTMyLTMyLTMyaC0zMmwxMjgtOTZ2MTQ0YzAgOC44NCA3LjE2IDE2IDE2IDE2aDMyYzguODQgMCAxNi03LjE2IDE2LTE2VjI4OS44NmMtMTAuMjkgMi42Ny0yMC44OSA0LjU0LTMyIDQuNTQtNjEuODEgMC0xMTMuNTItNDQuMDUtMTI1LjQxLTEwMi40ek00NDggOTZoLTY0bC02NC02NHYxMzQuNGMwIDUzLjAyIDQyLjk4IDk2IDk2IDk2czk2LTQyLjk4IDk2LTk2VjMybC02NCA2NHptLTcyIDgwYy04Ljg0IDAtMTYtNy4xNi0xNi0xNnM3LjE2LTE2IDE2LTE2IDE2IDcuMTYgMTYgMTYtNy4xNiAxNi0xNiAxNnptODAgMGMtOC44NCAwLTE2LTcuMTYtMTYtMTZzNy4xNi0xNiAxNi0xNiAxNiA3LjE2IDE2IDE2LTcuMTYgMTYtMTYgMTZ6Ij48L3BhdGg+IDwvc3ZnPg==) no-repeat left/30%;background-position: 10% 40%;}#wp-content-media-buttons > div> a:nth-child(20){background:#f6003c;border-color:#f6003c;color:#fff;}</style>
<script>
jQuery(function($) {
/* bengin */
@ -20,6 +20,7 @@ jQuery(function($) {
return false
})
/**end**/
});
</script>
<?php
@ -27,7 +28,7 @@ jQuery(function($) {
function nc_optimizeup_enqueue_script($hook_suffix) {
function gdk_admin_enqueue_script($hook_suffix) {
if($hook_suffix == 'post.php'|| $hook_suffix == 'post-new.php'){
wp_register_script('paste-upload-image', GDK_BASE_URL.'assets/js/paste-upload-image.js', array( 'jquery' ), GDK_PLUGIN_VER, true);
wp_enqueue_script('paste-upload-image');
@ -38,9 +39,9 @@ if($hook_suffix == 'post.php'|| $hook_suffix == 'post-new.php'){
wp_enqueue_script('sweetalert');
}
add_action('admin_enqueue_scripts', 'nc_optimizeup_enqueue_script');
add_action('admin_enqueue_scripts', 'gdk_admin_enqueue_script');
function nc_optimizeup_enqueue_script_frontend() {
function gdk_enqueue_script_frontend() {
if (!is_admin()) {
wp_register_style( 'gdk_css', GDK_BASE_URL.'assets/css/gdk.css', [], GDK_PLUGIN_VER, 'all' );
wp_register_script('code_prettify_js', GDK_BASE_URL.'assets/js/prettify.min.js', array('jquery'), GDK_PLUGIN_VER, true);
@ -53,7 +54,7 @@ function nc_optimizeup_enqueue_script_frontend() {
}
}
add_action('wp_enqueue_scripts', 'nc_optimizeup_enqueue_script_frontend');
add_action('wp_enqueue_scripts', 'gdk_enqueue_script_frontend');
//

View file

@ -1,8 +1,9 @@
<?php
/**
* 主题选项配置文件
* 插件选项配置文件
*/
$gdk_options = [
'优化选项' => [
[
@ -232,13 +233,14 @@ $gdk_options = [
'0' => '禁用',
'1' => '开启'
],
'std' => '1'
'std' => '0'
],
[
'name' => '主动推送接口地址,填写本项即开启推送',
'desc' => '在百度站长平台获取主动推送接口地址比如http://data.zz.baidu.com/urls?site=域名&token=一组字符, <a class="key_word" rel="nofollow" href="http://zhanzhang.baidu.com/linksubmit/index" target="_blank">主动推送接口地址</a>',
'id' => 'gdk_baidu_api',
'type' => 'text'
'type' => 'text',
'hide' => '1'
]
],
'安全设置' => [
@ -641,4 +643,15 @@ $gdk_options = [
'std' => ''
]
]
];
];
//载入主题配置,默认路径在主题根目录options.php
if( file_exists(get_template_directory() . '/options.php')) include(get_template_directory() . '/options.php');
if(!empty($gdk_theme_options)){
$gdk_options = array_merge($gdk_theme_options,$gdk_options);
}
//var_dump($gdk_options);

View file

@ -810,6 +810,28 @@ function get_qqv_mp4($vid){
return $mp4;
}
//字符串转数组,默认分隔符是:,
function gdk_str2arr($data, $delimiter = ',') {
// 数组原样返回
if (is_array($data)) {
return $data;
}
// 字符串处理
$string = (string)$data;
if (empty($string)) {
$result = [];
} elseif (preg_match('/^{.*?}$/', $string) || preg_match('/^\[.*?]$/', $string)) {
$result = json_decode($string, true);
} elseif (preg_match('/^a:.*?(})$/', $string)) {
$result = unserialize($string, null);
} elseif (strpos($string, $delimiter) >= 1) {
$result = explode($delimiter, $string);
} else {
$result = [];
}
if (!is_array($result) || count($result) < 1) {
return [];
}
return $result;
}

View file

@ -3,12 +3,12 @@ include( 'Common.php' );//通用代码
include( 'Ajax.php' );//Ajax服务
include( 'optimization.php');//优化措施
include( 'advanced.php' );//头像功能
include( 'advanced.php' );//高级功能
include( 'security.php' );//安全功能
//include( 'shortcode.php' );//短代码
include( 'shortcode.php' );//短代码
include( 'seo.php' );//seo功能

View file

@ -494,17 +494,3 @@ if(gdk_option('gdk_no_category')){
//WordPress 段代码按钮集合
function gdk_shortcode_list() {
$wpshortcodes = ['代码高亮'=>'&lt;pre class=\'prettyprint linenums\'&gt;&nbsp;&nbsp;&lt;/pre&gt;','链接按钮'=>'[dm href=\'\'][/dm]'];
$output = '';
foreach ($wpshortcodes as $name => $alt) {
$output.= '<a class="add-shortcode ed_button button button-small" data-shortcodes="' . $alt . '">' . $name . '</a>';
}
return $output;
}
add_action('media_buttons_context', 'gdk_shortcode_button');
function gdk_shortcode_button($context) {
$context = '<a id="insert-shortcode-button" style="position:relative" class="button insert-shortcodes add_shortcodes" title="添加简码" data-editor="content" href="javascript:void(0)">短代码</a><div class="shortcodes-wrap">' . gdk_shortcode_list() . '</div>';
return $context;
}

View file

@ -1,6 +1,6 @@
<?php
/* 短代码集合 */
//短代码集合
@ -60,38 +60,39 @@ function reply_to_read($atts, $content = null) {
}
}
add_shortcode('reply', 'reply_to_read');
/*绿色提醒框*/
//绿色提醒框
function toz($atts, $content = null) {
return '<div id="sc_notice">' . $content . '</div>';
}
add_shortcode('v_notice', 'toz');
/*红色提醒框*/
//红色提醒框
function toa($atts, $content = null) {
return '<div id="sc_error">' . $content . '</div>';
}
add_shortcode('v_error', 'toa');
/*黄色提醒框*/
//黄色提醒框
function toc($atts, $content = null) {
return '<div id="sc_warn">' . $content . '</div>';
}
add_shortcode('v_warn', 'toc');
/*灰色提醒框*/
//灰色提醒框
function tob($atts, $content = null) {
return '<div id="sc_tips">' . $content . '</div>';
}
add_shortcode('v_tips', 'tob');
/*蓝色提醒框*/
//蓝色提醒框
function tod($atts, $content = null) {
return '<div id="sc_blue">' . $content . '</div>';
}
add_shortcode('v_blue', 'tod');
/*蓝边文本框*/
//蓝边文本框
function toe($atts, $content = null) {
return '<div class="sc_act">' . $content . '</div>';
}
add_shortcode('v_act', 'toe');
/*灵魂按钮*/
//灵魂按钮
function tom($atts, $content = null) {
extract(shortcode_atts(array(
"href" => 'http://'
@ -99,7 +100,7 @@ function tom($atts, $content = null) {
return '<a class="lhb" href="' . $href . '" target="_blank" rel="nofollow">' . $content . '</a>';
}
add_shortcode('lhb', 'tom');
/*添加视频按钮*/
//添加视频按钮
function too($atts, $content = null) {
extract(shortcode_atts(array(
"play" => '0'
@ -112,7 +113,7 @@ function too($atts, $content = null) {
}
}
add_shortcode('video', 'too');
/*添加音频按钮*/
//添加音频按钮
function tkk($atts, $content = null) {
extract(shortcode_atts(array(
"play" => '0'
@ -125,7 +126,7 @@ function tkk($atts, $content = null) {
}
}
add_shortcode('audio', 'tkk');
/*弹窗下载*/
//弹窗下载
function ton($atts, $content = null) {
extract(shortcode_atts(array(
"href" => 'http://',
@ -146,7 +147,7 @@ function git_download($atts, $content = null) {
return '<a class="lhb" href="' . get_permalink(git_page_id('download')) . '?pid=' . get_the_ID() . '" target="_blank" rel="nofollow">' . $content . '</a>';
}
add_shortcode('download', 'git_download');
/* 短代码信息框 完毕*/
//为WordPress添加展开收缩功能
function xcollapse($atts, $content = null) {
extract(shortcode_atts(array(
@ -258,3 +259,47 @@ function git_list_shortcode_handler($atts, $content = '') {
return $output;
}
add_shortcode('list', 'git_list_shortcode_handler');
//WordPress 段代码按钮集合
function gdk_shortcode_list() {
$wpshortcodes = [
'横线'=>'<hr />',
'H2标题'=>'<h2> </h2>',
'H3标题'=>'<h3> </h3>',
'记号笔'=>'<mark> </mark>',
'链接按钮'=>'[dm href=] [/dm]',
'下载按钮'=>'[dl href=] [/dl]',
'透明按钮'=>'[lhb href=] [/lhb]',
'视频按钮'=>'[video play=0] [/video]',
'音频按钮'=>'[audio play=0] [/audio]',
'绿色通知'=>'[v_notice] [/v_notice]',
'红色警告'=>'[v_error] [/v_error]',
'黄色错误'=>'[v_warn] [/v_warn]',
'灰色提示'=>'[v_tips] [/v_tips]',
'蓝边提示'=>'[v_act] [/v_act]',
'隐藏收缩'=>'[collapse title=\'\'] [/collapse]',
'回复可见'=>'[reply] [/reply]',
'登陆可见'=>'[vip] [/vip]',
'密码可见'=>'[secret wx=0] [/secret]',
'积分购买可见'=>'[pay point=\'10\']这里是需要付费的内容[/pay]',
'游客付费可见'=>'[pax money=1]',
'弹窗下载'=>'[fanctdl filename=\'这里填写文件名\' filepass=\'这里填写文件密码什么的\' href=\'这里填写的主下载链接\' filedown=\'这里填写的是文件的主下载名称\']这里填写的文件的辅助下载链接,可写多个,空格间隔[/fanctdl]',
'面板下载'=>'[dltable file=\'在此处写下文件名称\' pass=\'在这里写下文件密码\']这里填写的文件的辅助下载链接,可写多个,空格间隔[/dltable]',
'单页下载'=>'[pdownload title=]',
'文章内链'=>'[neilian ids=]',
'无序列表'=>'[list] [/list]',
'表格简码'=>'[table] [/table]'
];
$output = '';
foreach ($wpshortcodes as $name => $alt) {
$output.= '<a class="add-shortcode ed_button button button-small" data-shortcodes="' . $alt . '">' . $name . '</a>';
}
return $output;
}
function gdk_shortcode_button($context) {
$context = '<a id="insert-shortcode-button" style="position:relative" class="button insert-shortcodes add_shortcodes" title="添加简码" data-editor="content" href="javascript:void(0)">短代码</a><div class="shortcodes-wrap">' . gdk_shortcode_list() . '</div>';
return $context;
}
add_action('media_buttons_context', 'gdk_shortcode_button');