Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/03/2011 06:35:03 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Settings, functions, CSS, and template-tags necessary to use wp_editor() function, introduced in WordPress 3.3. See #1673.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-common-template.php

    r3580 r3586  
    556556
    557557    return (bool) apply_filters( 'bbp_is_single_view', $retval );
     558}
     559
     560/**
     561 * Check if current page is an edit page
     562 *
     563 * @since bbPress (r3585)
     564 *
     565 * @uses WP_Query Checks if WP_Query::bbp_is_edit is true
     566 * @return bool True if it's the edit page, false if not
     567 */
     568function bbp_is_edit() {
     569    global $wp_query;
     570
     571    // Assume false
     572    $retval = false;
     573
     574    // Check query
     575    if ( !empty( $wp_query->bbp_is_edit ) && ( $wp_query->bbp_is_edit == true ) )
     576        $retval = true;
     577
     578    return (bool) apply_filters( 'bbp_is_edit', $retval );
    558579}
    559580
     
    13071328}
    13081329
     1330/**
     1331 * Output a textarea or TinyMCE if enabled
     1332 *
     1333 * @since bbPress (r3586)
     1334 *
     1335 * @param array $args
     1336 * @uses bbp_get_the_content() To return the content to output
     1337 */
     1338function bbp_the_content( $args = array() ) {
     1339    echo bbp_get_the_content( $args );
     1340}
     1341    /**
     1342     * Return a textarea or TinyMCE if enabled
     1343     *
     1344     * @since bbPress (r3586)
     1345     *
     1346     * @global obj $post
     1347     * @param array $args
     1348     *
     1349     * @uses apply_filter() To filter args and output
     1350     * @uses wp_parse_pargs() To compare args
     1351     * @uses bbp_use_wp_editor() To see if WP editor is in use
     1352     * @uses bbp_is_edit() To see if we are editing something
     1353     * @uses wp_editor() To output the WordPress editor
     1354     *
     1355     * @return string HTML from output buffer
     1356     */
     1357    function bbp_get_the_content( $args = array() ) {
     1358
     1359        // Default arguments
     1360        $defaults = array(
     1361            'context'       => 'topic',
     1362            'before'        => '<div class="bbp-the-content-wrapper">',
     1363            'after'         => '</div>',
     1364            'wpautop'       => true,
     1365            'media_buttons' => false,
     1366            'textarea_rows' => '6',
     1367            'tabindex'      => bbp_get_tab_index(),
     1368            'editor_class'  => 'bbp-the-content',
     1369            'tinymce'       => true,
     1370            'quicktags'     => true
     1371        );
     1372        $r = apply_filters( 'bbp_pre_the_content', wp_parse_args( $args, $defaults ) );
     1373        extract( $r );
     1374
     1375        // Assume we are not editing
     1376        $post_content = '';
     1377
     1378        // Start an output buffor
     1379        ob_start();
     1380
     1381        // Output something before the editor
     1382        if ( !empty( $before ) )
     1383            echo $before;
     1384
     1385        // Use TinyMCE if available
     1386        if ( function_exists( 'wp_editor' ) && bbp_use_wp_editor() ) {
     1387
     1388            // If it's an edit, use the $post global
     1389            if ( bbp_is_edit() ) {
     1390                global $post;
     1391                $post_content = $post->post_content;
     1392            }
     1393
     1394            $settings = array(
     1395                'wpautop'       => $wpautop,
     1396                'media_buttons' => $media_buttons,
     1397                'textarea_rows' => $textarea_rows,
     1398                'tabindex'      => $tabindex,
     1399                'editor_class'  => $editor_class,
     1400                'tinymce'       => $tinymce,
     1401                'quicktags'     => $quicktags
     1402            );
     1403            wp_editor( $post_content, 'bbp_' . $context . '_content', $settings );
     1404
     1405        // Fallback to normal textarea
     1406        } else {
     1407
     1408            // Get sanitized content
     1409            if ( bbp_is_edit() ) {
     1410                $post_content = call_user_func( 'bbp_get_form_' . $context . '_content' );
     1411            }
     1412
     1413            ?>
     1414
     1415            <textarea id="bbp_<?php echo $context; ?>_content" class="<?php echo $editor_class; ?>" name="bbp_<?php echo $context; ?>_content" cols="60" rows="<?php echo $textarea_rows; ?>" tabindex="<?php echo $tabindex; ?>"><?php echo $post_content; ?></textarea>
     1416
     1417            <?php
     1418        }
     1419
     1420        // Output something after the editor
     1421        if ( !empty( $after ) )
     1422            echo $after;
     1423
     1424        // Put the output into a usable variable
     1425        $output = ob_get_contents();
     1426
     1427        // Flush the output buffer
     1428        ob_end_clean();
     1429
     1430        return apply_filters( 'bbp_get_the_content', $output, $args, $post_content );
     1431    }
     1432
    13091433/** Views *********************************************************************/
    13101434
Note: See TracChangeset for help on using the changeset viewer.