| @@ -1,45 +1,111 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Plugin Name: Booking Calendar | Appointment Booking | BookIt | |
| 4 | - * Plugin URI: https://bookit.stylemixthemes.com/ | |
| 5 | - * Description: Booking Appointments Calendar. You can easily realize One Time and Recurring Booking with this plugin. | |
| 6 | - * Author: StylemixThemes | |
| 7 | - * Author URI: https://stylemixthemes.com/ | |
| 3 | + * Plugin Name: Bookit — Booking & Appointment Calendar | |
| 4 | + * Plugin URI: https://bookitwp.com/ | |
| 5 | + * Description: Appointment booking and event calendar for WordPress. Services, staff, availability, shortcodes, and email notifications. Prevents double-booking. | |
| 6 | + * Author: The Events Calendar | |
| 7 | + * Author URI: https://theeventscalendar.com/ | |
| 8 | 8 | * License: GNU General Public License v2 or later |
| 9 | - * License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
| 9 | + * License URI: https://www.gnu.org/licenses/gpl-2.0.html | |
| 10 | 10 | * Text Domain: bookit |
| 11 | - * Version: 1.2 | |
| 11 | + * Version: 2.6.0.5 | |
| 12 | + * Requires at least: 6.3 | |
| 13 | + * Requires PHP: 7.4 | |
| 12 | 14 | */ |
| 13 | 15 | |
| 14 | -define('STM_BOOKIT_CALENDAR_FILE', __FILE__); | |
| 15 | -define('STM_BOOKIT_CALENDAR_PATH', dirname(STM_BOOKIT_CALENDAR_FILE)); | |
| 16 | -define('STM_BOOKIT_CALENDAR_URL', plugin_dir_url(STM_BOOKIT_CALENDAR_FILE)); | |
| 16 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 17 | + exit; | |
| 18 | +} | |
| 17 | 19 | |
| 18 | -if (!is_textdomain_loaded('bookit')) { | |
| 19 | - load_plugin_textdomain('bookit', false, 'bookit/languages'); | |
| 20 | +define( 'BOOKIT_VERSION', '2.6.0.5' ); | |
| 21 | +define( 'BOOKIT_DB_VERSION', '2.2.6' ); | |
| 22 | +define( 'BOOKIT_FILE', __FILE__ ); | |
| 23 | +define( 'BOOKIT_PATH', dirname( BOOKIT_FILE ) ); | |
| 24 | +define( 'BOOKIT_INCLUDES_PATH', BOOKIT_PATH . '/includes/' ); | |
| 25 | +define( 'BOOKIT_CLASSES_PATH', BOOKIT_INCLUDES_PATH . 'classes/' ); | |
| 26 | +define( 'BOOKIT_URL', plugin_dir_url( BOOKIT_FILE ) ); | |
| 27 | + | |
| 28 | +$composer_autoload = BOOKIT_PATH . '/vendor/autoload.php'; | |
| 29 | +if ( file_exists( $composer_autoload ) ) { | |
| 30 | + require_once $composer_autoload; | |
| 20 | 31 | } |
| 21 | 32 | |
| 22 | -require_once STM_BOOKIT_CALENDAR_PATH . '/db/tables.php'; | |
| 23 | -require_once STM_BOOKIT_CALENDAR_PATH . '/api/appointment.php'; | |
| 24 | -require_once STM_BOOKIT_CALENDAR_PATH . '/api/user.php'; | |
| 25 | -require_once STM_BOOKIT_CALENDAR_PATH . '/api/calendar.php'; | |
| 26 | -require_once STM_BOOKIT_CALENDAR_PATH . '/user_account/user_dashboard.php'; | |
| 27 | -require_once STM_BOOKIT_CALENDAR_PATH . '/user_account/calendar_page.php'; | |
| 28 | -require_once STM_BOOKIT_CALENDAR_PATH . '/helpers/main.php'; | |
| 33 | +require_once BOOKIT_PATH . '/includes/autoload.php'; | |
| 29 | 34 | |
| 30 | -if (is_admin()) { | |
| 31 | - require_once STM_BOOKIT_CALENDAR_PATH . '/helpers/admin_menu.php'; | |
| 32 | - require_once STM_BOOKIT_CALENDAR_PATH . '/post_type/bookit.post.php'; | |
| 33 | - require_once STM_BOOKIT_CALENDAR_PATH . '/calendar_app/main.php'; | |
| 34 | - require_once(STM_BOOKIT_CALENDAR_PATH . '/helpers/post_type/metaboxes/metabox.php'); | |
| 35 | +if ( ! function_exists( 'bookit_fs' ) ) { | |
| 36 | + // Create a helper function for easy SDK access. | |
| 37 | + function bookit_fs() { | |
| 38 | + global $bookit_fs; | |
| 35 | 39 | |
| 36 | - if (file_exists(dirname(__FILE__) . '/cmb2/init.php')) { | |
| 37 | - require_once dirname(__FILE__) . '/cmb2/init.php'; | |
| 38 | - } elseif (file_exists(dirname(__FILE__) . '/CMB2/init.php')) { | |
| 39 | - require_once dirname(__FILE__) . '/CMB2/init.php'; | |
| 40 | + if ( ! isset( $bookit_fs ) ) { | |
| 41 | + // Load Freemius SDK when installed via Composer. | |
| 42 | + if ( ! function_exists( 'fs_dynamic_init' ) ) { | |
| 43 | + $freemius_start = null; | |
| 44 | + if ( class_exists( \Composer\InstalledVersions::class ) && \Composer\InstalledVersions::isInstalled( 'freemius/wordpress-sdk' ) ) { | |
| 45 | + $freemius_start = \Composer\InstalledVersions::getInstallPath( 'freemius/wordpress-sdk' ) . '/start.php'; | |
| 46 | + } else { | |
| 47 | + $freemius_start = BOOKIT_PATH . '/vendor/freemius/wordpress-sdk/start.php'; | |
| 48 | + } | |
| 49 | + if ( $freemius_start && file_exists( $freemius_start ) ) { | |
| 50 | + require_once $freemius_start; | |
| 51 | + } | |
| 52 | + } | |
| 53 | + | |
| 54 | + if ( function_exists( 'fs_dynamic_init' ) ) { | |
| 55 | + $bookit_fs = fs_dynamic_init( array( | |
| 56 | + 'id' => '8486', | |
| 57 | + 'slug' => 'bookit', | |
| 58 | + 'type' => 'plugin', | |
| 59 | + 'public_key' => 'pk_2cc14bc8c7ec47520d21f0b7d99e7', | |
| 60 | + 'is_premium' => false, | |
| 61 | + 'has_addons' => true, | |
| 62 | + 'has_paid_plans' => false, | |
| 63 | + 'menu' => array( | |
| 64 | + 'slug' => 'bookit', | |
| 65 | + 'first-path' => 'admin.php?page=bookit-settings', | |
| 66 | + 'account' => true, | |
| 67 | + 'contact' => true, | |
| 68 | + 'support' => false, | |
| 69 | + 'addons' => false, | |
| 70 | + ), | |
| 71 | + ) ); | |
| 72 | + } else { | |
| 73 | + $bookit_fs = null; | |
| 74 | + } | |
| 75 | + } | |
| 76 | + | |
| 77 | + return $bookit_fs; | |
| 40 | 78 | } |
| 41 | 79 | |
| 42 | - require_once STM_BOOKIT_CALENDAR_PATH . '/metaboxes/metaboxes.php'; | |
| 43 | - require_once(STM_BOOKIT_CALENDAR_PATH . '/helpers/settings/settings.php'); | |
| 44 | - require_once(STM_BOOKIT_CALENDAR_PATH . '/helpers/services/services.php'); | |
| 45 | -} | |
| 80 | + // Init Freemius. | |
| 81 | + bookit_fs(); | |
| 82 | + // Signal that SDK was initiated. | |
| 83 | + do_action( 'bookit_fs_loaded' ); | |
| 84 | + | |
| 85 | + call_user_func( array( 'Bookit\Classes\Base\Plugin', 'run' ) ); | |
| 86 | +} | |
| 87 | + | |
| 88 | +function bookit_after_upgrade_addon_sync( $prev_version, $new_version ) { | |
| 89 | + if ( '2.1.7' === $new_version && function_exists( 'bookit_fs' ) ) { | |
| 90 | + $bookit_fs = bookit_fs(); | |
| 91 | + if ( $bookit_fs ) { | |
| 92 | + // The true purges the cache. | |
| 93 | + $bookit_fs->get_addons( true ); | |
| 94 | + } | |
| 95 | + } | |
| 96 | +} | |
| 97 | + | |
| 98 | +$bookit_fs = bookit_fs(); | |
| 99 | +if ( $bookit_fs ) { | |
| 100 | + $bookit_fs->add_action( 'plugin_version_update', 'bookit_after_upgrade_addon_sync' ); | |
| 101 | + $bookit_fs->add_action( 'after_uninstall', array( \Bookit\Classes\Base\Plugin::class, 'uninstall' ) ); | |
| 102 | +} | |
| 103 | + | |
| 104 | +/** | |
| 105 | + * remove duplicates 'contact us' | |
| 106 | + * and 'account' for bookit lower than 2.0.0 | |
| 107 | + */ | |
| 108 | +\Bookit\Classes\Admin\SettingsController::removeBookitProFreemiusSubMenuDuplicate(); | |
| 109 | +\Bookit\Classes\Admin\SettingsController::removeBookitContactUsForFreeVersion(); | |
| 110 | + | |
| 111 | +add_action( 'plugins_loaded', 'bookit_load', 0 ); | |