Make WordPress Core


Ignore:
Timestamp:
09/10/2019 07:22:07 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Docs: Fix placement of some duplicate hook references.

Hook documentation should be on the line directly above the line containing the do_action() or apply_filters() call. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of duplicate hook references.

Includes minor code layout fixes.

See #47110.

File:
1 edited

Legend:

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

    r45932 r46088  
    40434043                $mid_size = 2;
    40444044        }
     4045
    40454046        $add_args   = $args['add_args'];
    40464047        $r          = '';
    … …  
    40564057                $link .= $args['add_fragment'];
    40574058
    4058                 /**
    4059                  * Filters the paginated links for the given archive pages.
    4060                  *
    4061                  * @since 3.0.0
    4062                  *
    4063                  * @param string $link The paginated link URL.
    4064                  */
    4065                 $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
     4059                $page_links[] = sprintf(
     4060                        '<a class="prev page-numbers" href="%s">%s</a>',
     4061                        /**
     4062                         * Filters the paginated links for the given archive pages.
     4063                         *
     4064                         * @since 3.0.0
     4065                         *
     4066                         * @param string $link The paginated link URL.
     4067                         */
     4068                        esc_url( apply_filters( 'paginate_links', $link ) ),
     4069                        $args['prev_text']
     4070                );
    40664071        endif;
     4072
    40674073        for ( $n = 1; $n <= $total; $n++ ) :
    40684074                if ( $n == $current ) :
    4069                         $page_links[] = "<span aria-current='" . esc_attr( $args['aria_current'] ) . "' class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . '</span>';
     4075                        $page_links[] = sprintf(
     4076                                '<span aria-current="%s" class="page-numbers current">%s</span>',
     4077                                esc_attr( $args['aria_current'] ),
     4078                                $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number']
     4079                        );
    40704080                        $dots         = true;
    40714081                else :
    … …  
    40784088                                $link .= $args['add_fragment'];
    40794089
    4080                                 /** This filter is documented in wp-includes/general-template.php */
    4081                                 $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . '</a>';
     4090                                $page_links[] = sprintf(
     4091                                        '<a class="page-numbers" href="%s">%s</a>',
     4092                                        /** This filter is documented in wp-includes/general-template.php */
     4093                                        esc_url( apply_filters( 'paginate_links', $link ) ),
     4094                                        $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number']
     4095                                );
    40824096                                $dots         = true;
    40834097                        elseif ( $dots && ! $args['show_all'] ) :
    … …  
    40874101                endif;
    40884102        endfor;
     4103
    40894104        if ( $args['prev_next'] && $current && $current < $total ) :
    40904105                $link = str_replace( '%_%', $args['format'], $args['base'] );
    … …  
    40954110                $link .= $args['add_fragment'];
    40964111
    4097                 /** This filter is documented in wp-includes/general-template.php */
    4098                 $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
     4112                $page_links[] = sprintf(
     4113                        '<a class="next page-numbers" href="%s">%s</a>',
     4114                        /** This filter is documented in wp-includes/general-template.php */
     4115                        esc_url( apply_filters( 'paginate_links', $link ) ),
     4116                        $args['next_text']
     4117                );
    40994118        endif;
     4119
    41004120        switch ( $args['type'] ) {
    41014121                case 'array':
    … …  
    41124132                        break;
    41134133        }
     4134
    41144135        return $r;
    41154136}
    … …  
    43234344 */
    43244345function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
    4325         // For backward compatibility
     4346        // For backward compatibility.
    43264347        $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
    43274348
    43284349        if ( wp_styles()->query( $handle ) ) {
    4329                 if ( $force_echo || did_action( 'wp_print_styles' ) ) { // we already printed the style queue. Print this one immediately
     4350                if ( $force_echo || did_action( 'wp_print_styles' ) ) {
     4351                        // We already printed the style queue. Print this one immediately.
    43304352                        wp_print_styles( $handle );
    4331                 } else { // Add to style queue
     4353                } else {
     4354                        // Add to style queue.
    43324355                        wp_enqueue_style( $handle );
    43334356                }
    43344357                return;
    43354358        }
     4359
     4360        $stylesheet_link = sprintf(
     4361                "<link rel='stylesheet' href='%s' type='text/css' />\n",
     4362                esc_url( wp_admin_css_uri( $file ) )
     4363        );
    43364364
    43374365        /**
    … …  
    43464374         *                                relative to wp-admin/. Defaults to 'wp-admin'.
    43474375         */
    4348         echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
     4376        echo apply_filters( 'wp_admin_css', $stylesheet_link, $file );
    43494377
    43504378        if ( function_exists( 'is_rtl' ) && is_rtl() ) {
     4379                $rtl_stylesheet_link = sprintf(
     4380                        "<link rel='stylesheet' href='%s' type='text/css' />\n",
     4381                        esc_url( wp_admin_css_uri( "$file-rtl" ) )
     4382                );
     4383
    43514384                /** This filter is documented in wp-includes/general-template.php */
    4352                 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
     4385                echo apply_filters( 'wp_admin_css', $rtl_stylesheet_link, "$file-rtl" );
    43534386        }
    43544387}
Note: See TracChangeset for help on using the changeset viewer.