PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.3
Elementor Website Builder – more than just a page builder v3.0.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.0.3, at core/common/modules/connect/apps/library.php

104 lines 2.7 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
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly
8 }
9
10 class Library extends Common_App {
11 public function get_title() {
12 return __( 'Library', 'elementor' );
13 }
14
15 /**
16 * @since 2.3.0
17 * @access protected
18 */
19 protected function get_slug() {
20 return 'library';
21 }
22
23 public function get_template_content( $id ) {
24 if ( ! $this->is_connected() ) {
25 return new \WP_Error( '401', __( 'Connecting to the Library failed. Please try reloading the page and try again', 'elementor' ) );
26 }
27
28 $body_args = [
29 'id' => $id,
30
31 // Which API version is used.
32 'api_version' => ELEMENTOR_VERSION,
33 // Which language to return.
34 'site_lang' => get_bloginfo( 'language' ),
35 ];
36
37 /**
38 * API: Template body args.
39 *
40 * Filters the body arguments send with the GET request when fetching the content.
41 *
42 * @since 1.0.0
43 *
44 * @param array $body_args Body arguments.
45 */
46 $body_args = apply_filters( 'elementor/api/get_templates/body_args', $body_args );
47
48 $template_content = $this->request( 'get_template_content', $body_args, true );
49
50 return $template_content;
51 }
52
53 public function localize_settings( $settings ) {
54 $is_connected = $this->is_connected();
55
56 return array_replace_recursive( $settings, [
57 'i18n' => [
58 // Route: library/connect
59 'library/connect:title' => __( 'Connect to Template Library', 'elementor' ),
60 'library/connect:message' => __( 'Access this template and our entire library by creating a free personal account', 'elementor' ),
61 'library/connect:button' => __( 'Get Started', 'elementor' ),
62 ],
63 'library_connect' => [
64 'is_connected' => $is_connected,
65 ],
66 ] );
67 }
68
69 public function library_connect_popup_seen() {
70 User::set_introduction_viewed( [
71 'introductionKey' => 'library_connect',
72 ] );
73 }
74
75 /**
76 * @param \Elementor\Core\Common\Modules\Ajax\Module $ajax_manager
77 */
78 public function register_ajax_actions( $ajax_manager ) {
79 $ajax_manager->register_ajax_action( 'library_connect_popup_seen', [ $this, 'library_connect_popup_seen' ] );
80 }
81
82 protected function get_app_info() {
83 return [
84 'user_common_data' => [
85 'label' => 'User Common Data',
86 'value' => get_user_option( $this->get_option_name(), get_current_user_id() ),
87 ],
88 'connect_site_key' => [
89 'label' => 'Site Key',
90 'value' => get_option( 'elementor_connect_site_key' ),
91 ],
92 'remote_info_library' => [
93 'label' => 'Remote Library Info',
94 'value' => get_option( 'elementor_remote_info_library' ),
95 ],
96 ];
97 }
98
99 protected function init() {
100 add_filter( 'elementor/editor/localize_settings', [ $this, 'localize_settings' ] );
101 add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
102 }
103 }
104