Search Results for 'code'
-
AuthorSearch Results
-
January 7, 2021 at 5:25 am #217344
neon67
Participantok ok – fixed a lot of syntax errors. Now the code looks like this and it works
function add_image_responsive_class($content) { global $post; $pattern ="/<img(.*?)class=\"(.*?)\"(.*?)>/i"; $replacement = '<img $1class="$2 img-responsive"$3>'; $content = preg_replace($pattern, $replacement, $content); return $content; } add_filter ('bbp_get_reply_content', 'add_image_responsive_class'); add_filter ('bbp_get_topic_content', 'add_image_responsive_class');
Summary. I got a new picture class – img-responsive. But no new link appeared. How to make it open like a rel prettyPhoto … no ideas yet ..
A feature is at stake – to allow all BBPforum pictures the last few years to open in a lightbox in full size. worth looking for a solution)
January 7, 2021 at 4:35 am #217340Robin W
Moderatormight be taking out spaces after the $ signs eg
return $ content;
should be
return $content;
January 6, 2021 at 3:15 pm #217328In reply to: Spammer still getting in?
MrFent37
ParticipantI do have that code on those other templates as well, so it works well. You know what though, I just found out that I didn’t have any custom code added to form-topic.php, so that must be how they are creating new topics. SMH. I thought that I had all of the template files customized and that they were somehow creating new posts via URL, RSS, or some other “back door” method. Thanks for your time, you can close this post.
January 6, 2021 at 3:06 pm #217327In reply to: Spammer still getting in?
Robin W
Moderatorhhmm… not sure how that would prevent the forums being shown
I’d suggest you add that code to
form-topic.php and form-reply.php
January 6, 2021 at 2:59 pm #217326In reply to: Spammer still getting in?
MrFent37
ParticipantOk for example, in the template file loop-single-reply.php, at the bottom, instead of this normal code:
<div class="bbp-reply-content"> <?php do_action( 'bbp_theme_before_reply_content' ); ?> <?php bbp_reply_content(); ?> <?php do_action( 'bbp_theme_after_reply_content' ); ?> </div><!-- .bbp-reply-content -->
I have custom code wrapped around the bbp_reply_content(); function so that the reply form will only load for my active members:
<div class="bbp-reply-content"> <?php do_action( 'bbp_theme_before_reply_content' ); ?> <?php if (((function_exists('wc_memberships_is_user_active_member')) && (wc_memberships_is_user_active_member(get_current_user_id(), 'biotic-pro-membership'))) { ?> <?php bbp_reply_content(); ?> <?php } else { echo $noaccess; } ?> <?php do_action( 'bbp_theme_after_reply_content' ); ?> </div><!-- .bbp-reply-content -->
January 6, 2021 at 2:44 pm #217325Robin W
Moderatorprobably filter on
add_filter ('bbp_get_reply_content', 'add_image_responsive_class'); add_filter ('bbp_get_topic_content', 'add_image_responsive_class');
January 6, 2021 at 2:34 pm #217324neon67
ParticipantThank you! But I’m looking for a way to apply link: data-rel=”prettyPhoto” target = “_ self” to all available bbpress images. It can be loaded in any way, it doesn’t matter.
Found the code
function add_image_responsive_class ($ content) { global $ post; $ pattern = "/ <img (. *?) class = \" (. *?) \ "(. *?)> / i"; $ replacement = '<img $ 1class = "$ 2 img-responsive" $ 3>'; $ content = preg_replace ($ pattern, $ replacement, $ content); return $ content; } add_filter ('the_content', 'add_image_responsive_class');
but for wordpress. Will it work for bbpress?
January 6, 2021 at 2:03 pm #217319In reply to: Forum statistics widget
Robin W
Moderatoryou could try this in the custom css part of your theme
#bbp_stats_widget-2 dt { padding-right: 10px; }
January 6, 2021 at 10:07 am #217311In reply to: bbp_reply_url not working for large topics
codestars
ParticipantThank you alriknijdam, this was exactly what I needed.
I improved your code a bit, for example you can use bbp_get_topics_per_page() so the amount of replies per page will always be correct. And you can use bbp_get_root_slug() to dynamically get the root URL of where your forum is located.
/** * Get reply in topic permalink. * * @param int $reply_id * @param int $topic_id * * @return string */ function custom_get_reply_in_topic_permalink( $reply_id, $topic_id ) { $position_raw = bbp_get_reply_position( $reply_id, $topic_id ); $position = str_replace( ',', '', $position_raw ); $page_raw = ceil( $position / bbp_get_topics_per_page() ); $page = $page_raw > 1 ? '/page/' . $page_raw : ''; $slug = get_post_field( 'post_name', get_post( $topic_id ) ); return bbp_get_root_slug() . '/topic/' . $slug . $page . '/#post-' . $reply_id; }
Can be used like this:
<a href="<?php echo custom_get_reply_in_topic_permalink( $reply_id, $topic_id ); ?>">
Enjoy!
January 6, 2021 at 8:16 am #217309In reply to: Avatar issues
neon67
Participanttry to css:
#bbpress-forums .widget_display_replies img.avatar, #bbpress-forums .widget_display_topics img.avatar, #bbpress-forums div.bbp-template-notice img.avatar, #bbpress-forums p.bbp-topic-meta img.avatar, #bbpress-forums ul.bbp-reply-revision-log img.avatar, #bbpress-forums ul.bbp-topic-revision-log img.avatar {display:none !important;}
January 6, 2021 at 6:00 am #217300In reply to: Moving Breadcrumbs
andyinspired
ParticipantThank you, works great, it was indeed page.php.
However, I’m trying to display the page title as well using:
<?php the_title(); ?><?php bbp_breadcrumb(); ?>
It works on all child pages but not on the homepage, I’ve also tried adding it to the index.php file but without success. I know the breadcrumbs won’t display there I just want the title there to keep it consistent with the rest of the site.
Any ideas?
January 5, 2021 at 1:39 pm #217287In reply to: Moving Breadcrumbs
Robin W
Moderatorif you want the bbpress breadcrumb in the forums, then you would need to find out which theme template astra is using to display the forum page.
You would then use this template and rename to bbpress.php and add the breadcrumb back which is what I think the first link you quoted was trying to do.
This plugin will tell you which tempate is being used
and then (presuming you are using a child theme) you would copy that template (quite often page.php) and rename it bbpress.php.
you would then add
<div class="truebreadcrumbs"><?php bbp_breadcrumb(); ?></div>
in the appropriate place in that file
January 5, 2021 at 1:14 pm #217286In reply to: Moving Breadcrumbs
andyinspired
ParticipantI’m using the Astra theme (https://wpastra.com/), I’m comfortable writing CSS and editing PHP code. Just wasn’t sure if there was a filter I could use or whether I need to edit a template?.
Thanks.
January 5, 2021 at 12:11 pm #217276In reply to: Moving Breadcrumbs
Robin W
Moderatorlooking at that suggestion, not sure what 1 & 2 are trying to do – not a section I wrote !
so to move them out of bbpress, then yes, use css and do this
div.bbp-breadcrumb { display: none; /*this will hide all breadcrumbs*/ }
put this in your theme’s custom css file.
The other part will be theme dependant – are you creating a theme or using an existing one?
January 5, 2021 at 8:33 am #217273Topic: Moving Breadcrumbs
in forum Troubleshootingandyinspired
ParticipantHi,
I’m trying to move the breadcrumbs out of the forum container and to the top of the page as explained in the codex here:
http://codex.bbpress.org/layout-and-functionality-examples-you-can-use/#7-how-can-i-remove-all-the-breadcrumbs-from-the-templates-and-set-them-at-the-top-of-the-pageHowever, if I create a bbpress.php file (or copy the one from the plugins folder) in the root of my child theme it breaks the forum completely!.
Any help appreciated!
Thanks.
January 5, 2021 at 5:20 am #217271In reply to: Oh, bother….can you spare a dime!?
Robin W
Moderatorthe easiest way is
once activated go to
dashboard>settings>bbp style pack>Topics Index Styling and tick item 16 don’t show this message
if you want to do it using FTP then
find
wp-content/plugins/bbpress/templates/default/bbpress/feedback-no-topics.phptransfer this to your pc and remove
<div class="bbp-template-notice"> <ul> <li><?php esc_html_e( 'Oh, bother! No topics were found here.', 'bbpress' ); ?></li> </ul> </div>
and save (this file must exist, but we just make it empty!)
create a directory on your theme called ‘bbpress’
ie wp-content/themes/%your-theme-name%/bbpresswhere %your-theme-name% is the name of your theme
Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
wp-content/themes/%your-theme-name%/bbpress/feedback-no-topics.phpbbPress will now use this template instead of the original
January 3, 2021 at 5:54 pm #217218In reply to: Remove underline from Topics
Robin W
Moderatormy mistake should be
main a { text-decoration: underline !important; } a.bbp-topic-permalink { text-decoration: none !important; }
January 3, 2021 at 3:15 pm #217216In reply to: Remove underline from Topics
uksentinel
Participantremoved all CSS code and replaced it with you code as above, alas this did not work, maybe an conflict with theme ?
January 3, 2021 at 2:40 pm #217214In reply to: User Statistics
Robin W
ModeratorAnyone coming new to this thread, I have added a revised version of this plugin to my site which can be downloaded from
This plugin is one which WordPress withdrew as it violated their guidelines (suspected to be listing users without login, but not certain).
You can download and use, but I offer no support or warranty that this code works !
January 3, 2021 at 2:30 pm #217213In reply to: Remove underline from Topics
Robin W
Moderatorok your code is
main a { text-decoration: underline !important; a.bbp-topic-permalink { text-decoration: none: !important; }: ; }
it should be
main a { text-decoration: underline !important; } a.bbp-topic-permalink { text-decoration: none: !important; }
January 3, 2021 at 2:21 pm #217212In reply to: Remove underline from Topics
uksentinel
Participantand new code is still in
January 3, 2021 at 1:32 pm #217210In reply to: Remove underline from Topics
uksentinel
ParticipantYes, original code is still there, I did notice when I pasted in the new CCS code, the a.bbp-topic-permalink changed to a red colour ?
January 3, 2021 at 12:55 pm #217208In reply to: Remove underline from Topics
uksentinel
ParticipantHi Robin
I placed code both above and below original CSS alas did not work, I assume because original css has priority ?
January 3, 2021 at 12:21 pm #217203In reply to: User Statistics
Robin W
Moderatorso in the statsistics plugin you are changing
$latest_user = get_users( array( 'number' => 1, 'fields' => array("user_login", "ID", "display_name"), 'orderby' => "registered", 'order' => "DESC", 'meta_key' => 'wp-approve-user', 'meta_value' => '1' ) );
to
//set up $args with core arguments needed $args = array( 'number' => 1, 'fields' => array("user_login", "ID", "display_name"), 'orderby' => "registered", 'order' => "DESC", ) ; //add additional meta data to $args if wp-approve-user is active if (class_exists ('Obenland_Wp_Approve_User')) { $args ['meta_key'] = 'wp-approve-user' ; $args ['meta_value'] = '1' ; } //then do the lookup $latest_user = get_users($args) ;
January 3, 2021 at 12:12 pm #217199In reply to: User Statistics
Robin W
Moderatorok, so final amendment needed, as if you deactivate wp-approve-user then the latest user will be forevermore the last one you approved before decativating the plugin.
If you open the wp-approve-plugin you’ll see the core file wp-appprove-user.php
open this and you’ll see a line 29 which says
class Obenland_Wp_Approve_User extends Obenland_Wp_Plugins_V4 {
so we know that the wp-approve-plugin sets up a class called ‘Obenland_Wp_Approve_User’, so we can use the existence of this class to know if wp-approve-use is active or not.
This is common to many plugins and a good way to ensure parts of code that use another plugin only fire if that plugin is active.
so now we can change the ‘get_uses’ to only add the meta_data is the class exists
//set up $args with core arguments needed $args = array( 'number' => 1, 'fields' => array("user_login", "ID", "display_name"), 'orderby' => "registered", 'order' => "DESC", ) ; //add additional meta data to $args if wp-approve-user is active if (class_exists ('Obenland_Wp_Approve_User')) { $args ['meta_key'] = 'wp-approve-user' ; $args ['meta_value'] = '1' ; } //then do the lookup $latest_user = get_users($args) ;
-
AuthorSearch Results