Forum Replies Created
-
MY PREVIOUS POST IS MISSING SO I’M REPOSTING AND HOPING THIS ISN’T JUST LAG…
OK I found a more targeted way to fix this. Short answer, I added this code
add_filter( 'bp_get_activity_content_body', 'stripslashes_deep' );
HOW I added it is kind of important, I think. I’m running a plugin called Code Snippets https://wordpress.org/plugins/code-snippets/
By creating a snippet with just the code above, it takes care of removing those backslashes from comments on activity before it is displayed on the front end. If you apply the fix with this plugin, you can also select “run on front end” in the snippet editor for efficiency/performance.
If you wanted to fix it in your child theme (I don’t know why you’d only want the fix to be theme dependent, but that’s up to you …) then I believe this code would go into your functions.php (untested):
add_action('plugins_loaded', 'jrevillini_buddypress_get_activty_content_body_stripslashes' ); function jrevillini_buddypress_get_activty_content_body_stripslashes () { add_filter( 'bp_get_activity_content_body', 'stripslashes_deep' ); }
Now I know that
stripslashes
is already applied tobp_get_activity_content_body
by buddypress itself because I found it listed in this document, line 00079: https://drive.google.com/file/d/0B2NrrKAXLm0JQ01GT1ZGQlVOMkE/view (so my code *seems* redundant)The only thing I can assume at this point is that the code built into buddypress to attach the filter is running too early for all output possibilities at priority 5. By simply adding it into a code snippet which is running as a plugin at the default priority, it seems to do the job before output on the member activity endpoint.
It should be noted that even without my fix, the same activity post will appear fine at some endpoints and not others.
The ones that I found that already worked:
* within a discussion e.g. /members/NAME/activity/73/#acomment-74
* on /member/NAME *as a reply* but *not* as an activity postConfirmed.
On my installation, this happens on comments on activity. So if I go to my activity feed, post an update, then comment on my own update, then when the page refreshes, the comment will have backslashes preceding any single quote.
I’m going to dig into this.