-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Bootstrap 4.0.0-alpha3 .tag class breaks WordPress #20542
Comments
Probably the easiest way is to remove/rename the |
And that is a bad WP practice.
|
It's been a long time since I worked with Wordpress—is there a list of used classes in the default theme(s) we should avoid? |
Here's a good article with possible classes: On Monday, 22 August 2016, Mark Otto notifications@github.com wrote:
|
I loved the idea behind
|
I think WP uses this only on the body tag (not 100% sure). Perhaps a rule to not have
|
@gilronc it appears that wordpress is using Furthermore, they are also recommending to add use the
https://codex.wordpress.org/Function_Reference/post_class |
@cyberwombat Not only the body, but also post entries. What if someone has success as a post tag? Then an entry would be assigned the @guylepage3 a snippet from WordPress 4.6 } elseif ( is_tag() ) {
$tag = $wp_query->get_queried_object();
$classes[] = 'tag';
if ( isset( $tag->term_id ) ) {
$tag_class = sanitize_html_class( $tag->slug, $tag->term_id );
if ( is_numeric( $tag_class ) || ! trim( $tag_class, '-' ) ) {
$tag_class = $tag->term_id;
}
$classes[] = 'tag-' . $tag_class;
$classes[] = 'tag-' . $tag->term_id;
}
} There it adds the |
@maimairel
As WP only uses https://jsfiddle.net/cyberwombat/yg4s5txs/2/ Does that address the WP use cases? |
.tag or .tags are pretty generic and may cause conflicts......i really like .label. Either one will work though. My main development platform is Drupal so i won't really encounter any conflicts with Bootstrap's css. I'm using Bootstrap 4 and 3 currently to develop a Drupal 8 theme. Other frameworks typically use prefixes to solve the problem eg: bs-tag instead of .tag. The problem with prefixes is that it can cause code bloat pretty quickly, imagine prefixing cards, tables, alerts etc( .bs-cards, .bs-tables, .bs-alerts ). Maybe the wordpress conflicts can be resolved quickly by themers who are capable of sub-theming the core wordpress themes and adding their own classes or removing the defaults.(Something that is always done anyways, from my experience). One thing that makes Bootstrap easy to use is that it is plug and play(Insert a stylesheet, add a couple classes and you're done) Salesforce Lightening Framework, Almost everything is prefixed(It increases compatibility but I don't like seeing slds scattered on every html tag, it gets messy pretty quickly) |
I feel I have to highly disagree on this instance @gilronc. IMO, there are two fractions of Boostrap users in this instance. 1) ALL Bootstrap users
vs. 2) Wordpress-Boostrap users
So having said that, I have to err on the side of the majority of Bootstrap users and push for the having the |
@guylepage3 let's keep it real. Currently 26% of all websites globally use WordPress so it's a massive fraction of Bootstrap users |
@guylepage3 , I do agree that it might cause friction and affect readability in some cases but Nothing is wrong with either one from my perspective, i'm fine with whichever one the core maintainers decide to go with. |
@olivia101, 26% is not the majority. |
Here's a snippet to unset the add_filter( 'body_class', 'bs4_remove_tag_body_class' );
function bs4_remove_tag_body_class( $classes ) {
if ( false !== ( $class = array_search( 'tag', $classes ) ) ) {
unset( $classes[$class] );
}
return $classes;
} There's no generic |
@guylepage3 I believe he meant that was 26% of the internet, not Bootstrap users. So it could quite easily be a majority of Bootstrap users, it just depends on the overlap. I know I have seen A LOT of WP themes based on BS and would happily advocate for the framework to try and play nice with it :) |
@eliottrobson thanks. Although I am still not convinced. We should find out what the actual number is then. |
I really still want to use the label component, but with it being |
@maimairel, if you look at the workarounds presented above you'll notice that it's extremely easy to alter for your specific use case. The work arounds for all other Bootstrap users are definitely cumbersome and anti-semantic. |
@diggy your addition to functions.php did the trick for me. WordPress has a popular feature that you add to the body tag to pull in WP classes based on the page you're on for the ability to edit those specific pages apart from other pages included in a Wordpress theme.
Translates to:
Before workaround applied to functions.php This attribute is calling in the class "tag" only on tag pages, I don't see this as a huge issue as a workaround has already been established and the "body class" is just empty class placeholders incase you want to edit a specific page class (IE: .tag, .home, .logged-in, etc). But because WP generates what itself sees as an empty "tag" class, when BS4 is added, this becomes a naming-convention problem as it wants to apply the BS4 ".tag" class to the entire body. None of these WP CSS classes are actually applying any rules to your page, they are there as utilities only incase you might want to. Thanks for addressing this. I'm happy with a functions workaround, I was going to program some JS to do the same thing but this works! Although, if a naming convention change is in consideration, might I offer up ".mark" or ".marker" or even ".bs-tag"? I can see .tag potentially running into similar issues with lesser used CMS's such as Drupal and Joomla, since the ability to "tag" posts/pages is kind of what made them what they are today. |
Improved snippet, removing all offending classes from WP's body and post class arrays: add_filter( 'body_class', '_twbs_bootstrap_20542', 10, 1 );
add_filter( 'post_class', '_twbs_bootstrap_20542', 10, 1 );
function _twbs_bootstrap_20542( $classes )
{
return array_diff( $classes, array(
'tag',
'tag-pill',
'tag-default',
'tag-info',
'tag-warning',
'tag-danger',
'tag-success',
'tag-primary',
) );
} |
|
We'll be getting the class name changed in Alpha 6. |
@mdo if we are going to change the class name. As referenced in #19094, there is a conflict with
|
Fix coming at you in #21020. |
I see that It's a roughly-equal amount of work to prefix either the generated class or the Bootstrap CSS, so this is mostly just a heads-up that there are other conflicts than WordPress. Is it fairly likely that |
@mdo why not just use |
Personally, I like the |
When using the new .tag class in WordPress, it is conflicting with the post tag class names applied to a lot of WordPress elements like the body class, hentry etc.
It just won't work on WordPress.
Any work around on this?
Thanks!
The text was updated successfully, but these errors were encountered: