Skip to content

Commit 4f4e28a

Browse files
committed
Plugins and Themes: Add filters to validation functions.
It is now possible to add additional validation requirements for themes and plugins besides the built in core checks. Developed in WordPress/wordpress-develop#1812 and WordPress/wordpress-develop#10361. Props kraftbj, mukesh27, jorbin, joedolson. Fixes #54381. Built from https://develop.svn.wordpress.org/trunk@60995 git-svn-id: http://core.svn.wordpress.org/trunk@60331 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent e3b7bff commit 4f4e28a

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

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
/**

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
/**

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '6.9-alpha-60994';
19+
$wp_version = '6.9-alpha-60995';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)