Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter to remove styles from breadcrumb #702

Open
abombelli opened this issue Dec 18, 2024 · 4 comments
Open

Filter to remove styles from breadcrumb #702

abombelli opened this issue Dec 18, 2024 · 4 comments
Labels
Breadcrumbs nomnom [Type] Enhancement Improves anything we already have.
Milestone

Comments

@abombelli
Copy link

Hello
Right now there is no way to remove the generated styles for breadcrumbs.
We can use this filter, but the <style></style> tags are still returned in the markup.

add_filter(
            'the_seo_framework_breadcrumb_shortcode_css',
            function ( $css, $class ) {
        
                // Remove all entries in $css
                $css = [];
        
                return $css;
            }, 10, 2 );

Or is there any other way without touching core files?

@sybrew sybrew added the [Type] Support It's also a question, but a resolution is required. label Dec 19, 2024
@sybrew
Copy link
Owner

sybrew commented Dec 19, 2024

Hello!

I recommend using that filter only to modify or add styles, not remove them altogether.
The breadcrumbs are generated as a list for improved machine readability, but they should actually be styled inline.

Outputting the CSS asynchronously would cause the browser to render the breadcrumbs as a list and then again as inline, causing a significant jump in the content, which is bad for UX. To learn more about this, see https://web.dev/articles/cls.

In any case, yes, that filter would effectively remove the default styles.

Is there any reason you wish to remove the styling? I made them as tiny as possible to mitigate any measurable impact.

P.S. is this your request? I've halted support on Matt's website until the litigatory dust is settled.

@abombelli
Copy link
Author

Hello back!
Thank you for the feedback.

I use function_exists( 'tsf_breadcrumb' ) ? tsf_breadcrumb(['class' => 'breadcrumb-nav'])
As I do the styling for the breadcrumb in the themes CSS, I would like to completely remove the one you provided. It would be a bit cleaner instead overriding the TSF styles.

The mentioned filter just removes the styles. But it leaves the empty <style></style> tags still in place. Actually it would be great tu update the filter, so it does not return them if the $css array is empty.
Thanks!

PS. Yes, this was my request. Let's hope the dust settles soon …

@sybrew
Copy link
Owner

sybrew commented Dec 23, 2024

I understand your use case. Thank you for the feedback!

I'll probably implement the change in the next minor update.

@sybrew sybrew added this to the 5.1.3 milestone Dec 23, 2024
@sybrew sybrew added [Type] Enhancement Improves anything we already have. Breadcrumbs nomnom and removed [Type] Support It's also a question, but a resolution is required. labels Dec 23, 2024
@abombelli
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breadcrumbs nomnom [Type] Enhancement Improves anything we already have.
Projects
None yet
Development

No branches or pull requests

2 participants