I am building a plugin based on a boilerplate gerenrated on wppb.me The problem I am having is getting the register_activation_hook to actually execute without following it with add_action
This is the code segment in promo-card.php
define('PROMO_DIR_PATH', plugin_dir_path(FILE));
function activate_promo_card() { log_me('activate_promo_card function start'); /* debug logger call */ require_once (PROMO_DIR_PATH . 'includes/class-promo-card-activator.php'); $promoCreate=new Promo_Card_Activator; $promoCreate->promo_db_master_create(); $promoCreate->promo_db_detail_create(); }
function deactivate_promo_card() { log_me('deactivate_promo_card function start'); /* debug logger call */ require_once (PROMO_DIR_PATH . 'includes/class-promo-card-deactivator.php'); Promo_Card_Deactivator::deactivate(); }
register_activation_hook( PROMO_DIR_PATH, 'activate_promo_card' ); //add_action('init', 'activate_promo_card'); register_deactivation_hook( PROMO_DIR_PATH, 'deactivate_promo_card' ); //add_action('init', 'deactivate_promo_card');
If I use the add_action then it fires the function in all cases which is not good. What am I missing?