-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
255 lines (199 loc) · 7.16 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<?php
if ( ! isset( $content_width ) )
$content_width = 640;
add_action( 'after_setup_theme', 'revolver_setup' );
if ( ! function_exists( 'revolver_setup' ) ):
function revolver_setup() {
global $revolver_options;
add_editor_style();
add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'automatic-feed-links' );
set_post_thumbnail_size( 160, 194, true );
$revolver_options = get_option( 'revolver_theme_options' );
add_image_size('gallery-image', 800, 525);
//add_image_size('post-thumb-img', 103, 100, true);
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Primary Navigation', 'revolver' ),
) );
register_nav_menus( array(
'top' => __( 'Top Navigation', 'revolver' ),
) );
register_nav_menus( array(
'resources' => __( 'Resources', 'revolver' ),
) );
register_nav_menus( array(
'footer' => __( 'Footer Navigation', 'revolver' ),
) );
}
endif;
add_filter('the_content', 'remove_empty_p', 20, 1);
function remove_empty_p($content){
$content = force_balance_tags($content);
return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
}
function revolver_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'revolver_page_menu_args' );
function revolver_excerpt_length( $length ) {
return 40;
}
add_filter( 'excerpt_length', 'revolver_excerpt_length' );
function revolver_continue_reading_link() {
return __( '', 'revolver' );
}
function revolver_auto_excerpt_more( $more ) {
return ' …' . revolver_continue_reading_link();
}
add_filter( 'excerpt_more', 'revolver_auto_excerpt_more' );
function revolver_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= revolver_continue_reading_link();
}
return $output;
}
add_filter( 'get_the_excerpt', 'revolver_custom_excerpt_more' );
function revolver_widgets_init() {
// Area 1, located at the top of the sidebar.
register_sidebar( array(
'name' => __( 'Primary Widget Area', 'revolver' ),
'id' => 'primary-widget-area',
'description' => __( 'The primary widget area', 'revolver' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Area 2, Located in the bottom right of the footer (Contact Us area)
register_sidebar( array(
'name' => __( 'Footer Bottom Right', 'revolver' ),
'id' => 'footer-right-widget-area',
'description' => __( 'The bottom right footer widget area', 'revolver' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Leadership Widget', 'revolver' ),
'id' => 'leadership-widget',
'description' => __( 'Leadership Widget', 'revolver' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h6>',
'after_title' => '</h6>',
) );
register_sidebar( array(
'name' => __( 'Single Blog Items', 'revolver' ),
'id' => 'single-blog-widget',
'description' => __( 'Single Blog Items', 'revolver' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
}
add_action( 'widgets_init', 'revolver_widgets_init' );
add_filter( 'widget_text', 'do_shortcode' );
function next_link_attributes( $output ) {
$code = 'class="next"';
return str_replace('<a href=', '<a '.$code.' href=', $output);
}
add_filter('next_post_link', 'next_link_attributes');
function previous_link_attributes( $output ) {
$code = 'class="prev"';
return str_replace('<a href=', '<a '.$code.' href=', $output);
}
add_filter('previous_post_link', 'previous_link_attributes');
function next_posts_link_attributes() {
return 'class="nextpostslink"';
}
add_filter('next_posts_link_attributes', 'next_posts_link_attributes');
function prev_posts_link_attributes() {
return 'class="previouspostslink"';
}
add_filter('previous_posts_link_attributes', 'prev_posts_link_attributes');
function revolver_comment_form($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
?>
<li>
<div class="comment-author vcard">
<div class="post-avtar"><?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?></div>
</div>
<div class="post-body">
<div class="comment-meta"><?php echo get_comment_author_link(); ?><span class="bullet time-ago-bullet" aria-hidden="true">•</span></div>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
echo short_time_diff( get_comment_time('U'),current_time('timestamp') );
//printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), ' ', '' );
?>
</div>
<div class="comment-text"><?php comment_text(); ?></div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div>
</div>
</li>
<?php
}
function short_time_diff( $from, $to = '' ) {
$diff = human_time_diff($from,$to);
$replace = array(
'hour' => 'h',
'hours' => 'h',
'day' => 'd',
'days' => 'd',
'mins' => 'm',
' ' =>''
);
return strtr($diff,$replace);
}
//Page Slug Body Class
function add_slug_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes;
}
add_filter( 'body_class', 'add_slug_body_class' );
require_once ( get_template_directory() . '/functions/index.php' );
//enable placeholder for gravity forms
add_filter( 'gform_enable_field_label_visibility_settings', '__return_true' );
//enable anchor for gravity forms
add_filter( 'gform_confirmation_anchor', '__return_true' );
function gallery_share_shortcode( $atts ){
$links = '';
$a = shortcode_atts( array(
'links' => ''
), $atts);
foreach( explode(',',$a['links']) as $type){
$links .= "<a class='$type'></a>";
}
return '<div class="archive-share-buttons">'.$links.'</div>';
}
add_shortcode( 'bpca_share' , 'gallery_share_shortcode');
add_filter("gform_validation_message_1", "change_message", 10, 2);
function change_message($message, $form){
return "<p class='error_msg_form'>To Download RFP Forms, please enter the required information, marked red below.</p>";
}
/* Added By Hire Jordan Smith - 4/22/2015 */
// Anchor all Gravity Forms on submission
add_filter( 'gform_confirmation_anchor', '__return_true' );
add_filter( 'gform_field_validation_1_6', 'custom_validation', 10, 4 );
function custom_validation( $result, $value, $form, $field ) {
if ( ! $result['is_valid'] && trim( $value)!==''){
// $result['is_valid'] = false;
$result['message'] = 'Please put a valid Email';
}
return $result;
}