PluginProbe
Hello Plus / 1.2.0
Hello Plus v1.2.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 All 30 releases
hello-plus / modules / template-parts / classes / sources / source-remote-ehp.php

source-remote-ehp.php in Hello Plus 1.2.0, at modules/template-parts/classes/sources/source-remote-ehp.php

54 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace HelloPlus\Modules\TemplateParts\Classes\Sources;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly
6 }
7
8 class Source_Remote_Ehp extends \Elementor\TemplateLibrary\Source_Remote {
9 const API_TEMPLATES_URL = 'https://my.elementor.com/api/connect/v1/library/templates/';
10 const TEMPLATES_DATA_TRANSIENT_KEY_PREFIX = 'elementor_remote_templates_ehp_data_';
11
12 public function get_id(): string {
13 return 'remote-ehp';
14 }
15
16 /**
17 * @inheritDoc
18 */
19 public function get_title() {
20 return esc_html__( 'Remote-Ehp', 'hello-plus' );
21 }
22
23 /**
24 * @inheritDoc
25 */
26 protected function get_templates_remotely( string $editor_layout_type ) {
27 $query_args = $this->get_url_params( $editor_layout_type );
28 $url = add_query_arg( $query_args, static::API_TEMPLATES_URL );
29
30 $response = wp_remote_get( $url, [
31 'headers' => apply_filters( 'stg-cf-headers', [] ),
32 ] );
33
34 if ( is_wp_error( $response ) || 200 !== (int) wp_remote_retrieve_response_code( $response ) ) {
35 return false;
36 }
37
38 $templates_data = json_decode( wp_remote_retrieve_body( $response ), true );
39
40 if ( empty( $templates_data ) || ! is_array( $templates_data ) ) {
41 return [];
42 }
43
44 return $templates_data;
45 }
46
47 protected function get_url_params( string $editor_layout_type ): array {
48 return [
49 'products' => 'ehp',
50 'editor_layout_type' => $editor_layout_type,
51 ];
52 }
53 }
54