New Subscribe Link CSS Class
-
Since updating the plugin, I noticed that the “Subscribe” link on forum topic pages now has an additional CSS class of “.bsp_button1” and this has its own styling which is overriding my theme settings for links.
Do I need to manually override this with another CSS rule or is there a way to change this in the admin panel of the plugin (I looked but couldn’t find this).
-
I’ve also noticed that even though I do not have the “Subscribe Button” activated, a blue subscribe button (rather than the text link I had there before and prefer to a button) loads on forum index pages.
@reedy – I’ve gone as far back as version 4.9.11 and can verify the “Subscribe” link showing on topics even when the subscription button is not activated at least since then. It is working as expected for actual forum subscriptions, but always displayed on topics whether activated or not.
As for the new class “bsp_button1” being added, I can’t say for sure when that change was made (probably version 5.2.x), but that has been that way for quite a while now.
There are CSS code snippets that can help you override the styles applied to that class, but you would have to target the specific “Subscribe” links you wanted since the “bsp_button1” class affects MANY buttons such as “Mark All Topics Read” and “Create New Topic”.
Before going that route, I think myself and @robin-w should discuss the best option for handling this and make some code changes accordingly. I personally think the bsp_button1 class SHOULD be applied for forum subscriptions (would match the other forum-level buttons), but should NOT be applied for topics (would match the favorites link).
Until this is resolved, here’s a few things you can do to hold you over:
1.) If you want to disable subscriptions, you can simply hide the subscription link until we apply code to actually disable it. You can add this CSS code snippet to the “Custom CSS” tab ( /wp-admin/options-general.php?page=bbp-style-pack&tab=css) to hide the button altogether.
a.subscription-toggle { display: none; }
2.) To mimic the default styling of your theme, you could add this CSS code snippet to the “Custom CSS” tab. NOTE: It may require small changes to match your theme ( values may need to be “initial”, “inherit”, “revert”, or “unset” depending on the CSS hierarchy of your theme):
a.subscription-toggle.bsp_button1 { font-size: revert !important; font-family: revert !important; color: unset !important; background: revert !important; background-image: revert !important; -webkit-border-radius: revert !important; -moz-border-radius: revert !important; border-radius: revert !important; padding: revert !important; text-decoration: revert !important; border: revert !important; cursor: revert !important; line-height: revert !important; } a.subscription-toggle.bsp_button1:hover{ background: revert !important; background-image: revert !important; text-decoration: inherit !important; }
The 2 code snippets above are TEMPORARY until we can dig into this and publish a new version to address this permanently.
-
This reply was modified 1 year, 9 months ago by
codejp3. Reason: fixed minor typos
I appreciate you getting back to me.
The subscribe link itself isn’t a problem —?I want it there. I just don’t want it as a button and I don’t want the plugin to use a custom style for the subscribe link.
If it helps, I upgraded from version 5.2.5 to 5.5.8 when these issues appeared:
- Subscribe link on forum index pages changing from a text link using my theme styling into a blue button with white text, even though I did not enable subscribe buttons.
- CSS overriding the subscribe/unsubscribe link theme styling in the opening post of a forum topic (the link that appears next to the “Favorite” link) so it is a different font size and color.
If it helps, I am running the older version of bbpress (2.5 branch) since I haven’t had time to update and modify the styling —?so perhaps that might also be causing an issue.
Upgrading bbPress itself is recommended. I think you would be fine upgrading bbPress core without any serious impact on your styling, but do a site backup first, and just revert it back to that if you do encounter issues.
As for the first code snippet to hide the subscribe link, I’d advise to not use that, and just use the built-in bbPress settings (/wp-admin/options-general.php?page=bbpress) to disable subscriptions (if you wanted to go that route, which it sounds like you don’t).
The second code snippet is what will hold you over until we come up with the best solution for this.
The only other solution I can offer for now is to go back to using Style Pack version 5.2.5 until we address this and issue a new release that will take care of it for you.
@robin-w – I take the blame for this one. I’m almost positive I added that class around 5.2.5ish, and I can see how/why that may not be desired by many users.
Since it’s my fault, I’ll take care of it, but I think it actually makes sense to add new settings to enhance the “Favorites” and “Subscribe” links for topic display. Here’s what I propose:
1.) Add a new checkbox option for “Favorites” and “Subscribe” links to add the “.bsp_button1” CSS class (disabled by default). That way, those who do want those links to be buttons that match the rest of the buttons can do so.
2.) Add a new text field option for “Favorites” and “Subscribe” links to allow a custom CSS class to be added (empty by default). That way, those who added a custom class to the other buttons can add the same class the these 2 links if they want them to match.
Just to be clear: This would have NO EFFECT on the existing forum index buttons (mark as read, subscribe, favorite, new topic). It would only be an enhancement to the per-topic favorites/subscribe links.
Let me know your input and I’ll get started on this. I’m still getting situated back home, but I’m getting there ??
go for it!
This would be great! I eagerly await the update!
@reedy – I’ve been sidetracked with other work and life events, but I am starting on this today and will have a release with these changes done in the near future. I’ll tag you in this topic when that’s done.
@reedy – Version 5.6.0 has just been released which includes these new features.
Head over to the “Topic/Reply Display” tab (wp-admin/options-general.php?page=bbp-style-pack&tab=topic_display) for the new settings. They have been labeled in the top image. #26 is the specific one you requested, but #27 may be of interest as well.
You don’t HAVE TO set any value since the default setting is to NOT apply any styling to the topic Favorite/Subscribe buttons (default bbPress links, which is what you requested), but you can style them as buttons, or add a custom class if you choose.
#27 will allow you to change the ” | ” separator between those links if you want something different.
Thank you for requesting this! It’s a good one!
Marking as resolved, but feel free to post here if you experience any issues.
This is great — thank you!
One issue I am seeing is that when I use this snippet in my theme:
<?php bbp_forum_subscription_link(); ?>
A CSS class is now getting added to the link —?it looks like “.new-post-button” has been added, and this is turning the link into a button.
Can this be fixed, too? Or can you point me to where I can remove that class in my theme files.
Thanks.
@reedy – I just got off work, but I will look into this shortly and see if I can replicate what you’re saying. As far as I’m aware, Style Pack does not add the “.new-post-button” class to the forum subscribe link. But if bbPress is adding it, I should be able to remove/replace it, either automatically or with an option. I need to see it happening, and follow the code trail to the source doing that.
A few questions though.
1.) Why/where are you using the bbp_forum_subscription_link() function? I’m assuming it’s because you DON’T want to use the forum subscribe link/button settings from Style Pack’s “Forum Buttons” tab.
2.) In case I can’t replicate it, do you have a link you can share with me showing it in action? You can email it to me privately at [email protected] if you don’t want to post it publicly here.
I wanted to change where the subscribe link appears, hence my use of the function. I’ll drop you an email ??
I got a chance to look into both Style Pack and bbPress.
Neither bbPress, or Style Pack add a “.new-post-button” class at any time, anywhere, to anything.
The only exception would be if you have “new-post-button” set as the custom class with the Style Pack “Forum Buttons” tab ( /wp-admin/options-general.php?page=bbp-style-pack&tab=buttons ):
You could also verify that by looking at the “Plugin Information” tab ( /wp-admin/options-general.php?page=bbp-style-pack&tab=plugin_info ) and at the bottom, looking specifically for the “Forum Buttons” value saved in the DB:
————————————————–
I also got a chance to look at your site. I do indeed see the “.new-post-button” class being added to the “Subscribe” link.
I can’t tell you exactly which file that CSS class is styled in because you have AutOptimize enabled, which is caching/concatenating CSS styles, but I can see the styling code is as follows:
a.subscription-toggle.new-post-button { font-size: inherit; padding: inherit; background-color: inherit !important; color: #eb805b; text-transform: inherit; } .new-post-button { font-size: 20px; border-radius: 4px; margin: 20px 0; text-transform: uppercase; color: #fff; background-color: #40a474; font-family: Segoe UI,Helvetica Neue,Helvetica,sans-serif; transition: color .1s ease-in-out,background-color .1s ease-in-out; border: 1px solid transparent; cursor: pointer; padding: 10px 20px; }
Considering Style Pack doesn’t include built-in settings for some of those things for Forum Buttons (like text-transform, transition, cursor, and so on ), my guess is that another plugin, or possibly even your theme is setup to automatically append the “new-post-button” class to “<a href>” tags/links.
Temporarily disabling AutOptimize and inspecting the CSS source files responsible for that code may help identify the culprit and resolve the issue. This is the preferred route, and at least you’ll know what’s doing it for future site development/enhancement purposes.
If you strike-out with that, worst-case, here’s a code snippet you can add to your theme’s functions.php file (or with the Code Snippets plugin). It will find that “new-post-button” class and strip it from the forum subscribe link:
/* * code snippet to strip the auto-added "new-post-button" class from custom forum subscribe link * https://www.ads-software.com/support/topic/new-subscribe-link-css-class/ */ function reedy_remove_new_post_button_class( $html ) { // strip "new-post-button" class from forum subscribe link html $pattern = '/class="subscription-toggle new-post-button"/' ; $replace = 'class="subscription-toggle"'; $html = preg_replace( $pattern, $replace, $html ); return $html; } add_filter ('bbp_get_forum_subscribe_link' , 'reedy_remove_new_post_button_class', 10 , 1 );
I appreciate you looking into this further!
Yes, I do have the class “new-post-button” set as the custom class with the Style Pack “Forum Buttons” tab —?and that’s because I want buttons to be styled that way (the css styling you found is mine, too).
However, I do not want the subscribe link to be styled as a button. And Style Pack has only seemed to want to start styling subscribe links as buttons since I upgraded from version 5.2.5!
Does this make things any clearer?
@reedy – Yes, that makes perfect sense.
Here’s the overall problem I’m facing. There’s no good/straightforward way to distinguish whether the bbp_forum_subscription_link() function is being used in the default way within the forum template, or being used within a custom fancy sentence with icons like you’re using it. Style Pack just hooks to the link itself to adjust classes. There is NOTHING within the bbPress hooks to differentiate what the surrounding content is before/after that subscribe link hook. Your case is a rare, non-traditional case, and the vast majority of bbPress users will never experience what you are.
With that said, I do like the way you’re utilizing the subscribe link, and want you to be happy with it. Here’s an updated code snippet that will let you accomplish that. Add it to your theme’s functions.php file (or with the Code Snippets plugin):
/* * code snippet to strip the auto-added "new-post-button" class from custom forum subscribe link * https://www.ads-software.com/support/topic/new-subscribe-link-css-class/ */ function reedy_remove_new_post_button_class( $html ) { // strip "new-post-button" class from forum subscribe link html $pattern = '/class="subscription-toggle new-post-button"/' ; $replace = 'class="subscription-toggle"'; $html = preg_replace( $pattern, $replace, $html ); return $html; } add_filter ('bbp_get_user_subscribe_link' , 'reedy_remove_new_post_button_class', 11, 1 );
This is nearly identical to the last code snippet I posted, but with 2 changes:
1.) Hooking into “bbp_get_user_subscribe_link” instead of “bbp_get_forum_subscribe_link”.
2.) Priority “11” instead of “10” so that it gets executed AFTER Style Pack has done its’ thing with the Forum Button style class settings.
I’ve tested this and it is working. All other forum buttons will have the “new-post-button” class. The subscribe button will have only the “subscription-toggle” class, but NOT the “new-post-button” class.
That should set you straight ??
-
This reply was modified 1 year, 9 months ago by
- The topic ‘New Subscribe Link CSS Class’ is closed to new replies.