| 1 |
<?php |
| 2 |
namespace Elementor\App\Modules\KitLibrary\Connect; |
| 3 |
|
| 4 |
use Elementor\Core\Common\Modules\Connect\Apps\Base_App; |
| 5 |
use Elementor\Core\Common\Modules\Connect\Apps\Library; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
class Kit_Library extends Library { |
| 12 |
const DEFAULT_BASE_ENDPOINT = 'https://my.elementor.com/api/v1/kits-library'; |
| 13 |
const FALLBACK_BASE_ENDPOINT = 'https://ms-8874.elementor.com/api/v1/kits-library'; |
| 14 |
|
| 15 |
public function get_title() { |
| 16 |
return esc_html__( 'Kit Library', 'elementor' ); |
| 17 |
} |
| 18 |
|
| 19 |
public function get_all( $args = [] ) { |
| 20 |
return $this->http_request( 'GET', 'kits/plugin-version/' . ELEMENTOR_VERSION, $args ); |
| 21 |
} |
| 22 |
|
| 23 |
public function get_by_id( $id ) { |
| 24 |
return $this->http_request( 'GET', 'kits/' . $id ); |
| 25 |
} |
| 26 |
|
| 27 |
public function get_taxonomies() { |
| 28 |
return $this->http_request( 'GET', 'taxonomies' ); |
| 29 |
} |
| 30 |
|
| 31 |
public function get_manifest( $id ) { |
| 32 |
return $this->http_request( 'GET', "kits/{$id}/manifest" ); |
| 33 |
} |
| 34 |
|
| 35 |
public function download_link( $id ) { |
| 36 |
return $this->http_request( 'GET', "kits/{$id}/download-link" ); |
| 37 |
} |
| 38 |
|
| 39 |
protected function get_api_url() { |
| 40 |
return [ |
| 41 |
static::DEFAULT_BASE_ENDPOINT, |
| 42 |
static::FALLBACK_BASE_ENDPOINT, |
| 43 |
]; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Get all the connect information |
| 48 |
* |
| 49 |
* @return array |
| 50 |
*/ |
| 51 |
protected function get_connect_info() { |
| 52 |
$connect_info = $this->get_base_connect_info(); |
| 53 |
|
| 54 |
$additional_info = []; |
| 55 |
|
| 56 |
// BC Support. |
| 57 |
$old_kit_library = new \Elementor\Core\App\Modules\KitLibrary\Connect\Kit_Library(); |
| 58 |
|
| 59 |
/** |
| 60 |
* Additional connect info. |
| 61 |
* |
| 62 |
* Filters the connection information when connecting to Elementor servers. |
| 63 |
* This hook can be used to add more information or add more data. |
| 64 |
* |
| 65 |
* @param array $additional_info Additional connecting information array. |
| 66 |
* @param Base_App $this The base app instance. |
| 67 |
*/ |
| 68 |
$additional_info = apply_filters( 'elementor/connect/additional-connect-info', $additional_info, $old_kit_library ); |
| 69 |
|
| 70 |
return array_merge( $connect_info, $additional_info ); |
| 71 |
} |
| 72 |
|
| 73 |
protected function init() { |
| 74 |
// Remove parent init actions. |
| 75 |
} |
| 76 |
} |
| 77 |
|