WordPress.org

Make WordPress Core

Changeset 45694


Ignore:
Timestamp:
07/28/2019 04:30:46 PM (18 months ago)
Author:
SergeyBiryukov
Message:

Rewrite Rules: Add a comment to # BEGIN/END .htaccess markers to clarify that the directives are dynamically generated, and should only be modified via WordPress filters.

Introduce insert_with_markers_inline_instructions filter to modify the default instructions text.

Props bradleyt, SergeyBiryukov.
Fixes #47466.

File:
1 edited

Legend:

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

    r45599 r45694  
    8080        }
    8181        if ( $state ) {
     82            if ( '#' === substr( $markerline, 0, 1 ) ) {
     83                continue;
     84            }
    8285            $result[] = $markerline;
    8386        }
     
    119122        $insertion = explode( "\n", $insertion );
    120123    }
     124
     125    $switched_locale = switch_to_locale( get_locale() );
     126
     127    $instructions = sprintf(
     128        /* translators: 1: marker */
     129        __( 'The directives (lines) between `BEGIN %1$s` and `END %1$s` are
     130dynamically generated, and should only be modified via WordPress filters.
     131Any changes to the directives between these markers will be overwritten.' ),
     132        $marker
     133    );
     134
     135    $instructions = explode( "\n", $instructions );
     136    foreach ( $instructions as $line => $text ) {
     137        $instructions[ $line ] = '# ' . $text;
     138    }
     139
     140    /**
     141     * Filters the inline instructions inserted before the dynamically generated content.
     142     *
     143     * @since 5.3.0
     144     *
     145     * @param string[] $instructions Array of lines with inline instructions.
     146     * @param string   $marker       The marker being inserted.
     147     */
     148    $instructions = apply_filters( 'insert_with_markers_inline_instructions', $instructions, $marker );
     149
     150    if ( $switched_locale ) {
     151        restore_previous_locale();
     152    }
     153
     154    $insertion = array_merge( $instructions, $insertion );
    121155
    122156    $start_marker = "# BEGIN {$marker}";
Note: See TracChangeset for help on using the changeset viewer.