ad-health-notices.php
1 year ago
class-ad-network-ad-unit.php
4 months ago
class-ad-network.php
1 year ago
class-licenses.php
3 months ago
class-notices.php
4 months ago
class-overview-widgets.php
1 year ago
class-plugins-screen-updates.php
2 months ago
notices.php
4 months ago
notices.php
218 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Array with admin notices |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | */ |
| 8 | |
| 9 | use AdvancedAds\Utilities\WordPress; |
| 10 | |
| 11 | if ( ! defined( 'NOTICE_TYPES' ) ) { |
| 12 | define( |
| 13 | 'NOTICE_TYPES', |
| 14 | [ |
| 15 | 'info' => 'info', |
| 16 | 'subscribe' => 'subscribe', |
| 17 | 'error' => 'plugin_error', |
| 18 | 'promo' => 'promo', |
| 19 | ] |
| 20 | ); |
| 21 | } |
| 22 | |
| 23 | // These add-on names correspond to the names in the class of constants from ADDONS_NON_COMPATIBLE_VERSIONS. |
| 24 | $manual_addons = [ |
| 25 | 'advanced-ads-page-peel' => [ |
| 26 | 'title' => 'Advanced Ads Page Peel', |
| 27 | 'zip' => esc_url( 'https://wpadvancedads.com/wp-content/uploads/advanced-ads-page-peel.zip' ), |
| 28 | 'link' => esc_url( 'https://wpadvancedads.com/manual/how-to-install-an-add-on/?utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-update-pagepeel-a220' ), |
| 29 | ], |
| 30 | 'advanced-ads-browser-language' => [ |
| 31 | 'title' => 'Advanced Ads Browser Language Visitor Condition', |
| 32 | 'zip' => esc_url( 'https://wpadvancedads.com/wp-content/uploads/advanced-ads-browser-language.zip' ), |
| 33 | 'link' => esc_url( 'https://wpadvancedads.com/manual/how-to-install-an-add-on/?utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-update-browserlang-a220' ), |
| 34 | ], |
| 35 | 'slider-ads' => [ |
| 36 | 'title' => 'Advanced Ads Ad Slider', |
| 37 | 'zip' => esc_url( 'https://wpadvancedads.com/wp-content/uploads/advanced-ads-slider.zip' ), |
| 38 | 'link' => esc_url( 'https://wpadvancedads.com/manual/how-to-install-an-add-on/?utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-update-adslider-a220' ), |
| 39 | ], |
| 40 | ]; |
| 41 | |
| 42 | $advanced_ads_admin_notices = [ |
| 43 | // email tutorial. |
| 44 | 'nl_first_steps' => [ |
| 45 | 'type' => NOTICE_TYPES['subscribe'], |
| 46 | 'text' => __( 'Thank you for activating <strong>Advanced Ads</strong>. Would you like to receive the first steps via email?', 'advanced-ads' ), |
| 47 | 'confirm_text' => __( 'Yes, send it', 'advanced-ads' ), |
| 48 | 'global' => true, |
| 49 | ], |
| 50 | // free add-ons. |
| 51 | 'nl_free_addons' => [ |
| 52 | 'type' => NOTICE_TYPES['subscribe'], |
| 53 | 'text' => __( 'Hey, welcome to Advanced Ads! Join our newsletter and snag <strong>2 free add-ons</strong> plus our email intro course. It’s the perfect way to get started smoothly!', 'advanced-ads' ), |
| 54 | 'confirm_text' => __( 'Subscribe me now', 'advanced-ads' ), |
| 55 | 'global' => false, |
| 56 | ], |
| 57 | // adsense newsletter group. |
| 58 | 'nl_adsense' => [ |
| 59 | 'type' => NOTICE_TYPES['subscribe'], |
| 60 | 'text' => __( 'Learn more about how and <strong>how much you can earn with AdSense</strong> and Advanced Ads from my dedicated newsletter.', 'advanced-ads' ), |
| 61 | 'global' => true, |
| 62 | ], |
| 63 | // missing license codes. |
| 64 | 'license_invalid' => [ |
| 65 | 'type' => NOTICE_TYPES['error'], |
| 66 | 'text' => __( 'One or more license keys for <strong>Advanced Ads add-ons are invalid or missing</strong>.', 'advanced-ads' ) . ' ' |
| 67 | /* translators: %s is a target URL. */ |
| 68 | . sprintf( __( 'Please add valid license keys <a href="%s">here</a>.', 'advanced-ads' ), get_admin_url( null, 'admin.php?page=advanced-ads-settings#top#licenses' ) ), |
| 69 | ], |
| 70 | // please review. |
| 71 | 'review' => [ |
| 72 | 'type' => NOTICE_TYPES['info'], |
| 73 | // 'text' => '<img src="' . ADVADS_BASE_URL . 'admin/assets/img/thomas.png" alt="Thomas" width="80" height="115" class="advads-review-image"/>' |
| 74 | 'text' => '<div style="float: left; font-size: 4em; line-height: 1em; margin-right: 0.5em;">' . WordPress::get_count_ads() . '</div>' |
| 75 | . '<div style="float:left;">' |
| 76 | . '<p>' . __( '… ads created using <strong>Advanced Ads</strong>.', 'advanced-ads' ) . '</p>' |
| 77 | . '<p>' . __( 'Do you find the plugin useful and would like to thank us for updates, fixing bugs and improving your ad setup?', 'advanced-ads' ) . '</p>' |
| 78 | . '<p>' . |
| 79 | /* translators: this belongs to our message asking the user for a review. You can find a nice equivalent in your own language. */ |
| 80 | __( 'When you give 5-stars, an actual person does a little happy dance!', 'advanced-ads' ) . '</p>' |
| 81 | . '<p>' |
| 82 | . '<span class="dashicons dashicons-external"></span> <strong><a href="https://wordpress.org/support/plugin/advanced-ads/reviews/?rate=5#new-post" target=_"blank">' . __( 'Sure, I appreciate your work', 'advanced-ads' ) . '</a></strong>' |
| 83 | . ' <span class="dashicons dashicons-sos"></span> <a href="https://wpadvancedads.com/support/?utm_source=advanced-ads&utm_medium=link&utm_campaign=notice-review" target=_"blank">' . __( 'Yes, but help me first to solve a problem, please', 'advanced-ads' ) . '</a>' |
| 84 | . '</p></div>', |
| 85 | 'global' => false, |
| 86 | ], |
| 87 | // Black Friday 2023 promotion. |
| 88 | 'bfcm23' => [ |
| 89 | 'type' => NOTICE_TYPES['promo'], |
| 90 | 'text' => sprintf( |
| 91 | /* translators: %1$s is the markup for the discount value, %2$s starts a button link, %3$s closes the button link. */ |
| 92 | __( 'Save %1$s on all products with our Black Friday / Cyber Monday offer! %2$sGet this deal%3$s', 'advanced-ads' ), |
| 93 | '<span style="font-weight: bold; font-size: 1.6em; vertical-align: sub;">30%</span>', |
| 94 | '<a class="button button-primary" target="_blank" href="https://wpadvancedads.com/pricing/?utm_source=advanced-ads&utm_medium=link&utm_campaign=bfcm-2023">', |
| 95 | '</a>' |
| 96 | ), |
| 97 | 'global' => true, |
| 98 | ], |
| 99 | // Black Friday 2025 promotion. |
| 100 | 'bfcm25' => [ |
| 101 | 'type' => NOTICE_TYPES['promo'], |
| 102 | 'text' => sprintf( |
| 103 | /* translators: %1$s is the markup for the discount value, %2$s starts a button link, %3$s closes the button link. */ |
| 104 | __( 'Save %1$s on all products with our Black Friday / Cyber Monday offer! %2$sGet this deal%3$s', 'advanced-ads' ), |
| 105 | '<span style="font-weight: bold; font-size: 1.6em; vertical-align: sub;">30%</span>', |
| 106 | '<a class="button button-primary" target="_blank" href="https://wpadvancedads.com/pricing/?utm_source=advanced-ads&utm_medium=link&utm_campaign=bfcm-2025">', |
| 107 | '</a>' |
| 108 | ), |
| 109 | 'global' => true, |
| 110 | ], |
| 111 | 'monetize_wizard' => [ |
| 112 | 'type' => NOTICE_TYPES['info'], |
| 113 | 'text' => sprintf( |
| 114 | wp_kses_post( |
| 115 | /* translators: %s: URL to the Advanced Ads onboarding wizard. */ |
| 116 | __( 'Quickly set up Advanced Ads and monetize your website with just a few clicks. <a class="button button-primary" href="%s">Launch the wizard</a>', 'advanced-ads' ) |
| 117 | ), |
| 118 | admin_url( 'admin.php?page=advanced-ads-onboarding' ) |
| 119 | ), |
| 120 | ], |
| 121 | ]; |
| 122 | |
| 123 | // Add specific notifications for plugins that are incompatible with Advanced Ads 2.0. |
| 124 | foreach ( \AdvancedAds\Constants::ADDONS_NON_COMPATIBLE_VERSIONS as $version => $addon ) { |
| 125 | if ( isset( $manual_addons[ $addon ] ) ) { |
| 126 | $advanced_ads_admin_notices[ $addon . '_upgrade' ] = [ |
| 127 | 'type' => NOTICE_TYPES['info'], |
| 128 | 'text' => sprintf( |
| 129 | wp_kses( |
| 130 | /* translators: %1$s: URL to the plugin file, %2$s: URL to the guide */ |
| 131 | __( 'Your automatically deactivated version of <strong>%1$s needs to be updated manually</strong>. Please <a href="%2$s" target="_blank">download the newest plugin file</a> and follow our guide on <a href="%3$s" target="_blank">How to install an add-on</a>.', 'advanced-ads' ), |
| 132 | [ |
| 133 | 'strong' => [], |
| 134 | 'a' => [ |
| 135 | 'href' => [], |
| 136 | 'target' => [], |
| 137 | ], |
| 138 | ] |
| 139 | ), |
| 140 | $manual_addons[ $addon ]['title'], |
| 141 | $manual_addons[ $addon ]['zip'], |
| 142 | $manual_addons[ $addon ]['link'] |
| 143 | ), |
| 144 | 'global' => true, |
| 145 | ]; |
| 146 | } else { |
| 147 | $advanced_ads_admin_notices[ $addon . '_upgrade' ] = [ |
| 148 | 'type' => NOTICE_TYPES['info'], |
| 149 | 'text' => sprintf( |
| 150 | wp_kses( |
| 151 | /* translators: %1$s: URL to the plugin file, %2$s: URL to the guide */ |
| 152 | __( 'Your version of <strong>%1$s</strong> is incompatible with <strong>Advanced Ads %2$s</strong> and has been deactivated. Please update the plugin to the latest version.', 'advanced-ads' ), |
| 153 | [ |
| 154 | 'strong' => [], |
| 155 | ] |
| 156 | ), |
| 157 | ucwords( str_replace( '-', ' ', $addon ) ), |
| 158 | ADVADS_VERSION |
| 159 | ), |
| 160 | 'global' => true, |
| 161 | ]; |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | // List of plugins that handle ads and may conflict with Advanced Ads |
| 166 | $plugin_conflicts = [ |
| 167 | // Ad management / insertion plugins |
| 168 | 'ad-inserter/ad-inserter.php' => 'Ad Inserter', |
| 169 | 'adsanity/adsanity.php' => 'AdSanity', |
| 170 | 'wp-quads/wpquads.php' => 'WP QUADS', |
| 171 | 'quick-adsense-reloaded/quick-adsense-reloaded.php' => 'Quick AdSense Reloaded', |
| 172 | 'simple-ads-manager/simple-ads-manager.php' => 'Simple Ads Manager', |
| 173 | 'adrotate/adrotate.php' => 'AdRotate', |
| 174 | 'adrotate-pro/adrotate-pro.php' => 'AdRotate Pro', |
| 175 | 'wp-insert/wp-insert.php' => 'WP Insert', |
| 176 | 'insert-post-ads/insert-post-ads.php' => 'Insert Post Ads', |
| 177 | |
| 178 | // AdSense specific plugins |
| 179 | 'adsense-plugin/adsense-plugin.php' => 'AdSense Plugin', |
| 180 | 'google-adsense/google-adsense.php' => 'Google AdSense', |
| 181 | 'adsense-made-easy/adsense-made-easy.php' => 'AdSense Made Easy', |
| 182 | |
| 183 | // Auto ads / monetization plugins |
| 184 | 'monetag/monetag.php' => 'Monetag', |
| 185 | 'media-net-ads/media-net-ads.php' => 'Media.net Ads', |
| 186 | 'ezoic/ezoic.php' => 'Ezoic', |
| 187 | 'mediavine-control-panel/mediavine.php' => 'Mediavine', |
| 188 | ]; |
| 189 | |
| 190 | |
| 191 | // Loop through conflict plugins |
| 192 | foreach ( $plugin_conflicts as $slug => $name ) { |
| 193 | |
| 194 | // Check if plugin is active |
| 195 | if ( is_plugin_active( $slug ) ) { |
| 196 | |
| 197 | // Generate unique notice ID |
| 198 | $noticeId = str_replace( ' ', '_', strtolower( $name ) ); |
| 199 | $notice_id = sanitize_title( $noticeId ) . '_active'; |
| 200 | |
| 201 | // Register admin notice |
| 202 | $advanced_ads_admin_notices[ $notice_id ] = [ |
| 203 | 'type' => NOTICE_TYPES['error'], |
| 204 | 'text' => sprintf( |
| 205 | /* translators: %s: Plugin name */ |
| 206 | __( 'The <strong>%s</strong> plugin is active. Running it alongside <strong>Advanced Ads</strong> may lead to ad placement or display issues.', 'advanced-ads' ), |
| 207 | esc_html( $name ) |
| 208 | ), |
| 209 | 'global' => true, |
| 210 | ]; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | $advanced_ads_admin_notices = apply_filters( |
| 215 | 'advanced-ads-notices', |
| 216 | $advanced_ads_admin_notices |
| 217 | ); |
| 218 |