first commit
This commit is contained in:
120
wp-content/plugins/yacht-booking-system/yacht-booking-system.php
Normal file
120
wp-content/plugins/yacht-booking-system/yacht-booking-system.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Yacht Booking System
|
||||
* Plugin URI: https://jachty.pagedev.pl
|
||||
* Description: System rezerwacji jachtów z kalendarzem i integracją z Google Calendar
|
||||
* Version: 1.0.0
|
||||
* Author: PageDev
|
||||
* Author URI: https://pagedev.pl
|
||||
* Text Domain: yacht-booking
|
||||
* Domain Path: /languages
|
||||
* Requires at least: 6.0
|
||||
* Requires PHP: 7.4
|
||||
* License: GPL v2 or later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Define plugin constants
|
||||
define( 'YACHT_BOOKING_VERSION', '1.0.0' );
|
||||
define( 'YACHT_BOOKING_PLUGIN_FILE', __FILE__ );
|
||||
define( 'YACHT_BOOKING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||
define( 'YACHT_BOOKING_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||
define( 'YACHT_BOOKING_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
||||
|
||||
/**
|
||||
* PSR-4 Autoloader for plugin classes
|
||||
*/
|
||||
spl_autoload_register( function( $class ) {
|
||||
// Project namespace prefix
|
||||
$prefix = 'YachtBooking\\';
|
||||
|
||||
// Base directory for the namespace prefix
|
||||
$base_dir = YACHT_BOOKING_PLUGIN_DIR . 'includes/';
|
||||
|
||||
// Does the class use the namespace prefix?
|
||||
$len = strlen( $prefix );
|
||||
if ( strncmp( $prefix, $class, $len ) !== 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the relative class name
|
||||
$relative_class = substr( $class, $len );
|
||||
|
||||
// Replace namespace separators with directory separators
|
||||
// Convert to lowercase and prepend 'class-'
|
||||
$file = $base_dir . 'class-' . str_replace( '\\', '/', strtolower( str_replace( '_', '-', $relative_class ) ) ) . '.php';
|
||||
|
||||
// If the file exists, require it
|
||||
if ( file_exists( $file ) ) {
|
||||
require $file;
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* Plugin activation hook
|
||||
*/
|
||||
function yacht_booking_activate() {
|
||||
// Load installer class
|
||||
require_once YACHT_BOOKING_PLUGIN_DIR . 'includes/class-installer.php';
|
||||
|
||||
$installer = new YachtBooking\Installer();
|
||||
$installer->install();
|
||||
|
||||
// Setup Google Calendar cron jobs
|
||||
require_once YACHT_BOOKING_PLUGIN_DIR . 'integrations/google-calendar/class-sync-controller.php';
|
||||
YachtBooking\Integrations\GoogleCalendar\Sync_Controller::setup_cron();
|
||||
|
||||
// Setup iCal import cron
|
||||
require_once YACHT_BOOKING_PLUGIN_DIR . 'integrations/ical/class-ical-import.php';
|
||||
YachtBooking\Integrations\ICal\ICal_Import::setup_cron();
|
||||
|
||||
// Flush rewrite rules
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
register_activation_hook( __FILE__, 'yacht_booking_activate' );
|
||||
|
||||
/**
|
||||
* Plugin deactivation hook
|
||||
*/
|
||||
function yacht_booking_deactivate() {
|
||||
// Clear Google Calendar cron jobs
|
||||
require_once YACHT_BOOKING_PLUGIN_DIR . 'integrations/google-calendar/class-sync-controller.php';
|
||||
YachtBooking\Integrations\GoogleCalendar\Sync_Controller::clear_cron();
|
||||
|
||||
// Clear iCal import cron
|
||||
require_once YACHT_BOOKING_PLUGIN_DIR . 'integrations/ical/class-ical-import.php';
|
||||
YachtBooking\Integrations\ICal\ICal_Import::clear_cron();
|
||||
|
||||
// Flush rewrite rules
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
register_deactivation_hook( __FILE__, 'yacht_booking_deactivate' );
|
||||
|
||||
/**
|
||||
* Initialize the plugin
|
||||
*/
|
||||
function yacht_booking_init() {
|
||||
// Load plugin main class
|
||||
require_once YACHT_BOOKING_PLUGIN_DIR . 'includes/class-yacht-booking.php';
|
||||
|
||||
// Get instance
|
||||
YachtBooking\Yacht_Booking::get_instance();
|
||||
}
|
||||
add_action( 'plugins_loaded', 'yacht_booking_init', 10 );
|
||||
|
||||
/**
|
||||
* Load plugin textdomain
|
||||
*/
|
||||
function yacht_booking_load_textdomain() {
|
||||
load_plugin_textdomain(
|
||||
'yacht-booking',
|
||||
false,
|
||||
dirname( YACHT_BOOKING_PLUGIN_BASENAME ) . '/languages'
|
||||
);
|
||||
}
|
||||
add_action( 'init', 'yacht_booking_load_textdomain' );
|
||||
Reference in New Issue
Block a user