Admin::admin_notices()
Admin notices.
Description
Add Elementor notices to WordPress admin screen.
Fired by admin_notices
action.
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |
Source
includes/admin.php
public function admin_notices() { $upgrade_notice = Api::get_upgrade_notice(); if ( empty( $upgrade_notice ) ) { return; } if ( ! current_user_can( 'update_plugins' ) ) { return; } if ( ! in_array( get_current_screen()->id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ] ) ) { return; } // Check if have any upgrades. $update_plugins = get_site_transient( 'update_plugins' ); if ( empty( $update_plugins ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ] ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ]->package ) ) { return; } $product = $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ]; // Check if have upgrade notices to show. if ( version_compare( ELEMENTOR_VERSION, $upgrade_notice['version'], '>=' ) ) { return; } $notice_id = 'upgrade_notice_' . $upgrade_notice['version']; if ( User::is_user_notice_viewed( $notice_id ) ) { return; } $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 ); ?> <div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>"> <div class="elementor-message-inner"> <div class="elementor-message-icon"> <i class="eicon-elementor-square" aria-hidden="true"></i> </div> <div class="elementor-message-content"> <strong><?php echo __( 'Update Notification', 'elementor' ); ?></strong> <p> <?php printf( /* 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' ), esc_url( $details_url ), esc_attr( sprintf( /* translators: %s: Elementor version */ __( 'View Elementor version %s details', 'elementor' ), $product->new_version ) ), $product->new_version, esc_url( $upgrade_url ), esc_attr( __( 'Update Elementor Now', 'elementor' ) ) ); ?> </p> </div> <div class="elementor-message-action"> <a class="button elementor-button" href="<?php echo $upgrade_url; ?>"> <i class="dashicons dashicons-update" aria-hidden="true"></i> <?php echo __( 'Update Now', 'elementor' ); ?> </a> </div> </div> </div> <?php }