Subir ajustes de acordeon y SEO
This commit is contained in:
@@ -104,7 +104,7 @@
|
||||
'wp-url',
|
||||
'wp-warning'
|
||||
),
|
||||
'version' => 'd3cbb2c45b145b27a5cf'
|
||||
'version' => '37e58da384b2558bd479'
|
||||
),
|
||||
'block-library.js' => array(
|
||||
'dependencies' => array(
|
||||
@@ -150,7 +150,7 @@
|
||||
'import' => 'dynamic'
|
||||
)
|
||||
),
|
||||
'version' => '2e80403676c10cc0a473'
|
||||
'version' => '00e6e2a44788af201f35'
|
||||
),
|
||||
'block-serialization-default-parser.js' => array(
|
||||
'dependencies' => array(
|
||||
@@ -402,7 +402,7 @@
|
||||
'import' => 'static'
|
||||
)
|
||||
),
|
||||
'version' => 'a7750dea8d5c880ddf33'
|
||||
'version' => 'a6cb1641d13f718c01bd'
|
||||
),
|
||||
'edit-site.js' => array(
|
||||
'dependencies' => array(
|
||||
@@ -452,7 +452,7 @@
|
||||
'import' => 'static'
|
||||
)
|
||||
),
|
||||
'version' => '638e98d0061f4b9f1efb'
|
||||
'version' => '008f89f2cb2ad17a5947'
|
||||
),
|
||||
'edit-widgets.js' => array(
|
||||
'dependencies' => array(
|
||||
@@ -543,7 +543,7 @@
|
||||
'import' => 'static'
|
||||
)
|
||||
),
|
||||
'version' => '2cd3b932f41a420d5904'
|
||||
'version' => 'af070cfff88093363220'
|
||||
),
|
||||
'element.js' => array(
|
||||
'dependencies' => array(
|
||||
@@ -663,7 +663,7 @@
|
||||
'wp-url',
|
||||
'wp-warning'
|
||||
),
|
||||
'version' => 'b8bf604c1cc119e63ee6'
|
||||
'version' => '07c1c94f9b21baa97a96'
|
||||
),
|
||||
'notices.js' => array(
|
||||
'dependencies' => array(
|
||||
@@ -881,7 +881,7 @@
|
||||
'import' => 'dynamic'
|
||||
)
|
||||
),
|
||||
'version' => 'f7174b0617bcd68e57c3'
|
||||
'version' => 'a2c026d433c295fd5145'
|
||||
),
|
||||
'url.js' => array(
|
||||
'dependencies' => array(
|
||||
|
||||
@@ -360,7 +360,7 @@
|
||||
'dependencies' => array(
|
||||
|
||||
),
|
||||
'version' => '685442d334b2d3e70832'
|
||||
'version' => '7e33cd8c4128731126e8'
|
||||
),
|
||||
'workflow/index.js' => array(
|
||||
'dependencies' => array(
|
||||
|
||||
@@ -542,6 +542,16 @@ function wp_render_block_states_support( $block_content, $block ) {
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
/*
|
||||
* Every CSS rule this function can produce is keyed off the block's `style`
|
||||
* attribute. Without it there is nothing to generate, so bail before doing
|
||||
* any of the lookups below — this runs for every block on every request.
|
||||
*/
|
||||
$style = $block['attrs']['style'] ?? array();
|
||||
if ( empty( $style ) || ! is_array( $style ) ) {
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
$block_name = $block['blockName'];
|
||||
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_name );
|
||||
if ( ! $block_type ) {
|
||||
@@ -549,7 +559,6 @@ function wp_render_block_states_support( $block_content, $block ) {
|
||||
}
|
||||
|
||||
$supported_pseudo_states = WP_Theme_JSON::VALID_BLOCK_PSEUDO_SELECTORS[ $block_name ] ?? array();
|
||||
$style = $block['attrs']['style'] ?? array();
|
||||
$css_rules = array();
|
||||
$viewport_settings = wp_get_global_settings( array( 'viewport' ) );
|
||||
$responsive_media_queries = WP_Theme_JSON::get_viewport_media_queries( $viewport_settings );
|
||||
|
||||
@@ -343,11 +343,22 @@ function _get_block_template_file( $template_type, $slug ) {
|
||||
);
|
||||
foreach ( $themes as $theme_slug => $theme_dir ) {
|
||||
$template_base_paths = get_block_theme_folders( $theme_slug );
|
||||
$file_path = $theme_dir . '/' . $template_base_paths[ $template_type ] . '/' . $slug . '.html';
|
||||
if ( file_exists( $file_path ) ) {
|
||||
$template_dir = $theme_dir . '/' . $template_base_paths[ $template_type ];
|
||||
$file_path = $template_dir . '/' . $slug . '.html';
|
||||
$template_file = realpath( $file_path );
|
||||
$template_root = realpath( $template_dir );
|
||||
|
||||
if (
|
||||
false !== $template_file &&
|
||||
false !== $template_root &&
|
||||
str_starts_with(
|
||||
wp_normalize_path( $template_file ),
|
||||
trailingslashit( wp_normalize_path( $template_root ) )
|
||||
)
|
||||
) {
|
||||
$new_template_item = array(
|
||||
'slug' => $slug,
|
||||
'path' => $file_path,
|
||||
'path' => $template_file,
|
||||
'theme' => $theme_slug,
|
||||
'type' => $template_type,
|
||||
);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
.wp-block-accordion-panel[hidden] {
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
margin-block-start: 0;
|
||||
padding: 0 !important;
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
.wp-block-accordion-panel[hidden]{margin-block-start:0}
|
||||
.wp-block-accordion-panel[hidden]{border:none!important;box-shadow:none!important;margin-block-start:0;padding:0!important}
|
||||
@@ -1,3 +1,6 @@
|
||||
.wp-block-accordion-panel[hidden] {
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
margin-block-start: 0;
|
||||
padding: 0 !important;
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
.wp-block-accordion-panel[hidden]{margin-block-start:0}
|
||||
.wp-block-accordion-panel[hidden]{border:none!important;box-shadow:none!important;margin-block-start:0;padding:0!important}
|
||||
@@ -310,6 +310,22 @@ function wp_font_library_render_page() {
|
||||
function wp_font_library_intercept_render() {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
if ( isset( $_GET['page'] ) && 'font-library' === $_GET['page'] ) {
|
||||
// The page renders outside the menu page callback flow, so it must
|
||||
// enforce authentication and capability checks itself. Without this,
|
||||
// any admin entry point firing `admin_init` (such as admin-post.php,
|
||||
// which serves logged-out requests) would render the page for
|
||||
// unauthenticated visitors.
|
||||
if ( ! is_user_logged_in() ) {
|
||||
auth_redirect();
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'edit_theme_options' ) ) {
|
||||
wp_die(
|
||||
__( 'Sorry, you are not allowed to access this page.' ),
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
wp_font_library_render_page();
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -310,6 +310,22 @@ function wp_options_connectors_render_page() {
|
||||
function wp_options_connectors_intercept_render() {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
if ( isset( $_GET['page'] ) && 'options-connectors' === $_GET['page'] ) {
|
||||
// The page renders outside the menu page callback flow, so it must
|
||||
// enforce authentication and capability checks itself. Without this,
|
||||
// any admin entry point firing `admin_init` (such as admin-post.php,
|
||||
// which serves logged-out requests) would render the page for
|
||||
// unauthenticated visitors.
|
||||
if ( ! is_user_logged_in() ) {
|
||||
auth_redirect();
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_die(
|
||||
__( 'Sorry, you are not allowed to access this page.' ),
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
wp_options_connectors_render_page();
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
* accepted_args: int,
|
||||
* }
|
||||
*
|
||||
* @phpstan-implements Iterator<int, array<string, Hook_Callback>>
|
||||
* @phpstan-implements ArrayAccess<int, array<string, Hook_Callback>>
|
||||
* @phpstan-implements Iterator<int, array<non-decimal-int-string, Hook_Callback>>
|
||||
* @phpstan-implements ArrayAccess<int, array<non-decimal-int-string, Hook_Callback>>
|
||||
*/
|
||||
#[AllowDynamicProperties]
|
||||
final class WP_Hook implements Iterator, ArrayAccess {
|
||||
@@ -31,7 +31,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||
*
|
||||
* @since 4.7.0
|
||||
* @var array
|
||||
* @phpstan-var array<int, array<string, Hook_Callback>>
|
||||
* @phpstan-var array<int, array<non-decimal-int-string, Hook_Callback>>
|
||||
*/
|
||||
public $callbacks = array();
|
||||
|
||||
@@ -502,7 +502,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||
*
|
||||
* @param int $offset The offset to retrieve.
|
||||
* @return array|null If set, the value at the specified offset, null otherwise.
|
||||
* @phpstan-return array<string, Hook_Callback>|null
|
||||
* @phpstan-return array<non-decimal-int-string, Hook_Callback>|null
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetGet( $offset ) {
|
||||
@@ -518,7 +518,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||
*
|
||||
* @param int|null $offset The offset to assign the value to.
|
||||
* @param array $value The value to set.
|
||||
* @phpstan-param array<string, Hook_Callback> $value
|
||||
* @phpstan-param array<non-decimal-int-string, Hook_Callback> $value
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetSet( $offset, $value ) {
|
||||
@@ -554,7 +554,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||
* @link https://www.php.net/manual/en/iterator.current.php
|
||||
*
|
||||
* @return array|false Array of callbacks at current priority, false if there are no more elements.
|
||||
* @phpstan-return array<string, Hook_Callback>|false
|
||||
* @phpstan-return array<non-decimal-int-string, Hook_Callback>|false
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function current() {
|
||||
@@ -569,7 +569,7 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
||||
* @link https://www.php.net/manual/en/iterator.next.php
|
||||
*
|
||||
* @return array|false Array of callbacks at next priority, false if there are no more elements.
|
||||
* @phpstan-return array<string, Hook_Callback>|false
|
||||
* @phpstan-return array<non-decimal-int-string, Hook_Callback>|false
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function next() {
|
||||
|
||||
@@ -1023,7 +1023,10 @@ class WP_Http {
|
||||
|
||||
// Strip all /path/../ out of the path.
|
||||
while ( strpos( $path, '../' ) > 1 ) {
|
||||
$path = preg_replace( '![^/]+/\.\./!', '', $path );
|
||||
$path = preg_replace( '![^/]+/\.\./!', '', $path, -1, $segment_replacement_count );
|
||||
if ( 0 === $segment_replacement_count ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Strip any final leading ../ from the path.
|
||||
|
||||
@@ -79,7 +79,6 @@ class WP_oEmbed {
|
||||
'#https?://(www\.)?twitter\.com/i/moments/.*#i' => array( 'https://publish.twitter.com/oembed', true ),
|
||||
'#https?://(www\.)?soundcloud\.com/.*#i' => array( 'https://soundcloud.com/oembed', true ),
|
||||
'#https?://(open|play)\.spotify\.com/.*#i' => array( 'https://embed.spotify.com/oembed/', true ),
|
||||
'#https?://(.+\.)?imgur\.com/.*#i' => array( 'https://api.imgur.com/oembed', true ),
|
||||
'#https?://(www\.)?issuu\.com/.+/docs/.+#i' => array( 'https://issuu.com/oembed_wp', true ),
|
||||
'#https?://(www\.)?mixcloud\.com/.*#i' => array( 'https://app.mixcloud.com/oembed/', true ),
|
||||
'#https?://(www\.|embed\.)?ted\.com/talks/.*#i' => array( 'https://www.ted.com/services/v1/oembed.{format}', true ),
|
||||
@@ -88,7 +87,7 @@ class WP_oEmbed {
|
||||
'#https?://(www\.)?kickstarter\.com/projects/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ),
|
||||
'#https?://kck\.st/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ),
|
||||
'#https?://cloudup\.com/.*#i' => array( 'https://cloudup.com/oembed', true ),
|
||||
'#https?://(www\.)?reverbnation\.com/.*#i' => array( 'https://www.reverbnation.com/oembed', true ),
|
||||
'#https?://((legacy|www)\.)?reverbnation\.com/.*#i' => array( 'https://legacy.reverbnation.com/oembed', true ),
|
||||
'#https?://videopress\.com/v/.*#' => array( 'https://public-api.wordpress.com/oembed/?for=' . $host, true ),
|
||||
'#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i' => array( 'https://www.reddit.com/oembed', true ),
|
||||
'#https?://(www\.)?speakerdeck\.com/.*#i' => array( 'https://speakerdeck.com/oembed.{format}', true ),
|
||||
@@ -102,9 +101,6 @@ class WP_oEmbed {
|
||||
'#https?://(www\.)?amzn\.in/.*#i' => array( 'https://read.amazon.in/kp/api/oembed', true ),
|
||||
'#https?://(www\.)?amzn\.asia/.*#i' => array( 'https://read.amazon.com.au/kp/api/oembed', true ),
|
||||
'#https?://(www\.)?z\.cn/.*#i' => array( 'https://read.amazon.cn/kp/api/oembed', true ),
|
||||
'#https?://www\.someecards\.com/.+-cards/.+#i' => array( 'https://www.someecards.com/v2/oembed/', true ),
|
||||
'#https?://www\.someecards\.com/usercards/viewcard/.+#i' => array( 'https://www.someecards.com/v2/oembed/', true ),
|
||||
'#https?://some\.ly\/.+#i' => array( 'https://www.someecards.com/v2/oembed/', true ),
|
||||
'#https?://(www\.)?tiktok\.com/.*/video/.*#i' => array( 'https://www.tiktok.com/oembed', true ),
|
||||
'#https?://(www\.)?tiktok\.com/@.*#i' => array( 'https://www.tiktok.com/oembed', true ),
|
||||
'#https?://([a-z]{2}|www)\.pinterest\.com(\.(au|mx))?/.*#i' => array( 'https://www.pinterest.com/oembed.json', true ),
|
||||
@@ -154,7 +150,6 @@ class WP_oEmbed {
|
||||
* | Dailymotion | dai.ly | 3.6.0 |
|
||||
* | Flickr | flic.kr | 3.6.0 |
|
||||
* | Spotify | spotify.com | 3.6.0 |
|
||||
* | Imgur | imgur.com | 3.9.0 |
|
||||
* | Animoto | animoto.com | 4.0.0 |
|
||||
* | Animoto | video214.com | 4.0.0 |
|
||||
* | Issuu | issuu.com | 4.0.0 |
|
||||
@@ -183,8 +178,6 @@ class WP_oEmbed {
|
||||
* | Amazon | a.co | 4.9.0 |
|
||||
* | Amazon | amzn.to (eu, in, asia) | 4.9.0 |
|
||||
* | Amazon | z.cn | 4.9.0 |
|
||||
* | Someecards | someecards.com | 4.9.0 |
|
||||
* | Someecards | some.ly | 4.9.0 |
|
||||
* | Crowdsignal | survey.fm | 5.1.0 |
|
||||
* | TikTok | tiktok.com | 5.4.0 |
|
||||
* | Pinterest | pinterest.com | 5.9.0 |
|
||||
@@ -219,6 +212,9 @@ class WP_oEmbed {
|
||||
* | Meetup.com | meetu.ps | 3.9.0 | 6.0.1 |
|
||||
* | SlideShare | slideshare.net | 3.5.0 | 6.6.0 |
|
||||
* | Screencast | screencast.com | 4.8.0 | 6.8.2 |
|
||||
* | Imgur | imgur.com | 3.9.0 | 7.1.3 |
|
||||
* | Someecards | someecards.com | 4.9.0 | 7.1.3 |
|
||||
* | Someecards | some.ly | 4.9.0 | 7.1.3 |
|
||||
*
|
||||
* @see wp_oembed_add_provider()
|
||||
*
|
||||
|
||||
@@ -3484,43 +3484,6 @@ class WP_Query {
|
||||
$this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $this->posts ) && $this->is_comment_feed && $this->is_singular ) {
|
||||
/** This filter is documented in wp-includes/class-wp-query.php */
|
||||
$cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-query.php */
|
||||
$cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1' AND {$wpdb->comments}.comment_type != 'note'", &$this ) );
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-query.php */
|
||||
$cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
|
||||
$cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-query.php */
|
||||
$corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
|
||||
$corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-query.php */
|
||||
$climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
|
||||
|
||||
$comments_request = "SELECT {$wpdb->comments}.comment_ID FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
|
||||
|
||||
$comment_key = md5( $comments_request );
|
||||
$comment_last_changed = wp_cache_get_last_changed( 'comment' );
|
||||
|
||||
$comment_cache_key = "comment_feed:$comment_key";
|
||||
$comment_ids = wp_cache_get_salted( $comment_cache_key, 'comment-queries', $comment_last_changed );
|
||||
if ( false === $comment_ids ) {
|
||||
$comment_ids = $wpdb->get_col( $comments_request );
|
||||
wp_cache_set_salted( $comment_cache_key, $comment_ids, 'comment-queries', $comment_last_changed );
|
||||
}
|
||||
_prime_comment_caches( $comment_ids );
|
||||
|
||||
// Convert to WP_Comment.
|
||||
/** @var WP_Comment[] */
|
||||
$this->comments = array_map( 'get_comment', $comment_ids );
|
||||
$this->comment_count = count( $this->comments );
|
||||
}
|
||||
|
||||
// Check post status to determine if post should be displayed.
|
||||
if ( ! empty( $this->posts ) && ( $this->is_single || $this->is_page ) ) {
|
||||
$status = get_post_status( $this->posts[0] );
|
||||
@@ -3579,6 +3542,43 @@ class WP_Query {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $this->posts ) && $this->is_comment_feed && $this->is_singular ) {
|
||||
/** This filter is documented in wp-includes/class-wp-query.php */
|
||||
$cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-query.php */
|
||||
$cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1' AND {$wpdb->comments}.comment_type != 'note'", &$this ) );
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-query.php */
|
||||
$cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
|
||||
$cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-query.php */
|
||||
$corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
|
||||
$corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-query.php */
|
||||
$climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
|
||||
|
||||
$comments_request = "SELECT {$wpdb->comments}.comment_ID FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
|
||||
|
||||
$comment_key = md5( $comments_request );
|
||||
$comment_last_changed = wp_cache_get_last_changed( 'comment' );
|
||||
|
||||
$comment_cache_key = "comment_feed:$comment_key";
|
||||
$comment_ids = wp_cache_get_salted( $comment_cache_key, 'comment-queries', $comment_last_changed );
|
||||
if ( false === $comment_ids ) {
|
||||
$comment_ids = $wpdb->get_col( $comments_request );
|
||||
wp_cache_set_salted( $comment_cache_key, $comment_ids, 'comment-queries', $comment_last_changed );
|
||||
}
|
||||
_prime_comment_caches( $comment_ids );
|
||||
|
||||
// Convert to WP_Comment.
|
||||
/** @var WP_Comment[] */
|
||||
$this->comments = array_map( 'get_comment', $comment_ids );
|
||||
$this->comment_count = count( $this->comments );
|
||||
}
|
||||
|
||||
// Put sticky posts at the top of the posts array.
|
||||
$sticky_posts = get_option( 'sticky_posts' );
|
||||
if ( $this->is_home && $page <= 1 && is_array( $sticky_posts ) && ! empty( $sticky_posts ) && ! $query_vars['ignore_sticky_posts'] ) {
|
||||
|
||||
@@ -3880,8 +3880,18 @@ class WP_Theme_JSON {
|
||||
// Only store if the variation has blockGap defined.
|
||||
if ( isset( $style_variation_node['spacing']['blockGap'] ) ) {
|
||||
// Append block selector to the variation selector for proper targeting.
|
||||
$variation_metadata_with_selector = $style_variation;
|
||||
$variation_metadata_with_selector['selector'] = $style_variation['selector'] . $block_metadata['css'];
|
||||
$variation_metadata_with_selector = $style_variation;
|
||||
$variation_metadata_with_selector['selector'] = $style_variation['selector'] . $block_metadata['css'];
|
||||
|
||||
/*
|
||||
* `get_layout_styles()` reads `name` as a block name, to check that the block
|
||||
* supports layout at all. A variation node's `name` is the variation slug,
|
||||
* which is never a registered block, so the check fails and every variation
|
||||
* gap rule is discarded. Pass the block the variation belongs to, so the
|
||||
* support check answers the question it is actually asking.
|
||||
*/
|
||||
$variation_metadata_with_selector['name'] = $block_name;
|
||||
|
||||
$style_variation_layout_metadata[ $style_variation['selector'] ] = array(
|
||||
'metadata' => $variation_metadata_with_selector,
|
||||
'node' => $style_variation_node,
|
||||
@@ -3937,7 +3947,11 @@ class WP_Theme_JSON {
|
||||
if ( isset( $breakpoint_node['spacing']['blockGap'] ) ) {
|
||||
$variation_layout_metadata = $style_variation;
|
||||
$variation_layout_metadata['selector'] = $style_variation['selector'] . $block_metadata['css'];
|
||||
$variation_responsive_css .= $this->get_layout_styles(
|
||||
|
||||
// The variation slug is not a block name here either. See above.
|
||||
$variation_layout_metadata['name'] = $block_name;
|
||||
|
||||
$variation_responsive_css .= $this->get_layout_styles(
|
||||
$variation_layout_metadata,
|
||||
array(
|
||||
'node' => $breakpoint_node,
|
||||
|
||||
@@ -16,11 +16,25 @@
|
||||
#[AllowDynamicProperties]
|
||||
class WP_Widget_Factory {
|
||||
|
||||
/**
|
||||
* Prefix for the key under which a widget registered as an instance is stored.
|
||||
*
|
||||
* Without it the key would be the decimal representation of an integer, which PHP casts from
|
||||
* string to int when it is used as an array key.
|
||||
*
|
||||
* @since 7.1.1
|
||||
*/
|
||||
private const INSTANCE_KEY_PREFIX = 'spl_object_id:';
|
||||
|
||||
/**
|
||||
* Widgets array.
|
||||
*
|
||||
* Keyed by class name for a widget registered by name, and by a prefixed object ID for a widget
|
||||
* registered as an instance.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @var array
|
||||
* @var array<string, WP_Widget>
|
||||
* @phpstan-var array<non-decimal-int-string, WP_Widget>
|
||||
*/
|
||||
public $widgets = array();
|
||||
|
||||
@@ -52,12 +66,13 @@ class WP_Widget_Factory {
|
||||
* @since 2.8.0
|
||||
* @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object
|
||||
* instead of simply a `WP_Widget` subclass name.
|
||||
* @since 7.1.1 The key for an instance is prefixed so that it is never cast to an integer.
|
||||
*
|
||||
* @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
|
||||
*/
|
||||
public function register( $widget ) {
|
||||
if ( $widget instanceof WP_Widget ) {
|
||||
$this->widgets[ spl_object_id( $widget ) ] = $widget;
|
||||
$this->widgets[ self::INSTANCE_KEY_PREFIX . spl_object_id( $widget ) ] = $widget;
|
||||
} else {
|
||||
$this->widgets[ $widget ] = new $widget();
|
||||
}
|
||||
@@ -69,12 +84,13 @@ class WP_Widget_Factory {
|
||||
* @since 2.8.0
|
||||
* @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object
|
||||
* instead of simply a `WP_Widget` subclass name.
|
||||
* @since 7.1.1 The key for an instance is prefixed so that it is never cast to an integer.
|
||||
*
|
||||
* @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
|
||||
*/
|
||||
public function unregister( $widget ) {
|
||||
if ( $widget instanceof WP_Widget ) {
|
||||
unset( $this->widgets[ spl_object_id( $widget ) ] );
|
||||
unset( $this->widgets[ self::INSTANCE_KEY_PREFIX . spl_object_id( $widget ) ] );
|
||||
} else {
|
||||
unset( $this->widgets[ $widget ] );
|
||||
}
|
||||
|
||||
@@ -1462,6 +1462,33 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return new IXR_Error( 403, __( 'Invalid post type.' ) );
|
||||
}
|
||||
|
||||
// Reject writes to internal-only builtin post types (e.g. customize_changeset)
|
||||
// whose intended write path is a dedicated helper, not a generic post API.
|
||||
$is_internal_only = (
|
||||
empty( $post_type->public )
|
||||
&& empty( $post_type->show_in_rest )
|
||||
&& ! empty( $post_type->_builtin )
|
||||
);
|
||||
|
||||
/**
|
||||
* Filters whether a post type accepts writes via XML-RPC.
|
||||
*
|
||||
* Defaults to false for internal-only builtin post types (public=false,
|
||||
* show_in_rest=false, _builtin=true), such as customize_changeset, whose
|
||||
* writes are meant to flow through dedicated helpers. Return true to opt
|
||||
* a post type back in.
|
||||
*
|
||||
* @since 7.1.1
|
||||
*
|
||||
* @param bool $allowed Whether the post type accepts XML-RPC writes.
|
||||
* @param WP_Post_Type $post_type The post type object.
|
||||
*/
|
||||
$allowed = apply_filters( 'xmlrpc_allow_post_type_writes', ! $is_internal_only, $post_type );
|
||||
|
||||
if ( ! $allowed ) {
|
||||
return new IXR_Error( 403, __( 'Sorry, this post type is not supported over XML-RPC.' ) );
|
||||
}
|
||||
|
||||
$update = ! empty( $post_data['ID'] );
|
||||
|
||||
if ( $update ) {
|
||||
|
||||
@@ -746,8 +746,9 @@ class WP {
|
||||
|
||||
$set_404 = true;
|
||||
|
||||
// Never 404 for the admin, robots, or favicon.
|
||||
if ( is_admin() || is_robots() || is_favicon() ) {
|
||||
// Never 404 here for the admin, robots, favicon, or sitemaps.
|
||||
// Sitemap routes send their own status in WP_Sitemaps::render_sitemaps().
|
||||
if ( is_admin() || is_robots() || is_favicon() || is_sitemap() || get_query_var( 'sitemap-stylesheet' ) ) {
|
||||
$set_404 = false;
|
||||
|
||||
// If posts were found, check for paged content.
|
||||
|
||||
@@ -599,10 +599,14 @@ html:lang(he-il) .rtl #wpadminbar * {
|
||||
content: none;
|
||||
}
|
||||
|
||||
#wpadminbar #wp-admin-bar-site-name > .ab-item .site-icon {
|
||||
/* The adminbar icon needs additional styling to prevent 3rd party styles from overriding the size. */
|
||||
#wpadminbar #wp-admin-bar-site-name > .ab-item img.site-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background: #f0f0f1; /* matching my-account (user avatar) node's background */
|
||||
max-width: 20px;
|
||||
max-height: 20px;
|
||||
min-width: 20px;
|
||||
min-height: 20px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
@@ -940,12 +944,24 @@ html:lang(he-il) .rtl #wpadminbar * {
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
#wpadminbar #wp-admin-bar-site-name > .ab-item .site-icon {
|
||||
/*
|
||||
* Flex prevents `text-indent` from hiding the site title, and is unused here
|
||||
* since the icon is positioned absolutely below.
|
||||
*/
|
||||
#wpadminbar #wp-admin-bar-site-name.has-site-icon > .ab-item {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#wpadminbar #wp-admin-bar-site-name > .ab-item img.site-icon {
|
||||
position: absolute;
|
||||
top: 9px;
|
||||
right: 12px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
max-width: 28px;
|
||||
max-height: 28px;
|
||||
min-width: 28px;
|
||||
min-height: 28px;
|
||||
margin: 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -598,10 +598,14 @@ html:lang(he-il) .rtl #wpadminbar * {
|
||||
content: none;
|
||||
}
|
||||
|
||||
#wpadminbar #wp-admin-bar-site-name > .ab-item .site-icon {
|
||||
/* The adminbar icon needs additional styling to prevent 3rd party styles from overriding the size. */
|
||||
#wpadminbar #wp-admin-bar-site-name > .ab-item img.site-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background: #f0f0f1; /* matching my-account (user avatar) node's background */
|
||||
max-width: 20px;
|
||||
max-height: 20px;
|
||||
min-width: 20px;
|
||||
min-height: 20px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
@@ -939,12 +943,24 @@ html:lang(he-il) .rtl #wpadminbar * {
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
#wpadminbar #wp-admin-bar-site-name > .ab-item .site-icon {
|
||||
/*
|
||||
* Flex prevents `text-indent` from hiding the site title, and is unused here
|
||||
* since the icon is positioned absolutely below.
|
||||
*/
|
||||
#wpadminbar #wp-admin-bar-site-name.has-site-icon > .ab-item {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#wpadminbar #wp-admin-bar-site-name > .ab-item img.site-icon {
|
||||
position: absolute;
|
||||
top: 9px;
|
||||
left: 12px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
max-width: 28px;
|
||||
max-height: 28px;
|
||||
min-width: 28px;
|
||||
min-height: 28px;
|
||||
margin: 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -59,7 +59,10 @@
|
||||
}
|
||||
|
||||
.wp-block-accordion-panel[hidden] {
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
margin-block-start: 0;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.wp-block-archives {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -59,7 +59,10 @@
|
||||
}
|
||||
|
||||
.wp-block-accordion-panel[hidden] {
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
margin-block-start: 0;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.wp-block-archives {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -15,6 +15,17 @@
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @see WP_Customize_Setting
|
||||
*
|
||||
* @phpstan-type Header_Image_Data array{
|
||||
* attachment_id?: int,
|
||||
* url?: string,
|
||||
* thumbnail_url?: string,
|
||||
* timestamp?: int,
|
||||
* width?: int,
|
||||
* height?: int,
|
||||
* alt_text?: string,
|
||||
* attachment_parent?: int,
|
||||
* }
|
||||
*/
|
||||
final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting {
|
||||
|
||||
@@ -62,4 +73,163 @@ final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes a header value.
|
||||
*
|
||||
* The value is expected to be one of the following:
|
||||
*
|
||||
* - An array of header image data, with the keys `attachment_id`, `url`, `thumbnail_url`, `timestamp`, `width`,
|
||||
* `height`, `alt_text`, and `attachment_parent`, as supplied by {@see get_uploaded_header_images()}. Any other
|
||||
* key is discarded.
|
||||
* - An array with a `choice` key, being the legacy format in which any of the other accepted values is nested.
|
||||
* - The string `remove-header`, `random-default-image`, or `random-uploaded-image`.
|
||||
* - A string corresponding to one of the keys for the array returned by {@see get_uploaded_header_images()}, or
|
||||
* one of the keys for the array passed into {@see register_default_headers()}.
|
||||
*
|
||||
* @since 7.1.1
|
||||
*
|
||||
* @see WP_Customize_Header_Image_Setting::update()
|
||||
* @see Custom_Image_Header::set_header_image()
|
||||
*
|
||||
* @param mixed $value Value to sanitize.
|
||||
* @return array|string|WP_Error|null Sanitized value, or `null`/`WP_Error` if invalid. The array holds
|
||||
* the header image data, or that data nested under a `choice` key,
|
||||
* before the `customize_sanitize_header_image_data` filter, which
|
||||
* may return anything, is applied to it.
|
||||
*
|
||||
* @phpstan-return array<mixed, mixed>|string|WP_Error|null
|
||||
*/
|
||||
public function sanitize( $value ) {
|
||||
/*
|
||||
* The update() method unwraps the legacy `choice` format before handing the value off to
|
||||
* Custom_Image_Header::set_header_image(), so the nested value is what must be sanitized.
|
||||
*/
|
||||
if ( is_array( $value ) && isset( $value['choice'] ) ) {
|
||||
$choice = $this->sanitize_choice( $value['choice'] );
|
||||
if ( is_null( $choice ) || is_wp_error( $choice ) ) {
|
||||
return $choice;
|
||||
}
|
||||
$value = array( 'choice' => $choice );
|
||||
} else {
|
||||
$value = $this->sanitize_choice( $value );
|
||||
if ( is_null( $value ) || is_wp_error( $value ) ) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
return parent::sanitize( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes a header image choice.
|
||||
*
|
||||
* This is the value which is ultimately passed to {@see Custom_Image_Header::set_header_image()}, whether
|
||||
* supplied at the top level of the setting value or nested under its legacy `choice` key.
|
||||
*
|
||||
* @since 7.1.1
|
||||
*
|
||||
* @param mixed $value Value to sanitize.
|
||||
* @return array|string|WP_Error|null Sanitized value, or `null`/`WP_Error` if invalid.
|
||||
*
|
||||
* @phpstan-return Header_Image_Data|string|WP_Error|null
|
||||
*/
|
||||
private function sanitize_choice( $value ) {
|
||||
// Custom_Image_Header::set_header_image() accepts an object in place of an array.
|
||||
if ( is_object( $value ) ) {
|
||||
$value = (array) $value;
|
||||
}
|
||||
|
||||
if ( is_string( $value ) ) {
|
||||
return sanitize_text_field( $value );
|
||||
}
|
||||
|
||||
if ( ! is_array( $value ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* The sanitized value is assembled member by member rather than filtered down from the
|
||||
* supplied one, so that nothing but the members below can end up in it.
|
||||
*/
|
||||
$sanitized = array();
|
||||
|
||||
if ( isset( $value['attachment_id'] ) ) {
|
||||
if ( ! is_scalar( $value['attachment_id'] ) ) {
|
||||
return null;
|
||||
}
|
||||
$attachment_id = absint( $value['attachment_id'] );
|
||||
|
||||
/*
|
||||
* A supplied attachment must be an existing image, since its ID is written to postmeta and its
|
||||
* data displayed. Note that an ID of zero must be skipped rather than looked up, as
|
||||
* get_post_mime_type() falls back to the global post when passed an empty value.
|
||||
*/
|
||||
if ( $attachment_id > 0 ) {
|
||||
$mime_type = get_post_mime_type( $attachment_id );
|
||||
if ( ! is_string( $mime_type ) || ! str_starts_with( $mime_type, 'image/' ) ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$sanitized['attachment_id'] = $attachment_id;
|
||||
}
|
||||
|
||||
if ( isset( $value['url'] ) ) {
|
||||
if ( ! is_string( $value['url'] ) ) {
|
||||
return null;
|
||||
}
|
||||
$sanitized['url'] = sanitize_url( $value['url'] );
|
||||
if ( '' === $sanitized['url'] ) {
|
||||
return new WP_Error( 'invalid_url', __( 'Invalid URL.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $value['thumbnail_url'] ) ) {
|
||||
if ( ! is_string( $value['thumbnail_url'] ) ) {
|
||||
return null;
|
||||
}
|
||||
$sanitized['thumbnail_url'] = sanitize_url( $value['thumbnail_url'] );
|
||||
if ( '' === $sanitized['thumbnail_url'] ) {
|
||||
return new WP_Error( 'invalid_url', __( 'Invalid URL.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $value['timestamp'] ) ) {
|
||||
if ( ! is_scalar( $value['timestamp'] ) ) {
|
||||
return null;
|
||||
}
|
||||
$sanitized['timestamp'] = absint( $value['timestamp'] );
|
||||
}
|
||||
|
||||
if ( isset( $value['width'] ) ) {
|
||||
if ( ! is_scalar( $value['width'] ) ) {
|
||||
return null;
|
||||
}
|
||||
$sanitized['width'] = absint( $value['width'] );
|
||||
}
|
||||
|
||||
if ( isset( $value['height'] ) ) {
|
||||
if ( ! is_scalar( $value['height'] ) ) {
|
||||
return null;
|
||||
}
|
||||
$sanitized['height'] = absint( $value['height'] );
|
||||
}
|
||||
|
||||
if ( isset( $value['alt_text'] ) ) {
|
||||
if ( ! is_string( $value['alt_text'] ) ) {
|
||||
return null;
|
||||
}
|
||||
$sanitized['alt_text'] = sanitize_text_field( $value['alt_text'] );
|
||||
}
|
||||
|
||||
if ( isset( $value['attachment_parent'] ) ) {
|
||||
if ( ! is_scalar( $value['attachment_parent'] ) ) {
|
||||
return null;
|
||||
}
|
||||
$sanitized['attachment_parent'] = absint( $value['attachment_parent'] );
|
||||
}
|
||||
|
||||
return $sanitized;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,7 +560,7 @@ function wpautop( $text, $br = true ) {
|
||||
$text = preg_replace( '|<p>(<li.+?)</p>|', '$1', $text );
|
||||
|
||||
// If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>.
|
||||
$text = preg_replace( '|<p><blockquote([^>]*)>|i', '<blockquote$1><p>', $text );
|
||||
$text = preg_replace( '!<p><blockquote((?:[^>"\']|"[^"]*"|\'[^\']*\')*)>!i', '<blockquote$1><p>', $text );
|
||||
$text = str_replace( '</blockquote></p>', '</p></blockquote>', $text );
|
||||
|
||||
// If an opening or closing block element tag is preceded by an opening <p> tag, remove it.
|
||||
|
||||
@@ -384,7 +384,7 @@ function get_search_form( $args = array() ) {
|
||||
* @type string $id Unique ID for the popover element. Default is a
|
||||
* generated unique ID.
|
||||
* @type string $button Existing `button` or `a` markup. Used instead of generated button.
|
||||
* Default standard button HTML.
|
||||
* Default empty string.
|
||||
* @type string $label Not used for tooltips.
|
||||
* @type string $close_label Not used for tooltips.
|
||||
* @type string $icon Dashicons icon class for the toggle button.
|
||||
@@ -414,7 +414,7 @@ function wp_get_tooltip( $content, $args = array() ) {
|
||||
* @type string $id Unique ID for the popover element. Default is a
|
||||
* generated unique ID.
|
||||
* @type string $button Existing `button` markup. Used instead of generated button.
|
||||
* Default standard button HTML.
|
||||
* Default empty string.
|
||||
* @type string $label Accessible label for the toggle button.
|
||||
* Default 'Help', matching the default icon.
|
||||
* Ignored for tooltips.
|
||||
@@ -449,7 +449,7 @@ function wp_get_toggletip( $content, $args = array() ) {
|
||||
* @type string $id Unique ID for the popover element. Default is a
|
||||
* generated unique ID.
|
||||
* @type string $button Existing `button` or `a` markup. Used instead of generated button.
|
||||
* Default standard button HTML.
|
||||
* Default empty string.
|
||||
* @type string $label Accessible label for the toggle button.
|
||||
* Default 'Help', matching the default icon.
|
||||
* Ignored for tooltips.
|
||||
@@ -473,7 +473,7 @@ function wp_get_tooltip_helper( $content, $args = array() ) {
|
||||
|
||||
$defaults = array(
|
||||
'id' => wp_unique_id( 'wp-tooltip-' ),
|
||||
'button' => '<button type="button" aria-label="%3$s"><span class="dashicons %4$s" aria-hidden="true"></span></button>',
|
||||
'button' => '',
|
||||
'label' => __( 'Help' ),
|
||||
'close_label' => __( 'Close' ),
|
||||
'icon' => 'dashicons-editor-help',
|
||||
@@ -488,39 +488,67 @@ function wp_get_tooltip_helper( $content, $args = array() ) {
|
||||
$classes .= ' ' . $args['class'];
|
||||
}
|
||||
|
||||
$icon = ( $args['icon'] ) ? trim( $args['icon'] ) : $defaults['icon'];
|
||||
$id = ( $args['id'] ) ? $args['id'] : $defaults['id'];
|
||||
$button = ( $args['button'] ) ? $args['button'] : $defaults['button'];
|
||||
$processed = false;
|
||||
$icon = ( $args['icon'] ) ? trim( $args['icon'] ) : $defaults['icon'];
|
||||
$id = ( $args['id'] ) ? $args['id'] : $defaults['id'];
|
||||
|
||||
// Tooltips use the content as the accessible name; toggletips use the label.
|
||||
$label = ( 'tooltip' === $args['type'] ) ? wp_strip_all_tags( $content, true ) : $args['label'];
|
||||
|
||||
/*
|
||||
* The generated button is a plain skeleton. Every dynamic attribute is
|
||||
* added through the tag processor below, so caller-supplied markup is
|
||||
* never scanned or substituted and a percent sign in custom markup,
|
||||
* such as a percent-encoded URL, is never treated as a conversion
|
||||
* specification.
|
||||
*/
|
||||
$default_button = '<button type="button"><span></span></button>';
|
||||
|
||||
$is_default = ! $args['button'];
|
||||
$button = ( $args['button'] ) ? $args['button'] : $default_button;
|
||||
|
||||
// The accepted root element is a `button`, or an `a` for tooltips.
|
||||
$tag = false;
|
||||
$processor = new WP_HTML_Tag_Processor( $button );
|
||||
if ( true === $processor->next_tag( 'button' ) ) {
|
||||
$processor->add_class( 'wp-tooltip__toggle' );
|
||||
if ( 'tooltip' !== $args['type'] ) {
|
||||
$processor->set_attribute( 'popovertarget', '%2$s' );
|
||||
$processor->set_attribute( 'aria-haspopup', 'dialog' );
|
||||
}
|
||||
$button = $processor->get_updated_html();
|
||||
$processed = true;
|
||||
$tag = 'button';
|
||||
} else {
|
||||
// Reset processor.
|
||||
$processor = new WP_HTML_Tag_Processor( $button );
|
||||
if ( true === $processor->next_tag( 'a' ) && 'tooltip' === $args['type'] ) {
|
||||
$processor->add_class( 'wp-tooltip__toggle' );
|
||||
$button = $processor->get_updated_html();
|
||||
$processed = true;
|
||||
if ( 'tooltip' === $args['type'] && true === $processor->next_tag( 'a' ) ) {
|
||||
$tag = 'a';
|
||||
}
|
||||
}
|
||||
if ( ! $processed ) {
|
||||
// Button HTML passed was not valid.
|
||||
$processor = new WP_HTML_Tag_Processor( $defaults['button'] );
|
||||
$processor->add_class( 'wp-tooltip__toggle' );
|
||||
if ( 'tooltip' !== $args['type'] ) {
|
||||
$processor->set_attribute( 'popovertarget', '%2$s' );
|
||||
$processor->set_attribute( 'aria-haspopup', 'dialog' );
|
||||
}
|
||||
$button = $processor->get_updated_html();
|
||||
|
||||
if ( false === $tag ) {
|
||||
// Button HTML passed was not valid. Reset to default.
|
||||
$is_default = true;
|
||||
$button = $default_button;
|
||||
$processor = new WP_HTML_Tag_Processor( $button );
|
||||
$processor->next_tag( 'button' );
|
||||
$tag = 'button';
|
||||
}
|
||||
|
||||
/*
|
||||
* Attributes that apply to every accepted button are added in one pass.
|
||||
* Attributes that name the control are only added when the caller's
|
||||
* markup did not already provide them.
|
||||
*/
|
||||
if ( null === $processor->get_attribute( 'aria-label' ) ) {
|
||||
$processor->set_attribute( 'aria-label', $label );
|
||||
}
|
||||
$processor->add_class( 'wp-tooltip__toggle' );
|
||||
if ( 'button' === $tag && 'tooltip' !== $args['type'] ) {
|
||||
$processor->set_attribute( 'popovertarget', $id );
|
||||
$processor->set_attribute( 'aria-haspopup', 'dialog' );
|
||||
}
|
||||
|
||||
// The generated button also carries the dashicon on its inner span.
|
||||
if ( $is_default && true === $processor->next_tag( 'span' ) ) {
|
||||
$processor->set_attribute( 'class', 'dashicons ' . $icon );
|
||||
$processor->set_attribute( 'aria-hidden', 'true' );
|
||||
}
|
||||
|
||||
$button = $processor->get_updated_html();
|
||||
|
||||
/*
|
||||
* The markup only uses phrasing content so it is valid when nested
|
||||
* in a phrasing context. Sectioning content (e.g. `div`, `dialog`) will
|
||||
@@ -528,11 +556,9 @@ function wp_get_tooltip_helper( $content, $args = array() ) {
|
||||
* the layout. See #65660.
|
||||
*/
|
||||
if ( 'tooltip' === $args['type'] ) {
|
||||
// Tooltips are only used to visually display labels.
|
||||
$label = wp_strip_all_tags( $content, true );
|
||||
$markup = sprintf(
|
||||
'<span class="%1$s">
|
||||
' . $button . '
|
||||
%6$s
|
||||
<span popover="hint" id="%2$s" class="wp-tooltip__bubble" role="tooltip">' .
|
||||
'<span id="%2$s-text" class="wp-tooltip__text">%5$s</span>' .
|
||||
'</span>' .
|
||||
@@ -542,6 +568,7 @@ function wp_get_tooltip_helper( $content, $args = array() ) {
|
||||
esc_attr( $label ),
|
||||
esc_attr( $icon ),
|
||||
esc_html( $content ),
|
||||
$button,
|
||||
);
|
||||
} else {
|
||||
/*
|
||||
@@ -551,7 +578,7 @@ function wp_get_tooltip_helper( $content, $args = array() ) {
|
||||
*/
|
||||
$markup = sprintf(
|
||||
'<span class="%1$s">
|
||||
' . $button . '
|
||||
%7$s
|
||||
<span popover="auto" id="%2$s" class="wp-tooltip__bubble" role="dialog" aria-label="%3$s" tabindex="-1" autofocus>' .
|
||||
'<span id="%2$s-text" class="wp-tooltip__text">%5$s</span>' .
|
||||
'<button type="button" class="wp-tooltip__close" popovertarget="%2$s" popovertargetaction="hide" aria-label="%6$s">' .
|
||||
@@ -561,10 +588,11 @@ function wp_get_tooltip_helper( $content, $args = array() ) {
|
||||
'</span>',
|
||||
esc_attr( $classes ),
|
||||
esc_attr( $id ),
|
||||
esc_attr( $args['label'] ),
|
||||
esc_attr( $label ),
|
||||
esc_attr( $icon ),
|
||||
esc_html( $content ),
|
||||
esc_attr( $args['close_label'] ),
|
||||
$button,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3988,7 +3988,7 @@ class WP_HTML_Tag_Processor {
|
||||
self::COMMENT_AS_HTML_COMMENT === $this->comment_type
|
||||
) {
|
||||
// Check if the text could close the comment.
|
||||
if ( 1 === preg_match( '/--!?>/', $plaintext_content ) ) {
|
||||
if ( 1 === preg_match( '/^-?>|--!?>/', $plaintext_content ) ) {
|
||||
_doing_it_wrong(
|
||||
__METHOD__,
|
||||
__( 'Comment text cannot contain a comment closer.' ),
|
||||
|
||||
Vendored
+1300
-1280
File diff suppressed because it is too large
Load Diff
+32
-32
File diff suppressed because one or more lines are too long
Vendored
+121
-46
@@ -29319,6 +29319,13 @@ ${url}
|
||||
function defaultColumnsNumber(imageCount) {
|
||||
return imageCount ? Math.min(3, imageCount) : 3;
|
||||
}
|
||||
function isObject(value) {
|
||||
return !!value && typeof value === "object" && !Array.isArray(value);
|
||||
}
|
||||
function isGalleryFlexLayout(layout) {
|
||||
const layoutType = isObject(layout) ? layout.type : void 0;
|
||||
return typeof layoutType !== "string" || layoutType === "" || layoutType === "flex";
|
||||
}
|
||||
var pickRelevantMediaFiles = (image, sizeSlug = "large") => {
|
||||
const imageProps = Object.fromEntries(
|
||||
Object.entries(image ?? {}).filter(
|
||||
@@ -30529,9 +30536,10 @@ ${url}
|
||||
)
|
||||
] });
|
||||
}
|
||||
function GalleryImagesPreview({ imageBlocks }) {
|
||||
function GalleryImagesPreview({ imageBlocks, layout }) {
|
||||
const { children, ref, className } = (0, import_block_editor97.__experimentalUseBlockPreview)({
|
||||
blocks: imageBlocks
|
||||
blocks: imageBlocks,
|
||||
layout
|
||||
});
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(
|
||||
"div",
|
||||
@@ -30563,6 +30571,10 @@ ${url}
|
||||
} = dynamic;
|
||||
const blockEditingMode = (0, import_block_editor97.useBlockEditingMode)();
|
||||
const [isConfirmingDetach, setIsConfirmingDetach] = (0, import_element44.useState)(false);
|
||||
const previewLayout = (0, import_element44.useMemo)(
|
||||
() => isGalleryFlexLayout(attributes.layout) ? { ...attributes.layout, type: "flex" } : attributes.layout,
|
||||
[attributes.layout]
|
||||
);
|
||||
const emptyInstructions = isResolvingDynamic ? (0, import_i18n79.__)("Loading images\u2026") : sourceDescriptor?.emptyMessage ?? (0, import_i18n79.__)("Dynamic images will appear here.");
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime274.jsxs)(import_jsx_runtime274.Fragment, { children: [
|
||||
blockEditingMode === "default" && /* @__PURE__ */ (0, import_jsx_runtime274.jsxs)(import_jsx_runtime274.Fragment, { children: [
|
||||
@@ -30589,7 +30601,8 @@ ${url}
|
||||
dynamicImageBlocks.length ? /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(import_block_editor97.BlockContextProvider, { value: galleryContext, children: /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(
|
||||
GalleryImagesPreview,
|
||||
{
|
||||
imageBlocks: dynamicImageBlocks
|
||||
imageBlocks: dynamicImageBlocks,
|
||||
layout: previewLayout
|
||||
}
|
||||
) }) : /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(
|
||||
import_components45.Placeholder,
|
||||
@@ -36185,6 +36198,42 @@ ${text}
|
||||
}
|
||||
return syncedAttributes;
|
||||
}
|
||||
function getNewAttachmentSizeAttributes(sizeSlug, attachment) {
|
||||
const sizes = attachment.media_details?.sizes;
|
||||
if (!sizeSlug || sizeSlug === DEFAULT_MEDIA_SIZE_SLUG3 || !sizes) {
|
||||
return void 0;
|
||||
}
|
||||
const sizeUrl = sizes[sizeSlug]?.source_url;
|
||||
if (sizeUrl) {
|
||||
return { url: sizeUrl };
|
||||
}
|
||||
const fullUrl = attachment.source_url ?? sizes.full?.source_url;
|
||||
return fullUrl ? { url: fullUrl, sizeSlug: DEFAULT_MEDIA_SIZE_SLUG3 } : void 0;
|
||||
}
|
||||
function getNewAttachmentLinkAttributes(linkDestination, attachment) {
|
||||
if (linkDestination === LINK_DESTINATION_MEDIA2) {
|
||||
return attachment.source_url ? { href: attachment.source_url } : void 0;
|
||||
}
|
||||
if (linkDestination === LINK_DESTINATION_ATTACHMENT2) {
|
||||
return attachment.link ? { href: attachment.link } : void 0;
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
function getNewAttachmentImageBlockAttributes(blockAttributes8, attachment) {
|
||||
if (!attachment) {
|
||||
return void 0;
|
||||
}
|
||||
return {
|
||||
...getNewAttachmentSizeAttributes(
|
||||
blockAttributes8.sizeSlug,
|
||||
attachment
|
||||
),
|
||||
...getNewAttachmentLinkAttributes(
|
||||
blockAttributes8.linkDestination,
|
||||
attachment
|
||||
)
|
||||
};
|
||||
}
|
||||
var { openMediaEditorModalKey: openMediaEditorModalKey2 } = unlock(import_block_editor115.privateApis);
|
||||
function getAttachmentFallbackForEmptyBlockMetadata({ alt, caption }) {
|
||||
const attachment = {};
|
||||
@@ -36210,7 +36259,7 @@ ${text}
|
||||
onClose,
|
||||
onUrlChange
|
||||
}) {
|
||||
const { id, url, alt, caption } = attributes;
|
||||
const { id, url, alt, caption, sizeSlug, linkDestination } = attributes;
|
||||
const registry = (0, import_data50.useRegistry)();
|
||||
const openMediaEditorModal = (0, import_data50.useSelect)(
|
||||
(select10) => select10(import_block_editor115.store).getSettings()[openMediaEditorModalKey2],
|
||||
@@ -36220,7 +36269,9 @@ ${text}
|
||||
id,
|
||||
url,
|
||||
alt,
|
||||
caption: caption?.toString()
|
||||
caption: caption?.toString(),
|
||||
sizeSlug,
|
||||
linkDestination
|
||||
});
|
||||
const mediaEditorMetadataBaselineRef = (0, import_element56.useRef)();
|
||||
const mediaEditorMetadataSyncRequestRef = (0, import_element56.useRef)(0);
|
||||
@@ -36229,9 +36280,11 @@ ${text}
|
||||
id,
|
||||
url,
|
||||
alt,
|
||||
caption: caption?.toString()
|
||||
caption: caption?.toString(),
|
||||
sizeSlug,
|
||||
linkDestination
|
||||
};
|
||||
}, [alt, caption, id, url]);
|
||||
}, [alt, caption, id, linkDestination, sizeSlug, url]);
|
||||
const getCachedAttachmentRecord = (0, import_element56.useCallback)(
|
||||
(attachmentId) => registry.select(import_core_data25.store).getEditedEntityRecord(
|
||||
"postType",
|
||||
@@ -36277,7 +36330,8 @@ ${text}
|
||||
const syncRequest = ++mediaEditorMetadataSyncRequestRef.current;
|
||||
const nextAttributes = {};
|
||||
const currentBlockAttributes = blockAttributesRef.current;
|
||||
if (newId !== currentBlockAttributes.id) {
|
||||
const isNewAttachment = newId !== currentBlockAttributes.id;
|
||||
if (isNewAttachment) {
|
||||
nextAttributes.id = newId;
|
||||
nextAttributes.url = newUrl ?? currentBlockAttributes.url;
|
||||
if (nextAttributes.url !== currentBlockAttributes.url) {
|
||||
@@ -36289,19 +36343,37 @@ ${text}
|
||||
url: nextAttributes.url
|
||||
};
|
||||
}
|
||||
if (originalAttachment) {
|
||||
if (originalAttachment || isNewAttachment) {
|
||||
const resolvedAttachment = await resolveFreshAttachmentRecord(newId);
|
||||
if (syncRequest !== mediaEditorMetadataSyncRequestRef.current) {
|
||||
return;
|
||||
}
|
||||
const attachmentRecord = resolvedAttachment ?? getCachedAttachmentRecord(newId);
|
||||
const latestBlockAttributes = blockAttributesRef.current;
|
||||
const resolvedMetadataAttributes = getSyncedImageBlockAttributes(
|
||||
latestBlockAttributes,
|
||||
originalAttachment,
|
||||
resolvedAttachment
|
||||
);
|
||||
if (Object.keys(resolvedMetadataAttributes).length) {
|
||||
Object.assign(nextAttributes, resolvedMetadataAttributes);
|
||||
if (originalAttachment) {
|
||||
const resolvedMetadataAttributes = getSyncedImageBlockAttributes(
|
||||
latestBlockAttributes,
|
||||
originalAttachment,
|
||||
attachmentRecord
|
||||
);
|
||||
if (Object.keys(resolvedMetadataAttributes).length) {
|
||||
Object.assign(
|
||||
nextAttributes,
|
||||
resolvedMetadataAttributes
|
||||
);
|
||||
}
|
||||
}
|
||||
if (isNewAttachment) {
|
||||
const derivedAttributes = getNewAttachmentImageBlockAttributes(
|
||||
latestBlockAttributes,
|
||||
attachmentRecord
|
||||
);
|
||||
if (derivedAttributes) {
|
||||
Object.assign(nextAttributes, derivedAttributes);
|
||||
if (derivedAttributes.url && derivedAttributes.url !== latestBlockAttributes.url) {
|
||||
onUrlChange?.(derivedAttributes.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Object.keys(nextAttributes).length) {
|
||||
@@ -36312,7 +36384,12 @@ ${text}
|
||||
setAttributes(nextAttributes);
|
||||
}
|
||||
},
|
||||
[onUrlChange, resolveFreshAttachmentRecord, setAttributes]
|
||||
[
|
||||
getCachedAttachmentRecord,
|
||||
onUrlChange,
|
||||
resolveFreshAttachmentRecord,
|
||||
setAttributes
|
||||
]
|
||||
);
|
||||
const openImageMediaEditorModal = (0, import_element56.useCallback)(async () => {
|
||||
if (!id || !openMediaEditorModal) {
|
||||
@@ -36563,7 +36640,8 @@ ${text}
|
||||
setOffsetTop(imageElement?.offsetTop ?? 0);
|
||||
}, [imageElement]);
|
||||
const setRefs = (0, import_compose24.useMergeRefs)([setImageElement, setResizeObserved]);
|
||||
const { allowResize = true } = context;
|
||||
const { allowResize = true, imageCrop = false } = context;
|
||||
const isCroppedGalleryImage = imageCrop && parentLayoutType === "flex";
|
||||
const { image, attachmentResolutionError } = (0, import_data51.useSelect)(
|
||||
(select10) => {
|
||||
const imageRecord = id && isSingleSelected ? select10(import_core_data26.store).getEntityRecord(
|
||||
@@ -37287,10 +37365,12 @@ ${text}
|
||||
} else if (width !== void 0 && width !== null) {
|
||||
style2.width = typeof width === "number" ? `${width}px` : width;
|
||||
}
|
||||
if (height === "auto" || height === void 0 || height === null) {
|
||||
if (height === "auto") {
|
||||
style2.height = "auto";
|
||||
} else {
|
||||
} else if (height !== void 0 && height !== null) {
|
||||
style2.height = typeof height === "number" ? `${height}px` : height;
|
||||
} else if (!isCroppedGalleryImage) {
|
||||
style2.height = "auto";
|
||||
}
|
||||
return style2;
|
||||
})(),
|
||||
@@ -40887,20 +40967,14 @@ ${text}
|
||||
var import_blocks45 = __toESM(require_blocks(), 1);
|
||||
function useOutdentListItem() {
|
||||
const registry = (0, import_data57.useRegistry)();
|
||||
const {
|
||||
moveBlocksToPosition,
|
||||
removeBlock,
|
||||
insertBlock,
|
||||
updateBlockListSettings
|
||||
} = (0, import_data57.useDispatch)(import_block_editor128.store);
|
||||
const { moveBlocksToPosition, removeBlock, removeBlocks, insertBlock } = (0, import_data57.useDispatch)(import_block_editor128.store);
|
||||
const {
|
||||
getBlockRootClientId,
|
||||
getBlockName,
|
||||
getBlockOrder,
|
||||
getBlockIndex,
|
||||
getSelectedBlockClientIds,
|
||||
getBlock,
|
||||
getBlockListSettings
|
||||
getBlock
|
||||
} = (0, import_data57.useSelect)(import_block_editor128.store);
|
||||
function getParentListItemId(id) {
|
||||
const listId = getBlockRootClientId(id);
|
||||
@@ -40936,25 +41010,22 @@ ${text}
|
||||
);
|
||||
registry.batch(() => {
|
||||
if (followingListItems.length) {
|
||||
let nestedListId = getBlockOrder(firstClientId)[0];
|
||||
if (!nestedListId) {
|
||||
const nestedListId = getBlockOrder(firstClientId)[0];
|
||||
if (nestedListId) {
|
||||
moveBlocksToPosition(
|
||||
followingListItems,
|
||||
parentListId,
|
||||
nestedListId
|
||||
);
|
||||
} else {
|
||||
const nestedListBlock = (0, import_blocks45.cloneBlock)(
|
||||
getBlock(parentListId),
|
||||
{},
|
||||
[]
|
||||
followingListItems.map((id) => getBlock(id))
|
||||
);
|
||||
nestedListId = nestedListBlock.clientId;
|
||||
removeBlocks(followingListItems, false);
|
||||
insertBlock(nestedListBlock, 0, firstClientId, false);
|
||||
updateBlockListSettings(
|
||||
nestedListId,
|
||||
getBlockListSettings(parentListId)
|
||||
);
|
||||
}
|
||||
moveBlocksToPosition(
|
||||
followingListItems,
|
||||
parentListId,
|
||||
nestedListId
|
||||
);
|
||||
}
|
||||
moveBlocksToPosition(
|
||||
clientIds,
|
||||
@@ -60530,7 +60601,9 @@ ${text}
|
||||
query: {
|
||||
perPage,
|
||||
offset = 0,
|
||||
postType,
|
||||
// Match `build_query_vars_from_query_block()`, which queries posts when
|
||||
// `query` has no post type.
|
||||
postType = "post",
|
||||
order,
|
||||
orderBy,
|
||||
author,
|
||||
@@ -64047,7 +64120,9 @@ ${text}
|
||||
orderBy,
|
||||
author: authorIds,
|
||||
pages,
|
||||
postType,
|
||||
// Match `build_query_vars_from_query_block()`, which queries posts when
|
||||
// `query` has no post type.
|
||||
postType = "post",
|
||||
perPage,
|
||||
offset,
|
||||
sticky,
|
||||
@@ -64135,7 +64210,7 @@ ${text}
|
||||
);
|
||||
const showExcludeCurrentControl = shouldExcludeCurrentPost && isControlAllowed(allowedControls, "excludeCurrent");
|
||||
const postTypeSingularName = (0, import_data125.useSelect)(
|
||||
(select10) => select10(import_core_data77.store).getPostType(postType)?.labels.singular_name,
|
||||
(select10) => select10(import_core_data77.store).getPostType(postType)?.labels?.singular_name,
|
||||
[postType]
|
||||
);
|
||||
const showFiltersPanel = showTaxControl || showAuthorControl || showSearchControl || showParentControl || showFormatControl || showExcludeCurrentControl;
|
||||
@@ -68050,7 +68125,7 @@ ${text}
|
||||
}
|
||||
|
||||
// packages/block-library/build-module/block/deprecated.mjs
|
||||
var isObject = (obj) => typeof obj === "object" && !Array.isArray(obj) && obj !== null;
|
||||
var isObject2 = (obj) => typeof obj === "object" && !Array.isArray(obj) && obj !== null;
|
||||
var v219 = {
|
||||
attributes: {
|
||||
ref: {
|
||||
@@ -68073,7 +68148,7 @@ ${text}
|
||||
// the likelihood, it doesn't solve it completely.
|
||||
isEligible({ content }) {
|
||||
return !!content && Object.keys(content).every(
|
||||
(contentKey) => content[contentKey].values && isObject(content[contentKey].values)
|
||||
(contentKey) => content[contentKey].values && isObject2(content[contentKey].values)
|
||||
);
|
||||
},
|
||||
/*
|
||||
|
||||
+29
-29
File diff suppressed because one or more lines are too long
Vendored
+24
-3
@@ -11932,7 +11932,6 @@ var wp;
|
||||
core.__experimentalGetCurrentThemeBaseGlobalStyles(),
|
||||
core.__experimentalGetCurrentThemeGlobalStylesVariations(),
|
||||
core.getEntityRecord("root", "__unstableBase"),
|
||||
core.getEntityRecord("root", "site"),
|
||||
core.canUser("read", { kind: "root", name: "site" }),
|
||||
core.canUser("create", { kind: "postType", name: "attachment" }),
|
||||
core.canUser("create", { kind: "postType", name: "page" }),
|
||||
@@ -11970,11 +11969,13 @@ var wp;
|
||||
] : []
|
||||
]);
|
||||
const tasks = [];
|
||||
if (coreSelect.canUser("read", { kind: "root", name: "site" })) {
|
||||
tasks.push(core.getEntityRecord("root", "site"));
|
||||
}
|
||||
const globalStylesId = coreSelect.__experimentalGetCurrentGlobalStylesId();
|
||||
if (globalStylesId) {
|
||||
tasks.push(
|
||||
core.getEntityRecord("root", "globalStyles", globalStylesId),
|
||||
core.canUser("read", {
|
||||
core.canUser("update", {
|
||||
kind: "root",
|
||||
name: "globalStyles",
|
||||
id: globalStylesId
|
||||
@@ -12006,6 +12007,26 @@ var wp;
|
||||
if (tasks.length) {
|
||||
await Promise.all(tasks);
|
||||
}
|
||||
if (globalStylesId) {
|
||||
if (coreSelect.canUser("update", {
|
||||
kind: "root",
|
||||
name: "globalStyles",
|
||||
id: globalStylesId
|
||||
})) {
|
||||
await core.getEntityRecord(
|
||||
"root",
|
||||
"globalStyles",
|
||||
globalStylesId
|
||||
);
|
||||
} else {
|
||||
await core.getEntityRecord(
|
||||
"root",
|
||||
"globalStyles",
|
||||
globalStylesId,
|
||||
{ context: "view" }
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+7
-3
@@ -54928,9 +54928,13 @@ If there's a particular need for this, please submit a feature request at https:
|
||||
const fieldsKey = fieldList ? [...fieldList].sort().join(",") : void 0;
|
||||
return (0, import_data65.useSelect)(
|
||||
(select4) => {
|
||||
return unlock7(select4(import_core_data41.store)).getViewConfig(kind, name2, {
|
||||
fields: fieldsKey
|
||||
});
|
||||
return unlock7(select4(import_core_data41.store)).getViewConfig(
|
||||
kind,
|
||||
name2,
|
||||
fieldsKey ? {
|
||||
fields: fieldsKey
|
||||
} : void 0
|
||||
);
|
||||
},
|
||||
[kind, name2, fieldsKey]
|
||||
);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+3526
-3449
File diff suppressed because it is too large
Load Diff
Vendored
+36
-36
File diff suppressed because one or more lines are too long
Vendored
+3
-11
@@ -1334,7 +1334,7 @@ var wp;
|
||||
return data !== null && typeof data === "object" && Object.getPrototypeOf(data) === Object.prototype;
|
||||
}
|
||||
function flattenFormData(formData, key, data) {
|
||||
if (isPlainObject(data)) {
|
||||
if (Array.isArray(data) || isPlainObject(data)) {
|
||||
for (const [name, value] of Object.entries(data)) {
|
||||
flattenFormData(formData, `${key}[${name}]`, value);
|
||||
}
|
||||
@@ -1361,11 +1361,7 @@ var wp;
|
||||
const data = new FormData();
|
||||
data.append("file", file, file.name || file.type.replace("/", "."));
|
||||
for (const [key, value] of Object.entries(additionalData)) {
|
||||
flattenFormData(
|
||||
data,
|
||||
key,
|
||||
value
|
||||
);
|
||||
flattenFormData(data, key, value);
|
||||
}
|
||||
return transformAttachment(
|
||||
await (0, import_api_fetch.default)({
|
||||
@@ -1587,11 +1583,7 @@ var wp;
|
||||
const data = new FormData();
|
||||
data.append("file", file, file.name || file.type.replace("/", "."));
|
||||
for (const [key, value] of Object.entries(additionalData)) {
|
||||
flattenFormData(
|
||||
data,
|
||||
key,
|
||||
value
|
||||
);
|
||||
flattenFormData(data, key, value);
|
||||
}
|
||||
return (0, import_api_fetch2.default)({
|
||||
path: `/wp/v2/media/${attachmentId}/sideload`,
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => '685442d334b2d3e70832');
|
||||
<?php return array('dependencies' => array(), 'version' => '7e33cd8c4128731126e8');
|
||||
+26
-8
@@ -52894,9 +52894,7 @@ var vips_heif_default = bytes2;
|
||||
|
||||
// packages/vips/src/utils.ts
|
||||
function supportsQuality(type) {
|
||||
return ["image/jpeg", "image/png", "image/webp", "image/avif"].includes(
|
||||
type
|
||||
);
|
||||
return ["image/jpeg", "image/webp", "image/avif"].includes(type);
|
||||
}
|
||||
function supportsAnimation(type) {
|
||||
return ["image/webp", "image/gif"].includes(type);
|
||||
@@ -52999,6 +52997,9 @@ async function convertImageFormat(id, buffer, inputType, outputType, options = {
|
||||
if (interlaced && supportsInterlace(outputType)) {
|
||||
saveOptions.interlace = interlaced;
|
||||
}
|
||||
if ("image/png" === outputType && isPaletteImage(image)) {
|
||||
saveOptions.palette = true;
|
||||
}
|
||||
if ("image/avif" === outputType) {
|
||||
saveOptions.effort = 2;
|
||||
const sourceBitdepth = getSourceBitdepth(image);
|
||||
@@ -53090,6 +53091,9 @@ function applyResizeAndCrop(resize, originalWidth, originalHeight, smartCrop, cr
|
||||
setImage.call(result, "gainmap", newGainmap);
|
||||
return result;
|
||||
}
|
||||
function isPaletteImage(image) {
|
||||
return image.getTypeof("palette") !== 0;
|
||||
}
|
||||
function getSourceBitdepth(image) {
|
||||
try {
|
||||
const bitdepth = image.getInt("heif-bitdepth");
|
||||
@@ -53110,7 +53114,13 @@ function resolveSaveBitdepth(sourceBitdepth, maxBitdepth) {
|
||||
}
|
||||
return 8;
|
||||
}
|
||||
function buildSaveOptions(type, quality, bitdepth = 8, stripMeta = true) {
|
||||
function buildSaveOptions({
|
||||
type,
|
||||
quality,
|
||||
bitdepth = 8,
|
||||
stripMeta = true,
|
||||
isPalette = false
|
||||
}) {
|
||||
const saveOptions = {
|
||||
// Strip metadata except ICC color profiles or gainmaps,
|
||||
// matching WordPress core's behavior. The \`image_strip_meta\`
|
||||
@@ -53120,6 +53130,9 @@ function buildSaveOptions(type, quality, bitdepth = 8, stripMeta = true) {
|
||||
if (supportsQuality(type)) {
|
||||
saveOptions.Q = quality * 100;
|
||||
}
|
||||
if ("image/png" === type && isPalette) {
|
||||
saveOptions.palette = true;
|
||||
}
|
||||
if ("image/avif" === type) {
|
||||
saveOptions.effort = 2;
|
||||
if (bitdepth > 8) {
|
||||
@@ -53208,12 +53221,13 @@ async function resizeImage(id, buffer, type, resize, options = {}) {
|
||||
return thumb;
|
||||
}
|
||||
);
|
||||
const saveOptions = buildSaveOptions(
|
||||
const saveOptions = buildSaveOptions({
|
||||
type,
|
||||
quality,
|
||||
saveBitdepth,
|
||||
stripMeta
|
||||
);
|
||||
bitdepth: saveBitdepth,
|
||||
stripMeta,
|
||||
isPalette: isPaletteImage(sourceImage)
|
||||
});
|
||||
const outBuffer = image.writeToBuffer(\`.\${ext}\`, saveOptions);
|
||||
const result = {
|
||||
buffer: outBuffer.buffer,
|
||||
@@ -53271,6 +53285,7 @@ async function rotateImage(id, buffer, type, orientation) {
|
||||
image.kill = true;
|
||||
}
|
||||
};
|
||||
const isPalette = isPaletteImage(image);
|
||||
switch (orientation) {
|
||||
case 2:
|
||||
image = image.flipHor();
|
||||
@@ -53296,6 +53311,9 @@ async function rotateImage(id, buffer, type, orientation) {
|
||||
}
|
||||
image.remove("orientation");
|
||||
const saveOptions = {};
|
||||
if ("image/png" === type && isPalette) {
|
||||
saveOptions.palette = true;
|
||||
}
|
||||
const outBuffer = image.writeToBuffer(\`.\${ext}\`, saveOptions);
|
||||
const result = {
|
||||
buffer: outBuffer.buffer,
|
||||
|
||||
Vendored
+72
-43
@@ -194,7 +194,8 @@ var wp;
|
||||
maxConcurrentUploads: DEFAULT_MAX_CONCURRENT_UPLOADS,
|
||||
maxConcurrentImageProcessing: DEFAULT_MAX_CONCURRENT_IMAGE_PROCESSING,
|
||||
retry: { ...DEFAULT_RETRY_SETTINGS }
|
||||
}
|
||||
},
|
||||
failureCount: 0
|
||||
};
|
||||
function reducer(state = DEFAULT_STATE, action = { type: Type.Unknown }) {
|
||||
switch (action.type) {
|
||||
@@ -235,9 +236,13 @@ var wp;
|
||||
...state,
|
||||
queue: [...state.queue, action.item]
|
||||
};
|
||||
case Type.Cancel:
|
||||
case Type.Cancel: {
|
||||
const cancelled = state.queue.find(
|
||||
(item) => item.id === action.id
|
||||
);
|
||||
return {
|
||||
...state,
|
||||
failureCount: cancelled && !cancelled.parentId ? state.failureCount + 1 : state.failureCount,
|
||||
queue: state.queue.map(
|
||||
(item) => item.id === action.id ? {
|
||||
...item,
|
||||
@@ -245,6 +250,7 @@ var wp;
|
||||
} : item
|
||||
)
|
||||
};
|
||||
}
|
||||
case Type.RetryItem:
|
||||
return {
|
||||
...state,
|
||||
@@ -421,6 +427,7 @@ var wp;
|
||||
getAllItems: () => getAllItems,
|
||||
getBlobUrls: () => getBlobUrls,
|
||||
getFailedItems: () => getFailedItems,
|
||||
getFailureCount: () => getFailureCount,
|
||||
getItem: () => getItem,
|
||||
getItemProgress: () => getItemProgress,
|
||||
getPendingImageProcessing: () => getPendingImageProcessing,
|
||||
@@ -433,6 +440,9 @@ var wp;
|
||||
function getAllItems(state) {
|
||||
return state.queue;
|
||||
}
|
||||
function getFailureCount(state) {
|
||||
return state.failureCount;
|
||||
}
|
||||
function getItem(state, id) {
|
||||
return state.queue.find((item) => item.id === id);
|
||||
}
|
||||
@@ -1569,6 +1579,13 @@ var wp;
|
||||
}
|
||||
function readItemData(buffer, loc, idatOffset) {
|
||||
const baseOffset = loc.constructionMethod === 1 ? idatOffset : 0;
|
||||
for (const ext of loc.extents) {
|
||||
if (baseOffset + ext.offset + ext.length > buffer.byteLength) {
|
||||
throw new Error(
|
||||
"HEIC item data extends past the end of the file"
|
||||
);
|
||||
}
|
||||
}
|
||||
if (loc.extents.length === 1) {
|
||||
const ext = loc.extents[0];
|
||||
const start = baseOffset + ext.offset;
|
||||
@@ -2057,6 +2074,8 @@ var wp;
|
||||
}
|
||||
|
||||
// packages/upload-media/build-module/canvas-utils.mjs
|
||||
var HeicUnsupportedError = class extends Error {
|
||||
};
|
||||
async function canvasConvertToJpeg(file, quality = 0.82) {
|
||||
const baseName = getFileBasename(file.name);
|
||||
try {
|
||||
@@ -2114,51 +2133,57 @@ var wp;
|
||||
}
|
||||
}
|
||||
}
|
||||
let heicData;
|
||||
try {
|
||||
heicData = parseHeic(await file.arrayBuffer());
|
||||
} catch (error) {
|
||||
throw new Error("The HEIC file could not be parsed", {
|
||||
cause: error
|
||||
});
|
||||
}
|
||||
if (typeof VideoDecoder !== "undefined") {
|
||||
let supported = false;
|
||||
try {
|
||||
const heicData = parseHeic(await file.arrayBuffer());
|
||||
const support = await VideoDecoder.isConfigSupported({
|
||||
codec: heicData.codecString
|
||||
});
|
||||
if (support.supported) {
|
||||
const canvas = new OffscreenCanvas(
|
||||
heicData.outputWidth,
|
||||
heicData.outputHeight
|
||||
);
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (!ctx) {
|
||||
throw new Error("Could not get canvas 2d context");
|
||||
}
|
||||
for (const tile of heicData.tiles) {
|
||||
const frame = await decodeHevcFrame(
|
||||
heicData.codecString,
|
||||
heicData.description,
|
||||
heicData.tileWidth,
|
||||
heicData.tileHeight,
|
||||
tile.data
|
||||
);
|
||||
try {
|
||||
ctx.drawImage(frame, tile.x, tile.y);
|
||||
} finally {
|
||||
frame.close();
|
||||
}
|
||||
}
|
||||
const outputCanvas = heicData.rotation !== 0 ? applyRotation(canvas, heicData.rotation) : applyExifOrientation(
|
||||
canvas,
|
||||
heicData.exifOrientation
|
||||
);
|
||||
const jpegBlob = await outputCanvas.convertToBlob({
|
||||
type: "image/jpeg",
|
||||
quality
|
||||
});
|
||||
return new File([jpegBlob], `${baseName}.jpg`, {
|
||||
type: "image/jpeg"
|
||||
});
|
||||
}
|
||||
supported = support.supported === true;
|
||||
} catch {
|
||||
}
|
||||
if (supported) {
|
||||
const canvas = new OffscreenCanvas(
|
||||
heicData.outputWidth,
|
||||
heicData.outputHeight
|
||||
);
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (!ctx) {
|
||||
throw new Error("Could not get canvas 2d context");
|
||||
}
|
||||
for (const tile of heicData.tiles) {
|
||||
const frame = await decodeHevcFrame(
|
||||
heicData.codecString,
|
||||
heicData.description,
|
||||
heicData.tileWidth,
|
||||
heicData.tileHeight,
|
||||
tile.data
|
||||
);
|
||||
try {
|
||||
ctx.drawImage(frame, tile.x, tile.y);
|
||||
} finally {
|
||||
frame.close();
|
||||
}
|
||||
}
|
||||
const outputCanvas = heicData.rotation !== 0 ? applyRotation(canvas, heicData.rotation) : applyExifOrientation(canvas, heicData.exifOrientation);
|
||||
const jpegBlob = await outputCanvas.convertToBlob({
|
||||
type: "image/jpeg",
|
||||
quality
|
||||
});
|
||||
return new File([jpegBlob], `${baseName}.jpg`, {
|
||||
type: "image/jpeg"
|
||||
});
|
||||
}
|
||||
}
|
||||
throw new Error(getHeicUnsupportedMessage());
|
||||
throw new HeicUnsupportedError(getHeicUnsupportedMessage());
|
||||
}
|
||||
function applyRotation(source, rotation) {
|
||||
if (rotation === 0) {
|
||||
@@ -2836,13 +2861,17 @@ var wp;
|
||||
file,
|
||||
settings.imageQuality ?? DEFAULT_OUTPUT_QUALITY
|
||||
);
|
||||
} catch {
|
||||
} catch (error) {
|
||||
const unsupported = error instanceof HeicUnsupportedError;
|
||||
dispatch.cancelItem(
|
||||
id,
|
||||
new UploadError({
|
||||
code: ErrorCode.HEIC_DECODE_ERROR,
|
||||
message: getHeicUnsupportedMessage(),
|
||||
file
|
||||
code: unsupported ? ErrorCode.HEIC_DECODE_ERROR : ErrorCode.IMAGE_TRANSCODING_ERROR,
|
||||
message: unsupported ? getHeicUnsupportedMessage() : (0, import_i18n7.__)(
|
||||
"This HEIC image could not be converted. Try converting it to JPEG before uploading."
|
||||
),
|
||||
file,
|
||||
cause: error instanceof Error ? error : void 0
|
||||
})
|
||||
);
|
||||
return;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -8,19 +8,29 @@
|
||||
*/
|
||||
(() => {
|
||||
|
||||
const popovers = /** @type {NodeListOf<HTMLSpanElement>} */ ( document.querySelectorAll( '.wp-is-tooltip' ) );
|
||||
const supportsPopover = /** @type {boolean} */ ( Object.prototype.hasOwnProperty.call( HTMLElement.prototype, 'popover' ) );
|
||||
let hidePopover = false;
|
||||
if ( ! supportsPopover ) {
|
||||
hidePopover = true;
|
||||
}
|
||||
|
||||
/** @type {ReturnType<typeof setTimeout>} */
|
||||
let openTimeout;
|
||||
const popovers = /** @type {NodeListOf<HTMLSpanElement>} */ ( document.querySelectorAll( '.wp-is-tooltip' ) );
|
||||
|
||||
popovers.forEach( function( popover ) {
|
||||
const trigger = /** @type {HTMLButtonElement|HTMLAnchorElement|null} */ ( popover.querySelector( '.wp-tooltip__toggle' ) );
|
||||
const panel = /** @type {HTMLSpanElement|null} */ ( popover.querySelector( 'span.wp-tooltip__bubble' ) );
|
||||
if ( hidePopover && panel ) {
|
||||
panel.classList.add( 'hidden' );
|
||||
|
||||
return;
|
||||
}
|
||||
if ( ! trigger || ! panel ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @type {ReturnType<typeof setTimeout>} */
|
||||
let openTimeout;
|
||||
|
||||
// Show Tooltip Function (with delay to prevent flickering).
|
||||
const showTooltip = () => {
|
||||
clearTimeout( openTimeout );
|
||||
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{var e=document.querySelectorAll(".wp-is-tooltip");let n;e.forEach(function(e){const o=e.querySelector(".wp-tooltip__toggle"),t=e.querySelector("span.wp-tooltip__bubble");var r;o&&t&&(e=()=>{clearTimeout(n),n=setTimeout(()=>{t.matches(":popover-open")||t.showPopover({source:o})},300)},r=()=>{clearTimeout(n),t.matches(":popover-open")&&t.hidePopover()},o.addEventListener("mouseenter",e),o.addEventListener("focus",e),o.addEventListener("mouseleave",r),o.addEventListener("blur",r))})})();
|
||||
(()=>{let e=Object.prototype.hasOwnProperty.call(HTMLElement.prototype,"popover")?!1:!0;document.querySelectorAll(".wp-is-tooltip").forEach(function(o){const t=o.querySelector(".wp-tooltip__toggle"),r=o.querySelector("span.wp-tooltip__bubble");if(e&&r)r.classList.add("hidden");else if(t&&r){let e;var o=()=>{clearTimeout(e),e=setTimeout(()=>{r.matches(":popover-open")||r.showPopover({source:t})},300)},p=()=>{clearTimeout(e),r.matches(":popover-open")&&r.hidePopover()};t.addEventListener("mouseenter",o),t.addEventListener("focus",o),t.addEventListener("mouseleave",p),t.addEventListener("blur",p)}})})();
|
||||
@@ -989,6 +989,7 @@ function _wp_call_all_hook( $args ) {
|
||||
* and no longer returns false, but can still return void for invalid callbacks.
|
||||
* @since 6.9.0 Returns explicit null if an invalid callback is supplied.
|
||||
* @since 7.1.0 Uses spl_object_id() instead of spl_object_hash() for performance.
|
||||
* @since 7.1.1 The ID for an object callback is prefixed so that it is never cast to an integer array key.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
@@ -998,6 +999,8 @@ function _wp_call_all_hook( $args ) {
|
||||
* @param int $priority Unused. The order in which the functions
|
||||
* associated with a particular action are executed.
|
||||
* @return string|null Unique function ID for usage as array key, or null if it couldn't be determined.
|
||||
*
|
||||
* @phpstan-return non-decimal-int-string|null
|
||||
*/
|
||||
function _wp_filter_build_unique_id( $hook_name, $callback, $priority ): ?string {
|
||||
if ( is_string( $callback ) ) {
|
||||
@@ -1005,7 +1008,12 @@ function _wp_filter_build_unique_id( $hook_name, $callback, $priority ): ?string
|
||||
}
|
||||
|
||||
if ( is_object( $callback ) ) {
|
||||
return (string) spl_object_id( $callback );
|
||||
/*
|
||||
* The prefix keeps the ID from being the decimal representation of an integer. PHP casts such a
|
||||
* string to int when it is used as an array key, which would change the type of the keys in
|
||||
* WP_Hook::$callbacks and break consumers that pass them to string functions.
|
||||
*/
|
||||
return 'spl_object_id:' . spl_object_id( $callback );
|
||||
}
|
||||
|
||||
if ( ! isset( $callback[1] ) || ! is_string( $callback[1] ) ) {
|
||||
|
||||
+64
-56
@@ -5921,63 +5921,71 @@ function wp_transition_post_status( $new_status, $old_status, $post ) {
|
||||
*/
|
||||
do_action( 'transition_post_status', $new_status, $old_status, $post );
|
||||
|
||||
/**
|
||||
* Fires when a post is transitioned from one status to another.
|
||||
*
|
||||
* The dynamic portions of the hook name, `$new_status` and `$old_status`,
|
||||
* refer to the old and new post statuses, respectively.
|
||||
*
|
||||
* Possible hook names include:
|
||||
*
|
||||
* - `draft_to_publish`
|
||||
* - `publish_to_trash`
|
||||
* - `pending_to_draft`
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param WP_Post $post Post object.
|
||||
*/
|
||||
do_action( "{$old_status}_to_{$new_status}", $post );
|
||||
$new_status_object = get_post_status_object( $new_status );
|
||||
$old_status_valid = get_post_status_object( $old_status ) || 'new' === $old_status;
|
||||
$post_type_object = get_post_type_object( $post->post_type );
|
||||
|
||||
/**
|
||||
* Fires when a post is transitioned from one status to another.
|
||||
*
|
||||
* The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
|
||||
* refer to the new post status and post type, respectively.
|
||||
*
|
||||
* Possible hook names include:
|
||||
*
|
||||
* - `draft_post`
|
||||
* - `future_post`
|
||||
* - `pending_post`
|
||||
* - `private_post`
|
||||
* - `publish_post`
|
||||
* - `trash_post`
|
||||
* - `draft_page`
|
||||
* - `future_page`
|
||||
* - `pending_page`
|
||||
* - `private_page`
|
||||
* - `publish_page`
|
||||
* - `trash_page`
|
||||
* - `publish_attachment`
|
||||
* - `trash_attachment`
|
||||
*
|
||||
* Please note: When this action is hooked using a particular post status (like
|
||||
* 'publish', as `publish_{$post->post_type}`), it will fire both when a post is
|
||||
* first transitioned to that status from something else, as well as upon
|
||||
* subsequent post updates (old and new status are both the same).
|
||||
*
|
||||
* Therefore, if you are looking to only fire a callback when a post is first
|
||||
* transitioned to a status, use the {@see 'transition_post_status'} hook instead.
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @since 5.9.0 Added `$old_status` parameter.
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
* @param WP_Post $post Post object.
|
||||
* @param string $old_status Old post status.
|
||||
*/
|
||||
do_action( "{$new_status}_{$post->post_type}", $post->ID, $post, $old_status );
|
||||
if ( $new_status_object && $old_status_valid ) {
|
||||
/**
|
||||
* Fires when a post is transitioned from one status to another.
|
||||
*
|
||||
* The dynamic portions of the hook name, `$new_status` and `$old_status`,
|
||||
* refer to the old and new post statuses, respectively.
|
||||
*
|
||||
* Possible hook names include:
|
||||
*
|
||||
* - `draft_to_publish`
|
||||
* - `publish_to_trash`
|
||||
* - `pending_to_draft`
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param WP_Post $post Post object.
|
||||
*/
|
||||
do_action( "{$old_status}_to_{$new_status}", $post );
|
||||
}
|
||||
|
||||
if ( $new_status_object && $post_type_object ) {
|
||||
/**
|
||||
* Fires when a post is transitioned from one status to another.
|
||||
*
|
||||
* The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
|
||||
* refer to the new post status and post type, respectively.
|
||||
*
|
||||
* Possible hook names include:
|
||||
*
|
||||
* - `draft_post`
|
||||
* - `future_post`
|
||||
* - `pending_post`
|
||||
* - `private_post`
|
||||
* - `publish_post`
|
||||
* - `trash_post`
|
||||
* - `draft_page`
|
||||
* - `future_page`
|
||||
* - `pending_page`
|
||||
* - `private_page`
|
||||
* - `publish_page`
|
||||
* - `trash_page`
|
||||
* - `publish_attachment`
|
||||
* - `trash_attachment`
|
||||
*
|
||||
* Please note: When this action is hooked using a particular post status (like
|
||||
* 'publish', as `publish_{$post->post_type}`), it will fire both when a post is
|
||||
* first transitioned to that status from something else, as well as upon
|
||||
* subsequent post updates (old and new status are both the same).
|
||||
*
|
||||
* Therefore, if you are looking to only fire a callback when a post is first
|
||||
* transitioned to a status, use the {@see 'transition_post_status'} hook instead.
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @since 5.9.0 Added `$old_status` parameter.
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
* @param WP_Post $post Post object.
|
||||
* @param string $old_status Old post status.
|
||||
*/
|
||||
do_action( "{$new_status}_{$post->post_type}", $post->ID, $post, $old_status );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3453,6 +3453,21 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
|
||||
$response_request['_fields'] = $request['_fields'];
|
||||
}
|
||||
|
||||
/*
|
||||
* Re-read the post. The 'wp_generate_attachment_metadata' filter above
|
||||
* runs long after $post was fetched, and a callback that rewrites the
|
||||
* post row - an optimizer changing post_mime_type once it has
|
||||
* converted the file, say - would otherwise be missing from this
|
||||
* response. The editor stores the response as its copy of the record
|
||||
* rather than reading the attachment again, so a stale row here is
|
||||
* what it keeps. A callback that deleted the attachment instead leaves
|
||||
* nothing to respond with, so that is reported as the error it is.
|
||||
*/
|
||||
$post = $this->get_post( $attachment_id );
|
||||
if ( is_wp_error( $post ) ) {
|
||||
return $post;
|
||||
}
|
||||
|
||||
return $this->prepare_item_for_response( $post, $response_request );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,12 +560,12 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $is_note && ! empty( $request['post'] ) && ! current_user_can( 'edit_post', (int) $request['post'] ) ) {
|
||||
return new WP_Error(
|
||||
'rest_cannot_create_note',
|
||||
__( 'Sorry, you are not allowed to create notes for this post.' ),
|
||||
array( 'status' => rest_authorization_required_code() )
|
||||
);
|
||||
if ( $is_note && ! empty( $request['post'] ) ) {
|
||||
$target_check = $this->check_target_post_permission( (int) $request['post'], $request, true );
|
||||
|
||||
if ( is_wp_error( $target_check ) ) {
|
||||
return $target_check;
|
||||
}
|
||||
}
|
||||
|
||||
$edit_cap = $is_note ? array( 'edit_post', (int) $request['post'] ) : array( 'moderate_comments' );
|
||||
@@ -586,6 +586,16 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* A note's target post was fully checked by check_target_post_permission()
|
||||
* above. Everything below applies to other comments only: a note is allowed
|
||||
* on a draft and on a post whose discussion is closed, and the rest would
|
||||
* repeat what that check already did.
|
||||
*/
|
||||
if ( $is_note ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$post = get_post( (int) $request['post'] );
|
||||
|
||||
if ( ! $post ) {
|
||||
@@ -596,15 +606,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
);
|
||||
}
|
||||
|
||||
if ( $is_note && ! $this->check_post_type_supports_notes( $post->post_type ) ) {
|
||||
return new WP_Error(
|
||||
'rest_comment_not_supported_post_type',
|
||||
__( 'Sorry, this post type does not support notes.' ),
|
||||
array( 'status' => 403 )
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'draft' === $post->post_status && ! $is_note ) {
|
||||
if ( 'draft' === $post->post_status ) {
|
||||
return new WP_Error(
|
||||
'rest_comment_draft_post',
|
||||
__( 'Sorry, you are not allowed to create a comment on this post.' ),
|
||||
@@ -628,7 +630,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! comments_open( $post->ID ) && ! $is_note ) {
|
||||
if ( ! comments_open( $post->ID ) ) {
|
||||
return new WP_Error(
|
||||
'rest_comment_closed',
|
||||
__( 'Sorry, comments are closed for this item.' ),
|
||||
@@ -862,6 +864,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
* Checks if a given REST request has access to update a comment.
|
||||
*
|
||||
* @since 4.7.0
|
||||
* @since 7.1.1 Target post permissions are checked when a comment's parent post is changed.
|
||||
*
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
* @return true|WP_Error True if the request has access to update the item, error object otherwise.
|
||||
@@ -880,6 +883,26 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* check_edit_permission() above only establishes that the comment may be
|
||||
* edited where it currently sits, because 'edit_comment' maps to 'edit_post'
|
||||
* on the comment's current parent. When the parent is being changed, the new
|
||||
* parent has to be authorized as well. Without this, a user holding
|
||||
* edit_comment on their own comment or note could reparent it onto any post,
|
||||
* including posts they can neither read nor edit.
|
||||
*/
|
||||
if ( isset( $request['post'] ) && (int) $request['post'] !== (int) $comment->comment_post_ID ) {
|
||||
$target_check = $this->check_target_post_permission(
|
||||
(int) $request['post'],
|
||||
$request,
|
||||
'note' === $comment->comment_type
|
||||
);
|
||||
|
||||
if ( is_wp_error( $target_check ) ) {
|
||||
return $target_check;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2041,6 +2064,106 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
return '' !== $check['comment_content'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that a post can receive a comment or a note from the current user.
|
||||
*
|
||||
* Used when creating a note and when changing the parent post of an existing
|
||||
* comment or note, so that attaching content to a post is authorized the same
|
||||
* way whichever path it arrives by.
|
||||
*
|
||||
* @since 7.1.1
|
||||
*
|
||||
* @param int $post_id Target post ID.
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
* @param bool $is_note Optional. Whether the comment is a note. Default false.
|
||||
* @return true|WP_Error True if the post can receive the comment, error object otherwise.
|
||||
*/
|
||||
protected function check_target_post_permission( int $post_id, WP_REST_Request $request, bool $is_note = false ) {
|
||||
if ( ! $post_id ) {
|
||||
return new WP_Error(
|
||||
'rest_comment_invalid_post_id',
|
||||
__( 'Sorry, you are not allowed to create this comment without a post.' ),
|
||||
array( 'status' => 403 )
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Notes are editorial content, so they may only be attached to a post the
|
||||
* user can edit. Any other comment needs either comment moderation rights
|
||||
* or edit access to the post, which is what check_edit_permission() grants
|
||||
* on the post a comment is moving away from. Requiring the same at the
|
||||
* destination means both ends of a move are authorized alike.
|
||||
*/
|
||||
if ( $is_note ) {
|
||||
$can_target_post = current_user_can( 'edit_post', $post_id );
|
||||
} else {
|
||||
$can_target_post = current_user_can( 'moderate_comments' ) || current_user_can( 'edit_post', $post_id );
|
||||
}
|
||||
|
||||
if ( ! $can_target_post ) {
|
||||
if ( $is_note ) {
|
||||
return new WP_Error(
|
||||
'rest_cannot_create_note',
|
||||
__( 'Sorry, you are not allowed to create notes for this post.' ),
|
||||
array( 'status' => rest_authorization_required_code() )
|
||||
);
|
||||
}
|
||||
|
||||
return new WP_Error(
|
||||
'rest_cannot_edit',
|
||||
__( 'Sorry, you are not allowed to edit this comment.' ),
|
||||
array( 'status' => rest_authorization_required_code() )
|
||||
);
|
||||
}
|
||||
|
||||
$post = get_post( $post_id );
|
||||
|
||||
if ( ! $post ) {
|
||||
return new WP_Error(
|
||||
'rest_comment_invalid_post_id',
|
||||
__( 'Sorry, you are not allowed to create this comment without a post.' ),
|
||||
array( 'status' => 403 )
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* The remaining rules mirror the create-time checks for notes only. They are
|
||||
* deliberately not applied to other comments, because moderators move comments
|
||||
* onto posts whose discussion has closed and onto drafts today. Enforcing the
|
||||
* create-time rules there would break that without blocking anything the
|
||||
* capability check above already permits.
|
||||
*/
|
||||
if ( ! $is_note ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ! $this->check_post_type_supports_notes( $post->post_type ) ) {
|
||||
return new WP_Error(
|
||||
'rest_comment_not_supported_post_type',
|
||||
__( 'Sorry, this post type does not support notes.' ),
|
||||
array( 'status' => 403 )
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'trash' === $post->post_status ) {
|
||||
return new WP_Error(
|
||||
'rest_comment_trash_post',
|
||||
__( 'Sorry, you are not allowed to create a comment on this post.' ),
|
||||
array( 'status' => 403 )
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $this->check_read_post_permission( $post, $request ) ) {
|
||||
return new WP_Error(
|
||||
'rest_cannot_read_post',
|
||||
__( 'Sorry, you are not allowed to read the post for this comment.' ),
|
||||
array( 'status' => rest_authorization_required_code() )
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if post type supports notes.
|
||||
*
|
||||
|
||||
@@ -703,7 +703,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) && ! current_user_can( $post_type->cap->publish_posts ) ) {
|
||||
if ( ! empty( $request['sticky'] ) && ( ! current_user_can( $post_type->cap->edit_others_posts ) || ! current_user_can( $post_type->cap->publish_posts ) ) ) {
|
||||
return new WP_Error(
|
||||
'rest_cannot_assign_sticky',
|
||||
__( 'Sorry, you are not allowed to make posts sticky.' ),
|
||||
@@ -914,7 +914,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) && ! current_user_can( $post_type->cap->publish_posts ) ) {
|
||||
if ( isset( $request['sticky'] ) && is_sticky( $post->ID ) !== (bool) $request['sticky'] && ( ! current_user_can( $post_type->cap->edit_others_posts ) || ! current_user_can( $post_type->cap->publish_posts ) ) ) {
|
||||
return new WP_Error(
|
||||
'rest_cannot_assign_sticky',
|
||||
__( 'Sorry, you are not allowed to make posts sticky.' ),
|
||||
|
||||
@@ -157,30 +157,45 @@ class WP_Sitemaps {
|
||||
* Renders sitemap templates based on rewrite rules.
|
||||
*
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @global WP_Query $wp_query WordPress Query object.
|
||||
*/
|
||||
public function render_sitemaps() {
|
||||
global $wp_query;
|
||||
/*
|
||||
* Bail early if this isn't a sitemap or stylesheet route.
|
||||
*
|
||||
* This runs on every front-end request, so it comes before any
|
||||
* sanitizing. The raw query vars are tested here, matching
|
||||
* WP::handle_404(), which exempts sitemap requests from its own 404 on
|
||||
* the same basis. Testing the sanitized values instead would let a
|
||||
* request that handle_404() exempted fall through both, leaving it a 200.
|
||||
*/
|
||||
if ( ! get_query_var( 'sitemap' ) && ! get_query_var( 'sitemap-stylesheet' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sitemap = sanitize_text_field( get_query_var( 'sitemap' ) );
|
||||
$object_subtype = sanitize_text_field( get_query_var( 'sitemap-subtype' ) );
|
||||
$stylesheet_type = sanitize_text_field( get_query_var( 'sitemap-stylesheet' ) );
|
||||
$paged = absint( get_query_var( 'paged' ) );
|
||||
|
||||
// Bail early if this isn't a sitemap or stylesheet route.
|
||||
// Force a 404 and bail early if the route did not survive sanitizing.
|
||||
if ( ! ( $sitemap || $stylesheet_type ) ) {
|
||||
$this->send_404();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $this->sitemaps_enabled() ) {
|
||||
$wp_query->set_404();
|
||||
status_header( 404 );
|
||||
$this->send_404();
|
||||
return;
|
||||
}
|
||||
|
||||
// Render stylesheet if this is stylesheet route.
|
||||
if ( $stylesheet_type ) {
|
||||
// Force a 404 and bail early if the stylesheet type is not recognized.
|
||||
if ( ! in_array( $stylesheet_type, array( 'sitemap', 'index' ), true ) ) {
|
||||
$this->send_404();
|
||||
return;
|
||||
}
|
||||
|
||||
$stylesheet = new WP_Sitemaps_Stylesheet();
|
||||
|
||||
$stylesheet->render_stylesheet( $stylesheet_type );
|
||||
@@ -197,7 +212,9 @@ class WP_Sitemaps {
|
||||
|
||||
$provider = $this->registry->get_provider( $sitemap );
|
||||
|
||||
// Force a 404 and bail early if the requested provider is not registered.
|
||||
if ( ! $provider ) {
|
||||
$this->send_404();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -209,8 +226,7 @@ class WP_Sitemaps {
|
||||
|
||||
// Force a 404 and bail early if no URLs are present.
|
||||
if ( empty( $url_list ) ) {
|
||||
$wp_query->set_404();
|
||||
status_header( 404 );
|
||||
$this->send_404();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -218,6 +234,26 @@ class WP_Sitemaps {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a 404 for a sitemap route that cannot be served.
|
||||
*
|
||||
* WP::handle_404() exempts sitemap requests, so every sitemap 404 is issued
|
||||
* here instead. That includes the no-cache headers handle_404() sends with
|
||||
* its own 404, so an intermediary does not retain a 404 for a route that
|
||||
* becomes valid once the site has more content.
|
||||
*
|
||||
* @since 7.1.1
|
||||
*
|
||||
* @global WP_Query $wp_query WordPress Query object.
|
||||
*/
|
||||
private function send_404(): void {
|
||||
global $wp_query;
|
||||
|
||||
$wp_query->set_404();
|
||||
status_header( 404 );
|
||||
nocache_headers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirects a URL to the wp-sitemap.xml
|
||||
*
|
||||
|
||||
@@ -490,7 +490,7 @@ function get_page_template() {
|
||||
}
|
||||
if ( $pagename ) {
|
||||
$pagename_decoded = urldecode( $pagename );
|
||||
if ( $pagename_decoded !== $pagename ) {
|
||||
if ( $pagename_decoded !== $pagename && 0 === validate_file( $pagename_decoded ) ) {
|
||||
$templates[] = "page-{$pagename_decoded}.php";
|
||||
}
|
||||
$templates[] = "page-{$pagename}.php";
|
||||
@@ -698,6 +698,67 @@ function wp_set_template_globals() {
|
||||
$wp_template_path = get_template_directory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a template found by locate_template() may be loaded.
|
||||
*
|
||||
* @since 7.1.2
|
||||
* @access private
|
||||
*
|
||||
* @global string $wp_stylesheet_path Path to current theme's stylesheet directory.
|
||||
* @global string $wp_template_path Path to current theme's template directory.
|
||||
*
|
||||
* @param string $path Path to an existing template file.
|
||||
* @return bool Whether the template may be loaded.
|
||||
*/
|
||||
function _wp_is_template_path_allowed( $path ) {
|
||||
global $wp_stylesheet_path, $wp_template_path;
|
||||
|
||||
// A file path that exists and does not contain `..` is allowed.
|
||||
if ( 0 === preg_match( '#(?:^|/)\.\.[. ]*(?:/|$)#', wp_normalize_path( $path ) ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Resolve the true location of the requested file for later comparison.
|
||||
$real_path = realpath( $path );
|
||||
|
||||
if ( false === $real_path ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$real_path = trailingslashit( wp_normalize_path( $real_path ) );
|
||||
|
||||
$directories = array(
|
||||
$wp_stylesheet_path,
|
||||
$wp_template_path,
|
||||
ABSPATH . WPINC . '/theme-compat',
|
||||
);
|
||||
|
||||
// If a theme is in a subdirectory, accept templates from its direct parent directory.
|
||||
if ( str_contains( get_stylesheet(), '/' ) ) {
|
||||
$directories[] = dirname( $wp_stylesheet_path );
|
||||
}
|
||||
|
||||
// If a parent theme is in a subdirectory, accept templates from its direct parent directory.
|
||||
if ( str_contains( get_template(), '/' ) ) {
|
||||
$directories[] = dirname( $wp_template_path );
|
||||
}
|
||||
|
||||
foreach ( $directories as $directory ) {
|
||||
$real_directory = realpath( $directory );
|
||||
|
||||
if ( false === $real_directory ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The true location of the requested file must be inside one of the allowed directories.
|
||||
if ( str_starts_with( $real_path, trailingslashit( wp_normalize_path( $real_directory ) ) ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the name of the highest priority template file that exists.
|
||||
*
|
||||
@@ -707,6 +768,7 @@ function wp_set_template_globals() {
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @since 5.5.0 The `$args` parameter was added.
|
||||
* @since 7.1.2 A template name containing `..` is only located if it resolves inside the theme.
|
||||
*
|
||||
* @global string $wp_stylesheet_path Path to current theme's stylesheet directory.
|
||||
* @global string $wp_template_path Path to current theme's template directory.
|
||||
@@ -734,13 +796,17 @@ function locate_template( $template_names, $load = false, $load_once = true, $ar
|
||||
continue;
|
||||
}
|
||||
if ( file_exists( $wp_stylesheet_path . '/' . $template_name ) ) {
|
||||
$located = $wp_stylesheet_path . '/' . $template_name;
|
||||
break;
|
||||
$candidate = $wp_stylesheet_path . '/' . $template_name;
|
||||
} elseif ( $is_child_theme && file_exists( $wp_template_path . '/' . $template_name ) ) {
|
||||
$located = $wp_template_path . '/' . $template_name;
|
||||
break;
|
||||
$candidate = $wp_template_path . '/' . $template_name;
|
||||
} elseif ( file_exists( ABSPATH . WPINC . '/theme-compat/' . $template_name ) ) {
|
||||
$located = ABSPATH . WPINC . '/theme-compat/' . $template_name;
|
||||
$candidate = ABSPATH . WPINC . '/theme-compat/' . $template_name;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( _wp_is_template_path_allowed( $candidate ) ) {
|
||||
$located = $candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1551,6 +1551,7 @@ function get_uploaded_header_images() {
|
||||
* Gets the header image data.
|
||||
*
|
||||
* @since 3.4.0
|
||||
* @since 7.1.1 The `width` and `height` are cast to non-negative integers.
|
||||
*
|
||||
* @global array $_wp_default_headers
|
||||
*
|
||||
@@ -1589,7 +1590,14 @@ function get_custom_header() {
|
||||
'height' => get_theme_support( 'custom-header', 'height' ),
|
||||
'video' => get_theme_support( 'custom-header', 'video' ),
|
||||
);
|
||||
return (object) wp_parse_args( $data, $default );
|
||||
|
||||
if ( ! is_array( $data ) && ! is_object( $data ) ) {
|
||||
$data = array();
|
||||
}
|
||||
$header = (object) wp_parse_args( $data, $default );
|
||||
$header->width = absint( $header->width );
|
||||
$header->height = absint( $header->height );
|
||||
return $header;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '7.1';
|
||||
$wp_version = '7.1.3';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user