__( '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 '
'; 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)">
['.__( "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 .= '- '.get_the_time('M').' ('.__(" post(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.'