Skip to content

Instantly share code, notes, and snippets.

@WerdsWords
Last active December 19, 2015 23:28
Show Gist options
  • Save WerdsWords/6034578 to your computer and use it in GitHub Desktop.
Save WerdsWords/6034578 to your computer and use it in GitHub Desktop.
#8: get_the_generator_{$type}
<?php
/**
* WordPress versions to jazz musicians
*
* @param string $gen The generator meta tag.
* @param string $type The type of page to generate the tag for.
*
* @return string The filtered generator meta tag.
*/
function wpdocs_generator_as_jazzer( $gen, $type ) {
// Jazz musicians to their respective release versions
// The leading space in the verisons are to avoid
// false positives from point releases in the strpos().
$jazzers = array(
' 1.0' => 'Miles Davis', ' 1.2' => 'Charles Mingus',
' 1.5' => 'Billy Strayhorn', ' 2.0' => 'Duke Ellington',
' 2.1' => 'Ella Fitzgerald', ' 2.2' => 'Stan Getz',
' 2.3' => 'Dexter Gordon', ' 2.5' => 'Michael Brecker',
' 2.6' => 'McCoy Tyner', ' 2.7' => 'John Coltrane',
' 2.8' => 'Chet Baker', ' 2.9' => 'Carmen McRae',
' 3.0' => 'Thelonious Monk', ' 3.1' => 'Django Reinhardt',
' 3.2' => 'George Gershwin', ' 3.3' => 'Sonny Stitt',
' 3.4' => 'Grant Green', ' 3.5' => 'Elvin Jones'
);
foreach ( $jazzers as $version => $name ) {
if ( strpos( $gen, $version ) )
$jazzer = $name;
}
if ( empty( $jazz ) )
$jazzer = 'Jazz';
// Outputs 'WordPress to the sounds of [Musician] or Jazz'
$jazzer = sprintf( esc_attr__( 'WordPress to the sounds of %s', 'yourtextdomain' ), $jazzer );
return '<meta content="' . $jazzer . '" name="generator">';
}
add_filter( 'get_the_generator_xhtml', 'wpdocs_generator_as_jazzer', 10, 2 );
@WerdsWords
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment