| 1 |
<?php |
| 2 |
namespace Elementor\App\Modules\KitLibrary\Data\Kits\Endpoints; |
| 3 |
|
| 4 |
use Elementor\Data\V2\Base\Endpoint; |
| 5 |
use Elementor\App\Modules\KitLibrary\Data\Kits\Controller; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
/** |
| 12 |
* @property Controller $controller |
| 13 |
*/ |
| 14 |
class Download_Link extends Endpoint { |
| 15 |
public function get_name() { |
| 16 |
return 'download-link'; |
| 17 |
} |
| 18 |
|
| 19 |
public function get_format() { |
| 20 |
return 'kits/download-link/{id}'; |
| 21 |
} |
| 22 |
|
| 23 |
protected function register() { |
| 24 |
$this->register_item_route( \WP_REST_Server::READABLE, [ |
| 25 |
'id_arg_type_regex' => '[\w]+', |
| 26 |
] ); |
| 27 |
} |
| 28 |
|
| 29 |
public function get_item( $id, $request ) { |
| 30 |
$repository = $this->controller->get_repository(); |
| 31 |
$data = $repository->get_download_link( $id ); |
| 32 |
|
| 33 |
return [ |
| 34 |
'data' => $data, |
| 35 |
'meta' => [ |
| 36 |
'nonce' => wp_create_nonce( 'kit-library-import' ), |
| 37 |
], |
| 38 |
]; |
| 39 |
} |
| 40 |
} |
| 41 |
|