FS_ID, 'slug' => SLUG, 'premium_slug' => SLUG . '-pro', 'type' => 'plugin', 'public_key' => FS_KEY, 'is_premium' => false, 'premium_suffix' => 'Pro', 'has_addons' => false, 'has_paid_plans' => true, 'trial' => array( 'days' => 14, 'is_require_payment' => true, ), 'menu' => array( 'slug' => SLUG, ), 'is_live' => true, ) ); $GLOBALS['wpide_fs'] = self::$fs; self::$fs->add_action( 'connect/before', [ __CLASS__, 'beforeConnectBox' ] ); self::$fs->add_action( 'connect/after', [ __CLASS__, 'afterConnectBox' ] ); self::$fs->add_filter( 'checkout/purchaseCompleted', [ __CLASS__, 'afterPurchaseJs' ] ); self::$fs->add_filter( 'templates/checkout.php', [ __CLASS__, 'checkoutGtmScript' ] ); self::$fs->add_filter( 'freemius_pricing_js_path', [ __CLASS__, 'pricingJsPath' ] ); self::$fs->add_filter( 'plugin_icon', [ __CLASS__, 'pluginIcon' ] ); self::$fs->add_filter( 'hide_account_tabs', '__return_true' ); self::$fs->add_filter( 'hide_freemius_powered_by', '__return_true' ); self::$fs->add_filter( 'hide_billing_and_payments_info', '__return_true' ); add_action( 'admin_enqueue_scripts', [ __CLASS__, 'admin_enqueue_scripts' ] ); self::$loaded = true; // Signal that SDK was initiated. do_action( 'wpide_fs_loaded' ); } } public static function admin_enqueue_scripts() { if ( App::instance()->isFreemiusScreen() ) { self::freemius_custom_styles(); } } public static function freemius_custom_styles() { wp_enqueue_style( SLUG . '-fs-connect', ASSETS_URL . 'css/freemius/freemius.css', [], VERSION ); } public static function beforeConnectBox() { wp_enqueue_style( SLUG . '-fs-connect', ASSETS_URL . 'css/freemius/freemius.css', [], VERSION ); echo '
' ; } public static function afterConnectBox() { echo '
' ; } public static function afterPurchaseJs() : string { return 'function ( data ) { /** * Since the user just entered their personal & billing information, agreed to the TOS & privacy, * know they are running within a secure iframe from an external domain, they implicitly permit tracking * this purchase. So initializing GTM here (after the purchase), is legitimate. */ var is_subscription = typeof(data.purchase.initial_amount) !== "undefined"; var is_trial = typeof(data.purchase.trial_ends) !== "undefined" && data.purchase.trial_ends !== null; var total = is_subscription ? data.purchase.initial_amount : data.purchase.gross; total = is_trial ? 0 : total; var coupon = data && data.coupon ? data.coupon.code : ""; var currency = data && data.currency ? data.currency.toUpperCase() : "USD"; var item = { item_name: "' . NAME . '", item_id: ' . FS_ID . ', item_brand: "' . AUTHOR . '", affiliation: "' . AUTHOR . '", price: data.total, discount: 0, currency: currency, coupon: coupon, index: 1, quantity: 1 }; // Purchase Event dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. dataLayer.push({ event: "purchase", ecommerce: { transaction_id: data.purchase.id, affiliation: item.affiliation, tax: 0, shipping: 0, items: [item], currency: item.currency, coupon: item.coupon, value: total } }); }'; } public static function checkoutGtmScript( $html ) : string { return "\n \n \n " . $html; } public static function pricingJsPath() : string { return ASSETS_DIR . 'pricing/freemius-pricing.js'; } public static function pluginIcon() : string { return ASSETS_DIR . 'img/icon.png'; } /** * Add license dialog boxes * * @since 1.0.0 */ public static function addLicenseActivationDialogBox() { if ( !did_action( SLUG . '_license_activation_dialog_added' ) && !App::instance()->isFreemiusScreen( 'account' ) ) { self::sdk()->_add_license_activation_dialog_box(); fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' ); do_action( SLUG . '_license_activation_dialog_added' ); } } public static function sdk() { return self::$fs; } public static function loaded() { return self::$loaded; } }