Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/22/2025 06:05:25 AM (7 months ago)
Author:
johnjamesjacoby
Message:

Tools - Code Improvement: stop ignoring these PHPCS sniffs:

  • Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
  • Generic.CodeAnalysis.EmptyStatement.DetectedElseif
  • Generic.CodeAnalysis.EmptyStatement.DetectedIf
  • Generic.CodeAnalysis.UselessOverridingMethod.Found
  • Generic.ControlStructures.InlineControlStructure.NotAllowed
  • Generic.Files.LineEndings.InvalidEOLChar
  • Generic.Formatting.DisallowMultipleStatements.SameLine
  • Generic.Formatting.SpaceAfterCast.TooMuchSpace
  • Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace
  • Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed
  • NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceAfterArrayOpenerMultiLine
  • NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceAfterArrayOpenerSingleLine
  • NormalizedArrays.Arrays.ArrayBraceSpacing.SpaceBeforeArrayCloserMultiLine
  • NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLineCloserSameLine
  • PEAR.Functions.FunctionCallSignature.CloseBracketLine
  • PEAR.Functions.FunctionCallSignature.EmptyLine
  • PEAR.Functions.FunctionCallSignature.Indent
  • PEAR.Functions.FunctionCallSignature.MultipleArguments
  • PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
  • PHPCompatibility.Syntax.RemovedCurlyBraceArrayAccess.Found
  • PSR2.Classes.ClassDeclaration.CloseBraceAfterBody
  • PSR2.Classes.PropertyDeclaration.ScopeMissing
  • PSR2.Classes.PropertyDeclaration.Underscore
  • PSR2.Classes.PropertyDeclaration.VarUsed
  • PSR2.ControlStructures.ElseIfDeclaration.NotAllowed
  • PSR2.ControlStructures.SwitchDeclaration.BreakIndent
  • PSR2.Methods.MethodDeclaration.Underscore
  • Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace
  • Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterOpen
  • Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeClose
  • Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace
  • Squiz.PHP.DisallowSizeFunctionsInLoops.Found
  • Squiz.Scope.MethodScope.Missing
  • Squiz.WhiteSpace.SuperfluousWhitespace.EndLine
  • Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound
  • Universal.NamingConventions.NoReservedKeywordParameterNames.echoFound
  • Universal.NamingConventions.NoReservedKeywordParameterNames.parentFound
  • Universal.Operators.DisallowStandalonePostIncrementDecrement.PostDecrementFound
  • Universal.Operators.DisallowStandalonePostIncrementDecrement.PostIncrementFound
  • Universal.Operators.StrictComparisons.LooseEqual
  • Universal.Operators.StrictComparisons.LooseNotEqual
  • WordPress.Arrays.ArrayKeySpacingRestrictions.TooMuchSpaceAfterKey
  • WordPress.DateTime.CurrentTimeTimestamp.Requested
  • WordPress.DateTime.RestrictedFunctions.date_date
  • WordPress.Files.FileName.NotHyphenatedLowercase
  • WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
  • WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
  • WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
  • WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
  • WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
  • WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
  • WordPress.PHP.IniSet.Risky
  • WordPress.PHP.PregQuoteDelimiter.Missing
  • WordPress.PHP.StrictInArray.MissingTrueStrict
  • WordPress.WP.AlternativeFunctions.parse_url_parse_url
  • WordPress.WP.AlternativeFunctions.rand_mt_rand
  • WordPress.WP.AlternativeFunctions.strip_tags_strip_tag
  • WordPress.WP.AlternativeFunctions.strip_tags_strip_tags
  • WordPress.WP.Capabilities.Unknown
  • WordPress.WP.DeprecatedParameters.Get_termsParam2Found
  • WordPress.WP.DeprecatedParameters.Wp_count_termsParam2Found
  • WordPress.WP.DiscouragedFunctions.query_posts_query_posts
  • WordPress.WP.DiscouragedFunctions.wp_reset_query_wp_reset_query
  • WordPress.WP.EnqueuedResourceParameters.NotInFooter
  • WordPress.WP.GlobalVariablesOverride.Prohibited
  • WordPress.WP.I18n.LowLevelTranslationFunction

This commit includes code formatting changes for the above sniffs.

See #3658.

File:
1 edited

Legend:

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

    r7374 r7378  
    2525
    2626    // Parse arguments against default values
    27     $reply_data = bbp_parse_args( $reply_data, array(
    28         'post_parent'    => 0, // topic ID
    29         'post_type'      => bbp_get_reply_post_type(),
    30         'post_author'    => bbp_get_current_user_id(),
    31         'post_password'  => '',
    32         'post_content'   => '',
    33         'post_title'     => '',
    34         'menu_order'     => bbp_get_topic_reply_count( $reply_data['post_parent'], true ) + 1,
    35         'comment_status' => 'closed'
    36     ), 'insert_reply' );
     27    $reply_data = bbp_parse_args(
     28        $reply_data,
     29        array(
     30            'post_parent'    => 0, // topic ID
     31            'post_type'      => bbp_get_reply_post_type(),
     32            'post_author'    => bbp_get_current_user_id(),
     33            'post_password'  => '',
     34            'post_content'   => '',
     35            'post_title'     => '',
     36            'menu_order'     => bbp_get_topic_reply_count( $reply_data['post_parent'], true ) + 1,
     37            'comment_status' => 'closed'
     38        ),
     39        'insert_reply'
     40    );
    3741
    3842    // Possibly override status based on parent topic
     
    5054
    5155    // Parse arguments against default values
    52     $reply_meta = bbp_parse_args( $reply_meta, array(
    53         'author_ip' => bbp_current_author_ip(),
    54         'forum_id'  => 0,
    55         'topic_id'  => 0,
    56         'reply_to'  => 0
    57     ), 'insert_reply_meta' );
     56    $reply_meta = bbp_parse_args(
     57        $reply_meta,
     58        array(
     59            'author_ip' => bbp_current_author_ip(),
     60            'forum_id'  => 0,
     61            'topic_id'  => 0,
     62            'reply_to'  => 0
     63        ),
     64        'insert_reply_meta'
     65    );
    5866
    5967    // Insert reply meta
     
    395403    // Add the content of the form to $reply_data as an array
    396404    // Just in time manipulation of reply data before being created
    397     $reply_data = apply_filters( 'bbp_new_reply_pre_insert', array(
    398         'post_author'    => $reply_author,
    399         'post_title'     => $reply_title,
    400         'post_content'   => $reply_content,
    401         'post_status'    => $reply_status,
    402         'post_parent'    => $topic_id,
    403         'post_type'      => bbp_get_reply_post_type(),
    404         'comment_status' => 'closed',
    405         'menu_order'     => bbp_get_topic_reply_count( $topic_id, true ) + 1
    406     ) );
     405    $reply_data = apply_filters(
     406        'bbp_new_reply_pre_insert',
     407        array(
     408            'post_author'    => $reply_author,
     409            'post_title'     => $reply_title,
     410            'post_content'   => $reply_content,
     411            'post_status'    => $reply_status,
     412            'post_parent'    => $topic_id,
     413            'post_type'      => bbp_get_reply_post_type(),
     414            'comment_status' => 'closed',
     415            'menu_order'     => bbp_get_topic_reply_count( $topic_id, true ) + 1
     416        )
     417    );
    407418
    408419    // Insert reply
     
    737748    // Add the content of the form to $reply_data as an array
    738749    // Just in time manipulation of reply data before being edited
    739     $reply_data = apply_filters( 'bbp_edit_reply_pre_insert', array(
    740         'ID'           => $reply_id,
    741         'post_title'   => $reply_title,
    742         'post_content' => $reply_content,
    743         'post_status'  => $reply_status,
    744         'post_parent'  => $topic_id,
    745         'post_author'  => $reply_author,
    746         'post_type'    => bbp_get_reply_post_type()
    747     ) );
     750    $reply_data = apply_filters(
     751        'bbp_edit_reply_pre_insert',
     752        array(
     753            'ID'           => $reply_id,
     754            'post_title'   => $reply_title,
     755            'post_content' => $reply_content,
     756            'post_status'  => $reply_status,
     757            'post_parent'  => $topic_id,
     758            'post_author'  => $reply_author,
     759            'post_type'    => bbp_get_reply_post_type()
     760        )
     761    );
    748762
    749763    // Toggle revisions to avoid duplicates
     
    793807            $revision_id = wp_save_post_revision( $reply_id );
    794808            if ( ! empty( $revision_id ) ) {
    795                 bbp_update_reply_revision_log( array(
    796                     'reply_id'    => $reply_id,
    797                     'revision_id' => $revision_id,
    798                     'author_id'   => bbp_get_current_user_id(),
    799                     'reason'      => $reply_edit_reason
    800                 ) );
     809                bbp_update_reply_revision_log(
     810                    array(
     811                        'reply_id'    => $reply_id,
     812                        'revision_id' => $revision_id,
     813                        'author_id'   => bbp_get_current_user_id(),
     814                        'reason'      => $reply_edit_reason
     815                    )
     816                );
    801817            }
    802818        }
     
    9871003
    9881004            // Reply meta relating to most recent reply
     1005            // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
    9891006            if ( bbp_is_reply( $ancestor ) ) {
    9901007                // @todo - hierarchical replies
     
    11981215
    11991216            // Get parent reply
     1217            // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
    12001218            while ( $ancestor = bbp_get_reply( $id ) ) {
    12011219
     
    12321250
    12331251    // Parse arguments against default values
    1234     $r = bbp_parse_args( $args, array(
    1235         'reason'      => '',
    1236         'reply_id'    => 0,
    1237         'author_id'   => 0,
    1238         'revision_id' => 0
    1239     ), 'update_reply_revision_log' );
     1252    $r = bbp_parse_args(
     1253        $args,
     1254        array(
     1255            'reason'      => '',
     1256            'reply_id'    => 0,
     1257            'author_id'   => 0,
     1258            'revision_id' => 0
     1259        ),
     1260        'update_reply_revision_log'
     1261    );
    12401262
    12411263    // Populate the variables
     
    13581380
    13591381                // Update the reply
    1360                 wp_update_post( array(
    1361                     'ID'          => $move_reply->ID,
    1362                     'post_title'  => '',
    1363                     'post_name'   => false, // will be automatically generated
    1364                     'post_parent' => $destination_topic->ID,
    1365                     'menu_order'  => $reply_position,
    1366                     'guid'        => ''
    1367                 ) );
     1382                wp_update_post(
     1383                    array(
     1384                        'ID'          => $move_reply->ID,
     1385                        'post_title'  => '',
     1386                        'post_name'   => false, // will be automatically generated
     1387                        'post_parent' => $destination_topic->ID,
     1388                        'menu_order'  => $reply_position,
     1389                        'guid'        => ''
     1390                    )
     1391                );
    13681392
    13691393                // Adjust reply meta values
     
    13901414
    13911415                    // Update the topic
    1392                     $destination_topic_id = wp_update_post( array(
    1393                         'ID'          => $move_reply->ID,
    1394                         'post_title'  => $destination_topic_title,
    1395                         'post_name'   => false,
    1396                         'post_type'   => bbp_get_topic_post_type(),
    1397                         'post_parent' => $source_topic->post_parent,
    1398                         'guid'        => ''
    1399                     ) );
     1416                    $destination_topic_id = wp_update_post(
     1417                        array(
     1418                            'ID'          => $move_reply->ID,
     1419                            'post_title'  => $destination_topic_title,
     1420                            'post_name'   => false,
     1421                            'post_type'   => bbp_get_topic_post_type(),
     1422                            'post_parent' => $source_topic->post_parent,
     1423                            'guid'        => ''
     1424                        )
     1425                    );
     1426
     1427                    // Get the topic
    14001428                    $destination_topic = bbp_get_topic( $destination_topic_id );
    14011429
     
    14331461
    14341462        // Set destination topic post_date to 1 second before from reply
     1463        // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
    14351464        $destination_post_date = date( 'Y-m-d H:i:s', strtotime( $move_reply->post_date ) - 1 );
    14361465
    14371466        // Update destination topic
    1438         wp_update_post( array(
    1439             'ID'            => $destination_topic_id,
    1440             'post_date'     => $destination_post_date,
    1441             'post_date_gmt' => get_gmt_from_date( $destination_post_date )
    1442         ) );
     1467        wp_update_post(
     1468            array(
     1469                'ID'            => $destination_topic_id,
     1470                'post_date'     => $destination_post_date,
     1471                'post_date_gmt' => get_gmt_from_date( $destination_post_date )
     1472            )
     1473        );
    14431474    }
    14441475
     
    14511482
    14521483    // Fix orphaned children
    1453     $children = get_posts( array(
    1454         'post_type'  => bbp_get_reply_post_type(),
    1455         'meta_key'   => '_bbp_reply_to',
    1456         'meta_type'  => 'NUMERIC',
    1457         'meta_value' => $move_reply->ID,
    1458     ) );
     1484    $children = get_posts(
     1485        array(
     1486            'post_type'  => bbp_get_reply_post_type(),
     1487            'meta_key'   => '_bbp_reply_to',
     1488            'meta_type'  => 'NUMERIC',
     1489            'meta_value' => $move_reply->ID,
     1490        )
     1491    );
     1492
    14591493    foreach ( $children as $child ) {
    14601494        bbp_update_reply_to( $child->ID, $parent );
     
    15771611
    15781612    // Do the reply toggling
    1579     $retval = bbp_toggle_reply( array(
    1580         'id'         => $reply_id,
    1581         'action'     => $action,
    1582         'sub_action' => $sub_action,
    1583         'data'       => $post_data
    1584     ) );
     1613    $retval = bbp_toggle_reply(
     1614        array(
     1615            'id'         => $reply_id,
     1616            'action'     => $action,
     1617            'sub_action' => $sub_action,
     1618            'data'       => $post_data
     1619        )
     1620    );
    15851621
    15861622    // Do additional reply toggle actions
     
    16131649
    16141650    // Parse the arguments
    1615     $r = bbp_parse_args( $args, array(
    1616         'id'         => 0,
    1617         'action'     => '',
    1618         'sub_action' => '',
    1619         'data'       => array()
    1620     ) );
     1651    $r = bbp_parse_args(
     1652        $args,
     1653        array(
     1654            'id'         => 0,
     1655            'action'     => '',
     1656            'sub_action' => '',
     1657            'data'       => array()
     1658        )
     1659    );
    16211660
    16221661    // Build the nonce suffix
     
    17131752
    17141753    // Filter & return
    1715     return (array) apply_filters( 'bbp_get_reply_statuses', array(
    1716         bbp_get_public_status_id()  => _x( 'Publish', 'Publish the reply',     'bbpress' ),
    1717         bbp_get_spam_status_id()    => _x( 'Spam',    'Spam the reply',        'bbpress' ),
    1718         bbp_get_trash_status_id()   => _x( 'Trash',   'Trash the reply',       'bbpress' ),
    1719         bbp_get_pending_status_id() => _x( 'Pending', 'Mark reply as pending', 'bbpress' )
    1720     ), $reply_id );
     1754    return (array) apply_filters(
     1755        'bbp_get_reply_statuses',
     1756        array(
     1757            bbp_get_public_status_id()  => _x( 'Publish', 'Publish the reply',     'bbpress' ),
     1758            bbp_get_spam_status_id()    => _x( 'Spam',    'Spam the reply',        'bbpress' ),
     1759            bbp_get_trash_status_id()   => _x( 'Trash',   'Trash the reply',       'bbpress' ),
     1760            bbp_get_pending_status_id() => _x( 'Pending', 'Mark reply as pending', 'bbpress' )
     1761        ),
     1762        $reply_id
     1763    );
    17211764}
    17221765
     
    17331776
    17341777    // Filter & return
    1735     return (array) apply_filters( 'bbp_get_toggle_reply_actions', array(
    1736         'bbp_toggle_reply_spam',
    1737         'bbp_toggle_reply_trash',
    1738         'bbp_toggle_reply_approve'
    1739     ), $reply_id );
     1778    return (array) apply_filters(
     1779        'bbp_get_toggle_reply_actions',
     1780        array(
     1781            'bbp_toggle_reply_spam',
     1782            'bbp_toggle_reply_trash',
     1783            'bbp_toggle_reply_approve'
     1784        ),
     1785        $reply_id
     1786    );
    17401787}
    17411788
     
    22302277        <link><?php self_link(); ?></link>
    22312278        <description><?php //?></description><?php // phpcs:ignore ?>
    2232         <lastBuildDate><?php echo date( 'r' ); ?></lastBuildDate>
     2279        <lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate>
    22332280        <generator><?php echo esc_url_raw( 'https://bbpress.org/?v=' . convert_chars( bbp_get_version() ) ); ?></generator>
    22342281        <language><?php bloginfo_rss( 'language' ); ?></language>
     
    22552302                                    __( 'Replies: %s', 'bbpress' ),
    22562303                                    bbp_get_topic_reply_count()
    2257                                     );
     2304                                );
    22582305                                ?>
    22592306                            </p>
     
    24202467                // Reverse replies array and search for current reply position
    24212468                $topic_replies  = array_reverse( $topic_replies );
    2422                 $reply_position = array_search( (string) $reply_id, $topic_replies );
     2469                $reply_position = array_search( $reply_id, $topic_replies, true );
    24232470
    24242471                // Bump the position to compensate for the lead topic post
    2425                 $reply_position++;
     2472                ++$reply_position;
    24262473            }
    24272474        }
     
    24762523
    24772524    // Parse arguments
    2478     $r = bbp_parse_args( $args, array(
    2479         'walker'       => new BBP_Walker_Reply(),
    2480         'max_depth'    => bbp_thread_replies_depth(),
    2481         'style'        => 'ul',
    2482         'callback'     => null,
    2483         'end_callback' => null,
    2484         'page'         => 1,
    2485         'per_page'     => -1
    2486     ), 'list_replies' );
     2525    $r = bbp_parse_args(
     2526        $args,
     2527        array(
     2528            'walker'       => new BBP_Walker_Reply(),
     2529            'max_depth'    => bbp_thread_replies_depth(),
     2530            'style'        => 'ul',
     2531            'callback'     => null,
     2532            'end_callback' => null,
     2533            'page'         => 1,
     2534            'per_page'     => -1
     2535        ),
     2536        'list_replies'
     2537    );
    24872538
    24882539    // Allowed styles (supported by BBP_Walker_Reply)
Note: See TracChangeset for help on using the changeset viewer.