Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| AbstractTaskManager | |
0.00% |
0 / 5 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_queue_name | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_hook_name | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| status | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace NewfoldLabs\WP\Module\Installer\TaskManagers; |
| 4 | |
| 5 | use NewfoldLabs\WP\Module\Installer\Data\Options; |
| 6 | |
| 7 | /** |
| 8 | * Manages the execution of Tasks. |
| 9 | */ |
| 10 | abstract class AbstractTaskManager { |
| 11 | |
| 12 | /** |
| 13 | * The number of times a PluginUninstallTask can be retried. |
| 14 | * |
| 15 | * @var int |
| 16 | */ |
| 17 | protected static $retry_limit = 1; |
| 18 | |
| 19 | /** |
| 20 | * Name of the Queue. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | protected static $queue_name = ''; |
| 25 | |
| 26 | /** |
| 27 | * Name of the Hook. |
| 28 | * |
| 29 | * @var string |
| 30 | */ |
| 31 | protected static $hook_name = ''; |
| 32 | |
| 33 | /** |
| 34 | * PluginUninstallTaskManager constructor. |
| 35 | */ |
| 36 | public function __construct() { |
| 37 | TaskManagerSchedules::init(); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Retrieve the Queue Name for the TaskManager. |
| 42 | * |
| 43 | * @return string |
| 44 | */ |
| 45 | public static function get_queue_name() { |
| 46 | return static::$queue_name; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | /** |
| 51 | * Retrieve the Hook Name for the TaskManager. |
| 52 | * |
| 53 | * @return string |
| 54 | */ |
| 55 | public static function get_hook_name() { |
| 56 | return static::$hook_name; |
| 57 | } |
| 58 | |
| 59 | |
| 60 | /** |
| 61 | * Returns the status of given plugin slug - uninstalling/completed. |
| 62 | * |
| 63 | * @param string $plugin Plugin Slug |
| 64 | * @return string|false |
| 65 | */ |
| 66 | public static function status( $plugin ) { |
| 67 | $plugins = \get_option( Options::get_option_name( static::$queue_name ), array() ); |
| 68 | return array_search( $plugin, array_column( $plugins, 'slug' ), true ); |
| 69 | } |
| 70 | } |