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/common/widgets.php

    r7374 r7378  
    3030     */
    3131    public function __construct() {
    32         $widget_ops = apply_filters( 'bbp_login_widget_options', array(
    33             'classname'                   => 'bbp_widget_login',
    34             'description'                 => esc_html__( 'A simple login form with optional links to sign-up and lost password pages.', 'bbpress' ),
    35             'customize_selective_refresh' => true
    36         ) );
     32        $widget_ops = apply_filters(
     33            'bbp_login_widget_options',
     34            array(
     35                'classname'                   => 'bbp_widget_login',
     36                'description'                 => esc_html__( 'A simple login form with optional links to sign-up and lost password pages.', 'bbpress' ),
     37                'customize_selective_refresh' => true
     38            )
     39        );
    3740
    3841        parent::__construct( false, esc_html__( '(bbPress) Login Widget', 'bbpress' ), $widget_ops );
     
    153156    public function update( $new_instance, $old_instance ) {
    154157        $instance             = $old_instance;
    155         $instance['title']    = strip_tags( $new_instance['title'] );
     158        $instance['title']    = wp_strip_all_tags( $new_instance['title'] );
    156159        $instance['register'] = esc_url_raw( $new_instance['register'] );
    157160        $instance['lostpass'] = esc_url_raw( $new_instance['lostpass'] );
     
    198201     */
    199202    public function parse_settings( $instance = array() ) {
    200         return bbp_parse_args( $instance, array(
    201             'title'    => '',
    202             'register' => '',
    203             'lostpass' => ''
    204         ), 'login_widget_settings' );
     203        return bbp_parse_args(
     204            $instance,
     205            array(
     206                'title'    => '',
     207                'register' => '',
     208                'lostpass' => ''
     209            ),
     210            'login_widget_settings'
     211        );
    205212    }
    206213}
     
    223230     */
    224231    public function __construct() {
    225         $widget_ops = apply_filters( 'bbp_views_widget_options', array(
    226             'classname'                   => 'widget_display_views',
    227             'description'                 => esc_html__( 'A list of registered optional topic views.', 'bbpress' ),
    228             'customize_selective_refresh' => true
    229         ) );
     232        $widget_ops = apply_filters(
     233            'bbp_views_widget_options',
     234            array(
     235                'classname'                   => 'widget_display_views',
     236                'description'                 => esc_html__( 'A list of registered optional topic views.', 'bbpress' ),
     237                'customize_selective_refresh' => true
     238            )
     239        );
    230240
    231241        parent::__construct( false, esc_html__( '(bbPress) Topic Views List', 'bbpress' ), $widget_ops );
     
    300310    public function update( $new_instance = array(), $old_instance = array() ) {
    301311        $instance          = $old_instance;
    302         $instance['title'] = strip_tags( $new_instance['title'] );
     312        $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
    303313
    304314        return $instance;
     
    334344     */
    335345    public function parse_settings( $instance = array() ) {
    336         return bbp_parse_args( $instance, array(
    337             'title' => ''
    338         ), 'view_widget_settings' );
     346        return bbp_parse_args(
     347            $instance,
     348            array(
     349                'title' => ''
     350            ),
     351            'view_widget_settings'
     352        );
    339353    }
    340354}
     
    357371     */
    358372    public function __construct() {
    359         $widget_ops = apply_filters( 'bbp_search_widget_options', array(
    360             'classname'                   => 'widget_display_search',
    361             'description'                 => esc_html__( 'The bbPress forum search form.', 'bbpress' ),
    362             'customize_selective_refresh' => true
    363         ) );
     373        $widget_ops = apply_filters(
     374            'bbp_search_widget_options',
     375            array(
     376                'classname'                   => 'widget_display_search',
     377                'description'                 => esc_html__( 'The bbPress forum search form.', 'bbpress' ),
     378                'customize_selective_refresh' => true
     379            )
     380        );
    364381
    365382        parent::__construct( false, esc_html__( '(bbPress) Forum Search Form', 'bbpress' ), $widget_ops );
     
    417434    public function update( $new_instance, $old_instance ) {
    418435        $instance          = $old_instance;
    419         $instance['title'] = strip_tags( $new_instance['title'] );
     436        $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
    420437
    421438        return $instance;
     
    451468     */
    452469    public function parse_settings( $instance = array() ) {
    453         return bbp_parse_args( $instance, array(
    454             'title' => esc_html__( 'Search Forums', 'bbpress' )
    455         ), 'search_widget_settings' );
     470        return bbp_parse_args(
     471            $instance,
     472            array(
     473                'title' => esc_html__( 'Search Forums', 'bbpress' )
     474            ),
     475            'search_widget_settings'
     476        );
    456477    }
    457478}
     
    474495     */
    475496    public function __construct() {
    476         $widget_ops = apply_filters( 'bbp_forums_widget_options', array(
    477             'classname'                   => 'widget_display_forums',
    478             'description'                 => esc_html__( 'A list of forums with an option to set the parent.', 'bbpress' ),
    479             'customize_selective_refresh' => true
    480         ) );
     497        $widget_ops = apply_filters(
     498            'bbp_forums_widget_options',
     499            array(
     500                'classname'                   => 'widget_display_forums',
     501                'description'                 => esc_html__( 'A list of forums with an option to set the parent.', 'bbpress' ),
     502                'customize_selective_refresh' => true
     503            )
     504        );
    481505
    482506        parent::__construct( false, esc_html__( '(bbPress) Forums List', 'bbpress' ), $widget_ops );
     
    513537        // Note: private and hidden forums will be excluded via the
    514538        // bbp_pre_get_posts_normalize_forum_visibility action and function.
    515         $widget_query = new WP_Query( array(
    516 
    517             // What and how
    518             'post_type'      => bbp_get_forum_post_type(),
    519             'post_status'    => bbp_get_public_status_id(),
    520             'post_parent'    => $settings['parent_forum'],
    521             'posts_per_page' => (int) get_option( '_bbp_forums_per_page', 50 ),
    522 
    523             // Order
    524             'orderby' => 'menu_order title',
    525             'order'   => 'ASC',
    526 
    527             // Performance
    528             'ignore_sticky_posts'    => true,
    529             'no_found_rows'          => true,
    530             'update_post_term_cache' => false,
    531             'update_post_meta_cache' => false
    532         ) );
     539        $widget_query = new WP_Query(
     540            array(
     541
     542                // What and how
     543                'post_type'      => bbp_get_forum_post_type(),
     544                'post_status'    => bbp_get_public_status_id(),
     545                'post_parent'    => $settings['parent_forum'],
     546                'posts_per_page' => (int) get_option( '_bbp_forums_per_page', 50 ),
     547
     548                // Order
     549                'orderby' => 'menu_order title',
     550                'order'   => 'ASC',
     551
     552                // Performance
     553                'ignore_sticky_posts'    => true,
     554                'no_found_rows'          => true,
     555                'update_post_term_cache' => false,
     556                'update_post_meta_cache' => false
     557            )
     558        );
    533559
    534560        // Bail if no posts
     
    573599    public function update( $new_instance, $old_instance ) {
    574600        $instance                 = $old_instance;
    575         $instance['title']        = strip_tags( $new_instance['title'] );
     601        $instance['title']        = wp_strip_all_tags( $new_instance['title'] );
    576602        $instance['parent_forum'] = sanitize_text_field( $new_instance['parent_forum'] );
    577603
     
    623649     */
    624650    public function parse_settings( $instance = array() ) {
    625         return bbp_parse_args( $instance, array(
    626             'title'        => esc_html__( 'Forums', 'bbpress' ),
    627             'parent_forum' => 0
    628         ), 'forum_widget_settings' );
     651        return bbp_parse_args(
     652            $instance,
     653            array(
     654                'title'        => esc_html__( 'Forums', 'bbpress' ),
     655                'parent_forum' => 0
     656            ),
     657            'forum_widget_settings'
     658        );
    629659    }
    630660}
     
    647677     */
    648678    public function __construct() {
    649         $widget_ops = apply_filters( 'bbp_topics_widget_options', array(
    650             'classname'                   => 'widget_display_topics',
    651             'description'                 => esc_html__( 'A list of recent topics, sorted by: newness, popularity, or recent replies.', 'bbpress' ),
    652             'customize_selective_refresh' => true
    653         ) );
     679        $widget_ops = apply_filters(
     680            'bbp_topics_widget_options',
     681            array(
     682                'classname'                   => 'widget_display_topics',
     683                'description'                 => esc_html__( 'A list of recent topics, sorted by: newness, popularity, or recent replies.', 'bbpress' ),
     684                'customize_selective_refresh' => true
     685            )
     686        );
    654687
    655688        parent::__construct( false, esc_html__( '(bbPress) Recent Topics', 'bbpress' ), $widget_ops );
     
    696729                    'post_parent'    => $settings['parent_forum'],
    697730                    'posts_per_page' => (int) $settings['max_shown'],
    698                     'meta_query'     => array( 
     731                    'meta_query'     => array(
    699732                        array(
    700733                            'key'  => '_bbp_last_active_time',
    701734                            'type' => 'DATETIME'
    702                         ) 
     735                        )
    703736                    ),
    704737
     
    724757                    'post_parent'    => $settings['parent_forum'],
    725758                    'posts_per_page' => (int) $settings['max_shown'],
    726                     'meta_query'     => array( 
     759                    'meta_query'     => array(
    727760                        array(
    728761                            'key'  => '_bbp_reply_count',
    729762                            'type' => 'NUMERIC'
    730                         ) 
     763                        )
    731764                    ),
    732765
     
    795828                // Maybe get the topic author
    796829                if ( ! empty( $settings['show_user'] ) ) :
    797                     $author_link = bbp_get_topic_author_link( array(
    798                         'post_id' => $topic_id,
    799                         'type'    => 'both',
    800                         'size'    => 14
    801                     ) );
     830                    $author_link = bbp_get_topic_author_link(
     831                        array(
     832                            'post_id' => $topic_id,
     833                            'type'    => 'both',
     834                            'size'    => 14
     835                        )
     836                    );
    802837                endif; ?>
    803838
     
    807842                    <?php if ( ! empty( $author_link ) ) : ?>
    808843
    809                         <?php 
    810                         printf( 
     844                        <?php
     845                        printf(
    811846                            /* translators: %1$s: Topic author link wrapped in span tag */
    812                             esc_html_x( 'by %1$s', 'widgets', 'bbpress' ), '<span class="topic-author">' . $author_link . '</span>'
    813                         );
     847                            esc_html_x( 'by %1$s', 'widgets', 'bbpress' ),
     848                            '<span class="topic-author">' . $author_link . '</span>'
     849                        );
    814850                        ?>
    815851
     
    847883    public function update( $new_instance = array(), $old_instance = array() ) {
    848884        $instance                 = $old_instance;
    849         $instance['title']        = strip_tags( $new_instance['title'] );
    850         $instance['order_by']     = strip_tags( $new_instance['order_by'] );
     885        $instance['title']        = wp_strip_all_tags( $new_instance['title'] );
     886        $instance['order_by']     = wp_strip_all_tags( $new_instance['order_by'] );
    851887        $instance['parent_forum'] = sanitize_text_field( $new_instance['parent_forum'] );
    852888        $instance['max_shown']    = (int) $new_instance['max_shown'];
     
    918954     */
    919955    public function parse_settings( $instance = array() ) {
    920         return bbp_parse_args( $instance, array(
    921             'title'        => esc_html__( 'Recent Topics', 'bbpress' ),
    922             'max_shown'    => 5,
    923             'show_date'    => false,
    924             'show_user'    => false,
    925             'parent_forum' => 'any',
    926             'order_by'     => false
    927         ), 'topic_widget_settings' );
     956        return bbp_parse_args(
     957            $instance,
     958            array(
     959                'title'        => esc_html__( 'Recent Topics', 'bbpress' ),
     960                'max_shown'    => 5,
     961                'show_date'    => false,
     962                'show_user'    => false,
     963                'parent_forum' => 'any',
     964                'order_by'     => false
     965            ),
     966            'topic_widget_settings'
     967        );
    928968    }
    929969}
     
    946986     */
    947987    public function __construct() {
    948         $widget_ops = apply_filters( 'bbp_stats_widget_options', array(
    949             'classname'                   => 'widget_display_stats',
    950             'description'                 => esc_html__( 'Some statistics from your forum.', 'bbpress' ),
    951             'customize_selective_refresh' => true
    952         ) );
     988        $widget_ops = apply_filters(
     989            'bbp_stats_widget_options',
     990            array(
     991                'classname'                   => 'widget_display_stats',
     992                'description'                 => esc_html__( 'Some statistics from your forum.', 'bbpress' ),
     993                'customize_selective_refresh' => true
     994            )
     995        );
    953996
    954997        parent::__construct( false, esc_html__( '(bbPress) Statistics', 'bbpress' ), $widget_ops );
     
    10061049    public function update( $new_instance, $old_instance ) {
    10071050        $instance          = $old_instance;
    1008         $instance['title'] = strip_tags( $new_instance['title'] );
     1051        $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
    10091052
    10101053        return $instance;
     
    10421085     */
    10431086    public function parse_settings( $instance = array() ) {
    1044         return bbp_parse_args( $instance, array(
    1045             'title' => esc_html__( 'Forum Statistics', 'bbpress' )
    1046         ), 'stats_widget_settings' );
     1087        return bbp_parse_args(
     1088            $instance,
     1089            array(
     1090                'title' => esc_html__( 'Forum Statistics', 'bbpress' )
     1091            ),
     1092            'stats_widget_settings'
     1093        );
    10471094    }
    10481095}
     
    10651112     */
    10661113    public function __construct() {
    1067         $widget_ops = apply_filters( 'bbp_replies_widget_options', array(
    1068             'classname'                   => 'widget_display_replies',
    1069             'description'                 => esc_html__( 'A list of the most recent replies.', 'bbpress' ),
    1070             'customize_selective_refresh' => true
    1071         ) );
     1114        $widget_ops = apply_filters(
     1115            'bbp_replies_widget_options',
     1116            array(
     1117                'classname'                   => 'widget_display_replies',
     1118                'description'                 => esc_html__( 'A list of the most recent replies.', 'bbpress' ),
     1119                'customize_selective_refresh' => true
     1120            )
     1121        );
    10721122
    10731123        parent::__construct( false, esc_html__( '(bbPress) Recent Replies', 'bbpress' ), $widget_ops );
     
    11041154        // Note: private and hidden forums will be excluded via the
    11051155        // bbp_pre_get_posts_normalize_forum_visibility action and function.
    1106         $widget_query = new WP_Query( array(
    1107 
    1108             // What and when
    1109             'post_type'      => bbp_get_reply_post_type(),
    1110             'post_status'    => bbp_get_public_reply_statuses(),
    1111             'posts_per_page' => (int) $settings['max_shown'],
    1112 
    1113             // Performance
    1114             'ignore_sticky_posts'    => true,
    1115             'no_found_rows'          => true,
    1116             'update_post_term_cache' => false,
    1117             'update_post_meta_cache' => false
    1118         ) );
     1156        $widget_query = new WP_Query(
     1157            array(
     1158
     1159                // What and when
     1160                'post_type'      => bbp_get_reply_post_type(),
     1161                'post_status'    => bbp_get_public_reply_statuses(),
     1162                'posts_per_page' => (int) $settings['max_shown'],
     1163
     1164                // Performance
     1165                'ignore_sticky_posts'    => true,
     1166                'no_found_rows'          => true,
     1167                'update_post_term_cache' => false,
     1168                'update_post_meta_cache' => false
     1169            )
     1170        );
    11191171
    11201172        // Bail if no replies
     
    11481200                    // Only query user if showing them
    11491201                    if ( ! empty( $settings['show_user'] ) ) :
    1150                         $author_link = bbp_get_reply_author_link( array(
    1151                             'post_id' => $reply_id,
    1152                             'type'    => 'both',
    1153                             'size'    => 14
    1154                         ) );
     1202                        $author_link = bbp_get_reply_author_link(
     1203                            array(
     1204                                'post_id' => $reply_id,
     1205                                'type'    => 'both',
     1206                                'size'    => 14
     1207                            )
     1208                        );
    11551209                    else :
    11561210                        $author_link = false;
     
    12051259    public function update( $new_instance = array(), $old_instance = array() ) {
    12061260        $instance              = $old_instance;
    1207         $instance['title']     = strip_tags( $new_instance['title'] );
     1261        $instance['title']     = wp_strip_all_tags( $new_instance['title'] );
    12081262        $instance['max_shown'] = (int) $new_instance['max_shown'];
    12091263
     
    12491303     */
    12501304    public function parse_settings( $instance = array() ) {
    1251         return bbp_parse_args( $instance, array(
    1252             'title'     => esc_html__( 'Recent Replies', 'bbpress' ),
    1253             'max_shown' => 5,
    1254             'show_date' => false,
    1255             'show_user' => false
    1256         ), 'replies_widget_settings' );
     1305        return bbp_parse_args(
     1306            $instance,
     1307            array(
     1308                'title'     => esc_html__( 'Recent Replies', 'bbpress' ),
     1309                'max_shown' => 5,
     1310                'show_date' => false,
     1311                'show_user' => false
     1312            ),
     1313            'replies_widget_settings'
     1314        );
    12571315    }
    12581316}
Note: See TracChangeset for help on using the changeset viewer.