-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.php
More file actions
97 lines (82 loc) · 3.19 KB
/
functions.php
File metadata and controls
97 lines (82 loc) · 3.19 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
93
94
95
96
97
<?php
require get_theme_file_path('/inc/search-route.php');
function university_custom_rest() {
register_rest_field('post', 'authorName', array(
'get_callback' => function() { return get_the_author(); }
));
}
add_action('rest_api_init', 'university_custom_rest');
function pageBanner($args = NULL) {
if ( !$args['title'] ) {
$args['title'] = get_the_title();
}
if ( !$args['subtitle'] ) {
$args['subtitle'] = get_field('page_banner_subtitle');
}
if ( !$args['bgImage'] ) {
$args['bgImage'] = get_field('page_banner_background_image')['sizes']['pageBanner'];
if ( ! $args['bgImage'] ) {
$args['bgImage'] = get_theme_file_uri('/images/ocean.jpg');
}
}
?>
<div class="page-banner">
<div class="page-banner__bg-image" style="background-image: url(<?php echo $args['bgImage']; ?>);">
</div>
<div class="page-banner__content container container--narrow">
<h1 class="page-banner__title"><?php echo $args['title']; ?></h1>
<div class="page-banner__intro">
<p><?php echo $args['subtitle']; ?></p>
</div>
</div>
</div>
<?php
}
// load CSS and javascript files
function university_files() {
wp_enqueue_script('googleMap', '//maps.googleapis.com/maps/api/js?key=AIzaSyAscX0N2UhDyc166yI8HgIS6Pmg0zG_9T4', NULL, 1.0, true );
wp_enqueue_script('main-university-js', get_theme_file_uri('/js/scripts-bundled.js'), NULL, microtime(), true );
wp_enqueue_style('custom-google-fonts', '//fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i|Roboto:100,300,400,400i,700,700i');
wp_enqueue_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
wp_enqueue_style('university_main_styles', get_stylesheet_uri());
wp_localize_script('main-university-js', 'universityData', array(
'root_url' => get_site_url()
));
}
add_action('wp_enqueue_scripts', 'university_files');
function university_features(){
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
add_image_size('professorLandscape', 400, 260, true);
add_image_size('professorPortrait', 480, 650, true);
add_image_size('pageBanner', 1500, 350, true);
}
add_action('after_setup_theme', 'university_features');
function university_adjust_queries($query) {
if ( !is_admin() AND is_post_type_archive('campus') AND $query->is_main_query() ) {
$query->set('posts_per_page', -1);
}
if ( !is_admin() AND is_post_type_archive('event') AND $query->is_main_query() ) {
$today = date('Ymd');
$query->set('meta_key', 'event_date');
$query->set('orderby', 'meta_value_num');
$query->set('order', 'ASC');
$query->set('meta_query', array(
'key' => 'event_date',
'compare' => '>=',
'value' => $today,
'type' => 'numeric'
));
}
if ( !is_admin() AND is_post_type_archive('program') AND $query->is_main_query() ) {
$query->set('orderby', 'title');
$query->set('order', 'ASC');
$query->set('posts_per_page', -1);
}
}
add_action('pre_get_posts', 'university_adjust_queries' );
function universityMapKey($api) {
$api['key'] = 'AIzaSyAscX0N2UhDyc166yI8HgIS6Pmg0zG_9T4';
return $api;
}
add_filter('acf/fields/google_map/api', universityMapKey);