Skip to:
Content

bbPress.org

Changeset 5387


Ignore:
Timestamp:
06/12/2014 02:10:21 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Tweak bbp_get_dropdown() to allow an array of custom posts to be used. See #2617.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/replies/template.php

    r5378 r5387  
    24782478
    24792479/**
     2480 * Output a select box allowing to pick which reply an existing hierarchical
     2481 * reply belongs to.
     2482 *
     2483 * @since bbPress (r5387)
     2484 *
     2485 * @param int $reply_id
     2486 */
     2487function bbp_reply_to_dropdown( $reply_id = 0 ) {
     2488        echo bbp_get_reply_to_dropdown( $reply_id );
     2489}
     2490        /**
     2491         * Return a select box allowing to pick which forum/topic a new
     2492         * topic/reply belongs in.
     2493         *
     2494         * @since bbPress (r5387)
     2495         *
     2496         * @param int $reply_id
     2497         *
     2498         * @uses BBP_Reply_Walker_Dropdown() As the default walker to generate the
     2499         *                                   dropdown
     2500         * @uses current_user_can()          To check if the current user can read
     2501         *                                   private forums
     2502         * @uses bbp_get_forum_post_type()   To get the forum post type
     2503         * @uses bbp_get_topic_post_type()   To get the topic post type
     2504         *
     2505         * @uses apply_filters() Calls 'bbp_get_dropdown' with the dropdown
     2506         *                        and args
     2507         * @return string The dropdown
     2508         */
     2509        function bbp_get_reply_to_dropdown( $reply_id = 0 ) {
     2510
     2511                // Validate the reply data
     2512                $reply_id = bbp_get_reply_id( $reply_id );
     2513                $reply_to = bbp_get_reply_to( $reply_id );
     2514                $topic_id = bbp_get_reply_topic_id( $reply_id );
     2515
     2516                // Setup default dropdown arguments
     2517                $r = bbp_parse_args( array(
     2518                        'show_none'   => sprintf( esc_attr__( '%1$s - %2$s', 'bbpress' ), $topic_id, bbp_get_topic_title( $topic_id ) ),
     2519                        'select_id'   => 'bbp_reply_to',
     2520                        'exclude'     => array(),
     2521                        'selected'    => $reply_to,
     2522                        'post_parent' => $topic_id,
     2523                        'post_type'   => bbp_get_reply_post_type(),
     2524                        'post_status' => bbp_get_public_status_id(),
     2525                        'max_depth'   => bbp_thread_replies_depth(),
     2526                        'page'        => 1,
     2527                        'per_page'    => -1,
     2528                        'orderby'     => 'menu_order',
     2529                        'order'       => 'ASC',
     2530                        'walker'      => new BBP_Walker_Reply_Dropdown()
     2531                ), 'reply_to_drodown' );
     2532
     2533                // Get the replies
     2534                $posts = get_posts( array(
     2535                        'post_type'   => $r['post_type'],
     2536                        'post_status' => $r['post_status'],
     2537                        'post_parent' => $r['post_parent'],
     2538                        'exclude'     => $r['exclude'],
     2539                        'numberposts' => $r['per_page'],
     2540                        'orderby'     => $r['orderby'],
     2541                        'order'       => $r['order'],
     2542                ) );
     2543
     2544                // Append `reply_to` for each reply so it can be walked
     2545                foreach ( $posts as &$post ) {
     2546
     2547                        // Check for reply post type
     2548                        $_reply_to = bbp_get_reply_to( $post->ID );
     2549
     2550                        // Make sure it's a reply to a reply
     2551                        if ( empty( $_reply_to ) || ( $topic_id === $_reply_to ) ) {
     2552                                $_reply_to = 0;
     2553                        }
     2554
     2555                        // Add reply_to to the post object so we can walk it later
     2556                        $post->reply_to = $_reply_to;
     2557                }
     2558
     2559                // Get the dropdown and return it
     2560                $retval = bbp_get_dropdown( array(
     2561                        'show_none'    => $r['show_none'],
     2562                        'select_id'    => $r['select_id'],
     2563                        'exclude'      => $r['exclude'],
     2564                        'selected'     => $r['selected'],
     2565                        'post_parent'  => $r['post_parent'],
     2566                        'post_type'    => $r['post_type'],
     2567                        'max_depth'    => $r['max_depth'],
     2568                        'page'         => $r['page'],
     2569                        'per_page'     => $r['per_page'],
     2570                        'walker'       => $r['walker'],
     2571                        'posts'        => $posts
     2572                ) );
     2573
     2574                // Filter and return
     2575                return apply_filters( 'bbp_get_reply_to_dropdown', $retval, $r, $reply_id, $reply_to, $topic_id );
     2576        }
     2577
     2578/**
    24802579 * Output checked value of reply log edit field
    24812580 *
Note: See TracChangeset for help on using the changeset viewer.