mirror of
https://github.com/mashirozx/sakura.git
synced 2025-05-29 01:49:21 +08:00
style: format api.php
This commit is contained in:
parent
f1981117b5
commit
f5c53f2224
59
inc/api.php
59
inc/api.php
@ -278,45 +278,68 @@ function cache_search_json()
|
|||||||
/<\/?[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;
|
$more = 1;
|
||||||
|
$output = array();
|
||||||
|
|
||||||
$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, ' ', apply_filters( 'the_content', get_the_content())))) . '},';
|
$output[] = array(
|
||||||
|
"type" => "post",
|
||||||
|
"link" => get_permalink(),
|
||||||
|
"title" => get_the_title(),
|
||||||
|
"comments" => get_comments_number('0', '1', '%'),
|
||||||
|
"text" => str_replace($vowels, " ", preg_replace($regex, ' ', apply_filters( 'the_content', get_the_content())))
|
||||||
|
);
|
||||||
endwhile;
|
endwhile;
|
||||||
wp_reset_postdata();
|
wp_reset_postdata();
|
||||||
|
|
||||||
$pages = new WP_Query('posts_per_page=-1&post_status=publish&post_type=page');
|
$pages = new WP_Query('posts_per_page=-1&post_status=publish&post_type=page');
|
||||||
while ($pages->have_posts()): $pages->the_post();
|
while ($pages->have_posts()): $pages->the_post();
|
||||||
$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())))) . '},';
|
$output[] = array(
|
||||||
|
"type" => "page",
|
||||||
|
"link" => get_permalink(),
|
||||||
|
"title" => get_the_title(),
|
||||||
|
"comments" => get_comments_number('0', '1', '%'),
|
||||||
|
"text" => str_replace($vowels, " ", preg_replace($regex, ' ', apply_filters( 'the_content', get_the_content())))
|
||||||
|
);
|
||||||
endwhile;
|
endwhile;
|
||||||
wp_reset_postdata();
|
wp_reset_postdata();
|
||||||
|
|
||||||
$tags = get_tags();
|
$tags = get_tags();
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
$output .= '{"type":"tag","link":"' . get_term_link($tag) . '","title":' . json_encode($tag->name) . ',"comments":"","text":""},';
|
$output[] = array(
|
||||||
|
"type" => "tag",
|
||||||
|
"link" => get_term_link($tag),
|
||||||
|
"title" => $tag->name,
|
||||||
|
"comments" => "",
|
||||||
|
"text" => ""
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$categories = get_categories();
|
$categories = get_categories();
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
$output .= '{"type":"category","link":"' . get_term_link($category) . '","title":' . json_encode($category->name) . ',"comments":"","text":""},';
|
$output[] = array(
|
||||||
|
"type" => "category",
|
||||||
|
"link" => get_term_link($category),
|
||||||
|
"title" => $category->name,
|
||||||
|
"comments" => "",
|
||||||
|
"text" => ""
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (akina_option('live_search_comment')) {
|
if (akina_option('live_search_comment')) {
|
||||||
$comments = get_comments();
|
$comments = get_comments();
|
||||||
foreach ($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
$is_private = get_comment_meta($comment->comment_ID, '_private', true);
|
$is_private = get_comment_meta($comment->comment_ID, '_private', true);
|
||||||
if ($is_private) {
|
$output[] = array(
|
||||||
$output .= '{"type":"comment","link":"' . get_comment_link($comment) . '","title":' . json_encode(get_the_title($comment->comment_post_ID)) . ',"comments":"","text":' . json_encode($comment->comment_author . ":" . __("The comment is private", "sakura") /*该评论为私密评论*/) . '},';
|
"type" => "comment",
|
||||||
continue;
|
"link" => get_comment_link($comment),
|
||||||
} else {
|
"title" => get_the_title($comment->comment_post_ID),
|
||||||
$output .= '{"type":"comment","link":"' . get_comment_link($comment) . '","title":' . json_encode(get_the_title($comment->comment_post_ID)) . ',"comments":"","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, " ", $comment->comment_author . ":" . $comment->comment_content))) . '},';
|
"comments" => "",
|
||||||
}
|
"text" => $is_private ? ($comment->comment_author . ": " . __('The comment is private', 'sakura')) : str_replace($vowels, ' ', preg_replace($regex, ' ', $comment->comment_author . ":" . $comment->comment_content))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = substr($output, 0, strlen($output) - 1);
|
$result = new WP_REST_Response($output, 200);
|
||||||
|
|
||||||
$data = '[' . $output . ']';
|
|
||||||
$result = new WP_REST_Response(json_decode($data), 200);
|
|
||||||
$result->set_headers(
|
$result->set_headers(
|
||||||
array(
|
array(
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
@ -415,9 +438,13 @@ function get_qq_avatar(){
|
|||||||
$imgurl='https://q2.qlogo.cn/headimg_dl?dst_uin='.$matches[0].'&spec=100';
|
$imgurl='https://q2.qlogo.cn/headimg_dl?dst_uin='.$matches[0].'&spec=100';
|
||||||
if(akina_option('qq_avatar_link')=='type_2'){
|
if(akina_option('qq_avatar_link')=='type_2'){
|
||||||
$imgdata = file_get_contents($imgurl);
|
$imgdata = file_get_contents($imgurl);
|
||||||
header("Content-type: image/jpeg");
|
$response = new WP_REST_Response();
|
||||||
header("Cache-Control: max-age=86400");
|
$response->set_headers(array(
|
||||||
|
'Content-Type' => 'image/jpeg',
|
||||||
|
'Cache-Control' => 'max-age=86400'
|
||||||
|
));
|
||||||
echo $imgdata;
|
echo $imgdata;
|
||||||
|
return $response;
|
||||||
}else{
|
}else{
|
||||||
$response = new WP_REST_Response();
|
$response = new WP_REST_Response();
|
||||||
$response->set_status(301);
|
$response->set_status(301);
|
||||||
|
@ -931,27 +931,6 @@ function getqqinfo() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// $.ajax({
|
|
||||||
// type: 'get',
|
|
||||||
// url: mashiro_option.qq_avatar_api_url + '?type=getqqavatar&qq=' + qq,
|
|
||||||
// dataType: 'jsonp',
|
|
||||||
// jsonp: 'callback',
|
|
||||||
// jsonpCallback: 'qqavatarCallBack',
|
|
||||||
// success: function (data) {
|
|
||||||
// $('div.comment-user-avatar img').attr('src', data[qq]);
|
|
||||||
// setCookie('user_avatar', data[qq], 30);
|
|
||||||
// },
|
|
||||||
// error: function () {
|
|
||||||
// cached.filter('#qq,#email,#url').val('');
|
|
||||||
// if (!cached.filter('#qq').val()) {
|
|
||||||
// $('.qq-check').css('display', 'none');
|
|
||||||
// $('.gravatar-check').css('display', 'block');
|
|
||||||
// setCookie('user_qq', '', 30);
|
|
||||||
// $('div.comment-user-avatar img').attr('src', get_gravatar(cached.filter('#email').val(), 80));
|
|
||||||
// setCookie('user_avatar', get_gravatar(cached.filter('#email').val(), 80), 30);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
if (getCookie('user_avatar') && getCookie('user_email') && getCookie('is_user_qq') == 'no' && !getCookie('user_qq_email')) {
|
if (getCookie('user_avatar') && getCookie('user_email') && getCookie('is_user_qq') == 'no' && !getCookie('user_qq_email')) {
|
||||||
$('div.comment-user-avatar img').attr('src', getCookie('user_avatar'));
|
$('div.comment-user-avatar img').attr('src', getCookie('user_avatar'));
|
||||||
@ -1024,6 +1003,8 @@ function load_bangumi() {
|
|||||||
var html = JSON.parse(xhr.responseText);
|
var html = JSON.parse(xhr.responseText);
|
||||||
$("#bangumi-pagination").remove();
|
$("#bangumi-pagination").remove();
|
||||||
$(".row").append(html);
|
$(".row").append(html);
|
||||||
|
}else{
|
||||||
|
$("#bangumi-pagination a").removeClass("loading").html('<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> ERROR ');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.send();
|
xhr.send();
|
||||||
@ -1615,7 +1596,7 @@ var home = location.href,
|
|||||||
var tempScrollTop = $(window).scrollTop();
|
var tempScrollTop = $(window).scrollTop();
|
||||||
$(window).scrollTop(tempScrollTop);
|
$(window).scrollTop(tempScrollTop);
|
||||||
$body.animate({
|
$body.animate({
|
||||||
scrollTop: tempScrollTop + 300
|
scrollTop: tempScrollTop + 100
|
||||||
}, 666)
|
}, 666)
|
||||||
} else {
|
} else {
|
||||||
$("#pagination").html("<span>很高兴你翻到这里,但是真的没有了...</span>");
|
$("#pagination").html("<span>很高兴你翻到这里,但是真的没有了...</span>");
|
||||||
|
Binary file not shown.
@ -1,8 +1,8 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Sakura\n"
|
"Project-Id-Version: Sakura\n"
|
||||||
"POT-Creation-Date: 2020-04-01 17:10+0800\n"
|
"POT-Creation-Date: 2020-04-02 11:56+0800\n"
|
||||||
"PO-Revision-Date: 2020-04-01 17:10+0800\n"
|
"PO-Revision-Date: 2020-04-02 11:56+0800\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: en_US\n"
|
"Language: en_US\n"
|
||||||
@ -222,7 +222,7 @@ msgstr ""
|
|||||||
msgid "page %s "
|
msgid "page %s "
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: inc/api.php:308 inc/theme_plus.php:727
|
#: inc/api.php:337 inc/theme_plus.php:727
|
||||||
msgid "The comment is private"
|
msgid "The comment is private"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
||||||
"Project-Id-Version: Sakura\n"
|
"Project-Id-Version: Sakura\n"
|
||||||
"POT-Creation-Date: 2020-04-01 17:10+0800\n"
|
"POT-Creation-Date: 2020-04-02 11:56+0800\n"
|
||||||
"PO-Revision-Date: 2019-11-01 14:27+0800\n"
|
"PO-Revision-Date: 2019-11-01 14:27+0800\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
@ -220,7 +220,7 @@ msgstr ""
|
|||||||
msgid "page %s "
|
msgid "page %s "
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: inc/api.php:308 inc/theme_plus.php:727
|
#: inc/api.php:337 inc/theme_plus.php:727
|
||||||
msgid "The comment is private"
|
msgid "The comment is private"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1,8 +1,8 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Sakura\n"
|
"Project-Id-Version: Sakura\n"
|
||||||
"POT-Creation-Date: 2020-04-01 17:11+0800\n"
|
"POT-Creation-Date: 2020-04-02 11:56+0800\n"
|
||||||
"PO-Revision-Date: 2020-04-01 17:13+0800\n"
|
"PO-Revision-Date: 2020-04-02 11:56+0800\n"
|
||||||
"Last-Translator: \n"
|
"Last-Translator: \n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"Language: zh_CN\n"
|
"Language: zh_CN\n"
|
||||||
@ -227,7 +227,7 @@ msgstr ""
|
|||||||
msgid "page %s "
|
msgid "page %s "
|
||||||
msgstr "第 %s 页 "
|
msgstr "第 %s 页 "
|
||||||
|
|
||||||
#: inc/api.php:308 inc/theme_plus.php:727
|
#: inc/api.php:337 inc/theme_plus.php:727
|
||||||
msgid "The comment is private"
|
msgid "The comment is private"
|
||||||
msgstr "该评论为私密评论"
|
msgstr "该评论为私密评论"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user