Use wp_plugin_dependencies_slug in PluginVersionRuleProcessor (#47235)
* Use wp_plugin_dependencies_slug * Fix incorrect function name * Remove unnessary content-type header * Add doc block for wp_plugin_dependencies_slug filter * Add changefile(s) from automation for the following project(s): woocommerce-beta-tester, woocommerce * Tmp fix - fix broken test --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
576db0933c
commit
7360928502
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: update
|
||||
|
||||
Applies `wp_plugin_dependencies_slug` filter to get the correct plugin name in PluginVersionRuleProcessor.
|
|
@ -14,7 +14,6 @@ export function* validate( jsonString ) {
|
|||
const response = yield apiFetch( {
|
||||
method: 'POST',
|
||||
path: `${ API_NAMESPACE }/remote-spec-validator/validate`,
|
||||
headers: { 'content-type': 'application/json' },
|
||||
data: {
|
||||
spec: JSON.stringify( JSON.parse( jsonString ) ),
|
||||
},
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: update
|
||||
|
||||
Applies `wp_plugin_dependencies_slug` filter to get the correct plugin name in PluginVersionRuleProcessor.
|
|
@ -45,12 +45,20 @@ class PluginVersionRuleProcessor implements RuleProcessorInterface {
|
|||
*/
|
||||
public function process( $rule, $stored_state ) {
|
||||
$active_plugin_slugs = $this->plugins_provider->get_active_plugin_slugs();
|
||||
/**
|
||||
* Filters a plugin dependency’s slug before matching to the WordPress.org slug format.
|
||||
*
|
||||
* @since 9.0.0
|
||||
*
|
||||
* @param string $plugin_name requested plugin name
|
||||
*/
|
||||
$plugin_name = apply_filters( 'wp_plugin_dependencies_slug', $rule->plugin );
|
||||
|
||||
if ( ! in_array( $rule->plugin, $active_plugin_slugs, true ) ) {
|
||||
if ( ! in_array( $plugin_name, $active_plugin_slugs, true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$plugin_data = $this->plugins_provider->get_plugin_data( $rule->plugin );
|
||||
$plugin_data = $this->plugins_provider->get_plugin_data( $plugin_name );
|
||||
|
||||
if ( ! is_array( $plugin_data ) || ! array_key_exists( 'Version', $plugin_data ) ) {
|
||||
return false;
|
||||
|
|
|
@ -116,7 +116,9 @@ class WC_Admin_Tests_API_Plugins extends WC_REST_Unit_Test_Case {
|
|||
*/
|
||||
public function test_activate_plugin() {
|
||||
wp_set_current_user( $this->user );
|
||||
|
||||
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
||||
activate_plugin( 'woocommerce/woocommerce.php' );
|
||||
}
|
||||
$request = new WP_REST_Request( 'POST', $this->endpoint . '/activate' );
|
||||
$request->set_query_params(
|
||||
array(
|
||||
|
|
Loading…
Reference in New Issue