| 1 |
<?php |
| 2 |
|
| 3 |
namespace StoreEngine; |
| 4 |
|
| 5 |
use StoreEngine; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
|
| 12 |
class API { |
| 13 |
|
| 14 |
public static function init() { |
| 15 |
$self = new self(); |
| 16 |
|
| 17 |
API\Product::init(); |
| 18 |
API\Orders::init(); |
| 19 |
API\cart::init(); |
| 20 |
API\MiniCart::init(); |
| 21 |
API\Payment::init(); |
| 22 |
API\Analytics::init(); |
| 23 |
API\Customer::init(); |
| 24 |
API\Settings::init(); |
| 25 |
API\Taxes::init(); |
| 26 |
API\Shipping::init(); |
| 27 |
API\Coupon::init(); |
| 28 |
API\Logs::init(); |
| 29 |
API\EmailLog::init(); |
| 30 |
API\Checkout::init(); |
| 31 |
API\PaymentMethods::init(); |
| 32 |
API\StorefrontAuth::init(); |
| 33 |
API\Me::init(); |
| 34 |
API\MeSubscriptions::init(); |
| 35 |
API\BundleSync::init(); |
| 36 |
|
| 37 |
|
| 38 |
add_filter( 'rest_api_init', [ $self, 'api_init' ] ); |
| 39 |
add_filter( 'user_has_cap', array( $self, 'update_user_cap' ), 10, 3 ); |
| 40 |
} |
| 41 |
|
| 42 |
public function api_init() { |
| 43 |
// @TODO move to specific api where cart is needed. |
| 44 |
StoreEngine::init()->load_cart(); |
| 45 |
} |
| 46 |
|
| 47 |
public function update_user_cap( $all_caps, $cap, $args ) { |
| 48 |
if ( isset( $all_caps['edit_posts'] ) && $all_caps['edit_posts'] ) { |
| 49 |
$all_caps['edit_post_meta'] = true; |
| 50 |
$all_caps['delete_post_meta'] = true; |
| 51 |
} |
| 52 |
|
| 53 |
return $all_caps; |
| 54 |
} |
| 55 |
} |
| 56 |
|