generated from uriweb/uri-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uri-ticks.php
159 lines (132 loc) · 3.13 KB
/
uri-ticks.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
* Plugin Name: URI Ticks
* Plugin URI: http://www.uri.edu
* Description: Creates custom posts, fields, and interaction for URI Tick Encounter data
* Version: 1.2.0
* Author: URI Web Communications
* Author URI: https://today.uri.edu/
*
* @author: Brandon Fuller <[email protected]>
* @package uri-ticks
*/
// Block direct requests
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
define( 'URI_TICKS_DIR_PATH', plugin_dir_path( __FILE__ ) );
define( 'URI_TICKS_IMAGES', plugins_url( 'i', __FILE__ ) );
/**
* Returns version from package.json to be used for cache busting
*
* @return str
*/
function uri_ticks_cache_buster() {
static $cache_buster;
if ( empty( $cache_buster ) && function_exists( 'get_plugin_data' ) ) {
$values = get_plugin_data( URI_TICKS_DIR_PATH . 'uri-ticks.php', false );
$cache_buster = $values['Version'];
} else {
$cache_buster = gmdate( 'Ymd', strtotime( 'now' ) );
}
return $cache_buster;
}
/**
* Include css and js
*/
function uri_ticks_enqueues() {
wp_register_style( 'uri-ticks-css', plugins_url( '/css/style.built.css', __FILE__ ), array(), uri_ticks_cache_buster(), 'all' );
wp_enqueue_style( 'uri-ticks-css' );
wp_register_script( 'uri-ticks-js', plugins_url( '/js/script.built.js', __FILE__ ), array(), uri_ticks_cache_buster(), true );
wp_enqueue_script( 'uri-ticks-js' );
}
add_action( 'wp_enqueue_scripts', 'uri_ticks_enqueues' );
/**
* Return an array of regions
*/
function uri_ticks_get_the_regions() {
return array(
'en-central' => 'Northeast Central',
'es-central' => 'Southeast Central',
'mid-atlantic' => 'Mid Atlantic',
'mountain' => 'Mountain',
'new-england' => 'New England',
'pacific' => 'Pacific',
'south-atlantic' => 'South Atlantic',
'wn-central' => 'Northwest Central',
'ws-central' => 'Southwest Central',
);
}
/**
* Return an array of months
*/
function uri_ticks_get_the_months() {
return array(
'january',
'february',
'march',
'april',
'may',
'june',
'july',
'august',
'september',
'october',
'november',
'december',
);
}
/**
* Return category or tag names
*
* @param str $type specify 'cats' or 'tags'.
*/
function uri_ticks_return_cat_names( $type = 'cats' ) {
switch ( $type ) {
case 'cats':
$cats = get_the_category();
break;
case 'tags':
$cats = get_the_tags();
break;
}
$names = array();
foreach ( $cats as $c ) {
array_push( $names, $c->name );
}
return $names;
}
/**
* Wrapper for Advanced Custom Fields get_field()
*/
function uri_ticks_get_field() {
$r = false;
if ( function_exists( 'get_field' ) ) {
$r = call_user_func_array( 'get_field', func_get_args() );
}
return $r;
}
/**
* Settings
*/
include( URI_TICKS_DIR_PATH . '/inc/settings.php' );
/**
* Custom fields
*/
include( URI_TICKS_DIR_PATH . '/inc/post-types.php' );
/**
* Custom taxonomy
*/
include( URI_TICKS_DIR_PATH . '/inc/taxonomy.php' );
/**
* Layout options
*/
include( URI_TICKS_DIR_PATH . '/inc/layout-options.php' );
/**
* Tick Map shortcode
*/
include( URI_TICKS_DIR_PATH . '/inc/tick-map.php' );
/**
* Display Tick Diseases shortcode
*/
include( URI_TICKS_DIR_PATH . '/inc/display-tick-phases.php' );