Skip to content

Instantly share code, notes, and snippets.

@generatepress
Last active January 31, 2017 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save generatepress/c662c1002e66f86a7cf42e084305a4db to your computer and use it in GitHub Desktop.
Save generatepress/c662c1002e66f86a7cf42e084305a4db to your computer and use it in GitHub Desktop.
GeneratePress Polylang compatibility. Copyright and mobile menu label added so far
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