-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
159 lines (141 loc) · 5.91 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
<?php
/*
Author: Zhen Huang
URL: http://themefortress.com/
This place is much cleaner. Put your theme specific codes here,
anything else you may want to use plugins to keep things tidy.
*/
/*
1. lib/clean.php
- head cleanup
- post and images related cleaning
*/
require_once('lib/clean.php'); // do all the cleaning and enqueue here
/*
2. lib/enqueue-style.php
- enqueue Foundation and Reverie CSS
*/
require_once('lib/enqueue-style.php');
/*
3. lib/foundation.php
- add pagination
*/
require_once('lib/foundation.php'); // load Foundation specific functions like top-bar
/*
4. lib/nav.php
- custom walker for top-bar and related
*/
require_once('lib/nav.php'); // filter default wordpress menu classes and clean wp_nav_menu markup
/*
5. lib/presstrends.php
- add PressTrends, tracks how many people are using Reverie
*/
require_once('lib/presstrends.php'); // load PressTrends to track the usage of Reverie across the web, comment this line if you don't want to be tracked
/**********************
Add theme supports
**********************/
if( ! function_exists( 'reverie_theme_support' ) ) {
function reverie_theme_support() {
// Add language supports.
load_theme_textdomain('reverie', get_template_directory() . '/lang');
// Add post thumbnail supports. http://codex.wordpress.org/Post_Thumbnails
add_theme_support('post-thumbnails');
set_post_thumbnail_size(300, 300);
add_image_size('fd-lrg', 1024, 99999);
add_image_size('fd-med', 768, 99999);
add_image_size('fd-sm', 320, 9999);
// rss thingy
add_theme_support('automatic-feed-links');
// Add post formats support. http://codex.wordpress.org/Post_Formats
add_theme_support('post-formats', array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat'));
// Add menu support. http://codex.wordpress.org/Function_Reference/register_nav_menus
add_theme_support('menus');
register_nav_menus(array(
'primary' => __('Primary Navigation', 'reverie'),
'additional' => __('Additional Navigation', 'reverie'),
'utility' => __('Utility Navigation', 'reverie'),
'off-canvas' => __('Off Canvas Navigation', 'reverie')
));
// Add custom background support
add_theme_support( 'custom-background',
array(
'default-image' => '', // background image default
'default-color' => '', // background color default (dont add the #)
'wp-head-callback' => '_custom_background_cb',
'admin-head-callback' => '',
'admin-preview-callback' => ''
)
);
}
}
add_action('after_setup_theme', 'reverie_theme_support'); /* end Reverie theme support */
// create widget areas: sidebar, footer
$sidebars = array('Sidebar');
foreach ($sidebars as $sidebar) {
register_sidebar(array('name'=> $sidebar,
'id' => 'Sidebar',
'before_widget' => '<article id="%1$s" class="panel widget %2$s">',
'after_widget' => '</article>',
'before_title' => '<h4>',
'after_title' => '</h4>'
));
}
$sidebars = array('Footer');
foreach ($sidebars as $sidebar) {
register_sidebar(array('name'=> $sidebar,
'id' => 'Footer',
'before_widget' => '<div class="large-4 columns"><article id="%1$s" class="widget %2$s">',
'after_widget' => '</article></div>',
'before_title' => '<h4>',
'after_title' => '</h4><hr>'
));
}
// return entry meta information for posts, used by multiple loops, you can override this function by defining them first in your child theme's functions.php file
if ( ! function_exists( 'reverie_entry_meta' ) ) {
function reverie_entry_meta() {
echo '<span class="byline author">'. __('Written by', 'reverie') .' <a href="'. 'mailto:' . get_the_author_meta( 'user_email', get_the_author_meta('ID') ) .'" rel="author" class="fn">'. get_the_author() .', </a></span>';
echo '<time class="updated" datetime="'. get_the_time('c') .'" pubdate>'. get_the_time('F jS, Y') .'</time>';
}
};
/**
* UTHSC Functions.
*/
function custom_excerpt_length( $length ) {
return 50;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
function new_excerpt_more( $more ) {
return '… <a class="read-more" href="'. get_permalink( get_the_ID() ) . '"><strong>' . __('Read More', 'uthsc') . '</strong></a>';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );
//WPUFE Javascript
function wpufe_javascript() {
if ( is_page('new-announcement') ) {
?>
<script type="text/javascript">
(function($) {
function limitText(field, maxChar){
var ref = $(field),
val = ref.val();
if ( val.length >= maxChar ) {
ref.val(val.substr(0, maxChar));
}
}
$( "label[for=wpuf-post_excerpt]" ).append( '<span class="announcement-excerpt-tooltip" style="display: none;"><span style="font-size:.9em;">The message that will appear in the campus emails. Make sure to include any details you want to appear in the email. <strong>Don\'t repeat the title here or it will appear twice!</strong></span></div>')
$('#post_excerpt').on('focus', function(event) {
$( ".announcement-excerpt-tooltip" ).show("fast");
});
$('#post_excerpt').on('focusout', function(event) {
$( '.announcement-excerpt-tooltip' ).hide("fast");
});
// Insert Limitations here
$('#post_excerpt').on('keyup', function(event) {
limitText(this, 400);
$( ".excerpt-char-count" ).html( 400 - $(this).val().length );
});
})(jQuery);
</script>
<?php
}
}
add_action( 'wp_footer', 'wpufe_javascript',20 );