-
-
Save deckerweb/7053919 to your computer and use it in GitHub Desktop.
This file contains 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 | |
// Don't include the above | |
add_filter( 'wp_nav_menu_items', 'prefix_change_nav_date_format', 15, 2 ); | |
/** | |
* Filter the Primary Navigation menu items in Genesis, to change the date format. | |
* | |
* @author Gary Jones | |
* @link http://www.studiopress.com/forums/topic/abbreviate-month-in-primary-navigation-bar-enterprise/ | |
* | |
* @uses genesis_get_option() Get navigation extras settings. | |
* | |
* @param string $menu HTML string of list items. | |
* @param stdClass $args Menu arguments. | |
* | |
* @return string Amended HTML string of list items. | |
*/ | |
function prefix_change_nav_date_format( $menu, stdClass $args ) { | |
if ( ! genesis_get_option( 'nav_extras' ) || 'primary' !== $args->theme_location ) | |
return $menu; | |
if ( 'date' !== genesis_get_option( 'nav_extras' ) ) | |
return $menu; | |
$format = 'j M Y'; // Change this, as per http://php.net/manual/en/function.date.php | |
return preg_replace( | |
'#\<li class="right date"\>(.*)\</li\>#', | |
'<li class="right date">' . date_i18n( $format ) . '</li>', | |
$menu | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment