Make WordPress Core

Changeset 62934


Ignore:
Timestamp:
07/29/2026 09:31:15 PM (3 months ago)
Author:
westonruter
Message:

Docs: Attach three hook doc comments to their filter calls.

Hook documentation is located by adjacency: the docblock must be the last thing before the line containing the apply_filters() or do_action() call, as established in r46088. In three places it was not, so the comment documented nothing.

  • In wp-admin/includes/ms.php the reference comment for users_have_additional_content was opened with /* rather than /**, making it an ordinary block comment instead of a docblock.
  • In wp-admin/includes/template.php the reference comment for editable_slug sat in the middle of a string concatenation, attached to no statement at all; the filter is now applied on its own line and the result interpolated.
  • In wp-includes/abilities-api/class-wp-ability.php the sentinel assignment sat between the wp_pre_execute_ability docblock and the call it documents, so the docblock attached to the assignment; the assignment is hoisted above the docblock.

None of this changes behavior. The filters run with the same arguments, in the same order, and produce the same output.

These comments were surfaced by the PHPStan extensions under development for this ticket, which resolve a hook's documentation the same way the parser behind the developer handbook does, and which are committed separately.

Developed as subset of ​https://github.com/WordPress/wordpress-develop/pull/12022.
Follow-up to r27237, r46088, r62397, r62688.

See #65376, #64896.

Location:
trunk/src
Files:
3 edited

Legend:

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

    r62688 r62934  
    940940                                                $user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
    941941                                                switch_to_blog( $details->userblog_id );
    942                                                 /* This filter is documented in wp-admin/users.php */
     942                                                /** This filter is documented in wp-admin/users.php */
    943943                                                $user_has_content = (bool) apply_filters( 'users_have_additional_content', false, array( $delete_user->ID ) );
    944944
  • trunk/src/wp-admin/includes/template.php

    r62816 r62934  
    317317        $title = esc_textarea( trim( $post->post_title ) );
    318318
     319        /** This filter is documented in wp-admin/edit-tag-form.php */
     320        $editable_slug = apply_filters( 'editable_slug', $post->post_name, $post );
     321
    319322        echo '
    320323<div class="hidden" id="inline_' . $post->ID . '">
    321         <div class="post_title">' . $title . '</div>' .
    322         /** This filter is documented in wp-admin/edit-tag-form.php */
    323         '<div class="post_name">' . apply_filters( 'editable_slug', $post->post_name, $post ) . '</div>
     324        <div class="post_title">' . $title . '</div>
     325        <div class="post_name">' . $editable_slug . '</div>
    324326        <div class="post_author">' . $post->post_author . '</div>
    325327        <div class="comment_status">' . esc_html( $post->comment_status ) . '</div>
  • trunk/src/wp-includes/abilities-api/class-wp-ability.php

    r62737 r62934  
    783783                do_action( 'wp_ability_invoked', $this->name, $input, $this );
    784784
     785                $pre_execute_sentinel = new WP_Filter_Sentinel();
     786
    785787                /**
    786788                 * Filters whether to short-circuit ability execution.
    … …  
    805807                 * @param WP_Ability $ability      The ability instance.
    806808                 */
    807                 $pre_execute_sentinel = new WP_Filter_Sentinel();
    808                 $pre                  = apply_filters( 'wp_pre_execute_ability', $pre_execute_sentinel, $this->name, $input, $this );
     809                $pre = apply_filters( 'wp_pre_execute_ability', $pre_execute_sentinel, $this->name, $input, $this );
    809810                if ( $pre !== $pre_execute_sentinel ) {
    810811                        return $pre;
Note: See TracChangeset for help on using the changeset viewer.