manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; // otherwise, return the default return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } } /** * Sanitize our Google Font variants * * @since 2.0 */ function generate_sanitize_variants( $input ) { if ( is_array( $input ) ) { $input = implode( ',', $input ); } return sanitize_text_field( $input ); } add_action( 'customize_controls_enqueue_scripts', 'generate_do_control_inline_scripts', 100 ); /** * Add misc inline scripts to our controls. * * We don't want to add these to the controls themselves, as they will be repeated * each time the control is initialized. * * @since 2.0 */ function generate_do_control_inline_scripts() { wp_localize_script( 'generatepress-typography-customizer', 'gp_customize', array( 'nonce' => wp_create_nonce( 'gp_customize_nonce' ) ) ); wp_localize_script( 'generatepress-typography-customizer', 'typography_defaults', generate_typography_default_fonts() ); } /** * Check to see if we have a logo or not. * * Used as an active callback. Calling has_custom_logo creates a PHP notice for * multisite users. * * @since 2.0.1 */ function generate_has_custom_logo_callback() { if ( get_theme_mod( 'custom_logo' ) ) { return true; } return false; }