bbPress Integration
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.
Feature 1: Paste Embeds
Section titled “Feature 1: Paste Embeds”When enabled (bbpress_embed setting), SnipShare paste URLs in bbPress topics and replies are automatically converted to inline code previews.
How It Works
Section titled “How It Works”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.
Example
Section titled “Example”A forum reply containing:
Check out this helper function: https://yoursite.com/paste/abc123Renders with the paste URL replaced by an inline code viewer iframe.
Access Control
Section titled “Access Control”Only public and unlisted pastes are embedded. Private pastes and password-protected pastes return 404 from the oEmbed endpoint and are not embedded.
Enabling/Disabling
Section titled “Enabling/Disabling”Go to SnipShare → Settings → Integrations → bbPress → Paste Embeds and toggle the checkbox.
Feature 2: Insert Paste Button
Section titled “Feature 2: Insert Paste Button”When enabled (bbpress_button setting), an Insert Paste button appears above the submit area of bbPress reply and topic forms.
What the Button Does
Section titled “What the Button Does”Clicking Insert Paste opens a dropdown UI with:
- Recent pastes list: The logged-in user’s 10 most recent active pastes, shown by title. Click any item to insert its shortcode.
- Manual hash input: Enter any paste hash and click Insert to insert a shortcode for a paste you know the hash of.
- “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.
Target Textareas
Section titled “Target Textareas”The button targets:
#bbp_reply_content- the reply form textarea#bbp_topic_content- the new topic form textarea
Visibility
Section titled “Visibility”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 formbbp_theme_before_topic_form_submit_wrapper // new topic formShortcode in Forum Content
Section titled “Shortcode in Forum Content”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.
Developer Notes
Section titled “Developer Notes”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.

