Skip to content

Instantly share code, notes, and snippets.

View vovafeldman's full-sized avatar
🔥
Making sh*t happen

Vova Feldman vovafeldman

🔥
Making sh*t happen
View GitHub Profile
@vovafeldman
vovafeldman / purchaseCompleted.php
Last active April 8, 2021 16:53
Freemius Purchase Completion JavaScript Callback Filter
<?php
// Add GA tracking only if user opted-in OR if non-WP.org compliant product.
function my_after_purchase_js( $js_function ) {
return 'function ( response ) {
/**
* 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 initizlizing GA here (after the purchase), is legitimate.
*/
ga('create', 'UA-XXXXXXX', 'auto');
@vovafeldman
vovafeldman / freemius-checkout-ga-fb-tracking.js
Last active October 2, 2024 01:00
Tracking purchases with Google Analytics and Facebook for Freemius Checkout
//
// Gist was kindly contributed by @jamesckemp from @iconicwp. Thanks!
//
handler.open({
...
purchaseCompleted: function( response ) {
var trial = response.purchase.trial_ends !== null,
total = trial ? 0 : response.purchase.initial_amount.toString(),
productName = 'Product Name',
@vovafeldman
vovafeldman / override-support-forum-url.php
Last active October 17, 2018 10:49
Freemius - Customizing the support forum URL for the premium code version
<?php
function my_premium_support_forum_url( $wp_org_support_forum_url ) {
return 'https://my-awesome-site.com/forum/';
}
if ( my_fs()->is_premium() ) {
my_fs()->add_filter( 'support_forum_url', 'my_premium_support_forum_url' );
}
@vovafeldman
vovafeldman / freemius-admin-notice-filter.php
Last active April 29, 2019 10:32
Controlling the visibility of a Freemius added admin notice
<?php
/**
* @param bool $show
* @param array $msg {
* @var string $message The actual message.
* @var string $title An optional message title.
* @var string $type The type of the message ('success', 'update', 'warning', 'promotion').
* @var string $id The unique identifier of the message.
* @var string $manager_id The unique identifier of the notices manager. For plugins it would be the plugin's slug, for themes - `<slug>-theme`.
* @var string $plugin The product's title.
@vovafeldman
vovafeldman / freemius-merging-free-premium.php
Created October 29, 2018 08:51
How to merge free and premium version into one with Freemius
<?php
/**
* Plugin Name: ...
* Plugin URI: ...
* ...
*
* @fs_premium_only /path/to/premium/folder/
*/
// Freemius Init SDK code
function my_fs() {
@vovafeldman
vovafeldman / .env
Created December 16, 2018 12:47 — forked from xplodedthemes/.env
Ticksy External Purchase Verification Freemius Integration
FS_API_SCOPE="developer"
FS_API_DEV_ID=000
FS_API_PUBLIC_KEY=""
FS_API_SECRET_KEY=""
TICKSY_SECRET_KEY=""
<?php
function my_after_license_change( $change, $current_plan ) {
switch ( $change ) {
case 'activated':
// License activated.
break;
case 'cancelled':
// License cancelled.
break;
case 'changed':
@vovafeldman
vovafeldman / README.md
Last active August 18, 2019 18:48
A code snippet to automatically activate the locally stored license key from the previous eCommerce platform (EDD/WC) with the Freemius SDK

Description

This extra snippet will check if a license was previously activated, and if it does, will activate it through Freemius in the background.

Usage

  • You will need to replace my_fs() with your theme's relevant shortcode.
  • You will need to rename the function my_fs_license_key_migration() to a unique name.
  • You will need to rename 'my_fs_migrated2fs' to a unique option name.
  • You will need to replace my_get_license_key_from_prev_platform_storage() with some logic that fetches the theme's license key.
<?php
my_fs()->add_filter( 'show_deactivation_subscription_cancellation', '__return_false' );
@vovafeldman
vovafeldman / sp-edd-fs.php
Created September 10, 2020 11:10 — forked from shamim2883/sp-edd-fs.php
Redirect EDD license renew request to Freemius
<?php
add_action('add_meta_boxes', function(){
add_meta_box('sp_edd_fs_metabox', 'Freemius data', 'sp_edd_fs_metabox', 'download', 'side', 'default' );
});
function sp_edd_fs_metabox( $post ){
$plugin_id = get_post_meta( $post->ID, '_sp_edd_fs_plugin_id', true );
$coupon = get_post_meta( $post->ID, '_sp_edd_fs_coupon', true );