Skip to:
Content

bbPress.org


Ignore:
Timestamp:
01/29/2012 08:23:20 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Global $post usage clean-up:

  • Use bbp_get_global_post_field() where appropriate, core WP functions otherwise
  • Replace local $post variables with $post to avoid stomping the global
  • Audit usage of bbp_get_global_post_field() and make sure we are providing the correct context
  • Fixes #1733.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-core-classes.php

    r3376 r3714  
    347347     * @param string $output Passed by reference. Used to append additional
    348348     *                        content.
    349      * @param object $post Post data object.
     349     * @param object $_post Post data object.
    350350     * @param int $depth Depth of post in reference to parent posts. Used
    351351     *                    for padding.
     
    359359     *                        title, output, post, depth and args
    360360     */
    361     function start_el( &$output, $post, $depth, $args ) {
     361    function start_el( &$output, $_post, $depth, $args ) {
    362362        $pad     = str_repeat( ' ', $depth * 3 );
    363363        $output .= "\t<option class=\"level-$depth\"";
    364364
    365365        // Disable the <option> if we're told to do so, the post type is bbp_forum and the forum is a category or is closed
    366         if ( true == $args['disable_categories'] && $post->post_type == bbp_get_forum_post_type() && ( bbp_is_forum_category( $post->ID ) || ( !current_user_can( 'edit_forum', $post->ID ) && bbp_is_forum_closed( $post->ID ) ) ) )
     366        if ( true == $args['disable_categories'] && $_post->post_type == bbp_get_forum_post_type() && ( bbp_is_forum_category( $_post->ID ) || ( !current_user_can( 'edit_forum', $_post->ID ) && bbp_is_forum_closed( $_post->ID ) ) ) )
    367367            $output .= ' disabled="disabled" value=""';
    368368        else
    369             $output .= ' value="' .$post->ID .'"' . selected( $args['selected'], $post->ID, false );
     369            $output .= ' value="' . $_post->ID .'"' . selected( $args['selected'], $_post->ID, false );
    370370
    371371        $output .= '>';
    372         $title   = esc_html( $post->post_title );
    373         $title   = apply_filters( 'bbp_walker_dropdown_post_title', $post->post_title, $output, $post, $depth, $args );
     372        $title   = esc_html( $_post->post_title );
     373        $title   = apply_filters( 'bbp_walker_dropdown_post_title', $_post->post_title, $output, $_post, $depth, $args );
    374374        $output .= $pad . $title;
    375375        $output .= "</option>\n";
Note: See TracChangeset for help on using the changeset viewer.