Skip to content

Commit 02a9794

Browse files
Merge branch 'trunk' into add-scaled-to-sideload-route
2 parents 5405e38 + 9ce5419 commit 02a9794

11 files changed

Lines changed: 66 additions & 130 deletions

File tree

src/js/_enqueues/wp/sanitize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* @return {string} Stripped text.
2424
*/
2525
stripTags: function( text ) {
26-
if ( ! text ) {
26+
if ( 'string' !== typeof text ) {
2727
return '';
2828
}
2929

src/wp-admin/css/common.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,10 @@ img.emoji {
812812
content: "\f153";
813813
content: "\f153" / '';
814814
display: block;
815-
font: normal 20px/24px dashicons;
816-
height: 24px;
815+
font: normal 20px/1 dashicons;
816+
height: 1em;
817817
text-align: center;
818-
width: 24px;
818+
width: 1em;
819819
-webkit-font-smoothing: antialiased;
820820
-moz-osx-font-smoothing: grayscale;
821821
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,9 @@ body.trashing #publish-settings {
613613
#customize-controls .control-section .accordion-section-title button:hover,
614614
#customize-controls .control-section.open .accordion-section-title,
615615
#customize-controls .control-section .accordion-section-title button:focus {
616-
color: #2271b1;
616+
color: var(--wp-admin-theme-color, #3858e9);
617617
background: #f6f7f7;
618-
border-left-color: #2271b1;
618+
border-left-color: var(--wp-admin-theme-color, #3858e9);
619619
}
620620

621621
#accordion-section-themes + .control-section {

src/wp-admin/css/dashboard.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
outline-offset: -2px;
7373
border-radius: 8px;
7474
height: 250px;
75+
margin: 4px;
7576
}
7677

7778
/* Only highlight drop zones when dragging. */

src/wp-admin/css/list-tables.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ ul.cat-checklist input[name="post_category[]"]:indeterminate::before {
11941194
}
11951195

11961196
#bulk-titles .ntdelbutton:focus {
1197-
box-shadow: 0 0 0 2px #3582c4;
1197+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus, 1.5px) var(--wp-admin-theme-color, #3858e9);
11981198
/* Only visible in Windows High Contrast mode */
11991199
outline: 2px solid transparent;
12001200
/* Reset inherited offset from Gutenberg */

src/wp-includes/ai-client/class-wp-ai-client-prompt-builder.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,18 @@ class WP_AI_Client_Prompt_Builder {
165165
* conversations. Default null.
166166
*/
167167
public function __construct( ProviderRegistry $registry, $prompt = null ) {
168-
$this->builder = new PromptBuilder( $registry, $prompt );
168+
try {
169+
$this->builder = new PromptBuilder( $registry, $prompt );
170+
} catch ( Exception $e ) {
171+
$this->builder = new PromptBuilder( $registry );
172+
$this->error = new WP_Error(
173+
'prompt_builder_error',
174+
$e->getMessage(),
175+
array(
176+
'exception_class' => get_class( $e ),
177+
)
178+
);
179+
}
169180

170181
/**
171182
* Filters the default request timeout in seconds for AI Client HTTP requests.

src/wp-includes/class-wp-duotone.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ public static function restore_image_outer_container( $block_content ) {
11931193

11941194
$inner_classnames = explode( ' ', $tags->get_attribute( 'class' ) );
11951195
foreach ( $inner_classnames as $classname ) {
1196-
if ( 0 === strpos( $classname, 'wp-duotone' ) ) {
1196+
if ( str_starts_with( $classname, 'wp-duotone' ) ) {
11971197
$tags->remove_class( $classname );
11981198
$tags->seek( 'wrapper-div' );
11991199
$tags->add_class( $classname );

src/wp-includes/php-ai-client/src/polyfills.php

Lines changed: 0 additions & 91 deletions
This file was deleted.

tests/phpunit/tests/ai-client/wpAiClientPromptBuilder.php

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,22 +1347,15 @@ public function test_validate_messages_non_user_last_returns_wp_error() {
13471347
/**
13481348
* Tests parseMessage with empty string returns WP_Error on termination.
13491349
*
1350-
* The SDK constructor throws immediately for empty strings, so the exception
1351-
* is caught in the constructor and stored.
1352-
*
13531350
* @ticket 64591
13541351
*/
13551352
public function test_parse_message_empty_string_returns_wp_error() {
1356-
// The empty string exception is thrown by the SDK's PromptBuilder constructor,
1357-
// which happens before our __call() error handling. We must catch it manually.
1358-
try {
1359-
$builder = new WP_AI_Client_Prompt_Builder( $this->registry, ' ' );
1360-
// If we get here, the SDK didn't throw. Test would need adjusting.
1361-
$result = $builder->generate_result();
1362-
$this->assertWPError( $result );
1363-
} catch ( InvalidArgumentException $e ) {
1364-
$this->assertStringContainsString( 'Cannot create a message from an empty string', $e->getMessage() );
1365-
}
1353+
$builder = new WP_AI_Client_Prompt_Builder( $this->registry, ' ' );
1354+
$result = $builder->generate_result();
1355+
1356+
$this->assertWPError( $result );
1357+
$this->assertSame( 'prompt_builder_error', $result->get_error_code() );
1358+
$this->assertStringContainsString( 'Cannot create a message from an empty string', $result->get_error_message() );
13661359
}
13671360

13681361
/**
@@ -1371,13 +1364,12 @@ public function test_parse_message_empty_string_returns_wp_error() {
13711364
* @ticket 64591
13721365
*/
13731366
public function test_parse_message_empty_array_returns_wp_error() {
1374-
try {
1375-
$builder = new WP_AI_Client_Prompt_Builder( $this->registry, array() );
1376-
$result = $builder->generate_result();
1377-
$this->assertWPError( $result );
1378-
} catch ( InvalidArgumentException $e ) {
1379-
$this->assertStringContainsString( 'Cannot create a message from an empty array', $e->getMessage() );
1380-
}
1367+
$builder = new WP_AI_Client_Prompt_Builder( $this->registry, array() );
1368+
$result = $builder->generate_result();
1369+
1370+
$this->assertWPError( $result );
1371+
$this->assertSame( 'prompt_builder_error', $result->get_error_code() );
1372+
$this->assertStringContainsString( 'Cannot create a message from an empty array', $result->get_error_message() );
13811373
}
13821374

13831375
/**
@@ -1386,13 +1378,31 @@ public function test_parse_message_empty_array_returns_wp_error() {
13861378
* @ticket 64591
13871379
*/
13881380
public function test_parse_message_invalid_type_returns_wp_error() {
1389-
try {
1390-
$builder = new WP_AI_Client_Prompt_Builder( $this->registry, 123 );
1391-
$result = $builder->generate_result();
1392-
$this->assertWPError( $result );
1393-
} catch ( InvalidArgumentException $e ) {
1394-
$this->assertStringContainsString( 'Input must be a string, MessagePart, MessagePartArrayShape', $e->getMessage() );
1395-
}
1381+
$builder = new WP_AI_Client_Prompt_Builder( $this->registry, 123 );
1382+
$result = $builder->generate_result();
1383+
1384+
$this->assertWPError( $result );
1385+
$this->assertSame( 'prompt_builder_error', $result->get_error_code() );
1386+
$this->assertStringContainsString( 'Input must be a string, MessagePart, MessagePartArrayShape', $result->get_error_message() );
1387+
}
1388+
1389+
/**
1390+
* Tests that wp_ai_client_prompt() with an empty string does not throw.
1391+
*
1392+
* Constructor exceptions are caught and surfaced as WP_Error from
1393+
* generating methods, consistent with the __call() wrapping behavior.
1394+
*
1395+
* @ticket 64591
1396+
*/
1397+
public function test_wp_ai_client_prompt_empty_string_returns_wp_error() {
1398+
$builder = wp_ai_client_prompt( ' ' );
1399+
1400+
$this->assertInstanceOf( WP_AI_Client_Prompt_Builder::class, $builder );
1401+
1402+
$result = $builder->generate_text();
1403+
1404+
$this->assertWPError( $result );
1405+
$this->assertSame( 'prompt_builder_error', $result->get_error_code() );
13961406
}
13971407

13981408
/**

tests/qunit/wp-includes/js/wp-sanitize.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ QUnit.test( 'stripTags should strip tags from string', function( assert ) {
1717
assert.strictEqual( result, 'Hello World', 'stripTags( "<p>Hello <b>World</b></p>" ) should return "Hello World"' );
1818
} );
1919

20-
QUnit.test( 'stripTags should convert numbers to strings', function( assert ) {
21-
const result = wp.sanitize.stripTags( 123 );
22-
assert.strictEqual( result, '123', 'stripTags( 123 ) should return "123"' );
20+
QUnit.test( 'stripTags should return empty string for truthy non-strings', function( assert ) {
21+
assert.strictEqual( wp.sanitize.stripTags( 123 ), '', 'stripTags( 123 ) should return ""' );
22+
assert.strictEqual( wp.sanitize.stripTags( true ), '', 'stripTags( true ) should return ""' );
23+
assert.strictEqual( wp.sanitize.stripTags( [ 6, 7 ] ), '', 'stripTags( [ 6, 7 ] ) should return ""' );
24+
assert.strictEqual( wp.sanitize.stripTags( { foo: 'bar' } ), '', 'stripTags( ( { foo: \'bar\' } ) should return ""' );
2325
} );
2426

2527
QUnit.test( 'stripTags should return empty string for input 0', function( assert ) {

0 commit comments

Comments
 (0)