Skip to content

Commit

Permalink
Close issue #103
Browse files Browse the repository at this point in the history
  • Loading branch information
spirit1431007 committed Aug 18, 2019
1 parent 8d0a24d commit ea8fdad
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 93 deletions.
28 changes: 10 additions & 18 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @package Sakura
*/

define( 'SAKURA_VERSION', '3.2.2' );
define( 'SAKURA_VERSION', '3.2.3' );
define( 'BUILD_VERSION', '3' );
define( 'JSDELIVR_VERSION', '3.6.7' );

Expand All @@ -28,16 +28,7 @@
require_once dirname( __FILE__ ) . '/inc/options-framework.php';
}

//live search
if(akina_option('live_search')){
if (file_exists(get_wp_root_path().'/themes/Sakura/cache/search.json')) {
if (time() - filemtime(get_wp_root_path().'/themes/Sakura/cache/search.json') > 10800) {
require_once(dirname( __FILE__ ) .'/inc/cache-search.php');
}
}else {
require_once(dirname( __FILE__ ) .'/inc/cache-search.php');
}
}


function akina_setup() {
/*
Expand Down Expand Up @@ -1670,12 +1661,13 @@ function cache_search_json() {

return $result;
}

add_action( 'rest_api_init', function () {
register_rest_route( 'cache_search/v1', '/json/', array(
'methods' => 'GET',
'callback' => 'cache_search_json',
) );
} );
if(akina_option('live_search')){
add_action( 'rest_api_init', function () {
register_rest_route( 'cache_search/v1', '/json/', array(
'methods' => 'GET',
'callback' => 'cache_search_json',
) );
} );
}

//code end
71 changes: 0 additions & 71 deletions inc/cache-search.php

This file was deleted.

2 changes: 1 addition & 1 deletion js/sakura-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ var home = location.href,
$('html').css('overflow-y','hidden');
if (mashiro_option.live_search) {
var QueryStorage = [];
search_a("https://"+document.domain+"/wp-content/themes/Sakura/cache/search.json");
search_a("https://"+document.domain+"/wp-json/cache_search/v1/json/");

var otxt = document.getElementById("search-input"),
list = document.getElementById("PostlistBox"),
Expand Down
2 changes: 1 addition & 1 deletion options.php
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ function optionsframework_options() {

$options[] = array(
'name' => __('启用实时搜索', 'options_framework_theme'),
'desc' => __('前台实现实时搜索,每3小时更新一次缓存,可通过删除主题文件夹下的 cache 文件夹手动更新缓存'),
'desc' => __('前台实现实时搜索,调用 Rest API 每小时更新一次缓存,可在 functions.php 里手动设置缓存时间'),
'id' => 'live_search',
'std' => '0',
'type' => 'checkbox');
Expand Down
4 changes: 2 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Theme URI: https://2heng.xin/theme-sakura/
Author: Mashiro, Louie, Fuzzz
Author URI: http://2heng.xin
Description: Akina主题分支(原版地址 http://www.akina.pw/themeakina)
Version: 3.2.2
Version: 3.2.3
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: akina
Expand Down Expand Up @@ -4371,7 +4371,7 @@ i.iconfont.js-toggle-search.iconsearch {
.ins-section .ins-search-item .ins-search-preview {
font-size: 12px;
color: #9a9a9a;
margin: 5px 0 0 20px;
margin: 5px 0 0 0px;
cursor: url(https://cdn.jsdelivr.net/gh/moezx/[email protected]/img/Sakura/cursor/ayuda.cur),auto;
}

Expand Down

0 comments on commit ea8fdad

Please sign in to comment.