From 07f32152d5fe95c97733a3064708f63d41f1f948 Mon Sep 17 00:00:00 2001 From: spirit Date: Fri, 15 Nov 2019 09:23:07 +0800 Subject: [PATCH] optimize --- functions.php | 6 ++++-- header.php | 2 +- inc/api.php | 2 +- js/sakura-app.js | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/functions.php b/functions.php index d6bd51d..006ced5 100644 --- a/functions.php +++ b/functions.php @@ -203,7 +203,9 @@ function sakura_scripts() { 'ajaxurl' => admin_url('admin-ajax.php'), 'order' => get_option('comment_order'), // ajax comments 'formpostion' => 'bottom', // ajax comments 默认为bottom,如果你的表单在顶部则设置为top。 - 'reply_link_version' => $reply_link_version + 'reply_link_version' => $reply_link_version, + 'api' => esc_url_raw( rest_url() ), + 'nonce' => wp_create_nonce( 'wp_rest' ) )); } add_action( 'wp_enqueue_scripts', 'sakura_scripts' ); @@ -1640,4 +1642,4 @@ function sakura_comment_notify($comment_id){ } add_action('comment_post', 'sakura_comment_notify'); -//code end \ No newline at end of file +//code end diff --git a/header.php b/header.php index 8f05888..96109ef 100644 --- a/header.php +++ b/header.php @@ -77,7 +77,7 @@ window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)} -> +> Plz rename the theme folder name as Sakura!
请将主题文件夹名改为 Sakura!'; ?> 主题需要 PHP 的 curl 支持!请在 `php.ini` 里开启或者联系你的主机商。
The theme requires PHP\'s curl support! Please turn on in `php.ini` or contact your hosting provider.'; ?>
diff --git a/inc/api.php b/inc/api.php index da10ac0..15c56c4 100644 --- a/inc/api.php +++ b/inc/api.php @@ -215,7 +215,7 @@ function SMMS_API($image) /* * 定制实时搜索 rest api - * @rest api接口路径:https://sakura.2heng.xin/wp-json/cache_search/v1/json/ + * @rest api接口路径:https://sakura.2heng.xin/wp-json/sakura/v1/cache_search/json * @可在cache_search_json()函数末尾通过设置 HTTP header 控制 json 缓存时间 */ function cache_search_json() diff --git a/js/sakura-app.js b/js/sakura-app.js index db66148..fb0754c 100644 --- a/js/sakura-app.js +++ b/js/sakura-app.js @@ -182,7 +182,7 @@ function attach_image() { var formData = new FormData(); formData.append('cmt_img_file', f); $.ajax({ - url: '/wp-json/sakura/v1/image/upload/?_wpnonce='+$('body').attr('nonce-data'), + url: Poi.api + 'sakura/v1/image/upload?_wpnonce=' + Poi.nonce, type: 'POST', processData: false, contentType: false, @@ -1376,7 +1376,7 @@ var home = location.href, $('html').css('overflow-y', 'hidden'); if (mashiro_option.live_search) { var QueryStorage = []; - search_a("https://" + document.domain + "/wp-json/sakura/v1/cache_search/json"); + search_a(Poi.api + "sakura/v1/cache_search/json"); var otxt = addComment.I("search-input"), list = addComment.I("PostlistBox"), @@ -1871,4 +1871,4 @@ if ((isWebkit || isOpera || isIe) && document.getElementById && window.addEventL element.focus(); } }, false); -} \ No newline at end of file +}