Skip to content

Commit eab98da

Browse files
committed
Add halt code for AA 2.0
1 parent b97f82e commit eab98da

File tree

1 file changed

+80
-2
lines changed

1 file changed

+80
-2
lines changed

genesis-ads.php

+80-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
defined( 'ABSPATH' ) || exit;
2424

25-
// Load basic path and url to the plugin.
25+
define( 'AAG_FILE', __FILE__ );
26+
define( 'AAG_VERSION', '1.0.8' );
2627
define( 'AAG_BASE_PATH', plugin_dir_path( __FILE__ ) );
2728
define( 'AAG_BASE_URL', plugin_dir_url( __FILE__ ) );
2829
define( 'AAG_BASE_DIR', dirname( plugin_basename( __FILE__ ) ) );
@@ -60,4 +61,81 @@ function advanced_ads_genesis_init() {
6061
// Kick it!!
6162
Plugin::get()->hooks();
6263
}
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

Comments
 (0)