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

104 lines 2.5 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 /**
23 * @return string
24 */
25 public function get_name() {
26 return 'admin-top-bar';
27 }
28
29 private function render_admin_top_bar() {
30 ?>
31 <div id="e-admin-top-bar-root">
32 </div>
33 <?php
34 }
35
36 /**
37 * Enqueue admin scripts
38 */
39 private function enqueue_scripts() {
40 wp_enqueue_style( 'elementor-admin-top-bar-fonts', 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap', [], ELEMENTOR_VERSION );
41
42 wp_enqueue_style( 'elementor-admin-top-bar', $this->get_css_assets_url( 'admin-top-bar', null, 'default', true ), [], ELEMENTOR_VERSION );
43
44 wp_enqueue_script( 'elementor-admin-top-bar', $this->get_js_assets_url( 'admin-top-bar' ), [
45 'elementor-common',
46 'react',
47 'react-dom',
48 'tipsy',
49 ], ELEMENTOR_VERSION, true );
50
51 $min_suffix = Utils::is_script_debug() ? '' : '.min';
52
53 wp_enqueue_script( 'tipsy', ELEMENTOR_ASSETS_URL . 'lib/tipsy/tipsy' . $min_suffix . '.js', [
54 'jquery',
55 ], '1.0.0', true );
56
57 $this->print_config();
58 }
59
60 private function add_frontend_settings() {
61 $settings = [];
62 $settings['is_administrator'] = current_user_can( 'manage_options' );
63 $current_screen = get_current_screen();
64
65 /** @var \Elementor\Core\Common\Modules\Connect\Apps\Library $library */
66 $library = Plugin::$instance->common->get_component( 'connect' )->get_app( 'library' );
67 if ( $library ) {
68 $settings = array_merge( $settings, [
69 'is_user_connected' => $library->is_connected(),
70 'connect_url' => $library->get_admin_url( 'authorize', [
71 'utm_source' => 'top-bar',
72 'utm_medium' => 'wp-dash',
73 'utm_campaign' => 'connect-account',
74 'utm_content' => $current_screen->id,
75 'source' => 'generic',
76 ] ),
77 ] );
78 }
79
80 $this->set_settings( $settings );
81
82 do_action( 'elementor/admin-top-bar/init', $this );
83 }
84
85 /**
86 * Module constructor.
87 */
88 public function __construct() {
89 parent::__construct();
90
91 add_action( 'in_admin_header', function () {
92 $this->render_admin_top_bar();
93 } );
94
95 add_action( 'admin_enqueue_scripts', function () {
96 $this->enqueue_scripts();
97 } );
98
99 add_action( 'current_screen', function () {
100 $this->add_frontend_settings();
101 } );
102 }
103 }
104