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-admin-notices.php
81 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Admin Notices. |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.48.2 |
| 8 | */ |
| 9 | |
| 10 | namespace AdvancedAds\Admin; |
| 11 | |
| 12 | use AdvancedAds\Utilities\WordPress; |
| 13 | use AdvancedAds\Framework\Interfaces\Integration_Interface; |
| 14 | |
| 15 | defined( 'ABSPATH' ) || exit; |
| 16 | |
| 17 | /** |
| 18 | * Admin Notices. |
| 19 | */ |
| 20 | class Admin_Notices implements Integration_Interface { |
| 21 | |
| 22 | /** |
| 23 | * Hook into WordPress. |
| 24 | * |
| 25 | * @return void |
| 26 | */ |
| 27 | public function hooks(): void { |
| 28 | add_action( 'all_admin_notices', [ $this, 'create_first_ad' ] ); |
| 29 | add_action( 'admin_notices', [ $this, 'show_rollback_notice' ] ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Show instructions to create first ad above the ad list |
| 34 | * |
| 35 | * @return void |
| 36 | */ |
| 37 | public function create_first_ad(): void { |
| 38 | $screen = get_current_screen(); |
| 39 | if ( ! isset( $screen->id ) || 'edit-advanced_ads' !== $screen->id ) { |
| 40 | return; |
| 41 | } |
| 42 | |
| 43 | $counts = WordPress::get_count_ads(); |
| 44 | |
| 45 | // Only display if there are no more than 2 ads. |
| 46 | if ( 3 > $counts ) { |
| 47 | include ADVADS_ABSPATH . 'views/notices/create-first-ad.php'; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Show notice to rollback to a previous version. |
| 53 | * |
| 54 | * @return void |
| 55 | */ |
| 56 | public function show_rollback_notice(): void { |
| 57 | // show only on plugins page. |
| 58 | if ( 'plugins' !== get_current_screen()->id ) { |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | $rollback = filter_input( INPUT_GET, 'rollback', FILTER_VALIDATE_BOOLEAN ); |
| 63 | if ( ! $rollback ) { |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | $rollback_notification = defined( 'ADVADS_VERSION' ) |
| 68 | /* translators: %s: version number */ |
| 69 | ? sprintf( esc_html__( 'You have successfully rolled back to Advanced Ads %s', 'advanced-ads' ), ADVADS_VERSION ) |
| 70 | : esc_html__( 'You have successfully rolled back to a previous version of Advanced Ads.', 'advanced-ads' ); |
| 71 | |
| 72 | ?> |
| 73 | <div class="notice notice-success is-dismissible"> |
| 74 | <p> |
| 75 | <?php echo esc_html( $rollback_notification ); ?> |
| 76 | </p> |
| 77 | </div> |
| 78 | <?php |
| 79 | } |
| 80 | } |
| 81 |