Skip to content

Instantly share code, notes, and snippets.

@mohammadmursaleen
Created November 3, 2016 06:48
Show Gist options
  • Save mohammadmursaleen/471481329929d9e8f0ede49389bcbc96 to your computer and use it in GitHub Desktop.
Save mohammadmursaleen/471481329929d9e8f0ede49389bcbc96 to your computer and use it in GitHub Desktop.
WordPress Adding language support to all get_the_date() calls
<?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