bbPress - Admin Notes
[resolved] Topic Notes - thanks & a conflict with (4 posts)

  1. sevenspark
    Posted 1 year ago #

    Hi Pippin,

    Thanks for adding the ability to reply to the main topics - that's a great feature, much appreciated!

    When upgrading, I noticed the following issue. I believe you are familiar with the Buddy-bbPress Support Topic plugin? Normally, the plugin displays a single selectbox, but with both that plugin and bbPress - Admin Notes enabled, it displays two

    Here's a screenshot: http://i.imgur.com/CBu7nRW.png

    I did some debugging and here's what I found:

    1. bbPress - Admin Notes adds the extra "Add Note" admin button by adding its own span, so you end up with two <span class="bbp-admin-links"> elements. As you noted in your code comments - "This is kind of a hacky way of doing this for now" - there doesn't seem to be a great way of handling this.

    2. The bbPress - Support Topic plugin adds its selectbox via a str_replace (even hackier)

    $new_span = str_replace( $r['before'], $r['before'] . $support_selectbox, $input );

    (bbpress-functions.php line 360 for your reference)

    What happens is that when the Support Topic plugin replaces that span.bbp-admin-links, it finds two strings that match, and therefore replaces the span twice, resulting in two selectboxes.

    At the moment, I believe this is simply dependent on which plugin loads first.

    Potential Workaround

    Of course, a real solution would allow both plugins to add their custom elements without having to filter a string. But in the meantime, there's a simple solution - if BBP Admin Notes changes its filter priority to ensure it runs after the Support Topic plugin, the issue is avoided because there is won't be two matching strings when str_replace is called.

    Basically, just changing line 122 from

    add_filter( 'bbp_get_topic_admin_links', array( $this, 'add_topic_note_link' ), 10, 2 );


    add_filter( 'bbp_get_topic_admin_links', array( $this, 'add_topic_note_link' ), 15, 2 );

    fixes the issue.

    Thought you might want to be aware of this, as a lot of users probably use these plugins in tandem and you may not even have noticed if your plugins happen to load in the reverse order.

    Thanks, Pippin! :)



  2. Thanks for the heads up! I will try and get that corrected in an update tomorrow. Pull requests welcome :) https://github.com/pippinsplugins/bbp-admin-notes

  3. The update has been pushed out.

  4. sevenspark
    Posted 1 year ago #

    Awesome, thanks, Pippin! :) Sorry I didn't get a chance to submit a pull request

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • bbPress - Admin Notes
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.