Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Simple Rating plugin for wordpress – get it working for bbpress?

@robin-w

Moderator

getting it to display is easy !

bbpress deosn’t use ‘the content’ function in its loops, so we need to hook to the bbpress content function which is bbp_get_reply_content

So you just add a second filter after line 15, this then puts the ratings in the display

{
    add_filter('the_content', 'spr_filter', 15);
	add_filter ('bbp_get_reply_content', 'spr_filter') ;
}

Then the next bit of the plugins code looks at whether we have an individual post/page or are in a loop – a list of pages/posts.

If just one (is_singular) then it will display the rating, and let you add one.
If in a loop then it simply displays, and doesn’t let you alter, or that’s what I think it’s doing

so to get it to understand that we’re in a list of replies (ie loop-single-reply) we test that we’re in bbpress

so we add a test for bbpress into the first function viz

foreach ($list as $list_)
    {
        if (is_bbpress() )
        {
            if ($options['position']=='before')
            {
                $content=spr_rating().$content;
            }
            elseif ($options['position']=='after')
            {
                $content .= spr_rating();
			
            }
            break;
        }
		if (is_singular($list_)&&$options['where_to_show'][$list_]&&$disable_rating!='1')

Ok so that does the display (at the moment for both topics and replies, but that’s easily fixed later)

What I can’t work out quite is why the amend doesn’t work. I think it is because the javascript/ajax is using spr_rate, but expects that to be part of $_post, but that’s may be failing as we are sort of in a bbpress loop at that stage, not in an individual post, so I dontl know what’s it looking for as post_id.

Anyway I’m rubbish at ajax/js etc. so am just poking code in the hope of finding a fix.

So that’s as far as I’ve got for now !!

Skip to toolbar