mktime( 0, 0, 0, 1, 8, 1989 ), '昭和' => mktime( 0, 0, 0, 12, 25, 1926 ), '大正' => mktime( 0, 0, 0, 7, 30, 1912 ), ) ); arsort( $names ); return $names; } } if ( ! function_exists( 'raindrops_japan_date' ) ) { /** * * @global type $post * @param type $date * @return type $string * @since 1.277 */ function raindrops_japan_date( $date ) { global $post; if( raindrops_warehouse_clone( 'raindrops_japanese_date' ) !== 'yes' ) { return $date; } $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 = raindrops_gengou_names(); $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 ); } } } if ( ! function_exists( 'raindrops_category_widget_wareki' ) ) { /** * * @param type $html * @return type $string * @since 1.277 */ function raindrops_category_widget_wareki( $html ) { if( raindrops_warehouse_clone( 'raindrops_japanese_date' ) !== 'yes' ) { return $html; } // archives dropdown has space $html = str_replace( '> ','>', $html); if ( preg_match( '!>([0-9]{4})([^0-9]*)([0-9]{1,2})!', $html, $regs ) && isset( $regs[ 1 ] ) && 2002 < $regs[ 1 ] ) { $year = intval($regs[ 1 ]); //$month = intval($regs[3]); //$date = mktime( 0, 0, 0, $month, 1, $year); $gengou = raindrops_year_to_gengou( $year ); //Do not consider the month return str_replace( array( '>'. $year,), array( '>'. $gengou,), $html ); } return $html; } } if ( ! function_exists( 'raindrops_calender_widget_wareki' ) ) { function raindrops_calender_widget_wareki( $html ) { if( raindrops_warehouse_clone( 'raindrops_japanese_date' ) !== 'yes' ) { return $html; } // archives dropdown has space $html = str_replace( '> ','>', $html); if ( preg_match( '!>([0-9]{4})([^0-9]*)([0-9]{1,2})!', $html, $regs ) && isset( $regs[ 1 ] ) && 2002 < $regs[ 1 ] ) { $year = intval($regs[ 1 ]); $month = intval($regs[3]); $date = mktime( 0, 0, 0, $month, 1, $year); $gengou = raindrops_year_to_gengou( $year,$date ); return str_replace( array( '>'. $year,), array( '>'. $gengou,), $html ); } return $html; } } if ( ! function_exists( 'raindrops_archive_month_widget_wareki' ) ) { /** * * @param type $html * @return type $string * @since 1.277 */ function raindrops_archive_month_widget_wareki( $html,$month ) { if( raindrops_warehouse_clone( 'raindrops_japanese_date' ) !== 'yes' ) { return $html; } // archives dropdown has space $html = str_replace( '> ','>', $html); if ( preg_match( '!>([0-9]{4})([^0-9]*)([0-9]{1,2})!', $html, $regs ) && isset( $regs[ 1 ] ) && 2002 < $regs[ 1 ] ) { $year = intval($regs[ 1 ]); $month = intval($regs[3]); $date = mktime( 0, 0, 0, $month, 1, $year); $gengou = raindrops_year_to_gengou( $year,$date ); //Do not consider the month return str_replace( array( '>'. $year,), array( '>'. $gengou,), $html ); } return $html; } } if ( class_exists( 'breadcrumb_navxt') ) { function raindrops_bcn_breadcrumb_title( $title ,$type,$id) { if( raindrops_warehouse_clone( 'raindrops_japanese_date' ) !== 'yes' ) { return $title; } if ( preg_match( '![0-9]{4}!', $title ) ) { return raindrops_year_to_gengou( $title ); } return $title; } } if ( ! function_exists( 'raindrops_year_to_gengou' ) ) { /** * * @param type $year * @return type $string * @since 1.277 */ function raindrops_year_to_gengou( $year , $date = '' ) { $nen = $year - 1988; if( ! empty( $date ) ) { $nen = $year - (int) date( 'Y', $date ); $gengou = raindrops_gengou_names(); foreach( $gengou as $key => $val ) { $current_diff = intval($date) - intval($val); $nen = (int) $year - (int) date('Y',$val) + 1; if( ! empty( $date ) && ! isset( $prev_diff ) ) { if( $val > $date ) { continue; } $result = $key . $nen; $geugou = $key; } if( ! empty( $date ) && 0 < $current_diff && isset( $prev_diff ) && $current_diff < $prev_diff && $val < $date ) { $result = $key . $nen; $gengou = $key; } $prev_diff = intval($date) - intval($val); } return apply_filters( 'raindrops_wareki_gengou', $result, $geugou, $nen, $year,$date ); } if( empty( $date ) ) { $gengou = raindrops_gengou_names(); foreach( $gengou as $key => $val ) { $current_diff = intval($year) - intval($val); if( ! isset( $prev_diff ) ) { $nen = (int) $year - (int) date('Y',$val) + 1; if( $nen <= 0 ) { continue; } $result = $key . $nen; $geugou = $key; } if( 0 < $current_diff && isset( $prev_diff ) && 0 < $prev_diff && $current_diff < $prev_diff ) { $nen = (int) $year - (int) date('Y',$val) + 1; if( $nen <= 0 ) { continue; } $result = $key . $nen; $gengou = $key; } $prev_diff = intval($year) - intval($val); } return apply_filters( 'raindrops_wareki_gengou', $result, $geugou, $nen, $year ); } //$gengou = apply_filters( 'raindrops_wareki_gengou', "平成" . $nen, "平成", $year - 1988, $year ); return $gengou; } } /* Breadcrump navxt */ if ( ! function_exists( 'raindrops_bcn_template_tags_filter' ) && class_exists( 'breadcrumb_navxt') ) { function raindrops_bcn_template_tags_filter( $replacements, $type, $id ) { if ( 'ja' == get_locale() ) { $this_type = implode( ',', $type ); if ( preg_match( '!date-year!', $this_type ) ) { $replacements["%htitle%"] = $replacements["%htitle%"] . '年'; } if ( preg_match( '!date-day!', $this_type ) ) { $replacements["%htitle%"] = $replacements["%htitle%"] . '日'; } return $replacements; } return $replacements; } } /** * Writing Mode Mix */ if ( ! function_exists( 'raindrops_writing_mode_disable' ) ) { function raindrops_writing_mode_disable() { $format = get_post_format(); if( 'chat' == $format || 'link' == $format ) { return true; } return false; } } if ( ! function_exists( 'raindrops_writing_mode_preparation_check' ) ) { function raindrops_writing_mode_preparation_check(){ $force_remove = apply_filters( 'raindrops_delete_writing-mode-mix', false ); $raindrops_enable_writing_mode_mix = raindrops_warehouse_clone( 'raindrops_enable_writing_mode_mix' ); if ( false == $force_remove && 'yes' == $raindrops_enable_writing_mode_mix ) { return true; } return false; } } $raindrops_enable_writing_mode_mix = raindrops_warehouse_clone( 'raindrops_enable_writing_mode_mix' ); if ( 'yes' == $raindrops_enable_writing_mode_mix ) { add_filter( 'post_class', 'raindrops_style_writing_mode_mix_add_post_class' ); add_filter( 'the_content', 'raindrops_writing_mode_mix_add_attribute', 11 ); add_action( 'wp_enqueue_scripts', 'raindrops_writing_mode_mix_add_font' ); add_filter( 'raindrops_entry_title_class', 'raindrops_style_writing_mode_mix_add_title_class' ); add_filter( 'raindrops_embed_meta_css', 'raindrops_filter_writing_mode_mix' ); add_filter( 'raindrops_delete_writing-mode-mix', 'raindrops_writing_mode_disable' ); } if ( !function_exists( 'raindrops_writing_mode_mix_add_attribute' ) ) { function raindrops_writing_mode_mix_add_attribute( $content ) { $change_elements = array(); $class_array = raindrops_article_wrapper_class(); $force_remove = apply_filters( 'raindrops_delete_writing-mode-mix', false ); $raindrops_enable_writing_mode_mix = raindrops_warehouse_clone( 'raindrops_enable_writing_mode_mix' ); $automatic_add_class = raindrops_warehouse_clone( 'raindrops_enable_writing_mode_mix_auto_add_class' ); if ( false == raindrops_writing_mode_preparation_check() ) { return $content; } if ( 'no' == $automatic_add_class ) { return $content; } if ( 'p' == $automatic_add_class ) { $change_elements[ '

' ] = '

'; } if ( 'p+h' == $automatic_add_class ) { $change_elements[ '

' ] = '

'; $change_elements[ '

' ] = '

'; $change_elements[ '

' ] = '

'; $change_elements[ '

' ] = '

'; $change_elements[ '

' ] = '

'; $change_elements[ '

' ] = '
'; $change_elements[ '
' ] = '
'; } if ( 'p+h+li' == $automatic_add_class ) { $change_elements[ '

' ] = '

'; $change_elements[ '

' ] = '

'; $change_elements[ '

' ] = '

'; $change_elements[ '

' ] = '

'; $change_elements[ '

' ] = '

'; $change_elements[ '

' ] = '
'; $change_elements[ '
' ] = '
'; $change_elements[ '