| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Routes; |
| 4 |
|
| 5 |
use WP_REST_Response; |
| 6 |
use Yoast\WP\SEO\Conditionals\Addon_Installation_Conditional; |
| 7 |
use Yoast\WP\SEO\Main; |
| 8 |
|
| 9 |
/** |
| 10 |
* Supported_Features_Route class. |
| 11 |
*/ |
| 12 |
class Supported_Features_Route implements Route_Interface { |
| 13 |
|
| 14 |
/** |
| 15 |
* Represents the supported features route. |
| 16 |
* |
| 17 |
* @var string |
| 18 |
*/ |
| 19 |
const SUPPORTED_FEATURES_ROUTE = '/supported-features'; |
| 20 |
|
| 21 |
/** |
| 22 |
* Returns the conditionals based in which this loadable should be active. |
| 23 |
* |
| 24 |
* @return array |
| 25 |
*/ |
| 26 |
public static function get_conditionals() { |
| 27 |
return [ |
| 28 |
Addon_Installation_Conditional::class, |
| 29 |
]; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Registers routes with WordPress. |
| 34 |
* |
| 35 |
* @return void |
| 36 |
*/ |
| 37 |
public function register_routes() { |
| 38 |
$supported_features_route = [ |
| 39 |
'methods' => 'GET', |
| 40 |
'callback' => [ $this, 'get_supported_features' ], |
| 41 |
'permission_callback' => '__return_true', |
| 42 |
]; |
| 43 |
|
| 44 |
\register_rest_route( Main::API_V1_NAMESPACE, self::SUPPORTED_FEATURES_ROUTE, $supported_features_route ); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Returns a list of features supported by this yoast seo installation. |
| 49 |
* |
| 50 |
* @return WP_REST_Response a list of features supported by this yoast seo installation. |
| 51 |
*/ |
| 52 |
public function get_supported_features() { |
| 53 |
return new WP_REST_Response( |
| 54 |
[ |
| 55 |
'addon-installation' => 1, |
| 56 |
] |
| 57 |
); |
| 58 |
} |
| 59 |
} |
| 60 |
|