Winner of the Best WordPress Business Website - WP Honors 2011
Since 2004
 

Forums

 

Manuals

 

Videos

 

Live Support

 

WPMU.org

HTML Code filtering through on Recent Site Wide Posts for Buddypress

Elite

How do I stop the html code coming through on this widget?

Here is my site: http://tinyurl.com/m5cjkl

You can see that the entire video from my new post is in the widget.

Thanks,

George

Everyday at WPMU DEV we help hundreds of WP Users. Become a member today to:

  • Download 250+ Premium Plugins and Themes
  • Get unlimited support from WordPress Experts
  • Get help with your WordPress or BuddyPress projects

Help & Support from WPMU DEV members and staff

Staff

How annoying :)

I know what you need to do - well, need to ha feature plugin.

Which will most likely be a core BP hack?

Anybody, ahem, want to help out with what that hack might be?

Elite

I'm digging up a super old post here.

I had this error fixed when I was using Thesis and had some code added to the custom_functions file which fixed it.

I have changed over to bp-corporate (although thats probably not the problem), but just the last few days it's happening again. And just the last few days, a week or 2 ago it wasn't happening.

It's ok for it to happen with the site wide activity, but not in the recent posts as videos overlaps the entire widget.

How do I stop the html filtering through the recent site wide post widget.

This might not be visible if you click on it as someone might have submit a new post, but here is my site: http://tinyurl.com/m5cjkl

Thanks,

George

Get personal, comprehensive and timely support and assistance
from WordPress Experts

Erstwhile founder

Hiya,

Open up the recent global posts widget and look at lines 170 and 174. You'll see sections of code similar to this:

strip_tags( $post['post_content'] )

Replace those bits with this:

$post['post_content']

Basically you're removing strip_tags().

Thanks,
Andrew

Staff

you can also do a hack on the core file
plugins/buddypress/bp-blogs/bp-blogs-widgets.php - line 45 where this code
appeared

'<?php echo bp_create_excerpt($post->post_content) ?>'

changed it to

'<?php
$post_output = $post->post_content;
$post_output = strip_tags($post_output);
$post_output = preg_replace('|\[(.+?)\](.+?\[/\\1\])?|s', '', $post_output);
echo bp_create_excerpt($post_output);
?>'

that should filtered the code.

edits: nah..this is for the bp recent site wide post Widget...
bp recent site wide activity widget should be auto filtering the video code or the js code..what version of bp you using?

Elite

Thanks!

I'm using bp 1.1.2.

@Richie_KS, is hacking the core files the only way to do it, or can that be dropped in mu-plugins?

I'm trying to avoid as many core hacks as possible as I always seem to miss what I've done when I upgrade.

Elite

Andrew, sorry, I cant seem to find this:

Open up the recent global posts widget and look at lines 170 and 174. You'll see sections of code similar to this:

Get personal, comprehensive and timely support and assistance
from WordPress Experts

Erstwhile founder

Hiya,

I think I was confused about the issue at hand when I posted that. I thought you were using our global posts widget but after re-reading your post just now I think you may have been referring to a BuddyPress widget. Let me know if this is the case.

Thanks,
Andrew

Elite

Hey Andrew,

Yes, it's a standard buddypress widget...

Erstwhile founder

Sorry about that then. Just ignore everything I've said!

Thanks,
Andrew

Elite

Thanks Andrew. Anything else I can try to stop this?

Get personal, comprehensive and timely support and assistance
from WordPress Experts

Staff

hi georgef

add this to your functions.php..not sure which one?..either site wide post or site wide activity

Strip html for recent sitewide post

//FILTER HTML FOR BP RECENT SITEWIDE POST WIDGET
function strip_recent_sitewide_post() {
global $post;
//start stripping the code
$post_output = $post->post_content;
$post_output = strip_tags($post_output);
$post_output = preg_replace('|\[(.+?)\](.+?\[/\\1\])?|s', '', $post_output);
//start count word and output excerpt
$post_output = substr($post_output,0,250);
$post_output = substr($post_output,0,strrpos($post_output,' '));
$post_output = $post_output . " ";
//return the output
return $post_output;
}
//apply to bp_create_excerpt without hack core
add_filter( 'bp_create_excerpt', 'strip_recent_sitewide_post' );

Strip html for site wide activity
//FILTER HTML FOR BP RECENT SITEWIDE ACTIVITY WIDGET
function strip_recent_sitewide_activity() {
global $post;
//start stripping the code
$post_output = $post->post_content;
$post_output = strip_tags($post_output);
$post_output = preg_replace('|\[(.+?)\](.+?\[/\\1\])?|s', '', $post_output);
//return the output
return $post_output;
}
//apply to bp_activity_content without hack core
add_filter( 'bp_activity_content', 'strip_recent_sitewide_activity' );

let me know if it work ok...my demo sitewide activity did not had the embed video etc like yours:)

cheers

Staff

or a simpler solution will be using css to hide it

#site-wide-stream blockquote div {
display: none;
}

i notice the content is outputing a div content..the video and image etc
do you use any plugin that add filter to the_content() across your blog?

cause i can't seem to get the same result even using the same post
from the source and my home sitewide activity automatically excerpt
the output without any extra div or script..video code etc

Get personal, comprehensive and timely support and assistance
from WordPress Experts

Elite

Hey Ritchie_KS,

Thanks, now we are getting somewhere.

I have 2 plugins: additional tags and also one called less_filter so that I can use javascript on my site.

THat could probably be the problem?

I will remove those and see. Otherwise, css sounds like a better option.

Thanks,

George

Elite

#site-wide-stream blockquote div {
display: none;
}

Thanks that seems to work for the site wide activity feed.

What will it be for the recent site wide posts?

#recent-site-wide-stream ?

Elite

I really don't get this!

Tried the code above. Didn't work.

Also removed the 2 suspecting plugins, additional tags and less filters and made no difference.

Videos and pictures keep feeding through to both widgets.

I know you guys have explored a gazillion options, but any idea what else could be doing this?

Thanks,

George

Staff

hi georgef

can you list the plugins used?..the 2 plugin you mention maybe
attached in zip here if can...

the problem maybe cause by some add filter to content entry and
when the site wide activity cache to homepage..it include the video and images

try this method if new post still have img and video feed ok.

- disable the 2 plugin you mention
- make a new post with text and img and video included in post

and see if the new site activity still cache the new post activity with img and video..

cheers

Get personal, comprehensive and timely support and assistance
from WordPress Experts

Elite

can you list the plugins used?..the 2 plugin you mention maybe
attached in zip here if can...

I have removed the less filters plugin, the only one left that (I think) can do that is the additional-tags plugin which is from here.

Should I upload all my active plugins?

- disable the 2 plugin you mention
- make a new post with text and img and video included in post

Just did a new post and bang, video is stretched all over the sidebar again.

I've added your scripts in the functions as well.

I'm lost with this.

Erstwhile founder

the only one left that (I think) can do that is the additional-tags plugin which is from here.

If you think a plugin might be the problem I'd just remove all plugins except BP temporarily to see if that fixes it. If it does then you know it's a plugin.

Thanks,
Andrew

Elite

If you think a plugin might be the problem I'd just remove all plugins except BP temporarily to see if that fixes it. If it does then you know it's a plugin.

I honestly have no clue what causes it, but that is probably the best place to start. Has anyone else experienced the same problem?

Erstwhile founder

Has anyone else experienced the same problem?

We've performed hundreds of installs via WP.MU and no one has ever reported this issue. So it's either caused by something specific to your site or people just haven't noticed it. It could be either really.

Thanks,
Andrew

Elite

I'm starting to think people just haven't noticed, or there widgets aren't aligned next to each other like mine.

I've seen a few sites that have pictures etc feed through.

Maybe I need to restructure my site or something.

Staff

hi georgef...follow this 2 step to optimize the activity content.

fix the img rule so it won't strech if only small image
open /_inc/css/base.css
search for the css line:
blockquote img {}
change width: 100%; to max-width: 100%;

fix the object rule so it won't overflow
add this line to /_inc/css/base.css

#custom .widget blockquote object, #custom .widget blockquote param, #custom .widget blockquote embed {
width: 98% !important;
height: auto;
}

cheers

Get personal, comprehensive and timely support and assistance
from WordPress Experts

Inactive

Hi,
I'm actually facing the same problems, using bp-social theme; pictures and videos are feeding through the widgets: I would prefer both recent post & activities widgets to show just text+link.

The filter to strip recent site wide post works; but not for the sitewide activities i.e. images are still being displayed.

I used the code below from buddypress site to filter the sitewide activity and it works ok now.

function get_activity_flatline( $content ) {
$striptags = array("<p>", "</p>");
$content2 = str_replace($striptags, "", $content);
$content3 = substr($content2, 0, strpos($content2, '<span class="time-since">'));
return $content3;
}
add_filter( 'bp_get_activity_content', 'get_activity_flatline' );

Elite

Thanks af3 and Richie_KS.

There is a plugin called BP Paginated Posts which allows you to remove all excerpts from the recent site wide posts.

Now I just need to fix the site wide activity, will try the options above and upate, thanks.

Hiya,

Open up the recent global posts widget and look at lines 170 and 174. You'll see sections of code similar to this:

strip_tags( $post['post_content'] )

Replace those bits with this:

$post['post_content']

Basically you're removing strip_tags().

Thanks,
Andrew

I am trying to do this for the Global Posts Feed Widget and it isn't working. If renders my site blank. Any suggestions?

This is what my code looks like after your suggestion:

if ( $options['recent-global-posts-display'] == 'title_content' ) {

echo '' . substr( $post['post_title'], 0, $options['recent-global-posts-title-characters'] ) . '';

echo '';

echo substr( $post['post_content'] ), 0, $options['recent-global-posts-content-characters'] );

} else if ( $options['recent-global-posts-display'] == 'title' ) {

echo '' . substr( $post['post_title'], 0, $options['recent-global-posts-title-characters'] ) . '';

} else if ( $options['recent-global-posts-display'] == 'content' ) {

echo substr( $post['post_content'] ), 0, $options['recent-global-posts-content-characters'] );

echo ' (' . __('More') . ')';

}

I also tried this by eliminating all of the () on the recommended lines and it still renders
What should the code exactly look like?

Erstwhile founder

Hiya,

It really isn't best to try and follow three month old instructions as a lot of the time the code has changed and line numbers are no longer the same ;)

The problem here though is that you missed something. Change this bit:

$post['post_content'] )

to this:

$post['post_content']

on both lines.

Basically you left in " )",

Thanks,
Andrew

We can help you out. Become a member today to:

  • Let our team help you out today and access to over 250+ Premium Plugins and Themes
  • Find out why people saying "it's like having your own developer"
  • WPMU DEV - The WordPress Experts