classes as $key => $value) {
$menu_class .= ' ' . $value;
}
if (in_array('menu-item-has-children', $item->classes)) {
// parent
$input_id = "nav-".$item->ID;
$caption = $item->title;
$label = '';
if($args->theme_location === 'primary'){
$label = "\n" .'' . "\n" ;
}
$output .= "\n" . '
';
}
else {
// child
$output .= "\n".'' ."\n" ;
}
}
private function create_a_tag($item, $depth, $args , $label) {
// link attributes
$attributes = ' class="menu_s_a f_box jc_sb ai_c sub_fc"';
$attributes .= ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
//$attributes .= ' class="menu-link ' . ( $depth > 0 ? 'sub-menu-link' : 'main-menu-link' ) . '"';
$item_output = sprintf( '%1$s%3$s%4$s%5$s%6$s%7$s',
$args->before,
$attributes,
$args->link_before,
apply_filters( 'the_title', $item->title, $item->ID ),
$args->link_after,
$label,
$args->after
);
return apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
}
/*ヘッダーメニュー*/
if ( ! function_exists( 'neatly_primary_menu' ) ) :
function neatly_primary_menu() {?>
';
}
endif;
/*フッターメニュー*/
if ( ! function_exists( 'neatly_credit_menu' ) ) :
function neatly_credit_menu(){
echo '';
}
endif;
/*ヘッダーウィジェット*/
if ( ! function_exists( 'neatly_header_widget' ) ) :
function neatly_header_widget(){
echo '';
}
endif;
if ( ! function_exists( 'neatly_header_logo_title' ) ) :
function neatly_header_logo_title () {
if ( has_custom_logo() ) {
$custom_logo_id = get_theme_mod( 'custom_logo' );
$logo = wp_get_attachment_image_src( $custom_logo_id , 'full' );
echo '';
} else {
echo '';
}
}
endif;
if ( ! function_exists( 'neatly_header_logo_icon' ) ) :
function neatly_header_logo_icon () {
$header_icon = get_theme_mod( 'neatly_header_icon','');
if($header_icon !== '' ){
$header_icon_size = wp_get_attachment_metadata( attachment_url_to_postid($header_icon) );
echo '';
}
}
endif;
/*時差*/
if ( ! function_exists( 'neatly_human_time_diff' ) ) :
function neatly_human_time_diff($post_time) {
$just_now = current_time('timestamp');
/*人間感覚 の日付差分*/
$diff['days'] = ( strtotime( date("Y-m-d" , $just_now ) ) - strtotime( date("Y-m-d", $post_time ) ) ) / 86400;
$diff['year'] = (int) floor($diff['days'] / 365);
if ($diff['year'] === 1) return __('a year ago','neatly');
/* translators: %s: years */
if ($diff['year'] > 1) return sprintf( __( '%s years ago' , 'neatly' ), $diff['year'] );
$diff['month'] = (int) floor($diff['days'] / 30);
if ($diff['month'] === 1) return __('a month ago','neatly');
/* translators: %s: months */
if ($diff['month'] > 1) return sprintf( __( '%s months ago' , 'neatly' ), $diff['month'] );
$diff['week'] = (int) floor($diff['days'] / 7);
/* translators: %s: week */
if ($diff['week'] > 1) return sprintf( __('%s weeks ago','neatly'), $diff['week'] );
if ($diff['week'] === 1) return __('a week ago','neatly');
/* translators: %s: date */
if ($diff['days'] > 1) return sprintf( __( '%s days ago' , 'neatly' ), $diff['days'] );
/*人間感覚 の時間差分*/
$diff['time'] = $just_now - $post_time ;
$diff['hour'] = (int) floor( $diff['time'] / 3600 );
if ($diff['hour'] === 1) return __('an hour ago','neatly');
/* translators: %s: hour */
if( $diff['hour'] <= 20 && $diff['hour'] >= 1) return sprintf( __( '%s hours ago' , 'neatly' ), $diff['hour'] );
/* translators: %s: post time */
if ($diff['hour'] >= 21 && $diff['days'] === 1) return sprintf( __('yesterday at %s','neatly'), date("h:i a", $post_time ) );
$diff['minute'] = (int) floor( $diff['time'] / 60 );
if ($diff['minute'] === 1) return __('a minute ago','neatly');
/* translators: %s: minute */
if ($diff['minute'] > 1) return sprintf( __( '%s minutes ago' , 'neatly' ), $diff['minute'] );
return __('just now','neatly');
}
endif;
if ( ! function_exists( 'neatly_get_thumbnail' ) ) :
function neatly_get_thumbnail($post_id = '' , $size = 'thumbnail') {
/*
* @param string $post_id Post ID.
* @param string $size thumbnail, middle ,large etc.
*/
$thumbnail = array();
if( has_post_thumbnail($post_id) ) {/*サムネイルがある場合*/
/*配列で返す*/
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id($post_id) , $size );
$thumbnail['has_image'] = true;
return $thumbnail;
}else{
preg_match("/]+src=[\"'](s?https?:\/\/[\-_\.!~\*'()a-z0-9;\/\?:@&=\+\$,%#]+\.(jpg|jpeg|png|gif))[\"'][^>]+>/i", get_post($post_id)->post_content, $thumurl);
if(isset($thumurl[1])){
$img_id = attachment_url_to_postid($thumurl[1]);
$img_data = wp_get_attachment_metadata ($img_id);
/*サイト内の画像であれば*/
if(!empty($img_data) ){
$thumbnail[0] = $thumurl[1];
$thumbnail[1] = $img_data['width'];
$thumbnail[2] = $img_data['height'];
$thumbnail['has_image'] = true;
return $thumbnail;
}
}
}
$thumbnail[0] = $thumbnail[1] = $thumbnail[2] = '';
$thumbnail['has_image'] = false;
return $thumbnail;
}
endif;
if ( ! function_exists( 'neatly_comment_author_anchor' ) ) :
function neatly_comment_author_anchor( $author_link ){
return str_replace( "comment_type ) :
case 'pingback':
case 'trackback':
?>
' . neatly_get_theme_svg( 'pencil' ) . '', '' ); ?>