bbp_get_the_content( array $args = array() )
Return a textarea or TinyMCE if enabled
Description
Parameters
- $args
-
(Optional)
Default value: array()
Return
(string) HTML from output buffer
Source
File: bp-forums/common/template.php
function bbp_get_the_content( $args = array() ) {
// Parse arguments against default values
$r = bbp_parse_args( $args, array(
'context' => 'topic',
'before' => '<div class="bbp-the-content-wrapper">',
'after' => '</div>',
'wpautop' => true,
'media_buttons' => false,
'textarea_rows' => '12',
'tabindex' => bbp_get_tab_index(),
'tabfocus_elements' => 'bbp_topic_title,bbp_topic_tags',
'editor_class' => 'bbp-the-content',
'tinymce' => false,
'teeny' => true,
'quicktags' => true,
'dfw' => false
), 'get_the_content' );
// If using tinymce, remove our escaping and trust tinymce
if ( bbp_use_wp_editor() && ( false !== $r['tinymce'] ) ) {
remove_filter( 'bbp_get_form_forum_content', 'esc_textarea' );
remove_filter( 'bbp_get_form_topic_content', 'esc_textarea' );
remove_filter( 'bbp_get_form_reply_content', 'esc_textarea' );
}
// Assume we are not editing
$post_content = call_user_func( 'bbp_get_form_' . $r['context'] . '_content' );
// Start an output buffor
ob_start();
// Output something before the editor
if ( !empty( $r['before'] ) ) {
echo $r['before'];
}
// Use TinyMCE if available
if ( bbp_use_wp_editor() ) :
// Enable additional TinyMCE plugins before outputting the editor
add_filter( 'tiny_mce_plugins', 'bbp_get_tiny_mce_plugins' );
add_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' );
add_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' );
add_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' );
?>
<div id="bbp_editor_<?php echo esc_attr( $r['context'] ); ?>_content" class="<?php echo esc_attr( $r['editor_class'] ); ?>" tabindex="<?php echo esc_attr( $r['tabindex'] ); ?>">
<?php echo $post_content; ?>
</div>
<input type="hidden" id="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" name="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" value="<?php echo esc_attr( $post_content ); ?>" />
<?php
// Output the editor
// wp_editor( $post_content, 'bbp_' . $r['context'] . '_content', array(
// 'wpautop' => $r['wpautop'],
// 'media_buttons' => $r['media_buttons'],
// 'textarea_rows' => $r['textarea_rows'],
// 'tabindex' => $r['tabindex'],
// 'tabfocus_elements' => $r['tabfocus_elements'],
// 'editor_class' => $r['editor_class'],
// 'tinymce' => $r['tinymce'],
// 'teeny' => $r['teeny'],
// 'quicktags' => $r['quicktags'],
// 'dfw' => $r['dfw'],
// ) );
// Remove additional TinyMCE plugins after outputting the editor
remove_filter( 'tiny_mce_plugins', 'bbp_get_tiny_mce_plugins' );
remove_filter( 'teeny_mce_plugins', 'bbp_get_tiny_mce_plugins' );
remove_filter( 'teeny_mce_buttons', 'bbp_get_teeny_mce_buttons' );
remove_filter( 'quicktags_settings', 'bbp_get_quicktags_settings' );
/**
* Fallback to normal textarea.
*
* Note that we do not use esc_textarea() here to prevent double
* escaping the editable output, mucking up existing content.
*/
else : ?>
<textarea id="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" class="<?php echo esc_attr( $r['editor_class'] ); ?>" name="bbp_<?php echo esc_attr( $r['context'] ); ?>_content" cols="60" rows="<?php echo esc_attr( $r['textarea_rows'] ); ?>" tabindex="<?php echo esc_attr( $r['tabindex'] ); ?>"><?php echo $post_content; ?></textarea>
<?php endif;
// Output something after the editor
if ( !empty( $r['after'] ) ) {
echo $r['after'];
}
// Put the output into a usable variable
$output = ob_get_clean();
return apply_filters( 'bbp_get_the_content', $output, $args, $post_content );
}
Changelog
| Version | Description |
|---|---|
| bbPress (r3586) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.