直接アクセスif(!defined( 'apath'))){exit; } / ** * ======基本的なテーマ設定====== * / / //テーマの定義定義( 'Animenew_version'、 '1.0.0'); define( 'animenew_theme_dir'、get_template_directory()); define( 'animenew_theme_url'、get_template_directory_uri()); /** *テーマのセットアップ */function animenew_theme_setup(){//翻訳サポートload_theme_textdomain( 'animenew'、animenew_theme_dir。 '/language'); // RSS add_theme_support( 'autom-feed-links')を供給する自動サポート; //ダイナミックタイトルサポートadd_theme_support( 'title-tag'); //強調表示された画像へのサポートadd_theme_support( 'post-sumbnails'); //パーソナライズされた画像サイズadd_image_size( 'animenew-card'、400、225、true); // 16:9カードadd_image_sizeの場合( 'animenew-featred'、800、450、true); //特徴の投稿add_image_size( 'animenew-lage'、1200、675、true); //個々の投稿// html5 add_theme_support( 'html5'、array(search-form '、' comment-form '、' comment-list '、' gallery '、' caption '、' style '、' scrip '););); //カスタマイズ可能なロゴadd_theme_support( 'custom-logo'、array( 'height' => 50、 'width' => 200、 'flex-width' => true、 'flex-height' => true)をサポートします。 // Customizer add_theme_support( 'Customize-selective-refresh-widgets')での選択的リフレッシュサポート); //メニューregister_nav_menus(array( 'primary' => __( 'メインメニュー'、 'animenew')、 'footer' => __( 'footer menu'、 'animenew')、)、); } add_acition( 'after_setup_theme'、 'animenew_theme_setup'); /** * =======スタイル====== */function animenw_scripts(){// css main wp_enqueue_style( 'animenew-style'、animenew_theme_url。 https://cdnjs.cloudflare.com/ajax/font-awesome/6.0/css/all.min.css '、array()、' 6.0.0 ')メインwp_enque_sript(' animenew-script '、animenew_theme_url ( 'jquery')、animenew_version、true); // REPLY REPLYスクリプトif(is_sicular()&& comments_open()&& get_option( 'thread_comments')){wp_enqueue_script( 'comment-reply'); }} add_action( 'wp_enqueue_scripts'、 'animenew_scripts'); / ** * ======ウィジェット領域====== */関数animenw_widgets_init(){// sidebar main register_sidebar( 'name' => __( 'main sidebar'、 'animenew')、 'id' => 'sidebar-1'、 'description' => __( ''、' before_title '=>''、); //フッターエリアレジスタ_sideBar(array( 'name' => __( 'footer'、 'animenew')、 'id' = 'footer-1'、 'description' => __( 'footer' of the footer '、' animenew ')、' before_widget '=>''、' after_widget '=>'
'、' before_title '=>''、); } add_acition( 'widgets_init'、 'animenew_widgets_init'); / ** * =====補助関数===== * // ** *カスタムExcerptを取得 */関数animenew_get_excerpt($ limit = 150){$ excerpt = get_the_excerpt(); if(strlen($ excerpt)> $ lime){$ excerpt = substr($ excerpt、0、$ lime)。 '...'; } $ excerptを返します。 } / ** *推定読み取り時間を取得 * / function animenew_reading_time(){$ content = get_post_field( 'post_content'、get_the_id()); $ word_count = str_word_count(sprip_tags($ content)); $ reading_time = ceil($ word_count / 200); // 1分あたり200ワードif($ reading_time == 1){return '1 min Reading'; } else {return $ reading_time。 「読む分」; }} / ** *フォーマットポルトガル語 * / function animenew_format_date($ date = null){if(!$ date){$ date = get_the_date( 'ym-d'); } $ mounth = array( '01' => '1月'、 '02' => 'February'、 '03' = 'March'、 '04' => 'April'、 '05' = 'may' = 'june'、 '07'、 '08' => 'August'、 '=>' 9月 '= '、'“ 11 '、>'“ 11 '、'“ 11 '、>'“ 11 '、'“ 11 '、' '=>'、> '' => 'decrev'); $ date_parts = Explode( ' - '、$ date); $ day = $ date_parts [2]; $ month = $ months [$ date_parts [1]]; $ year = $ date_parts [0]; $ dayを返します。 'の'。 $月。 'の'。 $ year; } / ** * ==== breadcruumbs ===== * / function animenew_breadcruumbs(){if(is_home()|| is_front_page())return; $ separator = '>'; $ home_title = 'home';エコー ''; } / ** * ======カスタマイズされたページング===== * / function animenew_pagoniation($ pages = ''、$ range = 4){$ showitems =($ range * 2) + 1;グローバル$ページ。 if(empty($ paged))$ paged = 1; if($ pages == ''){global $ wp_query; $ pages = $ wp_query-> max_num_pages; if(!$ pages){$ pages = 1; }} if(1!= $ pages){echo "\ n ";} / ** * ====== Performance Optimizations ===== * / / / / / / / / / / query文字列関数animenw_script_vernsion($ src){$ parts = explode( '?see'); return $ parts [0];}; 15、1) 'print_emoji_styles');'。 "\ n"; if(has_post_thumbnail()){$ thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id()、 'large');エコー ''。 "\ n"; }}} add_action( 'wp_head'、 'animenew_meta_tags'); /** * ====== wp_head ===== * ///// removy require lemain nefistary links remaid_action( 'wp_head'、 'wp_generator'); remaid_action( 'wp_head'、 'rsd_link'); remaid_action( 'wp_head'、 'wlwmanifest_link'); remaid_action( 'wp_head'、 'wp_shortlink_wp_head'); / ** * =====管理者のカスタマイズ====== * ///関数Animenew_add_addd_column($ columns)の投稿{$列['thumbnail'] = 'image'; $列を返します。 } add_filter( 'manager_posts_columns'、 'animenew_add_thumbnail_column');関数animenew_show_thumbnail_column($ column_name、$ post_id){if($ column_name == 'thumbnail'){if(has_post_thumbnail($ post_id))){echo get_the_post_thumbnail($ post_id '); } else {echo 'without image'; }}} add_action( 'manage_posts_custom_column'、 'animenew_show_thumbnail_column'、10、2); / ** * ======プラグインとの互換性====== * // ** * yoast seo */ function animenew_yoast_compatibilityとの互換性(// yoast if(function_exists( 'yoast_breadcrub'))))) 'animenew_breadcruumbs'); // yoast function breadcruumbs animenew_yoast_breadcruumbs(){if(function_exists( 'yoast_breadcruumb')&&!is_front_page()){yoast_breadcruumb( ''); }} add_action( 'animenew_breadcruumbs'、 'animenew_yoast_breadcruumbs'); }} add_action( 'init'、 'animenew_yoast_compatibility'); / ** * WP Rocketとの互換性 */ function animenew_wp_rocket_compatibity(){//クリティカルリソースのpreload add_action( 'wp_head'、function(){echo ''。 "\ n";エコー ''。 "\ n";エコー ''。 "\ n"; }、1); } add_action( 'init'、 'animenew_wp_rocket_compatibility'); / ** * woocommerceとの互換性 */ function animenw_woocommerce_support(){add_theme_support( 'woocommerce'); add_theme_support( 'wc - product-gallery-zoom'); add_theme_support( 'wc - product-galllery-mightbox'); add_theme_support( 'wc - product-gallery-slider'); } add_action( 'after_setup_theme'、 'animenew_woocommerce_support'); / ** *連絡先フォーム7との互換性 */ function animenew_cf7_compatibity(){// forms add_actionのカスタムスタイル( 'wp_enqueue_scripts'、function(){if( 'wpcf7_enqueue_scripts')) '.wpcf7-form {background:var( - ( - - coluror); padding:2re; border-radius:var( - border-radius); border:1px solid var(-border-color); .wpcf7-form textarea {background:var(-background-darker); {var(-primary-color); (「コンテナ」=>「container」、「render」=> 'animeNew_scroll_render' => 'page')); 'animenew_jetpack_compatibility'); ** * jetpack infinite scroll * / function animenew_infinite_scroll_render(){while_posts()){the_post(); get_template_part( 'template-parts/content'、 'card'); }} / ** *要素との互換性 * / function animenew_elementor_compatibility(){// elementorウィジェットサポートadd_theme_support( 'element'); // if(did_action( 'elementar/loaded')){add_action( 'elementor/widgets/widgets_registered'、function(){//必要に応じて登録}); }} add_action( 'init'、 'animenew_elementor_compatibility'); / ** *プラグインのキャッシュ互換性 */関数animenew_cache_compatibity(){// w3合計キャッシュ、wpスーパーキャッシュなどの最適化。 ( 'Cache-Control:public、max-age = 3600'); {// rankmath、すべて1つのseoなど。remove_action( 'wp_head'、 'animenew_meta_tags');ターゲット。 Cookie ComplianceなどAdd_Action( 'WP_Footer'、function(){if(function_exists( 'cn_cookies_accepted')|| function_exists( 'gdpr_cookie_is_accepted')){eCho ''; }}); } add_action( 'init'、 'animenew_gdpr_compatibility'); / ** * =====プラグインのハンドラー====== * // ** * Ajaxはビューを増やす */ function animenew_ajax_increment_views(){check_ajax_referent( 'animenew_nonce'、 'noce'); $ post_id = intval($ _ post ['post_id']); if($ post_id){$ views = get_post_meta($ post_id、 'views'、true); $ views = $ビュー? $ビュー + 1:1; update_post_meta($ post_id、 'views'、$ vieks); wp_send_json_success(array( 'views' => $ views)); } wp_send_json_error(); } add_action( 'wp_ajax_increment_post_views'、 'animenew_ajax_increment_vings'); add_acition( 'wp_ajax_nopriv_increment_post_vings'、 'animenew_ajax_increment_vings'); / ** * ajax for instant search */ function animenew_ajax_instant_search(){check_ajax_referent( 'animenew_nonce'、 'noce'); $ query = sanitize_text_field($ _ post ['query']); $ post = get_posts( 'post_type' => 'post'、 'post_page' => 5、 's' => $ query、 'post_status' => 'publish')); $ results = array(); foreach($ posts as $ post){$ results [] = array( 'title' => get_the_title($ post-> id)、 'url' => get_permalink($ post-> id)、 'thumbnail' => get_the_the_thumbnail_url($ post-> id、 'category' =>> =>> => [0] - > wp_send_json_success($ result);より多くの投稿をロードする */ function animenew_ajax_load_more_posts(){check_ajax_refers( 'animenew_nonce'、 'noce'); 'post_status =>' publish '); ob_get_clean(); ( 'wp_ajax_nopriv_load_more_posts'、 'animenew_ajax_load_more_posts'); add_action( 'wp_enqueue_sripts'、function(){wp_add_inline_script( 'animenew-script'、 '// document.addeventlistener( "domcontentloaded"、function(){setimeout(){// relinitialize eavery(// relinitialize if(){domcontentloaded "、function) {window.animenewupils.reinitaftertranslation();}、1000);'; }); //3。Lingiseadd_actionのメタタグ( 'wp_head'、function(){echo ''。 "\ n";エコー ''。 "\ n"; }、5); // 4。互換性のあるキャッシュ構成add_filter( 'lingise_cache_enabled'、 '__return_true'); //5。異なる言語の正しいURLを確保するadd_filter( 'theme_mod_custom_logo'、 'animenew_lingise_logo_ull'); add_filter( 'home_url'、 'animenew_lingise_home_url'、10、2); }} add_action( 'init'、 'animenew_lingise_compatibility'); / ** *さまざまな言語のロゴURLを調整 */ function animenew_lingise_logo_url($ logo_id){if(function_exists( 'linguise_get_current_language_code')){$ current_lang = lingise_get_current_language_code(); if($ current_lang && $ current_lang!== 'pt'){//すべての言語が$ logo_id; }} $ logo_idを返します。 } / ** *ホームの正しいURLを確保 * / function animenew_lingise_home_url($ url、$ path){if(function_exists( 'linguise_get_current_language_code')))))))))))))))))) if($ current_lang && $ current_lang!== 'pt'){// lingiseは既にURL URLを管理しています。 }} $ urlを返します。 } / ** *テーマから翻訳されたテキスト * / function animenew_lingise_translatable_strings(){//自動翻訳の録音文字列$文字列= array( 'rabt news' = __( 'animenew')、 'see' => __( 'view more'、 'aimenew')more '=> __(' aimenew ')、' ')、 animenew ')、'結果 '=> __(' for 'for' animenew ')、'関連投稿 '=> __('関連投稿 '、' animenew ')、' page not found '=> __(page not not' in 'animenew')、 'back to to the " __( 'search'、 'animenew')、 '=> __(' by '、'、 'in' => __( '' animenew ')、' tags '=> __(' tags '、' animenew ')、' home '=> __(' home '、' animenew ')、' contact ')、' contact ')、' contact ')、' contact ') '=> __(プライバシーPolycy'、 'Animenew')、「利用規約」、「Animenew」); lingise_get_available_languages();エコー ''。 "\ n"; } // x-defaultEcho 'を追加'。 "\ n"; }} add_action( 'wp_head'、 'animenew_lingise_hreflang'); / ** * Linguiseの特定の設定'; }); } add_action( 'wp_head'、 'animenew_lingise_settings'、20); ?