Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/elementor/modules/admin-top-bar/module.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
namespace Elementor\Modules\AdminTopBar;
3
+
4
+
use Elementor\Core\Admin\Admin;
5
+
use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
6
+
use Elementor\Plugin;
7
+
use Elementor\Core\Base\App as BaseApp;
8
+
use Elementor\Core\Experiments\Manager;
9
+
use Elementor\Utils;
10
+
11
+
if ( ! defined( 'ABSPATH' ) ) {
12
+
exit; // Exit if accessed directly.
13
+
}
14
+
15
+
class Module extends BaseApp {
16
+
17
+
/**
18
+
* @return bool
19
+
*/
20
+
public static function is_active() {
21
+
return is_admin();
22
+
}
23
+
24
+
/**
25
+
* @return string
26
+
*/
27
+
public function get_name() {
28
+
return 'admin-top-bar';
29
+
}
30
+
31
+
private function render_admin_top_bar() {
32
+
?>
33
+
<div id="e-admin-top-bar-root">
34
+
</div>
35
+
<?php
36
+
}
37
+
38
+
/**
39
+
* Enqueue admin scripts
40
+
*/
41
+
private function enqueue_scripts() {
42
+
wp_enqueue_style( 'elementor-admin-top-bar-fonts', 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap', [], ELEMENTOR_VERSION );
43
+
44
+
wp_enqueue_style( 'elementor-admin-top-bar', $this->get_css_assets_url( 'admin-top-bar' ), [], ELEMENTOR_VERSION );
45
+
46
+
/**
47
+
* Before admin top bar enqueue scripts.
48
+
*
49
+
* Fires before Elementor admin top bar scripts are enqueued.
50
+
*
51
+
* @since 3.19.0
52
+
*/
53
+
do_action( 'elementor/admin_top_bar/before_enqueue_scripts', $this );
54
+
55
+
wp_enqueue_script( 'elementor-admin-top-bar', $this->get_js_assets_url( 'admin-top-bar' ), [
56
+
'elementor-common',
57
+
'react',
58
+
'react-dom',
59
+
'tipsy',
60
+
], ELEMENTOR_VERSION, true );
61
+
62
+
wp_set_script_translations( 'elementor-admin-top-bar', 'elementor' );
63
+
64
+
$min_suffix = Utils::is_script_debug() ? '' : '.min';
65
+
66
+
wp_enqueue_script( 'tipsy', ELEMENTOR_ASSETS_URL . 'lib/tipsy/tipsy' . $min_suffix . '.js', [
67
+
'jquery',
68
+
], '1.0.0', true );
69
+
70
+
$this->print_config();
71
+
}
72
+
73
+
private function add_frontend_settings() {
74
+
$settings = [];
75
+
$settings['is_administrator'] = current_user_can( 'manage_options' );
76
+
77
+
// TODO: Find a better way to add apps page url to the admin top bar.
78
+
$settings['apps_url'] = admin_url( 'admin.php?page=elementor-apps' );
79
+
$settings['promotion'] = [
80
+
'text' => __( 'Upgrade Now', 'elementor' ),
81
+
'url' => 'https://go.elementor.com/wp-dash-admin-top-bar-upgrade/',
82
+
];
83
+
84
+
$settings['promotion'] = Filtered_Promotions_Manager::get_filtered_promotion_data(
85
+
$settings['promotion'],
86
+
'elementor/admin_top_bar/go_pro_promotion',
87
+
'url'
88
+
);
89
+
90
+
$current_screen = get_current_screen();
91
+
92
+
/** @var \Elementor\Core\Common\Modules\Connect\Apps\Library $library */
93
+
$library = Plugin::$instance->common->get_component( 'connect' )->get_app( 'library' );
94
+
if ( $library ) {
95
+
$settings = array_merge( $settings, [
96
+
'is_user_connected' => $library->is_connected(),
97
+
'connect_url' => $library->get_admin_url( 'authorize', [
98
+
'utm_source' => 'top-bar',
99
+
'utm_medium' => 'wp-dash',
100
+
'utm_campaign' => 'connect-account',
101
+
'utm_content' => $current_screen->id,
102
+
'source' => 'generic',
103
+
] ),
104
+
] );
105
+
}
106
+
107
+
$this->set_settings( $settings );
108
+
109
+
do_action( 'elementor/admin-top-bar/init', $this );
110
+
}
111
+
112
+
private function is_top_bar_active() {
113
+
$current_screen = get_current_screen();
114
+
115
+
return apply_filters(
116
+
'elementor/admin-top-bar/is-active',
117
+
Admin::is_elementor_admin_page( $current_screen ),
118
+
$current_screen
119
+
);
120
+
}
121
+
122
+
/**
123
+
* Module constructor.
124
+
*/
125
+
public function __construct() {
126
+
parent::__construct();
127
+
128
+
add_action( 'current_screen', function () {
129
+
if ( ! $this->is_top_bar_active() ) {
130
+
return;
131
+
}
132
+
133
+
$this->add_frontend_settings();
134
+
135
+
add_action( 'in_admin_header', function () {
136
+
$this->render_admin_top_bar();
137
+
} );
138
+
139
+
add_action( 'admin_enqueue_scripts', function () {
140
+
$this->enqueue_scripts();
141
+
} );
142
+
} );
143
+
}
144
+
}
145
+