hello world
hello world
hello world
hello world
hello world
hello world
hello world
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'get_the_date', 'japan_date', 11 ); | |
function japan_date( $date ) { | |
global $post; | |
$time_format = get_option( 'time_format' ); | |
$time = get_the_time( $time_format, $post->ID ); | |
$html = '%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s'; | |
$force_gengou = ''; | |
$year_name = '年'; | |
$month_name = '月'; | |
$day_name = '日'; | |
$error = $date; | |
$gengou = array( '平成' => mktime( 0, 0, 0, 1, 8, 1989 ), | |
'昭和' => mktime( 0, 0, 0, 12, 25, 1926 ), | |
'大正' => mktime( 0, 0, 0, 7, 30, 1912 ) | |
); | |
$date = preg_replace( '|[^0-9A-z]+|', '-', $date ); | |
$date = str_replace( array( 'am', 'pm', 'AM', 'PM' ), '', $date ); | |
$date = apply_filters( 'japan_date_input', $date ); | |
arsort( $gengou ); | |
$date = date_parse( $date ); | |
$year = $date[ "year" ]; | |
$month = $date[ "month" ]; | |
$day = $date[ "day" ]; | |
$hour = $date[ "hour" ]; | |
$minute = $date[ "minute" ]; | |
$second = $date[ "second" ]; | |
$fraction = $date[ "fraction" ]; | |
$warning_count = $date[ "warning_count" ]; | |
$warnings = $date[ "warnings" ]; | |
$error_count = $date[ "error_count" ]; | |
$errors = $date[ "errors" ]; | |
$is_localtime = $date[ "is_localtime" ]; | |
if ( $year == false ) { | |
return $error; | |
} | |
if ( $month == false ) { | |
return $error; | |
} | |
if ( $day == false ) { | |
return $error; | |
} | |
if ( $error_count > 1 ) { | |
return $error; | |
} | |
if ( $hour == false or | |
$minute == false or | |
$second == false ) { | |
$hour = 0; | |
$minute = 0; | |
$second = 0; | |
} | |
$input_date = mktime( $hour, $minute, $second, $month, $day, $year ); | |
if ( empty( $force_gengou ) ) { | |
foreach ( $gengou as $key => $val ) { | |
if ( $input_date >= $val ) { | |
$start = date( 'Y', $val ); | |
$year = $year - $start + 1; | |
$result = sprintf( $html, $key, $year, $year_name, $month, $month_name, $day, $day_name, $time ); | |
return $date = apply_filters( 'japan_date_output', $result ); | |
} | |
} | |
} else { | |
$start = date( 'Y', $gengou[ $force_gengou ] ); | |
$year = $year - $start + 1; | |
$result = sprintf( $html, $force_gengou, $year, $year_name, $month, $month_name, $day, $day_nam, $timee ); | |
return $date = apply_filters( 'japan_date_output', $result ); | |
} | |
} | |
?> |