Skip to content

Commit 344e04d

Browse files
committed
Merge branch 'trunk' into block_styles_on_demand_in_classic_themes
2 parents 6bf0d4a + 7e980dd commit 344e04d

File tree

5 files changed

+86
-7
lines changed

5 files changed

+86
-7
lines changed

src/wp-admin/includes/plugin.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,20 @@ function validate_plugin_requirements( $plugin ) {
12471247
);
12481248
}
12491249

1250-
return true;
1250+
/**
1251+
* Filters the plugin requirement validation response.
1252+
*
1253+
* If a plugin fails due to a Core-provided validation (incompatible WP, PHP versions), this
1254+
* filter will not fire. A WP_Error response will already be returned.
1255+
*
1256+
* This filter is intended to add additional validation steps by site administrators.
1257+
*
1258+
* @since 6.9.0
1259+
*
1260+
* @param bool|WP_Error $met_requirements True if the plugin meets requirements, WP_Error if not.
1261+
* @param string $plugin Path to the plugin file relative to the plugins directory.
1262+
*/
1263+
return apply_filters( 'validate_plugin_requirements', true, $plugin );
12511264
}
12521265

12531266
/**

src/wp-includes/template.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,21 +323,24 @@ function get_tag_template() {
323323
* The hierarchy for this template looks like:
324324
*
325325
* 1. taxonomy-{taxonomy_slug}-{term_slug}.php
326-
* 2. taxonomy-{taxonomy_slug}.php
327-
* 3. taxonomy.php
326+
* 2. taxonomy-{taxonomy_slug}-{term_id}.php
327+
* 3. taxonomy-{taxonomy_slug}.php
328+
* 4. taxonomy.php
328329
*
329330
* An example of this is:
330331
*
331332
* 1. taxonomy-location-texas.php
332-
* 2. taxonomy-location.php
333-
* 3. taxonomy.php
333+
* 2. taxonomy-location-67.php
334+
* 3. taxonomy-location.php
335+
* 4. taxonomy.php
334336
*
335337
* The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
336338
* and {@see '$type_template'} dynamic hooks, where `$type` is 'taxonomy'.
337339
*
338340
* @since 2.5.0
339341
* @since 4.7.0 The decoded form of `taxonomy-{taxonomy_slug}-{term_slug}.php` was added to the top of the
340342
* template hierarchy when the term slug contains multibyte characters.
343+
* @since 6.9.0 Added `taxonomy-{taxonomy_slug}-{term_id}.php` to the hierarchy.
341344
*
342345
* @see get_query_template()
343346
*
@@ -357,6 +360,7 @@ function get_taxonomy_template() {
357360
}
358361

359362
$templates[] = "taxonomy-$taxonomy-{$term->slug}.php";
363+
$templates[] = "taxonomy-$taxonomy-{$term->term_id}.php";
360364
$templates[] = "taxonomy-$taxonomy.php";
361365
}
362366
$templates[] = 'taxonomy.php';

src/wp-includes/theme.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,20 @@ function validate_theme_requirements( $stylesheet ) {
10021002
);
10031003
}
10041004

1005-
return true;
1005+
/**
1006+
* Filters the theme requirement validation response.
1007+
*
1008+
* If a theme fails due to a Core-provided validation (incompatible WP, PHP versions), this
1009+
* filter will not fire. A WP_Error response will already be returned.
1010+
*
1011+
* This filter is intended to add additional validation steps by site administrators.
1012+
*
1013+
* @since 6.9.0
1014+
*
1015+
* @param bool|WP_Error $met_requirements True if the theme meets requirements, WP_Error if not.
1016+
* @param string $stylesheet Directory name for the theme.
1017+
*/
1018+
return apply_filters( 'validate_theme_requirements', true, $stylesheet );
10061019
}
10071020

10081021
/**

src/wp-includes/user.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,6 @@ function is_user_member_of_blog( $user_id = 0, $blog_id = 0 ) {
11961196
return false;
11971197
}
11981198

1199-
12001199
if ( 1 === $blog_id ) {
12011200
$capabilities_key = $wpdb->base_prefix . 'capabilities';
12021201
} else {

tests/phpunit/tests/theme.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,4 +1529,54 @@ public function test_switch_to_blog_uses_original_template_path() {
15291529

15301530
$this->assertSame( $template_path, $new_template_path, 'Switching blogs switches the template path' );
15311531
}
1532+
1533+
/**
1534+
* Verify the validate_theme_requirements theme responds as expected for twentyten.
1535+
*
1536+
* @ticket 54381
1537+
*/
1538+
public function test_validate_theme_requirements_filter_default() {
1539+
// Default expectation since twentyten has the least strict requirements.
1540+
$this->assertTrue( validate_theme_requirements( 'twentyten' ) );
1541+
}
1542+
1543+
/**
1544+
* Verify that a filtered failure of validate_theme_requirements returns WP_Error
1545+
*
1546+
* @ticket 54381
1547+
*/
1548+
public function test_validate_theme_requirements_filter_error() {
1549+
// Adds an extra requirement that always fails.
1550+
add_filter(
1551+
'validate_theme_requirements',
1552+
function () {
1553+
return new WP_Error( 'theme_test_failed_requirement' );
1554+
}
1555+
);
1556+
1557+
$this->assertInstanceOf( 'WP_Error', validate_theme_requirements( 'twentyten' ) );
1558+
}
1559+
1560+
/**
1561+
* Verify that the theme is passed through to the validate_theme_requirements filter by selectively erroring.
1562+
*
1563+
* @ticket 54381
1564+
*/
1565+
public function test_validate_theme_requirements_filter_selective_failure() {
1566+
// Adds an extra requirement only for a particular theme.
1567+
add_filter(
1568+
'validate_theme_requirements',
1569+
function ( $met_requirements, $stylesheet ) {
1570+
if ( 'twentytwenty' === $stylesheet ) {
1571+
return new WP_Error( 'theme_test_failed_requirement' );
1572+
}
1573+
return $met_requirements;
1574+
},
1575+
10,
1576+
2
1577+
);
1578+
1579+
$this->assertTrue( validate_theme_requirements( 'twentyten' ) );
1580+
$this->assertInstanceOf( 'WP_Error', validate_theme_requirements( 'twentytwenty' ) );
1581+
}
15321582
}

0 commit comments

Comments
 (0)