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 / .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=""
@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 / 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 / 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-checkout-ga-fb-tracking.js
Last active April 6, 2023 21:58
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 / 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 / wordpress-tabs.php
Created February 28, 2018 15:56
Adding tabs
<div class="wrap">
<h2 class="nav-tab-wrapper">
<a href="#" class="nav-tab nav-tab-active"><?php __( 'Getting Started', 'text-domain' ) ?></a>
</h2>
</div>
@vovafeldman
vovafeldman / multi-plan-buy-button.html
Last active June 8, 2023 15:43
Freemius Buy Button Code for a Multi-Plans Table
<script src="https://checkout.freemius.com/checkout.min.js"></script>
<select id="starter-licenses">
<option value="1" selected="selected">Single Site License</option>
<option value="5">5-Site License</option>
<option value="25">25-Site License</option>
<option value="unlimited">Unlimited Sites License</option>
</select>
<button id="starter-purchase">Buy Starter</button>
@vovafeldman
vovafeldman / software-licensing.php
Created July 5, 2017 00:54
Freemius Software Licensing Examples
<?php
// This IF block will be auto removed from the Free version.
if ( my_fs()->is__premium_only() ) {
// This IF will be executed only if the user in a trial mode or have a valid license.
if ( my_fs()->can_use_premium_code() ) {
// ... logic related to any paid plan ...
}
if ( my_fs()->is_plan('starter') ) {
// ... logic related to starter plan and higher plans ...
@vovafeldman
vovafeldman / cm-pop-up-banners-for-wordpress.php
Created June 7, 2017 14:27
CM Pop-Up banners for WordPress Freemius integration - Premium is a separate version.
<?php
/**
* Plugin Name: ...
* Plugin URI: ...
* ...
*
* @fs_premium_only /path/to/premium/folder/
*/
// Freemius Init SDK code