Make WordPress Core


Ignore:
Timestamp:
09/25/2023 03:34:34 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Fix a few newly introduced WPCS issues.

Follow-up to [56570], [56573], [56589], [56604], [56612], [56620], [56629], [56631], [56638], [56642], [56644], [56649].

Props jrf.
See #59161, #58831.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r56678 r56680  
    791791     * `first_child`, respectively, to the serialized markup for the given block.
    792792     *
    793      * @param array $block  The block to inject the theme attribute into, and hooked blocks before.
    794      * @param array $parent The parent block of the given block.
    795      * @param array $prev   The previous sibling block of the given block.
     793     * @param array $block        The block to inject the theme attribute into, and hooked blocks before.
     794     * @param array $parent_block The parent block of the given block.
     795     * @param array $prev         The previous sibling block of the given block.
    796796     * @return string The serialized markup for the given block, with the markup for any hooked blocks prepended to it.
    797797     */
    798     return function( &$block, $parent = null, $prev = null ) use ( $context ) {
     798    return function ( &$block, $parent_block = null, $prev = null ) use ( $context ) {
    799799        _inject_theme_attribute_in_template_part_block( $block );
    800800
    801801        $markup = '';
    802802
    803         if ( $parent && ! $prev ) {
     803        if ( $parent_block && ! $prev ) {
    804804            // Candidate for first-child insertion.
    805805            $relative_position  = 'first_child';
    806             $anchor_block_type  = $parent['blockName'];
     806            $anchor_block_type  = $parent_block['blockName'];
    807807            $hooked_block_types = array_keys( get_hooked_blocks( $anchor_block_type, $relative_position ) );
    808808            /**
     
    857857     * `last_child`, respectively, to the serialized markup for the given block.
    858858     *
    859      * @param array $block  The block to inject the hooked blocks after.
    860      * @param array $parent The parent block of the given block.
    861      * @param array $next   The next sibling block of the given block.
     859     * @param array $block        The block to inject the hooked blocks after.
     860     * @param array $parent_block The parent block of the given block.
     861     * @param array $next         The next sibling block of the given block.
    862862     * @return string The serialized markup for the given block, with the markup for any hooked blocks appended to it.
    863863     */
    864     return function( &$block, $parent = null, $next = null ) use ( $context ) {
     864    return function ( &$block, $parent_block = null, $next = null ) use ( $context ) {
    865865        $markup = '';
    866866
     
    874874        }
    875875
    876         if ( $parent && ! $next ) {
     876        if ( $parent_block && ! $next ) {
    877877            // Candidate for last-child insertion.
    878878            $relative_position  = 'last_child';
    879             $anchor_block_type  = $parent['blockName'];
     879            $anchor_block_type  = $parent_block['blockName'];
    880880            $hooked_block_types = array_keys( get_hooked_blocks( $anchor_block_type, $relative_position ) );
    881881            /** This filter is documented in wp-includes/blocks.php */
     
    10601060                    ? null
    10611061                    : $block['innerBlocks'][ $block_index - 1 ];
     1062
    10621063                $block_content .= call_user_func_array(
    10631064                    $pre_callback,
     
    10721073                    ? null
    10731074                    : $block['innerBlocks'][ $block_index + 1 ];
     1075
    10741076                $block_content .= call_user_func_array(
    10751077                    $post_callback,
     
    10771079                );
    10781080            }
    1079             $block_index++;
     1081            ++$block_index;
    10801082        }
    10811083    }
     
    11311133                ? null
    11321134                : $blocks[ $index - 1 ];
     1135
    11331136            $result .= call_user_func_array(
    11341137                $pre_callback,
     
    11361139            );
    11371140        }
     1141
    11381142        $result .= traverse_and_serialize_block( $block, $pre_callback, $post_callback );
     1143
    11391144        if ( is_callable( $post_callback ) ) {
    11401145            $next = count( $blocks ) - 1 === $index
    11411146                ? null
    11421147                : $blocks[ $index + 1 ];
     1148
    11431149            $result .= call_user_func_array(
    11441150                $post_callback,
     
    11471153        }
    11481154    }
     1155
    11491156    return $result;
    11501157}
Note: See TracChangeset for help on using the changeset viewer.