| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* WP Controller |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace Extendify\Assist\Controllers; |
| 8 |
|
| 9 |
defined('ABSPATH') || die('No direct access.'); |
| 10 |
|
| 11 |
/** |
| 12 |
* The controller for interacting with WordPress. |
| 13 |
*/ |
| 14 |
|
| 15 |
class WPController |
| 16 |
{ |
| 17 |
/** |
| 18 |
* Get the list of active plugins slugs |
| 19 |
* |
| 20 |
* @return \WP_REST_Response |
| 21 |
*/ |
| 22 |
public static function getActivePlugins() |
| 23 |
{ |
| 24 |
$value = \get_option('active_plugins', null); |
| 25 |
$slugs = []; |
| 26 |
foreach ($value as $plugin) { |
| 27 |
$slugs[] = explode('/', $plugin)[0]; |
| 28 |
} |
| 29 |
|
| 30 |
return new \WP_REST_Response([ |
| 31 |
'success' => true, |
| 32 |
'data' => $slugs, |
| 33 |
]); |
| 34 |
} |
| 35 |
} |
| 36 |
|