PluginProbe
Advanced Ads – Ad Manager & AdSense / 2.0.9
Advanced Ads – Ad Manager & AdSense v2.0.9
2.0.26 2.0.25 2.0.24 2.0.23 2.0.22 2.0.21 1.38.0 1.39.0 1.39.1 1.39.2 1.39.3 1.39.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.40.0 1.40.1 1.40.2 All 348 releases
advanced-ads / includes / admin / class-welcome.php
class-welcome.php
77 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin Welcome.
4 *
5 * @package AdvancedAds
6 * @author Advanced Ads <info@wpadvancedads.com>
7 * @since 1.50.0
8 */
9
10 namespace AdvancedAds\Admin;
11
12 use AdvancedAds\Constants;
13
14 defined( 'ABSPATH' ) || exit;
15
16 /**
17 * Admin Welcome.
18 */
19 class Welcome {
20 /**
21 * Dismiss user meta
22 *
23 * @var string
24 */
25 const USER_META = 'advanced-ads-welcome';
26
27 /**
28 * Main instance
29 *
30 * Ensure only one instance is loaded or can be loaded.
31 *
32 * @return Welcome
33 */
34 public static function get() {
35 static $instance;
36
37 if ( null === $instance ) {
38 $instance = new Welcome();
39 }
40
41 return $instance;
42 }
43
44 /**
45 * Print the welcome box
46 *
47 * @return void
48 */
49 public function display() {
50 if ( ! $this->can_display() ) {
51 return;
52 }
53 require_once plugin_dir_path( ADVADS_FILE ) . '/views/admin/welcome-box.php';
54 }
55
56 /**
57 * Stop displaying the welcome box fot the current user
58 *
59 * @return void
60 */
61 public function dismiss() {
62 update_user_meta( get_current_user_id(), self::USER_META, '1' );
63 }
64
65 /**
66 * Checks if the welcome box can be displayed
67 *
68 * @return bool
69 */
70 public function can_display(): bool {
71 $meta = get_user_meta( get_current_user_id(), self::USER_META, true );
72 $wizard_done = get_option( Constants::OPTION_WIZARD_COMPLETED, false );
73
74 return empty( $meta ) && ! $wizard_done;
75 }
76 }
77