Site logo

[Resolved] Set default stying for the off canvas panel programatically

Home Forums Support [Resolved] Set default stying for the off canvas panel programatically

Home Forums Support Set default stying for the off canvas panel programatically

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #2595369
    David

    Hi, I’d like to set some defaults in functions.php for styling of the off canvas panel. Could you please help with a filter for this? Thanks! David

    #2595491
    Fernando
    Customer Support

    Hi David,

    Try adding these snippets:

    add_filter( 'generate_color_option_defaults', 'new_generate_menu_plus_color_defaults' );
    
    function new_generate_menu_plus_color_defaults( $defaults ) {
    	$defaults['slideout_background_color'] = '';
    	$defaults['slideout_text_color'] = '';
    	$defaults['slideout_background_hover_color'] = '';
    	$defaults['slideout_text_hover_color'] = '';
    	$defaults['slideout_background_current_color'] = '';
    	$defaults['slideout_text_current_color'] = '';
    	$defaults['slideout_submenu_background_color'] = '';
    	$defaults['slideout_submenu_text_color'] = '';
    	$defaults['slideout_submenu_background_hover_color'] = '';
    	$defaults['slideout_submenu_text_hover_color'] = '';
    	$defaults['slideout_submenu_background_current_color'] = '';
    	$defaults['slideout_submenu_text_current_color'] = '';
    
    	return $defaults;
    }
    
    add_filter( 'generate_font_option_defaults', 'new_generate_menu_plus_typography_defaults' );
    
    function new_generate_menu_plus_typography_defaults( $defaults ) {
    	$defaults['slideout_font_weight'] = 'normal';
    	$defaults['slideout_font_transform'] = 'none';
    	$defaults['slideout_font_size'] = '';
    	$defaults['slideout_mobile_font_size'] = '';
    
    	return $defaults;
    }

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    #2595877
    David

    Great, thank you Fernando. On the same note, can font-weight also be set this way for the normal primary navigation? Thanks! David

    #2596762
    Ying
    Staff
    Customer Support

    You can add one line of ‘navigation_font_weight’ to Fernando’s code, here’s the updated version:

    function new_generate_menu_plus_typography_defaults( $defaults ) {
    	$defaults['slideout_font_weight'] = 'normal';
    	$defaults['slideout_font_transform'] = 'none';
    	$defaults['slideout_font_size'] = '';
    	$defaults['slideout_mobile_font_size'] = '';
            $defaults['navigation_font_weight'] => 'normal',
    
    	return $defaults;
    }
    #2596803
    David

    Hi Fernando / Ying, I can;t seem to get any filter to work on ‘generate_font_option_defaults’ which is strange. My full function is:

    add_filter( ‘generate_font_option_defaults’, ‘ffdv_ext_font_defaults’ );
    function ffdv_ext_font_defaults( $ext_font_defaults ) {

    $ext_font_defaults[‘slideout_font_size’] = ’20’;
    $ext_font_defaults[‘slideout_mobile_font_size’] = ’17’;
    $ext_font_defaults[‘slideout_font_weight’] = ‘600’;
    $ext_font_defaults[‘slideout_font_transform’] = ”;

    return $ext_font_defaults;

    }

    #2598767
    Fernando
    Customer Support

    Hi David,

    Can you make sure that there are no syntax errors or slanted quotation marks?

    #2599030
    David

    Hi Fernando,

    The syntax is all good, still no luck with this.

    Thanks!

    #2599263
    David
    Staff
    Customer Support

    Hi there,

    the generate_font_option_defaults is for the old Typography system. Where a default option existed for every typography setting.
    This don’t work with the new dynamic typography system as there are no defaults. Typography rules only exist if you create them.
    If you want to set typography in a child theme then add them to yours styles.css.

    #2599285
    David

    Thanks as always David…

    #2599451
    David
    Staff
    Customer Support

    You’re welcome

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.