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