'40468', 'public_key' => 'pk_3395bc1fe6035b5df0df362288a8a', 'pricing_url' => '', // Freemius deployment marker for the Pro upload; scripts/build.mjs blanks it in the WordPress.org build. 'gatekeeper' => '', ); } if ( ! function_exists( 'hintwise_fs' ) ) { /** * Freemius instance, or null when not configured. * * @return Freemius|null */ function hintwise_fs() { global $hintwise_fs; if ( isset( $hintwise_fs ) ) { return $hintwise_fs ? $hintwise_fs : null; } $cfg = hintwise_fs_config(); $sdk = HINTWISE_DIR . 'vendor/freemius/start.php'; $hintwise_fs = false; if ( '' === $cfg['id'] || ! file_exists( $sdk ) ) { return null; } require_once $sdk; $args = array( 'id' => $cfg['id'], 'slug' => 'cedar-hintwise', 'type' => 'plugin', 'public_key' => $cfg['public_key'], 'is_premium' => hintwise_is_premium_build(), 'premium_suffix' => 'Pro', 'has_premium_version' => true, 'has_addons' => false, 'has_paid_plans' => true, 'is_org_compliant' => true, 'trial' => array( 'days' => 14, 'is_require_payment' => false, ), 'menu' => array( 'slug' => 'hintwise-settings', 'first-path' => 'admin.php?page=hintwise-library', 'parent' => array( 'slug' => 'hintwise' ), 'contact' => false, 'support' => false, ), ); if ( ! empty( $cfg['gatekeeper'] ) ) { $args['wp_org_gatekeeper'] = $cfg['gatekeeper']; } $hintwise_fs = fs_dynamic_init( $args ); $hintwise_fs->add_action( 'after_uninstall', 'hintwise_uninstall_cleanup' ); $hintwise_fs->add_filter( 'plugin_icon', 'hintwise_fs_icon' ); do_action( 'hintwise_fs_loaded' ); return $hintwise_fs; } hintwise_fs(); } /** * Icon shown on the Freemius opt-in, pricing and account screens. * * @return string Absolute path. */ function hintwise_fs_icon() { return HINTWISE_DIR . 'assets/img/icon.png'; } /** * Uninstall (runs through Freemius' after_uninstall hook). * * Settings and per-user data are always removed. Guides are content the site owner wrote, * so they are only deleted when "Delete guides when uninstalling" is ticked in the settings. */ function hintwise_uninstall_cleanup() { $settings = get_option( 'hintwise_settings', array() ); if ( ! empty( $settings['delete_docs'] ) ) { foreach ( array( 'hintwise_doc', 'hintwise_tour' ) as $type ) { $ids = get_posts( array( 'post_type' => $type, 'post_status' => array_keys( get_post_stati() ), 'numberposts' => -1, 'fields' => 'ids', ) ); foreach ( $ids as $id ) { wp_delete_post( $id, true ); } } } delete_option( 'hintwise_settings' ); delete_option( 'hintwise_sync_state' ); delete_metadata( 'user', 0, 'hintwise_read', '', true ); delete_metadata( 'user', 0, 'hintwise_tours_done', '', true ); delete_metadata( 'user', 0, 'hintwise_panel_seen', '', true ); wp_clear_scheduled_hook( 'hintwise_sync' ); } /** * Whether this copy of the plugin contains the Pro code. * * @return bool */ function hintwise_is_premium_build() { return file_exists( HINTWISE_DIR . 'pro/class-hintwise-pro__premium_only.php' ); } /** * Whether Pro features are active. * * @return bool */ function hintwise_is_pro() { if ( ! class_exists( 'Hintwise_Pro' ) ) { return false; } if ( defined( 'HINTWISE_DEV_PRO' ) && HINTWISE_DEV_PRO ) { return true; } $fs = hintwise_fs(); return $fs ? $fs->can_use_premium_code() : false; } /** * Where "Go Pro" links point. * * @return string */ function hintwise_upgrade_url() { $fs = hintwise_fs(); if ( $fs ) { return $fs->get_upgrade_url(); } $cfg = hintwise_fs_config(); return $cfg['pricing_url'] ? $cfg['pricing_url'] : 'https://wordpress.org/plugins/hintwise/'; }