Archives

Home Forums Search Search Results for 'option_generate_menu_plus_settings'

Search Results for 'option_generate_menu_plus_settings'

Home Forums Search Search Results for 'option_generate_menu_plus_settings'

Viewing 15 results - 1 through 15 (of 61 total)
  • Author
    Search Results
  • #1943134
    David
    Staff
    Customer Support

    Hmmm… lets try the reverse logic. Disable the Navigation as Header option in the Customizer then try this PHP Snippet:

    add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
        if ( !is_front_page() ) {
            $settings['navigation_as_header'] = 'true';
        }
    
        return $settings;
    } );
    #1943084
    David
    Staff
    Customer Support

    Hi there,

    Enable the Navigation as Header in the Customizer, and the you can use this PHP Snippet to disable it on the front page.

    add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
        if ( is_front_page() ) {
            $settings['navigation_as_header'] = 'false';
        }
    
        return $settings;
    } );
    #1890055
    Elvin
    Staff
    Customer Support

    Hi Darryl,

    Assuming a logged in user is automatically a member, you can try enabling the off-canvas menu by default but disable it for non-logged in users by using this PHP snippet.

    add_filter( 'option_generate_menu_plus_settings','lh_custom_homepage_menu_plus_settings' );
    function lh_custom_homepage_menu_plus_settings( $options ) {
    	if( !is_user_logged_in() ){
            $options['slideout_menu'] = 'false';
    	}
        
        return $options;
    }

    Here’s how to add PHP – https://docs.generatepress.com/article/adding-php/

    A wise man once said:
    "Have you cleared your cache?"

    #1842886
    Tom
    Lead Developer
    Lead Developer

    This depends on how you’re displaying the logo on mobile.

    If you’re using the Mobile Header option, you can adjust your function to include its logo:

    add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
        if ( ICL_LANGUAGE_CODE == 'en' ) {
            $settings['sticky_navigation_logo'] = 'your english logo image URL here';
            $settings['mobile_header_logo'] = 'your mobile logo';
        } 
    
        if ( ICL_LANGUAGE_CODE == 'jp' ) {
            $settings['sticky_navigation_logo'] = 'your japanese logo image URL here';
            $settings['mobile_header_logo'] = 'your mobile logo';
        }
        
        return $settings;
    } );
    #1841705
    Elvin
    Staff
    Customer Support

    You can base on this example for your sticky menu logo.

    This snippet assumes you’re using a Header Element with merged header.

    add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
        if ( ICL_LANGUAGE_CODE == 'en' ) {
            $settings['sticky_navigation_logo'] = 'your english logo image URL here';
        } 
    
        if ( ICL_LANGUAGE_CODE == 'jp' ) {
            $settings['sticky_navigation_logo'] = 'your japanese logo image URL here';
        }
        
        return $settings;
    } );

    A wise man once said:
    "Have you cleared your cache?"

    #1725219
    Nicole

    I had a similar problem and I could fix it with adding this to the functions.php:

    add_filter( ‘option_generate_menu_plus_settings’,’lh_custom_homepage_menu_plus_settings’ );
    function lh_custom_homepage_menu_plus_settings( $options ) {
    if ( is_page() || is_front_page() ) {
    $options[‘slideout_menu’] = ‘false’;
    }

    return $options;
    }

    #1710509
    Thomas

    I have one more question, sorry to thread spam!

    Is there a way to get the navigation as a header to be true for the front page if user is on mobile?

    I can accomplish this using wp_is_mobile but I read that it’s bad form to use that filter? Is that true?

    The php code above still didn’t work for some odd reason. I tried to reverse the logic and it worked, except I wanted to be able to keep the navigation as a header on for the mobile front page.

    Here is the reverse code:

    add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
        if ( is_front_page() == FALSE ) {
            $settings['navigation_as_header'] = 'true';
        }
    
        return $settings;
    } );

    I did figure out the CSS to turn the bar off on desktop and tablet though, which would be another option.

    .home #site-navigation{
                    display: none;
    }

    But I have a fear that doing something like that would have a effect on SEO? I dunno. Thank you for the help! 🙂

    #1710483
    Thomas

    Jeesh thanks I was looking for that filter action and couldn’t find it!

    Unfortuantely it doesn’t seem to have done anything :(. The header still oddly shows. I’m wondering if it’s conflicting with the other code I have in the functions file for the child theme?

    remove_action( 'wp_footer', 'generate_slideout_navigation', 0 );
    add_action( 'generate_before_header', function() {
    	if ( is_front_page() ) :
    		echo '<div class="header-wrap">';
    		generate_slideout_navigation();
    		echo '<div class="featured-container" style="background-image: url('. get_the_post_thumbnail_url(get_the_ID(),'medium_large') .  ')"></div>';
    		echo '</div>';
    	endif;
    }, 2);
    
    add_action( 'after_setup_theme','tu_remove_footer' );
    function tu_remove_footer() {
        remove_action( 'generate_footer','generate_construct_footer' );
    }
    
    add_shortcode( 'current_year', 'lh_current_year' );
    function lh_current_year() {
        ob_start();
        echo date('Y');
        return ob_get_clean();
    }
    
    add_shortcode( 'mobile_header', function () {
    	ob_start();
    	
    	$featured_img_url = get_the_post_thumbnail_url(get_the_ID(), 'full');
    	
    	if (wp_is_mobile() ):
    		echo '<div class="mobile-featured-container" style="background-image: url('. $featured_img_url .  ')"></div>';
    	endif;
    	return ob_get_clean();
    });
    
    add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
        if ( is_front_page() ) {
            $settings['navigation_as_header'] = 'false';
        }
    
        return $settings;
    } );
    #1637434
    Stacey

    Thanks I’ve added in this code

    add_filter( 'option_generate_menu_plus_settings','lh_custom_homepage_menu_plus_settings' );
    function lh_custom_homepage_menu_plus_settings( $options ) {
        if ( is_front_page() ) {
            $options['mobile_menu_label'] = 'Home Page Toggle Text';
            $options['slideout_menu'] = 'both';
    		$options['slideout_menu_side'] = 'left';      
        }
        
        return $options;
    }

    But it still looks the same on the home page. Do I need to hide the other menu? It mentions something along those lines in the post you referred to

    #1621780

    In reply to: How to add custom svg

    Randy

    Not quite, I tried that and it completely replaces my Sign In / Sign Out text that I showed in this code above: add_filter( 'option_generate_menu_plus_settings'

    I’m simply trying to put a small svg profile icon in front of the words Sign In and Sign Out.

    Link below so you can see the Sign In / Sign Out button I’m referring to 🙂

    #1621344

    In reply to: How to add custom svg

    Randy

    OK, I see that example, thank you! Just trying to determine how to approach it.

    I already have the following that is toggling the label:

    add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
    	if ( is_user_logged_in() ) {
    	   $settings['off_canvas_desktop_toggle_label'] = 'Sign Out';
    	} else {
    		$settings['off_canvas_desktop_toggle_label'] = 'Sign In or Join';	
    	}
        return $settings;
    } );

    So then I guess I would use
    add_filter( 'generate_off_canvas_toggle_output', function() {

    and in that define the $svg = ‘svg definition here’;

    But how would I then return it with the svg followed by my toggle label already set before in option_generate_menu_plus_settings?

    Conceptually I get it, but just not quite sure on the coding to use!

    #1620551
    [Resolved]

    Topic: How to add custom svg

    in forum Support
    Randy

    I have custom svg I’d like to add to my “off-canvas-toggle-label”.

    That label is controlled as showing either sign in or sign out by add_filter( ‘option_generate_menu_plus_settings’,

    In case its helpful, that toggle label is part of span with class “menu-bar-item slideout-toggle hide-on-mobile has-svg-icon”

    How can I insert custom svg in front of the $settings[‘off_canvas_desktop_toggle_label’] = in my add_filter, or even just hard-code it in front of that menu label if that’s easier.

    Thanks!

    #1618881
    Leo
    Staff
    Customer Support

    If you need the navigation as a header for one page only then use this PHP snippet:

    add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
        if ( is_page( xx ) ) {
            $settings['navigation_as_header'] = 'true';
        }
    
        return $settings;
    } );

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

    And edit xx to the actual ID of the page.

    #1609689
    johnaps

    i turned off, off canvas and added this to my functions.php

    //enable #generate-slideout-menu only on product filter categories
    
    add_filter( 'option_generate_menu_plus_settings','lh_custom_pages_menu_plus_settings' );
    function lh_custom_pages_menu_plus_settings( $options ) {
        if( is_product_category( array('νοσοκομειακα-κρεβατια', 'ηλεκτροκίνητα-αναπηρικά-αμαξίδια', 'χειροκίνητα-αναπηρικά-αμαξίδια', 'μαξιλάρια-ύπνου', '/οξυγονοθεραπεία/συμπυκνωτές-οξυγόνου-φιάλες/')) ) {
            $options['slideout_menu'] = 'both';
        }
        
        return $options;
    }

    the button that opens the off canvas menu, that appears under 1050px doesnt work (https://ibb.co/0qhcnxB)

    example url: https://staging-sofianosorthopedikagr.kinsta.cloud/%CE%BA%CE%B1%CF%84-%CE%BF%CE%AF%CE%BA%CE%BF%CE%BD-%CE%BD%CE%BF%CF%83%CE%B7%CE%BB%CE%B5%CE%AF%CE%B1/%CE%BD%CE%BF%CF%83%CE%BF%CE%BA%CE%BF%CE%BC%CE%B5%CE%B9%CE%B1%CE%BA%CE%AC-%CE%BA%CF%81%CE%B5%CE%B2%CE%AC%CF%84%CE%B9%CE%B1/%CE%BD%CE%BF%CF%83%CE%BF%CE%BA%CE%BF%CE%BC%CE%B5%CE%B9%CE%B1%CE%BA%CE%B1-%CE%BA%CF%81%CE%B5%CE%B2%CE%B1%CF%84%CE%B9%CE%B1/

    #1606159
    johnaps

    So would the following work for my case?

    //disable #generate-slideout-menu everywhere
    
    add_filter( 'option_generate_menu_plus_settings','lh_all_pages_menu_plus_settings' );
    function lh_all_pages_menu_plus_settings( $options ) {
            $options['slideout_menu'] = 'false';
            return $options;
    }
    
    //enable #generate-slideout-menu only on product filter categories
    
    add_filter( 'option_generate_menu_plus_settings','lh_custom_pages_menu_plus_settings' );
    function lh_custom_pages_menu_plus_settings( $options ) {
        if( is_product_category( array('category1-slug', 'category2-slug' )) ) {
            $options['slideout_menu'] = 'mobile';
        }
        
        return $options;
    }
Viewing 15 results - 1 through 15 (of 61 total)