get( Activecampaign_For_Woocommerce_Activator::class );
$activator->activate();
}
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-activecampaign-for-woocommerce-deactivator.php
*
* @since 1.0.0
*/
function activecampaign_for_woocommerce_deactivate() {
$deactivator = new Activecampaign_For_Woocommerce_Deactivator();
$deactivator->deactivate();
}
register_activation_hook( __FILE__, 'activecampaign_for_woocommerce_activate' );
register_deactivation_hook( __FILE__, 'activecampaign_for_woocommerce_deactivate' );
/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @param Container $container The PHP DI container instance.
*
* @throws DependencyException Dependency exception.
* @throws NotFoundException Not found exception.
* @since 1.0.0
*/
function activecampaign_for_woocommerce_run( Container $container ) {
$plugin = $container->get( Activecampaign_For_Woocommerce::class );
$plugin->run();
}
/**
* WooCommerce dependency alert.
*
* Alert the administrator if WooCommerce is unavailable.
*
* @since __NEXT__
*
* @return void
*/
function activecampaign_for_woocommerce_alert_woocommerce_not_available() {
echo "
The ActiveCampaign for WooCommerce plugin is not available because WooCommerce is either not installed or not activated. Please install and activate WooCommerce.
";
}
/**
* I'm the decider
*
* Should the plugin load or not? Dependency checks go here.
*
* @since __NEXT__
*
* @return bool True or false.
*/
function activecampaign_for_woocommerce_should_load() {
if ( ! defined( 'WC_PLUGIN_FILE' ) ) {
return false;
}
return true;
}
/**
* Late loader
*
* WordPress loads plugins in alphabetical order. This plugin **MUST** be
* loaded *after* WooCommerce. Defining this function allows us to use the
* `plugins_loaded` hook to manually load this plugin after WooCommerce is
* loaded.
*
* @return void
* @throws NotFoundException Not found exception.
*
* @throws DependencyException Dependency exception.
*/
function activecampaign_for_woocommerce_late_loader() {
if ( ! activecampaign_for_woocommerce_should_load() ) {
add_action( 'admin_notices', 'activecampaign_for_woocommerce_alert_woocommerce_not_available' );
return;
}
activecampaign_for_woocommerce_run( activecampaign_for_woocommerce_build_container() );
}
/**
* Show row meta on the plugin screen.
*
* @param mixed $links Plugin Row Meta.
* @param mixed $file Plugin Base file.
*
* @return array
*/
function activecampaign_for_woocommerce_plugin_row_meta( $links, $file ) {
if ( ACTIVECAMPAIGN_FOR_WOOCOMMERCE_PLUGIN_BASE_NAME !== $file ) {
return $links;
}
$row_meta = array(
'support' => '' . esc_html__( 'Contact Support', ACTIVECAMPAIGN_FOR_WOOCOMMERCE_LOCALIZATION_DOMAIN ) . '',
);
return array_merge( $links, $row_meta );
}
add_filter( 'plugin_row_meta', 'activecampaign_for_woocommerce_plugin_row_meta', 10, 2 );
/**
* PHPUnit Autoloads this file. In doing so, it actually runs the run() function.
* This causes a pollution of the global scope, registering actions and etc. The PHPUnit
* bootstrap file sets TESTING=1 to the environment to disable this.
*/
if ( ! getenv( 'TESTING' ) ) {
add_action( 'plugins_loaded', 'activecampaign_for_woocommerce_late_loader' );
}