New Plugin: Activity Stream #Hashtags
Same fundamentals as the atmention auto-link – this will catch a #hashtags and convert them into a link. The link will load the same activity-loop index template but modifies the querystring to include the search_term args. (so other activity ajax filtering works in conjunction )
Warning – links are converted prior to database saving – so if you wanted to disable the plugin the links will live on. (and probably to a 404). Sorry – this was the easy and best way to utilize the search_terms and built-in has_activities loop – since the sql within the ::get uses %%term%% – the ending delimiter is the closing a href tag. (exactly how mentions work in the activity-loop). Think I wrote 3 lines of code and just reused the rest – very simple.
You can include blog excerpts for posts and comments which are saved to the activity stream but you’ll need to add the following filters (functions or bp-custom will do)
add_filter( ‘bp_blogs_activity_new_post_content’, ‘bp_activity_hashtags_filter’ );
add_filter( ‘bp_blogs_activity_new_comment_content’, ‘bp_activity_hashtags_filter’ );
You may also change up the slug, just define BP_ACTIVITY_HASHTAGS_SLUG (default is: tag – so mydomain/bp-activity-slug/hashtags-slug/hashtag (remember the above statement about pre_ db content so it may break older links)
This the pattern that hits
/[#]([_0-9a-zA-Z-]+)/ (then double checks again for (^|s|b)#myactualhashtag )
Very very cool!
Just testing it on your demo site, when you’re on a hashtag page, the dropdown search filter will disregard the tag you’re on. I’d try to either append the search query or, my preference, hide it!
Re: saving links to DB – shouldn’t matter because if you deactivate the plugin and you click on a hashtag link, it should redirect to the BP root domain on a failed link anyway!
Also here’s a little code snippet to add a header to the page:
http://pastebin.com/5p44Pmn8 (updated, found a better action)
hmm, dang it should be appended as i hook on the querystring filter.
Ahhhhhh…. it does work but only if you filter first then select a hashtag. But clicking the hashtag first then selecting a filter does not.
Think I can trick this by setting the bp-activity-search-terms ajax cookie
@r-a-y – mind testing that filter sequence again on my demo site? think i fixed it.
@nuprn1 – Works! Just need an error message when there are no matches.
@nuprn1 you are killing it with the plugins! i have installed this and from my first rummaging I like it….I’m missing the #hash tag link from the blog comments though. @ mentions in when done in blogs’ comments link to the profile, it looked like that’s not so with #hash with linking back to all #hash from the comments.
will that be something that will be added in future versions you think?
did you add those two filters above? (or send me a link so i can understand a little better to what you’re referring too)
i have one other conflict with activity stream notifier but i’ll work on that a bit later.
yes I added those 2 lines to my bp-custom. when a hastag is made from a blog comment on main site and subsites it doesn’t get linked to anything just text.
it works in the in the activity.
That’s to be expected. The two filters mentioned by Rich only apply to the activity stream.
You could potentially add support to blog posts and comments, by adding the following to bp-custom.php:
add_filter( 'content_save_pre , 'bp_activity_hashtags_filter' );
add_filter( 'pre_comment_content ', 'bp_activity_hashtags_filter' );
This would take effect for new blog posts and comments, not previous ones.
Untested, but give it a shot!
Ah ok – those filters (and others which this plugin hooks into) only touches the content placed into the activity stream db table.
I don’t know the filters for the blog posts and comments within WP off hand – but as long as those filters just pass in the content – i don’t see why this would not work. (you could either filter it pre db or on the get – the_content and comment_text ?)
*edit – thanks ray!
thanks r-a-y & rich! , those new filters seem to be working on all network sites except the main site.
Just to confirm, you made a new blog post from the main site?
ah. no i didn’t make a new blog post, in fact I’ve not even tested hash from inside a post, only comments.
*edit my fault, ray i didn’t read correctly your post where you said, it will not take effect on old post. we’re all good! it all works on new posts and new comments on new posts. ( it does work on old post in P2 though! hehe)
You know what?
Try replacing the two filters I mentioned above with this:
add_filter( 'get_comment_text' , 'bp_activity_hashtags_filter' );
add_filter( 'the_content', 'bp_activity_hashtags_filter' );
(Edit: Brainfart! – re-update the filters again!)
This will probably work on older blog posts and comments as well.
I now understand why Rich saves the activity stream hashtag links to the DB, but this isn’t needed for real blog posts and comments.
Try that and report back.
yeah i would go with the get db reads instead of the writes. if that works, i’ll add it to the readme
ok ray those last 2 filters, work inside comments in old and new posts…but they do not work inside post
…doesn’t work at all in p2 theme.
Yeah, I know! I made a typo in the filters! Please copy and paste the filters above and try them again!
P2 might have their own filters on the post content. If it doesn’t work in P2, report back.
there was a typo the first time around and tthere’s still a typo in there, missing ‘get_comment_text’,
Thanks for that other typo!
The first change was to the second filter. Double check that one.
still same, work inside comments in old and new posts…but it doesn’t take inside post
…still no luck at all on posts or comments for P2
@nahummadrid i noticed p2 has a different filter for comments but the same for posts. (there is nothing wrong with the first set of filters you tried if that works – it will just save the links into the db).
i’ll look into this a bit more over the weekend.
just noticed this, after my test of #hashtag within a page i lost my homepage/blog reading settings and now the page that i put the hashtag in is set has my home, but it reads Page Not Found. After deleting it, it remains as the home page.
The hashtag (/activity/tag/whatevernameofthetag) loads up the activity/index template and the activity-loop. If you stay within that context it will keep the filter of the hashtag intact. So even clicking on all members, my friends, my groups, mentions tabs while under the url (/activity/tag/whatevernameofthetag) – will continue to filter the results to the hashtag. You’ll need to go back to the main activity screen to reset it (/activity/) Maybe I need to add in a breadcrumb (or some other method to make that a little more clear)
I noticed in your activity on the demo site that you have a # hashtag before every post
# · 1 day, 18 hours ago · nuprn1 posted on the forum topic Test code feature in forums in the group Test Group:
I can not seem to find how to order this and change my “view post” to the actual hash tag for the post.
Mine is setup like
username posted an update in the group Radical Skydiving: 1 day, 17 hours ago · View · Delete · Edit
is there a specific file I can update to change the order of this and the css classes each of the meta uses?
- The topic ‘New Plugin: Activity Stream #Hashtags’ is closed to new replies.