Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)

  • Ypswytch
    Participant

    @ypswytch

    I also noticed that the left curly quote was not correct in the activity stream, and curly quotes can cause other problems. To remove them I added the following to my functions.php in my child theme:

    remove_filter('bp_get_activity_content_body', 'wptexturize');

    Ypswytch
    Participant

    @ypswytch

    One thing I noticed from my example above is that it only works for new posts to the activity stream. My goal was to weed out image tags because I don’t want pictures to display. However, if a prior entry has an image tag it still seems to get through and the picture is displayed. My other solution didn’t solve that problem either.
    I’d be okay with pictures displaying if I could somehow create thumbnails that would link to the image. Otherwise images cause the page to load slowly, and for some odd reason some people feel the need to post pictures of every meal they eat…disgusting!


    Ypswytch
    Participant

    @ypswytch

    I’m a newbie to php and the wordpress/buddypress way of doing things, and I seem to learn best by seeing examples, so I’m posting my “action” for overriding the allowed tags. I was able to get one other approach to work where I removed filters on bp_activity_filter_kses and added my own, but this version also works and seems cleaner. If anyone knows of a better approach, please let me know. I’m all about optimizing my code.

    #*********************************************************
    #  set allowable html tags
    #*********************************************************
    function my_allowed_tags() {
    	global $allowedtags;
    	$allowedtags = array(
    		'a' => array(
    			'href' => array (),
    			'title' => array ()),
    		'abbr' => array(
    			'title' => array ()),
    		'acronym' => array(
    			'title' => array ()),
    		'b' => array(),
    		'blockquote' => array(
    			'cite' => array ()),
    		'cite' => array (),
    		'code' => array(),
    		'pre' => array(),
    		'del' => array(
    			'datetime' => array ()),
    		'em' => array (),
    		'i' => array (),
    		'q' => array(
    		'cite' => array ()),
    		'strike' => array(),
    		'strong' => array(),
    		'sub' => array(),
    		'sup' => array()
    	);
    
    //  adding any additional tags this way because it's easier to read
    	$allowedtags['h1']   	       = array();
    	$allowedtags['h2']   	       = array();
    	$allowedtags['h3']   	       = array();
    	$allowedtags['h4']   	       = array();
    	$allowedtags['h5']   	       = array();
    	$allowedtags['h6']   	       = array();
    	$allowedtags['u']   	       = array();
    	$allowedtags['center']        = array();
    	$allowedtags['big']   	       = array();
    	$allowedtags['small'] 	       = array();
    	$allowedtags['tt']   	       = array();
    	$allowedtags['br'] 	       = array();
    	$allowedtags['p'] 	       = array();
    	$allowedtags['dl']   	       = array();
    	$allowedtags['dt']   	       = array();
    	$allowedtags['dd']   	       = array();
    	$allowedtags['ul']			   = array();
    	$allowedtags['ul']['style']   = array();
    	$allowedtags['li']			   = array();
    	$allowedtags['li']['style']   = array();
    	$allowedtags['ol']			   = array();
    	$allowedtags['ol']['style']   = array();
    	$allowedtags['font']		   = array();
    	$allowedtags['font']['size']  = array();
    	$allowedtags['font']['color'] = array();
    	$allowedtags['font']['face']  = array();
    
    }
    add_action( 'bp_activity_allowed_tags', 'my_allowed_tags', 10 );
    

    Ypswytch
    Participant

    @ypswytch

    I’m looking forward to the 1.8 fix for this as I’ve been dealing with this issue for several years now.
    I just upgraded to Buddypress 1.7 from 1.2 and I’m trying to set up my site so that I’m customizing it the correct way instead of editing theme files and core files. Fear of losing my customizations is what has kept me from upgrading.
    My users complained that they wanted to see the actual date and time in the Activity stream, and they also wanted to know the time zone. It would be nice if we had an easy way to show the actual date and time instead of the “time since”.
    I am able to get around this problem by doing the following (which may or may not be the best way to approach it):
    1. Under Settings General I have my time set for New York (eastern time).
    2. I created a functions.php file and put it in my customized buddypress default theme.
    3. In the functions.php file I added the following function and filter:

    function format_activity_date() {
      $activityDate=bp_get_activity_date_recorded();
      // Get GMT offset from root blog
      $root_blog_offset = get_blog_option( BP_ROOT_BLOG, 'gmt_offset' );
      // Calculate offset time
      $time_offset = $time + ( $root_blog_offset * 3600 );
      // Format the time using the offset and return it; date-i18n retrieves the date in localized format
      return '' . date_i18n("l, M j, Y, g:ia T", strtotime($activityDate) + $time_offset) . '';
    }
    add_filter('bp_activity_time_since', 'format_activity_date');
    

    I wish I could say I completely understand why this works. I hope it’s still showing the correct time when we go off daylight savings time in the fall.

Viewing 4 replies - 1 through 4 (of 4 total)
Skip to toolbar