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(Plugin::instance()->get_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"></i>
</div>
<div class="elementor-message-content">
<h3><?php
_e('New in Elementor', 'elementor');
?>
</h3>
<p><?php
printf(__('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(__('View Elementor version %s details', 'elementor'), $product->new_version)), $product->new_version, esc_url($upgrade_url), esc_attr(__('Update Now', 'elementor')));
?>
</p>
</div>
<div class="elementor-update-now">
<a class="button elementor-button" href="<?php
echo $upgrade_url;
?>
"><i class="dashicons dashicons-update"></i><?php
_e('Update Now', 'elementor');
?>
</a>
</div>
</div>
</div>
<?php
}