| 1 |
<?php |
| 2 |
/** |
| 3 |
* Get_Status_Ability class. |
| 4 |
* |
| 5 |
* @package cookiebot |
| 6 |
* @subpackage abilities |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace cybot\cookiebot\abilities; |
| 10 |
|
| 11 |
use cybot\cookiebot\lib\Cookiebot_WP; |
| 12 |
|
| 13 |
/** |
| 14 |
* Ability to get Cookiebot CMP status. |
| 15 |
* |
| 16 |
* @since 4.8.0 |
| 17 |
*/ |
| 18 |
class Get_Status_Ability implements Cookiebot_Ability_Interface { |
| 19 |
|
| 20 |
/** |
| 21 |
* Returns the ability name. |
| 22 |
* |
| 23 |
* @return string |
| 24 |
* |
| 25 |
* @since 4.8.0 |
| 26 |
*/ |
| 27 |
public function get_name() { |
| 28 |
return 'cookiebot/get-status'; |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Returns the ability arguments. |
| 33 |
* |
| 34 |
* @return array |
| 35 |
* |
| 36 |
* @since 4.8.0 |
| 37 |
*/ |
| 38 |
public function get_args() { |
| 39 |
return array( |
| 40 |
'label' => __( 'Get Cookiebot Status', 'cookiebot' ), |
| 41 |
'description' => __( 'Returns the current Cookiebot CMP plugin configuration: whether a Domain Group ID is set, GCM v2 status, cookie blocking mode, banner state, and plugin version.', 'cookiebot' ), |
| 42 |
'category' => 'cookiebot', |
| 43 |
'output_schema' => array( |
| 44 |
'type' => 'object', |
| 45 |
'properties' => array( |
| 46 |
'cbid_set' => array( 'type' => 'boolean', 'description' => 'Whether a Domain Group ID has been configured.' ), |
| 47 |
'gcm_enabled' => array( 'type' => 'boolean', 'description' => 'Whether Google Consent Mode v2 is enabled.' ), |
| 48 |
'blocking_mode' => array( 'type' => 'string', 'description' => 'Cookie blocking mode: auto or manual.' ), |
| 49 |
'banner_enabled' => array( 'type' => 'boolean', 'description' => 'Whether the consent banner is enabled.' ), |
| 50 |
'plugin_version' => array( 'type' => 'string', 'description' => 'Installed plugin version.' ), |
| 51 |
), |
| 52 |
'additionalProperties' => false, |
| 53 |
), |
| 54 |
'execute_callback' => function() { |
| 55 |
$cbid = Cookiebot_WP::get_cbid(); |
| 56 |
return array( |
| 57 |
'cbid_set' => ! empty( $cbid ), |
| 58 |
'gcm_enabled' => Cookiebot_WP::get_gcm_enabled() === '1', |
| 59 |
'blocking_mode' => Cookiebot_WP::get_cookie_blocking_mode(), |
| 60 |
'banner_enabled' => Cookiebot_WP::get_banner_enabled() === '1', |
| 61 |
'plugin_version' => Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION, |
| 62 |
); |
| 63 |
}, |
| 64 |
'permission_callback' => function() { |
| 65 |
return current_user_can( 'manage_options' ); |
| 66 |
}, |
| 67 |
'meta' => array( |
| 68 |
'annotations' => array( 'readonly' => true, 'destructive' => false, 'idempotent' => true ), |
| 69 |
'show_in_rest' => true, |
| 70 |
), |
| 71 |
); |
| 72 |
} |
| 73 |
} |
| 74 |
|