From 2c7ce700201489d1412fc90933bd6cb13418b20f Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Wed, 8 May 2024 12:49:21 -0600 Subject: [PATCH 01/25] allowedMimeTypes: filter types that are not supported by the server. --- src/wp-includes/block-editor.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php index e04b012e7dd08..b9288e8af710b 100644 --- a/src/wp-includes/block-editor.php +++ b/src/wp-includes/block-editor.php @@ -211,10 +211,30 @@ function get_default_block_editor_settings() { ); } + $allowed_mime_types = get_allowed_mime_types(); + // Filter image types that are not supported by the server. + $types_to_test_for_support = array( 'image/webp', 'image/avif' ); + foreach ( $types_to_test_for_support as $type ) { + error_log( 'checking type:' . $type ); + error_log( wp_image_editor_supports( array( 'mime_type' => $type ) ) ? 'supported' : 'not supported' ); + + if ( ! wp_image_editor_supports( array( 'mime_type' => $type ) ) ) { + error_log( 'removing by type:' . $type ); + + $key = array_search( $type, $allowed_mime_types, true ); + error_log( 'found key:' . $key ); + + if ( $key !== false ) { + error_log( 'removing by key:' . $key ); + unset( $allowed_mime_types[ $key ] ); + } + } + } + $editor_settings = array( 'alignWide' => get_theme_support( 'align-wide' ), 'allowedBlockTypes' => true, - 'allowedMimeTypes' => get_allowed_mime_types(), + 'allowedMimeTypes' => $allowed_mime_types, 'defaultEditorStyles' => $default_editor_styles, 'blockCategories' => get_default_block_categories(), 'isRTL' => is_rtl(), From 93c4813115fbd9e49d726075a54fbb8887bf9814 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Wed, 8 May 2024 12:50:47 -0600 Subject: [PATCH 02/25] Cleanup --- src/wp-includes/block-editor.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php index b9288e8af710b..1dd6140c743b0 100644 --- a/src/wp-includes/block-editor.php +++ b/src/wp-includes/block-editor.php @@ -211,21 +211,13 @@ function get_default_block_editor_settings() { ); } - $allowed_mime_types = get_allowed_mime_types(); // Filter image types that are not supported by the server. + $allowed_mime_types = get_allowed_mime_types(); $types_to_test_for_support = array( 'image/webp', 'image/avif' ); foreach ( $types_to_test_for_support as $type ) { - error_log( 'checking type:' . $type ); - error_log( wp_image_editor_supports( array( 'mime_type' => $type ) ) ? 'supported' : 'not supported' ); - if ( ! wp_image_editor_supports( array( 'mime_type' => $type ) ) ) { - error_log( 'removing by type:' . $type ); - $key = array_search( $type, $allowed_mime_types, true ); - error_log( 'found key:' . $key ); - if ( $key !== false ) { - error_log( 'removing by key:' . $key ); unset( $allowed_mime_types[ $key ] ); } } From 760f13f0c26c491aa520e3bce41645e25e0acf0a Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Wed, 8 May 2024 12:56:20 -0600 Subject: [PATCH 03/25] Use Yoda consitionals, I must --- src/wp-includes/block-editor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php index 1dd6140c743b0..6565eb263f1b7 100644 --- a/src/wp-includes/block-editor.php +++ b/src/wp-includes/block-editor.php @@ -217,7 +217,7 @@ function get_default_block_editor_settings() { foreach ( $types_to_test_for_support as $type ) { if ( ! wp_image_editor_supports( array( 'mime_type' => $type ) ) ) { $key = array_search( $type, $allowed_mime_types, true ); - if ( $key !== false ) { + if ( false !== $key ) { unset( $allowed_mime_types[ $key ] ); } } From a510e3970046aaafd70aa3b0f01486df480cc9ee Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 14 Feb 2025 13:12:34 -0700 Subject: [PATCH 04/25] revert previous version --- src/wp-includes/block-editor.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php index 01bc1438c10dd..007c713190c45 100644 --- a/src/wp-includes/block-editor.php +++ b/src/wp-includes/block-editor.php @@ -211,22 +211,10 @@ function get_default_block_editor_settings() { ); } - // Filter image types that are not supported by the server. - $allowed_mime_types = get_allowed_mime_types(); - $types_to_test_for_support = array( 'image/webp', 'image/avif' ); - foreach ( $types_to_test_for_support as $type ) { - if ( ! wp_image_editor_supports( array( 'mime_type' => $type ) ) ) { - $key = array_search( $type, $allowed_mime_types, true ); - if ( false !== $key ) { - unset( $allowed_mime_types[ $key ] ); - } - } - } - $editor_settings = array( 'alignWide' => get_theme_support( 'align-wide' ), 'allowedBlockTypes' => true, - 'allowedMimeTypes' => $allowed_mime_types, + 'allowedMimeTypes' => get_allowed_mime_types(), 'defaultEditorStyles' => $default_editor_styles, 'blockCategories' => get_default_block_categories(), 'isRTL' => is_rtl(), From ff2e0c0ad5ec52a4179d2e7bb1d6eb571aa6b754 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 14 Feb 2025 14:30:08 -0700 Subject: [PATCH 05/25] =?UTF-8?q?Error=20when=20an=20(image)=20upload?= =?UTF-8?q?=E2=80=99s=20mime=20type=20is=20unsupported?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../class-wp-rest-attachments-controller.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index 0c98a729e43f9..c9e90bf5fc6ba 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -135,6 +135,23 @@ public function create_item_permissions_check( $request ) { ); } + // If the upload is an image, check if the server can handle the mime type. + $files = $request->get_file_params(); + if ( + ! empty( $files ) && + isset( $files['file'] ) && + str_starts_with( $files['file']['type'], 'image/' ) + ) { + // Check if the image editor supports the type. + if ( ! wp_image_editor_supports( array( 'mime_type' => $files['file']['type'] ) ) ) { + return new WP_Error( + 'rest_upload_image_type_not_supported', + __( 'The web server cannot generate responsive image sizes for this image. Convert it to JPEG or PNG before uploading.', 'gutenberg' ), + array( 'status' => 400 ) + ); + } + } + return true; } From 0bfaf9591136f3192042dd8bdc4bde91f90fa67a Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 14 Feb 2025 14:42:31 -0700 Subject: [PATCH 06/25] phpcbf --- .../rest-api/endpoints/class-wp-rest-attachments-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index c9e90bf5fc6ba..d882351c5eace 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -142,7 +142,7 @@ public function create_item_permissions_check( $request ) { isset( $files['file'] ) && str_starts_with( $files['file']['type'], 'image/' ) ) { - // Check if the image editor supports the type. + // Check if the image editor supports the type. if ( ! wp_image_editor_supports( array( 'mime_type' => $files['file']['type'] ) ) ) { return new WP_Error( 'rest_upload_image_type_not_supported', From 86e9f3860901953071153d3bafdeec9b58b810e3 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Fri, 14 Feb 2025 20:32:48 +0000 Subject: [PATCH 07/25] Customize: Accessibility: Restore heading semantics in sections. Remove `role="presentation"` from headings in the customizer. These were needed to avoid confusing semantics when the headings also acted as buttons to control accordions, changed in [59924]. Change responsive CSS to use `screen-reader-text` styling rather than `display: none` so that mobile retains the headings hierarchy. Props joedolson, hbhalodia, mikinc860, guillaumeturpin, rcreators, tirth03, dhrumilk . Fixes #62215. git-svn-id: https://develop.svn.wordpress.org/trunk@59825 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/css/customize-controls.css | 29 ++++++++++++++++++- src/wp-admin/customize.php | 4 +-- .../class-wp-customize-nav-menus.php | 4 +-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css index 7e4eb5229389b..b803c86ebdf0b 100644 --- a/src/wp-admin/css/customize-controls.css +++ b/src/wp-admin/css/customize-controls.css @@ -447,6 +447,9 @@ body.trashing #publish-settings { #customize-controls .customize-info .preview-notice { font-size: 13px; line-height: 1.9; + margin: 0; + font-weight: 400; + color: #50575e; } #customize-controls .customize-pane-child .customize-section-title h3, @@ -2641,6 +2644,19 @@ body.adding-widget .add-new-widget:before, #available-widgets .customize-section-title, #available-menu-items .customize-section-title { + border: 0; + clip-path: inset(50%); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + word-wrap: normal !important; +} + +#available-widgets .customize-section-title button, +#available-menu-items .customize-section-title button { display: none; } @@ -2977,8 +2993,19 @@ body.adding-widget .add-new-widget:before, #available-widgets .customize-section-title, #available-menu-items .customize-section-title { - display: block; + border: 0; + clip-path: none; + height: inherit; margin: 0; + overflow: hidden; + padding: 0; + width: auto; + position: static; + } + + #available-widgets .customize-section-title button, + #available-menu-items .customize-section-title button { + display: block; } #available-widgets .customize-section-back, diff --git a/src/wp-admin/customize.php b/src/wp-admin/customize.php index 9fe0b3f6d3912..957984cb509f1 100644 --- a/src/wp-admin/customize.php +++ b/src/wp-admin/customize.php @@ -233,12 +233,12 @@
- +

' . get_bloginfo( 'name', 'display' ) . '' ); ?> - +