|
22 | 22 |
|
23 | 23 | defined( 'ABSPATH' ) || exit;
|
24 | 24 |
|
25 |
| -// Load basic path and url to the plugin. |
| 25 | +define( 'AAG_FILE', __FILE__ ); |
| 26 | +define( 'AAG_VERSION', '1.0.8' ); |
26 | 27 | define( 'AAG_BASE_PATH', plugin_dir_path( __FILE__ ) );
|
27 | 28 | define( 'AAG_BASE_URL', plugin_dir_url( __FILE__ ) );
|
28 | 29 | define( 'AAG_BASE_DIR', dirname( plugin_basename( __FILE__ ) ) );
|
@@ -60,4 +61,81 @@ function advanced_ads_genesis_init() {
|
60 | 61 | // Kick it!!
|
61 | 62 | Plugin::get()->hooks();
|
62 | 63 | }
|
63 |
| -add_action( 'plugins_loaded', 'advanced_ads_genesis_init' ); |
| 64 | + |
| 65 | +/** |
| 66 | + * Halt code remove with new release. |
| 67 | + * |
| 68 | + * @return void |
| 69 | + */ |
| 70 | +function wp_advads_genesis_halt_code() { |
| 71 | + global $advads_halt_notices; |
| 72 | + |
| 73 | + if ( version_compare( ADVADS_VERSION, '2.0.0', '>=' ) ) { |
| 74 | + if ( ! isset( $advads_halt_notices ) ) { |
| 75 | + $advads_halt_notices = []; |
| 76 | + } |
| 77 | + $advads_halt_notices[] = __( 'Advanced Ads – Genesis', 'advanced-ads-genesis' ); |
| 78 | + |
| 79 | + add_action( |
| 80 | + 'all_admin_notices', |
| 81 | + static function () { |
| 82 | + global $advads_halt_notices; |
| 83 | + |
| 84 | + // Early bail!! |
| 85 | + if ( 'plugins' === get_current_screen()->base || empty( $advads_halt_notices ) ) { |
| 86 | + return; |
| 87 | + } |
| 88 | + ?> |
| 89 | + <div class="notice notice-error"> |
| 90 | + <h2><?php esc_html_e( 'Important Notice', 'advanced-ads-genesis' ); ?></h2> |
| 91 | + <p> |
| 92 | + <?php |
| 93 | + echo wp_kses_post( |
| 94 | + sprintf( |
| 95 | + /* translators: %s: Plugin name */ |
| 96 | + __( 'Your versions of the Advanced Ads addons listed below are incompatible with <strong>Advanced Ads 2.0</strong> and have been deactivated. Please update them to their latest version. If you cannot update, e.g., due to an expired license, you can <a href="%1$s">roll back to a compatible version of the Advanced Ads plugin</a> at any time or <a href="%2$s">renew your license</a>.', 'advanced-ads-genesis' ), |
| 97 | + esc_url( admin_url( 'admin.php?page=advanced-ads-tools&sub_page=version' ) ), |
| 98 | + 'https://wpadvancedads.com/account/#h-licenses' |
| 99 | + ) |
| 100 | + ) |
| 101 | + ?> |
| 102 | + </p> |
| 103 | + <h3><?php esc_html_e( 'The following addons are affected:', 'advanced-ads-genesis' ); ?></h3> |
| 104 | + <ul> |
| 105 | + <?php foreach ( $advads_halt_notices as $notice ) : ?> |
| 106 | + <li><strong><?php echo esc_html( $notice ); ?></strong></li> |
| 107 | + <?php endforeach; ?> |
| 108 | + </ul> |
| 109 | + </div> |
| 110 | + <?php |
| 111 | + $advads_halt_notices = []; |
| 112 | + } |
| 113 | + ); |
| 114 | + |
| 115 | + add_action( |
| 116 | + 'after_plugin_row_' . plugin_basename( __FILE__ ), |
| 117 | + static function () { |
| 118 | + echo '<tr class="active"><td colspan="5" class="plugin-update colspanchange">'; |
| 119 | + wp_admin_notice( |
| 120 | + sprintf( |
| 121 | + /* translators: %s: Plugin name */ |
| 122 | + __( 'Your version of <strong>Advanced Ads – Genesis</strong> is incompatible with <strong>Advanced Ads 2.0</strong> and has been deactivated. Please update the plugin to the latest version. If you cannot update the plugin, e.g., due to an expired license, you can <a href="%1$s">roll back to a compatible version of the Advanced Ads plugin</a> at any time or <a href="%2$s">renew your license</a>.', 'advanced-ads-pro' ), |
| 123 | + esc_url( admin_url( 'admin.php?page=advanced-ads-tools&sub_page=version' ) ), |
| 124 | + 'https://wpadvancedads.com/account/#h-licenses' |
| 125 | + ), |
| 126 | + [ |
| 127 | + 'type' => 'error', |
| 128 | + 'additional_classes' => array( 'notice-alt', 'inline', 'update-message' ), |
| 129 | + ] |
| 130 | + ); |
| 131 | + echo '</td></tr>'; |
| 132 | + } |
| 133 | + ); |
| 134 | + return; |
| 135 | + } |
| 136 | + |
| 137 | + // Autoload and activate. |
| 138 | + add_action( 'plugins_loaded', 'advanced_ads_genesis_init' ); |
| 139 | +} |
| 140 | + |
| 141 | +add_action( 'plugins_loaded', 'wp_advads_genesis_halt_code', 5 ); |
0 commit comments