Skip to content

bbPress Integration

SnipShare overviewPremiumGet SnipShare →

SnipShare integrates with bbPress to make it easy to share and embed code in forum discussions.

Activation: Integration loads automatically when function_exists('bbpress') or class_exists('bbPress') is true. No manual activation needed.

Configuration: Both features are individually toggled in SnipShare → Settings → Integrations.


When enabled (bbpress_embed setting), SnipShare paste URLs in bbPress topics and replies are automatically converted to inline code previews.

SnipShare hooks into bbp_get_reply_content and bbp_get_topic_content to replace bare paste URLs with embedded code viewers:

add_filter( 'bbp_get_reply_content', array( 'SnipShare_Helpers', 'embed_paste_urls' ), 8 );
add_filter( 'bbp_get_topic_content', array( 'SnipShare_Helpers', 'embed_paste_urls' ), 8 );

The replacement uses the SnipShare_Helpers::embed_paste_urls() method, which resolves paste URLs anywhere in the content (inline or on their own line), unlike WP’s standard autoembed which only matches URLs on their own paragraph.

A forum reply containing:

Check out this helper function: https://yoursite.com/paste/abc123

Renders with the paste URL replaced by an inline code viewer iframe.

Only public and unlisted pastes are embedded. Private pastes and password-protected pastes return 404 from the oEmbed endpoint and are not embedded.

Go to SnipShare → Settings → Integrations → bbPress → Paste Embeds and toggle the checkbox.


When enabled (bbpress_button setting), an Insert Paste button appears above the submit area of bbPress reply and topic forms.

Clicking Insert Paste opens a dropdown UI with:

  1. Recent pastes list: The logged-in user’s 10 most recent active pastes, shown by title. Click any item to insert its shortcode.
  2. Manual hash input: Enter any paste hash and click Insert to insert a shortcode for a paste you know the hash of.
  3. “Create new paste” link: Opens /pastes/create/ in a new tab.

Selecting a paste inserts a [snipshare hash="abc123"] shortcode at the cursor position in the bbPress textarea.

The button targets:

  • #bbp_reply_content - the reply form textarea
  • #bbp_topic_content - the new topic form textarea

The Insert Paste button only appears for logged-in users. Guests do not see it.

The button is rendered on:

bbp_theme_before_reply_form_submit_wrapper // reply form
bbp_theme_before_topic_form_submit_wrapper // new topic form

The [snipshare] shortcode works natively in bbPress topics and replies because bbPress runs do_shortcode() on its content by default. No extra configuration is needed.

The Insert Paste button automates shortcode insertion, but users can also type [snipshare hash="abc123"] manually.


The bbPress integration class is SnipShare_bbPress (integrations/class-snipshare-bbpress.php). Hooks are registered by the loader:

$this->loader->add_action( 'bbp_theme_before_reply_form_submit_wrapper', $bbp, 'add_paste_button' );
$this->loader->add_action( 'bbp_theme_before_topic_form_submit_wrapper', $bbp, 'add_paste_button' );
$this->loader->add_action( 'bbp_init', $bbp, 'enable_autoembed' );

The JavaScript for the dropdown UI and shortcode insertion is inlined in the add_paste_button() output - no separate JS file is enqueued. The script is wrapped in an IIFE and attaches event listeners after DOMContentLoaded.