Search Results for 'code'
-
AuthorSearch Results
-
December 18, 2014 at 10:34 am #155764
In reply to: Remove Separator
Robin W
Moderatornever write code whilst your other half is waiting to go out !
ok, this works
function remove_sep ($args) { $args['before'] = '' ; return $args ; } add_filter ('bbp_before_get_forum_subscribe_link_parse_args', 'remove_sep') ;On your larger point, there are a lot of resources, but it takes a lot of practice to get good at PHP, and to understand how any plugin works which is the size that bbpress is.
Generally it is quicker to ask a question on here, than spend hours delving into bbpress. But if you start wanting to really tailor it, then the step by step guides and other documentation will try and get you into how to go about finding code within bbpress.
I know nothing of php 18months ago (I’m just a humble bbpress user – I didn’t write any of it!), and now have several plugins for bbpress to add functionality, so it is quire do-able.
I’ve tried to get much of my learning into the documentation, so have a look round
December 18, 2014 at 10:28 am #155762In reply to: Sub forums in bbpress 2.3 and buddypress 1.7
derricksmith01
ParticipantHello,
I really needed this feature so I dug into the code and came up with a solution that doesn’t modify core files. The solution hooks the query pre_get_posts and uses the buddypress ‘plugins’ template file to catch and display the group sub forums.
This probably isn’t the most efficient solution but it seems to work in my environment. I’ll post back if I notice any issues as more subforums are created.
Here are the functions – place in your theme’s functions.php. I also included my plugins.php file also.
// functions.php
//Filters bbpress forum permalink if on a group forum page. Keeps users from being redirected to sitewide forums function buddyboss_forum_permalink($link){ global $wpdb, $bp; if (strpos($link, "/forums/forum/")){ $forum = substr($link, strpos($link, "/forum/") + 7); $forums = explode("/",$forum); $args=array( 'post_type' => 'forum', 'name' => $forums[0], ); $root_forum = get_posts( $args ); $group_id = $wpdb->get_var( " SELECT group_id FROM wp_bp_groups_groupmeta WHERE meta_key = 'forum_id' AND meta_value = '". serialize(array($root_forum[0]->ID)) ."'" ); if (isset($group_id)){ $group = groups_get_group( array( 'group_id' => $group_id ) ); unset($forums[0]); $forums = implode("/",$forums); $permalink = bp_get_group_forum_permalink($group)."/".$forums; } else { $permalink = $link; } } return $permalink; } add_filter('bbp_get_forum_permalink','buddyboss_forum_permalink',10,1); //Filters bbpress topic permalink if on a group forum page. Keeps users from being redirected to sitewide forums function buddyboss_topic_permalink($link){ global $wpdb, $bp; if (strpos($link, "/forums/topic/")){ $start_topic = substr($link, strpos($link, "/topic/") + 7); $args=array( 'post_type' => 'topic', 'name' => $start_topic, ); $topic = get_posts( $args ); $topic_forums = get_post_ancestors( $topic[0]->ID ); $root_forum_id = end($topic_forums); $group_id = $wpdb->get_var( " SELECT group_id FROM wp_bp_groups_groupmeta WHERE meta_key = 'forum_id' AND meta_value = '". serialize(array($root_forum_id)) ."'" ); if (isset($group_id)){ $group = groups_get_group( array( 'group_id' => $group_id ) ); array_pop($topic_forums); //Pop group's root forum foreach ($topic_forums as $forum){ $post = get_post($forum); $slug = $post->post_name; $forum_parts .= $slug."/"; } $permalink = bp_get_group_forum_permalink($group)."/".$forum_parts."topic/".$start_topic; } else { $permalink = $link; } } return $permalink; } add_filter('bbp_get_topic_permalink','buddyboss_topic_permalink',10,1); //Filters bbpress reply permalink if on a group forum page. Keeps users from being redirected to sitewide forums function buddyboss_reply_permalink($link){ if (strpos($link, "/forums/reply/")){ $reply = str_replace(site_url()."/forums/reply/","reply/",$link); $forum = str_replace("/forums/forum/".$bp->groups->current_group->slug, "/groups/".$bp->groups->current_group->slug ."/forum", bbp_get_topic_permalink(bbp_get_topic_id())); $permalink = $forum.$reply; } return $link; } add_filter('bbp_get_reply_permalink','buddyboss_reply_permalink',10,1); function buddyboss_bbpress_pre_get_posts($query){ global $bp; if( $query->is_main_query()) { if (bp_current_action() == 'forum'){ if (!empty($bp->action_variables) && !in_array("topic", $bp->action_variables) && !in_array("reply", $bp->action_variables)){ //Sub Forum $forum = end($bp->action_variables); $args = array( 'post_type' => 'forum', 'name' => $forum ); $forums = get_posts( $args ); $parent = $query->get('p'); $query->set('p',''); $query->set('post_parent',$parent); bbpress()->current_forum_id = $forums[0]->ID; bbp_set_query_name( 'bbp_single_forum' ); return $query; } if (empty($bp->action_variables) ) { //Root Group Forum bbp_set_query_name( 'bbp_single_forum' ); return $query; } if (in_array("topic", $bp->action_variables) && !in_array("reply", $bp->action_variables)){ //Topic $topic = end($bp->action_variables); if ($topic == 'edit'){ $edit_key == array_search($topic,$bp->action_variables); $topic = $bp->action_variables[$edit_key-1]; } $args = array( 'post_type' => 'topic', 'name' => $topic ); $topics = get_posts( $args ); $query->set('p',''); $query->set('post_parent',$topics[0]->post_parent); bbpress()->current_forum_id = $topics[0]->post_parent; bbpress()->current_topic_id = $topics[0]->ID; bbp_set_query_name( 'bbp_single_topic' ); if (end($bp->action_variables) == 'edit'){ bbpress()->current_view_id = 'edit'; } return $query; } if (in_array("topic", $bp->action_variables) && in_array("reply", $bp->action_variables)){ //Reply $reply = array_search('reply', $bp->action_variables); $reply_id = $bp->action_variables[$reply+1]; $reply_post = get_post( $reply_id ); $query->set('p',$reply_id); bbpress()->current_topic_id = $reply_post->post_parent; bbpress()->current_reply_id = $reply_id; bbp_set_query_name( 'bbp_single_reply' ); if (end($bp->action_variables) == 'edit'){ bbpress()->current_view_id = 'edit'; } return $query; } } } return $query; } add_action('pre_get_posts','buddyboss_bbpress_pre_get_posts',10, 1); function buddyboss_bbpress_is_edit($retval){ global $bp; if (end($bp->action_variables) == 'edit') $retval = true; return $retval; } add_filter('bbp_is_topic_edit','buddyboss_bbpress_is_edit', 10, 1); add_filter('bbp_is_reply_edit','buddyboss_bbpress_is_edit', 10, 1); function buddyboss_bbpress_form_reply_content($retval){ global $bp; if (end($bp->action_variables) == 'edit' && in_array('topic', $bp->action_variables) && in_array('reply', $bp->action_variables)) { $post = get_post( bbpress()->current_reply_id ); return esc_textarea( $post->post_content ); } } add_filter('bbp_get_form_reply_content','buddyboss_bbpress_form_reply_content', 10, 1); function buddyboss_bbpress_form_topic_content($retval){ global $bp; if (end($bp->action_variables) == 'edit' && in_array('topic', $bp->action_variables) && !in_array('reply', $bp->action_variables)) { $post = get_post( bbpress()->current_topic_id ); return esc_textarea( $post->post_content ); } } add_filter('bbp_get_form_topic_content','buddyboss_bbpress_form_topic_content', 10, 1); function buddyboss_bbpress_form_title(){ global $bp; if (end($bp->action_variables) == 'edit' && in_array('topic', $bp->action_variables) && !in_array('reply', $bp->action_variables)) { $post = get_post( bbpress()->current_topic_id ); return esc_html( $post->post_title ); } } add_filter('bbp_get_form_topic_title','buddyboss_bbpress_form_title', 10, 1); //Filters bbpress admin links if on a group forum page. Keeps users from being redirected to sitewide forums function buddyboss_reply_admin_links( $links, $args ) { global $bp; if (bp_current_action() == 'forum'){ $dom = new DOMDocument; $dom->loadHTML($links); foreach ($dom->getElementsByTagName('a') as $node) { //print_r($node); if ($node->nodeValue == 'Edit'){ $forum = str_replace("/forums/forum/".$bp->groups->current_group->slug, "/groups/".$bp->groups->current_group->slug ."/forum", bbp_get_topic_permalink(bbp_get_topic_id())); $reply = str_replace(site_url()."/forums/reply/","reply/",$node->getAttribute( 'href' )); $node->setAttribute('href', $forum.$reply); } } $links = $dom->saveHTML(); } return $links; } add_filter( 'bbp_get_reply_admin_links', 'buddyboss_reply_admin_links', 10, 2 );/buddypress/groups/single/plugins.php
<?php global $bp; do_action( 'bp_before_group_plugin_template' ); if (bp_current_action() == 'forum'){ if (empty($bp->action_variables)){ //Forum $bp->groups->current_group->id; $group_forum = groups_get_groupmeta( $bp->groups->current_group->id, $meta_key = 'forum_id'); $group_forum_id = $group_forum[0]; bbpress()->current_forum_id = $group_forum_id; bbp_get_template_part('content','single-forum'); } elseif (!empty($bp->action_variables) && !in_array("topic", $bp->action_variables) && !in_array("reply", $bp->action_variables)){ bbp_get_template_part('content','single-forum'); } elseif (in_array("topic", $bp->action_variables) && !in_array("reply", $bp->action_variables)){ //Topic if (bbpress()->current_view_id === 'edit'){ echo "<div id='bbpress-forums'>"; echo "<a href='".bbp_get_topic_permalink()."'><h4><img src='".get_stylesheet_directory_uri()."/images/back_button.png' />Back to Topic</h4></a>"; bbp_get_template_part('form','topic'); echo "</div>"; } else { bbp_get_template_part('content','single-topic'); } } elseif (in_array("topic", $bp->action_variables) && in_array("reply", $bp->action_variables)){ //Reply if (bbpress()->current_view_id === 'edit'){ echo "<div id='bbpress-forums'>"; echo "<a href='".bbp_get_topic_permalink()."'><h4><img src='".get_stylesheet_directory_uri()."/images/back_button.png' /> Back to Topic</h4></a>"; bbp_get_template_part('form','reply'); echo "</div>"; } else { bbp_get_template_part('content','single-reply'); } } } else { do_action( 'bp_template_content' ); } ?> <?php do_action( 'bp_after_group_plugin_template' );December 18, 2014 at 10:16 am #155761Robkk
Moderatoryou can place this code into your child themes functions.php file
/** * Include bbPress 'topic' custom post type in WordPress' search results */ function ntwb_bbp_topic_cpt_search( $topic_search ) { $topic_search['exclude_from_search'] = false; return $topic_search; } add_filter( 'bbp_register_topic_post_type', 'ntwb_bbp_topic_cpt_search' ); /** * Include bbPress 'reply' custom post type in WordPress' search results */ function ntwb_bbp_reply_cpt_search( $reply_search ) { $reply_search['exclude_from_search'] = false; return $reply_search; } add_filter( 'bbp_register_reply_post_type', 'ntwb_bbp_reply_cpt_search' );got the code from here, i see you also commented on it to š
December 18, 2014 at 10:05 am #155760In reply to: Page Not Found Error
Robkk
Moderatorwhy didnt you use the phpbb to bbPress importer in the bbPress plugin.
December 18, 2014 at 9:54 am #155757In reply to: Remove Separator
MaxLiao
ParticipantFirst of all, thank you for the response. I really appreciate your help.
Unfortunately, that code did not work; the separator is still there. You indicated that was a possibility, so no worries.
Since this doesn’t seem like a matter of just finding a | in some code and removing it or adding a
display:none;to the CSS to remove it, is there a resource that would better help me understand how this is being accomplished? I would hate to have to ask this same question every time I want to add or remove a separator. My PHP skills exist but they are weak. Anything to help strengthen them in this regard would be fantastic.December 18, 2014 at 8:30 am #155754Robkk
Moderatorif you were here Iād give you a big kiss.
uhhhhhhhhhhhhhh , your welcome i guess?? haha
about it not being updated in over a year , the plugin is very simple it basically just outputs a shortcode at the bottom of blog posts.
and also that this functionality is going to be implemented in the future release of bbPress.
so when the update comes and says bbPress for WordPress comments in the changelog of the plguin. you can pretty much just remove the topics for posts plugin from there on and just use bbPress.
December 18, 2014 at 8:21 am #155752In reply to: resize bbpress forum
Robkk
Moderatoradd this anywhere you can add custom css and see if this works
.bbpress .container { max-width:100%; }if it doesnt try this also
.bbpress .container { max-width:100% !important; }December 18, 2014 at 8:15 am #155751Robkk
Moderatoryeah you shouldnt edit the core files.
i see there is additional quotation marks in your code maybe replacing it with this will help.
<span class="bbp-topic-started-by"><?php printf( __( 'Started by: %1$s', 'bbpress' ), bbp_get_topic_author_link( array( 'size' => '90' ) ) ); ?></span>December 18, 2014 at 7:32 am #155744In reply to: Change the color of individual role names
Robkk
Moderatorthis topic is for changing the role names background color.
like for example this site has them with a gray background
if i use the code snippet above i can have blue for participants , red for keymasters , and yellow for moderators and so on for each role just by applying a little CSS.
make a new topic and ill check out doing that in the next few days when i setup my custom cpu up all right with a local dev area and not use linux anymore.
December 18, 2014 at 7:22 am #155743Robkk
Moderator@skisma i think that was just a mockup from this website in the link below
and the author of this topic just stumbled upon it.
and since this is from 2009 it is most likely the bbpress standalone version 1.0x and such
but you could accomplish close to the same result using wp-usersonline plugin and also the inbuilt stats shortcode and just a little bit of CSS.
create a new topic about this though.
December 18, 2014 at 7:13 am #155742In reply to: Remove "This post was modified…"
Robkk
Moderatoruntick topic/reply edit logging in settings>forums to disable the logging of future posts.
and add this CSS anywhere you can add custom CSS to hide the edit logs on any existing posts.
#bbpress-forums .bbp-topic-content ul.bbp-topic-revision-log, #bbpress-forums .bbp-reply-content ul.bbp-topic-revision-log, #bbpress-forums .bbp-reply-content ul.bbp-reply-revision-log { display: none; }December 18, 2014 at 4:20 am #155730In reply to: Remove Separator
Robin W
Moderatorquick reply as I’m on my way out, so untested, but put the following in your functions file
function remove_sep ($args) { $args['before' ] = '' ; Return $args ; } add_filter ('bbp_before_get_topic_subscription_link_parse_args', 'remove_sep') ;If it doesn’t work, come back and I’ll do it properly and test it for you !
December 18, 2014 at 3:54 am #155727In reply to: I need simple breadcrumb
December 17, 2014 at 12:42 pm #155710In reply to: I need my subtopic to have line-brakes
December 17, 2014 at 12:41 pm #155709In reply to: I need simple breadcrumb
December 17, 2014 at 11:33 am #155701In reply to: My language files are overwritten by update
robertosalemi
ParticipantHi,
I try this code
add_filter( 'auto_update_translation', '__return_false' );but this code not works, today my language files are overwritten.
Why?
Thanks.
December 17, 2014 at 10:25 am #155696AlexandruIoan
ParticipantTry to use a plugin, search for ” statistics plugin or who’s online plugin ” or use this new short code : [bbp-statistics] .
You welcome!December 17, 2014 at 9:17 am #155694Lumartist
ParticipantOkay,
I did install a complete fresh wordpress with only bbpress. Then I added
function bbp_enable_visual_editor( $args = array() ) { $args['tinymce'] = true; return $args; } add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );to the functions.php of “Twenty Fourteen”. And again, the same problem as described above. I have to click row one. If I click below it nothing happens.
But – I also found out, that it is a problem of “Chrome” only. Everything is working fine in Firefox and others. Here the cursor jumps to row one if I click into the text field.
So I guess it might not be a problem of bbpress… Not sure.
Any Ideas?
——–
Btw: As soon as I add links into this answer it disappears…
December 17, 2014 at 7:39 am #155691dice2dice
ParticipantI have found some more information that may be relevant. My forums still exist, here’s one http://whichinvestmenttrust.com/forums/topic/our-top-10-tips-on-where-to-start-as-a-new-investor/
The option to select a bbPress forum is gone when I’m creating a post but even if I use a short code such as [bbp-single-forum id=8671] the forum still fails to appear in the post.
I can’t figure out what’s stopping this from working, what is blocking it?
December 17, 2014 at 6:02 am #155689Lumartist
ParticipantOkay,
I did a few tests. The Problem also appears if I enable the visual (tab) editor via functions.php, like described here: BBPress Codex, and even if I use this Plugin: bbPress Enable TinyMCE Visual Tab
This is what it looks like on the Website: directupload.net Image
And this is how it looks like in chrome dev tools: directupload.net Image
Can’t believe that I am the only one with this problem… Or am I doing somethings wrong?
December 16, 2014 at 11:16 pm #155679In reply to: How to Remove Greens Dots on Forum?
Tecca
ParticipantIt’s likely inheriting the bullets from your WordPress style.css rather than something coming from the bbPress stylesheet. So what you can do is add something like the below CSS to your bbPress stylesheet.
#bbpress-forums li { list-style-type: none; }That will likely remove bullets from forum posts as well, but it’s hard to get specific without seeing the site itself.
Hopefully that takes you in the right direction.
December 16, 2014 at 11:08 pm #155678jmodine
ParticipantI guess I should have tested that code before I posted it. This gets it in the footer but I cant seem to get the blue bullets this way (although they are there) I even tried placing the
- tag first just in case it needed that which didn’t do it. Also I cant seem to adjust the font size in the footer either. So the table boxes wont increase to fill the footer. I will play with it. See if i can’t come up with a better solution
December 16, 2014 at 3:31 pm #155661Topic: Changing Editor to full TinyMCE – Problems with textarea
in forum ThemesLumartist
ParticipantHello everyone,
I am trying to change the tinymce toolbar for the forum (reply & topic). To do so I added this code to the form-reply.php and the same (just different context) for form-topic.php:
<?php bbp_the_content( array( 'context' => 'reply', 'media_buttons' => false, 'wpautop' => true, 'quicktags' => true, 'teeny' => false, 'tinymce' => array( 'toolbar1' => 'bold,italic,underline,strikethrough,alignleft,aligncenter,alignright,bullist,numlist,blockquote,link,unlink,forecolor,backcolor,undo,redo,removeformat' ), ) ); ?>Everything is working so far, except a small detail:
I am not able to click into the textarea/editor, so that the cursor jumps into the first line. Instead I have to click the first line, which is working.
I was able to isolte the problem, which is coming from this part of the code:
'tinymce' => array( 'toolbar1' => 'bold,italic,underline,strikethrough,alignleft,aligncenter,alignright,bullist,numlist,blockquote,link,unlink,forecolor,backcolor,undo,redo,removeformat'It also appears if I just add:
'tinymce' => trueI looks like that the syntax might be wrong, but I read a lot of guides, and in all the syntax was the same.
I also recognized, that there is a change in the source code, after I add that “tinymce” bit to the array.
After the changes the appears this code:
<p><br data-mce-bogus="1"></p>—–
What I read is, that this problem occurs when tinymce is using a <textarea> – But I don’t know how to change that textarea to a div, which is recommended.
Anyone can help me on this?
Thank you for your help in advance!
December 16, 2014 at 2:08 pm #155660In reply to: Layout of the main forum is scrambled when I go back
Robin W
Moderatorok, so it sounds like a theme issue, so I googled ‘wordpress theme pinboard bbpress’ and got this
https://wordpress.org/support/topic/bbpress-forum-homepage-displaying-oddly?replies=8
the advice is closed to perfect as this looks very strongly like your problem. The only issue might be that the page.php file has been changed in a later version and the lines might be slightly different.
Read this first for background
so try the following
1. copy page.php and rename it bbpress.php
2, edit the bbpress.php file
line 12:
<?php post_class(); ?>
to
<?php $classes=get_post_class(); echo str_replace(“twocol”, “onecol”, $classes); ?>
4. modify LOCAL forums.php line 18:
<?php the_content(); ?>
to
$content = get_the_content(); echo str_replace(“twocol”, “onecol”, $content); ?>
Save this file and reload it to your themeAs the link says, you should really put it into a child theme
but either way keep a copy of it.
Come back if this isn’t clear
December 16, 2014 at 5:50 am #155630In reply to: Admin toolbar: disable bbpress section
robertosalemi
ParticipantResolved.
function admin_bar_remove_this(){ global $wp_admin_bar; $wp_admin_bar->remove_node('my-account-buddypress'); } add_action('wp_before_admin_bar_render','admin_bar_remove_this');I hope this code is useful for someone.
-
AuthorSearch Results