| @@ -1,11 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | 2 | namespace Elementor\Modules\AdminTopBar; |
| 4 | 3 | |
| 5 | 4 | use Elementor\Core\Base\App as BaseApp; |
| 6 | 5 | use Elementor\Core\Experiments\Manager; |
| 7 | -use Elementor\Plugin; | |
| 8 | 6 | use Elementor\Utils; |
| 9 | 7 | |
| 10 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | 9 | exit; // Exit if accessed directly. |
| @@ -93,17 +91,26 @@ | ||
| 93 | 91 | */ |
| 94 | 92 | public function __construct() { |
| 95 | 93 | parent::__construct(); |
| 96 | 94 | |
| 97 | - add_action( 'in_admin_header', function () { | |
| 98 | - $this->render_admin_top_bar(); | |
| 99 | - } ); | |
| 95 | + add_action( 'current_screen', function () { | |
| 96 | + $current_screen = get_current_screen(); | |
| 100 | 97 | |
| 101 | - add_action( 'admin_enqueue_scripts', function () { | |
| 102 | - $this->enqueue_scripts(); | |
| 103 | - } ); | |
| 98 | + // Only in elementor based pages. | |
| 99 | + if ( ! $current_screen || ! strstr( $current_screen->id, 'elementor' ) ) { | |
| 100 | + return; | |
| 101 | + } | |
| 104 | 102 | |
| 105 | - add_action( 'wp_dashboard_setup', function () { | |
| 106 | - $this->register_dashboard_widgets(); | |
| 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( 'wp_dashboard_setup', function () { | |
| 112 | + $this->register_dashboard_widgets(); | |
| 113 | + } ); | |
| 107 | 114 | } ); |
| 108 | 115 | } |
| 109 | 116 | } |