| @@ -1,11 +1,10 @@ | ||
| 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 | 4 | use Elementor\Plugin; |
| 7 | 5 | use Elementor\Core\Base\App as BaseApp; |
| 6 | +use Elementor\Core\Experiments\Manager; | |
| 8 | 7 | use Elementor\Utils; |
| 9 | 8 | |
| 10 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | 10 | exit; // Exit if accessed directly. |
| @@ -39,19 +38,10 @@ | ||
| 39 | 38 | */ |
| 40 | 39 | private function enqueue_scripts() { |
| 41 | 40 | wp_enqueue_style( 'elementor-admin-top-bar-fonts', 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap', [], ELEMENTOR_VERSION ); |
| 42 | 41 | |
| 43 | - wp_enqueue_style( 'elementor-admin-top-bar', $this->get_css_assets_url( 'admin-top-bar' ), [], ELEMENTOR_VERSION ); | |
| 42 | + wp_enqueue_style( 'elementor-admin-top-bar', $this->get_css_assets_url( 'admin-top-bar', null, 'default', true ), [], ELEMENTOR_VERSION ); | |
| 44 | 43 | |
| 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 | 44 | wp_enqueue_script( 'elementor-admin-top-bar', $this->get_js_assets_url( 'admin-top-bar' ), [ |
| 55 | 45 | 'elementor-common', |
| 56 | 46 | 'react', |
| 57 | 47 | 'react-dom', |
| @@ -57,10 +47,8 @@ | ||
| 57 | 47 | 'react-dom', |
| 58 | 48 | 'tipsy', |
| 59 | 49 | ], ELEMENTOR_VERSION, true ); |
| 60 | 50 | |
| 61 | - wp_set_script_translations( 'elementor-admin-top-bar', 'elementor' ); | |
| 62 | - | |
| 63 | 51 | $min_suffix = Utils::is_script_debug() ? '' : '.min'; |
| 64 | 52 | |
| 65 | 53 | wp_enqueue_script( 'tipsy', ELEMENTOR_ASSETS_URL . 'lib/tipsy/tipsy' . $min_suffix . '.js', [ |
| 66 | 54 | 'jquery', |
| @@ -71,22 +59,8 @@ | ||
| 71 | 59 | |
| 72 | 60 | private function add_frontend_settings() { |
| 73 | 61 | $settings = []; |
| 74 | 62 | $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 | 63 | $current_screen = get_current_screen(); |
| 90 | 64 | |
| 91 | 65 | /** @var \Elementor\Core\Common\Modules\Connect\Apps\Library $library */ |
| 92 | 66 | $library = Plugin::$instance->common->get_component( 'connect' )->get_app( 'library' ); |
| @@ -107,18 +81,8 @@ | ||
| 107 | 81 | |
| 108 | 82 | do_action( 'elementor/admin-top-bar/init', $this ); |
| 109 | 83 | } |
| 110 | 84 | |
| 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 | 85 | /** |
| 122 | 86 | * Module constructor. |
| 123 | 87 | */ |
| 124 | 88 | public function __construct() { |
| @@ -123,21 +87,17 @@ | ||
| 123 | 87 | */ |
| 124 | 88 | public function __construct() { |
| 125 | 89 | parent::__construct(); |
| 126 | 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 | + | |
| 127 | 99 | add_action( 'current_screen', function () { |
| 128 | - if ( ! $this->is_top_bar_active() ) { | |
| 129 | - return; | |
| 130 | - } | |
| 131 | - | |
| 132 | 100 | $this->add_frontend_settings(); |
| 133 | - | |
| 134 | - add_action( 'in_admin_header', function () { | |
| 135 | - $this->render_admin_top_bar(); | |
| 136 | - } ); | |
| 137 | - | |
| 138 | - add_action( 'admin_enqueue_scripts', function () { | |
| 139 | - $this->enqueue_scripts(); | |
| 140 | - } ); | |
| 141 | 101 | } ); |
| 142 | 102 | } |
| 143 | 103 | } |