[site_title].

Greetings,
[site_title]
[site_url] "; const NOTIFY_ADMIN = 'notify_admin'; const NOTIFY_AFFILIATE = 'notify_affiliate'; const NOTIFY_ADMIN_DEFAULT = true; const NOTIFY_AFFILIATE_DEFAULT = true; const REFERRAL_RATE = "referral-rate"; const REFERRAL_RATE_DEFAULT = "0"; const USAGE_STATS = 'usage_stats'; const USAGE_STATS_DEFAULT = true; const AUTO_ADJUST_DEFAULT = true; const RATE_ADJUSTED = 'rate-adjusted'; private static $admin_messages = array(); /** * Activation handler. */ public static function activate() { $options = get_option( self::PLUGIN_OPTIONS , null ); if ( $options === null ) { $options = array(); // add the options and there's no need to autoload these add_option( self::PLUGIN_OPTIONS, $options, null, 'no' ); } } /** * Prints admin notices. */ public static function admin_notices() { if ( !empty( self::$admin_messages ) ) { foreach ( self::$admin_messages as $msg ) { echo $msg; } } } /** * Initializes the integration if dependencies are verified. */ public static function init() { add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) ); if ( self::check_dependencies() ) { register_activation_hook( __FILE__, array( __CLASS__, 'activate' ) ); include_once 'class-affiliates-cf7-handler.php'; if ( is_admin() ) { include_once 'class-affiliates-cf7-admin.php'; } } } /** * Check dependencies and print notices if they are not met. * @return true if ok, false if plugins are missing */ public static function check_dependencies() { $result = true; $active_plugins = get_option( 'active_plugins', array() ); if ( is_multisite() ) { $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins', array() ); $active_sitewide_plugins = array_keys( $active_sitewide_plugins ); $active_plugins = array_merge( $active_plugins, $active_sitewide_plugins ); } // required plugins $affiliates_is_active = in_array( 'affiliates/affiliates.php', $active_plugins ) || in_array( 'affiliates-pro/affiliates-pro.php', $active_plugins ) || in_array( 'affiliates-enterprise/affiliates-enterprise.php', $active_plugins ); if ( !$affiliates_is_active ) { self::$admin_messages[] = "
" . __( 'The Affiliates Contact Form 7 Integration plugin requires an appropriate Affiliates plugin: Affiliates, Affiliates Pro or Affiliates Enterprise.', AFF_CF7_PLUGIN_DOMAIN ) . "
"; } // $cf7_is_active = in_array( 'contact-form-7/wp-contact-form-7.php', $active_plugins ); // if ( !$cf7_is_active ) { // self::$admin_messages[] = // "
" . // __( 'The Affiliates Contact Form 7 Integration plugin requires Contact Form 7.', AFF_CF7_PLUGIN_DOMAIN ) . // "
"; // } // if ( !$affiliates_is_active || !$cf7_is_active ) { // $result = false; // } if ( !$affiliates_is_active ) { $result = false; } // deactivate the old plugin $affiliates_cf7_is_active = in_array( 'affiliates-cf7/affiliates-cf7.php', $active_plugins ); if ( $affiliates_cf7_is_active ) { include_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( function_exists('deactivate_plugins' ) ) { deactivate_plugins( 'affiliates-cf7/affiliates-cf7.php' ); self::$admin_messages[] = "
" . __( 'The Affiliates Contact Form 7 Integration plugin version 3 and above replaces the former integration plugin (version number below 3.x).
The former plugin has been deactivated and can now be deleted.', AFF_CF7_PLUGIN_DOMAIN ) . "
"; } else { self::$admin_messages[] = "
" . __( 'The Affiliates Contact Form 7 Integration plugin version 3 and above replaces the former integration plugin with an inferior version number.
Please deactivate and delete the former integration plugin with version number below 3.x.', AFF_CF7_PLUGIN_DOMAIN ) . "
"; } } return $result; } } Affiliates_CF7::init();