| 1 |
<?php |
| 2 |
namespace Elementor\Modules\Apps; |
| 3 |
|
| 4 |
use Elementor\Core\Upgrade\Manager as Upgrade_Manager; |
| 5 |
use Elementor\User; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; // Exit if accessed directly. |
| 9 |
} |
| 10 |
|
| 11 |
class Admin_Pointer { |
| 12 |
|
| 13 |
const RELEASE_VERSION = '3.15.0'; |
| 14 |
|
| 15 |
const CURRENT_POINTER_SLUG = 'e-apps'; |
| 16 |
|
| 17 |
public static function add_hooks() { |
| 18 |
add_action( 'admin_print_footer_scripts-index.php', [ __CLASS__, 'admin_print_script' ] ); |
| 19 |
} |
| 20 |
|
| 21 |
public static function admin_print_script() { |
| 22 |
if ( static::is_dismissed() || static::is_new_installation() ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
wp_enqueue_script( 'wp-pointer' ); |
| 27 |
wp_enqueue_style( 'wp-pointer' ); |
| 28 |
|
| 29 |
$pointer_content = '<h3>' . esc_html__( 'New! Popular Add-ons', 'elementor' ) . '</h3>'; |
| 30 |
$pointer_content .= '<p>' . esc_html__( 'Discover our collection of plugins and add-ons carefully selected to enhance your Elementor website and unleash your creativity.', 'elementor' ) . '</p>'; |
| 31 |
|
| 32 |
$pointer_content .= sprintf( |
| 33 |
'<p><a class="button button-primary" href="%s">%s</a></p>', |
| 34 |
admin_url( 'admin.php?page=' . Module::PAGE_ID ), |
| 35 |
esc_html__( 'Explore Add-ons', 'elementor' ) |
| 36 |
) |
| 37 |
|
| 38 |
?> |
| 39 |
<script> |
| 40 |
jQuery( document ).ready( function( $ ) { |
| 41 |
$( '#toplevel_page_elementor' ).pointer( { |
| 42 |
content: '<?php echo $pointer_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>', |
| 43 |
position: { |
| 44 |
edge: <?php echo is_rtl() ? "'right'" : "'left'"; ?>, |
| 45 |
align: 'center' |
| 46 |
}, |
| 47 |
close: function() { |
| 48 |
elementorCommon.ajax.addRequest( 'introduction_viewed', { |
| 49 |
data: { |
| 50 |
introductionKey: '<?php echo esc_attr( static::CURRENT_POINTER_SLUG ); ?>', |
| 51 |
}, |
| 52 |
} ); |
| 53 |
} |
| 54 |
} ).pointer( 'open' ); |
| 55 |
} ); |
| 56 |
</script> |
| 57 |
<?php |
| 58 |
} |
| 59 |
|
| 60 |
private static function is_dismissed() { |
| 61 |
return User::get_introduction_meta( static::CURRENT_POINTER_SLUG ); |
| 62 |
} |
| 63 |
|
| 64 |
private static function is_new_installation() { |
| 65 |
return Upgrade_Manager::install_compare( static::RELEASE_VERSION, '>=' ); |
| 66 |
} |
| 67 |
} |
| 68 |
|