Last active
December 1, 2021 14:58
-
-
Save alanef/1c85b9c00afd1682f806f1c98f6f9c03 to your computer and use it in GitHub Desktop.
Handle contact form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var \Freemius $myfreemiustag_fs Freemius global object. */ | |
global $myfreemiustag_fs; | |
if ( ! isset( $myfreemiustag_fs ) ) { | |
// Include Freemius SDK. | |
require_once 'mypath/includes/vendor/freemius/wordpress-sdk/start.php'; | |
$myfreemiustag_fs = fs_dynamic_init( array( | |
'id' => '10000', | |
'slug' => 'my-slug', | |
'type' => 'plugin', | |
'public_key' => 'pk_xxxxxxxxxxx', | |
'is_premium' => true, | |
'has_premium_version' => true, | |
'has_addons' => true, | |
'has_paid_plans' => true, | |
'trial' => array( | |
'days' => 14, | |
'is_require_payment' => true, | |
), | |
'navigation' => 'tabs', | |
'menu' => array( | |
'slug' => 'my-slug', | |
'contact' => false, | |
'support' => false, | |
'parent' => array( | |
'slug' => 'options-general.php', | |
), | |
), | |
) ); | |
} | |
if ( $myfreemiustag_fs->can_use_premium_code__premium_only() ) { | |
// premium code users if they ever had a licence show the contact form | |
$myfreemiustag_fs->add_filter( | |
'is_submenu_visible', | |
function ( $is_visible, $menu_id ) { | |
/** @var \Freemius $myfreemiustag_fs Freemius global object. */ | |
global $myfreemiustag_fs; | |
if ( 'contact' === $menu_id ) { | |
return $myfreemiustag_fs->has_any_license(); | |
} | |
if ( 'support' === $menu_id ) { | |
return ! $myfreemiustag_fs->has_any_license(); | |
} | |
return $is_visible; | |
} | |
); | |
} else { | |
// free code users if they ever had a licence show only the support menu which is the free forum | |
$myfreemiustag_fs->add_filter( | |
'is_submenu_visible', | |
function ( $is_visible, $menu_id ) { | |
if ( 'contact' === $menu_id ) { | |
return false; | |
} | |
if ( 'support' === $menu_id ) { | |
return true; | |
} | |
return $is_visible; | |
} | |
); | |
} | |
// hide deactivation form - because users moan about this | |
$myfreemiustag_fs->add_filter( | |
'show_deactivation_feedback_form', | |
__return_false() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment