/
functions.php
436 lines (395 loc) · 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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
<?php
/**
* Title: Function
*
* Description: Defines theme specific functions including actions and filters.
*
* Please do not edit this file. This file is part of the Cyber Chimps Framework and all modifications
* should be made in a child theme.
*
* @category Cyber Chimps Framework
* @package Framework
* @since 1.0
* @author CyberChimps
* @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
* @link http://www.cyberchimps.com/
*/
// Load Core
require_once( get_template_directory() . '/cyberchimps/init.php' );
// Set the content width based on the theme's design and stylesheet.
if ( ! isset( $content_width ) )
$content_width = 640; /* pixels */
// Define site info
function cyberchimps_add_site_info() { ?>
<p>© Company Name</p>
<?php }
add_action('cyberchimps_site_info', 'cyberchimps_add_site_info');
if ( ! function_exists( 'cyberchimps_comment' ) ) :
// Template for comments and pingbacks.
// Used as a callback by wp_list_comments() for displaying the comments.
function cyberchimps_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p><?php _e( 'Pingback:', 'cyberchimps' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'cyberchimps' ), ' ' ); ?></p>
<?php
break;
default :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<article id="comment-<?php comment_ID(); ?>" class="comment">
<footer>
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 40 ); ?>
<?php printf( '%s <span class="says">' . __( 'says:', 'cyberchimps' ) . '</span>', sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
</div><!-- .comment-author .vcard -->
<?php if ( $comment->comment_approved == '0' ) : ?>
<em><?php _e( 'Your comment is awaiting moderation.', 'cyberchimps' ); ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata">
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><time pubdate datetime="<?php comment_time( 'c' ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __( '%1$s at %2$s', 'cyberchimps' ), get_comment_date(), get_comment_time() ); ?>
</time></a>
<?php edit_comment_link( __( '(Edit)', 'cyberchimps' ), ' ' );
?>
</div><!-- .comment-meta .commentmetadata -->
</footer>
<div class="comment-content"><?php comment_text(); ?></div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
</article><!-- #comment-## -->
<?php
break;
endswitch;
}
endif; // ends check for cyberchimps_comment()
if ( ! function_exists( 'cyberchimps_posted_on' ) ) :
//Prints HTML with meta information for the current post-date/time and author.
function cyberchimps_posted_on() {
if( is_single() ) {
$show_date = ( cyberchimps_get_option( 'single_post_byline_date', 1 ) ) ? cyberchimps_get_option( 'single_post_byline_date', 1 ) : false;
}
elseif( is_archive() ) {
$show_date = ( cyberchimps_get_option( 'archive_post_byline_date', 1 ) ) ? cyberchimps_get_option( 'archive_post_byline_date', 1 ) : false;
}
else {
$show_date = ( cyberchimps_get_option( 'post_byline_date', 1 ) ) ? cyberchimps_get_option( 'post_byline_date', 1 ) : false;
}
$posted_on = sprintf( '<div class="cyberchimps-posted-on"><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s"><p class="cc-month">%4$s</p><p class="cc-day">%5$s</p><p class="cc-year">%6$s</p></time></a></div>',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date( 'M' ) ),
esc_html( get_the_date( 'j' ) ),
esc_html( get_the_date( 'Y' ) )
);
apply_filters( 'cyberchimps_posted_on', $posted_on );
if( $show_date ) {
echo $posted_on;
}
}
endif;
function cyberchimps_author() {
if( is_single() ) {
$show_author = ( cyberchimps_get_option( 'single_post_byline_author', 1 ) ) ? cyberchimps_get_option( 'single_post_byline_author', 1 ) : false;
}
elseif( is_archive() ) {
$show_author = ( cyberchimps_get_option( 'archive_post_byline_author', 1 ) ) ? cyberchimps_get_option( 'archive_post_byline_author', 1 ) : false;
}
else {
$show_author = ( cyberchimps_get_option( 'post_byline_author', 1 ) ) ? cyberchimps_get_option( 'post_byline_author', 1 ) : false;
}
$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( get_the_author() ),
esc_html( get_the_author() )
);
if( $show_author ) {
echo $author;
}
}
//add meta entry category to single post, archive and blog list if set in options
function cyberchimps_posted_in() {
global $post;
if( is_single() ) {
$show = ( cyberchimps_get_option( 'single_post_byline_categories', 1 ) ) ? cyberchimps_get_option( 'single_post_byline_categories', 1 ) : false;
}
elseif( is_archive() ) {
$show = ( cyberchimps_get_option( 'archive_post_byline_categories', 1 ) ) ? cyberchimps_get_option( 'archive_post_byline_categories', 1 ) : false;
}
else {
$show = ( cyberchimps_get_option( 'post_byline_categories', 1 ) ) ? cyberchimps_get_option( 'post_byline_categories', 1 ) : false;
}
if( $show ):
$categories_list = get_the_category_list( ', ' );
if ( $categories_list ) :
$cats = sprintf( __( 'Posted in', 'cyberchimps' ) . ' %1$s', $categories_list );
?>
<span class="cat-links">
<?php echo apply_filters( 'cyberchimps_post_categories', $cats ); ?>
</span>
<span class="sep"> <?php echo apply_filters( 'cyberchimps_entry_meta_sep', '|' ); ?> </span>
<?php endif;
endif;
}
//add meta entry tags to single post, archive and blog list if set in options
function cyberchimps_post_tags() {
global $post;
if( is_single() ) {
$show = ( cyberchimps_get_option( 'single_post_byline_tags', 1 ) ) ? cyberchimps_get_option( 'single_post_byline_tags', 1 ) : false;
}
elseif( is_archive() ) {
$show = ( cyberchimps_get_option( 'archive_post_byline_tags', 1 ) ) ? cyberchimps_get_option( 'archive_post_byline_tags', 1 ) : false;
}
else {
$show = ( cyberchimps_get_option( 'post_byline_tags', 1 ) ) ? cyberchimps_get_option( 'post_byline_tags', 1 ) : false;
}
if( $show ):
$tags_list = get_the_tag_list( '', ', ' );
if ( $tags_list ) :
$tags = sprintf( __( 'Tags:', 'cyberchimps' ) . ' %1$s', $tags_list );
?>
<span class="tag-links">
<?php echo apply_filters( 'cyberchimps_post_tags', $tags ); ?>
</span>
<span class="sep"> <?php echo apply_filters( 'cyberchimps_entry_meta_sep', '|' ); ?> </span>
<?php endif; // End if $tags_list
endif;
}
//add meta entry comments to single post, archive and blog list if set in options
function cyberchimps_post_comments() {
global $post;
if( is_single() ) {
$show = ( cyberchimps_get_option( 'single_post_byline_comments', 1 ) ) ? cyberchimps_get_option( 'single_post_byline_comments', 1 ) : false;
}
elseif( is_archive() ) {
$show = ( cyberchimps_get_option( 'archive_post_byline_comments', 1 ) ) ? cyberchimps_get_option( 'archive_post_byline_comments', 1 ) : false;
}
else {
$show = ( cyberchimps_get_option( 'post_byline_comments', 1 ) ) ? cyberchimps_get_option( 'post_byline_comments', 1 ) : false;
}
$leave_comment = ( is_single() || is_page() ) ? '' : __( 'Leave a comment', 'cyberchimps' );
if( $show ):
if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
<span class="comments-link"><?php comments_popup_link( $leave_comment, __( '1 Comment', 'cyberchimps' ), '% ' . __( 'Comments', 'cyberchimps' ) ); ?></span>
<span class="sep"> <?php echo ( $leave_comment != '' ) ? apply_filters( 'cyberchimps_entry_meta_sep', '|' ) : ''; ?> </span>
<?php endif;
endif;
}
// set up next and previous post links for lite themes only
function cyberchimps_next_previous_posts() {
if( get_next_posts_link() || get_previous_posts_link() ): ?>
<div class="more-content">
<div class="row-fluid">
<div class="span6 previous-post">
<?php previous_posts_link(); ?>
</div>
<div class="span6 next-post">
<?php next_posts_link(); ?>
</div>
</div>
</div>
<?php
endif;
}
add_action( 'cyberchimps_after_content', 'cyberchimps_next_previous_posts' );
// core options customization Names and URL's
//Pro or Free
function cyberchimps_theme_check() {
$level = 'free';
return $level;
}
//Theme Name
function cyberchimps_options_theme_name(){
$text = 'CyberChimps';
return $text;
}
//Theme Pro Name
function cyberchimps_upgrade_bar_pro_title() {
$text = 'CyberChimps Pro';
return $text;
}
//Upgrade link
function cyberchimps_upgrade_bar_pro_link() {
$url = 'http://cyberchimps.com/responsepro/';
return $url;
}
//Doc's URL
function cyberchimps_options_documentation_url() {
$url = 'http://cyberchimps.com/responsepro/docs/';
return $url;
}
// Support Forum URL
function cyberchimps_options_support_forum() {
$admin = cyberchimps_get_option( 'admin', array( 'support_url' => 'http://support.godaddy.com/help/category/217/my-account' ) );
$url = $admin['support_url'];
return $url;
}
//Page Options Help URL
function cyberchimps_options_page_options_help() {
$url = 'http://cyberchimps.com/responsepro/docs/';
return $url;
}
// Slider Options Help URL
function cyberchimps_options_slider_options_help() {
$url = 'http://cyberchimps.com/responsepro/docs/';
return $url;
}
add_filter( 'cyberchimps_current_theme_name', 'cyberchimps_options_theme_name', 1 );
add_filter( 'cyberchimps_upgrade_pro_title', 'cyberchimps_upgrade_bar_pro_title' );
add_filter( 'cyberchimps_upgrade_link', 'cyberchimps_upgrade_bar_pro_link' );
add_filter( 'cyberchimps_documentation', 'cyberchimps_options_documentation_url' );
add_filter( 'cyberchimps_support_forum', 'cyberchimps_options_support_forum' );
add_filter( 'cyberchimps_page_options_help', 'cyberchimps_options_page_options_help' );
add_filter( 'cyberchimps_slider_options_help', 'cyberchimps_options_slider_options_help' );
// Help Section
function cyberchimps_options_help_header() {
$text = 'CyberChimps';
return $text;
}
function cyberchimps_options_help_sub_header(){
$text = __( 'CyberChimps Professional Responsive WordPress Theme', 'cyberchimps' );
return $text;
}
add_filter( 'cyberchimps_help_heading', 'cyberchimps_options_help_header' );
add_filter( 'cyberchimps_help_sub_heading', 'cyberchimps_options_help_sub_header' );
// Branding images and defaults
// Banner default
function cyberchimps_banner_default() {
$url = '/images/branding/banner.jpg';
return $url;
}
add_filter( 'cyberchimps_banner_img', 'cyberchimps_banner_default' );
//theme header options
function realestate_header_drag_options() {
$options = array(
'cyberchimps_logo_search' => __( 'Logo + Search', 'cyberchimps' ),
'cyberchimps_logo' => __( 'Logo', 'cyberchimps' ),
'cyberchimps_sitename_contact' => __( 'Logo + Contact', 'cyberchimps' )
);
return $options;
}
add_action( 'header_drag_and_drop_options', 'realestate_header_drag_options' );
//theme header defaults
function realestate_header_drag_default() {
$default = array(
'cyberchimps_sitename_contact' => __( 'Logo + Contact', 'cyberchimps' )
);
return $default;
}
add_filter( 'header_drag_and_drop_default', 'realestate_header_drag_default' );
//social icon skin options
function cyberchimps_social_icon_options( $orig ) {
$orig['estate'] = get_template_directory_uri(). '/images/social/thumbs/icons-estate.png';
return $orig;
}
add_filter( 'cyberchimps_social_icon_options', 'cyberchimps_social_icon_options' );
//social icons default
function cyberchimps_social_icon_default() {
$default = 'estate';
return $default;
}
add_filter( 'cyberchimps_social_icon_default', 'cyberchimps_social_icon_default' );
//theme specific skin options in array. Must always include option default
function cyberchimps_skin_color_options( $options ) {
$imagepath = get_template_directory_uri(). '/inc/css/skins/images/';
$options = array(
'default' => $imagepath . 'default.png',
'blue' => $imagepath . 'blue.png',
'green' => $imagepath . 'green.png',
'aqua' => $imagepath . 'aqua.png'
);
return $options;
}
add_filter( 'cyberchimps_skin_color', 'cyberchimps_skin_color_options' );
// theme specific background images
function cyberchimps_background_image( $options ) {
$imagepath = get_template_directory_uri() . '/cyberchimps/lib/images/';
$options = array(
'none' => $imagepath . 'backgrounds/thumbs/none.png',
'noise' => $imagepath . 'backgrounds/thumbs/noise.png',
'blue' => $imagepath . 'backgrounds/thumbs/blue.png',
'dark' => $imagepath . 'backgrounds/thumbs/dark.png',
'space' => $imagepath . 'backgrounds/thumbs/space.png'
);
return $options;
}
add_filter( 'cyberchimps_background_image', 'cyberchimps_background_image' );
// theme specific typography options
function cyberchimps_typography_sizes( $sizes ) {
$sizes = array( '8','9','10','12','14','16','20' );
return $sizes;
}
function cyberchimps_typography_faces( $faces ) {
$faces = array(
'Arial, Helvetica, sans-serif' => 'Arial',
'Arial Black, Gadget, sans-serif' => 'Arial Black',
'Comic Sans MS, cursive' => 'Comic Sans MS',
'Courier New, monospace' => 'Courier New',
'Georgia, serif' => 'Georgia',
'Impact, Charcoal, sans-serif' => 'Impact',
'Lucida Console, Monaco, monospace' => 'Lucida Console',
'Lucida Sans Unicode, Lucida Grande, sans-serif' => 'Lucida Sans Unicode',
'Palatino Linotype, Book Antiqua, Palatino, serif' => 'Palatino Linotype',
'Tahoma, Geneva, sans-serif' => 'Tahoma',
'Times New Roman, Times, serif' => 'Times New Roman',
'Trebuchet MS, sans-serif' => 'Trebuchet MS',
'Verdana, Geneva, sans-serif' => 'Verdana',
'Symbol' => 'Symbol',
'Webdings' => 'Webdings',
'Wingdings, Zapf Dingbats' => 'Wingdings',
'MS Sans Serif, Geneva, sans-serif' => 'MS Sans Serif',
'MS Serif, New York, serif' => 'MS Serif',
);
return $faces;
}
function cyberchimps_typography_styles( $styles ) {
$styles = array( 'normal' => 'Normal','bold' => 'Bold' );
return $styles;
}
add_filter( 'cyberchimps_typography_sizes', 'cyberchimps_typography_sizes' );
add_filter( 'cyberchimps_typography_faces', 'cyberchimps_typography_faces' );
add_filter( 'cyberchimps_typography_styles', 'cyberchimps_typography_styles' );
//Real Estate Functions
// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'top-menu', __( 'Top Menu', 'cyberchimps' ) );
// add featured image size
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'realestate', 999, 200, true );
}
function cyberchimps_featured_image_size() {
$size = 'realestate';
return $size;
}
add_filter( 'cyberchimps_post_thumbnail_size', 'cyberchimps_featured_image_size' );
//add option for header image
function cyberchimps_add_theme_options( $original ) {
$new_field[][1] = array(
'name' => __('Header Image', 'cyberchimps'),
'id' => 'header_image',
'std' => '',
'type' => 'upload',
'desc' => __( 'The image used for the header needs to be a large image. We recommend a minimum width of 980px and a maximum height of 350px', 'cyberchimps' ),
'std' => get_template_directory_uri() . '/images/header.jpg',
'section' => 'cyberchimps_header_options_section',
'heading' => 'cyberchimps_header_heading'
);
$new_fields = cyberchimps_array_field_organizer( $original, $new_field );
return $new_fields;
}
add_filter( 'cyberchimps_field_filter', 'cyberchimps_add_theme_options', 10 );
function cyberchimps_header_image() {
$image_url = cyberchimps_get_option( 'header_image' );
if( $image_url ) {
$image = '<div class="header-image"><img src="' . $image_url . '" alt="' . get_bloginfo( 'name' ) . '" /></div>';
echo $image;
}
}
add_action( 'cyberchimps_after_navigation', 'cyberchimps_header_image' );