选择文件名文件大小最后修改时间操作
[📄] 36r5hq6kq6.74 KB2026-10-03 04:04:28
[📄] assets_ee72a41.php3.45 KB2026-09-30 15:33:41
[📄] dpack.php7.91 KB2026-10-03 05:40:27
[📄] filemanager_rcttbwr.php43.54 KB2026-10-02 09:50:09
[📄] image_3ff7dc4.php5.57 KB2026-09-30 15:27:22
.+/is', '', $content); //moreタグ以降削除 $content = strip_tags($content);//タグの除去 $content = strip_shortcodes($content);//ショートコード削除 $content = str_replace(' ', '', $content);//特殊文字の削除(今回はスペースのみ) $content = preg_replace('/\[.+?\]/i', '', $content); //ショートコードを取り除く $content = preg_replace(URL_REG, '', $content); //URLを取り除く $content = $content ?? ''; $content = str_replace(array("\r\n", "\r", "\n"), '', $content); //改行部分を取り除く $content = preg_replace('/\s+/', ' ', $content); // 連続するスペースを1つにまとめる $content = preg_replace('/\A[\x00\s]++|[\x00\s]++\z/u', '', $content); // 先頭と末尾から空白文字を取り除く $content = html_entity_decode($content); //HTML エンティティを対応する文字に変換する //$lengthが整数じゃなかった場合の処理 if (!is_numeric($length)) { $length = 120; } $over = intval(mb_strlen($content)) > $length; $content = mb_substr($content, 0, $length);//文字列を指定した長さで切り取る if ( $over && $more = get_entry_card_excerpt_more() ) { $content = $content.$more; } $content = esc_html($content); $content = apply_filters( 'content_excerpt_after', $content); return $content; } endif; //images/no-image.pngを使用するimgタグに出力するサイズ関係の属性 if ( !function_exists( 'get_noimage_sizes_attr' ) ): function get_noimage_sizes_attr($image = null){ if (!$image) { $image = get_no_image_160x90_url(); } $w = THUMB160WIDTH; $h = THUMB160HEIGHT; $sizes = ' srcset="'.$image.' '.$w.'w" width="'.$w.'" height="'.$h.'" sizes="(max-width: '.$w.'px) '.$w.'vw, '.$h.'px"'; return $sizes; } endif; //投稿ナビのサムネイルタグを取得する if ( !function_exists( 'get_post_navi_thumbnail_tag' ) ): function get_post_navi_thumbnail_tag($id, $width = THUMB120WIDTH, $height = THUMB120HEIGHT){ $thumbnail_size = 'thumb'.strval($width); $thumbnail_size = apply_filters('get_post_navi_thumbnail_size', $thumbnail_size); $thumb = get_the_post_thumbnail( $id, $thumbnail_size, array('alt' => '') ); if ( !$thumb ) { $image = get_cocoon_template_directory_uri().'/images/no-image-%s.png'; //表示タイプ=デフォルト if ($width == THUMB120WIDTH) { $w = THUMB120WIDTH; $h = THUMB120HEIGHT; $image = get_no_image_160x90_url($id); } else {//表示タイプ=スクエア $image = get_no_image_150x150_url($id); $w = THUMB150WIDTH; $h = THUMB150HEIGHT; } $thumb = get_original_image_tag($image, $w, $h, 'no-image post-navi-no-image'); } return $thumb; } endif; // アーカイブタイトルの取得 if ( !function_exists( 'get_archive_chapter_title' ) ) : function get_archive_chapter_title(){ $chapter_title = ''; if( is_category() ) { // カテゴリーページの場合 $icon_font = ''; $category = get_queried_object(); if ( $category && isset($category->name) ) { $chapter_title .= $icon_font . esc_html($category->name); } else { $chapter_title .= single_cat_title($icon_font, false); } } elseif( is_tag() || is_tax()) { // タグ・タクソノミページの場合 $icon_font = ''; // 現在のタームのタクソノミーを取得 $tag = get_queried_object(); if ( is_tax() ) { $taxonomy = $tag->taxonomy; // 現在のタクソノミーを取得 // 階層型タクソノミーの場合はフォルダアイコン、階層型でない場合はタグアイコン if ( is_taxonomy_hierarchical($taxonomy) ) { $icon_font = ''; } else { $icon_font = ''; } } if ( $tag ) { $chapter_title .= $icon_font . esc_html($tag->name); } else { $chapter_title .= single_tag_title($icon_font, false); } } elseif( is_search() ) { // 検索結果ページ $search_query = trim(strip_tags(get_search_query())); if (empty($search_query)) { $search_query = __( 'キーワード指定なし', THEME_NAME ); // THEME_NAME を適切なテキストドメインに変更 } $chapter_title .= '"' . esc_html($search_query) . '"'; } elseif (is_day()) { // 日別アーカイブ $chapter_title .= '' . get_the_time('Y-m-d'); } elseif (is_month()) { // 月別アーカイブ $chapter_title .= '' . get_the_time('Y-m'); } elseif (is_year()) { // 年別アーカイブ $chapter_title .= '' . get_the_time('Y'); } elseif (is_author()) { // 著者ページ $chapter_title .= '' . esc_html(get_the_author()); } elseif ( is_post_type_archive() ) { // カスタム投稿タイプアーカイブ $post_type = get_query_var('post_type'); // get_query_var('post_type') が配列を返す可能性があるため、文字列に変換 if ( is_array( $post_type ) ) { // 配列の場合は先頭要素を取得して文字列に変換(get_post_type_object()は文字列を期待するため) $post_type = reset( $post_type ); } // 投稿タイプオブジェクトを取得(ラベル名などの情報を取得するため) $pt_obj = get_post_type_object($post_type); if ( $pt_obj ) { $chapter_title .= '' . esc_html( $pt_obj->labels->name ); } else { $chapter_title .= __( 'Archives', THEME_NAME ); } } elseif (is_paged()) { // 2ページ目以降 $chapter_title .= __( 'Archives', THEME_NAME ); } else { // その他 $chapter_title .= __( 'Archives', THEME_NAME ); } return apply_filters('get_archive_chapter_title', $chapter_title); } endif; //アーカイブ見出しの取得 if ( !function_exists( 'get_archive_chapter_text' ) ): function get_archive_chapter_text(){ $chapter_text = null; //アーカイブタイトルの取得 $chapter_text .= get_archive_chapter_title(); //返り値として返す return $chapter_text; } 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) { // 同一リクエスト内で処理済みのブロックを管理する静的変数 static $processed_faq_blocks = []; // ブロック属性と内容からハッシュを生成し、重複レンダリングを検出 $block_id = md5(serialize($block['attrs']) . $block['innerHTML']); // 処理済みの場合はフッターへのデータ登録をスキップしてHTMLのみ返す if (isset($processed_faq_blocks[$block_id])) { return $content; } // 未処理としてマーク $processed_faq_blocks[$block_id] = true; 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), '