-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathccc-wor-camping.php
More file actions
92 lines (77 loc) · 3.18 KB
/
ccc-wor-camping.php
File metadata and controls
92 lines (77 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* Plugin Name: CCC WOR Camping
* Description: Campground reservations with annual customers for Week of Rivers event
* Version: 1.0.0
* Author: Rick Steeves, Carolina Canoe Club
* Text Domain: ccc-wor-camping
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
// Define plugin constants
define('CCC_WOR_PLUGIN_URL', plugin_dir_url(__FILE__));
define('CCC_WOR_PLUGIN_PATH', plugin_dir_path(__FILE__));
define('CCC_WOR_VERSION', '1.0.0');
class CCC_WOR_Camping {
public function __construct() {
add_action('plugins_loaded', array($this, 'init'));
register_activation_hook(__FILE__, array($this, 'activate'));
register_deactivation_hook(__FILE__, array($this, 'deactivate'));
}
public function init() {
// Load required files
$this->load_dependencies();
// Initialize components
new CCC_WOR_Admin();
new CCC_WOR_Frontend();
new CCC_WOR_Email();
new CCC_WOR_WooCommerce();
new CCC_WOR_Cron();
}
private function load_dependencies() {
require_once CCC_WOR_PLUGIN_PATH . 'includes/class-database.php';
require_once CCC_WOR_PLUGIN_PATH . 'includes/class-admin.php';
require_once CCC_WOR_PLUGIN_PATH . 'includes/class-frontend.php';
require_once CCC_WOR_PLUGIN_PATH . 'includes/class-email.php';
require_once CCC_WOR_PLUGIN_PATH . 'includes/class-woocommerce.php';
require_once CCC_WOR_PLUGIN_PATH . 'includes/class-cron.php';
require_once CCC_WOR_PLUGIN_PATH . 'includes/functions.php';
}
public function activate() {
// Load database class
require_once CCC_WOR_PLUGIN_PATH . 'includes/class-database.php';
// Create database tables
$database = new CCC_WOR_Database();
$database->create_tables();
// Set default options
$this->set_default_options();
// Schedule cron jobs
if (!wp_next_scheduled('ccc_wor_cleanup_pending_reservations')) {
wp_schedule_event(time(), 'hourly', 'ccc_wor_cleanup_pending_reservations');
}
}
public function deactivate() {
// Clear scheduled events
wp_clear_scheduled_hook('ccc_wor_cleanup_pending_reservations');
}
private function set_default_options() {
$defaults = array(
'annual_start_date' => date('Y') . '-05-01', // May 1st of current year
'general_availability_date' => date('Y') . '-06-01', // June 1st of current year
'event_start_date' => date('Y') . '-06-26',
'event_end_date' => date('Y') . '-07-05',
'transaction_timeout' => 30,
'reservation_url' => 'https://wor.carolinacanoeclub.org/week-of-rivers-reservations/',
'campground_image_url' => 'https://smokymtnmeadows.com/sitemap/'
);
foreach ($defaults as $key => $value) {
if (get_option('ccc_wor_' . $key) === false) {
update_option('ccc_wor_' . $key, $value);
}
}
}
}
// Initialize the plugin
new CCC_WOR_Camping();