Skip to content

Commit

Permalink
Merge branch 'trunk' into html-api/normalize-to-xml
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Sep 17, 2024
2 parents f914c3f + ca64c85 commit 4721aa2
Show file tree
Hide file tree
Showing 24 changed files with 345 additions and 81 deletions.
6 changes: 3 additions & 3 deletions src/js/_enqueues/admin/inline-edit-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ window.wp = window.wp || {};
if ( ! $( this ).parent().find( 'input[name="indeterminate_post_category[]"]' ).length ) {
// Get the term label text.
var label = $( this ).parent().text();
// Set indeterminate states for the backend. Add accessible text for indeterminate inputs.
// Set indeterminate states for the backend. Add accessible text for indeterminate inputs.
$( this ).after( '<input type="hidden" name="indeterminate_post_category[]" value="' + $( this ).val() + '">' ).attr( 'aria-label', label.trim() + ': ' + wp.i18n.__( 'Some selected posts have this category' ) );
}
}
Expand Down Expand Up @@ -603,9 +603,9 @@ $( function() { inlineEditPost.init(); } );
// Show/hide locks on posts.
$( function() {

// Set the heartbeat interval to 15 seconds.
// Set the heartbeat interval to 10 seconds.
if ( typeof wp !== 'undefined' && wp.heartbeat ) {
wp.heartbeat.interval( 15 );
wp.heartbeat.interval( 10 );
}
}).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
var locked = data['wp-check-locked-posts'] || {};
Expand Down
4 changes: 2 additions & 2 deletions src/js/_enqueues/admin/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ jQuery( function($) {
}
}).filter(':visible').find('.wp-tab-first').trigger( 'focus' );

// Set the heartbeat interval to 15 seconds if post lock dialogs are enabled.
// Set the heartbeat interval to 10 seconds if post lock dialogs are enabled.
if ( wp.heartbeat && $('#post-lock-dialog').length ) {
wp.heartbeat.interval( 15 );
wp.heartbeat.interval( 10 );
}

// The form is being submitted by the user.
Expand Down
56 changes: 25 additions & 31 deletions src/js/_enqueues/wp/heartbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,17 @@
}

/*
* The interval can be from 15 to 120 seconds and can be set temporarily to 5 seconds.
* It can be set in the initial options or changed later through JS and/or through PHP.
* Logic check: the interval can be from 1 to 3600 seconds and can be set temporarily
* to 5 seconds. It can be set in the initial options or changed later from JS
* or from PHP through the AJAX responses.
*/
if ( options.interval ) {
settings.mainInterval = options.interval;

if ( settings.mainInterval < 15 ) {
settings.mainInterval = 15;
} else if ( settings.mainInterval > 120 ) {
settings.mainInterval = 120;
if ( settings.mainInterval < 1 ) {
settings.mainInterval = 1;
} else if ( settings.mainInterval > 3600 ) {
settings.mainInterval = 3600;
}
}

Expand Down Expand Up @@ -721,10 +722,10 @@
*
* @memberOf wp.heartbeat.prototype
*
* @param {string|number} speed Interval: 'fast' or 5, 15, 30, 60, 120.
* @param {string|number} speed Interval: 'fast' or integer between 1 and 3600 (seconds).
* Fast equals 5.
* @param {string} ticks Tells how many ticks before the interval reverts
* back. Used with speed = 'fast' or 5.
* @param {number} ticks Tells how many ticks before the interval reverts back.
* Value must be between 1 and 30. Used with speed = 'fast' or 5.
*
* @return {number} Current interval in seconds.
*/
Expand All @@ -733,35 +734,28 @@
oldInterval = settings.tempInterval ? settings.tempInterval : settings.mainInterval;

if ( speed ) {
switch ( speed ) {
case 'fast':
case 5:
newInterval = 5000;
break;
case 15:
newInterval = 15000;
break;
case 30:
newInterval = 30000;
break;
case 60:
newInterval = 60000;
break;
case 120:
newInterval = 120000;
break;
case 'long-polling':
// Allow long polling (experimental).
settings.mainInterval = 0;
return 0;
default:
if ( 'fast' === speed ) {
// Special case, see below.
newInterval = 5000;
} else if ( 'long-polling' === speed ) {
// Allow long polling (experimental).
settings.mainInterval = 0;
return 0;
} else {
speed = parseInt( speed, 10 );

if ( speed >= 1 && speed <= 3600 ) {
newInterval = speed * 1000;
} else {
newInterval = settings.originalInterval;
}
}

if ( settings.minimalInterval && newInterval < settings.minimalInterval ) {
newInterval = settings.minimalInterval;
}

// Special case, runs for a number of ticks then reverts to the previous interval.
if ( 5000 === newInterval ) {
ticks = parseInt( ticks, 10 ) || 30;
ticks = ticks < 1 || ticks > 30 ? 30 : ticks;
Expand Down
22 changes: 19 additions & 3 deletions src/wp-admin/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,17 @@ th.action-links {
overflow: hidden;
}

.wp-filter .favorites-form .favorites-username {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 0.5rem;
}

.wp-filter .favorites-form .favorites-username input {
margin: 0;
}

.show-filters .filter-drawer,
.show-favorites-form .favorites-form {
display: block;
Expand Down Expand Up @@ -1288,11 +1299,13 @@ th.action-links {
}

.filtered-by .tags {
display: inline;
display: flex;
align-items: flex-start;
flex-wrap: wrap;
gap: 8px;
}

.filtered-by .tag {
margin: 0 5px;
padding: 4px 8px;
border: 1px solid #dcdcde;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
Expand All @@ -1307,7 +1320,10 @@ th.action-links {
}

.filters-applied .filtered-by {
display: block;
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10px;
}

.filters-applied .filter-drawer {
Expand Down
8 changes: 8 additions & 0 deletions src/wp-admin/edit-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ static function ( $classes ) {
'before'
);

// Set Heartbeat interval to 10 seconds, used to refresh post locks.
wp_add_inline_script(
'heartbeat',
'if ( window.wp && window.wp.heartbeat ) {
window.wp.heartbeat.interval( 10 );
}'
);

/*
* Get all available templates for the post/page attributes meta-box.
* The "Default template" array element should only be added if the array is
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/theme-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
?>
<p class="install-help"><?php _e( 'If you have marked themes as favorites on WordPress.org, you can browse them here.' ); ?></p>

<p>
<p class="favorites-username">
<label for="wporg-username-input"><?php _e( 'Your WordPress.org username:' ); ?></label>
<input type="hidden" id="wporg-username-nonce" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( $action ) ); ?>" />
<input type="search" id="wporg-username-input" value="<?php echo esc_attr( $user ); ?>" />
Expand Down
1 change: 0 additions & 1 deletion src/wp-includes/block-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function _register_core_block_patterns_and_categories() {
'query-grid-posts',
'query-large-title-posts',
'query-offset-posts',
'social-links-shared-background-color',
);

foreach ( $core_block_patterns as $core_block_pattern ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Social links with a shared background color.
*
* @package WordPress
* @since 5.8.0
* @deprecated 6.7.0 This pattern is deprecated. Please use the Social Links block instead.
*/

return array(
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-network.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static function get_instance( $network_id ) {
*/
public function __construct( $network ) {
foreach ( get_object_vars( $network ) as $key => $value ) {
$this->$key = $value;
$this->__set( $key, $value );
}

$this->_set_site_name();
Expand Down
21 changes: 9 additions & 12 deletions src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4943,7 +4943,7 @@ private function step_in_foreign_content(): bool {

$this->state->stack_of_open_elements->pop();
}
return $this->step( self::REPROCESS_CURRENT_NODE );
goto in_foreign_content_process_in_current_insertion_mode;
}

/*
Expand Down Expand Up @@ -5019,6 +5019,7 @@ private function step_in_foreign_content(): bool {
goto in_foreign_content_end_tag_loop;
}

in_foreign_content_process_in_current_insertion_mode:
switch ( $this->state->insertion_mode ) {
case WP_HTML_Processor_State::INSERTION_MODE_INITIAL:
return $this->step_initial();
Expand Down Expand Up @@ -5169,17 +5170,13 @@ public function get_tag(): ?string {

$tag_name = parent::get_tag();

switch ( $tag_name ) {
case 'IMAGE':
/*
* > A start tag whose tag name is "image"
* > Change the token's tag name to "img" and reprocess it. (Don't ask.)
*/
return 'IMG';

default:
return $tag_name;
}
/*
* > A start tag whose tag name is "image"
* > Change the token's tag name to "img" and reprocess it. (Don't ask.)
*/
return ( 'IMAGE' === $tag_name && 'html' === $this->get_namespace() )
? 'IMG'
: $tag_name;
}

/**
Expand Down
10 changes: 7 additions & 3 deletions src/wp-includes/link-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1618,14 +1618,18 @@ function get_edit_comment_link( $comment_id = 0, $context = 'display' ) {

$location = admin_url( $action ) . $comment->comment_ID;

// Ensure the $comment_id variable passed to the filter is always an ID.
$comment_id = (int) $comment->comment_ID;

/**
* Filters the comment edit link.
*
* @since 2.3.0
* @since 6.7.0 The $comment_id and $context parameters are now being passed to the filter.
*
* @param string $location The edit link.
* @param int $comment_id Optional. Unique ID of the comment to generate an edit link.
* @param int $context Optional. Context to include HTML entities in link. Default 'display'.
* @param string $location The edit link.
* @param int $comment_id Unique ID of the comment to generate an edit link.
* @param string $context Context to include HTML entities in link. Default 'display'.
*/
return apply_filters( 'get_edit_comment_link', $location, $comment_id, $context );
}
Expand Down
3 changes: 3 additions & 0 deletions src/wp-includes/meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,7 @@ function sanitize_meta( $meta_key, $meta_value, $object_type, $object_subtype =
* @since 5.3.0 Valid meta types expanded to include "array" and "object".
* @since 5.5.0 The `$default` argument was added to the arguments array.
* @since 6.4.0 The `$revisions_enabled` argument was added to the arguments array.
* @since 6.7.0 The `label` argument was added to the arguments array.
*
* @param string $object_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user',
* or any other object type with an associated meta table.
Expand All @@ -1380,6 +1381,7 @@ function sanitize_meta( $meta_key, $meta_value, $object_type, $object_subtype =
* the meta key will be registered on the entire object type. Default empty.
* @type string $type The type of data associated with this meta key.
* Valid values are 'string', 'boolean', 'integer', 'number', 'array', and 'object'.
* @type string $label A human-readable label of the data attached to this meta key.
* @type string $description A description of the data attached to this meta key.
* @type bool $single Whether the meta key has one value per object, or an array of values per object.
* @type mixed $default The default value returned from get_metadata() if no value has been set yet.
Expand Down Expand Up @@ -1412,6 +1414,7 @@ function register_meta( $object_type, $meta_key, $args, $deprecated = null ) {
$defaults = array(
'object_subtype' => '',
'type' => 'string',
'label' => '',
'description' => '',
'default' => '',
'single' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ protected function get_registered_fields() {

$default_schema = array(
'type' => $default_args['type'],
'title' => empty( $args['label'] ) ? '' : $args['label'],
'description' => empty( $args['description'] ) ? '' : $args['description'],
'default' => isset( $args['default'] ) ? $args['default'] : null,
);
Expand Down
6 changes: 4 additions & 2 deletions src/wp-includes/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,26 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
// Filter to supported values.
$gd_info = array_filter( $gd_info );

// Add data for GD WebP and AVIF support.
// Add data for GD WebP, AVIF and HEIC support.
$query['image_support']['gd'] = array_keys(
array_filter(
array(
'webp' => isset( $gd_info['WebP Support'] ),
'avif' => isset( $gd_info['AVIF Support'] ),
'heic' => isset( $gd_info['HEIC Support'] ),
)
)
);
}

if ( class_exists( 'Imagick' ) ) {
// Add data for Imagick WebP and AVIF support.
// Add data for Imagick WebP, AVIF and HEIC support.
$query['image_support']['imagick'] = array_keys(
array_filter(
array(
'webp' => ! empty( Imagick::queryFormats( 'WEBP' ) ),
'avif' => ! empty( Imagick::queryFormats( 'AVIF' ) ),
'heic' => ! empty( Imagick::queryFormats( 'HEIC' ) ),
)
)
);
Expand Down
10 changes: 6 additions & 4 deletions tests/phpunit/tests/canonical.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,11 @@ public function test_utf8_query_keys_canonical() {

$this->go_to( get_permalink( $p ) );

$url = redirect_canonical( add_query_arg( '%D0%BA%D0%BE%D0%BA%D0%BE%D0%BA%D0%BE', 1, site_url( '/' ) ), false );
$this->assertNull( $url );
$redirect = redirect_canonical( add_query_arg( '%D0%BA%D0%BE%D0%BA%D0%BE%D0%BA%D0%BE', 1, site_url( '/' ) ), false );

delete_option( 'page_on_front' );

$this->assertNull( $redirect );
}

/**
Expand All @@ -456,11 +457,12 @@ public function test_feed_canonical_with_not_exists_query() {
)
);

$url = redirect_canonical( get_term_feed_link( self::$terms['/category/parent/'] ), false );
$redirect = redirect_canonical( get_term_feed_link( self::$terms['/category/parent/'] ), false );

// Restore original global.
$GLOBALS['wp_query'] = $global_query;

$this->assertNull( $url );
$this->assertNull( $redirect );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/canonical/https.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function test_https_request_with_https_home() {

$redirect = redirect_canonical( $this->https, false );

$this->assertNull( $redirect );

remove_filter( 'home_url', array( $this, 'set_https' ) );

$this->assertNull( $redirect );
}
}
Loading

0 comments on commit 4721aa2

Please sign in to comment.