diff --git a/CHANGELOG.md b/CHANGELOG.md index 9036fe1b96ccaa62a6386bfff137620e0e854523..2d20b79cf5b1434ac08ae388a9b5145b7fe4b52c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## [3.2.1] - 2019-11-15 ### Fixed - Fixed plugin version notice +- Fixed required plugin name display in admin notices ## [3.2.0] - 2019-11-14 ### Added diff --git a/src/Basic_Requirement_Checker.php b/src/Basic_Requirement_Checker.php index 7feeb269338cf69f7aafb859b5fc1fafe225a323..ff0672e289901e97d47e9527c17cb1089f9604f0 100644 --- a/src/Basic_Requirement_Checker.php +++ b/src/Basic_Requirement_Checker.php @@ -297,7 +297,7 @@ foreach ( $required_plugins as $plugin ) { if ( version_compare ( $plugin[ 'Version' ], $plugin[ self::PLUGIN_INFO_APPEND_PLUGIN_DATA ] , '<' ) ) { $notices[] = $this->prepare_notice_message( sprintf( __( 'The “%s” plugin requires at least %s version of %s to work correctly. Please update it', $this->get_text_domain() ), - esc_html( $this->plugin_name ), $plugin[ self::PLUGIN_INFO_APPEND_PLUGIN_DATA ], $plugin[ 'Version' ] ) ); + esc_html( $this->plugin_name ), $plugin[ self::PLUGIN_INFO_APPEND_PLUGIN_DATA ], $plugin[ 'Name' ] ) ); } } } diff --git a/src/Basic_Requirement_Checker_Factory.php b/src/Basic_Requirement_Checker_Factory.php index 4535a49170377b16c54314141fc2a8af9fb21789..00b72de3d4a9c5710470719937e8814e1a7f9858 100644 --- a/src/Basic_Requirement_Checker_Factory.php +++ b/src/Basic_Requirement_Checker_Factory.php @@ -42,7 +42,7 @@ $requirements_checker = new WPDesk_Basic_Requirement_Checker_With_Update_Disable( $plugin_file, $plugin_name, - $text_domain, + $text_domain, $requirements['php'], $requirements['wp'] ); diff --git a/tests/unit/Test_Basic_Requirement_Checker_Factory.php b/tests/unit/Test_Basic_Requirement_Checker_Factory.php index 7d8c9642830487b8b54b6ca3f17afe08eca92a6e..d7f6183ca953a20be1b400136b9e5df7025da4d9 100644 --- a/tests/unit/Test_Basic_Requirement_Checker_Factory.php +++ b/tests/unit/Test_Basic_Requirement_Checker_Factory.php @@ -1,51 +1,51 @@ <?php - - -class Test_Basic_Requirement_Checker_Factory extends PHPUnit\Framework\TestCase { - public function test_can_create_checker_withn_valid_requirements() { - $existing_locale = 'pl_PL'; - $requirements = array( - 'php' => '5.6', - 'wp' => '4.5', - 'plugins' => array( - array( - 'name' => 'woocommerce/woocommerce.php', - 'nice_name' => 'WooCommerce', - 'version' => '1.0' + + + class Test_Basic_Requirement_Checker_Factory extends PHPUnit\Framework\TestCase { + public function test_can_create_checker_withn_valid_requirements() { + $existing_locale = 'pl_PL'; + $requirements = array( + 'php' => '5.6', + 'wp' => '4.5', + 'plugins' => array( + array( + 'name' => 'woocommerce/woocommerce.php', + 'nice_name' => 'WooCommerce', + 'version' => '1.0' + ), ), - ), - 'repo_plugins' => array( - array( - 'name' => 'flexible-checkout-fields/flexible-checkout-fields.php', - 'version' => '1.0', - 'nice_name' => 'Flexible Checkout Fields', + 'repo_plugins' => array( + array( + 'name' => 'flexible-checkout-fields/flexible-checkout-fields.php', + 'version' => '1.0', + 'nice_name' => 'Flexible Checkout Fields', + ), ), - ), - ); - - WP_Mock::wpFunction( 'get_locale' ) - ->andReturn( $existing_locale ); - - $factory = new WPDesk_Basic_Requirement_Checker_Factory(); - $checker = $factory->create_from_requirement_array( 'whatever', 'whatever', $requirements ); - - WP_Mock::wpFunction( 'get_plugins' ) - ->andReturn( array() ); - - WP_Mock::wpFunction( 'get_option' ) - ->withArgs( array( 'active_plugins', array() ) ) - ->andReturn( array() ); - - WP_Mock::passthruFunction( 'self_admin_url' ); - WP_Mock::passthruFunction( 'wp_kses' ); - WP_Mock::passthruFunction( 'wp_nonce_url' ); - WP_Mock::passthruFunction( 'wp_create_nonce' ); - WP_Mock::passthruFunction( 'admin_url' ); - - $this->assertFalse( $checker->are_requirements_met(), '2 plugins required and there should be none activated' ); - - $this->expectOutputRegex( '/Flexible Checkout Fields/' ); - $this->expectOutputRegex( '/WooCommerce/' ); - $checker->handle_render_notices_action(); + ); + + WP_Mock::wpFunction( 'get_locale' ) + ->andReturn( $existing_locale ); + + $factory = new WPDesk_Basic_Requirement_Checker_Factory(); + $checker = $factory->create_from_requirement_array( 'whatever', 'whatever', $requirements ); + + WP_Mock::wpFunction( 'get_plugins' ) + ->andReturn( array() ); + + WP_Mock::wpFunction( 'get_option' ) + ->withArgs( array( 'active_plugins', array() ) ) + ->andReturn( array() ); + + WP_Mock::passthruFunction( 'self_admin_url' ); + WP_Mock::passthruFunction( 'wp_kses' ); + WP_Mock::passthruFunction( 'wp_nonce_url' ); + WP_Mock::passthruFunction( 'wp_create_nonce' ); + WP_Mock::passthruFunction( 'admin_url' ); + + $this->assertFalse( $checker->are_requirements_met(), '2 plugins required and there should be none activated' ); + + $this->expectOutputRegex( '/Flexible Checkout Fields/' ); + $this->expectOutputRegex( '/WooCommerce/' ); + $checker->handle_render_notices_action(); + } } -}