| 1 |
<?php |
| 2 |
namespace Elementor\Core\Admin; |
| 3 |
|
| 4 |
use Elementor\Api; |
| 5 |
use Elementor\Core\Base\Module; |
| 6 |
use Elementor\Plugin; |
| 7 |
use Elementor\Tracker; |
| 8 |
use Elementor\User; |
| 9 |
use Elementor\Utils; |
| 10 |
use Elementor\Core\Admin\Notices\Base_Notice; |
| 11 |
use Elementor\Core\Admin\Notices\Elementor_Dev_Notice; |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; // Exit if accessed directly. |
| 15 |
} |
| 16 |
|
| 17 |
class Admin_Notices extends Module { |
| 18 |
|
| 19 |
private $plain_notices = [ |
| 20 |
'api_notice', |
| 21 |
'api_upgrade_plugin', |
| 22 |
'tracker', |
| 23 |
'rate_us_feedback', |
| 24 |
'woocommerce_promote', |
| 25 |
'cf7_promote', |
| 26 |
'mc4wp_promote', |
| 27 |
'popup_maker_promote', |
| 28 |
'role_manager_promote', |
| 29 |
]; |
| 30 |
|
| 31 |
private $elementor_pages_count = null; |
| 32 |
|
| 33 |
private $install_time = null; |
| 34 |
|
| 35 |
private $current_screen_id = null; |
| 36 |
|
| 37 |
private function get_notices() { |
| 38 |
$notices = [ |
| 39 |
new Elementor_Dev_Notice(), |
| 40 |
]; |
| 41 |
|
| 42 |
return apply_filters( 'elementor/core/admin/notices', $notices ); |
| 43 |
} |
| 44 |
|
| 45 |
private function get_install_time() { |
| 46 |
if ( null === $this->install_time ) { |
| 47 |
$this->install_time = Plugin::$instance->get_install_time(); |
| 48 |
} |
| 49 |
|
| 50 |
return $this->install_time; |
| 51 |
} |
| 52 |
|
| 53 |
private function get_elementor_pages_count() { |
| 54 |
if ( null === $this->elementor_pages_count ) { |
| 55 |
$elementor_pages = new \WP_Query( [ |
| 56 |
'post_type' => 'any', |
| 57 |
'post_status' => 'publish', |
| 58 |
'fields' => 'ids', |
| 59 |
'update_post_meta_cache' => false, |
| 60 |
'update_post_term_cache' => false, |
| 61 |
'meta_key' => '_elementor_edit_mode', |
| 62 |
'meta_value' => 'builder', |
| 63 |
] ); |
| 64 |
|
| 65 |
$this->elementor_pages_count = $elementor_pages->post_count; |
| 66 |
} |
| 67 |
|
| 68 |
return $this->elementor_pages_count; |
| 69 |
} |
| 70 |
|
| 71 |
private function notice_api_upgrade_plugin() { |
| 72 |
$upgrade_notice = Api::get_upgrade_notice(); |
| 73 |
if ( empty( $upgrade_notice ) ) { |
| 74 |
return false; |
| 75 |
} |
| 76 |
|
| 77 |
if ( ! current_user_can( 'update_plugins' ) ) { |
| 78 |
return false; |
| 79 |
} |
| 80 |
|
| 81 |
if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ) ) { |
| 82 |
return false; |
| 83 |
} |
| 84 |
|
| 85 |
// Check if have any upgrades. |
| 86 |
$update_plugins = get_site_transient( 'update_plugins' ); |
| 87 |
|
| 88 |
$has_remote_update_package = ! ( empty( $update_plugins ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ] ) || empty( $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ]->package ) ); |
| 89 |
|
| 90 |
if ( ! $has_remote_update_package && empty( $upgrade_notice['update_link'] ) ) { |
| 91 |
return false; |
| 92 |
} |
| 93 |
|
| 94 |
if ( $has_remote_update_package ) { |
| 95 |
$product = $update_plugins->response[ ELEMENTOR_PLUGIN_BASE ]; |
| 96 |
|
| 97 |
$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $product->slug . '§ion=changelog&TB_iframe=true&width=600&height=800' ); |
| 98 |
$upgrade_url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . ELEMENTOR_PLUGIN_BASE ), 'upgrade-plugin_' . ELEMENTOR_PLUGIN_BASE ); |
| 99 |
$new_version = $product->new_version; |
| 100 |
} else { |
| 101 |
$upgrade_url = $upgrade_notice['update_link']; |
| 102 |
$details_url = $upgrade_url; |
| 103 |
|
| 104 |
$new_version = $upgrade_notice['version']; |
| 105 |
} |
| 106 |
|
| 107 |
// Check if have upgrade notices to show. |
| 108 |
if ( version_compare( ELEMENTOR_VERSION, $upgrade_notice['version'], '>=' ) ) { |
| 109 |
return false; |
| 110 |
} |
| 111 |
|
| 112 |
$notice_id = 'upgrade_notice_' . $upgrade_notice['version']; |
| 113 |
if ( User::is_user_notice_viewed( $notice_id ) ) { |
| 114 |
return false; |
| 115 |
} |
| 116 |
?> |
| 117 |
<div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>"> |
| 118 |
<div class="elementor-message-inner"> |
| 119 |
<div class="elementor-message-icon"> |
| 120 |
<div class="e-logo-wrapper"> |
| 121 |
<i class="eicon-elementor" aria-hidden="true"></i> |
| 122 |
</div> |
| 123 |
</div> |
| 124 |
<div class="elementor-message-content"> |
| 125 |
<strong><?php echo __( 'Update Notification', 'elementor' ); ?></strong> |
| 126 |
<p> |
| 127 |
<?php |
| 128 |
printf( |
| 129 |
/* translators: 1: Details URL, 2: Accessibility text, 3: Version number, 4: Update URL, 5: Accessibility text */ |
| 130 |
__( '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' ), |
| 131 |
esc_url( $details_url ), |
| 132 |
esc_attr( sprintf( |
| 133 |
/* translators: %s: Elementor version */ |
| 134 |
__( 'View Elementor version %s details', 'elementor' ), |
| 135 |
$new_version |
| 136 |
) ), |
| 137 |
$new_version, |
| 138 |
esc_url( $upgrade_url ), |
| 139 |
esc_attr( __( 'Update Elementor Now', 'elementor' ) ) |
| 140 |
); |
| 141 |
?> |
| 142 |
</p> |
| 143 |
</div> |
| 144 |
<div class="elementor-message-action"> |
| 145 |
<a class="button elementor-button" href="<?php echo $upgrade_url; ?>"> |
| 146 |
<i class="dashicons dashicons-update" aria-hidden="true"></i> |
| 147 |
<?php echo __( 'Update Now', 'elementor' ); ?> |
| 148 |
</a> |
| 149 |
</div> |
| 150 |
</div> |
| 151 |
</div> |
| 152 |
<?php |
| 153 |
|
| 154 |
return true; |
| 155 |
} |
| 156 |
|
| 157 |
private function notice_api_notice() { |
| 158 |
$admin_notice = Api::get_admin_notice(); |
| 159 |
if ( empty( $admin_notice ) ) { |
| 160 |
return false; |
| 161 |
} |
| 162 |
|
| 163 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 164 |
return false; |
| 165 |
} |
| 166 |
|
| 167 |
if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_elementor', 'edit-elementor_library', 'elementor_page_elementor-system-info', 'dashboard' ], true ) ) { |
| 168 |
return false; |
| 169 |
} |
| 170 |
|
| 171 |
$notice_id = 'admin_notice_api_' . $admin_notice['notice_id']; |
| 172 |
if ( User::is_user_notice_viewed( $notice_id ) ) { |
| 173 |
return false; |
| 174 |
} |
| 175 |
?> |
| 176 |
<div class="notice is-dismissible updated elementor-message-dismissed elementor-message-announcement" data-notice_id="<?php echo esc_attr( $notice_id ); ?>"> |
| 177 |
<p><?php echo $admin_notice['notice_text']; ?></p> |
| 178 |
</div> |
| 179 |
<?php |
| 180 |
|
| 181 |
return true; |
| 182 |
} |
| 183 |
|
| 184 |
private function notice_tracker() { |
| 185 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 186 |
return false; |
| 187 |
} |
| 188 |
|
| 189 |
// Show tracker notice after 24 hours from installed time. |
| 190 |
if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) { |
| 191 |
return false; |
| 192 |
} |
| 193 |
|
| 194 |
if ( '1' === get_option( 'elementor_tracker_notice' ) ) { |
| 195 |
return false; |
| 196 |
} |
| 197 |
|
| 198 |
if ( Tracker::is_allow_track() ) { |
| 199 |
return false; |
| 200 |
} |
| 201 |
|
| 202 |
if ( 2 > $this->get_elementor_pages_count() ) { |
| 203 |
return false; |
| 204 |
} |
| 205 |
|
| 206 |
// TODO: Skip for development env. |
| 207 |
$optin_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_into' ), 'opt_into' ); |
| 208 |
$optout_url = wp_nonce_url( add_query_arg( 'elementor_tracker', 'opt_out' ), 'opt_out' ); |
| 209 |
|
| 210 |
$tracker_description_text = __( 'Love using Elementor? Become a super contributor by opting in to share non-sensitive plugin data and to receive periodic email updates from us.', 'elementor' ); |
| 211 |
|
| 212 |
/** |
| 213 |
* Tracker admin description text. |
| 214 |
* |
| 215 |
* Filters the admin notice text for non-sensitive data collection. |
| 216 |
* |
| 217 |
* @since 1.0.0 |
| 218 |
* |
| 219 |
* @param string $tracker_description_text Description text displayed in admin notice. |
| 220 |
*/ |
| 221 |
$tracker_description_text = apply_filters( 'elementor/tracker/admin_description_text', $tracker_description_text ); |
| 222 |
?> |
| 223 |
<div class="notice updated elementor-message"> |
| 224 |
<div class="elementor-message-inner"> |
| 225 |
<div class="elementor-message-icon"> |
| 226 |
<div class="e-logo-wrapper"> |
| 227 |
<i class="eicon-elementor" aria-hidden="true"></i> |
| 228 |
</div> |
| 229 |
</div> |
| 230 |
<div class="elementor-message-content"> |
| 231 |
<p><?php echo esc_html( $tracker_description_text ); ?> <a href="https://go.elementor.com/usage-data-tracking/" target="_blank"><?php echo __( 'Learn more.', 'elementor' ); ?></a></p> |
| 232 |
<p class="elementor-message-actions"> |
| 233 |
<a href="<?php echo $optin_url; ?>" class="button button-primary"><?php echo __( 'Sure! I\'d love to help', 'elementor' ); ?></a> <a href="<?php echo $optout_url; ?>" class="button-secondary"><?php echo __( 'No thanks', 'elementor' ); ?></a> |
| 234 |
</p> |
| 235 |
</div> |
| 236 |
</div> |
| 237 |
</div> |
| 238 |
<?php |
| 239 |
|
| 240 |
return true; |
| 241 |
} |
| 242 |
|
| 243 |
private function notice_rate_us_feedback() { |
| 244 |
$notice_id = 'rate_us_feedback'; |
| 245 |
|
| 246 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 247 |
return false; |
| 248 |
} |
| 249 |
|
| 250 |
if ( 'dashboard' !== $this->current_screen_id || User::is_user_notice_viewed( $notice_id ) ) { |
| 251 |
return false; |
| 252 |
} |
| 253 |
|
| 254 |
if ( 10 >= $this->get_elementor_pages_count() ) { |
| 255 |
return false; |
| 256 |
} |
| 257 |
|
| 258 |
$dismiss_url = add_query_arg( [ |
| 259 |
'action' => 'elementor_set_admin_notice_viewed', |
| 260 |
'notice_id' => esc_attr( $notice_id ), |
| 261 |
], admin_url( 'admin-post.php' ) ); |
| 262 |
|
| 263 |
?> |
| 264 |
<div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>"> |
| 265 |
<div class="elementor-message-inner"> |
| 266 |
<div class="elementor-message-icon"> |
| 267 |
<div class="e-logo-wrapper"> |
| 268 |
<i class="eicon-elementor" aria-hidden="true"></i> |
| 269 |
</div> |
| 270 |
</div> |
| 271 |
<div class="elementor-message-content"> |
| 272 |
<p><strong><?php echo __( 'Congrats!', 'elementor' ); ?></strong> <?php _e( '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' ); ?></p> |
| 273 |
<p class="elementor-message-actions"> |
| 274 |
<a href="https://go.elementor.com/admin-review/" target="_blank" class="button button-primary"><?php _e( 'Happy To Help', 'elementor' ); ?></a> |
| 275 |
<a href="<?php echo esc_url_raw( $dismiss_url ); ?>" class="button elementor-button-notice-dismiss"><?php _e( 'Hide Notification', 'elementor' ); ?></a> |
| 276 |
</p> |
| 277 |
</div> |
| 278 |
</div> |
| 279 |
</div> |
| 280 |
<?php |
| 281 |
|
| 282 |
return true; |
| 283 |
} |
| 284 |
|
| 285 |
private function notice_woocommerce_promote() { |
| 286 |
$notice_id = 'woocommerce_promote'; |
| 287 |
|
| 288 |
if ( Utils::has_pro() || ! function_exists( 'WC' ) ) { |
| 289 |
return false; |
| 290 |
} |
| 291 |
|
| 292 |
if ( ! current_user_can( 'install_plugins' ) ) { |
| 293 |
return false; |
| 294 |
} |
| 295 |
|
| 296 |
if ( ! in_array( $this->current_screen_id, [ 'edit-product', 'woocommerce_page_wc-settings' ], true ) || User::is_user_notice_viewed( $notice_id ) ) { |
| 297 |
return false; |
| 298 |
} |
| 299 |
|
| 300 |
if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) { |
| 301 |
return false; |
| 302 |
} |
| 303 |
|
| 304 |
if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) { |
| 305 |
return false; |
| 306 |
} |
| 307 |
|
| 308 |
?> |
| 309 |
<div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>"> |
| 310 |
<div class="elementor-message-inner"> |
| 311 |
<div class="elementor-message-icon"> |
| 312 |
<div class="e-logo-wrapper"> |
| 313 |
<i class="eicon-elementor" aria-hidden="true"></i> |
| 314 |
</div> |
| 315 |
</div> |
| 316 |
<div class="elementor-message-content"> |
| 317 |
<p><?php _e( 'Using WooCommerce? With Elementor Pro’s WooCommerce Builder, you’ll be able to design your store without coding!', 'elementor' ); ?></p> |
| 318 |
<p class="elementor-message-actions"> |
| 319 |
<a href="https://go.elementor.com/plugin-promotion-woocommerce/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a> |
| 320 |
</p> |
| 321 |
</div> |
| 322 |
</div> |
| 323 |
</div> |
| 324 |
<?php |
| 325 |
|
| 326 |
return true; |
| 327 |
} |
| 328 |
|
| 329 |
private function notice_cf7_promote() { |
| 330 |
$notice_id = 'cf7_promote'; |
| 331 |
|
| 332 |
if ( Utils::has_pro() || ! defined( 'WPCF7_VERSION' ) ) { |
| 333 |
return false; |
| 334 |
} |
| 335 |
|
| 336 |
if ( ! current_user_can( 'install_plugins' ) ) { |
| 337 |
return false; |
| 338 |
} |
| 339 |
|
| 340 |
if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_wpcf7', 'contact_page_wpcf7-integration' ], true ) || User::is_user_notice_viewed( $notice_id ) ) { |
| 341 |
return false; |
| 342 |
} |
| 343 |
|
| 344 |
if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) { |
| 345 |
return false; |
| 346 |
} |
| 347 |
|
| 348 |
if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) { |
| 349 |
return false; |
| 350 |
} |
| 351 |
|
| 352 |
?> |
| 353 |
<div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>"> |
| 354 |
<div class="elementor-message-inner"> |
| 355 |
<div class="elementor-message-icon"> |
| 356 |
<div class="e-logo-wrapper"> |
| 357 |
<i class="eicon-elementor" aria-hidden="true"></i> |
| 358 |
</div> |
| 359 |
</div> |
| 360 |
<div class="elementor-message-content"> |
| 361 |
<p><?php _e( 'Using Elementor & Contact Form 7? Try out Elementor Pro and design your forms visually with one powerful tool.', 'elementor' ); ?></p> |
| 362 |
<p class="elementor-message-actions"> |
| 363 |
<a href="https://go.elementor.com/plugin-promotion-contactform7/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a> |
| 364 |
</p> |
| 365 |
</div> |
| 366 |
</div> |
| 367 |
</div> |
| 368 |
<?php |
| 369 |
|
| 370 |
return true; |
| 371 |
} |
| 372 |
|
| 373 |
private function notice_mc4wp_promote() { |
| 374 |
$notice_id = 'mc4wp_promote'; |
| 375 |
|
| 376 |
if ( Utils::has_pro() || ! defined( 'MC4WP_VERSION' ) ) { |
| 377 |
return false; |
| 378 |
} |
| 379 |
|
| 380 |
if ( ! current_user_can( 'install_plugins' ) ) { |
| 381 |
return false; |
| 382 |
} |
| 383 |
|
| 384 |
if ( ! in_array( $this->current_screen_id, [ 'toplevel_page_mailchimp-for-wp', 'mc4wp_page_mailchimp-for-wp-forms', 'mc4wp_page_mailchimp-for-wp-integrations', 'mc4wp_page_mailchimp-for-wp-other', 'mc4wp_page_mailchimp-for-wp-extensions' ], true ) || User::is_user_notice_viewed( $notice_id ) ) { |
| 385 |
return false; |
| 386 |
} |
| 387 |
|
| 388 |
if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) { |
| 389 |
return false; |
| 390 |
} |
| 391 |
|
| 392 |
if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) { |
| 393 |
return false; |
| 394 |
} |
| 395 |
|
| 396 |
?> |
| 397 |
<div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>"> |
| 398 |
<div class="elementor-message-inner"> |
| 399 |
<div class="elementor-message-icon"> |
| 400 |
<div class="e-logo-wrapper"> |
| 401 |
<i class="eicon-elementor" aria-hidden="true"></i> |
| 402 |
</div> |
| 403 |
</div> |
| 404 |
<div class="elementor-message-content"> |
| 405 |
<p><?php _e( 'Want to design better MailChimp forms? Use Elementor Pro and enjoy unlimited integrations, visual design, templates and more.', 'elementor' ); ?></p> |
| 406 |
<p class="elementor-message-actions"> |
| 407 |
<a href="https://go.elementor.com/plugin-promotion-mc4wp/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a> |
| 408 |
</p> |
| 409 |
</div> |
| 410 |
</div> |
| 411 |
</div> |
| 412 |
<?php |
| 413 |
|
| 414 |
return true; |
| 415 |
} |
| 416 |
|
| 417 |
private function notice_popup_maker_promote() { |
| 418 |
$notice_id = 'popup_maker_promote'; |
| 419 |
|
| 420 |
if ( Utils::has_pro() || ! class_exists( 'Popup_Maker' ) ) { |
| 421 |
return false; |
| 422 |
} |
| 423 |
|
| 424 |
if ( ! current_user_can( 'install_plugins' ) ) { |
| 425 |
return false; |
| 426 |
} |
| 427 |
|
| 428 |
if ( ! in_array( $this->current_screen_id, [ 'edit-popup', 'popup_page_pum-settings' ], true ) || User::is_user_notice_viewed( $notice_id ) ) { |
| 429 |
return false; |
| 430 |
} |
| 431 |
|
| 432 |
if ( strtotime( '2019-08-01' ) > $this->get_install_time() ) { |
| 433 |
return false; |
| 434 |
} |
| 435 |
|
| 436 |
if ( strtotime( '+24 hours', $this->get_install_time() ) > time() ) { |
| 437 |
return false; |
| 438 |
} |
| 439 |
|
| 440 |
?> |
| 441 |
<div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>"> |
| 442 |
<div class="elementor-message-inner"> |
| 443 |
<div class="elementor-message-icon"> |
| 444 |
<div class="e-logo-wrapper"> |
| 445 |
<i class="eicon-elementor" aria-hidden="true"></i> |
| 446 |
</div> |
| 447 |
</div> |
| 448 |
<div class="elementor-message-content"> |
| 449 |
<p><?php _e( 'Using popups on your site? Build outstanding popups using Elementor Pro and get more leads, sales and subscribers.', 'elementor' ); ?></p> |
| 450 |
<p class="elementor-message-actions"> |
| 451 |
<a href="https://go.elementor.com/plugin-promotion-popupmaker/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a> |
| 452 |
</p> |
| 453 |
</div> |
| 454 |
</div> |
| 455 |
</div> |
| 456 |
<?php |
| 457 |
|
| 458 |
return true; |
| 459 |
} |
| 460 |
|
| 461 |
private function notice_role_manager_promote() { |
| 462 |
$notice_id = 'role_manager_promote'; |
| 463 |
|
| 464 |
if ( Utils::has_pro() ) { |
| 465 |
return false; |
| 466 |
} |
| 467 |
|
| 468 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 469 |
return false; |
| 470 |
} |
| 471 |
|
| 472 |
if ( 'elementor_page_elementor-role-manager' !== $this->current_screen_id || User::is_user_notice_viewed( $notice_id ) ) { |
| 473 |
return false; |
| 474 |
} |
| 475 |
|
| 476 |
$users = new \WP_User_Query( [ |
| 477 |
'fields' => 'ID', |
| 478 |
'number' => 10, |
| 479 |
] ); |
| 480 |
|
| 481 |
if ( 5 > $users->get_total() ) { |
| 482 |
return false; |
| 483 |
} |
| 484 |
|
| 485 |
?> |
| 486 |
<div class="notice updated is-dismissible elementor-message elementor-message-dismissed" data-notice_id="<?php echo esc_attr( $notice_id ); ?>"> |
| 487 |
<div class="elementor-message-inner"> |
| 488 |
<div class="elementor-message-icon"> |
| 489 |
<div class="e-logo-wrapper"> |
| 490 |
<i class="eicon-elementor" aria-hidden="true"></i> |
| 491 |
</div> |
| 492 |
</div> |
| 493 |
<div class="elementor-message-content"> |
| 494 |
<p><?php _e( 'Managing a multi-user site? With Elementor Pro, you can control user access and make sure no one messes up your design.', 'elementor' ); ?></p> |
| 495 |
<p class="elementor-message-actions"> |
| 496 |
<a href="https://go.elementor.com/promotion-role-manager/" target="_blank" class="button button-secondary"><?php _e( 'Learn More', 'elementor' ); ?></a> |
| 497 |
</p> |
| 498 |
</div> |
| 499 |
</div> |
| 500 |
</div> |
| 501 |
<?php |
| 502 |
|
| 503 |
return true; |
| 504 |
} |
| 505 |
|
| 506 |
/* |
| 507 |
* @TODO: Rewrite this method markup and use it for every admin notice |
| 508 |
*/ |
| 509 |
public function print_admin_notice( array $options ) { |
| 510 |
$default_options = [ |
| 511 |
'id' => null, |
| 512 |
'title' => '', |
| 513 |
'description' => '', |
| 514 |
'dismissible' => false, |
| 515 |
'button' => [ |
| 516 |
'text' => '', |
| 517 |
'url' => '', |
| 518 |
'class' => 'elementor-button', |
| 519 |
], |
| 520 |
]; |
| 521 |
|
| 522 |
$options = array_replace_recursive( $default_options, $options ); |
| 523 |
|
| 524 |
$id_attr = ''; |
| 525 |
$dismissible_classes = ''; |
| 526 |
|
| 527 |
if ( $options['id'] ) { |
| 528 |
$id_attr = sprintf( 'data-notice_id="%s"', $options['id'] ); |
| 529 |
} |
| 530 |
|
| 531 |
if ( $options['dismissible'] ) { |
| 532 |
$dismissible_classes = 'is-dismissible elementor-message-dismissed'; |
| 533 |
} |
| 534 |
?> |
| 535 |
<div |
| 536 |
class="notice elementor-message <?php echo $dismissible_classes; ?>" |
| 537 |
<?php echo $id_attr; ?> |
| 538 |
> |
| 539 |
<div class="elementor-message-inner"> |
| 540 |
<div class="elementor-message-icon"> |
| 541 |
<div class="e-logo-wrapper"> |
| 542 |
<i class="eicon-elementor" aria-hidden="true"></i> |
| 543 |
</div> |
| 544 |
</div> |
| 545 |
<div class="elementor-message-content"> |
| 546 |
<?php if ( $options['title'] ) { ?> |
| 547 |
<strong><?php echo $options['title']; ?></strong> |
| 548 |
<?php } ?> |
| 549 |
<?php if ( $options['description'] ) { ?> |
| 550 |
<p><?php echo $options['description']; ?></p> |
| 551 |
<?php } ?> |
| 552 |
</div> |
| 553 |
<?php if ( $options['button']['text'] ) { ?> |
| 554 |
<div class="elementor-message-action"> |
| 555 |
<a class="<?php echo $options['button']['class']; ?>" href="<?php echo esc_url( $options['button']['url'] ); ?>"><?php echo $options['button']['text']; ?></a> |
| 556 |
</div> |
| 557 |
<?php } ?> |
| 558 |
</div> |
| 559 |
</div> |
| 560 |
<?php |
| 561 |
} |
| 562 |
|
| 563 |
public function admin_notices() { |
| 564 |
$this->install_time = Plugin::$instance->get_install_time(); |
| 565 |
$this->current_screen_id = get_current_screen()->id; |
| 566 |
|
| 567 |
foreach ( $this->plain_notices as $notice ) { |
| 568 |
$method_callback = "notice_{$notice}"; |
| 569 |
if ( $this->$method_callback() ) { |
| 570 |
return; |
| 571 |
} |
| 572 |
} |
| 573 |
|
| 574 |
/** @var Base_Notice $notice_instance */ |
| 575 |
foreach ( $this->get_notices() as $notice_instance ) { |
| 576 |
if ( ! $notice_instance->should_print() ) { |
| 577 |
continue; |
| 578 |
} |
| 579 |
|
| 580 |
$this->print_admin_notice( $notice_instance->get_config() ); |
| 581 |
|
| 582 |
// It exits the method to make sure it prints only one notice. |
| 583 |
return; |
| 584 |
} |
| 585 |
} |
| 586 |
|
| 587 |
/** |
| 588 |
* @since 2.9.0 |
| 589 |
* @access public |
| 590 |
*/ |
| 591 |
public function __construct() { |
| 592 |
add_action( 'admin_notices', [ $this, 'admin_notices' ], 20 ); |
| 593 |
} |
| 594 |
|
| 595 |
/** |
| 596 |
* Get module name. |
| 597 |
* |
| 598 |
* Retrieve the module name. |
| 599 |
* |
| 600 |
* @since 2.9.0 |
| 601 |
* @access public |
| 602 |
* |
| 603 |
* @return string Module name. |
| 604 |
*/ |
| 605 |
public function get_name() { |
| 606 |
return 'admin-notices'; |
| 607 |
} |
| 608 |
} |
| 609 |
|