ads
1 week ago
groups
1 week ago
metaboxes
1 year ago
pages
3 months ago
placements
1 week ago
class-action-links.php
1 week ago
class-addon-box.php
1 year ago
class-addon-updater.php
3 months ago
class-admin-menu.php
1 week ago
class-admin-notices.php
1 year ago
class-ajax.php
3 months ago
class-assets.php
1 week ago
class-authors.php
1 year ago
class-edd-updater.php
4 weeks ago
class-list-filters.php
1 week ago
class-marketing.php
1 year ago
class-metabox-ad-settings.php
1 year ago
class-metabox-ad.php
1 year ago
class-misc.php
1 week ago
class-page-quick-edit.php
1 year ago
class-plugin-installer.php
1 year ago
class-post-list.php
1 year ago
class-post-types.php
1 week ago
class-screen-options.php
3 months ago
class-settings.php
1 year ago
class-shortcode-creator.php
1 year ago
class-system-info.php
1 year ago
class-tinymce.php
2 years ago
class-translation-promo.php
1 year ago
class-upgrades.php
1 year ago
class-version-control.php
3 months ago
class-welcome.php
1 year ago
class-wordpress-dashboard.php
1 year ago
index.php
2 years ago
class-welcome.php
77 lines
| 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 |