generated from uriweb/uri-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uri-tuition-calculator.php
76 lines (65 loc) · 2.24 KB
/
uri-tuition-calculator.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
<?php
/**
* Plugin Name: URI Tuition Calculator
* Plugin URI: http://www.uri.edu
* Description: A calculator for course tuition and fees
* Version: 1.3.0
* Author: URI Web Communications
* Author URI: https://www.uri.edu/
*
* @author: Brandon Fuller <[email protected]>
* @author: Alexandra Gauss <[email protected]>
* @author: Sarah Pucino <[email protected]>
* @package uri-tuition-calculator
*/
// Block direct requests
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
define( 'URI_TUITION_CALCULATOR_PATH', plugin_dir_path( __FILE__ ) );
define( 'URI_TUITION_CALCULATOR_URL', str_replace( '/assets', '/', plugins_url( 'assets', __FILE__ ) ) );
/**
* Returns version from package.json to be used for cache busting
*
* @return str
*/
function uri_tuition_calculator_cache_buster() {
static $cache_buster;
if ( empty( $cache_buster ) && function_exists( 'get_plugin_data' ) ) {
$values = get_plugin_data( URI_TUITION_CALCULATOR_PATH . 'uri-tuition-calculator.php', false );
$cache_buster = $values['Version'];
} else {
$cache_buster = gmdate( 'Ymd', strtotime( 'now' ) );
}
return $cache_buster;
}
// Include the admin settings screen
include_once( URI_TUITION_CALCULATOR_PATH . 'inc/uri-tuition-calculator-settings.php' );
/**
* Include css and js
*/
function uri_tuition_calculator_enqueues() {
wp_register_style( 'uri-tuition-calculator-css', plugins_url( '/css/style.built.css', __FILE__ ), array(), uri_tuition_calculator_cache_buster(), 'all' );
wp_enqueue_style( 'uri-tuition-calculator-css' );
wp_register_script( 'uri-tuition-calculator-js', plugins_url( '/js/script.built.js', __FILE__ ), array(), uri_tuition_calculator_cache_buster(), true );
wp_enqueue_script( 'uri-tuition-calculator-js' );
$spreadsheet = get_option( 'uri_tuition_calculator_spreadsheet' );
wp_localize_script(
'uri-tuition-calculator-js',
'spreadsheet',
array(
'text' => $spreadsheet,
)
);
$term = get_option( 'uri_tuition_calculator_term' );
wp_localize_script(
'uri-tuition-calculator-js',
'term',
array(
'text' => $term,
)
);
}
add_action( 'wp_enqueue_scripts', 'uri_tuition_calculator_enqueues' );
// Include shortcodes
include( URI_TUITION_CALCULATOR_PATH . 'inc/uri-tuition-calculator-shortcodes.php' );