[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';
/**
* Admin messages
*
* @var array
*/
private static $admin_messages = array();
/**
* Activation handler.
*/
public static function activate() {
$options = get_option( self::PLUGIN_OPTIONS , '' );
if ( $options === null ) {
$options = array();
// add the options and there's no need to autoload these
add_option( self::PLUGIN_OPTIONS, $options, '', 'no' );
}
}
/**
* Prints admin notices.
*/
public static function admin_notices() {
if ( !empty( self::$admin_messages ) ) {
foreach ( self::$admin_messages as $msg ) {
echo wp_kses( $msg, array(
'a' => array( 'href' => array(), 'target' => array(), 'title' => array() ),
'br' => array(),
'div' => array( 'class' => array() ),
'em' => array(),
'p' => array( 'class' => array() ),
'strong' => array()
));
}
}
}
/**
* Initializes the integration if dependencies are verified.
*/
public static function init() {
add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
add_action( 'init', array( __CLASS__, 'wp_init' ) );
if ( is_admin() ) {
include_once 'class-affiliates-cf7-admin.php';
}
}
/**
* Loads classes.
*/
public static function wp_init() {
if ( self::check_dependencies() ) {
register_activation_hook( __FILE__, array( __CLASS__, 'activate' ) );
self::$supported_currencies = apply_filters( 'affiliates_cf7_currencies', Affiliates::$supported_currencies );
sort( self::$supported_currencies );
if (
defined( 'AFFILIATES_EXT_VERSION' ) &&
version_compare( AFFILIATES_EXT_VERSION, '3.0.0' ) >= 0 &&
class_exists( 'Affiliates_Referral' ) &&
(
!defined( 'Affiliates_Referral::DEFAULT_REFERRAL_CALCULATION_KEY' ) ||
!get_option( Affiliates_Referral::DEFAULT_REFERRAL_CALCULATION_KEY, null )
)
) {
include_once 'class-affiliates-cf7-handler.php';
} else {
include_once 'class-affiliates-cf7-handler-legacy.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[] =
"