mirror of
https://github.com/mashirozx/sakura.git
synced 2024-11-22 14:58:14 +08:00
perf: update live-search
This commit is contained in:
parent
7d5ff98f87
commit
a62d42d372
13
inc/api.php
13
inc/api.php
@ -268,21 +268,24 @@ function SMMS_API($image)
|
|||||||
*/
|
*/
|
||||||
function cache_search_json()
|
function cache_search_json()
|
||||||
{
|
{
|
||||||
|
global $more;
|
||||||
$vowels = array("[", "{", "]", "}", "<", ">", "\r\n", "\r", "\n", "-", "'", '"', '`', " ", ":", ";", '\\', " ", "toc");
|
$vowels = array("[", "{", "]", "}", "<", ">", "\r\n", "\r", "\n", "-", "'", '"', '`', " ", ":", ";", '\\', " ", "toc");
|
||||||
$regex = <<<EOS
|
$regex = <<<EOS
|
||||||
/<\/?[a-zA-Z]+("[^"]*"|'[^']*'|[^'">])*>|begin[\S\s]*\/begin|hermit[\S\s]*\/hermit|img[\S\s]*\/img|{{.*?}}|:.*?:/m
|
/<\/?[a-zA-Z]+("[^"]*"|'[^']*'|[^'">])*>|begin[\S\s]*\/begin|hermit[\S\s]*\/hermit|img[\S\s]*\/img|{{.*?}}|:.*?:/m
|
||||||
EOS;
|
EOS;
|
||||||
|
$more = 1;
|
||||||
|
|
||||||
$posts = new WP_Query('posts_per_page=-1&post_status=publish&post_type=post');
|
$posts = new WP_Query('posts_per_page=-1&post_status=publish&post_type=post');
|
||||||
while ($posts->have_posts()): $posts->the_post();
|
while ($posts->have_posts()): $posts->the_post();
|
||||||
$output .= '{"type":"post","link":"' . get_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_permalink() . '","title":' . json_encode(get_the_title()) . ',"comments":"' . get_comments_number('0', '1', '%') . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', apply_filters( 'the_content', get_the_content())))) . '},';
|
||||||
endwhile;
|
endwhile;
|
||||||
wp_reset_postdata();
|
wp_reset_postdata();
|
||||||
|
|
||||||
$pages = get_pages();
|
$pages = new WP_Query('posts_per_page=-1&post_status=publish&post_type=page');
|
||||||
foreach ($pages as $page) {
|
while ($pages->have_posts()): $pages->the_post();
|
||||||
$output .= '{"type":"page","link":"' . get_page_link($page) . '","title":' . json_encode($page->post_title) . ',"comments":"' . $page->comment_count . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', $page->post_content))) . '},';
|
$output .= '{"type":"page","link":"' . get_permalink() . '","title":' . json_encode(get_the_title()) . ',"comments":"' . get_comments_number('0', '1', '%') . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', apply_filters( 'the_content', get_the_content())))) . '},';
|
||||||
}
|
endwhile;
|
||||||
|
wp_reset_postdata();
|
||||||
|
|
||||||
$tags = get_tags();
|
$tags = get_tags();
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
|
Loading…
Reference in New Issue
Block a user