Skip to content
Snippets Groups Projects
Commit bf4a5800 authored by Dyszczo's avatar Dyszczo
Browse files

Merge branch 'feature/can-render-or-disable' into 'devel'

requirement class can render or disable

See merge request !7
parents c52ff062 cc03850e
No related branches found
No related tags found
2 merge requests!8Devel,!7requirement class can render or disable
Pipeline #8284 passed
...@@ -345,13 +345,46 @@ class WPDesk_Basic_Requirement_Checker implements WPDesk_Translatable { ...@@ -345,13 +345,46 @@ class WPDesk_Basic_Requirement_Checker implements WPDesk_Translatable {
/** /**
* @return void * @return void
*
* @deprecated use render_notices or disable_plugin
*/ */
public function disable_plugin_render_notice() { public function disable_plugin_render_notice() {
add_action( self::HOOK_ADMIN_NOTICES_ACTION, array( $this, 'render_notices_action' ) ); add_action( self::HOOK_ADMIN_NOTICES_ACTION, array( $this, 'render_notices_action' ) );
} }
/** /**
* Shoud be called as WordPress 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 ) );
}
}
/**
* Should be called as WordPress action
*
* @internal Do not use as public. Public only for wp action.
* *
* @return void * @return void
*/ */
......
...@@ -158,7 +158,8 @@ class Test_Basic_Requirement_Checker extends PHPUnit\Framework\TestCase { ...@@ -158,7 +158,8 @@ class Test_Basic_Requirement_Checker extends PHPUnit\Framework\TestCase {
[ $requirements, 'render_notices_action' ] ); [ $requirements, 'render_notices_action' ] );
$this->assertFalse( $requirements->are_requirements_met() ); $this->assertFalse( $requirements->are_requirements_met() );
$requirements->disable_plugin_render_notice(); $requirements->disable_plugin();
$requirements->render_notices();
$this->expectOutputRegex( '/cannot run on PHP/' ); $this->expectOutputRegex( '/cannot run on PHP/' );
$requirements->render_notices_action(); $requirements->render_notices_action();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment