perf: translate

pull/185/head
Spirit 2020-01-09 16:50:07 +08:00
parent baaabaa394
commit d9a6895d0d
9 changed files with 1073 additions and 1038 deletions

View File

@ -1860,7 +1860,7 @@ function create_sakura_table()
if (!$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'manifest_json'")) {
$manifest = array(
"mate_key" => "manifest_json",
"mate_value" => file_get_contents(get_stylesheet_directory() . "/manifest/manifest.json"),
"mate_value" => file_get_contents(get_template_directory() . "/manifest/manifest.json"),
);
$wpdb->insert($sakura_table_name, $manifest);
}

View File

@ -355,29 +355,7 @@ function cover_gallery() {
* @rest api接口路径https://sakura.2heng.xin/wp-json/sakura/v1/image/feature
*/
function feature_gallery() {
if(akina_option('cover_cdn_options')=="type_2"){
$img_array = glob(get_template_directory() . "/manifest/gallery/*.{gif,jpg,png}",GLOB_BRACE);
$img = array_rand($img_array);
$imgurl = trim($img_array[$img]);
$imgurl = str_replace(get_template_directory(), get_template_directory_uri(), $imgurl);
}elseif(akina_option('cover_cdn_options')=="type_3"){
$imgurl = akina_option('cover_cdn');
}else{
global $sakura_image_array;
$img_array = json_decode($sakura_image_array, true);
$img = array_rand($img_array);
$img_domain = akina_option('cover_cdn') ? akina_option('cover_cdn') : get_template_directory_uri();
if(strpos($_SERVER['HTTP_ACCEPT'], 'image/webp')) {
$imgurl = $img_domain . "/manifest/" . $img_array[$img]["webp"][0];
} else {
$imgurl = $img_domain . "/manifest/" . $img_array[$img]["jpeg"][0];
}
}
$data = array('cover image');
$response = new WP_REST_Response($data);
$response->set_status(302);
$response->header('Location', $imgurl);
return $response;
return cover_gallery();
}
/*
@ -385,30 +363,34 @@ function feature_gallery() {
* @rest api接口路径https://sakura.2heng.xin/wp-json/sakura/v1/database/update
*/
function update_database() {
global $wpdb;
$sakura_table_name = $wpdb->base_prefix.'sakura';
$img_domain = akina_option('cover_cdn') ? akina_option('cover_cdn') : get_template_directory();
$manifest = file_get_contents($img_domain . "/manifest/manifest.json");
if($manifest) {
$manifest = array(
"mate_key" => "manifest_json",
"mate_value" => $manifest
);
$time = array(
"mate_key" => "json_time",
"mate_value" => date("Y-m-d H:i:s",time())
);
$wpdb->query("DELETE FROM $sakura_table_name WHERE `mate_key` ='manifest_json'");
$wpdb->query("DELETE FROM $sakura_table_name WHERE `mate_key` ='json_time'");
$wpdb->insert($sakura_table_name,$manifest);
$wpdb->insert($sakura_table_name,$time);
$output = "manifest.json has been stored into database.";
if(akina_option('cover_cdn_options')=="type_1"){
global $wpdb;
$sakura_table_name = $wpdb->base_prefix.'sakura';
$img_domain = akina_option('cover_cdn') ? akina_option('cover_cdn') : get_template_directory();
$manifest = file_get_contents($img_domain . "/manifest/manifest.json");
if($manifest) {
$manifest = array(
"mate_key" => "manifest_json",
"mate_value" => $manifest
);
$time = array(
"mate_key" => "json_time",
"mate_value" => date("Y-m-d H:i:s",time())
);
$wpdb->query("DELETE FROM $sakura_table_name WHERE `mate_key` ='manifest_json'");
$wpdb->query("DELETE FROM $sakura_table_name WHERE `mate_key` ='json_time'");
$wpdb->insert($sakura_table_name,$manifest);
$wpdb->insert($sakura_table_name,$time);
$output = "manifest.json has been stored into database.";
}else{
$output = "manifest.json not found, please ensure your url ($img_domain) is corrent.";
}
$result = new WP_REST_Response($output, 200);
return $result;
}else{
$output = "manifest.json not found, please ensure your url ($img_domain) is corrent.";
return new WP_REST_Response("Invalid access", 200);
}
$result = new WP_REST_Response($output, 200);
return $result;
}
/**

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -117,9 +117,6 @@
<?php if (akina_option('facebook')){ ?>
<li><a href="<?php echo akina_option('facebook', ''); ?>" target="_blank" class="social-wangyiyun" title="Facebook"><img src="https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/sns/facebook.png"/></a></li>
<?php } ?>
<?php if (akina_option('googleplus')){ ?>
<li><a href="<?php echo akina_option('googleplus', ''); ?>" target="_blank" class="social-wangyiyun" title="Google+"><img src="https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/sns/googleplus.png"/></a></li>
<?php } ?>
<?php if (akina_option('jianshu')){ ?>
<li><a href="<?php echo akina_option('jianshu', ''); ?>" target="_blank" class="social-wangyiyun" title="Jianshu"><img src="https://cdn.jsdelivr.net/gh/moezx/cdn@3.1.9/img/Sakura/images/sns/jianshu.png"/></a></li>
<?php } ?>

View File

@ -377,11 +377,11 @@ function optionsframework_options()
'name' => __('Cover manifest', 'sakura'), /*封面图片库选项*/
'desc' => __('Select how to call the cover random image', 'sakura'), /*选择封面随机图的调用方式*/
'id' => 'cover_cdn_options',
'std' => "type_1",
'std' => "type_2",
'type' => "select",
'options' => array(
'type_1' => __('webp images (optimization)', 'sakura'), /*webp优化随机图*/
'type_2' => __('built-in api (easiest)', 'sakura'), /*内置原图随机图*/
'type_2' => __('built-in api (default)', 'sakura'), /*内置原图随机图*/
'type_3' => __('custom api (advanced)', 'sakura'), /*外部随机图API*/
)
);
@ -704,14 +704,7 @@ function optionsframework_options()
'id' => 'facebook',
'std' => '',
'type' => 'text');
/*
$options[] = array(
'name' => __('Google+', 'sakura'),
'desc' => __('G+ address', 'sakura'),
'id' => 'googleplus',
'std' => '',
'type' => 'text');
*/
$options[] = array(
'name' => __('Jianshu', 'sakura'), /*简书*/
'desc' => __('Jianshu address', 'sakura'), /*简书地址*/