Site logo

Archived topic

GP Child Theme Set Customizer Options In Theme

3 replies · Started by Mike on April 20, 2022

Viewing posts 1–4 of 4

Hi,

I am looking for a way to set customizer options in the GP child theme.

I know its possible as I have found these two articles:

https://generatepress.com/forums/topic/passing-customizer-settings-from-a-custom-child-theme-on-installation/
https://generatepress.com/forums/topic/how-can-i-create-a-child-theme-that-comprehends-customizer-settings/

But I am just wondering if this is still the best way to go about this?

I have been playing around with the above methods and I am currently stuck on getting the navigation_as_header set as true.

I have tried setting the parameter using the generate_option_defaults filter but having looked at a customizer export from another site it looks like this part of generate_menu_plus_settings which I am guessing uses a separate filter?

I'm wondering if there is a better method? Maybe do all my customizer edits, take an export, put that .json export file in the child theme and then a PHP snippet in the custom theme to import these settings from the file?

Or maybe some updated defaults filters?

Thanks in advance! Not an easy one!

Mike

Hi David,

Thanks for those links.

Had a quick look and I cant find a way to set the navigation_as_header parameter.

Any ideas?

Have been trying the following code:


if ( !function_exists( 'theme_get_menuplus_defaults' ) ) :
add_filter( 'option_generate_menu_plus_settings','theme_get_menuplus_defaults' );
function theme_get_menuplus_defaults()
{
	$theme_menuplus_defaults = array(
		'navigation_as_header' => true,
		'slideout_menu' => 'both',
		'slideout_menu_style' => 'overlay',
		'mobile_menu_label' => ''
	);

	return $theme_menuplus_defaults;
}
endif;

Thanks!

Mike

OK there's this defaults filter: generate_menu_plus_option_defaults
You will find it in gp-premium/menu-plus/functions/generate-menu-plus.php

Here it is with all its defaults inc. the navigation_as_header

add_filter('generate_menu_plus_option_defaults', function($defaults){
    return array(
        'mobile_menu_label' => __( 'Menu', 'gp-premium' ),
        'sticky_menu' => 'false',
        'sticky_menu_effect' => 'fade',
        'sticky_menu_logo' => '', // Deprecated since 1.8.
        'sticky_menu_logo_position' => 'sticky-menu', // Deprecated since 1.8.
        'mobile_header' => 'disable',
        'mobile_menu_breakpoint' => '768',
        'mobile_header_logo' => '',
        'mobile_header_sticky' => 'disable',
        'mobile_header_branding' => 'logo',
        'slideout_menu' => 'false',
        'off_canvas_desktop_toggle_label' => '',
        'slideout_menu_side' => 'left',
        'slideout_menu_style' => 'slide',
        'slideout_close_button' => 'outside',
        'auto_hide_sticky' => false,
        'mobile_header_auto_hide_sticky' => false,
        'sticky_navigation_logo' => '',
        'navigation_as_header' => true,
    );
});
This archived topic is closed to new replies.