PluginProbe
Elementor Website Builder – more than just a page builder / 3.2.3
Elementor Website Builder – more than just a page builder v3.2.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / core / common / modules / connect / apps / library.php

library.php in Elementor Website Builder – more than just a page builder 3.2.3, at core/common/modules/connect/apps/library.php

106 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Common\Modules\Connect\Apps;
3
4 use Elementor\User;
5 use Elementor\Plugin;
6 use Elementor\Core\Common\Modules\Connect\Module as ConnectModule;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly
10 }
11
12 class Library extends Common_App {
13 public function get_title() {
14 return __( 'Library', 'elementor' );
15 }
16
17 /**
18 * @since 2.3.0
19 * @access protected
20 */
21 protected function get_slug() {
22 return 'library';
23 }
24
25 public function get_template_content( $id ) {
26 if ( ! $this->is_connected() ) {
27 return new \WP_Error( '401', __( 'Connecting to the Library failed. Please try reloading the page and try again', 'elementor' ) );
28 }
29
30 $body_args = [
31 'id' => $id,
32
33 // Which API version is used.
34 'api_version' => ELEMENTOR_VERSION,
35 // Which language to return.
36 'site_lang' => get_bloginfo( 'language' ),
37 ];
38
39 /**
40 * API: Template body args.
41 *
42 * Filters the body arguments send with the GET request when fetching the content.
43 *
44 * @since 1.0.0
45 *
46 * @param array $body_args Body arguments.
47 */
48 $body_args = apply_filters( 'elementor/api/get_templates/body_args', $body_args );
49
50 $template_content = $this->request( 'get_template_content', $body_args, true );
51
52 return $template_content;
53 }
54
55 public function localize_settings( $settings ) {
56 $is_connected = $this->is_connected();
57
58 /** @var ConnectModule $connect */
59 $connect = Plugin::$instance->common->get_component( 'connect' );
60
61 return array_replace_recursive( $settings, [
62 'library_connect' => [
63 'is_connected' => $is_connected,
64 'subscription_plans' => $connect->get_subscription_plans( 'panel-library' ),
65 'base_access_level' => ConnectModule::ACCESS_LEVEL_CORE,
66 'current_access_level' => ConnectModule::ACCESS_LEVEL_CORE,
67 ],
68 ] );
69 }
70
71 public function library_connect_popup_seen() {
72 User::set_introduction_viewed( [
73 'introductionKey' => 'library_connect',
74 ] );
75 }
76
77 /**
78 * @param \Elementor\Core\Common\Modules\Ajax\Module $ajax_manager
79 */
80 public function register_ajax_actions( $ajax_manager ) {
81 $ajax_manager->register_ajax_action( 'library_connect_popup_seen', [ $this, 'library_connect_popup_seen' ] );
82 }
83
84 protected function get_app_info() {
85 return [
86 'user_common_data' => [
87 'label' => 'User Common Data',
88 'value' => get_user_option( $this->get_option_name(), get_current_user_id() ),
89 ],
90 'connect_site_key' => [
91 'label' => 'Site Key',
92 'value' => get_option( 'elementor_connect_site_key' ),
93 ],
94 'remote_info_library' => [
95 'label' => 'Remote Library Info',
96 'value' => get_option( 'elementor_remote_info_library' ),
97 ],
98 ];
99 }
100
101 protected function init() {
102 add_filter( 'elementor/editor/localize_settings', [ $this, 'localize_settings' ] );
103 add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
104 }
105 }
106