Site logo

[Resolved] Replace menu bars close icon

Home Forums Support [Resolved] Replace menu bars close icon

Home Forums Support Replace menu bars close icon

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2308811
    Daniel

    So using the following snippet Ive been able to replace the normal menu-bars, but not the close menu-bars.

    add_filter( 'generate_svg_icon_element', function( $output, $icon ) {
        if ( 'menu-bars' === $icon ) {
            $output = '<svg class="mobile-menu-toggle" width="26" height="21" viewBox="0 0 26 21" fill="none" xmlns="http://www.w3.org/2000/svg">
    				   <path d="M0 0.5H26M0 10.5H26M0 20.5H26"/>
    		           </svg>';
        }
    	
        if ( 'close' === $icon ) {
            $output = '<svg class="mobile-menu-close" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M1.1612 0.646495L19.546 19.0313M0.454102 19.0313L18.8389 0.646484"/>
        </svg>';
        }
    	
        return $output;
    	
    }, 10, 2 );

    What is wrong here? 😅

    #2309227
    Ying
    Staff
    Customer Support

    Hi Daniel,

    Can you try this filter instead?

    add_filter( 'generate_svg_icon', function( $output, $icon ) {
        if ( 'menu-bars' === $icon ) {
            $output = '<span class="gp-icon icon-menu-bars">
                        <svg>Hamburger icon</svg>
                        <svg>Close icon</svg>
                    </span>';
        }
        return $output;
    }, 10, 2 );
    #2309312
    Daniel

    Hey Ying,

    Perfect, worked like a charm. 🙂

    #2309327
    Ying
    Staff
    Customer Support

    Great 🙂

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