-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbc-schedule.php
99 lines (83 loc) · 2.66 KB
/
bc-schedule.php
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
93
94
95
96
97
98
99
<?php
/*
*
* Plugin Name: Schedule Manager
* Description: Church Volunteer Schedule.
* Version: 2.0.6
* Author: Belinda Caylor
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
define( 'BC_SCHEDULE_PATH', plugin_dir_path( __FILE__ ) );
define( 'BC_SCHEDULE_URL', plugin_dir_url(__FILE__) );
require_once BC_SCHEDULE_PATH . '/src/database/api/routes.php';
require_once BC_SCHEDULE_PATH . 'admin-functions.php';
register_activation_hook(__FILE__, 'bc_schedule_create_tables');
function bc_schedule_create_tables() {
require_once BC_SCHEDULE_PATH . '/src/database/table-setup.php';
}
/**
* Enqueue scripts and styles for the admin area
*/
function bc_schedule_enqueue_admin_assets( $hook ) {
// Enqueue alpine.js
wp_enqueue_script(
'alpine-js',
'https://cdn.jsdelivr.net/npm/[email protected]/dist/alpine.min.js',
// 'https://cdn.jsdelivr.net/npm/[email protected]/dist/alpine.min.js',
// array(),
null,
true
);
// Enqueue the bundled JavaScript file
wp_enqueue_script(
'bc-schedule-admin-main',
// BC_SCHEDULE_URL . 'dist/admin.js',
BC_SCHEDULE_URL . 'dist/admin.min.js',
array(),
'2.0.6',
true
);
// Enqueue the bundled CSS file
$current_screen = get_current_screen();
if ($current_screen->id === 'toplevel_page_volunteer-schedule') {
wp_enqueue_style(
'bc-schedule-admin-styles',
// BC_SCHEDULE_URL . 'dist/stylesheet.css',
BC_SCHEDULE_URL . 'dist/stylesheet.min.6ed43d264a3c250ff49d.css',
array(),
'2.0.6'
);
}
}
add_action( 'admin_enqueue_scripts', 'bc_schedule_enqueue_admin_assets' );
/**
* Enqueue scripts and styles for the front end
*/
function enqueue_bcs_frontend_scripts() {
wp_enqueue_style(
'bc-schedule-styles',
// BC_SCHEDULE_URL . 'dist/stylesheet.css',
BC_SCHEDULE_URL . 'dist/stylesheet.min.6ed43d264a3c250ff49d.css',
array(),
'2.0.6'
);
$bcs_frontend_data = array(
'ajax_url' => admin_url('admin-ajax.php')
);
// wp_enqueue_script('bcs-frontend', BC_SCHEDULE_URL . '/dist/frontend.js', array('jquery'), false, true);
wp_localize_script('bcs-frontend', 'bcs_frontend_data', $bcs_frontend_data);
}
add_action('wp_enqueue_scripts', 'enqueue_bcs_frontend_scripts');
/**
* Render the schedule on the frontend using a shortcode
*/
require_once BC_SCHEDULE_PATH . '/src/frontend/schedule.php';
function render_schedule_shortcode($atts) {
ob_start();
render_schedule_frontend();
$output = ob_get_clean();
return $output;
}
add_shortcode('bcs_schedule', 'render_schedule_shortcode');