Add WooCommerceSettings endpoint
[MAILPOET-2278]
This commit is contained in:
committed by
Jack Kitterhing
parent
af902e93f4
commit
86cffacdbe
33
lib/API/JSON/v1/WoocommerceSettings.php
Normal file
33
lib/API/JSON/v1/WoocommerceSettings.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\API\JSON\v1;
|
||||
|
||||
use MailPoet\API\JSON\Endpoint as APIEndpoint;
|
||||
use MailPoet\Config\AccessControl;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class WoocommerceSettings extends APIEndpoint {
|
||||
public $permissions = [
|
||||
'global' => AccessControl::PERMISSION_MANAGE_EMAILS,
|
||||
];
|
||||
|
||||
private $allowed_settings = [
|
||||
'woocommerce_email_base_color',
|
||||
];
|
||||
|
||||
/** @var WPFunctions */
|
||||
private $wp;
|
||||
|
||||
function __construct(WPFunctions $wp) {
|
||||
$this->wp = $wp;
|
||||
}
|
||||
|
||||
function set($data = []) {
|
||||
foreach ($data as $option => $value) {
|
||||
if (in_array($option, $this->allowed_settings)) {
|
||||
$this->wp->updateOption($option, $value);
|
||||
}
|
||||
}
|
||||
return $this->successResponse([]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user