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 5.1 branch. Props xknown, sstoqnov, vortfu, SergeyBiryukov, whyisjake. Built from https://develop.svn.wordpress.org/branches/5.1@47963 git-svn-id: http://core.svn.wordpress.org/branches/5.1@47734 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6ee378fa7a
commit
8fc9dbc55b
|
@ -3039,7 +3039,7 @@ function edit_form_image_editor( $post ) {
|
|||
}
|
||||
?>
|
||||
</label>
|
||||
<?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
|
||||
<?php wp_editor( format_to_edit( $post->post_content ), 'attachment_content', $editor_args ); ?>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
|
|
|
@ -639,6 +639,7 @@ function set_screen_options() {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
|
||||
/**
|
||||
* Filters a screen option value before it is set.
|
||||
*
|
||||
|
@ -648,14 +649,36 @@ function set_screen_options() {
|
|||
* Returning false to the filter will skip saving the current option.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 5.4.2 Only applied to options ending with '_page',
|
||||
* or the 'layout_columns' option.
|
||||
*
|
||||
* @see set_screen_options()
|
||||
*
|
||||
* @param bool $keep Whether to save or skip saving the screen option value. Default false.
|
||||
* @param bool $keep Whether to save or skip saving the screen option value.
|
||||
* Default false.
|
||||
* @param string $option The option name.
|
||||
* @param int $value The number of rows to use.
|
||||
*/
|
||||
$value = apply_filters( 'set-screen-option', false, $option, $value );
|
||||
$value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a screen option value before it is set.
|
||||
*
|
||||
* The dynamic portion of the hook, `$option`, refers to the option name.
|
||||
*
|
||||
* Returning false to the filter will skip saving the current option.
|
||||
*
|
||||
* @since 5.4.2
|
||||
*
|
||||
* @see set_screen_options()
|
||||
*
|
||||
* @param bool $keep Whether to save or skip saving the screen option value.
|
||||
* Default false.
|
||||
* @param string $option The option name.
|
||||
* @param int $value The number of rows to use.
|
||||
*/
|
||||
$value = apply_filters( "set_screen_option_{$option}", false, $option, $value );
|
||||
|
||||
if ( false === $value ) {
|
||||
return;
|
||||
|
|
|
@ -364,7 +364,7 @@ if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes = w
|
|||
</tr>
|
||||
<?php foreach ( $broken_themes as $broken_theme ) : ?>
|
||||
<tr>
|
||||
<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?></td>
|
||||
<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
|
||||
<td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
|
||||
<?php
|
||||
if ( $can_delete ) {
|
||||
|
|
|
@ -573,6 +573,7 @@ add_filter( 'the_excerpt_embed', 'wpautop' );
|
|||
add_filter( 'the_excerpt_embed', 'shortcode_unautop' );
|
||||
add_filter( 'the_excerpt_embed', 'wp_embed_excerpt_attachment' );
|
||||
|
||||
add_filter( 'oembed_dataparse', 'wp_filter_oembed_iframe_title_attribute', 5, 3 );
|
||||
add_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10, 3 );
|
||||
add_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10, 4 );
|
||||
add_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10, 3 );
|
||||
|
|
|
@ -780,6 +780,68 @@ function _oembed_create_xml( $data, $node = null ) {
|
|||
return $node->asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the given oEmbed HTML to make sure iframes have a title attribute.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $result The oEmbed HTML result.
|
||||
* @param object $data A data object result from an oEmbed provider.
|
||||
* @param string $url The URL of the content to be embedded.
|
||||
* @return string The filtered oEmbed result.
|
||||
*/
|
||||
function wp_filter_oembed_iframe_title_attribute( $result, $data, $url ) {
|
||||
if ( false === $result || ! in_array( $data->type, array( 'rich', 'video' ), true ) ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$title = ! empty( $data->title ) ? $data->title : '';
|
||||
|
||||
$pattern = '`<iframe([^>]*)>`i';
|
||||
if ( preg_match( $pattern, $result, $matches ) ) {
|
||||
$attrs = wp_kses_hair( $matches[1], wp_allowed_protocols() );
|
||||
|
||||
foreach ( $attrs as $attr => $item ) {
|
||||
$lower_attr = strtolower( $attr );
|
||||
if ( $lower_attr === $attr ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! isset( $attrs[ $lower_attr ] ) ) {
|
||||
$attrs[ $lower_attr ] = $item;
|
||||
unset( $attrs[ $attr ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $attrs['title']['value'] ) ) {
|
||||
$title = $attrs['title']['value'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the title attribute of the given oEmbed HTML iframe.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $title The title attribute.
|
||||
* @param string $result The oEmbed HTML result.
|
||||
* @param object $data A data object result from an oEmbed provider.
|
||||
* @param string $url The URL of the content to be embedded.
|
||||
*/
|
||||
$title = apply_filters( 'oembed_iframe_title_attribute', $title, $result, $data, $url );
|
||||
|
||||
if ( '' === $title ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ( isset( $attrs['title'] ) ) {
|
||||
unset( $attrs['title'] );
|
||||
$attr_string = join( ' ', wp_list_pluck( $attrs, 'whole' ) );
|
||||
$result = str_replace( $matches[0], '<iframe ' . trim( $attr_string ) . '>', $result );
|
||||
}
|
||||
return str_ireplace( '<iframe ', sprintf( '<iframe title="%s" ', esc_attr( $title ) ), $result );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filters the given oEmbed HTML.
|
||||
*
|
||||
|
|
|
@ -1374,9 +1374,9 @@ if ( ! function_exists( 'wp_validate_redirect' ) ) :
|
|||
* @return string redirect-sanitized URL
|
||||
*/
|
||||
function wp_validate_redirect( $location, $default = '' ) {
|
||||
$location = trim( $location, " \t\n\r\0\x08\x0B" );
|
||||
// browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
|
||||
if ( substr( $location, 0, 2 ) == '//' ) {
|
||||
$location = wp_sanitize_redirect( trim( $location, " \t\n\r\0\x08\x0B" ) );
|
||||
// Browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'.
|
||||
if ( '//' === substr( $location, 0, 2 ) ) {
|
||||
$location = 'http:' . $location;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue