Skip to content

Commit

Permalink
Merge pull request #159 from mashirozx/dev
Browse files Browse the repository at this point in the history
update to v3.3.3
  • Loading branch information
mashirozx authored Dec 13, 2019
2 parents 65e9fe3 + d91e1ad commit 5608a0d
Show file tree
Hide file tree
Showing 50 changed files with 1,792 additions and 1,255 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

![Sakura](https://view.moezx.cc/images/2018/05/26/sakura.png)

![PHP version](https://img.shields.io/badge/PHP-7.1+-4F5B93.svg?style=flat-square)
![WP version](https://img.shields.io/badge/WordPress-5.0+-0073aa.svg?style=flat-square)
[![GitHub release](https://img.shields.io/github/release/mashirozx/Sakura.svg?style=flat-square)](https://github.com/mashirozx/Sakura/releases/latest)
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/mashirozx/Sakura/latest.svg?style=flat-square)](https://github.com/mashirozx/Sakura/commits/)
![PHP version](https://shader.2heng.xin/badge/PHP-7.1+-4F5B93.svg?style=flat-square&logo=php)
![WP version](https://shader.2heng.xin/badge/WordPress-5.3-0073aa.svg?style=flat-square&logo=wordpress)
[![GitHub release](https://img.shields.io/github/v/release/mashirozx/Sakura.svg?style=flat-square&logo=github)](https://github.com/mashirozx/Sakura/releases/latest)
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/mashirozx/Sakura/latest.svg?style=flat-square&logo=git&color=important)](https://github.com/mashirozx/Sakura/commits/)
[![](https://data.jsdelivr.com/v1/package/gh/moezx/cdn/badge)](https://www.jsdelivr.com/package/gh/moezx/cdn)

在 Louie 基于 Fuzzz 的 [Akina](http://www.akina.pw/themeakina) 主题修改的主题 [Siren](https://github.com/louie-senpai/Siren) 基础上三次修改 =.=
Expand Down
3 changes: 1 addition & 2 deletions archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

</main><!-- #main -->
<?php if ( akina_option('pagenav_style') == 'ajax') { ?>
<div id="pagination" <?php if(akina_option('image_category') && is_category(explode(',',akina_option('image_category')))) echo 'class="pagination-archive"'; ?>><?php next_posts_link(__('Previous')); ?></div>
<div id="pagination" <?php if(akina_option('image_category') && is_category(explode(',',akina_option('image_category')))) echo 'class="pagination-archive"'; ?>><?php next_posts_link(' Previous'); ?></div>
<div id="add_post"><span id="add_post_time" style="visibility: hidden;" title="<?php echo akina_option('auto_load_post',''); ?>" ></span></div>
<?php }else{ ?>
<nav class="navigator">
Expand All @@ -62,5 +62,4 @@
</div><!-- #primary -->

<?php
get_sidebar();
get_footer();
3 changes: 1 addition & 2 deletions author.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

</main><!-- #main -->
<?php if ( akina_option('pagenav_style') == 'ajax') { ?>
<div id="pagination"><?php next_posts_link(__('Previous')); ?></div>
<div id="pagination"><?php next_posts_link(' Previous'); ?></div>
<div id="add_post"><span id="add_post_time" style="visibility: hidden;" title="<?php echo akina_option('auto_load_post',''); ?>" ></span></div>
<?php }else{ ?>
<nav class="navigator">
Expand All @@ -83,5 +83,4 @@
</div><!-- #primary -->

<?php
get_sidebar();
get_footer();
14 changes: 0 additions & 14 deletions cover/index.php

This file was deleted.

Binary file removed feature/gallery/1.jpg
Binary file not shown.
Binary file removed feature/gallery/2.jpg
Binary file not shown.
14 changes: 0 additions & 14 deletions feature/index.php

This file was deleted.

122 changes: 95 additions & 27 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.3.2' );
define( 'SAKURA_VERSION', '3.3.3' );
define( 'BUILD_VERSION', '3' );

//ini_set('display_errors', true);
Expand Down Expand Up @@ -466,17 +466,18 @@ function restyle_text($number) {
}

function set_post_views() {
global $post;
$post_id = intval($post->ID);
$count_key = 'views';
$views = get_post_custom($post_id);
$views = array_key_exists("views",$views) ? intval($views['views'][0]) : 0;
if(is_single() || is_page()) {
if(!update_post_meta($post_id, 'views', ($views + 1))) {
add_post_meta($post_id, 'views', 1, true);
if (is_singular()) {
global $post;
$post_id = intval($post->ID);
if($post_id) {
$views = get_post_meta($post_id, 'views', true);
if(!update_post_meta($post_id, 'views', ($views + 1))) {
add_post_meta($post_id, 'views', 1, true);
}
}
}
}

add_action('get_header', 'set_post_views');

function get_post_views($post_id) {
Expand All @@ -487,10 +488,7 @@ function get_post_views($post_id) {
return restyle_text(wp_statistics_pages('total','uri',$post_id));
}
} else {
$count_key = 'views';
$views = get_post_custom($post_id);
$views = array_key_exists("views",$views) ? intval($views['views'][0]) : 0;
$post_views = intval(post_custom('views'));
$views = get_post_meta($post_id, 'views', true);
if($views == '') {
return 0;
}else{
Expand Down Expand Up @@ -1521,16 +1519,16 @@ function html_tag_parser($content) {
//With Thumbnail: !{alt}(url)[th_url]
if (preg_match_all('/\!\{.*?\)\[.*?\]/i', $content,$matches)){
$i=0;
foreach ($matches as $val) {
$content=str_replace($val[$i],preg_replace(
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>',
$val[$i]),
$matches[$i]),
$content);
$i++;
}
Expand Down Expand Up @@ -1559,6 +1557,30 @@ class="fancybox"
',
$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 href="$2"><img src="$7" alt="$1" title="$1"></a>',$matches[$i]),
$content
);
$i++;
}
}
$content=preg_replace('/!\{([^\{\}]+)*\}\('.$url_regex.'\)/i','<a href="$2"><img src="$2" alt="$1" title="$1"></a>',$content);

//Github cards
$content=preg_replace(
'/\[github repo=[\'"]([^\'"]+)[\'"]\]/i',
'<a href="https://github.com/$1">',
$content
);
}
return $content;
}
Expand Down Expand Up @@ -1594,11 +1616,21 @@ function output_comments_qq_columns( $column_name, $comment_id ){
*/
add_filter( 'get_avatar', 'change_avatar', 10, 3 );
function change_avatar($avatar){
global $comment;
global $comment,$sakura_privkey;
if ($comment) {
if( get_comment_meta( $comment->comment_ID, 'new_field_qq', true )){
$qq_number = get_comment_meta( $comment->comment_ID, 'new_field_qq', true );
return '<img src="https://q2.qlogo.cn/headimg_dl?dst_uin='.$qq_number.'&spec=100" data-src="'.stripslashes($m[1]).'" class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">';
if(akina_option('qq_avatar_link')=='off'){
return '<img src="https://q2.qlogo.cn/headimg_dl?dst_uin='.$qq_number.'&spec=100" data-src="'.stripslashes($m[1]).'" class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">';
}elseif(akina_option('qq_avatar_link')=='type_3'){
$qqavatar = file_get_contents('http://ptlogin2.qq.com/getface?appid=1006102&imgtype=3&uin='.$qq_number);
preg_match('/:\"([^\"]*)\"/i',$qqavatar,$matches);
return '<img src="'.$matches[1].'" data-src="'.stripslashes($m[1]).'" class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">';
}else{
$encrypted = openssl_encrypt($qq_number, 'aes-128-cbc', $sakura_privkey, 0);
$encrypted = urlencode(base64_encode($encrypted));
return '<img src="'.rest_url("sakura/v1/qqinfo/avatar").'?qq='.$encrypted.'"class="lazyload avatar avatar-24 photo" alt="😀" width="24" height="24" onerror="imgError(this,1)">';
}
}else{
return $avatar ;
}
Expand All @@ -1609,12 +1641,7 @@ function change_avatar($avatar){

// default feature image
function DEFAULT_FEATURE_IMAGE() {
if ( empty( akina_option('default_feature_image' )) ) {
return get_template_directory_uri().'/feature/index.php?'.rand(1,1000);
//return 'https://api.mashiro.top/feature/?'.rand(1,1000);
} else {
return akina_option('default_feature_image').'?'.rand(1,1000);
}
return rest_url('sakura/v1/image/feature').'?'.rand(1,1000);
}

//防止设置置顶文章造成的图片同侧bug
Expand Down Expand Up @@ -1649,12 +1676,12 @@ function markdown_parser($incoming_comment) {
global $wpdb,$comment_markdown_content;
$re = '/```([\s\S]*?)```[\s]*|`{1,2}[^`](.*?)`{1,2}|\[.*?\]\([\s\S]*?\)/m';
if(preg_replace($re,'temp',$incoming_comment['comment_content']) != strip_tags(preg_replace($re,'temp',$incoming_comment['comment_content']))){
siren_ajax_comment_err('评论只支持Markdown啦,见谅╮( ̄▽ ̄)╭<br>Markdown Supported while <i class="fa fa-code" aria-hidden="true"></i> Forbidden');
return( $incoming_comment );
siren_ajax_comment_err('评论只支持Markdown啦,见谅╮( ̄▽ ̄)╭<br>Markdown Supported while <i class="fa fa-code" aria-hidden="true"></i> Forbidden');
return( $incoming_comment );
}
$myCustomer = $wpdb->get_row("SELECT * FROM wp_comments");
//Add column if not present.
if (!isset($myCustomer->say_state)) {
if (!isset($myCustomer->comment_markdown)) {
$wpdb->query("ALTER TABLE wp_comments ADD comment_markdown text");
}
$comment_markdown_content = $incoming_comment['comment_content'];
Expand Down Expand Up @@ -1697,4 +1724,45 @@ function allow_more_tag_in_comment() {
$allowedtags['span'] = array('class'=>array());
}
add_action('pre_comment_on_post', 'allow_more_tag_in_comment');

/*
* 随机图
*/
function create_sakura_table(){
global $wpdb,$sakura_image_array,$sakura_privkey;
$sakura_table_name = $wpdb->base_prefix.'sakura';
require_once(ABSPATH . "wp-admin/includes/upgrade.php");
dbDelta("CREATE TABLE IF NOT EXISTS `" . $sakura_table_name . "` (
`mate_key` varchar(50) COLLATE utf8_bin NOT NULL,
`mate_value` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`mate_key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;");
//default data
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_template_directory()."/manifest/manifest.json")
);
$wpdb->insert($sakura_table_name,$manifest);
}
if ( !$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'json_time'") ){
$time = array(
"mate_key" => "json_time",
"mate_value" => date("Y-m-d H:i:s",time())
);
$wpdb->insert($sakura_table_name,$time);
}
if ( !$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'privkey'") ){
$privkey = array(
"mate_key" => "privkey",
"mate_value" => wp_generate_password(8)
);
$wpdb->insert($sakura_table_name,$privkey);
}
//reduce sql query
$sakura_image_array = $wpdb->get_var("SELECT `mate_value` FROM `wp_sakura` WHERE `mate_key`='manifest_json'");
$sakura_privkey = $wpdb->get_var("SELECT `mate_value` FROM `wp_sakura` WHERE `mate_key`='privkey'");
}
add_action( 'after_setup_theme', 'create_sakura_table' );

//code end
1 change: 0 additions & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
</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
Expand Down
Loading

0 comments on commit 5608a0d

Please sign in to comment.