$class,
);
$thumb = '';
if ( has_post_thumbnail( $the_id ) ) {
// アイキャッチ画像の設定がある場合
$thumb = get_the_post_thumbnail( $the_id, $size, $attachment_args );
} elseif ( ARKHE_NOIMG_ID ) {
// まだサムネイル画像が取得できていない場合で、ARKHE_NOIMG_ID がある場合
$thumb = wp_get_attachment_image( ARKHE_NOIMG_ID, $size, false, $attachment_args );
}
if ( $thumb ) {
if ( $sizes ) {
// 指定のサイズに書き換える
$thumb = preg_replace( '/ sizes="([^"]*)"/', ' sizes="' . $sizes . '"', $thumb );
}
} else {
$thumb = '
';
}
// 通常のフロント表示の時(Gutenberg上やRESTの時以外)
if ( ! defined( 'REST_REQUEST' ) ) {
$placeholder = $placeholder ?: ARKHE_PLACEHOLDER;
$thumb = str_replace( ' src="', ' src="' . esc_url( $placeholder ) . '" data-src="', $thumb );
$thumb = str_replace( ' srcset="', ' data-srcset="', $thumb );
// loading="lazy"
}
return apply_filters( 'ark_get__thumbnail', $thumb, $the_id, $args );
}
}
/**
* タームリストを出力する
*/
if ( ! function_exists( 'ark_get__term_links' ) ) {
function ark_get__term_links( $the_id = '', $tax_slug = '', $is_head = true ) {
if ( 'cat' === $tax_slug ) {
$terms = get_the_category( $the_id );
$icon = 'arkhe-icon-folder';
} elseif ( 'tag' === $tax_slug ) {
$terms = get_the_tags( $the_id );
$icon = 'arkhe-icon-tag';
} else {
$terms = get_the_terms( $the_id, $tax_slug );
$icon = 'arkhe-icon-' . $tax_slug;
}
if ( empty( $terms ) ) return '';
// is_head なら リスト全体の前にアイコンを一つ
$return = $is_head ? '' : '';
foreach ( $terms as $term ) {
$term_link = get_term_link( $term );
$return .= 'term_id ) . '">' .
esc_html( $term->name ) .
'';
}
return apply_filters( 'ark_get__term_links', $return, $the_id, $tax_slug );
}
}
/**
* アーカイブページのデータを取得
* ['title'] : アーカイブページのタイトルとして表示する文字列
* ['type'] : アーカイブ種別を表す文字列。cayegory | tag | tax | etc...
*/
if ( ! function_exists( 'ark_get__archive_data' ) ) {
function ark_get__archive_data() {
$data = array(
'type' => '',
'title' => '',
);
if ( is_date() ) {
// 日付アーカイブなら
$qv_day = get_query_var( 'day' );
$qv_monthnum = get_query_var( 'monthnum' );
$qv_year = get_query_var( 'year' );
if ( 0 !== $qv_day ) {
$ymd_name = $qv_year . '年' . $qv_monthnum . '月' . $qv_day . '日';
} elseif ( 0 !== $qv_monthnum ) {
$ymd_name = $qv_year . '年' . $qv_monthnum . '月';
} else {
$ymd_name = $qv_year . '年';
}
if ( is_post_type_archive() ) {
// さらに、投稿タイプの日付アーカイブだった場合
$data['title'] = $ymd_name . '(' . post_type_archive_title( '', false ) . ')';
}
$data['title'] = $ymd_name;
$data['type'] = 'date';
} elseif ( is_post_type_archive() ) {
// 投稿タイプのアーカイブページなら
$data['title'] = post_type_archive_title( '', false );
$data['type'] = 'pt_archive';
} elseif ( is_author() ) {
// 投稿者アーカイブ
$data['title'] = get_queried_object()->display_name;
$data['type'] = 'author';
} elseif ( is_category() ) {
$data['title'] = single_term_title( '', false );
$data['type'] = 'category';
} elseif ( is_tag() ) {
$data['title'] = single_term_title( '', false );
$data['type'] = 'tag';
} elseif ( is_tax() ) {
$data['title'] = single_term_title( '', false );
$data['type'] = 'tax';
} elseif ( is_archive() ) {
$data['title'] = single_term_title( '', false );
$data['type'] = '';
}
return apply_filters( 'ark_get__archive_data', $data );
}
}
/**
* 日付を出力する
*/
if ( ! function_exists( 'ark_the__postdate' ) ) {
function ark_the__postdate( $date = null, $type = 'posted', $use_time_tag = true ) {
if ( null === $date ) return;
$time_class = 'c-postTimes__item -' . $type . ' u-flex--aic';
if ( $use_time_tag ) {
echo '';
} else {
echo '' .
'' .
esc_html( $date->format( 'Y.m.d' ) ) .
'';
}
}
}