1
0
Fork 0
mirror of https://github.com/yunluo/gdk.git synced 2024-05-04 23:43:23 +02:00

多重更新:后台金币支持具体文章查询,微信验证码功能优化,修复按钮js的报错,优化短代码嵌套使用的问题

This commit is contained in:
云落 2020-10-19 11:03:52 +08:00
parent 260fc09467
commit 195162580d
16 changed files with 3586 additions and 3556 deletions

8
.gitignore vendored
View file

@ -1,4 +1,4 @@
desktop.ini
.ecloud/*
.git/
public/cache/*.txt
desktop.ini
.ecloud/*
.git/
public/cache/*.txt

View file

@ -1,2 +1,2 @@
#GitCafe Development Kit
#GitCafe Development Kit

View file

@ -15,7 +15,7 @@ add_action('admin_enqueue_scripts', 'gdk_admin_enqueue_script');
function gdk_enqueue_script_frontend()
{
if (!is_admin()) {
wp_enqueue_style('pure_css', 'https://cdn.jsdelivr.net/npm/css-mint@2.0.7/build/css-mint.min.css', false, GDK_PLUGIN_VER, 'all');
wp_enqueue_style('pure_css', GDK_BASE_URL . 'assets/css/css-mint.min.css', false, GDK_PLUGIN_VER, 'all');
wp_enqueue_style('font-awesome', GDK_BASE_URL . 'assets/css/font-awesome.min.css', false, GDK_PLUGIN_VER, 'all');
//wp_enqueue_style( 'milligram_css', GDK_BASE_URL.'assets/css/milligram.min.css', false, GDK_PLUGIN_VER, 'all' );
wp_enqueue_style('gdk_css', GDK_BASE_URL . 'assets/css/gdk.css', false, GDK_PLUGIN_VER, 'all');
@ -53,6 +53,7 @@ jQuery(function($) {
/* bengin */
if ($("#ed_toolbar").length > 0) {
/***文章编辑器 */
QTags.addButton('h2', 'H2标题', '<h2>', '</h2>');
QTags.addButton('ipre', '代码高亮', '<pre class="prettyprint linenums" >\n\n</pre>', "");
$("#content").pasteUploadImage(ajaxurl); //ajax img upload
$(".insert-shortcodes").click(function() { //shortcode botton

7
assets/css/css-mint.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -14,6 +14,7 @@ body.compensate-for-scrollbar{overflow:hidden}.fancybox-active{height:auto}.fanc
.cm-badge{padding:8px;font-size:.8em;background-color:#dadada;border-radius:3px;text-align:center;margin-bottom:15px}
.cm-coin{padding:4px 18px;border:1px solid #f0ad4e;border-radius:20px;background-color:#fff;color:#f0ad4e}
.cm-round{width:30px;height:30px;border-radius:50%;}
.cm-btn{display: inline-block;}
.alert-warning,.warning{background-color:#fdd867;border-color:#f6b73c;}
.alert-info,.info{background-color:#7db1f1;border-color:#3d7e9a;color:#fff;}
.alert-success,.success{background-color:#68d58c;border-color:#4d9f0c;color:#fff;}

View file

@ -1,6 +1,6 @@
<?php
include 'clean-up.php'; //数据库清理
include 'local_avatars.php'; //本地头像
include 'updates.php'; //在线更新
@ -11,3 +11,5 @@ include 'points/points.php'; //积分功能
include 'aq_resizer.php'; //缩略图功能
include 'wechat.php'; //微信功能

View file

@ -201,27 +201,35 @@ class GDK_Points_Admin
$alert = "";
if (isset($_POST['psearch'])) {
$sdata = trim($_POST['psearch']);
if (preg_match('/E20/', $sdata)) {
if (preg_match('/E20/', $sdata) ) {
//order id
global $wpdb;
$point_id = $wpdb->get_row("SELECT point_id FROM " . GDK_Points_Database::points_get_table("users") . " WHERE description = '{$sdata}'", ARRAY_A)['point_id'];
$points = GDK_Points::get_point($point_id);
} elseif (filter_var($sdata, FILTER_VALIDATE_EMAIL)) {
}elseif (preg_match('/(D|d)/', $sdata)){// description
$data = substr($sdata,1);
global $wpdb;
$points = $wpdb->get_results("SELECT * FROM " . GDK_Points_Database::points_get_table("users") . " WHERE description = '{$data}'");
//var_dump($points);
$k[] = '<div style="margin-bottom:10px;">文章ID' . $data . ' &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;文章名为:' . get_post($data)->post_title . '</div><hr />';
} elseif (filter_var($sdata, FILTER_VALIDATE_EMAIL)) {
//email
$user = get_user_by('email', $sdata);
$points = GDK_Points::get_points_by_user($user->ID);
$k[] = '<div style="margin-bottom:10px;">用户ID' . $user->ID . ' &nbsp;&nbsp;总金币为:' . GDK_Points::get_user_total_points($user->ID) . '</div>';
$k[] = '<div style="margin-bottom:10px;">用户ID' . $user->ID . ' &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;总金币为:' . GDK_Points::get_user_total_points($user->ID) . '</div>';
} else {
//userid
$points = GDK_Points::get_points_by_user($sdata);
$k[] = '<div style="margin-bottom:10px;">用户ID' . $sdata . ' &nbsp;&nbsp;总金币为:' . GDK_Points::get_user_total_points($sdata) . '</div>';
$k[] = '<div style="margin-bottom:10px;">用户ID' . $sdata . ' &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;总金币为:' . GDK_Points::get_user_total_points($sdata) . '</div>';
}
if (is_array($points)) {
foreach ($points as $point) {
$k[] = '<div style="margin-bottom:5px;">金币:' . $point->points . ' &nbsp;&nbsp;描述:' . $point->description . ' &nbsp;&nbsp;日期:' . $point->datetime . '</div>';
$userid = $point->user_id;
$user_name = get_user_by('id', $userid)->display_name;
$k[] = '<div style="margin-bottom:5px;">用户ID' . $userid . '&nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;金币:' . $point->points . ' &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;描述:' . $point->description . ' &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;日期:' . $point->datetime . '&nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;用户名:' . $user_name . '</div>';
}
} else {
$k[] = '<div style="margin-bottom:5px;">金币:' . $points->points . ' &nbsp;&nbsp;描述:' . $points->description . ' &nbsp;&nbsp;日期:' . $points->datetime . '</div>';
$k[] = '<div style="margin-bottom:5px;">用户ID' . $point->user_id . '&nbsp;&nbsp;金币:' . $points->points . ' &nbsp;&nbsp;描述:' . $points->description . ' &nbsp;&nbsp;日期:' . $points->datetime . '</div>';
}
$alert = implode(" ", $k);
}
@ -327,7 +335,7 @@ class GDK_Points_Admin
<a class="add button" href="<?php echo esc_url(add_query_arg('action', 'edit', $current_url)); ?>" title="点击手动添加金币">添加金币</a>
</span>
<form method="POST" style="float:right;">
<input size="40" placeholder="搜索用户ID/用户邮箱/订单号" type="search" name="psearch" value="" />
<input size="40" placeholder="搜索用户ID/用户邮箱/订单号/D文章ID" type="search" name="psearch" value="" />
</form>
<?php echo '<style type="text/css">tbody#the-list tr:hover{background:rgba(132,219,162,.61)}</style>';
$exampleListTable->display(); ?>

View file

@ -66,6 +66,7 @@ class GDK_Points_Shortcodes
public static function pay($atts, $content = null)
{
$content = do_shortcode($content);
global $wpdb;
$user_id = get_current_user_id();
$pid = get_the_ID();

File diff suppressed because it is too large Load diff

View file

@ -80,12 +80,15 @@ class Wechat_Captcha
}
}
function wx_process()
{
global $object;
$wx_token = trim(gdk_option('gdk_wxmp_token'));
$object = new Wechat_Captcha($wx_token, wx_captcha());
$object->responseMsg();
return;
function wx_process() {
if(isset($_GET["signature"])) {
global $wx_captchas;
if(!isset($wx_captchas)) {
$wx_token = trim(gdk_option('gdk_wxmp_token'));
$wx_captchas = new Wechat_Captcha($wx_token, wx_captcha());
$wx_captchas->responseMsg();
exit;
}
}
}
add_action('pre_get_posts', 'wx_process', 4);
add_action('parse_request', 'wx_process', 4);

View file

@ -1,200 +1,200 @@
<?php
error_reporting(E_ALL ^ E_NOTICE); //镇魔石,镇压一切魑魅魍魉!
if (!class_exists('myCustomFields')) {
class myCustomFields
{
/**
* @var string $prefix 自定义栏目前缀,一个完整的自定义栏目是需要前缀+name的比如我的前缀是git_,name下面有baidu_submit那么完整的自定义栏目就是git_baidu_submit.
*/
public $prefix = 'gdk_';
/**
* @var array $postTypes 这是自定义面板的使用范围,这里一般就是在文章以及页面
*/
public $postTypes = array("post");
/**
* @var array $customFields 开始组件自定义面板数组
*/
public $customFields = array(
array(
"name" => "thumb",
"title" => "自定义缩略图",
"description" => "这里可以输入您的自定义缩略图链接",
"type" => "text",
"scope" => array("post"),
"capability" => "edit_posts",
),
array(
"name" => "download_name",
"title" => "单页下载文件名字",
"description" => "这里可以输入您的下载文件的名字",
"type" => "text",
"scope" => array("post"),
"capability" => "edit_posts",
),
array(
"name" => "download_size",
"title" => "单页下载文件大小",
"description" => "这里可以输入您的下载文件的大小可以加上单位比如233KB或者233MB",
"type" => "text",
"scope" => array("post"),
"capability" => "edit_posts",
),
array(
"name" => "download_link",
"title" => "单页下载下载链接",
"description" => "按照链接,名字,备注的格式,注意中间是用英文逗号,换行可添加多个,举个栗子:<code>https://www.baidu.com,百度官网,中国最大的搜索引擎网站</code>",
"type" => "textarea",
"scope" => array("post"),
"capability" => "edit_posts",
),
);
/**
* PHP 5 Constructor
*/
public function __construct()
{
add_action('admin_menu', array($this, 'createCustomFields'));
add_action('save_post', array($this, 'saveCustomFields'), 1, 2);
// 下面这句可以关闭WordPress自带的自定义栏目但是不推荐需要的话可以开启
//add_action( 'do_meta_boxes', array( $this, 'removeDefaultCustomFields' ), 10, 3 );
}
/**
* 创建一组你自己的自定义栏目
*/
public function createCustomFields()
{
if (function_exists('add_meta_box')) {
foreach ($this->postTypes as $postType) {
add_meta_box('my-custom-fields', '文章选项', array($this, 'displayCustomFields'), $postType, 'normal', 'high');
}
}
}
/**
* 在文章发布页显示出来面板
*/
public function displayCustomFields()
{
global $post;
?>
<div class="form-wrap">
<?php wp_nonce_field('my-custom-fields', 'my-custom-fields_wpnonce', false, true);
foreach ($this->customFields as $customField) {
// Check scope
$scope = $customField['scope'];
$output = false;
foreach ($scope as $scopeItem) {
switch ($scopeItem) {
default:{
if ($post->post_type == $scopeItem) {
$output = true;
}
break;
}
}
if ($output) {
break;
}
}
// 检查权限
if (!current_user_can($customField['capability'], $post->ID)) {
$output = false;
}
// 通过则输出
if ($output) {
?>
<div class="form-field form-required form-field-<?php echo $customField['name'];?>">
<?php switch ($customField['type']) {
case "checkbox":{
// Checkbox 组件
echo '<label for="' . $this->prefix . $customField['name'] . '" style="display:inline;"><b>' . $customField['title'] . '</b></label> ';
echo '<input type="checkbox" name="' . $this->prefix . $customField['name'] . '" id="' . $this->prefix . $customField['name'] . '" value="1"';
if (get_post_meta($post->ID, $this->prefix . $customField['name'], true) == "1") {
echo ' checked="checked"';
}
echo '" style="width: auto;" />';
break;
}
case "textarea":
case "wysiwyg":{
// Text area
echo '<label for="' . $this->prefix . $customField['name'] . '"><b>' . $customField['title'] . '</b></label>';
echo '<textarea name="' . $this->prefix . $customField['name'] . '" id="' . $this->prefix . $customField['name'] . '" columns="30" rows="5">' . htmlspecialchars(get_post_meta($post->ID, $this->prefix . $customField['name'], true)) . '</textarea>';
// WYSIWYG
if ($customField['type'] == "wysiwyg") { ?>
<script type="text/javascript">
jQuery( document ).ready( function() {
jQuery( "<?php echo $this->prefix . $customField['name']; ?>" ).addClass( "mceEditor" );
if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
tinyMCE.execCommand( "mceAddControl", false, "<?php echo $this->prefix . $customField['name']; ?>" );
}
});
</script>
<?php }
break;
}
default:{
// Plain text field
echo '<label for="' . $this->prefix . $customField['name'] . '"><b>' . $customField['title'] . '</b></label>';
echo '<input type="text" name="' . $this->prefix . $customField['name'] . '" id="' . $this->prefix . $customField['name'] . '" value="' . htmlspecialchars(get_post_meta($post->ID, $this->prefix . $customField['name'], true)) . '" />';
break;
}
}
?>
<?php if ($customField['description']) {
echo '<p>' . $customField['description'] . '</p>';
}
?>
</div>
<?php
}
} ?>
</div>
<?php
}
/**
* 保存自定义栏目数据
*/
public function saveCustomFields($post_id, $post)
{
if (!isset($_POST['my-custom-fields_wpnonce']) || !wp_verify_nonce($_POST['my-custom-fields_wpnonce'], 'my-custom-fields')) {
return;
}
if (!current_user_can('edit_post', $post_id)) {
return;
}
if (!in_array($post->post_type, $this->postTypes)) {
return;
}
foreach ($this->customFields as $customField) {
if (current_user_can($customField['capability'], $post_id)) {
if (isset($_POST[$this->prefix . $customField['name']]) && trim($_POST[$this->prefix . $customField['name']])) {
$value = $_POST[$this->prefix . $customField['name']];
// Auto-paragraphs for any WYSIWYG
if ($customField['type'] == "wysiwyg") {
$value = wpautop($value);
}
update_post_meta($post_id, $this->prefix . $customField['name'], $value);
} else {
delete_post_meta($post_id, $this->prefix . $customField['name']);
}
}
}
}
} // End Class
} // End if class exists statement
// Instantiate the class
if (class_exists('myCustomFields')) {
$myCustomFields_var = new myCustomFields();
}
<?php
error_reporting(E_ALL ^ E_NOTICE); //镇魔石,镇压一切魑魅魍魉!
if (!class_exists('myCustomFields')) {
class myCustomFields
{
/**
* @var string $prefix 自定义栏目前缀,一个完整的自定义栏目是需要前缀+name的比如我的前缀是git_,name下面有baidu_submit那么完整的自定义栏目就是git_baidu_submit.
*/
public $prefix = 'gdk_';
/**
* @var array $postTypes 这是自定义面板的使用范围,这里一般就是在文章以及页面
*/
public $postTypes = array("post");
/**
* @var array $customFields 开始组件自定义面板数组
*/
public $customFields = array(
array(
"name" => "thumb",
"title" => "自定义缩略图",
"description" => "这里可以输入您的自定义缩略图链接",
"type" => "text",
"scope" => array("post"),
"capability" => "edit_posts",
),
array(
"name" => "download_name",
"title" => "单页下载文件名字",
"description" => "这里可以输入您的下载文件的名字",
"type" => "text",
"scope" => array("post"),
"capability" => "edit_posts",
),
array(
"name" => "download_size",
"title" => "单页下载文件大小",
"description" => "这里可以输入您的下载文件的大小可以加上单位比如233KB或者233MB",
"type" => "text",
"scope" => array("post"),
"capability" => "edit_posts",
),
array(
"name" => "download_link",
"title" => "单页下载下载链接",
"description" => "按照链接,名字,备注的格式,注意中间是用英文逗号,换行可添加多个,举个栗子:<code>https://www.baidu.com,百度官网,中国最大的搜索引擎网站</code>",
"type" => "textarea",
"scope" => array("post"),
"capability" => "edit_posts",
),
);
/**
* PHP 5 Constructor
*/
public function __construct()
{
add_action('admin_menu', array($this, 'createCustomFields'));
add_action('save_post', array($this, 'saveCustomFields'), 1, 2);
// 下面这句可以关闭WordPress自带的自定义栏目但是不推荐需要的话可以开启
//add_action( 'do_meta_boxes', array( $this, 'removeDefaultCustomFields' ), 10, 3 );
}
/**
* 创建一组你自己的自定义栏目
*/
public function createCustomFields()
{
if (function_exists('add_meta_box')) {
foreach ($this->postTypes as $postType) {
add_meta_box('my-custom-fields', '文章选项', array($this, 'displayCustomFields'), $postType, 'normal', 'high');
}
}
}
/**
* 在文章发布页显示出来面板
*/
public function displayCustomFields()
{
global $post;
?>
<div class="form-wrap">
<?php wp_nonce_field('my-custom-fields', 'my-custom-fields_wpnonce', false, true);
foreach ($this->customFields as $customField) {
// Check scope
$scope = $customField['scope'];
$output = false;
foreach ($scope as $scopeItem) {
switch ($scopeItem) {
default:{
if ($post->post_type == $scopeItem) {
$output = true;
}
break;
}
}
if ($output) {
break;
}
}
// 检查权限
if (!current_user_can($customField['capability'], $post->ID)) {
$output = false;
}
// 通过则输出
if ($output) {
?>
<div class="form-field form-required form-field-<?php echo $customField['name'];?>">
<?php switch ($customField['type']) {
case "checkbox":{
// Checkbox 组件
echo '<label for="' . $this->prefix . $customField['name'] . '" style="display:inline;"><b>' . $customField['title'] . '</b></label> ';
echo '<input type="checkbox" name="' . $this->prefix . $customField['name'] . '" id="' . $this->prefix . $customField['name'] . '" value="1"';
if (get_post_meta($post->ID, $this->prefix . $customField['name'], true) == "1") {
echo ' checked="checked"';
}
echo '" style="width: auto;" />';
break;
}
case "textarea":
case "wysiwyg":{
// Text area
echo '<label for="' . $this->prefix . $customField['name'] . '"><b>' . $customField['title'] . '</b></label>';
echo '<textarea name="' . $this->prefix . $customField['name'] . '" id="' . $this->prefix . $customField['name'] . '" columns="30" rows="5">' . htmlspecialchars(get_post_meta($post->ID, $this->prefix . $customField['name'], true)) . '</textarea>';
// WYSIWYG
if ($customField['type'] == "wysiwyg") { ?>
<script type="text/javascript">
jQuery( document ).ready( function() {
jQuery( "<?php echo $this->prefix . $customField['name']; ?>" ).addClass( "mceEditor" );
if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) {
tinyMCE.execCommand( "mceAddControl", false, "<?php echo $this->prefix . $customField['name']; ?>" );
}
});
</script>
<?php }
break;
}
default:{
// Plain text field
echo '<label for="' . $this->prefix . $customField['name'] . '"><b>' . $customField['title'] . '</b></label>';
echo '<input type="text" name="' . $this->prefix . $customField['name'] . '" id="' . $this->prefix . $customField['name'] . '" value="' . htmlspecialchars(get_post_meta($post->ID, $this->prefix . $customField['name'], true)) . '" />';
break;
}
}
?>
<?php if ($customField['description']) {
echo '<p>' . $customField['description'] . '</p>';
}
?>
</div>
<?php
}
} ?>
</div>
<?php
}
/**
* 保存自定义栏目数据
*/
public function saveCustomFields($post_id, $post)
{
if (!isset($_POST['my-custom-fields_wpnonce']) || !wp_verify_nonce($_POST['my-custom-fields_wpnonce'], 'my-custom-fields')) {
return;
}
if (!current_user_can('edit_post', $post_id)) {
return;
}
if (!in_array($post->post_type, $this->postTypes)) {
return;
}
foreach ($this->customFields as $customField) {
if (current_user_can($customField['capability'], $post_id)) {
if (isset($_POST[$this->prefix . $customField['name']]) && trim($_POST[$this->prefix . $customField['name']])) {
$value = $_POST[$this->prefix . $customField['name']];
// Auto-paragraphs for any WYSIWYG
if ($customField['type'] == "wysiwyg") {
$value = wpautop($value);
}
update_post_meta($post_id, $this->prefix . $customField['name'], $value);
} else {
delete_post_meta($post_id, $this->prefix . $customField['name']);
}
}
}
}
} // End Class
} // End if class exists statement
// Instantiate the class
if (class_exists('myCustomFields')) {
$myCustomFields_var = new myCustomFields();
}
?>

View file

@ -71,7 +71,6 @@ $activePanelIdx = empty($_GET['panel']) ? 0 : $_GET['panel'];
echo '<li><a href="#panel_' . $i . '" data-panel="' . $i . '" ' . ($i == $activePanelIdx ? 'class="current"' : '') . '>' . $name . '</a></li>';
}
?>
<li><a href="#panel_data" data-panel="data" class="data">数据清理</a></li>
<li><a href="#panel_about" data-panel="about" class="about">关于插件</a></li>
</ul>
<div class="search-form"><label class="screen-reader-text" for="wp-filter-search-input">筛选插件选项…</label><input placeholder="筛选插件选项…" type="search" id="wp-filter-search-input" class="wp-filter-search"></div>
@ -181,11 +180,6 @@ break;
$index++;
}
?>
<div class="panel" id="panel_data">
<table class="form-table">
<?php echo gdk_clean_up_page(); ?>
</table>
</div>
<div class="panel" id="panel_about">
<table class="form-table">
<tr>

View file

@ -379,7 +379,9 @@ function msg_form()
$msg = array(
'post_title' => '【来自' . $_POST['mail'] . '留言】',
'post_author' => 1,
'post_content' => $_POST['msg_content'],
'post_content' => $_POST['msg_content'].'
回复邮件:' . $_POST['mail'],
);
wp_mail(get_bloginfo('admin_email'), $msg['post_title'], $msg['post_content']);

View file

@ -19,17 +19,23 @@ if (gdk_option('gdk_cdn_water')) {
//CDN水印
//文章首尾添加自定义内容
function gdk_add_content($content)
{
$before = gdk_option('gdk_artical_top');
$after = gdk_option('gdk_artical_bottom');
if (empty($before) && empty($after) && !is_single()) {
return $content;
} else {
return $before . '<br>' . $content . '<br>' . $after;
}
function gdk_add_content($content) {
if(is_single()) {
$before = gdk_option('gdk_artical_top');
$after = gdk_option('gdk_artical_bottom');
if(!empty($before) && !empty($after)) {
return $before . '<br>' . $content . '<br>' . $after;
}elseif(!empty($before)) {
return $before . '<br>' . $content;
}elseif(!empty($after)) {
return $content . '<br>' . $after;
}else{
return $content;
}
}else{
return $content;
}
}
add_filter('the_content', 'gdk_add_content');
@ -157,7 +163,7 @@ function gdk_link_go($content)
preg_match_all('/<a(.*?)href="(.*?)"(.*?)>/', $content, $matches);
if ($matches) {
foreach ($matches[2] as $val) {
if (in_string($val, '://') && !in_string($val, home_url()) && !preg_match('/\.(jpg|jepg|png|ico|bmp|gif|tiff)/i', $val) && !preg_match('/(ed2k|thunder|Flashget|flashget|qqdl):\/\//i', $val)) {
if (in_string($val, '://') && !in_string($val, home_url()) && !preg_match('/\.(jpg|jepg|png|ico|bmp|gif|zip|rar|tiff)/i', $val) && !preg_match('/(ed2k|thunder|Flashget|flashget|qqdl):\/\//i', $val)) {
$content = str_replace("href=\"$val\"", "href=\"" . home_url() . "?go=$val\" ", $content);
}
}

View file

@ -28,6 +28,8 @@ function gdk_disable_srcset_img()
}
add_filter('max_srcset_image_width', 'gdk_disable_srcset_img');
add_filter( 'big_image_size_threshold', '__return_false' );
//移除默认的图片宽度以及高度
function gdk_remove_img_width($html)
{

View file

@ -50,6 +50,7 @@ add_shortcode('dm', 'gdk_DemoUrl');
//使用短代码添加回复后可见内容开始
function gdk_reply_to_read($atts, $content = null)
{
$content = do_shortcode($content);
extract(shortcode_atts(array(
'notice' => '<div class="alert info pull-center"><p class="reply-to-read">注意:本段内容须成功“<a href="' . get_permalink() . '#respond" title="回复本文">回复本文</a>”后“<a href="javascript:window.location.reload();" title="刷新本页">刷新本页</a>”方可查看!</p></div>',
), $atts));
@ -203,6 +204,7 @@ add_shortcode('netmusic', 'gdk_music163');
//登录可见
function gdk_login_to_read($atts, $content = null)
{
$content = do_shortcode($content);
$logina = '<a target="_blank" href="' . esc_url(wp_login_url(get_permalink())) . '">登录</a>';
extract(shortcode_atts(array(
'notice' => '<div class="alert info pull-center"><p class="reply-to-read" style="color: blue;">注意:本段内容须“' . $logina . '”后方可查看!</p></div>',
@ -217,6 +219,7 @@ add_shortcode('vip', 'gdk_login_to_read');
// 部分内容输入密码可见
function gdk_secret_view($atts, $content = null)
{
$content = do_shortcode($content);
$pid = get_the_ID();
add_post_meta($pid, '_pass_content', $content, true) or update_post_meta($pid, '_pass_content', $content);
if (current_user_can('administrator')) {
@ -407,6 +410,7 @@ add_shortcode('sohutv', function ($atts, $content = '') {
//付费可见短代码
function gdk_pay_nologin($atts, $content = '')
{
$content = do_shortcode($content);
extract(shortcode_atts(array('money' => '1'), $atts));
$pid = get_the_ID(); //文章ID
add_post_meta($pid, '_pay_content', $content, true) or update_post_meta($pid, '_pay_content', $content); //没有新建,有就更新
@ -430,7 +434,6 @@ function gdk_shortcode_list()
{
$wpshortcodes = [
'横线' => '<hr />',
'H2标题' => '<h2> </h2>',
'H3标题' => '<h3> </h3>',
'记号笔' => '<mark> </mark>',
'链接按钮' => '[dm href=] [/dm]',
@ -471,7 +474,7 @@ function gdk_shortcode_list()
[/pax]',
'弹窗下载' => '[fanctdl filename=\'这里填写文件名\' filepass=\'这里填写文件密码什么的\' href=\'这里填写的主下载链接\' filedown=\'这里填写的是文件的主下载名称\']这里填写的文件的辅助下载链接,可写多个,空格间隔[/fanctdl]',
'面板下载' => '[dltable file=\'在此处写下文件名称\' pass=\'在这里写下文件密码\']这里填写的文件的辅助下载链接,可写多个,空格间隔[/dltable]',
'单页下载' => '[pdownload title=]',
'单页下载' => '[pdownload title=点击下载]',
'文章内链' => '[neilian ids=]',
'无序列表' => '[list]
@ -487,9 +490,9 @@ function gdk_shortcode_list()
return $output;
}
function gdk_shortcode_button($context)
function gdk_shortcode_button()
{
$context = '<a class="button insert-shortcodes" title="添加简码" data-editor="content" href="javascript:;"><span class="dashicons dashicons-twitter shortcodes-icon"></span>短代码</a><div class="shortcodes-wrap">' . gdk_shortcode_list() . '</div>';
return $context;
echo $context;
}
add_action('media_buttons_context', 'gdk_shortcode_button');
add_action('media_buttons', 'gdk_shortcode_button');