Show a confirm message before plug-in activation
I want to display a message when the user try to activate my plugin. This message will ask if him really wants to activate the plugin or, if him change his mind, cancel the activation. How can I accomplish that? This is the code for the warning message just for reference.
--- UPDATED CODE ---
register_activation_hook( __FILE__, 'on_activation' );
function on_activation() {
// Add the admin notice:
add_action( 'admin_notices', 'on_activation_note' );
// Then you should check the DB option:
$plugins = get_option( 'active_plugins' );
// Do all the checks from the confirmation message
if ( !in_array(__FILE__, $plugins) ) {
unset( $plugins[ dirname( __FILE__ ) ] );
update_option( 'active_plugins', $plugins );
}
}
function on_activation_note() {
global $pagenow;
if ( $pagenow == 'plugins.php' ) {
ob_start(); ?
div id="message" class="error"
pstrongAviso/strong/br
Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et./p
pspana class="button" href=""Cancelar/a/span
spana class="button" href=""Continuar/a/span/p
/div
?php
echo ob_get_clean();
}
}
Topic deactivated-plugin activation plugins Wordpress
Category Web