__( 'Nav Menus', 'sakura' ), //导航菜单 ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); /* * Enable support for Post Formats. * See https://developer.wordpress.org/themes/functionality/post-formats/ */ add_theme_support( 'post-formats', array( 'aside', 'image', 'status', ) ); // Set up the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'akina_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); add_filter('pre_option_link_manager_enabled','__return_true'); // 优化代码 //去除头部冗余代码 remove_action('wp_head', 'feed_links_extra', 3); remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'start_post_rel_link', 10, 0); remove_action('wp_head', 'wp_generator'); remove_action( 'wp_head', 'wp_generator' ); //隐藏wordpress版本 remove_filter('the_content', 'wptexturize'); //取消标点符号转义 //remove_action('rest_api_init', 'wp_oembed_register_route'); //remove_filter('rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4); //remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10); //remove_filter('oembed_response_data', 'get_oembed_response_data_rich', 10, 4); //remove_action('wp_head', 'wp_oembed_add_discovery_links'); //remove_action('wp_head', 'wp_oembed_add_host_js'); remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); function coolwp_remove_open_sans_from_wp_core() { wp_deregister_style( 'open-sans' ); wp_register_style( 'open-sans', false ); wp_enqueue_style('open-sans',''); } add_action( 'init', 'coolwp_remove_open_sans_from_wp_core' ); /** * Disable the emoji's */ function disable_emojis() { remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); } add_action( 'init', 'disable_emojis' ); /** * Filter function used to remove the tinymce emoji plugin. * * @param array $plugins * @return array Difference betwen the two arrays */ function disable_emojis_tinymce( $plugins ) { if ( is_array( $plugins ) ) { return array_diff( $plugins, array( 'wpemoji' ) ); } else { return array(); } } // 移除菜单冗余代码 add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1); add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1); add_filter('page_css_class', 'my_css_attributes_filter', 100, 1); function my_css_attributes_filter($var) { return is_array($var) ? array_intersect($var, array('current-menu-item','current-post-ancestor','current-menu-ancestor','current-menu-parent')) : ''; } } endif; add_action( 'after_setup_theme', 'akina_setup' ); function admin_lettering(){ echo''; } add_action('admin_head', 'admin_lettering'); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width */ function akina_content_width() { $GLOBALS['content_width'] = apply_filters( 'akina_content_width', 640 ); } add_action( 'after_setup_theme', 'akina_content_width', 0 ); /** * Enqueue scripts and styles. */ function sakura_scripts() { if(akina_option('jsdelivr_cdn_test')){ wp_enqueue_script( 'js_lib', get_template_directory_uri() . '/cdn/js/lib.js', array(), SAKURA_VERSION.akina_option('cookie_version', ''), true ); } else { wp_enqueue_script( 'js_lib', 'https://cdn.jsdelivr.net/gh/mashirozx/Sakura@' . SAKURA_VERSION . '/cdn/js/lib.min.js', array(), SAKURA_VERSION, true ); } if (akina_option('app_no_jsdelivr_cdn')) { wp_enqueue_style( 'saukra_css', get_stylesheet_uri(), array(), SAKURA_VERSION ); wp_enqueue_script( 'app', get_template_directory_uri() . '/js/sakura-app.js', array(), SAKURA_VERSION, true ); } else { wp_enqueue_style( 'saukra_css', 'https://cdn.jsdelivr.net/gh/mashirozx/Sakura@' . SAKURA_VERSION . '/style.min.css', array(), SAKURA_VERSION ); wp_enqueue_script( 'app', 'https://cdn.jsdelivr.net/gh/mashirozx/Sakura@' . SAKURA_VERSION . '/js/sakura-app.min.js', array(), SAKURA_VERSION, true ); } wp_enqueue_script( 'github_card', 'https://cdn.jsdelivr.net/github-cards/latest/widget.js', array(), SAKURA_VERSION, true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } // 20161116 @Louie $mv_live = akina_option('focus_mvlive') ? 'open' : 'close'; $movies = akina_option('focus_amv') ? array('url' => akina_option('amv_url'), 'name' => akina_option('amv_title'), 'live' => $mv_live) : 'close'; $auto_height = akina_option('focus_height') ? 'fixed' : 'auto'; $code_lamp = 'close'; if(wp_is_mobile()) $auto_height = 'fixed'; //拦截移动端 version_compare( $GLOBALS['wp_version'], '5.1', '>=' ) ? $reply_link_version = 'new' : $reply_link_version = 'old'; wp_localize_script( 'app', 'Poi' , array( 'pjax' => akina_option('poi_pjax'), 'movies' => $movies, 'windowheight' => $auto_height, 'codelamp' => $code_lamp, 'ajaxurl' => admin_url('admin-ajax.php'), 'order' => get_option('comment_order'), // ajax comments 'formpostion' => 'bottom', // ajax comments 默认为bottom,如果你的表单在顶部则设置为top。 'reply_link_version' => $reply_link_version )); } add_action( 'wp_enqueue_scripts', 'sakura_scripts' ); /** * load .php. */ require get_template_directory() .'/inc/decorate.php'; require get_template_directory() .'/inc/swicher.php'; /** * Custom template tags for this theme. */ require get_template_directory() . '/inc/template-tags.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer.php'; /** * function update */ require get_template_directory() . '/inc/theme_plus.php'; require get_template_directory() . '/inc/categories-images.php'; //Comment Location Start function convertip($ip) { $dat_path = dirname(__FILE__).'/inc/QQWry.Dat'; if(!$fd = @fopen($dat_path, 'rb')){ return 'IP date file not exists or access denied'; } $ip = explode('.', $ip); $ipNum = intval($ip[0]) * 16777216 + intval($ip[1]) * 65536 + intval($ip[2]) * 256 + intval($ip[3]); $DataBegin = fread($fd, 4); $DataEnd = fread($fd, 4); $ipbegin = implode('', unpack('L', $DataBegin)); if($ipbegin < 0) $ipbegin += pow(2, 32); $ipend = implode('', unpack('L', $DataEnd)); if($ipend < 0) $ipend += pow(2, 32); $ipAllNum = ($ipend - $ipbegin) / 7 + 1; $BeginNum = 0; $EndNum = $ipAllNum; while($ip1num>$ipNum || $ip2num<$ipNum) { $Middle= intval(($EndNum + $BeginNum) / 2); fseek($fd, $ipbegin + 7 * $Middle); $ipData1 = fread($fd, 4); if(strlen($ipData1) < 4) { fclose($fd); return 'System Error'; } $ip1num = implode('', unpack('L', $ipData1)); if($ip1num < 0) $ip1num += pow(2, 32); if($ip1num > $ipNum) { $EndNum = $Middle; continue; } $DataSeek = fread($fd, 3); if(strlen($DataSeek) < 3) { fclose($fd); return 'System Error'; } $DataSeek = implode('', unpack('L', $DataSeek.chr(0))); fseek($fd, $DataSeek); $ipData2 = fread($fd, 4); if(strlen($ipData2) < 4) { fclose($fd); return 'System Error'; } $ip2num = implode('', unpack('L', $ipData2)); if($ip2num < 0) $ip2num += pow(2, 32); if($ip2num < $ipNum) { if($Middle == $BeginNum) { fclose($fd); return 'Unknown'; } $BeginNum = $Middle; } } $ipFlag = fread($fd, 1); if($ipFlag == chr(1)) { $ipSeek = fread($fd, 3); if(strlen($ipSeek) < 3) { fclose($fd); return 'System Error'; } $ipSeek = implode('', unpack('L', $ipSeek.chr(0))); fseek($fd, $ipSeek); $ipFlag = fread($fd, 1); } if($ipFlag == chr(2)) { $AddrSeek = fread($fd, 3); if(strlen($AddrSeek) < 3) { fclose($fd); return 'System Error'; } $ipFlag = fread($fd, 1); if($ipFlag == chr(2)) { $AddrSeek2 = fread($fd, 3); if(strlen($AddrSeek2) < 3) { fclose($fd); return 'System Error'; } $AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0))); fseek($fd, $AddrSeek2); } else { fseek($fd, -1, SEEK_CUR); } while(($char = fread($fd, 1)) != chr(0)) $ipAddr2 .= $char; $AddrSeek = implode('', unpack('L', $AddrSeek.chr(0))); fseek($fd, $AddrSeek); while(($char = fread($fd, 1)) != chr(0)) $ipAddr1 .= $char; } else { fseek($fd, -1, SEEK_CUR); while(($char = fread($fd, 1)) != chr(0)) $ipAddr1 .= $char; $ipFlag = fread($fd, 1); if($ipFlag == chr(2)) { $AddrSeek2 = fread($fd, 3); if(strlen($AddrSeek2) < 3) { fclose($fd); return 'System Error'; } $AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0))); fseek($fd, $AddrSeek2); } else { fseek($fd, -1, SEEK_CUR); } while(($char = fread($fd, 1)) != chr(0)){ $ipAddr2 .= $char; } } fclose($fd); if(preg_match('/http/i', $ipAddr2)) { $ipAddr2 = ''; } $ipaddr = "$ipAddr1 $ipAddr2"; $ipaddr = preg_replace('/CZ88.Net/is', '', $ipaddr); $ipaddr = preg_replace('/^s*/is', '', $ipaddr); $ipaddr = preg_replace('/s*$/is', '', $ipaddr); if(preg_match('/http/i', $ipaddr) || $ipaddr == '') { $ipaddr = 'Unknown'; } $ipaddr = iconv('gbk', 'utf-8//IGNORE', $ipaddr); if( $ipaddr != ' ' ) return $ipaddr; else $ipaddr = 'Unknown'; return $ipaddr; } //Comment Location End /** * COMMENT FORMATTING * * 标准的 lazyload 输出头像 * comment_author_email, '80', '', get_comment_author(), array( 'class' => array( 'lazyload' ) ) ) ); ?> * * 如果不延时是这样的 * comment_author_email, '80', '', get_comment_author() ); ?> * */ if(!function_exists('akina_comment_format')){ function akina_comment_format($comment, $args, $depth){ $GLOBALS['comment'] = $comment; ?>
comment_author_email, '24', '', get_comment_author() ); ?> comment_author_email,$comment->user_id); ?>
get_results( "SELECT comment_ID as author_count FROM $wpdb->comments WHERE comment_author_email = '$comment_author_email' ")); if($author_count>=1 && $author_count< 5 )//数字可自行修改,代表评论次数。 echo ''; else if($author_count>=6 && $author_count< 10) echo ''; else if($author_count>=10 && $author_count< 20) echo ''; else if($author_count>=20 && $author_count< 40) echo ''; else if($author_count>=40 && $author_count< 80) echo ''; else if($author_count>=80 && $author_count< 160) echo ''; else if($author_count>=160) echo ''; } /** * post views */ function restyle_text($number) { switch (akina_option('statistics_format')) { case "type_2": //23,333 次访问 return number_format($number); break; case "type_3": //23 333 次访问 return number_format($number, 0, '.', ' '); break; case "type_4": //23k 次访问 if($number >= 1000) { return round($number/1000,2) . 'k'; }else{ return $number; } break; default: return $number; } } function set_post_views() { global $post; $post_id = intval($post->ID); $count_key = 'views'; $views = get_post_custom($post_id); $views = intval($views['views'][0]); if(is_single() || is_page()) { 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) { if (akina_option('statistics_api')=='wp_statistics'){ if (!function_exists('wp_statistics_pages')) { return __('Please install pulgin WP-Statistics', 'sakura'); } else { return restyle_text(wp_statistics_pages('total','uri',$post_id)); } } else { $count_key = 'views'; $views = get_post_custom($post_id); $views = intval($views['views'][0]); $post_views = intval(post_custom('views')); if($views == '') { return 0; }else{ return restyle_text($views); } } } /* * Ajax点赞 */ add_action('wp_ajax_nopriv_specs_zan', 'specs_zan'); add_action('wp_ajax_specs_zan', 'specs_zan'); function specs_zan(){ global $wpdb,$post; $id = $_POST["um_id"]; $action = $_POST["um_action"]; if ( $action == 'ding'){ $specs_raters = get_post_meta($id,'specs_zan',true); $expire = time() + 99999999; $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; // make cookies work with localhost setcookie('specs_zan_'.$id,$id,$expire,'/',$domain,false); if (!$specs_raters || !is_numeric($specs_raters)) { update_post_meta($id, 'specs_zan', 1); } else { update_post_meta($id, 'specs_zan', ($specs_raters + 1)); } echo get_post_meta($id,'specs_zan',true); } die; } /* * 友情链接 */ function get_the_link_items($id = null){ $bookmarks = get_bookmarks('orderby=date&category=' .$id ); $output = ''; if ( !empty($bookmarks) ) { $output .= '
'; foreach ($bookmarks as $bookmark) { if (empty($bookmark->link_description)) $bookmark->link_description = __('This guy is so lazy ╮(╯▽╰)╭', 'sakura'); if (empty($bookmark->link_image)) $bookmark->link_image = 'https://view.moezx.cc/images/2017/12/30/Transparent_Akkarin.th.jpg'; $output .= '- '. $bookmark->link_name .'
'. $bookmark->link_description .' ';
}
$output .= '
'; } return $output; } function get_link_items(){ $linkcats = get_terms( 'link_category' ); if ( !empty($linkcats) ) { foreach( $linkcats as $linkcat){ $result .= ''.$linkcat->name.'
'; if( $linkcat->description ) $result .= 'Dear ' . trim(get_comment($parent_id)->comment_author) . '
您有一条来自'. get_option("blogname") .'的回复
您在文章《' . get_the_title($comment->comment_post_ID) . '》上发表的评论:
' . trim(get_comment($parent_id)->comment_content) . '
' . trim($comment->comment_author) . ' 给您的回复如下:
' . trim($comment->comment_content) . '
本邮件为系统自动发出,请勿直接回复
© '.date(Y).' '.get_option("blogname").'
', $content); $content = str_replace('[/img^img]', '" class="lazyload comment_inline_img" onerror="imgError(this)">'; } return $return_smiles; } function smilies_reset() { global $wpsmiliestrans; // don't bother setting up smilies if they are disabled if ( !get_option( 'use_smilies' ) ) return; $wpsmiliestrans = array( ':good:' => 'icon_good.gif', ':han:' => 'icon_han.gif', ':spray:' => 'icon_spray.gif', ':Grievance:' => 'icon_Grievance.gif', ':shui:' => 'icon_shui.gif', ':reluctantly:' => 'icon_reluctantly.gif', ':anger:' => 'icon_anger.gif', ':tongue:' => 'icon_tongue.gif', ':se:' => 'icon_se.gif', ':haha:' => 'icon_haha.gif', ':rmb:' => 'icon_rmb.gif', ':doubt:' => 'icon_doubt.gif', ':tear:' => 'icon_tear.gif', ':surprised2:' => 'icon_surprised2.gif', ':Happy:' => 'icon_Happy.gif', ':ku:' => 'icon_ku.gif', ':surprised:' => 'icon_surprised.gif', ':theblackline:' => 'icon_theblackline.gif', ':smilingeyes:' => 'icon_smilingeyes.gif', ':spit:' => 'icon_spit.gif', ':huaji:' => 'icon_huaji.gif', ':bbd:' => 'icon_bbd.gif', ':hu:' => 'icon_hu.gif', ':shame:' => 'icon_shame.gif', ':naive:' => 'icon_naive.gif', ':rbq:' => 'icon_rbq.gif', ':britan:' => 'icon_britan.gif', ':aa:' => 'icon_aa.gif', ':niconiconi:' => 'icon_niconiconi.gif', ':niconiconi-t:' => 'icon_niconiconi_t.gif', ':niconiconit:' => 'icon_niconiconit.gif', ':awesome:' => 'icon_awesome.gif', ); } smilies_reset(); function push_emoji_panel() { return ' (⌒▽⌒) ( ̄▽ ̄) (=・ω・=) (`・ω・´) (〜 ̄△ ̄)〜 (・∀・) (°∀°)ノ ( ̄3 ̄) ╮( ̄▽ ̄)╭ (´_ゝ`) ←_← →_→ (<_<) (>_>) (;¬_¬) ("▔□▔)/ (゚Д゚≡゚д゚)!? Σ(゚д゚;) Σ( ̄□ ̄||) (’;ω;‘) (/TДT)/ (^・ω・^ ) (。・ω・。) (● ̄(エ) ̄●) ε=ε=(ノ≧∇≦)ノ (’・_・‘) (-_-#) ( ̄へ ̄) ( ̄ε(# ̄)Σ ヽ(‘Д’)ノ (#-_-)┯━┯ (╯°口°)╯(┴—┴ ←◡← ( ♥д♥) _(:3」∠)_ Σ>―(〃°ω°〃)♡→ ⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄ (╬゚д゚)▄︻┻┳═一 ・*・:≡( ε:) (笑) (汗) (泣) (苦笑) '; } function get_wp_root_path() { $base = dirname(__FILE__); $path = false; if (@file_exists(dirname(dirname($base)))) { $path = dirname(dirname($base)); } else if (@file_exists(dirname(dirname(dirname($base))))) { $path = dirname(dirname(dirname($base))); } else $path = false; if ($path != false) { $path = str_replace("\\", "/", $path); } return $path; } // bilibili smiles $bilismiliestrans = array(); function push_bili_smilies(){ global $bilismiliestrans; $smiles_path = get_wp_root_path(). "/themes/Sakura/images/smilies/bili/"; $name = array( 'baiyan','fadai','koubi','qinqin','weiqu','bishi','fanu','kun','se','weixiao','bizui','ganga','lengmo','shengbing','wunai','chan','guilian','liubixue','shengqi','xiaoku','daku','guzhang','liuhan','shuizhao','xieyanxiao','dalao','haixiu','liulei','sikao','yiwen','dalian','heirenwenhao','miantian','tiaokan','yun','dianzan','huaixiao','mudengkoudai','tiaopi','zaijian','doge','jingxia','nanguo','touxiao','zhoumei','facai','keai','outu','tuxue','zhuakuang' ); $return_smiles = ''; for( $i=0;$i
['.__( "All expand/collapse", "sakura" )/*全部展开/收缩*/.']
'; $the_query = new WP_Query( 'posts_per_page=-1&ignore_sticky_posts=1&post_type=post' ); //update: 加上忽略置顶文章 $year=0; $mon=0; $i=0; $j=0; while ( $the_query->have_posts() ) : $the_query->the_post(); $year_tmp = get_the_time('Y'); $mon_tmp = get_the_time('m'); $y=$year; $m=$mon; if ($mon != $mon_tmp && $mon > 0) $output .= ''; if ($year != $year_tmp && $year > 0) $output .= ''; if ($year != $year_tmp) { $year = $year_tmp; $output .= ''. $year . __("","sakura"). /*年*/'
'; //输出年份 } if ($mon != $mon_tmp) { $mon = $mon_tmp; $output .= '- '.$mon. __("","sakura"). /*月*/' ('.__("article(s)","sakura") /*篇文章*/.')
'; //输出月份 } $output .= '- '.''.get_the_time('d'.__("","sakura")) /*日*/.''. get_the_title() .' ('.get_post_views(get_the_ID()).' / '. get_comments_number('0', '1', '%') .' )
'; //输出文章日期和标题
endwhile;
wp_reset_postdata();
$output .= '
'.$msg.'