set_basename( str_ends_with( basename( __DIR__ ), '-premium' ), __FILE__ );
// This copy's activation, deactivation and uninstall must still run, or switching packages would skip them.
Plugin::instance()->container()->get( 'activator' )->register_file( __FILE__ );
return;
}
define( 'CONSENTFOLD_VERSION', '1.0.0' );
define( 'CONSENTFOLD_FILE', __FILE__ );
define( 'CONSENTFOLD_DIR', plugin_dir_path( __FILE__ ) );
define( 'CONSENTFOLD_URL', plugin_dir_url( __FILE__ ) );
$consentfold_autoload = CONSENTFOLD_DIR . 'vendor/autoload.php';
if ( ! is_readable( $consentfold_autoload ) ) {
// A source checkout without `composer install`: explain instead of fataling.
add_action(
'admin_notices',
static function (): void {
if ( current_user_can( 'activate_plugins' ) ) {
echo '
';
echo esc_html__( 'Consentfold is missing its dependencies. Run "composer install" in the plugin directory.', 'consentfold' );
echo '
';
}
}
);
return;
}
require_once $consentfold_autoload;
// The SDK normally arrives with the autoloader (composer lists its start.php under autoload.files), but
// start.php returns at its first line unless ABSPATH is defined, so an autoloader loaded before WordPress
// (PHPUnit does this) leaves it absent. `require`, not `require_once`: PHP records the early-returning
// first pass as included.
if ( ! function_exists( 'fs_dynamic_init' ) ) {
require CONSENTFOLD_DIR . 'vendor/freemius/wordpress-sdk/start.php';
}
if ( ! function_exists( 'consentfold_fs' ) ) {
/**
* The Freemius instance: connect screen, upgrade, checkout, license and updates.
*
* @return Freemius
*/
function consentfold_fs(): Freemius {
global $consentfold_fs;
if ( ! isset( $consentfold_fs ) ) {
$consentfold_fs = fs_dynamic_init(
array(
// The product's public identifiers from the Freemius dashboard: the only place they are
// set. The dashboard shows a third value beside them, the secret key (sk_...), which
// authenticates the REST API as the vendor and must never appear in this repository or in any
// shipped file.
'id' => '42468',
'public_key' => 'pk_ebf77a915e3971577966c9a32e94d',
'slug' => 'consentfold',
// Must differ from 'slug' and keep the directory suffix the SDK derives each package's
// basename from by string replacement.
'premium_slug' => 'consentfold-premium',
// The label the SDK appends to the plugin name in the second package.
'premium_suffix' => 'Pro',
'type' => 'plugin',
'has_paid_plans' => true,
'has_premium_version' => true,
'is_premium_only' => false,
// The packaging step flips this single value for the second package. The Freemius
// deployment reads this call statically, so it stays a plain literal.
'is_premium' => false,
// Nothing leaves the site until the user opts in. The SDK shows its own connect screen
// on first activation with "Skip" on it: that is 'enable_anonymous' (true by default,
// set here so it is not lost). 'anonymous_mode' is a different switch that bypasses the
// screen, so it is left out.
'enable_anonymous' => true,
// With this false the SDK runs in development mode and never shows the connect screen.
'is_live' => true,
// Account and Upgrade become submenus of the top-level Consentfold menu, which the SDK
// finds by this slug (registered in Admin\Menu, before the SDK's own late admin_menu pass).
'menu' => array(
'slug' => Menu::SLUG,
'first-path' => 'admin.php?page=' . Menu::SLUG,
'account' => true,
'pricing' => true,
'contact' => false,
'support' => false,
'affiliation' => false,
),
)
);
}
return $consentfold_fs;
}
}
consentfold_fs();
// The SDK deactivates the other package when one is activated, unless this filter answers no. WordPress.org does
// not allow a plugin to switch another one off without the user asking for it, so both stay active.
consentfold_fs()->add_filter( 'deactivate_on_activation', '__return_false' );
// Data removal on uninstall rides the SDK's `after_uninstall` action: the package ships no uninstall.php,
// because the Freemius deployment rejects one. Registered through the SDK's own add_action() so the
// per-product hook suffix is resolved by the SDK.
if ( ! function_exists( 'consentfold_fs_after_uninstall' ) ) {
/**
* Removes the plugin's data when "delete data on uninstall" is set and no sibling package is installed.
* The class check covers a bulk delete of both packages in one process, where this function outlives
* the first package's deleted directory.
*/
function consentfold_fs_after_uninstall(): void {
if ( class_exists( Uninstaller::class ) ) {
Uninstaller::run_for_current_uninstall();
}
}
}
consentfold_fs()->add_action( 'after_uninstall', 'consentfold_fs_after_uninstall' );
// consentfold:no-evaluation-period:begin (the packaging step of the other tier removes this block)
// The SDK learns from the Freemius API which plans offer an evaluation period, so leaving it out of the init
// settings only covers visitors who have not opted in. This package is a WordPress.org listing and may not promote
// one: the filter makes the SDK's admin notice and its Account page button answer no. The SDK keeps its promotion
// as a stored notice and checks that notice before the filter, so one stored by an earlier build is dropped as well.
consentfold_fs()->add_filter( 'show_trial', '__return_false' );
if ( consentfold_fs()->is_in_trial_promotion() ) {
consentfold_fs()->remove_sticky( 'trial_promotion' );
}
// consentfold:no-evaluation-period:end.
do_action( 'consentfold_fs_loaded' );
Plugin::boot();