Merge pull request #14 from mashirozx/dev

Dev update
pull/180/head
Ekkles 2019-11-30 01:03:30 +13:00 committed by GitHub
commit 83f535b7bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 388 additions and 139 deletions

View File

@ -1557,6 +1557,44 @@ function html_tag_parser($content) {
',
$content
);
}
//html tag parser for rss
if(is_feed()) {
//Fancybox
$url_regex ='((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))';
if (preg_match_all('/\!\{.*?\)\[.*?\]/i', $content,$matches)){
$i=0;
if ($i<sizeof($matches)) {
$content=str_replace($matches[$i],preg_replace(
'/!\{([^\{\}]+)*\}\('.$url_regex.'\)\['.$url_regex.'\]/i',
'<a data-fancybox="gallery"
data-caption="$1"
class="fancybox"
href="$2"
alt="$1"
title="$1"><img src="$7" target="_blank" rel="nofollow" class="fancybox"></a>',
$matches[$i]),
$content);
$i++;
}
}
$content=preg_replace(
'/!\{([^\{\}]+)*\}\('.$url_regex.'\)/i',
'<a data-fancybox="gallery"
data-caption="$1"
class="fancybox"
href="$2"
alt="$1"
title="$1"><img src="$2" target="_blank" rel="nofollow" class="fancybox"></a>',
$content
);
//Github cards
$content=preg_replace(
'/\[github repo=[\'"]([^\'"]+)[\'"]\]/i',
'<a href="https://github.com/$1">',
$content
);
}
return $content;
}

View File

@ -79,7 +79,6 @@ window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}
</head>
<body <?php body_class(); ?>>
<?php if(get_template_directory_uri() != get_site_url().'/wp-content/themes/Sakura') echo '<div style="position:fixed;height:100%;width:100%;top:0;left:0;font-size:20px;z-index:999999;background-color: #fff;">Plz rename the theme folder name as <span style="color:red">Sakura</span>!<br>请将主题文件夹名改为 <span style="color:red">Sakura</span></div>'; ?>
<?php if(!function_exists('curl_exec')) echo '<div style="position:fixed;height:100%;width:100%;top:0;left:0;font-size:20px;z-index:999999;background-color: #fff;">主题需要 PHP 的 curl 支持!请在 `php.ini` 里开启或者联系你的主机商。<br>The theme requires PHP\'s curl support! Please turn on in `php.ini` or contact your hosting provider.</div>'; ?>
<div class="scrollbar" id="bar"></div>
<section id="main-container">
<?php

View File

@ -4,84 +4,77 @@
* Router
*/
add_action('rest_api_init', function () {
register_rest_route('sakura/v1', '/image/upload', array(
'methods' => 'POST',
'callback' => 'upload_image',
));
register_rest_route('sakura/v1', '/cache_search/json', array(
'methods' => 'GET',
'callback' => 'cache_search_json',
));
register_rest_route('sakura/v1', '/image/upload', array(
'methods' => 'POST',
'callback' => 'upload_image',
));
register_rest_route('sakura/v1', '/cache_search/json', array(
'methods' => 'GET',
'callback' => 'cache_search_json',
));
});
/**
* Image uploader response
*/
function upload_image(WP_REST_Request $request)
{
// see: https://developer.wordpress.org/rest-api/requests/
function upload_image(WP_REST_Request $request) {
// see: https://developer.wordpress.org/rest-api/requests/
// handle file params $file === $_FILES
/**
* curl \
* -F "filecomment=This is an img file" \
* -F "cmt_img_file=@screenshot.jpg" \
* https://dev.2heng.xin/wp-json/sakura/v1/image/upload
*/
// $file = $request->get_file_params();
if ( !check_ajax_referer('wp_rest', '_wpnonce', false) ) {
$output = array(
'status' => 403,
'success' => false,
'message' => 'Unauthorized client.',
'link' => "https://view.moezx.cc/images/2019/11/14/step04.md.png",
'proxy' => akina_option('cmt_image_proxy') . "https://view.moezx.cc/images/2019/11/14/step04.md.png",
);
$result = new WP_REST_Response($output, 403);
// handle file params $file === $_FILES
/**
* curl \
* -F "filecomment=This is an img file" \
* -F "cmt_img_file=@screenshot.jpg" \
* https://dev.2heng.xin/wp-json/sakura/v1/image/upload
*/
// $file = $request->get_file_params();
if (!check_ajax_referer('wp_rest', '_wpnonce', false)) {
$output = array(
'status' => 403,
'success' => false,
'message' => 'Unauthorized client.',
'link' => "https://view.moezx.cc/images/2019/11/14/step04.md.png",
'proxy' => akina_option('cmt_image_proxy') . "https://view.moezx.cc/images/2019/11/14/step04.md.png",
);
$result = new WP_REST_Response($output, 403);
$result->set_headers(array('Content-Type' => 'application/json'));
return $result;
}
switch (akina_option("img_upload_api")) {
case 'imgur':
$image = file_get_contents($_FILES["cmt_img_file"]["tmp_name"]);
$API_Request = Imgur_API($image);
break;
case 'smms':
$image = $_FILES;
$API_Request = SMMS_API($image);
break;
case 'chevereto':
$image = file_get_contents($_FILES["cmt_img_file"]["tmp_name"]);
$API_Request = Chevereto_API($image);
break;
}
$result = new WP_REST_Response($API_Request, $API_Request->status);
$result->set_headers(array('Content-Type' => 'application/json'));
return $result;
}
switch (akina_option("img_upload_api")) {
case 'imgur':
$image = file_get_contents($_FILES["cmt_img_file"]["tmp_name"]);
$API_Request = Imgur_API($image);
break;
case 'smms':
$image = $_FILES;
$API_Request = SMMS_API($image);
break;
case 'chevereto':
$image = file_get_contents($_FILES["cmt_img_file"]["tmp_name"]);
$API_Request = Chevereto_API($image);
break;
}
$result = new WP_REST_Response($API_Request, $API_Request->status);
$result->set_headers(array('Content-Type' => 'application/json'));
return $result;
}
/**
* Chevereto upload interface
*/
function Chevereto_API($image)
{
$fields = array(
'source' => base64_encode($image),
'key' => akina_option('chevereto_api_key')
function Chevereto_API($image) {
$upload_url = akina_option('cheverto_url').'/api/1/upload';
$args = array(
'body' => array(
'source' => base64_encode($image),
'key' => akina_option('chevereto_api_key')
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, akina_option('cheverto_url').'/api/1/upload');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$reply = curl_exec($ch);
curl_close($ch);
$reply = json_decode($reply);
$response = wp_remote_post($upload_url, $args);
$reply = json_decode($response["body"]);
if ($reply->status_txt == 'OK' && $reply->status_code == 200) {
$status = 200;
@ -109,21 +102,20 @@ function Chevereto_API($image)
/**
* Imgur upload interface
*/
function Imgur_API($image)
{
function Imgur_API($image) {
$client_id = akina_option('imgur_client_id');
$upload_url = akina_option('imgur_upload_image_proxy');
$args = array(
'headers' => array(
'Authorization' => 'Client-ID ' . $client_id
),
'body' => array(
'image' => base64_encode($image)
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, akina_option('imgur_upload_image_proxy'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . $client_id));
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => base64_encode($image)));
$reply = curl_exec($ch);
curl_close($ch);
$reply = json_decode($reply);
$response = wp_remote_post($upload_url, $args);
$reply = json_decode($response["body"]);
if ($reply->success && $reply->status == 200) {
$status = 200;
@ -151,66 +143,66 @@ function Imgur_API($image)
/**
* smms upload interface
*/
function SMMS_API($image)
{
$client_id = akina_option('smms_client_id');
function SMMS_API($image) {
$client_id = akina_option('smms_client_id');
$upload_url = "https://sm.ms/api/v2/upload";
$filename = $image['cmt_img_file']['name'];
$filedata = $image['cmt_img_file']['tmp_name'];
$Boundary = wp_generate_password();
$bits = file_get_contents($filedata);
$filename = $image['cmt_img_file']['name'];
$filedata = $image['cmt_img_file']['tmp_name'];
$filesize = $image['cmt_img_file']['size'];
$headers = array();
array_push($headers, "Content-Type: multipart/form-data; boundary=$Boundary");
array_push($headers, '');
array_push($headers, "Authorization: Basic " . $client_id);
array_push($headers, '');
array_push($headers, "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97");
$headers = implode("\r\n", $headers);
$url = "https://sm.ms/api/v2/upload";
$headers = array();
array_push($headers, "Content-Type: multipart/form-data");
array_push($headers, "Authorization: Basic " . $client_id);
array_push($headers, "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97");
$fields = array();
array_push($fields, "--" . $Boundary);
array_push($fields, "Content-Disposition: form-data; name=\"smfile\"; filename=\"$filename\"");
array_push($fields, '');
array_push($fields, $bits);
array_push($fields, '');
array_push($fields, "--" . $Boundary . "--");
$fields = implode("\r\n", $fields);
$finfo = new \finfo(FILEINFO_MIME_TYPE);
$mimetype = $finfo->file($filedata);
$args = array(
'headers' => $headers,
'body' => $fields
);
$fields = array('smfile' => curl_file_create($filedata, $mimetype, $filename));
$response = wp_remote_post($upload_url, $args);
$reply = json_decode($response["body"]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$reply = curl_exec($ch);
curl_close($ch);
$reply = json_decode($reply);
if ($reply->success && $reply->code == 'success') {
$status = 200;
$success = true;
$message = $reply->message;
$link = $reply->data->url;
$proxy = akina_option('cmt_image_proxy') . $link;
} else if (preg_match("/Image upload repeated limit/i", $reply->message, $matches)) {
$status = 200; // sm.ms 接口不规范,建议检测到重复的情况下返回标准化的 code并单独把 url 放进一个字段
$success = true;
$message = $reply->message;
$link = str_replace('Image upload repeated limit, this image exists at: ', '', $reply->message);
$proxy = akina_option('cmt_image_proxy') . $link;
} else {
$status = 400;
$success = false;
$message = $reply->message;
$link = 'https://view.moezx.cc/images/2019/10/28/default_d_h_large.gif';
$proxy = akina_option('cmt_image_proxy') . $link;
}
$output = array(
'status' => $status,
'success' => $success,
'message' => $message,
'link' => $link,
'proxy' => $proxy,
);
return $output;
if ($reply->success && $reply->code == 'success') {
$status = 200;
$success = true;
$message = $reply->message;
$link = $reply->data->url;
$proxy = akina_option('cmt_image_proxy') . $link;
} else if (preg_match("/Image upload repeated limit/i", $reply->message, $matches)) {
$status = 200; // sm.ms 接口不规范,建议检测到重复的情况下返回标准化的 code并单独把 url 放进一个字段
$success = true;
$message = $reply->message;
$link = str_replace('Image upload repeated limit, this image exists at: ', '', $reply->message);
$proxy = akina_option('cmt_image_proxy') . $link;
} else {
$status = 400;
$success = false;
$message = $reply->message;
$link = 'https://view.moezx.cc/images/2019/10/28/default_d_h_large.gif';
$proxy = akina_option('cmt_image_proxy') . $link;
}
$output = array(
'status' => $status,
'success' => $success,
'message' => $message,
'link' => $link,
'proxy' => $proxy,
);
return $output;
}
/*
@ -218,8 +210,7 @@ function SMMS_API($image)
* @rest api接口路径https://sakura.2heng.xin/wp-json/sakura/v1/cache_search/json
* @可在cache_search_json()函数末尾通过设置 HTTP header 控制 json 缓存时间
*/
function cache_search_json()
{
function cache_search_json() {
$vowels = array("[", "{", "]", "}", "<", ">", "\r\n", "\r", "\n", "-", "'", '"', '`', " ", ":", ";", '\\', " ", "toc");
$regex = <<<EOS
/<\/?[a-zA-Z]+("[^"]*"|'[^']*'|[^'">])*>|begin[\S\s]*\/begin|hermit[\S\s]*\/hermit|img[\S\s]*\/img|{{.*?}}|:.*?:/m
@ -227,7 +218,7 @@ EOS;
$posts = new WP_Query('posts_per_page=-1&post_status=publish&post_type=post');
while ($posts->have_posts()): $posts->the_post();
$output .= '{"type":"post","link":"' . get_post_permalink() . '","title":' . json_encode(get_the_title()) . ',"comments":"' . get_comments_number('0', '1', '%') . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', get_the_content()))) . '},';
$output .= '{"type":"post","link":"' . get_post_permalink() . '","title":' . json_encode(get_the_title()) . ',"comments":"' . get_comments_number('0', '1', '%') . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', get_the_content()))) . '},';
endwhile;
wp_reset_postdata();
@ -262,8 +253,12 @@ EOS;
$data = '[' . $output . ']';
$result = new WP_REST_Response(json_decode($data), 200);
$result->set_headers(array('Content-Type' => 'application/json',
'Cache-Control' => 'max-age=3600')); // json 缓存控制
$result->set_headers(
array(
'Content-Type' => 'application/json',
'Cache-Control' => 'max-age=3600'// json 缓存控制
)
);
return $result;
}

3
manifest/.vscode/settings.json vendored 100644
View File

@ -0,0 +1,3 @@
{
"python.pythonPath": "C:\\Users\\Mashiro\\AppData\\Local\\Programs\\Python\\Python38\\python.exe"
}

45
manifest/README.md 100644
View File

@ -0,0 +1,45 @@
封面图生成工具
===
### 依赖
Python3
PIL (Pillow)
### 安装依赖
安装 Python <https://docs.python.org/zh-cn/3.7/using/index.html>
安装 PIL
```bash
# Linix/Mac Terminal
pip install Pillow
# 如果也安装了 Python 2需要指定 pip 版本:
pip3 install Pillow
# Windows Powershell 或者 CMD
pip install Pillow
# 如果也安装了 Python 2需要指定 pip 版本:
pip3 install Pillow
# 如果提示权限不足([WinError 5] Access is denied请运行
pip install Pillow --user
```
### 运行
把图片文件放到 `gallary` 目录Windows 可直接双击 manifest.py或者和其他操作系统一样在 Terminal、Powershell、CMD 中运行:
```bash
# 切换到 manifest.py 所在目录:
cd /path/to/manifest/
python manifest.py
# 如果也安装了 Python 2需要指定 Python 版本:
python3 manifest.py
```
GUI 程序开发中,除了以上运行 manifest.py 的方法以外,也可直接运行 qt.py 启动可视化窗口,需要安装 PyQT5
```bash
pip3 install PyQt5
python3 qt.py
```
### TODO
shell/batch 自动安装依赖、自动删除过期文件、压缩图片、GitHub API push、release

View File

@ -0,0 +1 @@
from .manifest import *

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
manifest/icon.ico 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

BIN
manifest/icon.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@ -0,0 +1 @@
{"19313b0d62b27c8ba022f60fbfedd5ee": {"source": "beyond_by_auroralion-dan5njb.jpg", "jpeg": ["jpeg/19313b0d62b27c8ba022f60fbfedd5ee.jpeg", "jpeg/19313b0d62b27c8ba022f60fbfedd5ee.th.jpeg"], "webp": ["webp/19313b0d62b27c8ba022f60fbfedd5ee.webp", "webp/19313b0d62b27c8ba022f60fbfedd5ee.th.webp"]}, "783bf161f47b32882f0e962fd4064de7": {"source": "pixar_up_movie_balloons_desktop_1920x1080_hd-wallpaper-507967.jpg", "jpeg": ["jpeg/783bf161f47b32882f0e962fd4064de7.jpeg", "jpeg/783bf161f47b32882f0e962fd4064de7.th.jpeg"], "webp": ["webp/783bf161f47b32882f0e962fd4064de7.webp", "webp/783bf161f47b32882f0e962fd4064de7.th.webp"]}, "e9f33c2c502ab43804964ce7edd431f9": {"source": "\u6d77\u306e\u7a7a(56993195)_by_\u590fT.jpg", "jpeg": ["jpeg/e9f33c2c502ab43804964ce7edd431f9.jpeg", "jpeg/e9f33c2c502ab43804964ce7edd431f9.th.jpeg"], "webp": ["webp/e9f33c2c502ab43804964ce7edd431f9.webp", "webp/e9f33c2c502ab43804964ce7edd431f9.th.webp"]}}

View File

@ -0,0 +1,72 @@
# coding=utf-8
'''
Created on Apr 23, 2018
Desc: Webp convertor
@author: Mashiro https://2heng.xin
'''
import os
import sys
import json
import hashlib
from PIL import Image
class Single(object):
def __init__(self, file, manifest):
self.file = file
self.mani = manifest
def hash(self):
hasher = hashlib.md5()
with open('gallary/' + self.file, 'rb') as afile:
buf = afile.read()
hasher.update(buf)
self.hash = hasher.hexdigest()
self.jpeg = 'jpeg/' + self.hash + '.jpeg'
self.webp = 'webp/' + self.hash + '.webp'
self.th_jpeg = 'jpeg/' + self.hash + '.th.jpeg'
self.th_webp = 'webp/' + self.hash + '.th.webp'
def optimize(self):
im = Image.open('gallary/' + self.file).convert('RGB')
im.save(self.jpeg, 'JPEG') # todo: TinyPNG API
im.save(self.webp, 'WEBP')
def thumbnail(self):
im = Image.open('gallary/' + self.file).convert('RGB')
im.thumbnail((450, 300))
im.save(self.th_jpeg, 'JPEG') # todo: TinyPNG API
im.save(self.th_webp, 'WEBP')
def manifest(self):
self.mani[self.hash] = {
'source': self.file,
'jpeg': ['jpeg/' + self.hash + '.jpeg', 'jpeg/' + self.hash + '.th.jpeg'],
'webp': ['webp/' + self.hash + '.webp', 'webp/' + self.hash + '.th.webp']
}
def main(self):
self.hash()
# if os.path.exists(self.jpeg) and os.path.exists(self.webp):
self.optimize()
self.thumbnail()
self.manifest()
return self.mani
def main():
onlyfiles = [f for f in os.listdir('gallary') if os.path.isfile(os.path.join('gallary', f))]
id = 1
Manifest = {}
for f in onlyfiles:
worker = Single(f, Manifest)
Manifest = worker.main()
print(str(id) + '/' + str(len(onlyfiles)))
id += 1
with open('manifest.json', 'w+') as json_file:
json.dump(Manifest, json_file)
if __name__ == '__main__':
main()
key = input('`manifest.json` saved. Press any key to quit.')
quit()

89
manifest/qt.py 100644
View File

@ -0,0 +1,89 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Created on Nov 29, 2019
Desc: Webp convertor QT
@author: Mashiro @ https://2heng.xin
"""
import sys
import time
from PyQt5.QtWidgets import QMainWindow, QWidget, QApplication, QPushButton, QMessageBox, QDesktopWidget, QGridLayout
from PyQt5.QtCore import QCoreApplication
from PyQt5.QtGui import QIcon
from manifest import main as manifest
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.statusBar().showMessage('Ready')
self.BtnWid = QWidget(self)
self.setCentralWidget(self.BtnWid)
grid = QGridLayout()
self.BtnWid.setLayout(grid)
names = ['Generate manifest.json',
'Pull from GitHub',
'Push to GitHub',
'Release on GitHub',
'Push manifest.json to WordPress',
'About and Turtor']
actions = [self.Action_1,
self.Action_0,
self.Action_0,
self.Action_0,
self.Action_0]
positions = [(i, j) for i in range(6) for j in range(1)]
for position, name, action in zip(positions, names, actions):
if name == '':
continue
button = QPushButton(name)
button.clicked.connect(action)
grid.addWidget(button, *position)
# self.resize(500, 500)
self.center()
self.setWindowTitle('Manifest Generator')
self.setWindowIcon(QIcon('icon.png'))
self.show()
def Action_0(self):
sender = self.sender()
self.statusBar().showMessage('"' + sender.text() + '" was pressed')
#Generate manifest.json
def Action_1(self):
# self.statusBar().showMessage('Processing...')
# time.sleep(1)
manifest()
self.statusBar().showMessage('`manifest.json` saved.')
def center(self):
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
def closeEvent(self, event):
reply = QMessageBox.question(self, 'Message',
"Are you sure to quit?", QMessageBox.Yes |
QMessageBox.No, QMessageBox.No)
if reply == QMessageBox.Yes:
event.accept()
else:
event.ignore()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MainWindow()
sys.exit(app.exec_())

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -1067,14 +1067,14 @@ function optionsframework_options() {
$options[] = array(
'name' => __('Enable live search', 'sakura'),/*启用实时搜索*/
'desc' => __('Real-time search in the foreground, call the Rest API to update the cache every hour, you can manually set the cache time in functions.php'),/*前台实现实时搜索,调用 Rest API 每小时更新一次缓存,可在 functions.php 里手动设置缓存时间*/
'desc' => __('Real-time search in the foreground, call the Rest API to update the cache every hour, you can manually set the cache time in functions.php', 'sakura'),/*前台实现实时搜索,调用 Rest API 每小时更新一次缓存,可在 functions.php 里手动设置缓存时间*/
'id' => 'live_search',
'std' => '0',
'type' => 'checkbox');
$options[] = array(
'name' => __('Include comments in live search', 'sakura'),/*实时搜索包含评论*/
'desc' => __('Search for comments in real-time search (not recommended if there are too many comments on the site)'),/*在实时搜索中搜索评论(如果网站评论数量太多不建议开启)*/
'desc' => __('Search for comments in real-time search (not recommended if there are too many comments on the site)', 'sakura'),/*在实时搜索中搜索评论(如果网站评论数量太多不建议开启)*/
'id' => 'live_search_comment',
'std' => '0',
'type' => 'checkbox');

View File

@ -8502,6 +8502,12 @@ h1[id*=toc-head]::before,h2[id*=toc-head]::before,h3[id*=toc-head]::before,h4[id
visibility:hidden
}
@media (max-width:860px) {
.widget-area{
display: none;
}
}
.widget-area {
position: fixed;
top: 100px;