diff --git a/src/Basic_Requirement_Checker.php b/src/Basic_Requirement_Checker.php index 5346a1511145a99244c520f58888abe189a17520..89ae599f125432ffbc8297e4293872ecbeccdef2 100644 --- a/src/Basic_Requirement_Checker.php +++ b/src/Basic_Requirement_Checker.php @@ -345,14 +345,47 @@ class WPDesk_Basic_Requirement_Checker implements WPDesk_Translatable { /** * @return void + * + * @deprecated use render_notices or disable_plugin */ public function disable_plugin_render_notice() { add_action( self::HOOK_ADMIN_NOTICES_ACTION, array( $this, 'render_notices_action' ) ); } + /** + * Renders requirement notices in admin panel + * + * @return void + */ + public function render_notices() { + add_action( self::HOOK_ADMIN_NOTICES_ACTION, array( $this, 'render_notices_action' ) ); + } + + /** + * Renders requirement notices in admin panel + * + * @return void + */ + public function disable_plugin() { + add_action( self::HOOK_ADMIN_NOTICES_ACTION, array( $this, 'deactivate_action' ) ); + } + + /** + * @internal Do not use as public. Public only for wp action. + * + * @return void + */ + public function deactivate_action() { + if ( isset( $this->plugin_file ) ) { + deactivate_plugins( plugin_basename( $this->plugin_file ) ); + } + } + /** - * Shoud be called as WordPress action + * Should be called as WordPress action * + * @internal Do not use as public. Public only for wp action. + * * @return void */ public function render_notices_action() { diff --git a/tests/unit/Test_Basic_Requirement_Checker.php b/tests/unit/Test_Basic_Requirement_Checker.php index ccc6d12625caa45e0f20be42a9d7d39f0d8bfa68..e68e24d5e82e428bad51c0c6cd46fec47ae5560d 100644 --- a/tests/unit/Test_Basic_Requirement_Checker.php +++ b/tests/unit/Test_Basic_Requirement_Checker.php @@ -158,7 +158,8 @@ class Test_Basic_Requirement_Checker extends PHPUnit\Framework\TestCase { [ $requirements, 'render_notices_action' ] ); $this->assertFalse( $requirements->are_requirements_met() ); - $requirements->disable_plugin_render_notice(); + $requirements->disable_plugin(); + $requirements->render_notices(); $this->expectOutputRegex( '/cannot run on PHP/' ); $requirements->render_notices_action();