Skip to content

Commit 2bcafd9

Browse files
authored
Merge branch 'trunk' into toolbar-command-palette-icon-link
2 parents 61b4f83 + 421d1d4 commit 2bcafd9

21 files changed

Lines changed: 490 additions & 35 deletions

.github/workflows/javascript-type-checking.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
- 'typings/**'
2828
# Confirm any changes to relevant workflow files.
2929
- '.github/workflows/javascript-type-checking.yml'
30-
- '.github/workflows/reusable-javascript-type-checking.yml'
30+
- '.github/workflows/reusable-javascript-type-checking-v1.yml'
3131
workflow_dispatch:
3232

3333
# Cancels all previous workflow runs for pull requests that have not completed.
@@ -45,10 +45,10 @@ jobs:
4545
# Runs JavaScript type checking.
4646
typecheck:
4747
name: JavaScript type checking
48-
uses: ./.github/workflows/reusable-javascript-type-checking.yml
48+
uses: ./.github/workflows/reusable-javascript-type-checking-v1.yml
4949
permissions:
5050
contents: read
51-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
51+
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
5252

5353
slack-notifications:
5454
name: Slack Notifications

.github/workflows/phpstan-static-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
- 'tests/phpstan/baseline.php'
2525
# Confirm any changes to relevant workflow files.
2626
- '.github/workflows/phpstan-static-analysis.yml'
27-
- '.github/workflows/reusable-phpstan-static-analysis.yml'
27+
- '.github/workflows/reusable-phpstan-static-analysis-v1.yml'
2828
workflow_dispatch:
2929

3030
# Cancels all previous workflow runs for pull requests that have not completed.
@@ -42,10 +42,10 @@ jobs:
4242
# Runs PHPStan Static Analysis.
4343
phpstan:
4444
name: PHP static analysis
45-
uses: ./.github/workflows/reusable-phpstan-static-analysis.yml
45+
uses: ./.github/workflows/reusable-phpstan-static-analysis-v1.yml
4646
permissions:
4747
contents: read
48-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
48+
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
4949

5050
slack-notifications:
5151
name: Slack Notifications

.github/workflows/reusable-javascript-type-checking.yml renamed to .github/workflows/reusable-javascript-type-checking-v1.yml

File renamed without changes.

.github/workflows/reusable-phpstan-static-analysis.yml renamed to .github/workflows/reusable-phpstan-static-analysis-v1.yml

File renamed without changes.

.github/workflows/reusable-phpunit-tests-v3.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jobs:
120120
phpunit-tests:
121121
name: ${{ ( inputs.phpunit-test-groups || inputs.coverage-report ) && format( 'PHP {0} with ', inputs.php ) || '' }} ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }}${{ inputs.db-innovation && ' (innovation release)' || '' }}${{ inputs.memcached && ' with memcached' || '' }}${{ inputs.report && ' (test reporting enabled)' || '' }} ${{ 'example.org' != inputs.tests-domain && inputs.tests-domain || '' }}
122122
runs-on: ${{ inputs.os }}
123-
timeout-minutes: ${{ inputs.coverage-report && 120 || inputs.php == '8.4' && 30 || 20 }}
123+
timeout-minutes: ${{ inputs.coverage-report && 120 || 40 }}
124124
permissions:
125125
contents: read
126126

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://develop.svn.wordpress.org/trunk"
88
},
99
"gutenberg": {
10-
"ref": "022d8dd3d461f91b15c1f0410649d3ebb027207f"
10+
"ref": "f4d8a5803aa2fbe26e7d9af4d17e80a622b7bab8"
1111
},
1212
"engines": {
1313
"node": ">=20.10.0",

src/wp-admin/css/customize-controls.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,11 @@ p.customize-section-description {
19071907
bottom: 0;
19081908
}
19091909

1910+
.themes-filter-bar .feature-filter-toggle {
1911+
min-height: 32px;
1912+
line-height: 2.30769231;
1913+
}
1914+
19101915
.themes-filter-bar .feature-filter-toggle:before {
19111916
content: "\f111";
19121917
content: "\f111" / '';

src/wp-admin/css/dashboard.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@
536536
}
537537

538538
.community-events li.event-none {
539-
border-left: 4px solid #72aee6;
539+
border-left: 4px solid var(--wp-admin-theme-color, #3858e9);
540540
}
541541

542542
#dashboard-widgets .community-events li.event-none a {

src/wp-admin/includes/image.php

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ function wp_exif_date2ts( $str ) {
813813
* created_timestamp, focal_length, shutter_speed, and title.
814814
*
815815
* The IPTC metadata that is retrieved is APP13, credit, byline, created date
816-
* and time, caption, copyright, and title. Also includes FNumber, Model,
816+
* and time, caption, copyright, alt, and title. Also includes FNumber, Model,
817817
* DateTimeDigitized, FocalLength, ISOSpeedRatings, and ExposureTime.
818818
*
819819
* @todo Try other exif libraries if available.
@@ -854,6 +854,7 @@ function wp_read_image_metadata( $file ) {
854854
'title' => '',
855855
'orientation' => 0,
856856
'keywords' => array(),
857+
'alt' => '',
857858
);
858859

859860
$iptc = array();
@@ -926,6 +927,8 @@ function wp_read_image_metadata( $file ) {
926927
}
927928
}
928929

930+
$meta['alt'] = wp_get_image_alttext( $file );
931+
929932
$exif = array();
930933

931934
/**
@@ -1074,6 +1077,72 @@ function wp_read_image_metadata( $file ) {
10741077
return apply_filters( 'wp_read_image_metadata', $meta, $file, $image_type, $iptc, $exif );
10751078
}
10761079

1080+
/**
1081+
* Gets the alt text from image meta data.
1082+
*
1083+
* @since 7.0.0
1084+
*
1085+
* @param string $file File path to the image.
1086+
* @return string Embedded alternative text.
1087+
*/
1088+
function wp_get_image_alttext( $file ) {
1089+
$alt_text = '';
1090+
$img_contents = file_get_contents( $file );
1091+
// Find the start and end positions of the XMP metadata.
1092+
$xmp_start = strpos( $img_contents, '<x:xmpmeta' );
1093+
$xmp_end = strpos( $img_contents, '</x:xmpmeta>' );
1094+
1095+
if ( ! $xmp_start || ! $xmp_end ) {
1096+
// No XMP metadata found.
1097+
return $alt_text;
1098+
}
1099+
1100+
// Extract the XMP metadata from the JPEG contents
1101+
$xmp_data = substr( $img_contents, $xmp_start, $xmp_end - $xmp_start + 12 );
1102+
1103+
// Parse the XMP metadata using DOMDocument.
1104+
$doc = new DOMDocument();
1105+
if ( false === $doc->loadXML( $xmp_data ) ) {
1106+
// Invalid XML in metadata.
1107+
return $alt_text;
1108+
}
1109+
1110+
// Instantiate an XPath object, used to extract portions of the XMP.
1111+
$xpath = new DOMXPath( $doc );
1112+
1113+
// Register the relevant XML namespaces.
1114+
$xpath->registerNamespace( 'x', 'adobe:ns:meta/' );
1115+
$xpath->registerNamespace( 'rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' );
1116+
$xpath->registerNamespace( 'Iptc4xmpCore', 'http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/' );
1117+
1118+
$node_list = $xpath->query( '/x:xmpmeta/rdf:RDF/rdf:Description/Iptc4xmpCore:AltTextAccessibility' );
1119+
if ( $node_list && $node_list->count() ) {
1120+
1121+
$node = $node_list->item( 0 );
1122+
1123+
// Get the site's locale.
1124+
$locale = get_locale();
1125+
1126+
// Get the alt text accessibility alternative most appropriate for the site language.
1127+
// There are 3 possibilities:
1128+
//
1129+
// 1. there is an rdf:li with an exact match on the site locale.
1130+
// 2. there is an rdf:li with a partial match on the site locale (e.g., site locale is en_US and rdf:li has @xml:lang="en").
1131+
// 3. there is an rdf:li with an "x-default" lang.
1132+
//
1133+
// Evaluate in that order, stopping when we have a match.
1134+
$alt_text = $xpath->evaluate( "string( rdf:Alt/rdf:li[ @xml:lang = '{$locale}' ] )", $node );
1135+
if ( ! $alt_text ) {
1136+
$alt_text = $xpath->evaluate( 'string( rdf:Alt/rdf:li[ @xml:lang = "' . substr( $locale, 0, 2 ) . '" ] )', $node );
1137+
if ( ! $alt_text ) {
1138+
$alt_text = $xpath->evaluate( 'string( rdf:Alt/rdf:li[ @xml:lang = "x-default" ] )', $node );
1139+
}
1140+
}
1141+
}
1142+
1143+
return $alt_text;
1144+
}
1145+
10771146
/**
10781147
* Validates that file is an image.
10791148
*

src/wp-admin/includes/media.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid
319319
$title = sanitize_text_field( $name );
320320
$content = '';
321321
$excerpt = '';
322+
$alt = '';
322323

323324
if ( preg_match( '#^audio#', $type ) ) {
324325
$meta = wp_read_audio_metadata( $file );
@@ -399,6 +400,10 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid
399400
if ( trim( $image_meta['caption'] ) ) {
400401
$excerpt = $image_meta['caption'];
401402
}
403+
404+
if ( trim( $image_meta['alt'] ) ) {
405+
$alt = $image_meta['alt'];
406+
}
402407
}
403408
}
404409

@@ -421,6 +426,10 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid
421426
// Save the data.
422427
$attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true );
423428

429+
if ( trim( $alt ) ) {
430+
update_post_meta( $attachment_id, '_wp_attachment_image_alt', sanitize_text_field( $alt ) );
431+
}
432+
424433
if ( ! is_wp_error( $attachment_id ) ) {
425434
/*
426435
* Set a custom header with the attachment_id.
@@ -477,6 +486,7 @@ function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_d
477486
$file = $file['file'];
478487
$title = preg_replace( '/\.[^.]+$/', '', wp_basename( $file ) );
479488
$content = '';
489+
$alt = '';
480490

481491
// Use image exif/iptc data for title and caption defaults if possible.
482492
$image_meta = wp_read_image_metadata( $file );
@@ -489,6 +499,9 @@ function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_d
489499
if ( trim( $image_meta['caption'] ) ) {
490500
$content = $image_meta['caption'];
491501
}
502+
if ( trim( $image_meta['alt'] ) ) {
503+
$alt = $image_meta['alt'];
504+
}
492505
}
493506

494507
if ( isset( $desc ) ) {
@@ -513,6 +526,10 @@ function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_d
513526
// Save the attachment metadata.
514527
$attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true );
515528

529+
if ( trim( $alt ) ) {
530+
update_post_meta( $attachment_id, '_wp_attachment_image_alt', sanitize_text_field( $alt ) );
531+
}
532+
516533
if ( ! is_wp_error( $attachment_id ) ) {
517534
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
518535
}

0 commit comments

Comments
 (0)