Last active
January 31, 2017 17:59
-
-
Save generatepress/c662c1002e66f86a7cf42e084305a4db to your computer and use it in GitHub Desktop.
GeneratePress Polylang compatibility. Copyright and mobile menu label added so far
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
add_action( 'after_setup_theme','generate_polylang_integration' ); | |
function generate_polylang_integration() { | |
if ( function_exists( 'pll_register_string' ) ) { | |
if ( function_exists( 'generate_copyright_add_custom' ) ) { | |
$new_copyright = get_theme_mod( 'generate_copyright' ); | |
if ( ! empty( $new_copyright ) ) { | |
pll_register_string( 'GeneratePress Copyright', $new_copyright, 'GP Premium' ); | |
add_filter('generate_copyright','generate_polylang_copyright_add_custom'); | |
} | |
} | |
if ( function_exists( 'generate_menu_plus_get_defaults' ) ) { | |
$generate_menu_plus_settings = wp_parse_args( | |
get_option( 'generate_menu_plus_settings', array() ), | |
generate_menu_plus_get_defaults() | |
); | |
pll_register_string( 'GeneratePress Mobile Menu', $generate_menu_plus_settings['mobile_menu_label'], 'GP Premium' ); | |
remove_filter( 'generate_mobile_menu_label','generate_menu_plus_label' ); | |
add_filter( 'generate_mobile_menu_label','generate_menu_plus_polylang_label' ); | |
} | |
} | |
} | |
function generate_polylang_copyright_add_custom( $copyright ) | |
{ | |
$options = array( | |
'%current_year%', | |
'%copy%' | |
); | |
$replace = array( | |
date('Y'), | |
'©' | |
); | |
$new_copyright = get_theme_mod( 'generate_copyright' ); | |
$new_copyright = str_replace( $options, $replace, get_theme_mod( 'generate_copyright' ) ); | |
if ( get_theme_mod( 'generate_copyright' ) && '' !== get_theme_mod( 'generate_copyright' ) ) { | |
return do_shortcode( pll__( $new_copyright ) ); | |
} | |
return $copyright; | |
} | |
function generate_menu_plus_polylang_label() | |
{ | |
$generate_menu_plus_settings = wp_parse_args( | |
get_option( 'generate_menu_plus_settings', array() ), | |
generate_menu_plus_get_defaults() | |
); | |
return pll__( $generate_menu_plus_settings['mobile_menu_label'] ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment