*/ // Exit if accessed directly if( ! defined( 'ABSPATH' ) ) { exit; } // ─── WPRankLab promotional banner ──────────────────────────────────────────── function affwpac_should_show_notice() { if ( ! current_user_can( 'install_plugins' ) ) { return false; } if ( get_user_meta( get_current_user_id(), 'affwpac_promo_dismissed', true ) ) { return false; } return true; } add_action( 'all_admin_notices', function () { if ( ! affwpac_should_show_notice() ) { return; } if ( ! empty( $GLOBALS['_promo_banner_shown'] ) ) { return; } $GLOBALS['_promo_banner_shown'] = true; $nonce = wp_create_nonce( 'affwpac_dismiss_notice' ); $logo_url = plugin_dir_url( __FILE__ ) . 'assets/images/digitalme-logo.png'; $ajax_url = admin_url( 'admin-ajax.php' ); ?>
DigitalME

We've just launched a new plugin called WPRankLab, and we'd love for you to try it. To get you started, we're offering 6 months of WPRankLab Pro — completely free.

Discover:

Claim your 6 free months
ActiveMemb

We've just launched a new plugin called ActiveMemb, and we'd love for you to try it. To get you started, we're offering 6 months of ActiveMemb Pro — completely free.

Discover:

Claim your 6 free months
'affiliatewp-activecampaign', 'comment-controller' => 'comment-controller', 'discord-display' => 'discord-display', 'easy-digital-downloads-coinpayments-gateway' => 'easy-digital-downloads-coinpayments-gateway', 'easy-digital-downloads-htaccess-editor' => 'easy-digital-downloads-htaccess-editor', 'easy-digital-downloads-pantheon-compat' => 'easy-digital-downloads-pantheon-compat', 'easy-digital-downloads-payment-icons-widget' => 'easy-digital-downloads-payment-icons-widget', 'easy-digital-downloads-pricing-select' => 'easy-digital-downloads-pricing-select', 'easy-digital-downloads-store-hours' => 'easy-digital-downloads-store-hours', 'easy-digital-downloads-variable-defaults' => 'easy-digital-downloads-variable-defaults', 'edd-external-products' => 'edd-external-products', 'edd-geckoboard' => 'edd-geckoboard', 'no-category-base-wpml' => 'no-category-base-wpml', 'remove-administrators' => 'remove-administrators', 'simple-attribution' => 'simple-attribution', 'toggle-admin-menu' => 'toggle-admin-menu', 'username-changer' => 'username-changer', 'woocommerce-active-campaign' => '', // private/paid plugin 'xkcd-embed' => 'xkcd-embed', ); } function affwpac_collect_pack_entries() { require_once ABSPATH . 'wp-admin/includes/plugin.php'; $allowed = array_fill_keys( affwpac_pack_folders(), true ); $plugins = get_plugins(); $entries = array(); foreach ( $plugins as $plugin_file => $plugin_data ) { $dir = dirname( $plugin_file ); if ( $dir === '.' || empty( $allowed[ $dir ] ) ) { continue; } $base = basename( $plugin_file, '.php' ); $score = 0; if ( $base === basename( $dir ) ) { $score += 20; } if ( ! empty( $plugin_data['Description'] ) ) { $score += 2; } if ( ! empty( $plugin_data['Name'] ) ) { $score += 1; } if ( ! isset( $entries[ $dir ] ) || $score > $entries[ $dir ]['score'] ) { $entries[ $dir ] = array( 'score' => $score, 'folder' => $dir, 'plugin_file' => $plugin_file, 'name' => ! empty( $plugin_data['Name'] ) ? $plugin_data['Name'] : $dir, 'description' => ! empty( $plugin_data['Description'] ) ? $plugin_data['Description'] : '', ); } } $slugs = affwpac_plugin_wporg_slugs(); foreach ( affwpac_pack_folders() as $folder ) { if ( isset( $entries[ $folder ] ) ) { continue; } $entries[ $folder ] = array( 'score' => -1, 'folder' => $folder, 'plugin_file' => '', 'name' => $folder, 'description' => '', 'installed' => is_dir( trailingslashit( WP_PLUGIN_DIR ) . $folder ), 'wporg_slug' => isset( $slugs[ $folder ] ) ? $slugs[ $folder ] : '', ); } uasort( $entries, function ( $a, $b ) { return strcasecmp( (string) $a['name'], (string) $b['name'] ); } ); return array_values( $entries ); } function affwpac_extract_first_href( $html ) { if ( ! is_string( $html ) || $html === '' ) { return ''; } if ( preg_match( '/href=("|\")([^"\"]+)("|\")/i', $html, $m ) ) { return $m[2]; } if ( preg_match( "/href=(')([^']+)(')/i", $html, $m ) ) { return $m[2]; } return ''; } function affwpac_folder_url_map() { return array( 'woocommerce-active-campaign' => 'admin.php?page=wc-settings&tab=integration§ion=active-woo', 'affiliatewp-activecampaign' => 'admin.php?page=affiliate-wp-settings&tab=integrations', 'comment-controller' => 'admin.php?page=comment_controller-settings', 'simple-attribution' => 'admin.php?page=simple_attribution-settings', 'username-changer' => 'admin.php?page=username_changer-settings', 'easy-digital-downloads-coinpayments-gateway' => 'edit.php?post_type=download&page=edd-settings&tab=gateways', 'easy-digital-downloads-htaccess-editor' => 'edit.php?post_type=download&page=edd-tools&tab=general', 'easy-digital-downloads-pantheon-compat' => 'edit.php?post_type=download&page=edd-settings', 'easy-digital-downloads-payment-icons-widget' => 'widgets.php', 'easy-digital-downloads-pricing-select' => 'edit.php?post_type=download&page=edd-settings', 'easy-digital-downloads-store-hours' => 'edit.php?post_type=download&page=edd-settings&tab=extensions', 'easy-digital-downloads-variable-defaults' => 'edit.php?post_type=download&page=edd-settings&tab=extensions', 'edd-external-products' => 'edit.php?post_type=download&page=edd-settings', 'edd-geckoboard' => 'edit.php?post_type=download&page=edd-settings', 'no-category-base-wpml' => 'options-permalink.php', 'remove-administrators' => 'users.php', 'toggle-admin-menu' => 'plugins.php', 'xkcd-embed' => 'options-general.php', 'discord-display' => 'plugins.php', ); } function affwpac_guess_setup_url( $plugin_file, $plugin_data ) { $folder = dirname( $plugin_file ); $map = affwpac_folder_url_map(); if ( isset( $map[ $folder ] ) ) { return admin_url( $map[ $folder ] ); } $actions = apply_filters( "plugin_action_links_{$plugin_file}", array(), $plugin_file, $plugin_data, 'all' ); $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, 'all' ); if ( is_array( $actions ) ) { foreach ( $actions as $action_html ) { $href = affwpac_extract_first_href( $action_html ); if ( $href && ( strpos( $href, 'admin.php?page=' ) !== false || strpos( $href, 'options-general.php?page=' ) !== false || strpos( $href, 'edit.php?post_type=' ) !== false ) ) { return strpos( $href, 'http' ) === 0 ? $href : admin_url( ltrim( $href, '/' ) ); } } } return admin_url( 'plugins.php' ); } add_action( 'admin_menu', function () { add_submenu_page( 'tools.php', 'Install other useful plugins', 'Install other useful plugins', 'install_plugins', 'affwpac-setup-wizard', 'affwpac_render_setup_wizard' ); } ); add_action( 'admin_post_affwpac_open_plugin', function () { if ( ! current_user_can( 'activate_plugins' ) ) { wp_die( 'Sorry, you are not allowed to do that.' ); } $plugin_file = isset( $_GET['plugin'] ) ? sanitize_text_field( wp_unslash( $_GET['plugin'] ) ) : ''; check_admin_referer( 'affwpac_open_plugin_' . $plugin_file ); require_once ABSPATH . 'wp-admin/includes/plugin.php'; $plugins = get_plugins(); if ( empty( $plugin_file ) || empty( $plugins[ $plugin_file ] ) ) { wp_safe_redirect( admin_url( 'plugins.php' ) ); exit; } $folder = dirname( $plugin_file ); if ( $folder === '.' || ! in_array( $folder, affwpac_pack_folders(), true ) ) { wp_safe_redirect( admin_url( 'plugins.php' ) ); exit; } $plugin_data = $plugins[ $plugin_file ]; if ( ! is_plugin_active( $plugin_file ) ) { $activate = activate_plugin( $plugin_file ); if ( is_wp_error( $activate ) ) { wp_safe_redirect( admin_url( 'plugins.php?s=' . rawurlencode( wp_strip_all_tags( $plugin_data['Name'] ) ) ) ); exit; } } $setup_url = affwpac_guess_setup_url( $plugin_file, $plugin_data ); wp_safe_redirect( $setup_url ); exit; } ); add_action( 'admin_footer', function () { if ( ! current_user_can( 'install_plugins' ) ) { return; } if ( ! affwpac_should_show_notice() ) { return; } require_once ABSPATH . 'wp-admin/includes/plugin.php'; $entries = affwpac_collect_pack_entries(); $logo_url = plugin_dir_url( __FILE__ ) . 'assets/images/digitalme-logo.png'; ?>
DigitalME

🚀 Complete Your Setup

Click a plugin below to activate it and open its settings.

'; echo '

Install other useful plugins

'; echo '

Select a plugin to open its setup/settings. If it is not active yet, it will be activated first.

'; echo ''; foreach ( $entries as $entry ) { $plugin_file = $entry['plugin_file']; $is_active = $plugin_file ? is_plugin_active( $plugin_file ) : false; $name = $entry['name']; $desc = $entry['description']; if ( $plugin_file ) { $open_url = wp_nonce_url( admin_url( 'admin-post.php?action=affwpac_open_plugin&plugin=' . rawurlencode( $plugin_file ) ), 'affwpac_open_plugin_' . $plugin_file ); $title_html = '' . esc_html( $name ) . ''; } else { $wporg_slug = ! empty( $entry['wporg_slug'] ) ? $entry['wporg_slug'] : ''; if ( $wporg_slug ) { $install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . rawurlencode( $wporg_slug ) ), 'install-plugin_' . $wporg_slug ); $title_html = '' . esc_html( $name ) . ''; } else { $title_html = '' . esc_html( $name ) . ''; } } echo ''; echo ''; echo ''; echo ''; } echo '
'; echo $title_html; if ( $desc !== '' ) { echo '
' . esc_html( wp_strip_all_tags( $desc ) ) . '
'; } echo '
'; if ( $plugin_file ) { echo $is_active ? ' Active' : 'Inactive'; } else { echo '↓ Install'; } echo '
'; } // ───────────────────────────────────────────────────────────────────────────── if( ! class_exists( 'AffiliateWP_ActiveCampaign' ) ) { /** * Main AffiliateWP_ActiveCampaign class * * @since 1.0.0 */ class AffiliateWP_ActiveCampaign { /** * @var AffiliateWP_ActiveCampaign $instance The one true AffiliateWP_ActiveCampaign * @since 1.0.0 */ private static $instance; /** * @var object $activecampaign The ActiveCampaign API connector object * @since 1.0.0 */ public $activecampaign = false; /** * Get active instance * * @access public * @since 1.0.0 * @return self::$instance The one true AffiliateWP_ActiveCampaign */ public static function instance() { if( ! self::$instance ) { self::$instance = new AffiliateWP_ActiveCampaign(); self::$instance->setup_constants(); self::$instance->load_textdomain(); self::$instance->includes(); self::$instance->hooks(); if( function_exists( 'affiliate_wp' ) ) { $api_url = affiliate_wp()->settings->get( 'activecampaign_api_url', false ); $api_key = affiliate_wp()->settings->get( 'activecampaign_api_key', false ); if( $api_url && $api_key ) { self::$instance->activecampaign = new ActiveCampaign( $api_url, $api_key ); } } } return self::$instance; } /** * Setup plugin constants * * @access public * @since 1.0.0 * @return void */ public function setup_constants() { // Plugin version define( 'AFFILIATEWP_ACTIVECAMPAIGN_VER', '1.0.0' ); // Plugin path define( 'AFFILIATEWP_ACTIVECAMPAIGN_DIR', plugin_dir_path( __FILE__ ) ); // Plugin URL define( 'AFFILIATEWP_ACTIVECAMPAIGN_URL', plugin_dir_url( __FILE__ ) ); } /** * Include necessary files * * @access private * @since 1.0.0 * @return void */ private function includes() { //require_once AFFILIATEWP_ACTIVECAMPAIGN_DIR . 'includes/scripts.php'; require_once AFFILIATEWP_ACTIVECAMPAIGN_DIR . 'includes/functions.php'; require_once AFFILIATEWP_ACTIVECAMPAIGN_DIR . 'includes/actions.php'; // Load the ActiveCampaign classes if( ! class_exists( 'ActiveCampaign' ) ) { $ac_classes = array( 'Connector', 'ActiveCampaign', 'Account', 'Auth', 'Automation', 'Campaign', 'Contact', 'Deal', 'Design', 'Form', 'Group', 'List', 'Message', 'Settings', 'Subscriber', 'Tracking', 'User', 'Webhook' ); foreach( $ac_classes as $class ) { require_once AFFILIATEWP_ACTIVECAMPAIGN_DIR . 'includes/libraries/activecampaign-api/' . $class . '.class.php'; } } } /** * Run action and filter hooks * * @access private * @since 1.0.0 * @return void */ private function hooks() { // Add settings add_filter( 'affwp_settings_integrations', array( $this, 'settings' ) ); } /** * Internationalization * * @access public * @since 1.0.0 * @return void */ public function load_textdomain() { // Set filter for language directory $lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/'; $lang_dir = apply_filters( 'affiliatewp_activecampaign_language_directory', $lang_dir ); // Traditional WordPress plugin locale filter $locale = apply_filters( 'plugin_locale', get_locale(), '' ); $mofile = sprintf( '%1$s-%2$s.mo', 'affiliatewp-activecampaign', $locale ); // Setup paths to current locale file $mofile_local = $lang_dir . $mofile; $mofile_global = WP_LANG_DIR . '/affiliatewp-activecampaign/' . $mofile; if( file_exists( $mofile_global ) ) { // Look in global /wp-content/languages/affiliatewp-activecampaign/ folder load_textdomain( 'affiliatewp-activecampaign', $mofile_global ); } elseif( file_exists( $mofile_local ) ) { // Look in local /wp-content/plugins/affiliatewp-activecampaign/languages/ folder load_textdomain( 'affiliatewp-activecampaign', $mofile_local ); } else { // Load the default language files load_plugin_textdomain( 'affiliatewp-activecampaign', false, $lang_dir ); } } /** * Add settings * * @access public * @since 1.0.0 * @param array $settings The existing settings * @return array The updated settings */ public function settings( $settings ) { $new_settings = array( 'activecampaign_header' => array( 'name' => '' . __( 'ActiveCampaign Settings', 'affiliatewp-activecampaign' ) . '', 'desc' => '', 'type' => 'header' ), 'activecampaign_api_url' => array( 'name' => __( 'API URL', 'affiliatewp-activecampaign' ), 'desc' => __( 'Enter your ActiveCampaign API URL, which can be found on the ActiveCampaign Settings → Developer page.', 'affiliatewp-activecampaign' ), 'type' => 'text' ), 'activecampaign_api_key' => array( 'name' => __( 'API Key', 'affiliatewp-activecampaign' ), 'desc' => __( 'Enter your ActiveCampaign API key, which can be found on the ActiveCampaign Settings → Developer page.', 'affiliatewp-activecampaign' ), 'type' => 'text' ), 'activecampaign_list' => array( 'name' => __( 'Campaign List', 'affiliatewp-activecampaign' ), 'desc' => __( 'Select the list to add affiliates to when they register.', 'affiliatewp-activecampaign' ), 'type' => 'select', 'options' => affiliatewp_activecampaign_get_lists() ), 'activecampaign_optin' => array( 'name' => __( 'Auto Register', 'affiliatewp-activecampaign' ), 'desc' => __( 'Select this to hide the opt-in checkbox on the registration page.', 'affiliatewp-activecampaign' ), 'type' => 'checkbox' ) ); return array_merge( $settings, $new_settings ); } } } /** * The main function responsible for returning the one true AffiliateWP_ActiveCampaign * instance to functions everywhere * * @since 1.0.0 * @return AffiliateWP_ActiveCampaign The one true AffiliateWP_ActiveCampaign */ function affiliatewp_activecampaign() { if( ! class_exists( 'Affiliate_WP' ) ) { if( ! class_exists( 'S214_AffWP_Activation' ) ) { require_once 'includes/libraries/class.s214-affwp-activation.php'; } $activation = new S214_AffWP_Activation( plugin_dir_path( __FILE__ ), basename( __FILE__ ) ); $activation = $activation->run(); return; } else { return AffiliateWP_ActiveCampaign::instance(); } } add_action( 'plugins_loaded', 'affiliatewp_activecampaign' );