- This topic has 20 replies, 5 voices, and was last updated 3 years, 3 months ago by Elvin.
-
AuthorPosts
-
January 6, 2021 at 9:18 am #1608288Mr 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/9T1bC1MJanuary 6, 2021 at 2:38 pm #1608618LeoStaffCustomer SupportHi 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 π
January 6, 2021 at 8:16 pm #1608820Mr CalvertBut 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>January 6, 2021 at 8:19 pm #1608822Mr CalvertI 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>
January 6, 2021 at 10:59 pm #1608908Mr CalvertHave anyone help me! I very need that!!!
January 7, 2021 at 1:13 am #1609011Mr CalvertHave any body help me! I very need function to remove that. I only have this problem to run the website.
January 7, 2021 at 3:19 am #1609126DavidStaffCustomer SupportIf 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.
January 7, 2021 at 4:04 am #1609184Mr CalvertI 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!
January 7, 2021 at 4:49 am #1609264DavidStaffCustomer SupportAs 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.
January 7, 2021 at 6:08 am #1609377Mr CalvertI 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/zRKVzwGJanuary 7, 2021 at 8:54 am #1609816Mr CalvertI 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/CQMmw1nI 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!!!
January 7, 2021 at 11:40 am #1609990TomLead DeveloperLead DeveloperHi 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.
January 7, 2021 at 11:46 am #1609996Mr CalvertHello 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?January 7, 2021 at 11:51 am #1610002TomLead DeveloperLead DeveloperWe 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.
January 7, 2021 at 4:05 pm #1610185Mr CalvertBut 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? -
AuthorPosts
- You must be logged in to reply to this topic.