Skip to content

Commit 6552d95

Browse files
committed
General: Backport several commits for release.
- Embeds: Ensure that the title attribute is set correctly on embeds. - Editor: Prevent HTML decoding on by setting the proper editor context. - Formatting: Ensure that wp_validate_redirect() sanitizes a wider variety of characters. - Themes: Ensure a broken theme name is returned properly. - Administration: Add a new filter to extend set-screen-option. Merges [47947-47951] to the 4.5 branch. Props xknown, sstoqnov, vortfu, SergeyBiryukov, whyisjake. git-svn-id: https://develop.svn.wordpress.org/branches/4.5@47973 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5c08ae5 commit 6552d95

4 files changed

Lines changed: 36 additions & 11 deletions

File tree

src/wp-admin/includes/media.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,8 +2794,11 @@ function edit_form_image_editor( $post ) {
27942794
<label for="attachment_content"><strong><?php _e( 'Description' ); ?></strong><?php
27952795
if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
27962796
echo ': ' . __( 'Displayed on attachment pages.' );
2797-
} ?></label>
2798-
<?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
2797+
}
2798+
2799+
?>
2800+
</label>
2801+
<?php wp_editor( format_to_edit( $post->post_content ), 'attachment_content', $editor_args ); ?>
27992802

28002803
</div>
28012804
<?php

src/wp-admin/includes/misc.php

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,24 +436,46 @@ function set_screen_options() {
436436
return;
437437
break;
438438
default:
439+
if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
440+
/**
441+
* Filters a screen option value before it is set.
442+
*
443+
* The filter can also be used to modify non-standard [items]_per_page
444+
* settings. See the parent function for a full list of standard options.
445+
*
446+
* Returning false to the filter will skip saving the current option.
447+
*
448+
* @since 2.8.0
449+
* @since 5.4.2 Only applied to options ending with '_page',
450+
* or the 'layout_columns' option.
451+
*
452+
* @see set_screen_options()
453+
*
454+
* @param bool $keep Whether to save or skip saving the screen option value.
455+
* Default false.
456+
* @param string $option The option name.
457+
* @param int $value The number of rows to use.
458+
*/
459+
$value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
460+
}
439461

440462
/**
441463
* Filter a screen option value before it is set.
442464
*
443-
* The filter can also be used to modify non-standard [items]_per_page
444-
* settings. See the parent function for a full list of standard options.
465+
* The dynamic portion of the hook, `$option`, refers to the option name.
445466
*
446467
* Returning false to the filter will skip saving the current option.
447468
*
448-
* @since 2.8.0
469+
* @since 5.4.2
449470
*
450471
* @see set_screen_options()
451472
*
452-
* @param bool|int $value Screen option value. Default false to skip.
453-
* @param string $option The option name.
454-
* @param int $value The number of rows to use.
473+
* @param bool $keep Whether to save or skip saving the screen option value.
474+
* Default false.
475+
* @param string $option The option name.
476+
* @param int $value The number of rows to use.
455477
*/
456-
$value = apply_filters( 'set-screen-option', false, $option, $value );
478+
$value = apply_filters( "set_screen_option_{$option}", false, $option, $value );
457479

458480
if ( false === $value )
459481
return;

src/wp-admin/themes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@
314314
</tr>
315315
<?php foreach ( $broken_themes as $broken_theme ) : ?>
316316
<tr>
317-
<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?></td>
317+
<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
318318
<td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
319319
<?php
320320
if ( $can_delete ) {

src/wp-includes/pluggable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ function wp_safe_redirect($location, $status = 302) {
12741274
* @return string redirect-sanitized URL
12751275
**/
12761276
function wp_validate_redirect($location, $default = '') {
1277-
$location = trim( $location, " \t\n\r\0\x08\x0B" );
1277+
$location = wp_sanitize_redirect( trim( $location, " \t\n\r\0\x08\x0B" ) );
12781278
// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
12791279
if ( substr($location, 0, 2) == '//' )
12801280
$location = 'http:' . $location;

0 commit comments

Comments
 (0)