Created
November 3, 2016 06:48
-
-
Save mohammadmursaleen/471481329929d9e8f0ede49389bcbc96 to your computer and use it in GitHub Desktop.
WordPress Adding language support to all get_the_date() calls
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 | |
/** | |
* @author Mohammad Mursalenen | |
* @param $date | |
* @return mixed | |
*/ | |
function mm_get_date_lang_support($date){ | |
if ( function_exists('icl_object_id') ) { | |
if ('ja' == ICL_LANGUAGE_CODE) { | |
$dateformatstring = "Y年-m月-d日"; | |
$unixtimestamp = strtotime($date); | |
$date = date_i18n($dateformatstring, $unixtimestamp); | |
} | |
} | |
return $date; | |
} | |
/** | |
* @author Mohammad Mursaleen | |
* @usage to add japanese lang support to all get_the_date() calls | |
* @param $the_date | |
* @param $d | |
* @param $post | |
* @return mixed | |
*/ | |
function mm_date_lang_support_filter( $the_date, $d, $post ) { | |
return mm_get_date_lang_support($the_date); | |
} | |
add_action( 'get_the_date', 'mm_date_lang_support_filter', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment