-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
177 lines (124 loc) · 3.88 KB
/
functions.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
// Theme foundation
include_once 'includes/config.php';
include_once 'includes/meta.php';
// Add other includes to this file as needed.
function wpse_298888_posts_where( $where, $query ) {
global $wpdb;
$starts_with = esc_sql( $query->get( 'starts_with' ) );
if ( $starts_with ) {
$where .= " AND $wpdb->posts.post_title LIKE '$starts_with%'";
}
return $where;
}
add_filter( 'posts_where', 'wpse_298888_posts_where', 10, 2 );
/**
* Allow Pods Templates to use shortcodes
*/
add_filter( 'pods_shortcode', function( $tags ) {
$tags[ 'shortcodes' ] = true;
return $tags;
});
add_filter( 'get_the_author_description', 'do_shortcode' );
add_image_size( 'square-sixhundred', 600, 600, true);
/**
* Disable the UCF WP Theme's template redirect overrides so that we can
* define our own in this theme.
*
* @since 1.0.0
* @author Jo Dickson
*/
function today_reenable_templates() {
remove_action( 'template_redirect', 'ucfwp_kill_unused_templates' );
}
add_action( 'after_setup_theme', 'today_reenable_templates' );
/*
* Layout function for the UCF RSS Plugin
* Called via this shortcode: [rss-feed url="https://jobs.ucf.edu/cw/en-us/rss" limit="3" layout="hr"]
* On the Prospective Employees page
*/
if ( !function_exists( 'ucf_rss_display_hr_before' ) ) {
function ucf_rss_display_hr_before( $content, $items, $args ) {
ob_start();
?>
<div class="ucf-rss-feed ucf-rss-feed-hr">
<?php
return ob_get_clean();
}
add_filter( 'ucf_rss_display_hr_before', 'ucf_rss_display_hr_before', 10, 3 );
}
if ( !function_exists( 'ucf_rss_display_hr_title' ) ) {
function ucf_rss_display_hr_title( $content, $items, $args ) {
$formatted_title = '';
if ( $args['list_title'] ) {
$formatted_title = '<h2 class="ucf-rss-title">' . $args['list_title'] . '</h2>';
}
return $formatted_title;
}
add_filter( 'ucf_rss_display_hr_title', 'ucf_rss_display_hr_title', 10, 3 );
}
//Adds HR Layout to UCF RSS Feed Plugin
if ( !function_exists( 'ucf_rss_display_hr' ) ) {
function ucf_rss_display_hr( $content, $items, $args ) {
if ( ! is_array( $items ) && $items !== false ) { $items = array( $items ); }
ob_start();
?>
<?php if ( $items ): ?>
<ul class="ucf-rss-items">
<?php foreach ( $items as $item ): ?>
<li class="ucf-rss-item">
<a class="ucf-rss-item-link" href="<?php echo UCF_RSS_Common::get_simplepie_url( $item ); ?>"
title="<?php echo $item->get_date( 'j F Y | g:i a' ); ?>">
<?php echo UCF_RSS_Common::get_simplepie_title( $item ); ?>
<p class="desc"><?php echo UCF_RSS_Common::get_simplepie_description( $item ); ?></p>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<div class="ucf-rss-feed-error">No results found.</div>
<?php endif; ?>
<?php
return ob_get_clean();
}
add_filter( 'ucf_rss_display_hr', 'ucf_rss_display_hr', 10, 3 );
}
if ( !function_exists( 'ucf_rss_display_hr_after' ) ) {
function ucf_rss_display_hr_after( $content, $items, $args ) {
ob_start();
?>
</div>
<?php
return ob_get_clean();
}
add_filter( 'ucf_rss_display_hr_after', 'ucf_rss_display_hr_after', 10, 3 );
}
/*
* Extend Search to Custom Fields
*/
function cf_search_join( $join ) {
global $wpdb;
if ( is_search() ) {
$join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
}
return $join;
}
add_filter('posts_join', 'cf_search_join' );
function cf_search_where( $where ) {
global $pagenow, $wpdb;
if ( is_search() ) {
$where = preg_replace(
"/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
"(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );
}
return $where;
}
add_filter( 'posts_where', 'cf_search_where' );
function cf_search_distinct( $where ) {
global $wpdb;
if ( is_search() ) {
return "DISTINCT";
}
return $where;
}
add_filter( 'posts_distinct', 'cf_search_distinct' );