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

98 lines 2.4 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 'library_connect' => [
58 'is_connected' => $is_connected,
59 ],
60 ] );
61 }
62
63 public function library_connect_popup_seen() {
64 User::set_introduction_viewed( [
65 'introductionKey' => 'library_connect',
66 ] );
67 }
68
69 /**
70 * @param \Elementor\Core\Common\Modules\Ajax\Module $ajax_manager
71 */
72 public function register_ajax_actions( $ajax_manager ) {
73 $ajax_manager->register_ajax_action( 'library_connect_popup_seen', [ $this, 'library_connect_popup_seen' ] );
74 }
75
76 protected function get_app_info() {
77 return [
78 'user_common_data' => [
79 'label' => 'User Common Data',
80 'value' => get_user_option( $this->get_option_name(), get_current_user_id() ),
81 ],
82 'connect_site_key' => [
83 'label' => 'Site Key',
84 'value' => get_option( 'elementor_connect_site_key' ),
85 ],
86 'remote_info_library' => [
87 'label' => 'Remote Library Info',
88 'value' => get_option( 'elementor_remote_info_library' ),
89 ],
90 ];
91 }
92
93 protected function init() {
94 add_filter( 'elementor/editor/localize_settings', [ $this, 'localize_settings' ] );
95 add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
96 }
97 }
98