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 / detect_playground.php
Created November 23, 2023 10:23 — forked from alanef/detect_playground.php
Detect WP Playground
<?php
if ( 'PHP.wasm' === $_SERVER['SERVER_SOFTWARE'] && 'playground.wordpress.net' === $_SERVER['HTTP_HOST'] ) {
// inside playground.wordpress.net
}
<?php
namespace Blocksy;
/*
*/
class Capabilities {
private $accounts_cache = null;
@vovafeldman
vovafeldman / my.cnf
Created February 21, 2022 17:30 — forked from chrisjlee/my.cnf
my.cnf file optimized for InnoDB 64bit setups
# forked from http://forge.mysql.com/tools/tool.php?id=137
[client]
#password = [your_password]
port = 3306
socket = /tmp/mysqld.sock
# *** Application-specific options follow here ***
#
<?php
my_fs()->add_filter( 'show_deactivation_feedback_form', '__return_false' );
@vovafeldman
vovafeldman / freemius-api-license-validation.php
Last active April 20, 2023 13:09
Validates a license key using Freemius API using the PHP SDK
<?php
// Freemius PHP SDK - https://github.com/Freemius/freemius-php-sdk
require_once './php-sdk-master/freemius/Freemius.php';
define( 'FS__API_SCOPE', 'developer' );
define( 'FS__API_DEV_ID', 1234 );
define( 'FS__API_PUBLIC_KEY', 'pk_YOUR_PUBLIC_KEY' );
define( 'FS__API_SECRET_KEY', 'sk_YOUR_SECRET_KEY' );
// Init SDK.
@vovafeldman
vovafeldman / gist.php
Created November 8, 2020 13:14 — forked from mecha/gist.php
Freemius - Free plugin updates blocked if premium and free versions do not match
<?php
// Functions that you'll need
function get_free_version() { /* ... */ }
function get_premium_version() { /* ... */ }
function is_free_plugin($plugin_basename) { /* ... */ }
// Filter the value of the transient where WordPress stores pending updates
add_filter('site_transient_update_plugins', function ($value) {
// Only proceed if the transient has responses from update servers
@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 );
<?php
my_fs()->add_filter( 'show_deactivation_subscription_cancellation', '__return_false' );
@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
function my_after_license_change( $change, $current_plan ) {
switch ( $change ) {
case 'activated':
// License activated.
break;
case 'cancelled':
// License cancelled.
break;
case 'changed':