| 1 |
<?php |
| 2 |
namespace Elementor\Core\Editor\Data\Globals; |
| 3 |
|
| 4 |
use Elementor\Data\V2\Base\Controller as Controller_Base; |
| 5 |
use Elementor\Data\V2\Base\Endpoint; |
| 6 |
use Elementor\Plugin; |
| 7 |
|
| 8 |
class Controller extends Controller_Base { |
| 9 |
public function get_name() { |
| 10 |
return 'globals'; |
| 11 |
} |
| 12 |
|
| 13 |
public function register_endpoints() { |
| 14 |
$this->register_endpoint( new Endpoints\Colors( $this ) ); |
| 15 |
$this->register_endpoint( new Endpoints\Typography( $this ) ); |
| 16 |
} |
| 17 |
|
| 18 |
public function get_collection_params() { |
| 19 |
// Does not have 'get_items' args (OPTIONS). |
| 20 |
// Maybe TODO: try `$this->get_index_endpoint()->get_collection_params()`. |
| 21 |
return []; |
| 22 |
} |
| 23 |
|
| 24 |
public function get_permission_callback( $request ) { |
| 25 |
// Allow internal get global values. (e.g render global.css for a visitor) |
| 26 |
if ( 'GET' === $request->get_method() && Plugin::$instance->data_manager_v2->is_internal() ) { |
| 27 |
return true; |
| 28 |
} |
| 29 |
|
| 30 |
return current_user_can( 'edit_posts' ); |
| 31 |
} |
| 32 |
|
| 33 |
protected function register_index_endpoint() { |
| 34 |
$this->register_endpoint( new Endpoint\Index\AllChildren( $this ) ); |
| 35 |
} |
| 36 |
} |
| 37 |
|