PluginProbe
Elementor Website Builder – more than just a page builder / 3.7.8
Elementor Website Builder – more than just a page builder v3.7.8
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 / modules / admin-top-bar / module.php

module.php in Elementor Website Builder – more than just a page builder 3.7.8, at modules/admin-top-bar/module.php

116 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\Modules\AdminTopBar;
3
4 use Elementor\Plugin;
5 use Elementor\Core\Base\App as BaseApp;
6 use Elementor\Core\Experiments\Manager;
7 use Elementor\Utils;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 class Module extends BaseApp {
14
15 /**
16 * @return bool
17 */
18 public static function is_active() {
19 return is_admin();
20 }
21
22 public static function get_experimental_data() {
23 return [
24 'name' => 'admin-top-bar',
25 'title' => esc_html__( 'Admin Top Bar', 'elementor' ),
26 'description' => esc_html__( 'Adds a top bar to elementors pages in admin area.', 'elementor' ),
27 'release_status' => Manager::RELEASE_STATUS_STABLE,
28 'new_site' => [
29 'default_active' => true,
30 ],
31 ];
32 }
33
34 /**
35 * @return string
36 */
37 public function get_name() {
38 return 'admin-top-bar';
39 }
40
41 private function render_admin_top_bar() {
42 ?>
43 <div id="e-admin-top-bar-root">
44 </div>
45 <?php
46 }
47
48 /**
49 * Enqueue admin scripts
50 */
51 private function enqueue_scripts() {
52 wp_enqueue_style( 'elementor-admin-top-bar-fonts', 'https://fonts.googleapis.com/css2?family=Roboto&display=swap', [], ELEMENTOR_VERSION );
53
54 wp_enqueue_style( 'elementor-admin-top-bar', $this->get_css_assets_url( 'admin-top-bar', null, 'default', true ), [], ELEMENTOR_VERSION );
55
56 wp_enqueue_script( 'elementor-admin-top-bar', $this->get_js_assets_url( 'admin-top-bar' ), [
57 'elementor-common',
58 'react',
59 'react-dom',
60 'tipsy',
61 ], ELEMENTOR_VERSION, true );
62
63 $min_suffix = Utils::is_script_debug() ? '' : '.min';
64
65 wp_enqueue_script( 'tipsy', ELEMENTOR_ASSETS_URL . 'lib/tipsy/tipsy' . $min_suffix . '.js', [
66 'jquery',
67 ], '1.0.0', true );
68
69 $this->print_config();
70 }
71
72 private function add_frontend_settings() {
73 $settings = [];
74 $settings['is_administrator'] = current_user_can( 'manage_options' );
75 $current_screen = get_current_screen();
76
77 /** @var \Elementor\Core\Common\Modules\Connect\Apps\Library $library */
78 $library = Plugin::$instance->common->get_component( 'connect' )->get_app( 'library' );
79 if ( $library ) {
80 $settings = array_merge( $settings, [
81 'is_user_connected' => $library->is_connected(),
82 'connect_url' => $library->get_admin_url( 'authorize', [
83 'utm_source' => 'top-bar',
84 'utm_medium' => 'wp-dash',
85 'utm_campaign' => 'connect-account',
86 'utm_content' => $current_screen->id,
87 'source' => 'generic',
88 ] ),
89 ] );
90 }
91
92 $this->set_settings( $settings );
93
94 do_action( 'elementor/admin-top-bar/init', $this );
95 }
96
97 /**
98 * Module constructor.
99 */
100 public function __construct() {
101 parent::__construct();
102
103 add_action( 'in_admin_header', function () {
104 $this->render_admin_top_bar();
105 } );
106
107 add_action( 'admin_enqueue_scripts', function () {
108 $this->enqueue_scripts();
109 } );
110
111 add_action( 'current_screen', function () {
112 $this->add_frontend_settings();
113 } );
114 }
115 }
116