set_basename( false, __FILE__ ); } else { /** * DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE * `function_exists` CALL ABOVE TO PROPERLY WORK. */ if ( ! function_exists( 'webcal_fs' ) ) { // Load scoped vendor dependencies (built by bin/build-release.sh for distribution). if ( file_exists( WEBCALENDAR_WP_PATH . 'vendor-prefixed/autoload.php' ) ) { require_once WEBCALENDAR_WP_PATH . 'vendor-prefixed/autoload.php'; } // Autoload dependencies. if ( file_exists( WEBCALENDAR_WP_PATH . 'vendor/autoload.php' ) ) { require_once WEBCALENDAR_WP_PATH . 'vendor/autoload.php'; } // Load Freemius SDK (guarded so tests work without it). $webcal_freemius_init = WEBCALENDAR_WP_PATH . 'freemius-init.php'; if ( file_exists( WEBCALENDAR_WP_PATH . 'freemius/start.php' ) && file_exists( $webcal_freemius_init ) ) { require_once $webcal_freemius_init; } } /** * The code that runs during plugin activation. * This action is documented in src/Activator.php */ function webcal_activate_plugin(): void { require_once WEBCALENDAR_WP_PATH . 'src/Activator.php'; \WebCalendar\WP\Activator::activate(); } /** * The code that runs during plugin deactivation. * This action is documented in src/Deactivator.php */ function webcal_deactivate_plugin(): void { require_once WEBCALENDAR_WP_PATH . 'src/Deactivator.php'; \WebCalendar\WP\Deactivator::deactivate(); } register_activation_hook( __FILE__, 'webcal_activate_plugin' ); register_deactivation_hook( __FILE__, 'webcal_deactivate_plugin' ); /** * Cleanup data on uninstall (opt-in via Settings). * * Hooked to Freemius after_uninstall so Freemius can track the * uninstall event and collect user feedback before data is removed. */ function webcal_fs_uninstall_cleanup() { $delete_data = get_option( 'webcal_delete_data_on_uninstall' ); if ( 'yes' !== $delete_data ) { return; } global $wpdb; $tables = [ 'webcal_entry', 'webcal_entry_repeats', 'webcal_entry_repeats_not', 'webcal_entry_user', 'webcal_categories', 'webcal_entry_categories', 'webcal_user_pref', 'webcal_config', 'webcal_entry_log', 'webcal_reminders', 'webcal_site_extras', 'webcal_import', 'webcal_import_data', 'webcal_nonuser_cals', ]; foreach ( $tables as $table ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.SchemaChange $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $wpdb->prefix . $table ) ); } delete_option( 'webcalendar_wp_db_version' ); delete_option( 'webcal_license_tier' ); delete_option( 'webcal_license_key' ); delete_option( 'webcal_license_dev_override' ); delete_option( 'webcal_single_event_pages' ); delete_option( 'webcal_google_maps_api_key' ); delete_option( 'webcal_delete_data_on_uninstall' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", 'webcal\_config\_%' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", 'webcal\_featured\_image\_%' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", 'webcal\_attachments\_%' ) ); } // Hook uninstall cleanup to Freemius (runs after uninstall tracking). if ( function_exists( 'webcal_fs' ) ) { webcal_fs()->add_action( 'after_uninstall', 'webcal_fs_uninstall_cleanup' ); } require_once WEBCALENDAR_WP_PATH . 'src/functions.php'; require_once WEBCALENDAR_WP_PATH . 'src/Plugin.php'; $webcal_plugin = new \WebCalendar\WP\Plugin(); $webcal_plugin->run(); }