-
Notifications
You must be signed in to change notification settings - Fork 2
/
bu-liaison-inquiry.php
123 lines (100 loc) · 2.84 KB
/
bu-liaison-inquiry.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
* Plugin Name: BU Liaison Inquiry
* Plugin URI: http://developer.bu.edu
* Author: Boston University IS&T (Jonathan Williams)
* Author URI: http://developer.bu.edu
* Description: Provide a form to send data to the Liaison SpectrumEMP API
* Version: 0.8.2
*
* @package BU_Liaison_Inquiry
*/
namespace BU\Plugins\Liaison_Inquiry;
/**
* Composer autoload
*/
require __DIR__ . '/vendor/autoload.php';
$admin = new Admin();
// Initialize the admin settings.
add_action( 'admin_init', array( $admin, 'bu_liaison_inquiry_settings_init' ) );
// Register the page in the admin menu.
add_action( 'admin_menu', array( $admin, 'bu_liaison_inquiry_options_page' ) );
// Instantiate plugin (only once).
if ( ! isset( $GLOBALS['bu_liaison_inquiry'] ) ) {
// Check whether in Dev Mode.
if ( defined( 'BU_LIAISON_INQUIRY_SAMPLE' ) && BU_LIAISON_INQUIRY_SAMPLE ) {
$plugin = new Plugin( Sample_Spectrum_API::class );
} else {
$plugin = new Plugin( Spectrum_API::class );
}
}
$GLOBALS['bu_liaison_inquiry'] = $plugin;
// Assign inquiry form shortcode.
add_shortcode( 'liaison_inquiry_form', array( $plugin, 'liaison_inquiry_form' ) );
// Setup form submission handlers.
add_action( 'admin_post_nopriv_liaison_inquiry', array( $plugin, 'ajax_inquiry_form_post' ) );
add_action( 'admin_post_liaison_inquiry', array( $plugin, 'ajax_inquiry_form_post' ) );
// Register scripts and styles now, enqueue in the shortcode handler.
add_action( 'wp_enqueue_scripts', __namespace__ . '\register_validation_files' );
/**
* Register js form validation scripts so that they may be enqueued later
*/
function register_validation_files() {
wp_register_script(
'jquery-ui',
plugin_dir_url( __FILE__ ) . 'assets/js/jquery/jquery-ui.min.js',
array( 'jquery' ),
null,
true
);
wp_register_script(
'jquery-masked',
plugin_dir_url( __FILE__ ) . 'assets/js/jquery/jquery-masked.js',
array( 'jquery' ),
null,
true
);
wp_register_script(
'jquery-pubsub',
plugin_dir_url( __FILE__ ) . 'assets/js/jquery/jquery-pubsub.js',
array( 'jquery' ),
null,
true
);
wp_register_script(
'iqs-validate',
plugin_dir_url( __FILE__ ) . 'assets/js/iqs/validate.js',
array( 'jquery' ),
null,
true
);
wp_register_script(
'field_rules_form_library',
plugin_dir_url( __FILE__ ) . 'assets/js/field_rules_form_library.js',
array( 'jquery' ),
null,
true
);
wp_register_script(
'field_rules_handler',
plugin_dir_url( __FILE__ ) . 'assets/js/field_rules_handler.js',
array( 'jquery' ),
null,
true
);
wp_register_script(
'bu-liaison-main',
plugin_dir_url( __FILE__ ) . 'assets/js/main.js',
array( 'jquery' ),
null,
true
);
wp_register_style(
'liason-form-style',
plugin_dir_url( __FILE__ ) . 'assets/css/form-style.css'
);
wp_register_style(
'jquery-ui-css',
plugin_dir_url( __FILE__ ) . 'assets/js/jquery/jquery-ui.min.css'
);
}