set_basename( false, __FILE__ );
return;
}
/**
* Currently plugin version.
* Start at version 1.0.0 and use SemVer - https://semver.org
*/
define( 'ABFW_VERSION', '1.0.2' );
define( 'ABFW_FILE', __FILE__ );
define( 'ABFW_PATH', plugin_dir_path( __FILE__ ) );
define( 'ABFW_URL', plugin_dir_url( __FILE__ ) );
/**
* Whether the Pro plan is on sale. Switch it to true once the plan and the Pro
* version exist on the Freemius dashboard: the plugin then offers its plans and
* an upgrade page, and a licence bought there unlocks the paid features.
*/
define( 'ABFW_PAID_PLANS', true );
/**
* Composer autoloader. Bail with an admin notice rather than white-screening when
* dependencies were never installed (someone cloned the repository as is).
*/
if ( !file_exists( ABFW_PATH . 'vendor/autoload.php' ) ) {
add_action( 'admin_notices', function () {
echo '
';
echo esc_html__( 'Abogo Booking for WooCommerce: dependencies are missing. Please contact the plugin support at azouamauriac@gmail.com', 'abogo-booking' );
echo '
';
} );
return;
}
require_once ABFW_PATH . 'vendor/autoload.php';
/*
* Plugin-wide helper functions. Loaded here rather than through Composer's "files"
* autoload: that list runs whenever vendor/autoload.php is included, so the code
* checkers would hit its ABSPATH guard and stop before checking anything.
*/
require_once ABFW_PATH . 'src/Support/functions.php';
if ( !function_exists( 'abfw_fs' ) ) {
/**
* Single Freemius SDK instance for the plugin.
*
* @return Freemius
*/
function abfw_fs() {
global $abfw_fs;
if ( !isset( $abfw_fs ) ) {
require_once ABFW_PATH . 'vendor/freemius/wordpress-sdk/start.php';
$abfw_fs = fs_dynamic_init( array(
'id' => '39866',
'slug' => 'abogo-booking',
'type' => 'plugin',
'public_key' => 'pk_d8706c2d16c12174f9b62e8d6a3a7',
'is_premium' => false,
'premium_suffix' => 'Pro',
'has_addons' => false,
'has_paid_plans' => ABFW_PAID_PLANS,
'is_org_compliant' => true,
'trial' => array(
'days' => 14,
'is_require_payment' => false,
),
'menu' => array(
'slug' => 'abogo_booking',
),
'is_live' => true,
) );
}
return $abfw_fs;
}
abfw_fs();
do_action( 'abfw_fs_loaded' );
// Uninstall cleanup goes through Freemius: it walks every site of a network for us.
if ( abfw_fs() ) {
abfw_fs()->add_action( 'after_uninstall', array(\AdvancedBooking\Uninstaller::class, 'run') );
// Before the licensing service decides on its own trial offer.
add_action( 'admin_init', array(\AdvancedBooking\Admin\Notices::class, 'replace_licensing_trial_offer'), 1 );
}
}
register_activation_hook( __FILE__, array(\AdvancedBooking\Activator::class, 'activate') );
register_deactivation_hook( __FILE__, array(\AdvancedBooking\Deactivator::class, 'deactivate') );
/**
* Declare HPOS and Cart/Checkout Blocks compatibility: bookings are stored in the
* plugin's own tables and orders are never written to directly.
*/
add_action( 'before_woocommerce_init', function () {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true );
}
} );
/*
* PHP declares the functions of a file before running it, unless they sit in a
* condition: these wait until the check at the top has let this copy of the plugin run.
*/
if ( !function_exists( 'abfw_run' ) ) {
/** Admin notice shown when the required WooCommerce plugin is inactive. */
function abfw_woocommerce_missing_notice() {
echo '';
echo esc_html__( 'Abogo Booking for WooCommerce requires WooCommerce to be installed and active.', 'abogo-booking' );
echo '
';
}
/**
* Bootstrap on plugins_loaded so the WooCommerce classes exist, and bail with a
* notice rather than fatally erroring when WooCommerce is absent.
*/
function abfw_run() {
if ( !class_exists( 'WooCommerce' ) ) {
add_action( 'admin_notices', 'abfw_woocommerce_missing_notice' );
return;
}
$plugin = new \AdvancedBooking\Plugin();
$plugin->run();
}
/**
* Add a "Settings" shortcut to the plugins list.
*
* @param array $links Existing action links.
* @return array
*/
function abfw_plugin_action_links( $links ) {
$settings_url = admin_url( 'admin.php?page=abogo_booking' );
$settings_link = '' . esc_html__( 'Settings', 'abogo-booking' ) . '';
array_unshift( $links, $settings_link );
return $links;
}
}
add_action( 'plugins_loaded', 'abfw_run' );
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'abfw_plugin_action_links' );