[Support request] How to remove Menu That is not neccesary

Home Forums Support [Support request] How to remove Menu That is not neccesary

Home Forums Support How to remove Menu That is not neccesary

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #1608288
    Mr Calvert

    How to remove <span class=”screen-reader-text”>Menu</span> That is not neccesary
    I was try add this code of Tom:
    add_filter(‘generate_mobile_menu_label’,’generate_remove_menu_label’);
    function generate_remove_menu_label()
    {
    return ”;
    }
    But it not useful. Can you give me function to remove that?
    This is image class I need remove: https://ibb.co/9T1bC1M

    #1608618
    Leo
    Staff
    Customer Support

    Hi there,

    That is actually needed for accessibility purpose and I would recommend keeping it – we don’t add any unnecessary code in GP to your site πŸ™‚

    #1608820
    Mr Calvert

    But i was add another menu! Can you help me code for remove that class? I don’t want it in HTML:
    <span class=”screen-reader-text”>Menu</span>

    #1608822
    Mr Calvert

    I see this code but don’t know how to fix that with add function child theme:

    				<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
    					<?php
    					/**
    					 * generate_inside_mobile_menu hook.
    					 *
    					 * @since 0.1
    					 */
    					do_action( 'generate_inside_mobile_menu' );
    
    					generate_do_svg_icon( 'menu-bars', true );
    
    					$mobile_menu_label = apply_filters( 'generate_mobile_menu_label', __( 'Menu', 'generatepress' ) );
    
    					if ( $mobile_menu_label ) {
    						printf(
    							'<span class="mobile-menu">%s</span>',
    							$mobile_menu_label // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML allowed in filter.
    						);
    					} else {
    						printf(
    							'<span class="screen-reader-text">%s</span>',
    							esc_html__( 'Menu', 'generatepress' )
    						);
    					}
    					?>
    				</button>

    Can you give me code to remove <span class=”screen-reader-text”>Menu</span>

    #1608908
    Mr Calvert

    Have anyone help me! I very need that!!!

    #1609011
    Mr Calvert

    Have any body help me! I very need function to remove that. I only have this problem to run the website.

    #1609126
    David
    Staff
    Customer Support

    If you’re displaying the GP Menu button then what exactly is the issue with the Screen Reader element being there ? As Leo said it is for Accessibility purposes.

    It would help if we understood what you’re trying to achieve, ,maybe a link to your site would help us understand better.

    #1609184
    Mr Calvert

    I only need function to remove that sir. I was find some code to remove screen-reader-text of Tag.
    Tom was share that but I can’t find that topic again:

    add_filter( 'generate_tag_list_output', function() {
        return sprintf(
            '<span class="tags-links">%3$s%2$s</span> ',
            esc_html_x( 'Tags', 'Used before tag names.', 'generatepress' ),
            strip_tags( get_the_tag_list( '', ', ' ) ),
            apply_filters( 'generate_inside_post_meta_item_output', '', 'tags' )
        );
    } );

    I use that for remove screen-reader-text tag. So I need something function like that to remove <span class=”screen-reader-text”>Menu</span>

    I was try with this function but it not work!

    add_filter( 'generate_mobile_menu_label', 'tu_change_mobile_menu' );
    function tu_change_mobile_menu() {
    $mobile_menu_label = apply_filters( 'generate_mobile_menu_label', $mobile_menu_label );
    if ( $mobile_menu_label ) {
    	return printf(
    	'',
    	$mobile_menu_label // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML allowed in filter.
    	);
    } else {
    	return printf(
    	'',
    	esc_html__( 'Menu', 'generatepress' )
    	);
    }
    }

    I don’t need any html tag not hiden. I need remove “Menu” word, but when remove “Menu” word <span class=”screen-reader-text”> will empty. So I need function to remove all that!

    #1609264
    David
    Staff
    Customer Support

    As per Tom’s reply here that element is NOT filterable:

    https://generatepress.com/forums/topic/need-to-add-this-to-the-tag/#post-1397467

    What i don’t understand is why you believe it is not necessary ? This is a necessary requirement to ensure the site remains accessible, without that element users who require accessible technologies will not know that the button is the menu.

    #1609377
    Mr Calvert

    I think I not have same question with Shrawan. Can you talk Tom help me about that? I think it can remove. It is navigation.php, line 50 and line 145. I was try remove like this and it work exactly I need, I only don’t know how to fix that with function add child theme!!!
    You can see this image I was remove that and it useful: https://ibb.co/zRKVzwG

    #1609816
    Mr Calvert

    I will description detail again for easy to knowleage.
    I need remove <span class="mobile-menu">Menu</span> and <span class="screen-reader-text">Menu</span> (I don’t want it show in HTML source code). This is two span I need remove in HTML:https://ibb.co/CQMmw1n

    I was search in source code GeneratePress have one file navigation.php in this URL: \generatepress\inc\structure\navigation.php
    Two span class in function at line 12 and line 104.

    I was try delete span class in source main of GeneratePress it work fine. But I can’t fix main theme, I only want add function in child-theme to fix that!
    After that I was try four way:
    Way 1: I was copy all navigation.php to child theme and remove all span class like I need (but it not effect).

    Way 2: I copy code in navigation.php to navigation-custom.php in child-theme and change all name of function I add _custom in last of function name. I do it because I think have one function to remove navigation.php (old) to replace with navigation-custom.php, but I don’t know that function to replace.

    Way 3: Like way 2 I was copy the code and change name of some function redeclare but I add that code to child-theme. But not work it generate double menu.

    Way 4: I not know code exactly but I think have action hook to fix that (but I don’t know exactly hook and code I need to use). I was try something like this code but it not useful:

    add_filter( 'generate_mobile_menu_label', 'tu_change_mobile_menu' );
    $mobile_menu_label = apply_filters( 'generate_mobile_menu_label', __( 'Menu', 'generatepress' ) );
    	if ( $mobile_menu_label ) {
    		return printf(
    			'<span class="hello">%s</span>',
    			$mobile_menu_label // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML allowed in filter.
    		);
    	} else {
    		return printf(
    			'<span class="how">%s</span>',
    			esc_html__( '', 'generatepress' )
    			);
    		}
    }

    I was try a lot but can’t edit. Can you help me? I very need way add code function to child theme (if not I need anyway to fix) I was try in two day but I don’t know exactly code for fix!!!

    #1609990
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    As of right now, there is no filter to remove that accessibility text – it’s added after the filter as it’s important for accessibility reasons.

    I’ve made a note to add a filter later so it can be removed in a future version.

    #1609996
    Mr Calvert

    Hello Tom! Thanks for your anwser!
    I have one problem hope you help!
    I had saw a lot of comment tag not necessary. Can you help me remove that with function? I think if one post have a lot of comment the DOM will inscrease size and have lost data of engine bot to read that!
    <!– #comment-## –>
    <!– .children –>
    <!– .comment-list –>
    <!– #respond –>
    <!– #comments –>
    It in html you can see this image: https://ibb.co/LYSkSGC
    Can remove it with function add to child-theme?

    #1610002
    Tom
    Lead Developer
    Lead Developer

    We have been removing these slowly in our recent releases. The good news is the size they add to the DOM is tiny – it’s not something I would worry about whatsoever at the moment.

    #1610185
    Mr Calvert

    But have anyway to remove that with function? I was upload with newest update and I see it still have comment tag:
    <!– #comment-## –>
    <!– .children –>
    <!– .comment-list –>
    <!– #respond –>
    <!– #comments –>
    I have page with 100 comment and it was show still 105 tag like this. Do it increase DOM too much?

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