assets
3 weeks ago
init.php
3 weeks ago
layout-import-api.php
2 years ago
layout-list-api.php
3 weeks ago
library-source.php
2 years ago
layout-list-api.php
33 lines
| 1 | <?php |
| 2 | namespace ElementsKit_Lite\Modules\Layout_Manager; |
| 3 | |
| 4 | defined( 'ABSPATH' ) || exit; |
| 5 | |
| 6 | class Layout_List_Api extends \ElementsKit_Lite\Core\Handler_Api { |
| 7 | |
| 8 | public function config() { |
| 9 | $this->prefix = 'layout-manager-api'; |
| 10 | } |
| 11 | |
| 12 | public function get_layout_list() { |
| 13 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 14 | return new \WP_Error( 'rest_forbidden', esc_html__( 'You do not have permission to access this resource', 'elementskit-lite' ), array( 'status' => 403 ) ); |
| 15 | } |
| 16 | |
| 17 | $param = array_merge( \ElementsKit_Lite::license_data(), $_GET, array( 'action' => 'get_layout_list' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Passed in elementor's hook for get url which has processed the nonce already. |
| 18 | |
| 19 | $response = wp_remote_get( |
| 20 | \ElementsKit_Lite::api_url() . 'layout-manager-api/?' . http_build_query( $param ), |
| 21 | array( |
| 22 | 'timeout' => 30, |
| 23 | 'headers' => array( |
| 24 | 'Content-Type' => 'application/json', |
| 25 | ), |
| 26 | ) |
| 27 | ); |
| 28 | |
| 29 | return json_decode( wp_remote_retrieve_body( $response ) ); |
| 30 | } |
| 31 | |
| 32 | } |
| 33 |