Skip to:
Content

bbPress.org

Changeset 4505


Ignore:
Timestamp:
11/24/2012 07:27:51 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Code Improvement:

  • Add brackets to /forums/template-tags.php.
  • Remove duplicate variable assignments.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/forums/template-tags.php

    r4504 r4505  
    155155
    156156                // Easy empty checking
    157                 if ( !empty( $forum_id ) && is_numeric( $forum_id ) )
     157                if ( !empty( $forum_id ) && is_numeric( $forum_id ) ) {
    158158                        $bbp_forum_id = $forum_id;
    159159
    160160                // Currently inside a forum loop
    161                 elseif ( !empty( $bbp->forum_query->in_the_loop ) && isset( $bbp->forum_query->post->ID ) )
     161                } elseif ( !empty( $bbp->forum_query->in_the_loop ) && isset( $bbp->forum_query->post->ID ) ) {
    162162                        $bbp_forum_id = $bbp->forum_query->post->ID;
    163163
    164164                // Currently viewing a forum
    165                 elseif ( bbp_is_single_forum() && !empty( $bbp->current_forum_id ) )
     165                } elseif ( bbp_is_single_forum() && !empty( $bbp->current_forum_id ) ) {
    166166                        $bbp_forum_id = $bbp->current_forum_id;
    167167
    168168                // Currently viewing a forum
    169                 elseif ( bbp_is_single_forum() && isset( $wp_query->post->ID ) )
     169                } elseif ( bbp_is_single_forum() && isset( $wp_query->post->ID ) ) {
    170170                        $bbp_forum_id = $wp_query->post->ID;
    171171
    172172                // Currently viewing a topic
    173                 elseif ( bbp_is_single_topic() )
     173                } elseif ( bbp_is_single_topic() ) {
    174174                        $bbp_forum_id = bbp_get_topic_forum_id();
    175175
    176176                // Fallback
    177                 else
     177                } else {
    178178                        $bbp_forum_id = 0;
     179                }
    179180
    180181                return (int) apply_filters( 'bbp_get_forum_id', (int) $bbp_forum_id, $forum_id );
     
    450451         */
    451452        function bbp_get_forum_last_active_time( $forum_id = 0 ) {
    452                 $forum_id = bbp_get_forum_id( $forum_id );
    453 
     453
     454                // Verify forum and get last active meta
     455                $forum_id    = bbp_get_forum_id( $forum_id );
    454456                $last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true );
     457
    455458                if ( empty( $last_active ) ) {
    456459                        $reply_id = bbp_get_forum_last_reply_id( $forum_id );
     
    465468                }
    466469
    467                 $last_active = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';
    468 
    469                 return apply_filters( 'bbp_get_forum_last_active', $last_active, $forum_id );
     470                $active_time = !empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';
     471
     472                return apply_filters( 'bbp_get_forum_last_active', $active_time, $forum_id );
    470473        }
    471474
     
    19401943
    19411944                // Get _POST data
    1942                 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_title'] ) )
     1945                if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_title'] ) ) {
    19431946                        $forum_title = $_POST['bbp_forum_title'];
    19441947
    19451948                // Get edit data
    1946                 elseif ( bbp_is_forum_edit() )
     1949                } elseif ( bbp_is_forum_edit() ) {
    19471950                        $forum_title = bbp_get_global_post_field( 'post_title', 'raw' );
    19481951
    19491952                // No data
    1950                 else
     1953                } else {
    19511954                        $forum_title = '';
     1955                }
    19521956
    19531957                return apply_filters( 'bbp_get_form_forum_title', esc_attr( $forum_title ) );
     
    19761980
    19771981                // Get _POST data
    1978                 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_content'] ) )
     1982                if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_content'] ) ) {
    19791983                        $forum_content = $_POST['bbp_forum_content'];
    19801984
    19811985                // Get edit data
    1982                 elseif ( bbp_is_forum_edit() )
     1986                } elseif ( bbp_is_forum_edit() ) {
    19831987                        $forum_content = bbp_get_global_post_field( 'post_content', 'raw' );
    19841988
    19851989                // No data
    1986                 else
     1990                } else {
    19871991                        $forum_content = '';
     1992                }
    19881993
    19891994                return apply_filters( 'bbp_get_form_forum_content', esc_textarea( $forum_content ) );
     
    20132018
    20142019                // Get _POST data
    2015                 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_id'] ) )
     2020                if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_id'] ) ) {
    20162021                        $forum_parent = $_POST['bbp_forum_id'];
    20172022
    20182023                // Get edit data
    2019                 elseif ( bbp_is_forum_edit() )
     2024                } elseif ( bbp_is_forum_edit() ) {
    20202025                        $forum_parent = bbp_get_forum_parent_id();
    20212026
    20222027                // No data
    2023                 else
     2028                } else {
    20242029                        $forum_parent = 0;
     2030                }
    20252031
    20262032                return apply_filters( 'bbp_get_form_forum_parent', esc_attr( $forum_parent ) );
     
    20502056
    20512057                // Get _POST data
    2052                 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_type'] ) )
     2058                if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_type'] ) ) {
    20532059                        $forum_type = $_POST['bbp_forum_type'];
    20542060
    20552061                // Get edit data
    2056                 elseif ( bbp_is_forum_edit() )
     2062                } elseif ( bbp_is_forum_edit() ) {
    20572063                        $forum_type = bbp_get_forum_type();
    20582064
    20592065                // No data
    2060                 else
     2066                } else {
    20612067                        $forum_type = 'forum';
     2068                }
    20622069
    20632070                return apply_filters( 'bbp_get_form_forum_type', esc_attr( $forum_type ) );
     
    20872094
    20882095                // Get _POST data
    2089                 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_visibility'] ) )
     2096                if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['bbp_forum_visibility'] ) ) {
    20902097                        $forum_visibility = $_POST['bbp_forum_visibility'];
    20912098
    20922099                // Get edit data
    2093                 elseif ( bbp_is_forum_edit() )
     2100                } elseif ( bbp_is_forum_edit() ) {
    20942101                        $forum_visibility = bbp_get_forum_visibility();
    20952102
    20962103                // No data
    2097                 else
     2104                } else {
    20982105                        $forum_visibility = bbpress()->public_status_id;
     2106                }
    20992107
    21002108                return apply_filters( 'bbp_get_form_forum_visibility', esc_attr( $forum_visibility ) );
Note: See TracChangeset for help on using the changeset viewer.