-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
executable file
·786 lines (697 loc) · 28.1 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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
<?php
if ( ! function_exists( 'onemozilla_setup' ) ):
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* To override onemozilla_setup() in a child theme, add your own onemozilla_setup to your child theme's
* functions.php file.
*
* @uses load_theme_textdomain() For translation/localization support.
* @uses add_editor_style() To style the visual editor.
* @uses add_theme_support() To add support for post thumbnails.
* @uses register_nav_menus() To add support for navigation menus.
* @uses add_custom_background() To add support for a custom background.
* @uses add_custom_image_header() To add support for a custom header.
* @uses register_default_headers() To register the default custom header images provided with the theme.
* @uses set_post_thumbnail_size() To set a custom post thumbnail size.
*
*/
function onemozilla_setup() {
/* Make the theme available for translation.
* Translations can be added to the /languages/ directory.
*/
load_theme_textdomain( 'onemozilla', get_template_directory() . '/languages' );
$locale = get_locale();
$locale_file = get_template_directory() . "/languages/$locale.php";
if ( is_readable( $locale_file ) )
require_once( $locale_file );
// Load up our theme options page and related code.
require( get_template_directory() . '/inc/theme-options.php' );
// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'primary', __( 'Primary Menu', 'onemozilla' ) );
// This theme uses Featured Images (also known as post thumbnails)
add_theme_support( 'post-thumbnails' );
// The height and width of your custom header.
// Add a filter to onemozilla_header_image_width and onemozilla_header_image_height to change these values.
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'onemozilla_header_image_width', 340 ) );
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'onemozilla_header_image_height', 240 ) );
// Add a way for the custom header to be styled in the admin panel that controls
// custom headers. See onemozilla_admin_header_style(), below.
global $wp_version;
if ( version_compare( $wp_version, '3.4', '>=' ) ) {
$defaults = array(
'wp-head-callback' => 'onemozilla_header_style',
'admin-head-callback' => 'onemozilla_admin_header_style',
'admin-preview-callback' => 'onemozilla_admin_header_image',
);
add_theme_support( 'custom-header', $defaults );
} else {
add_custom_image_header( 'onemozilla_header_style', 'onemozilla_admin_header_style', 'onemozilla_admin_header_image' );
}
// Disable the header text and color options
define( 'NO_HEADER_TEXT', true );
// ... and thus ends the changeable header business.
// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
register_default_headers( array(
'firefox' => array(
'url' => '%s/img/headers/firefox.png',
'thumbnail_url' => '%s/img/headers/firefox-thumbnail.png',
/* L10N: header image description */
'description' => __( 'Firefox Logo', 'onemozilla' )
)
)
);
// We've moved the share_posts and hide_authors out of theme options but we'll bring over those settings (if they exist)
$options = get_option( 'onemozilla_theme_options' );
// Stash the values in variables
if (isset($options['color_scheme'])) {
$color_scheme = $options['color_scheme'];
}
if (isset($options['share_posts'])) {
$share_posts = $options['share_posts'];
}
if (isset($options['hide_author'])) {
$hide_authors = $options['hide_author'];
}
if ( isset($share_posts) && (get_option('onemozilla_share_posts') == null) ) {
update_option('onemozilla_share_posts', $share_posts);
}
if ( isset($hide_authors) && (get_option('onemozilla_hide_authors') == null) ) {
update_option('onemozilla_hide_authors', $hide_authors);
}
// Remove the old values from theme_options, we're only keeping the color scheme (if set)
if ( isset($color_scheme) ) {
update_option('onemozilla_theme_options', array('color_scheme' => $color_scheme));
}
else {
update_option('onemozilla_theme_options', array('color_scheme' => 'stone'));
}
}
endif; // onemozilla_setup
add_action('after_setup_theme', 'onemozilla_setup');
/*********
* Do some stuff when the theme is activated.
*/
if ( ! function_exists( 'onemozilla_activate' ) ):
function onemozilla_activate() {
// Set default media options
update_option('thumbnail_size_w', 160, true);
update_option('thumbnail_size_h', 160, true);
update_option('thumbnail_crop', 1);
update_option('medium_size_w', 250, true);
update_option('medium_size_h', '', true);
update_option('large_size_w', 600, true);
update_option('large_size_h', '', true);
}
endif; // onemozilla_activate
add_action('after_switch_theme', 'onemozilla_activate');
/*********
* Register and define the Social Sharing and Hide Authors settings
*/
function onemozilla_admin_init(){
register_setting(
'reading',
'onemozilla_share_posts'
);
add_settings_field(
'share_posts',
__( 'Social sharing', 'onemozilla' ),
'onemozilla_settings_field_share_posts',
'reading',
'default'
);
register_setting(
'reading',
'onemozilla_hide_authors'
);
add_settings_field(
'hide_authors',
__( 'Hide post authors', 'onemozilla' ),
'onemozilla_settings_field_hide_authors',
'reading',
'default'
);
}
add_action('admin_init', 'onemozilla_admin_init');
/**
* Renders the Add Sharing setting field.
*/
function onemozilla_settings_field_share_posts() { ?>
<div class="layout share-posts">
<label>
<input type="checkbox" id="onemozilla_share_posts" name="onemozilla_share_posts" value="1" <?php checked( '1', get_option('onemozilla_share_posts') ); ?> />
<span>
<?php _e('Add social sharing buttons to posts and pages', 'onemozilla'); ?>
</span>
<p class="description"><?php _e('Adds buttons for Facebook, Twitter, and Google+.', 'onemozilla' ); ?></p>
</label>
</div>
<?php
}
/**
* Renders the Show Author setting field.
*/
function onemozilla_settings_field_hide_authors() { ?>
<div class="layout hide-authors">
<label>
<input type="checkbox" name="onemozilla_hide_authors" value="1" <?php checked( '1', get_option('onemozilla_hide_authors') ); ?> />
<span>
<?php _e('Hide post authors', 'onemozilla'); ?>
</span>
<p class="description"><?php _e('This removes the author byline and author bio from individual posts.', 'onemozilla' ); ?></p>
</label>
</div>
<?php
}
/*********
* Adds classes to the array of post classes. We'll use these as style hooks for post headers.
*/
function onemozilla_post_classes( $classes ) {
global $post;
$comment_count = get_comments_number($post->ID);
if ( get_option('onemozilla_hide_authors') != 1 ) {
$classes[] = 'show-author';
}
elseif ( get_option('onemozilla_hide_authors') == 1 ) {
$classes[] = 'no-author';
}
if ( comments_open($post->ID) || pings_open($post->ID) || ($comment_count > 0) ) {
$classes[] = 'show-comments';
}
elseif ( !comments_open($post->ID) && !pings_open($post->ID) && ($comment_count == 0) ) {
$classes[] = 'no-comments';
}
if ( get_option('onemozilla_share_posts') == 1 ) {
$classes[] = 'show-sharing';
}
return $classes;
}
add_filter( 'post_class', 'onemozilla_post_classes' );
/*********
* Use auto-excerpts for meta description if hand-crafted exerpt is missing
*/
function fc_meta_desc() {
$post_desc_length = 25; // auto-excerpt length in number of words
global $cat, $cache_categories, $wp_query, $wp_version;
if(is_single() || is_page()) {
$post = $wp_query->post;
$post_custom = get_post_custom($post->ID);
if(!empty($post->post_excerpt)) {
$text = $post->post_excerpt;
} else {
$text = $post->post_content;
}
$text = do_shortcode($text);
$text = str_replace(array("\r\n", "\r", "\n", " "), " ", $text);
$text = str_replace(array("\""), "", $text);
$text = trim(strip_tags($text));
$text = explode(' ', $text);
if(count($text) > $post_desc_length) {
$l = $post_desc_length;
$ellipsis = '...';
} else {
$l = count($text);
$ellipsis = '';
}
$description = '';
for ($i=0; $i<$l; $i++)
$description .= $text[$i] . ' ';
$description .= $ellipsis;
}
elseif(is_category()) {
$category = $wp_query->get_queried_object();
if (!empty($category->category_description)) {
$description = trim(strip_tags($category->category_description));
} else {
$description = single_cat_title('Articles posted in ');
}
}
else {
$description = trim(strip_tags(get_bloginfo('description')));
}
if($description) {
echo $description;
}
}
/*********
* Disable the embedded styles when using [gallery] shortcode
*/
add_filter( 'use_default_gallery_style', '__return_false' );
/*********
* Disable comments on Pages by default
*
* This is a hack. WP doesn't currently make it possible to enable comments
* by default for Posts while disabling them for Pages; it's either comments on
* all or comments on none. But in most cases authors will prefer to turn off
* comments for Pages. This just unchecks those checkboxes automatically so authors
* don't need to remember. Comments can still be enabled for Pages on an individual
* basis.
*/
function fc_page_comments_off() {
if(isset($_REQUEST['post_type'])) {
if ( $_REQUEST['post_type'] == "page" ) {
echo '<script>
if (document.post) {
var opt_comment = document.post.comment_status;
var opt_ping = document.post.ping_status;
if (the_comment && the_ping) {
the_comment.checked = false;
the_ping.checked = false;
}
}
</script>';
}
}
}
add_action ( 'admin_footer', 'fc_page_comments_off' );
/*********
* Prints the page number currently being browsed, with a pipe before it.
* Used in header.php to add the page number to the <title>.
*/
if ( ! function_exists( 'fc_page_number' ) ) :
function fc_page_number() {
global $paged; // Contains page number.
if ( $paged >= 2 )
echo ' | ' . sprintf( __( 'Page %s' , 'wordpress' ), $paged );
}
endif;
/*********
* Allow uploading some additional MIME types
*/
function fc_add_mimes( $mimes=array() ) {
$mimes['webm'] = 'video/webm';
$mimes['ogv'] = 'video/ogg';
$mimes['mp4'] = 'video/mp4';
$mimes['m4v'] = 'video/mp4';
$mimes['flv'] = 'video/x-flv';
return $mimes;
}
add_filter('upload_mimes', 'fc_add_mimes');
/*********
* Load various JavaScripts
*/
function onemozilla_load_scripts() {
// Load the default jQuery
wp_enqueue_script('jquery');
// Register and load the socialsharing script
wp_register_script( 'socialshare', get_template_directory_uri() . '/js/socialshare.min.js' );
if ( (get_option('onemozilla_share_posts') == 1) && is_singular() ) {
wp_enqueue_script( 'socialshare' );
}
// Load the threaded comment reply script
if ( get_option('thread_comments') && is_singular() ) {
wp_enqueue_script( 'comment-reply' );
}
// Check required fields on comment form
wp_register_script( 'checkcomments', get_template_directory_uri() . '/js/fc-checkcomment.js' );
if ( get_option('require_name_email') && is_singular() ) {
wp_enqueue_script('checkcomments');
}
}
add_action( 'wp_enqueue_scripts', 'onemozilla_load_scripts' );
/*********
* Remove WP version from head (helps us evade spammers/hackers)
*/
remove_action('wp_head', 'wp_generator');
/*********
* Catch spambots with a honeypot field in the comment form.
* It's hidden from view with CSS so most humans will leave it blank, but robots will kindly fill it in to alert us to their presence.
* The field has an innucuous name -- 'age' in this case -- likely to be autofilled by a robot.
*/
function fc_honeypot( array $data ){
if( !isset($_POST['comment']) && !isset($_POST['content'])) { die("No Direct Access"); } // Make sure the form has actually been submitted
if($_POST['age']) { // If the Honeypot field has been filled in
$message = _e('Sorry, you appear to be a spamming robot because you filled in the hidden spam trap field. To show you are not a spammer, submit your comment again and leave the field blank.', 'onemozilla');
$title = 'Spam Prevention';
$args = array('response' => 200);
wp_die( $message, $title, $args );
exit(0);
} else {
return $data;
}
}
add_filter('preprocess_comment','fc_honeypot');
/*********
* Removes the default styles that are packaged with the Recent Comments widget.
*/
function onemozilla_remove_recent_comments_style() {
add_filter( 'show_recent_comments_widget_style', '__return_false' );
}
add_action( 'widgets_init', 'onemozilla_remove_recent_comments_style' );
/*********
* Customize the password protected form
*/
function fc_password_form() {
global $post;
$label = 'pwbox-'.(empty($post->ID) ? rand() : $post->ID);
$output = '<form class="pwform" action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
<p>'.__('This post is password protected. To view it, please enter the password.', 'onemozilla').'</p>
<ol><li><label for="'.$label.'">'.__('Password', 'onemozilla').'</label><input name="post_password" id="'.$label.'" type="password" size="20" /></li><li><button type="submit" name="Submit">'.esc_attr__('Submit', 'onemozilla').'</button></li></ol>
</form>';
return $output;
}
add_filter('the_password_form', 'fc_password_form');
if ( ! function_exists( 'onemozilla_header_style' ) ) :
/**
* Styles the header image on the blog
*/
function onemozilla_header_style() {
if (get_header_image()) :
?>
<style type="text/css">
#masthead { background-image: url(<?php header_image(); ?>); }
</style>
<?php
endif;
}
endif; // onemozilla_header_style
if ( ! function_exists( 'onemozilla_admin_header_style' ) ) :
/**
* Styles the header image displayed on the Appearance > Header admin panel.
* Referenced via add_custom_image_header() in onemozilla_setup().
*/
function onemozilla_admin_header_style() {
if (function_exists('onemozilla_get_theme_options')) { // fail gracefully if we can't get theme options
$options = onemozilla_get_theme_options(); // get the theme options
}
$header_image = get_header_image();
?>
<style type="text/css">
@import url(<?php echo get_template_directory_uri() . '/colors/'.$options['color_scheme'].'/'.$options['color_scheme'].'-header-preview.css'; ?>);
#header-preview .header {
background: url("<?php echo esc_url( $header_image ); ?>") right top no-repeat;
}
</style>
<?php
}
endif; // onemozilla_admin_header_style
if ( ! function_exists( 'onemozilla_admin_header_image' ) ) :
/**
* Custom header image markup displayed on the Appearance > Header admin panel.
* Referenced via add_custom_image_header() in onemozilla_setup().
*/
function onemozilla_admin_header_image() { ?>
<div id="header-preview">
<div class="header">
<h1 id="site-title"><?php bloginfo( 'name' ); ?></h1>
<h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
<span id="faux-tabzilla">Mozilla</span>
</div>
</div>
<?php }
endif; // onemozilla_admin_header_image
/**
* Enable featured posts
*/
function fc_featured_meta_box($post){
$featured = get_post_meta($post->ID, '_fc_featuredpost', true);
?>
<label class="selectit" for="fc_featuredpost">
<input type="checkbox" name="_fc_featuredpost" id="fc_featuredpost" value="1" <?php if ($featured) { ?>checked<?php } ?> />
<?php _e('Make this a featured post?', 'onemozilla'); ?>
</label>
<?php
}
function register_fc_featuredpost(){
add_meta_box('meta-featured-post', __('Featured Post', 'onemozilla'), 'fc_featured_meta_box', 'post', 'side', 'low');
}
add_action('admin_init', 'register_fc_featuredpost', 1);
function save_fc_featuredpost() {
global $post;
if (isset($_POST['_fc_featuredpost'])) {
update_post_meta($post->ID, '_fc_featuredpost', true);
} else {
update_post_meta($post->ID, '_fc_featuredpost', false);
}
}
add_action('save_post', 'save_fc_featuredpost');
/**
* Enable a few more buttons in the visual editor
*/
function add_more_buttons($buttons) {
$buttons[] = 'hr';
$buttons[] = 'del';
$buttons[] = 'sub';
$buttons[] = 'sup';
$buttons[] = 'cleanup';
return $buttons;
}
add_filter("mce_buttons_3", "add_more_buttons");
/**
* Sets the post excerpt length to 40 words.
*
* To override this length in a child theme, remove the filter and add your own
* function tied to the excerpt_length filter hook.
*/
function onemozilla_excerpt_length( $length ) {
return 40;
}
add_filter( 'excerpt_length', 'onemozilla_excerpt_length' );
/**
* Returns a "Continue Reading" link for excerpts
*/
function onemozilla_continue_reading_link() {
return ' <a class="go" href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading', 'onemozilla' ) . '</a>';
}
/**
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and onemozilla_continue_reading_link().
*
* To override this in a child theme, remove the filter and add your own
* function tied to the excerpt_more filter hook.
*/
function onemozilla_auto_excerpt_more( $more ) {
return ' …' . onemozilla_continue_reading_link();
}
add_filter( 'excerpt_more', 'onemozilla_auto_excerpt_more' );
/**
* Adds a pretty "Continue Reading" link to custom post excerpts.
*
* To override this link in a child theme, remove the filter and add your own
* function tied to the get_the_excerpt filter hook.
*/
function onemozilla_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= onemozilla_continue_reading_link();
}
return $output;
}
add_filter( 'get_the_excerpt', 'onemozilla_custom_excerpt_more' );
/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*/
function onemozilla_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'onemozilla_page_menu_args' );
/**
* Register the widgetized sidebar.
*/
function onemozilla_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'onemozilla' ),
'id' => 'sidebar',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'onemozilla_widgets_init' );
/**********
* Determine if the page is paged and should show posts navigation
*/
function fc_show_posts_nav() {
global $wp_query;
return ($wp_query->max_num_pages > 1) ? TRUE : FALSE;
}
/*********
* Determine if a previous post exists (i.e. that this isn't the first one)
*
* @param bool $in_same_cat Optional. Whether link should be in same category.
* @param string $excluded_categories Optional. Excluded categories IDs.
*/
function fc_previous_post($in_same_cat = false, $excluded_categories = '') {
if ( is_attachment() )
$post = & get_post($GLOBALS['post']->post_parent);
else
$post = get_previous_post($in_same_cat, $excluded_categories);
if ( !$post )
return false;
else
return true;
}
/*********
* Determine if a next post exists (i.e. that this isn't the last post)
*
* @param bool $in_same_cat Optional. Whether link should be in same category.
* @param string $excluded_categories Optional. Excluded categories IDs.
*/
function fc_next_post($in_same_cat = false, $excluded_categories = '') {
if ( is_attachment() )
$post = & get_post($GLOBALS['post']->post_parent);
else
$post = get_next_post($in_same_cat, $excluded_categories);
if ( !$post )
return false;
else
return true;
}
/*********
* Customize the login screen
*/
function fc_custom_login() {
echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('template_directory') . '/css/login.css">';
}
add_action('login_head', 'fc_custom_login');
/*********
* Style the visual editor to match the theme styles
* onemozilla_get_theme_options() is defined in /inc/theme-options.php
* If you add new color schemes, remember to include an editor style sheet!
* Otherwise this will return a 404 and you'll only get default styling.
*/
function fc_editor_style($url) {
if ( !empty($url) ) {
$url .= ',';
}
if (function_exists('onemozilla_get_theme_options')) { // fail gracefully if we can't get theme options
$options = onemozilla_get_theme_options(); // get the theme options
}
if ($options['color_scheme']) { // if we have a color scheme, use its editor stylesheet
$url .= trailingslashit( get_template_directory_uri() ) . 'colors/'.$options['color_scheme'].'/'.$options['color_scheme'].'-editor-style.css';
}
else { // fall back to the default
$url .= trailingslashit( get_template_directory_uri() ) . 'colors/stone/stone-editor-style.css';
}
return $url;
}
add_filter('mce_css', 'fc_editor_style');
/*********
* Comment Template
*/
if ( ! function_exists( 'onemozilla_comment' ) ) :
function onemozilla_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
$comment_type = get_comment_type();
$date_format = get_option("date_format");
$time_format = get_option("time_format");
?>
<li id="comment-<?php comment_ID(); ?>" <?php comment_class('hentry'); ?>>
<?php if ( $comment_type == 'trackback' ) : ?>
<h3 class="entry-title"><?php _e( 'Trackback from ', 'onemozilla' ); ?> <cite><?php esc_html(comment_author_link()); ?></cite>
<?php /* L10N: Trackback headings read "Trackback from <Site> on <Date> at <Time>:" */ ?>
<span class="comment-meta"><?php _e('on', 'onemozilla'); ?>
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>" rel="bookmark" title=" <?php _e('Permanent link to this comment by ','onemozilla'); comment_author(); ?>">
<time class="published" datetime="<?php comment_date('Y-m-d'); ?>" title="<?php comment_date('Y-m-d'); ?>">
<?php /* L10N: Trackback headings read "Trackback from <Site> on <Date> at <Time>:" */ ?>
<?php printf( __('%1$s at %2$s','onemozilla'), get_comment_date($date_format), get_comment_time($time_format) ); ?></time></a>:</span>
</h3>
<?php elseif ( $comment_type == 'pingback' ) : ?>
<h3 class="entry-title"><?php _e( 'Pingback from ', 'onemozilla' ); ?> <cite><?php esc_html(comment_author_link()); ?></cite>
<?php /* L10N: Pingback headings read "Pingback from <Site> on <Date> at <Time>:" */ ?>
<span class="comment-meta"><?php _e('on', 'onemozilla'); ?>
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>" rel="bookmark" title="<?php _e('Permanent link to this comment by ','onemozilla'); comment_author(); ?>">
<time class="published" datetime="<?php comment_date('Y-m-d'); ?>" title="<?php comment_date('Y-m-d'); ?>">
<?php /* L10N: Pingback headings read "Pingback from <Site> on <Date> at <Time>:" */ ?>
<?php printf( __('%1$s at %2$s','onemozilla'), get_comment_date($date_format), get_comment_time($time_format) ); ?></time></a>:</span>
</h3>
<?php else : ?>
<?php if ( ( $comment->comment_author_url != "http://" ) && ( $comment->comment_author_url != "" ) ) : // if author has a link ?>
<h3 class="entry-title vcard">
<a href="<?php comment_author_url(); ?>" class="url" rel="nofollow external" title="<?php esc_html(comment_author_url()); ?>">
<cite class="author fn"><?php esc_html(comment_author()); ?></cite>
<?php if (function_exists('get_avatar')) : echo ('<span class="photo">'.get_avatar( $comment, 48 ).'</span>'); endif; ?>
</a>
<span class="comment-meta">
<?php /* L10N: Comment headings read "<Name> wrote on <Date> at <Time>:" */ ?>
<?php _e('wrote on', 'onemozilla'); ?>
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>" rel="bookmark" title="<?php _e('Permanent link to this comment by ','onemozilla'); comment_author(); ?>">
<time class="published" datetime="<?php comment_date('Y-m-d'); ?>" title="<?php comment_date('Y-m-d'); ?>">
<?php /* L10N: Comment headings read "<Name> wrote on <Date> at <Time>:" */ ?>
<?php printf( __('%1$s at %2$s','onemozilla'), get_comment_date($date_format), get_comment_time($time_format) ); ?></time></a>:</span>
</h3>
<?php else : // author has no link ?>
<h3 class="entry-title vcard">
<cite class="author fn"><?php esc_html(comment_author()); ?></cite>
<?php if (function_exists('get_avatar')) : echo ('<span class="photo">'.get_avatar( $comment, 48 ).'</span>'); endif; ?>
<span class="comment-meta"><?php _e('wrote on', 'onemozilla'); ?>
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>" rel="bookmark" title="<?php _e('Permanent link to this comment by ','onemozilla'); comment_author(); ?>">
<time class="published" datetime="<?php comment_date('Y-m-d'); ?>" title="<?php comment_date('Y-m-d'); ?>">
<?php /* L10N: Comment headings read "<Name> wrote on <Date> at <Time>:" */ ?>
<?php printf( __('%1$s at %2$s','onemozilla'), get_comment_date($date_format), get_comment_time($time_format) ); ?></time></a>:</span>
</h3>
<?php endif; ?>
<?php endif; ?>
<?php if ($comment->comment_approved == '0') : ?>
<p class="mod"><strong><?php _e('Your comment is awaiting moderation.', 'onemozilla'); ?></strong></p>
<?php endif; ?>
<blockquote class="entry-content">
<?php esc_html(comment_text()); ?>
</blockquote>
<?php if ( (get_option('thread_comments') == true) || (current_user_can('edit_post', $comment->comment_post_ID)) ) : ?>
<p class="comment-util"><?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?> <?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) : ?><span class="edit"><?php edit_comment_link(__('Edit Comment','onemozilla'),'',''); ?></span><?php endif; ?></p>
<?php endif; ?>
<?php
} /* end onemozilla_comment */
endif;
/*********
* Featured posts widget for sidebar
*/
class moz_widget_featuredPosts extends WP_Widget {
function widget($args,$instance) {
$args['title'] = $instance['title'];
moz_featuredPosts($args);
}
function moz_widget_featuredPosts() {
$widget_options = array(
'description'=>__('This widget shows the three most recent featured posts.', 'onemozilla')
);
$this->WP_Widget('moz_widget_featuredPosts','Featured Posts',$widget_options);
}
function update($new_instance, $old_instance) {
return $new_instance;
}
function form($instance) {
$title = esc_attr($instance['title']);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'wordpress'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
<?php
}
}
function moz_featuredPosts($args) {
$title = $args['title'];
if ( !is_front_page() ) :
/* Set up a custom loop for the three most recent featured posts */
$featured = new WP_Query( array('posts_per_page' => 3, 'meta_key' => '_fc_featuredpost', 'meta_value' => 1) );
if( $featured->have_posts() ) : ?>
<aside class="widget featured-posts">
<?php if ($title) : ?>
<h3 class="widget-title"><?php echo $title; ?></h3>
<?php endif; ?>
<ul class="hfeed">
<?php while($featured->have_posts()): $featured->the_post(); ?>
<li id="feature-<?php the_ID(); ?>" class="hentry feature">
<h4 class="entry-title entry-summary">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permanent link to “%s”', 'onemozilla' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<span class="feature-img">
<?php if (has_post_thumbnail()) : ?>
<?php the_post_thumbnail(array(115,115), array('alt' => "", 'title' => "")); ?>
<?php else : ?>
<img src="<?php echo get_template_directory_uri(); ?>/img/featured.png" alt="" width="115" height="115" class="wp-post-image">
<?php endif; ?>
</span>
<?php the_title(); ?>
</a>
</h4>
</li>
<?php endwhile; ?>
</ul>
</aside>
<?php else: endif;
endif;
}
function featuredposts_widget_init() {
register_widget("moz_widget_featuredPosts");
}
add_action("widgets_init","featuredposts_widget_init");
?>