set_basename( is_dir( __DIR__ . '/includes/premium__premium_only' ), __FILE__ ); } elseif ( defined( 'WPIM_LENDING_VERSION' ) ) { // Another copy is already loaded on a site where the SDK is skipped (test sites). Stand down. } else { define( 'WPIM_LENDING_VERSION', '0.4.2' ); define( 'WPIM_LENDING_FILE', __FILE__ ); define( 'WPIM_LENDING_PATH', plugin_dir_path( __FILE__ ) ); define( 'WPIM_LENDING_URL', plugin_dir_url( __FILE__ ) ); /** * Freemius (product 43293). Standalone freemium product, not an add-on of WP Inventory. * * No 'menu' block on purpose: with a menu slug, an unlicensed or unreachable SDK runs its * activation-mode menu override, which emptied the whole WP Inventory submenu when the QR Code * add-on did it. Without one, the SDK uses hidden pages of its own and touches nothing else. * * Filter 'wpim_lending_fs_load' (from an mu-plugin) to skip the SDK, e.g. on test sites. */ if ( apply_filters( 'wpim_lending_fs_load', TRUE ) ) { function wpim_lending_fs() { global $wpim_lending_fs; if ( !isset( $wpim_lending_fs ) ) { require_once __DIR__ . '/vendor/freemius/start.php'; $wpim_lending_fs = fs_dynamic_init( [ 'id' => '43293', 'slug' => 'borrowdesk', 'premium_slug' => 'borrowdesk-premium', 'type' => 'plugin', 'public_key' => 'pk_8304a3c97cd6fb7a7e52c25ea14f4', 'is_premium' => false, 'premium_suffix' => 'Premium', 'has_addons' => false, 'has_paid_plans' => true, 'is_org_compliant' => true, 'trial' => [ 'days' => 30, 'is_require_payment' => false, ], 'is_live' => true, ] ); } return $wpim_lending_fs; } wpim_lending_fs(); do_action( 'wpim_lending_fs_loaded' ); // Freemius owns the uninstall hook (it reports the uninstall), so cleanup runs from its // after_uninstall action rather than an uninstall.php, which Freemius rejects. wpim_lending_fs()->add_action( 'after_uninstall', 'wpim_lending_uninstall_cleanup' ); } /** * Data is kept unless the admin opted in to deletion in Lending Settings. */ function wpim_lending_uninstall_cleanup() { wp_clear_scheduled_hook( 'wpim_lending_daily' ); $settings = get_option( 'wpim_lending_settings', [] ); if ( empty( $settings['delete_on_uninstall'] ) ) { return; } require_once __DIR__ . '/includes/class-wpimlend-db.php'; WPIMLend_DB::drop_all(); } require_once WPIM_LENDING_PATH . 'includes/class-wpimlend-db.php'; register_activation_hook( __FILE__, ['WPIMLend_DB', 'activate'] ); register_deactivation_hook( __FILE__, ['WPIMLend_DB', 'deactivate'] ); /** * Load only when WP Inventory (free or Pro) is active. Never call WPIMCore::check_version(): * on free core it always returns FALSE (foundations V2). */ function wpim_lending_bootstrap() { if ( !class_exists( 'WPIMCore' ) ) { add_action( 'admin_notices', 'wpim_lending_missing_core_notice' ); return; } require_once WPIM_LENDING_PATH . 'includes/class-wpimlend-repo.php'; require_once WPIM_LENDING_PATH . 'includes/class-wpimlend-availability.php'; require_once WPIM_LENDING_PATH . 'includes/class-wpimlend-service.php'; require_once WPIM_LENDING_PATH . 'includes/class-wpimlend-settings.php'; require_once WPIM_LENDING_PATH . 'includes/class-wpimlend-mail.php'; require_once WPIM_LENDING_PATH . 'includes/class-wpimlend-csv.php'; require_once WPIM_LENDING_PATH . 'includes/class-wpimlend-admin.php'; require_once WPIM_LENDING_PATH . 'includes/class-wpimlend-item-form.php'; require_once WPIM_LENDING_PATH . 'includes/class-wpimlend-frontend.php'; require_once WPIM_LENDING_PATH . 'includes/class-wpimlend-privacy.php'; require_once WPIM_LENDING_PATH . 'includes/class-wpimlend.php'; // Premium (bookings, calendar, self-service). Freemius strips this folder from the free build. if ( wpim_lending_is_premium() ) { require_once WPIM_LENDING_PATH . 'includes/premium__premium_only/class-wpimlend-booking.php'; require_once WPIM_LENDING_PATH . 'includes/premium__premium_only/class-wpimlend-booking-admin.php'; require_once WPIM_LENDING_PATH . 'includes/premium__premium_only/class-wpimlend-member.php'; require_once WPIM_LENDING_PATH . 'includes/premium__premium_only/class-wpimlend-premium.php'; } $init = function () { WPIMLend::init(); if ( class_exists( 'WPIMLend_Premium' ) ) { WPIMLend_Premium::init(); } }; if ( did_action( 'wpim_core_loaded' ) ) { $init(); } else { add_action( 'wpim_core_loaded', $init ); } } add_action( 'plugins_loaded', 'wpim_lending_bootstrap', 20 ); /** * Premium features on? Only in the premium build (the folder exists) AND with a valid licence or * trial. Without the SDK (test sites) the folder alone decides; the filter overrides both. */ function wpim_lending_is_premium() { $has_code = is_dir( WPIM_LENDING_PATH . 'includes/premium__premium_only' ); $licensed = $has_code && (!function_exists( 'wpim_lending_fs' ) || wpim_lending_fs()->can_use_premium_code()); return (bool) apply_filters( 'wpim_lending_is_premium', $licensed ); } /** * Where to buy Premium: Freemius pricing when the SDK is loaded, the website otherwise. */ function wpim_lending_upgrade_url() { if ( function_exists( 'wpim_lending_fs' ) ) { return wpim_lending_fs()->get_upgrade_url(); } return 'https://www.wpinventory.com/'; } function wpim_lending_missing_core_notice() { if ( !current_user_can( 'activate_plugins' ) ) { return; } $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=wp-inventory-manager' ), 'install-plugin_wp-inventory-manager' ); printf( '

%s %s

', esc_html__( 'Borrowdesk needs WP Inventory Manager (free or Pro) to be installed and active.', 'borrowdesk' ), esc_url( $url ), esc_html__( 'Install WP Inventory Manager', 'borrowdesk' ) ); } }