namespace Elementor\Core\Admin;
use Elementor\Core\Admin\UI\Components\Button;
use Elementor\Core\Base\Module;
use Elementor\Core\Upgrade\Manager;
use Elementor\Core\Utils\Hints;
use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
use Elementor\Core\Admin\Notices\Base_Notice;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
class Admin_Notices extends Module {
const DEFAULT_EXCLUDED_PAGES = [ 'plugins.php', 'plugin-install.php', 'plugin-editor.php' ];
const LOCAL_GOOGLE_FONTS_DISABLED_NOTICE_ID = 'local_google_fonts_disabled';
const LOCAL_GOOGLE_FONTS_NOTICE_MIN_VERSION = '3.33.3';
const EXIT_EARLY_FOR_BACKWARD_COMPATIBILITY = false;
private $plain_notices = [
'plugin_image_optimization',
self::LOCAL_GOOGLE_FONTS_DISABLED_NOTICE_ID,
private $elementor_pages_count = null;
private $install_time = null;
private $current_screen_id = null;
private function get_notices() {
* Filters Elementor admin notices.
* This hook can be used by external developers to manage existing
* admin notice or to add new notices for Elementor add-ons.
* @param array $notices A list of notice classes.
$notices = apply_filters( 'elementor/core/admin/notices', [] );
private function get_install_time() {
if ( null === $this->install_time ) {
$this->install_time = Plugin::$instance->get_install_time();
return $this->install_time;
private function get_elementor_pages_count() {
if ( null === $this->elementor_pages_count ) {
$elementor_pages = new \WP_Query( [
'post_status' => 'publish',
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'meta_key' => '_elementor_edit_mode',
'meta_value' => 'builder',
$this->elementor_pages_count = $elementor_pages->post_count;
return $this->elementor_pages_count;
private function notice_api_upgrade_plugin() {
$upgrade_notice = Api::get_upgrade_notice();
if ( empty( $upgrade_notice ) ) {
if ( ! current_user_can( 'update_plugins' ) ) {
if ( ! $this->is_elementor_admin_screen_with_system_info() ) {
$update_plugins = get_site_transient( 'update_plugins' );
$has_remote_update_package = ! ( empty( $update_plugins ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ] ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ]->package ) );
if ( ! $has_remote_update_package && empty( $upgrade_notice['update_link'] ) ) {
if ( $has_remote_update_package ) {
$product = $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ];
$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $product->slug . '§ion=changelog&TB_iframe=true&width=600&height=800' );
$upgrade_url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . ELEMENTOR_PLUGIN_BASE ), 'upgrade-plugin_' . ELEMENTOR_PLUGIN_BASE );
$new_version = $product->new_version;
$upgrade_url = $upgrade_notice['update_link'];
$details_url = $upgrade_url;
$new_version = $upgrade_notice['version'];
// Check if upgrade messages should be shown.
if ( version_compare( ELEMENTOR_VERSION, $upgrade_notice['version'], '>=' ) ) {
$notice_id = 'upgrade_notice_' . $upgrade_notice['version'];
if ( User::is_user_notice_viewed( $notice_id ) ) {
/* translators: 1: Details URL, 2: Accessibility text, 3: Version number, 4: Update URL, 5: Accessibility text. */
__( 'There is a new version of Elementor Page Builder available. <a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">View version %3$s details</a> or <a href="%4$s" class="update-link" aria-label="%5$s">update now</a>.', 'elementor' ),
/* translators: %s: Elementor version. */
esc_attr__( 'View Elementor version %s details', 'elementor' ),
esc_attr__( 'Update Now', 'elementor' )
'title' => esc_html__( 'Update Notification', 'elementor' ),
'description' => $message,
'icon_classes' => 'dashicons dashicons-update',
'text' => esc_html__( 'Update Now', 'elementor' ),
$this->print_admin_notice( $options );
private function notice_api_notice() {
$admin_notice = Api::get_admin_notice();
if ( empty( $admin_notice ) ) {
if ( ! current_user_can( 'manage_options' ) ) {
if ( ! $this->is_elementor_admin_screen_with_system_info() ) {
$notice_id = 'admin_notice_api_' . $admin_notice['notice_id'];
if ( User::is_user_notice_viewed( $notice_id ) ) {
'title' => esc_html__( 'Update Notification', 'elementor' ),
'description' => $admin_notice['notice_text'],
$this->print_admin_notice( $options );
private function notice_tracker() {
if ( ! current_user_can( 'manage_options' ) ) {
// Show tracker notice after 24 hours from installed time.
if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) {
if ( '1' === get_option( 'elementor_tracker_notice' ) ) {
if ( Tracker::is_allow_track() ) {
if ( 2 > $this->get_elementor_pages_count() ) {
// TODO: Skip for development env.
$optin_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_into' ), 'opt_into' );
$optout_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_out' ), 'opt_out' );
$tracker_description_text = esc_html__( 'Become a super contributor by helping us understand how you use our service to enhance your experience and improve our product.', 'elementor' );
* Tracker admin description text.
* Filters the admin notice text for non-sensitive data collection.
* @param string $tracker_description_text Description text displayed in admin notice.
$tracker_description_text = apply_filters( 'elementor/tracker/admin_description_text', $tracker_description_text );
$message = esc_html( $tracker_description_text ) . ' <a href="https://go.elementor.com/usage-data-tracking/" target="_blank">' . esc_html__( 'Learn more.', 'elementor' ) . '</a>';
'title' => esc_html__( 'Want to shape the future of web creation?', 'elementor' ),
'description' => $message,
'text' => esc_html__( 'Sure! I\'d love to help', 'elementor' ),
'text' => esc_html__( 'No thanks', 'elementor' ),
$this->print_admin_notice( $options );
private function notice_tracker_last_update() {
if ( ! current_user_can( 'manage_options' ) ) {
if ( ! Tracker::has_terms_changed() ) {
$notice_id = 'tracker_last_update_' . Tracker::LAST_TERMS_UPDATED;
if ( User::is_user_notice_viewed( $notice_id ) ) {
$optin_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_into' ), 'opt_into' );
$message = esc_html__( 'We\'re updating our Terms and Conditions to include the collection of usage and behavioral data. This information helps us understand how you use Elementor so we can make informed improvements to the product.', 'elementor' );
'title' => esc_html__( 'Update regarding usage data collection', 'elementor' ),
'description' => $message,
'text' => esc_html__( 'Opt in', 'elementor' ),
'text' => esc_html__( 'Learn more', 'elementor' ),
'url' => 'https://go.elementor.com/wp-dash-update-usage-notice/',
$this->print_admin_notice( $options );
private function notice_rate_us_feedback() {
$notice_id = 'rate_us_feedback';
if ( ! current_user_can( 'manage_options' ) ) {
if ( 'dashboard' !== $this->current_screen_id || User::is_user_notice_viewed( $notice_id ) ) {
if ( 10 >= $this->get_elementor_pages_count() ) {
$dismiss_url = add_query_arg( [
'action' => 'elementor_set_admin_notice_viewed',
'notice_id' => esc_attr( $notice_id ),
'_wpnonce' => wp_create_nonce( 'elementor_set_admin_notice_viewed' ),
], admin_url( 'admin-post.php' ) );
'title' => esc_html__( 'Congrats!', 'elementor' ),
'description' => esc_html__( 'You created over 10 pages with Elementor. Great job! If you can spare a minute, please help us by leaving a five star review on WordPress.org.', 'elementor' ),
'text' => esc_html__( 'Happy To Help', 'elementor' ),
'url' => 'https://go.elementor.com/admin-review/',
'text' => esc_html__( 'Hide Notification', 'elementor' ),
'classes' => [ 'e-notice-dismiss' ],
'url' => esc_url_raw( $dismiss_url ),
$this->print_admin_notice( $options );
private function notice_role_manager_promote() {
$notice_id = 'role_manager_promote';
if ( Utils::has_pro() ) {
if ( ! current_user_can( 'manage_options' ) ) {
if ( 'elementor_page_elementor-role-manager' !== $this->current_screen_id || User::is_user_notice_viewed( $notice_id ) ) {
$users = new \WP_User_Query( [
if ( 5 > $users->get_total() ) {
'title' => esc_html__( 'Managing a multi-user site?', 'elementor' ),
'description' => esc_html__( 'With Elementor Pro, you can control user access and make sure no one messes up your design.', 'elementor' ),
'text' => esc_html__( 'Learn More', 'elementor' ),
'url' => 'https://go.elementor.com/plugin-promotion-role-manager/',
$options = Filtered_Promotions_Manager::get_filtered_promotion_data( $options, 'core/admin/notice_role_manager_promote', 'button', 'url' );
$this->print_admin_notice( $options );
private function notice_experiment_promotion() {
$notice_id = 'experiment_promotion';
if ( ! current_user_can( 'manage_options' ) || User::is_user_notice_viewed( $notice_id ) ) {
$experiments = Plugin::$instance->experiments;
$is_all_performance_features_active = (
$experiments->is_feature_active( 'e_font_icon_svg' ) &&
$experiments->is_feature_active( 'e_optimized_markup' )
if ( $is_all_performance_features_active ) {
'title' => esc_html__( 'Improve your site’s performance score.', 'elementor' ),
'description' => esc_html__( 'With our experimental speed boosting features you can go faster than ever before. Look for the Performance label on our Experiments page and activate those experiments to improve your site loading speed.', 'elementor' ),
'text' => esc_html__( 'Try it out', 'elementor' ),
'url' => Settings::get_settings_tab_url( 'experiments' ),
'text' => esc_html__( 'Learn more', 'elementor' ),
'url' => 'https://go.elementor.com/wp-dash-experiment-promotion/',
$this->print_admin_notice( $options );
private function site_has_forms_plugins() {
return defined( 'WPFORMS_VERSION' ) || defined( 'WPCF7_VERSION' ) || defined( 'FLUENTFORM_VERSION' ) || class_exists( '\GFCommon' ) || class_exists( '\Ninja_Forms' ) || function_exists( 'load_formidable_forms' ) || did_action( 'metform/after_load' ) || defined( 'FORMINATOR_PLUGIN_BASENAME' );
private function site_has_woocommerce() {
return class_exists( 'WooCommerce' );
private function get_installed_form_plugin_name() {
static $detected_form_plugin = null;
if ( null !== $detected_form_plugin ) {
return $detected_form_plugin;
$form_plugins_constants_to_name_mapper = [
'WPFORMS_VERSION' => 'WPForms',
'WPCF7_VERSION' => 'Contact Form 7',
foreach ( $form_plugins_constants_to_name_mapper as $constant => $name ) {
if ( defined( $constant ) ) {
$detected_form_plugin = $name;
return $detected_form_plugin;
$form_plugins_classes_to_name_mapper = [
'\GFCommon' => 'Gravity Forms',
'\Ninja_Forms' => 'Ninja Forms',
foreach ( $form_plugins_classes_to_name_mapper as $class => $name ) {
if ( class_exists( $class ) ) {
$detected_form_plugin = $name;
return $detected_form_plugin;
$detected_form_plugin = false;
return $detected_form_plugin;
private function notice_local_google_fonts_disabled() {
if ( ! $this->is_elementor_page() && ! $this->is_elementor_admin_screen() ) {
if ( ! Manager::had_install_prior_to( self::LOCAL_GOOGLE_FONTS_NOTICE_MIN_VERSION ) ) {
if ( User::is_user_notice_viewed( self::LOCAL_GOOGLE_FONTS_DISABLED_NOTICE_ID ) ) {
$is_local_gf_enabled = (bool) get_option( 'elementor_local_google_fonts', '0' );
if ( $is_local_gf_enabled ) {
'title' => esc_html__( 'Important: Local Google Fonts Settings in Elementor', 'elementor' ),
'description' => esc_html__( 'Please note: The "Load Google Fonts Locally" feature has been disabled by default on all websites. To turn it back on, go to Elementor → Settings → Performance → Enable Load Google Fonts Locally.', 'elementor' ),
'id' => self::LOCAL_GOOGLE_FONTS_DISABLED_NOTICE_ID,
'text' => esc_html__( 'Take me there', 'elementor' ),
'url' => '../wp-admin/admin.php?page=elementor-settings#tab-performance',