Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/01/2011 09:01:00 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Fix issue where post form values would disappear when editing or creating a new topic. Addresses topic portion of #1466.

File:
1 edited

Legend:

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

    r2974 r2976  
    23952395    $topic_id = bbp_get_topic_id( $topic_id );
    23962396
    2397     // Current topic type
    2398     if ( !bbp_is_topic_edit() ) {
    2399         $sticky_current = 'unstick';
    2400     } else {
    2401         if ( bbp_is_topic_super_sticky( $topic_id ) ) {
     2397    // Edit topic
     2398    if ( bbp_is_topic_edit() ) {
     2399
     2400        // Post value is passed
     2401        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST[$select_id] ) ) {
     2402            $sticky_current = $_POST[$select_id];
     2403
     2404        // Topic is super sticky
     2405        } elseif ( bbp_is_topic_super_sticky( $topic_id ) ) {
    24022406            $sticky_current = 'super';
     2407
     2408        // Topic is sticky or normal
    24032409        } else {
    24042410            $sticky_current = bbp_is_topic_sticky( $topic_id, false ) ? 'stick' : 'unstick';
     2411        }
     2412
     2413    // New topic
     2414    } else {
     2415
     2416        // Post value is passed
     2417        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST[$select_id] ) ) {
     2418            $sticky_current = $_POST[$select_id];
     2419
     2420        // Default to unstick
     2421        } else {
     2422            $sticky_current = 'unstick';
    24052423        }
    24062424    }
     
    25062524    }
    25072525
     2526/** Forms *********************************************************************/
     2527
     2528/**
     2529 * Output the value of topic title field
     2530 *
     2531 * @since bbPress (r2976)
     2532 *
     2533 * @uses bbp_get_form_topic_title()
     2534 */
     2535function bbp_form_topic_title() {
     2536    echo bbp_get_form_topic_title();
     2537}
     2538    /**
     2539     * Return the value of topic title field
     2540     *
     2541     * @since bbPress (r2976)
     2542     *
     2543     * @global obj $post
     2544     * @uses bbp_is_topic_edit()
     2545     * @uses esc_attr()
     2546     * @return string
     2547     */
     2548    function bbp_get_form_topic_title() {
     2549        global $post;
     2550
     2551        // Get _POST data
     2552        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_title'] ) )
     2553            $topic_title = $_POST['bbp_topic_title'];
     2554
     2555        // Get edit data
     2556        elseif ( !empty( $post->post_title ) && bbp_is_topic_edit() )
     2557            $topic_title = $post->post_title;
     2558
     2559        // No data
     2560        else
     2561            $topic_title = '';
     2562
     2563        return apply_filters( 'bbp_get_form_topic_title', esc_attr( $topic_title ) );
     2564    }
     2565
     2566/**
     2567 * Output the value of topic content field
     2568 *
     2569 * @since bbPress (r2976)
     2570 *
     2571 * @uses bbp_get_form_topic_content()
     2572 */
     2573function bbp_form_topic_content() {
     2574    echo bbp_get_form_topic_content();
     2575}
     2576    /**
     2577     * Return the value of topic content field
     2578     *
     2579     * @since bbPress (r2976)
     2580     *
     2581     * @global obj $post
     2582     * @uses bbp_is_topic_edit()
     2583     * @uses esc_textarea()
     2584     * @return string
     2585     */
     2586    function bbp_get_form_topic_content() {
     2587        global $post;
     2588
     2589        // Get _POST data
     2590        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_content'] ) )
     2591            $topic_content = $_POST['bbp_topic_content'];
     2592
     2593        // Get edit data
     2594        elseif ( !empty( $post->post_title ) && bbp_is_topic_edit() )
     2595            $topic_content = $post->post_content;
     2596
     2597        // No data
     2598        else
     2599            $topic_content = '';
     2600
     2601        return apply_filters( 'bbp_get_form_topic_content', esc_textarea( $topic_content ) );
     2602    }
     2603
     2604/**
     2605 * Output value of topic tags field
     2606 *
     2607 * @since bbPress (r2976)
     2608 * @uses bbp_get_form_topic_tags()
     2609 */
     2610function bbp_form_topic_tags() {
     2611    echo bbp_get_form_topic_tags();
     2612}
     2613    /**
     2614     * Return value of topic tags field
     2615     *
     2616     * @since bbPress (r2976)
     2617     *
     2618     * @global obj $post
     2619     * @uses bbp_is_topic_edit()
     2620     * @uses esc_attr()
     2621     * @return string
     2622     */
     2623    function bbp_get_form_topic_tags() {
     2624        global $post;
     2625
     2626        // Get _POST data
     2627        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_tags'] ) )
     2628            $topic_tags = $_POST['bbp_topic_tags'];
     2629
     2630        // Get edit data
     2631        elseif ( !empty( $post->post_title ) && bbp_is_topic_edit() )
     2632            $topic_tags = $post->post_tags;
     2633
     2634        // No data
     2635        else
     2636            $topic_tags = '';
     2637
     2638        return apply_filters( 'bbp_get_form_topic_tags', esc_attr( $topic_tags ) );
     2639    }
     2640
     2641/**
     2642 * Output value of topic forum
     2643 *
     2644 * @since bbPress (r2976)
     2645 *
     2646 * @uses bbp_get_form_topic_forum()
     2647 */
     2648function bbp_form_topic_forum() {
     2649    echo bbp_get_form_topic_forum();
     2650}
     2651    /**
     2652     * Return value of topic forum
     2653     *
     2654     * @since bbPress (r2976)
     2655     *
     2656     * @uses bbp_is_topic_edit()
     2657     * @uses bbp_get_topic_forum_id()
     2658     * @uses esc_attr()
     2659     * @return string
     2660     */
     2661    function bbp_get_form_topic_forum() {
     2662
     2663        // Get _POST data
     2664        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_id'] ) )
     2665            $topic_forum = $_POST['bbp_forum_id'];
     2666
     2667        // Get edit data
     2668        elseif ( bbp_is_topic_edit() )
     2669            $topic_forum = bbp_get_topic_forum_id();
     2670
     2671        // No data
     2672        else
     2673            $topic_forum = 0;
     2674
     2675        return apply_filters( 'bbp_get_form_topic_forum', esc_attr( $topic_forum ) );
     2676    }
     2677
     2678/**
     2679 * Output checked value of topic subscription
     2680 *
     2681 * @since bbPress (r2976)
     2682 *
     2683 * @uses bbp_get_form_topic_subscribed()
     2684 */
     2685function bbp_form_topic_subscribed() {
     2686    echo bbp_get_form_topic_subscribed();
     2687}
     2688    /**
     2689     * Return checked value of topic subscription
     2690     *
     2691     * @since bbPress (r2976)
     2692     *
     2693     * @global obj $post
     2694     * @uses bbp_is_topic_edit()
     2695     * @uses bbp_is_user_user_subscribed()
     2696     * @return string
     2697     */
     2698    function bbp_get_form_topic_subscribed() {
     2699        global $post;
     2700
     2701        // Get _POST data
     2702        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_subscription'] ) )
     2703            $topic_subscribed = $_POST['bbp_topic_subscription'];
     2704
     2705        // Get edit data
     2706        elseif ( bbp_is_topic_edit() )
     2707            $topic_subscribed = bbp_is_user_subscribed( $post->post_author );
     2708
     2709        // No data
     2710        else
     2711            $topic_subscribed = 0;
     2712
     2713        return apply_filters( 'bbp_get_form_topic_subscribed', checked( 'bbp_subscribe', $topic_subscribed, false ) );
     2714    }
     2715
     2716/**
     2717 * Output checked value of topic log edit field
     2718 *
     2719 * @since bbPress (r2976)
     2720 *
     2721 * @uses bbp_get_form_topic_log_edit()
     2722 */
     2723function bbp_form_topic_log_edit() {
     2724    echo bbp_get_form_topic_log_edit();
     2725}
     2726    /**
     2727     * Return checked value of topic log edit field
     2728     *
     2729     * @since bbPress (r2976)
     2730     *
     2731     * @global obj $post
     2732     * @uses checked()
     2733     * @return string
     2734     */
     2735    function bbp_get_form_topic_log_edit() {
     2736        global $post;
     2737
     2738        // Get _POST data
     2739        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_log_topic_edit'] ) )
     2740            $topic_revision = $_POST['bbp_log_topic_edit'];
     2741
     2742        // No data
     2743        else
     2744            $topic_revision = 1;
     2745
     2746        return apply_filters( 'bbp_get_form_topic_log_edit', checked( true, $topic_revision, false ) );
     2747    }
     2748
     2749/**
     2750 * Output the value of the topic edit reason
     2751 *
     2752 * @since bbPress (r2976)
     2753 *
     2754 * @uses bbp_get_form_topic_edit_reason()
     2755 */
     2756function bbp_form_topic_edit_reason() {
     2757    echo bbp_get_form_topic_edit_reason();
     2758}
     2759    /**
     2760     * Return the value of the topic edit reason
     2761     *
     2762     * @since bbPress (r2976)
     2763     *
     2764     * @global obj $post
     2765     * @uses esc_attr()
     2766     * @return string
     2767     */
     2768    function bbp_get_form_topic_edit_reason() {
     2769        global $post;
     2770
     2771        // Get _POST data
     2772        if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_topic_edit_reason'] ) )
     2773            $topic_edit_reason = $_POST['bbp_topic_edit_reason'];
     2774
     2775        // No data
     2776        else
     2777            $topic_edit_reason = '';
     2778
     2779        return apply_filters( 'bbp_get_form_topic_edit_reason', esc_attr( $topic_edit_reason ) );
     2780    }
     2781
    25082782?>
Note: See TracChangeset for help on using the changeset viewer.