Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/24/2025 07:23:06 PM (6 months ago)
Author:
johnjamesjacoby
Message:

Tools - Code Improvement: stop ignoring these PHPCS sniffs:

  • PEAR.Files.IncludingFile.UseRequire
  • PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLineDEFAULT
  • PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose
  • Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace
  • Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure
  • Squiz.PHP.EmbeddedPhp.MultipleStatements
  • Squiz.PHP.NonExecutableCode.Unreachable
  • Universal.Arrays.DuplicateArrayKey.Found
  • Universal.ControlStructures.DisallowLonelyIf.Found
  • WordPress.PHP.NoSilencedErrors.Discouraged

This commit includes code formatting changes for the above sniffs.

See #3658.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/topics/functions.php

    r7378 r7379  
    469469        return;
    470470
    471     // Topic exists
     471    // Check users ability to create new topic
     472    } elseif ( ! bbp_is_topic_anonymous( $topic_id ) ) {
     473
     474        // User cannot edit this topic
     475        if ( ! current_user_can( 'edit_topic', $topic_id ) ) {
     476            bbp_add_error( 'bbp_edit_topic_permission', __( '<strong>Error</strong>: You do not have permission to edit that topic.', 'bbpress' ) );
     477        }
     478
     479        // Set topic author
     480        $topic_author = bbp_get_topic_author_id( $topic_id );
     481
     482    // It is an anonymous post
    472483    } else {
    473484
    474         // Check users ability to create new topic
    475         if ( ! bbp_is_topic_anonymous( $topic_id ) ) {
    476 
    477             // User cannot edit this topic
    478             if ( ! current_user_can( 'edit_topic', $topic_id ) ) {
    479                 bbp_add_error( 'bbp_edit_topic_permission', __( '<strong>Error</strong>: You do not have permission to edit that topic.', 'bbpress' ) );
    480             }
    481 
    482             // Set topic author
    483             $topic_author = bbp_get_topic_author_id( $topic_id );
    484 
    485         // It is an anonymous post
    486         } else {
    487 
    488             // Filter anonymous data
    489             $anonymous_data = bbp_filter_anonymous_post_data();
    490         }
     485        // Filter anonymous data
     486        $anonymous_data = bbp_filter_anonymous_post_data();
    491487    }
    492488
     
    11751171        bbp_add_error( 'bbp_merge_topic_nonce', __( '<strong>Error</strong>: Are you sure you wanted to do that?', 'bbpress' ) );
    11761172        return;
     1173    }
     1174
     1175    // Get source topic
     1176    $source_topic = bbp_get_topic( $source_topic_id );
    11771177
    11781178    // Source topic not found
    1179     } elseif ( ! $source_topic = bbp_get_topic( $source_topic_id ) ) {
     1179    if ( empty( $source_topic ) ) {
    11801180        bbp_add_error( 'bbp_merge_topic_source_not_found', __( '<strong>Error</strong>: The topic you want to merge was not found.', 'bbpress' ) );
    11811181        return;
     
    11971197    }
    11981198
     1199    // Get the destination topic
     1200    $destination_topic = bbp_get_topic( $destination_topic_id );
     1201
    11991202    // Destination topic not found
    1200     if ( ! $destination_topic = bbp_get_topic( $destination_topic_id ) ) {
     1203    if ( empty( $destination_topic ) ) {
    12011204        bbp_add_error( 'bbp_merge_topic_destination_not_found', __( '<strong>Error</strong>: The topic you want to merge to was not found.', 'bbpress' ) );
    12021205    }
     
    15071510            case 'reply' :
    15081511            default :
    1509 
    15101512                // User needs to be able to publish topics
    15111513                if ( current_user_can( 'publish_topics' ) ) {
     
    18121814
    18131815            // No tag name was provided
    1814             if ( empty( $_POST['tag-name'] ) || ! $name = $_POST['tag-name'] ) {
     1816            if ( empty( $_POST['tag-name'] ) || ! is_scalar( $_POST['tag-name'] ) ) {
    18151817                bbp_add_error( 'bbp_manage_topic_tag_update_name', __( '<strong>Error</strong>: You need to enter a tag name.', 'bbpress' ) );
    18161818                return;
     
    18181820
    18191821            // Attempt to update the tag
     1822            $name        = $_POST['tag-name'];
    18201823            $slug        = ! empty( $_POST['tag-slug']        ) ? $_POST['tag-slug'] : '';
    18211824            $description = ! empty( $_POST['tag-description'] ) ? $_POST['tag-description'] : '';
     
    18611864
    18621865            // No tag name was provided
    1863             if ( empty( $_POST['tag-existing-name'] ) || ! $name = $_POST['tag-existing-name'] ) {
     1866            if ( empty( $_POST['tag-existing-name'] ) || ! is_scalar( $_POST['tag-existing-name'] ) ) {
    18641867                bbp_add_error( 'bbp_manage_topic_tag_merge_name', __( '<strong>Error</strong>: You need to enter a tag name.', 'bbpress' ) );
    18651868                return;
    18661869            }
    18671870
     1871            // Unsanitized name of existing tag
     1872            $name = $_POST['tag-existing-name'];
     1873
    18681874            // If term does not exist, create it
    1869             if ( ! $tag = term_exists( $name, bbp_get_topic_tag_tax_id() ) ) {
     1875            $tag = term_exists( $name, bbp_get_topic_tag_tax_id() );
     1876            if ( empty( $tag ) ) {
    18701877                $tag = wp_insert_term( $name, bbp_get_topic_tag_tax_id() );
    18711878            }
     
    39313938        <?php if ( bbp_has_topics( $topics_query ) ) : ?>
    39323939
    3933             <?php while ( bbp_topics() ) : bbp_the_topic(); ?>
     3940            <?php while ( bbp_topics() ) :
     3941
     3942                bbp_the_topic(); ?>
    39343943
    39353944                <item>
Note: See TracChangeset for help on using the changeset viewer.