From 4c90935f3064bfd31c822686a4a4716d3d0b104e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E8=90=BD?= Date: Thu, 20 Feb 2020 18:59:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/assets_load.php | 15 ++-- assets/css/gdk.css | 10 +-- assets/js/gdk.js | 2 +- class/wechat.php | 5 +- framework/options-config.php | 7 ++ framework/plugin-options.php | 2 + functions/Common.php | 170 ++++------------------------------- functions/shortcode.php | 66 +++++++++----- public/daohang.php | 10 +-- 9 files changed, 87 insertions(+), 200 deletions(-) diff --git a/assets/assets_load.php b/assets/assets_load.php index 3d81f65..3803629 100644 --- a/assets/assets_load.php +++ b/assets/assets_load.php @@ -16,17 +16,18 @@ 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( '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' ); wp_deregister_script('jquery'); - wp_enqueue_script('jquery', GDK_BASE_URL.'assets/js/jQuery.min.js', false, GDK_PLUGIN_VER, true);//加载自定义jQuery2.0.3 + wp_enqueue_script('jquery', 'https://cdn.jsdelivr.net/npm/jquery@2.1.0/dist/jquery.min.js', false, GDK_PLUGIN_VER, true);//加载自定义jQuery2.0.3 wp_enqueue_script('code_prettify_js', GDK_BASE_URL.'assets/js/prettify.min.js', array('jquery'), GDK_PLUGIN_VER, true); wp_enqueue_script('fancybox_js', GDK_BASE_URL.'assets/js/fancybox.min.js', array('jquery'), GDK_PLUGIN_VER, true); wp_enqueue_script('lazyload_js', GDK_BASE_URL.'assets/js/lazyload.min.js', array('jquery'), GDK_PLUGIN_VER, true); wp_enqueue_script('sweetalert_js','https://cdn.jsdelivr.net/combine/npm/sweetalert@2.0.0,npm/qrious@4.0.2', [], GDK_PLUGIN_VER, true); wp_enqueue_script('gdk_js', GDK_BASE_URL.'assets/js/gdk.js', array('jquery'), GDK_PLUGIN_VER, true); wp_localize_script('gdk_js', 'ajax', [ - 'url'=> admin_url('admin-ajax.php'), + 'url'=> admin_url('admin-ajax.php'), 'pass_nonce' => wp_create_nonce('pass_nonce'), 'pay_points' => wp_create_nonce('pay_points'), 'check_pay_points' => wp_create_nonce('check_pay_points'), @@ -59,7 +60,7 @@ jQuery(function($) { } }); $(".add-shortcode").click(function() { - send_to_editor(" " + $(this).data("shortcodes") + " "); + send_to_editor("" + $(this).data("shortcodes") + ""); $(".shortcodes-wrap").removeClass("is-active"); return false }); @@ -73,18 +74,18 @@ if ($("#replysubmit").length > 0) { } }); } - - + + /**end**/ - + }); { - check_code(a, `$ {code}`); /**文章id, 提取码 */ + check_code(a, `${code}`); /**文章id, 提取码 */ }); } else { /* 未支付,选择支付方式*/ pay_way(a, b, c); diff --git a/class/wechat.php b/class/wechat.php index c9ea8d1..ff8f4c0 100644 --- a/class/wechat.php +++ b/class/wechat.php @@ -238,8 +238,6 @@ class WeChat - -define("TOKEN", 'wxcaptcha'); //TOKEN值 define("WX_WELCOME", '欢迎关注极客公园'); //欢迎词 define("POSTNUM", '5'); //文章数量 define("DEFAULT_THUMB", '');//封面 @@ -255,9 +253,10 @@ add_action('pre_get_posts', 'wm_preprocess', 4); function wm_preprocess($wp_query) { global $object; + $wx_token = trim(gdk_option('gdk_wxmp_token')); if (!isset($object)) { //创建一个WeChat类的实例, 回调函数名称为"onMessage",即消息处理函数 - $object = new WeChat(TOKEN, "onMessage"); + $object = new WeChat($wx_token, "onMessage"); $object->process(); //处理消息 return; } diff --git a/framework/options-config.php b/framework/options-config.php index 9aa13c1..86d2d26 100644 --- a/framework/options-config.php +++ b/framework/options-config.php @@ -525,6 +525,13 @@ $gdk_options = [ 'id' => 'gdk_Server', 'type' => 'checkbox' ], + [ + 'name' => '微信公众号TOKEN', + 'desc' => '请输入您的微信公众号TOKEN,微信公众号后台获取', + 'id' => 'gdk_wxmp_token', + 'type' => 'text', + 'std' => '' + ], [ 'name' => '微信推送KEY', 'desc' => '请输入您的微信推送KEY', diff --git a/framework/plugin-options.php b/framework/plugin-options.php index c09e98e..8781f6a 100644 --- a/framework/plugin-options.php +++ b/framework/plugin-options.php @@ -353,6 +353,8 @@ jQuery(function ($) { + + }); post_excerpt; + $text = get_the_excerpt($post);//自带的摘要 if ('' == $text) { - $text = get_the_content(); - $text = strip_shortcodes($text); + $text = get_the_content();//获取文字 $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); } @@ -49,13 +17,10 @@ function gdk_print_excerpt($length, $post = null, $echo = true) $text = strip_shortcodes($text); $text = strip_tags($text); - $text = nc_substr_ext($text, 0, $length); - $excerpt = nc_reverse_strrchr($text, '。', 3); + $excerpt = wp_trim_words( $text, $length, $more ); if ($excerpt) { - $result = strip_tags(apply_filters('the_excerpt', $excerpt)).'...'; - } else { - $result = strip_tags(apply_filters('the_excerpt', $text)).'...'; + $result = $excerpt; } if ($echo == true) { echo $result; @@ -121,109 +86,6 @@ function nc_get_template_part_with_vars($slug, array $params = array(), $output } } -function nc_ajax_comment_callback() -{ - global $wpdb; - $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0; - $post = get_post($comment_post_ID); - $post_author = $post->post_author; - if (empty($post->comment_status)) { - do_action('comment_id_not_found', $comment_post_ID); - nc_ajax_comment_err('Invalid comment status.'); - } - $status = get_post_status($post); - $status_obj = get_post_status_object($status); - if (!comments_open($comment_post_ID)) { - do_action('comment_closed', $comment_post_ID); - nc_ajax_comment_err(__('Sorry, comments are closed.', 'jimu')); - } elseif ('trash' == $status) { - do_action('comment_on_trash', $comment_post_ID); - nc_ajax_comment_err(__('Unknown error.', 'jimu')); - } elseif (!$status_obj->public && !$status_obj->private) { - do_action('comment_on_draft', $comment_post_ID); - nc_ajax_comment_err(__('Unknown error.', 'jimu')); - } elseif (post_password_required($comment_post_ID)) { - do_action('comment_on_password_protected', $comment_post_ID); - nc_ajax_comment_err(__('Password protected.', 'jimu')); - } else { - do_action('pre_comment_on_post', $comment_post_ID); - } - - $comment_author = (isset($_POST['author'])) ? trim(strip_tags($_POST['author'])) : null; - $comment_author_email = (isset($_POST['email'])) ? trim($_POST['email']) : null; - $comment_author_url = (isset($_POST['url'])) ? trim($_POST['url']) : null; - $comment_content = (isset($_POST['comment'])) ? trim($_POST['comment']) : null; - $user = wp_get_current_user(); - $user_id = $user->ID; - if ($user->exists()) { - if (empty($user->display_name)) { - $user->display_name=$user->user_login; - } - $comment_author = esc_sql($user->display_name); - $comment_author_email = esc_sql($user->user_email); - $comment_author_url = esc_sql($user->user_url); - $user_id = esc_sql($user->ID); - } else { - if (get_option('comment_registration') || 'private' == $status) { - nc_ajax_comment_err('

'.__('Sorry, you must be logged in to leave a comment', 'jimu').'

'); - } // 抱歉,您必须登录后才能发表评论。 - } - $comment_type = ''; - if (get_option('require_name_email') && !$user->exists()) { - if (6 > strlen($comment_author_email) || '' == $comment_author) { - nc_ajax_comment_err('

'.__('Please fill in the required options (Name, Email).', 'jimu').'

'); - } // 错误:请填写必须的选项(姓名,电子邮件)。 - elseif (!is_email($comment_author_email)) { - nc_ajax_comment_err('

'.__('Please input a valid email address.', 'jimu').'

'); - } // 错误:请输入有效的电子邮件地址。 - } - if ('' == $comment_content) { - nc_ajax_comment_err('

'.__('Say something...', 'jimu').'

'); - } // 说点什么吧 - $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$comment_author' "; - if ($comment_author_email) { - $dupe .= "OR comment_author_email = '$comment_author_email' "; - } - $dupe .= ") AND comment_content = '$comment_content' LIMIT 1"; - if ($wpdb->get_var($dupe)) { - nc_ajax_comment_err('

'.__('Please do not repeat your comments. :)', 'jimu').'

'); // Do not repeat comments aha~似乎说过这句话了 - } - - if ($lasttime = $wpdb->get_var($wpdb->prepare("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author = %s ORDER BY comment_date DESC LIMIT 1", $comment_author))) { - $time_lastcomment = mysql2date('U', $lasttime, false); - $time_newcomment = mysql2date('U', current_time('mysql', 1), false); - $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); - if ($flood_die) { - nc_ajax_comment_err('

'.__('You reply too fast. Take it easy.', 'jimu').'

'); // 你回复太快啦。慢慢来。 - } - } - $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0; - $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); - - $comment_id = wp_new_comment($commentdata); - - - $comment = get_comment($comment_id); - do_action('set_comment_cookies', $comment, $user, true); - $comment_depth = 1; - $tmp_c = $comment; - while ($tmp_c->comment_parent != 0) { - $comment_depth++; - $tmp_c = get_comment($tmp_c->comment_parent); - } - $GLOBALS['comment'] = $comment; - get_template_part('comment'); ?> - $login_name, 'display_name' => $nickname, @@ -1303,15 +1161,17 @@ function wx_captcha(){ $min = floor(date("i")/2); $day = date("d"); $day = ltrim($day,0); - $url = home_url(); - $captcha = sha1($min.$url); + $home = home_url(); + $wx_token = trim(gdk_option('gdk_wxmp_token')); + $captcha = sha1($min.$home.$wx_token); $captcha = substr($captcha , $day , 6); return $captcha; } + function gdk_post_dropdown(){ - /* Option list of all post */ + /* Option list of all post */ $gdk_options_posts = []; $gdk_options_posts_obj = get_posts('posts_per_page=-1'); $gdk_options_posts[''] = '选择文章'; @@ -1331,7 +1191,7 @@ function gdk_categories_dropdown(){ 'hide_empty' => 1, 'hierarchical' => 1, 'taxonomy' => 'category' - ); + ); $gdk_option_categories = []; $gdk_category_lists = get_categories( $gdk_args ); $gdk_option_categories[''] = '选择分类'; @@ -1350,7 +1210,7 @@ function gdk_tag_dropdown(){ 'hide_empty' => 1, 'hierarchical' => 1, 'taxonomy' => 'tag' - ); + ); $gdk_option_tags = []; $gdk_tag_lists = get_tags( $gdk_args ); $gdk_option_tags[''] = '选择标签'; diff --git a/functions/shortcode.php b/functions/shortcode.php index ad22349..401cf80 100644 --- a/functions/shortcode.php +++ b/functions/shortcode.php @@ -79,41 +79,37 @@ add_shortcode('reply', 'gdk_reply_to_read'); //绿色提醒框 function gdk_toz($atts, $content = null) { - return '
' . $content . '
'; + return '
' . $content . '
'; } add_shortcode('v_notice', 'gdk_toz'); //红色提醒框 function gdk_toa($atts, $content = null) { - return '
' . $content . '
'; + return '
' . $content . '
'; } add_shortcode('v_error', 'gdk_toa'); //黄色提醒框 function gdk_toc($atts, $content = null) { - return '
' . $content . '
'; + return '
' . $content . '
'; } add_shortcode('v_warn', 'gdk_toc'); -//灰色提醒框 -function gdk_tob($atts, $content = null) { - return '
' . $content . '
'; -} -add_shortcode('v_tips', 'gdk_tob'); + //蓝色提醒框 function gdk_tod($atts, $content = null) { - return '
' . $content . '
'; + return '
' . $content . '
'; } add_shortcode('v_blue', 'gdk_tod'); //蓝边文本框 function gdk_toe($atts, $content = null) { - return '
' . $content . '
'; + return '
' . $content . '
'; } -add_shortcode('v_act', 'gdk_toe'); +add_shortcode('v_tips', 'gdk_toe'); //灵魂按钮 function gdk_tom($atts, $content = null) { extract(shortcode_atts(array( "href" => 'http://' ) , $atts)); - return '' . $content . ''; + return '' . $content . ''; } add_shortcode('lhb', 'gdk_tom'); //添加视频按钮 @@ -254,7 +250,7 @@ function gdk_insert_posts($atts, $content = null) { $content.= '

'; $content.= get_the_excerpt(); $content.= '

'; } wp_reset_postdata(); @@ -418,23 +414,45 @@ function gdk_shortcode_list() { '透明按钮'=>'[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]', + '绿色通知'=>'[v_notice] + +[/v_notice]', + '红色警告'=>'[v_error] + +[/v_error]', + '黄色错误'=>'[v_warn] + +[/v_warn]', + '蓝色提示'=>'[v_blue] + +[/v_blue]', + '默认提示'=>'[v_tips] + +[/v_tips]', + '隐藏收缩'=>'[collapse title=\'\'] + +[/collapse]', + '回复可见'=>'[reply] + +[/reply]', + '登陆可见'=>'[vip] + +[/vip]', + '微信验证码可见'=>'[wxcaptcha] + +[/wxcaptcha]', '积分购买可见'=>'[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]' + '无序列表'=>'[list] + +[/list]', + '表格简码'=>'[table] + +[/table]' ]; $output = ''; foreach ($wpshortcodes as $name => $alt) { diff --git a/public/daohang.php b/public/daohang.php index b63712f..f7f431b 100644 --- a/public/daohang.php +++ b/public/daohang.php @@ -11,11 +11,11 @@ function gdk_daohang_html_api_handlers( $template ){ status_header(404); header('HTTP/1.0 404 Not Found'); $GLOBALS['wp_query']->set_404(); - include( get_query_template( '404' ) ); - exit; + include( get_query_template( '404' ) ); + exit; } $daohang = get_transient('gdk-daohang-html'); - + if( false === $daohang || empty( $daohang ) ){ $daohang = gdk_create_html_daohang(); set_transient( 'gdk-daohang-html', $daohang ); @@ -40,7 +40,7 @@ function gdk_create_html_daohang() { @@ -92,7 +92,7 @@ function gdk_create_html_daohang() {