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. Built from https://develop.svn.wordpress.org/trunk@45694 git-svn-id: http://core.svn.wordpress.org/trunk@45505 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7a4d1b5dbd
commit
67e5038470
|
@ -79,6 +79,9 @@ function extract_from_markers( $filename, $marker ) {
|
|||
$state = false;
|
||||
}
|
||||
if ( $state ) {
|
||||
if ( '#' === substr( $markerline, 0, 1 ) ) {
|
||||
continue;
|
||||
}
|
||||
$result[] = $markerline;
|
||||
}
|
||||
if ( false !== strpos( $markerline, '# BEGIN ' . $marker ) ) {
|
||||
|
@ -119,6 +122,37 @@ function insert_with_markers( $filename, $marker, $insertion ) {
|
|||
$insertion = explode( "\n", $insertion );
|
||||
}
|
||||
|
||||
$switched_locale = switch_to_locale( get_locale() );
|
||||
|
||||
$instructions = sprintf(
|
||||
/* translators: 1: marker */
|
||||
__( 'The directives (lines) between `BEGIN %1$s` and `END %1$s` are
|
||||
dynamically generated, and should only be modified via WordPress filters.
|
||||
Any changes to the directives between these markers will be overwritten.' ),
|
||||
$marker
|
||||
);
|
||||
|
||||
$instructions = explode( "\n", $instructions );
|
||||
foreach ( $instructions as $line => $text ) {
|
||||
$instructions[ $line ] = '# ' . $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the inline instructions inserted before the dynamically generated content.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*
|
||||
* @param string[] $instructions Array of lines with inline instructions.
|
||||
* @param string $marker The marker being inserted.
|
||||
*/
|
||||
$instructions = apply_filters( 'insert_with_markers_inline_instructions', $instructions, $marker );
|
||||
|
||||
if ( $switched_locale ) {
|
||||
restore_previous_locale();
|
||||
}
|
||||
|
||||
$insertion = array_merge( $instructions, $insertion );
|
||||
|
||||
$start_marker = "# BEGIN {$marker}";
|
||||
$end_marker = "# END {$marker}";
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.3-alpha-45693';
|
||||
$wp_version = '5.3-alpha-45694';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue