-
Notifications
You must be signed in to change notification settings - Fork 4
/
functions.php
902 lines (723 loc) · 40.5 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
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
<?php
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'functions.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');
$themename = 'LightWord';
define('LW_CURRENT_VERSION', '2.0.0.6');
$top_header_image_path = get_template_directory_uri().'/images/header-image.png';
if ( ! isset( $content_width ) ) $content_width = 550;
$options = array (
array( 'name' => 'Welcome',
'type' => 'title'),
array( 'type' => 'open'),
array( 'name' => __('Layout settings', 'lightword'),
'id' => 'lw_layout_settings',
'options' => array(__('Original','lightword'), __('Wider','lightword')),
'std' => __('Original','lightword'),
'desc' => '',
'type' => 'select'),
array( 'name' => __('Cufón settings', 'lightword'),
'desc' => __('Show certain text on your blog (blog title, tagline, post titles, page titles, etc.) using Cufón¹ or the lighter weight, more modern CSS3 <tt>font-face</tt> declaration.<br /><br />If using Cufón, select <em>Extra</em>² (or <em>Disabled</em>) for languages with accents and special characters.','lightword'),
'id' => 'lw_cufon_settings',
'options' => array(__('Enabled','lightword'), __('Disabled','lightword'), __('Extra','lightword'), __('CSS3 Font-face (lightweight)')),
'std' => __('Enabled','lightword'),
'type' => 'select'),
array( 'name' => __('Disable comments on pages','lightword'),
'desc' => __('Check this box if you would like to DISABLE COMMENTS on pages','lightword'),
'id' => 'lw_disable_comments',
'type' => 'checkbox',
'std' => 'false'),
array( 'name' => __('Custom image header', 'lightword'),
'id' => 'lw_top_header_image',
'options' => array( __('Disabled','lightword'), __('Enabled','lightword') ),
'std' => __('Disabled','lightword'),
'desc' => __('When <em>enabling</em> this feature, please save this setting and then set image height & width below before going to <strong>Appearance » Background</strong> to upload your custom header image','lightword'),
'type' => 'select'),
array( 'name' => __('Header image height in pixels','lightword'),
'desc' => '',
'id' => 'lw_top_header_image_height',
'type' => 'header_image_height',
'std' => '56'),
array( 'name' => __('Header image width in pixels','lightword'),
'desc' => '',
'id' => 'lw_top_header_image_width',
'type' => 'header_image_width',
'std' => '600'),
array( 'name' => __('About author feature', 'lightword'),
'desc' => __('Display information about post author','lightword'),
'id' => 'lw_post_author',
'options' => array(__('Disabled','lightword'), __('Main page','lightword'), __('Single page','lightword'), __('Both','lightword')),
'std' => __('Disabled','lightword'),
'type' => 'select'),
array( 'name' => __('Enjoy this post feature','lightword'),
'desc' => __('Check this box to show a subscription plug banner below the content on post pages','lightword'),
'id' => 'lw_enjoy_post',
'type' => 'checkbox',
'std' => 'false'),
array( 'name' => __('Use "dumb" front menu','lightword'),
'desc' => __('Show an automatically generated list of pages/categories instead of a custom navigation menu','lightword'),
'id' => 'lw_use_dumb_menu',
'type' => 'checkbox',
'std' => 'false'),
array( 'name' => __('Show categories in front menu','lightword'),
'desc' => __('List CATEGORIES instead of PAGES on front menu','lightword'),
'id' => 'lw_show_categories',
'type' => 'checkbox',
'std' => 'false'),
array( 'name' => __('Exclude pages from front menu','lightword'),
'desc' => __('Type the page IDs in the box below. Example input: <code>5,19,24</code>','lightword'),
'id' => 'lw_exclude_pages',
'type' => 'exclude_pages',
'std' => ''),
array( 'name' => __('Exclude categories from front menu','lightword'),
'desc' => __('Type the category IDs in the box below. Example input: <code>5,19,24</code>','lightword'),
'id' => 'lw_exclude_categories',
'type' => 'exclude_categories',
'std' => ''),
array( 'name' => __('Remove home button','lightword'),
'desc' => __('Remove home button from front menu','lightword'),
'id' => 'lw_remove_homebtn',
'type' => 'checkbox',
'std' => 'false'),
array( 'name' => __('Remove search box','lightword'),
'desc' => __('Remove search box and expand space for front menu','lightword'),
'id' => 'lw_remove_searchbox',
'type' => 'checkbox',
'std' => 'false'),
array( 'name' => __('Remove tags from posts','lightword'),
'desc' => __('Show only categories in post footer','lightword'),
'id' => 'lw_disable_tags',
'type' => 'checkbox',
'std' => 'false'),
array( 'name' => __('Remove RSS badge','lightword'),
'desc' => __('Remove RSS badge from blog header','lightword'),
'id' => 'lw_remove_rss',
'type' => 'checkbox',
'std' => 'false'),
array( 'name' => __('Google Custom Search Engine','lightword'),
'desc' => __('Find <code>name="cx"</code> in the <strong>Search box code</strong> of Google CSE, and type the <code>value</code> here.','lightword'),
'id' => 'lw_google_search_code',
'type' => 'text',
'std' => ''),
array( 'name' => __('Sidebox settings', 'lightword'),
'id' => 'lw_sidebox_settings',
'options' => array(__('Enabled','lightword'), __('Disabled','lightword'), __('Show only date','lightword'), __('Show only in posts','lightword'), __('Last two options combined','lightword')),
'std' => __('Enabled','lightword'),
'desc' => '',
'type' => 'select'),
array( 'name' => __('Sidebar settings', 'lightword'),
'id' => 'lw_sidebar_settings',
'desc' => __('Two sidebars option is available on Wider layout only','lightword'),
'options' => array(__('One sidebar','lightword'), __('Two sidebars','lightword')),
'std' => __('One sidebar','lightword'),
'type' => 'select'),
array( 'name' => __('Custom CSS', 'lightword'),
'desc' => __('Put your custom CSS styles here','lightword'),
'id' => 'lw_custom_css',
'type' => 'textarea',
'std' => ''),
array( 'name' => __('AdSense', 'lightword'),
'desc' => __('Copy your AdSense (or any other advertising service) code and paste it here.<br/>Usually 468x60 text or image ad works best, but you can use any ad format you want.','lightword'),
'id' => 'lw_adsense_spot',
'type' => 'textarea',
'std' => ''),
array( 'name' => __('Additional header content', 'lightword'),
'desc' => __('Additional header content, including scripts, etc.','lightword'),
'id' => 'lw_header_content',
'type' => 'textarea',
'std' => ''),
array( 'name' => __('Favicon', 'lightword'),
'desc' => __('The path to your site\'s favicon, relative to your WordPress installation.<br />Example: If WordPress is installed at <tt>http://mydoma.in/</tt> and your icon is located at <tt>http://mydoma.in/icons/favicon.ico</tt>, use <tt>/icons/favicon.ico</tt>'),
'id' => 'lw_favicon_path',
'type' => 'text',
'std' => ''),
array( 'name' => __('Additional footer content', 'lightword'),
'desc' => __('Additional footer content for Google Analytics or any other service','lightword'),
'id' => 'lw_footer_content',
'type' => 'textarea',
'std' => ''),
array( 'type' => 'close')
);
// ADMIN PAGE FUNCTIONS
function lightword_admin() {
global $themename, $options;
if ( nullit($_GET['page']) == basename(__FILE__) ) {
if ( 'save' == nullit($_REQUEST['action']) ) {
foreach ($options as $value) {
update_option( @$value['id'], lightword_stripslash_check(@$_REQUEST[ $value['id'] ]) ); }
foreach ($options as $value) {
if( isset( $_REQUEST[ @$value['id'] ] ) ) {
update_option( @$value['id'], lightword_stripslash_check($_REQUEST[ $value['id'] ]) );
} else {
delete_option( @$value['id'] );
}
}
header('Location: ' . admin_url( 'themes.php?page=functions.php&saved=true' ));
} else if( 'reset' == nullit($_REQUEST['action']) ) {
foreach ($options as $value) {
delete_option( @$value['id'] ); }
header('Location: ' . admin_url( 'themes.php?page=functions.php&reset=true' ));
}
}
add_theme_page(__('LightWord Settings','lightword'), __('LightWord Settings','lightword'), 'edit_themes', basename(__FILE__), 'lightword_admin_page');
}
// ADMIN PAGE LAYOUT
function lightword_admin_page() {
global $themename, $themeversion, $options, $lw_top_header_image, $top_header_image_height, $lw_show_categories;
if ( nullit($_REQUEST['saved']) ) { echo '<div id="message" class="updated fade"><p><strong>'.$themename.' '; _e('settings saved','lightword'); echo '.</strong></p></div>'; }
if ( nullit($_REQUEST['reset']) ) { echo '<div id="message" class="updated fade"><p><strong>'.$themename.' '; _e('settings reset','lightword'); echo '.</strong></p></div>'; }
?>
<div class="wrap">
<h2><?php _e('LightWord Settings','lightword') ?></h2>
<div id="poststuff" class="metabox-holder">
<div class="stuffbox">
<h3><label for="link_url"><?php _e('Support the developer','lightword'); ?></label></h3>
<div class="inside">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="5545477">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="<?php _e('PayPal - The safer, easier way to pay online!','lightword'); ?>">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</div></div>
<form method="post">
<p class="submit" style="margin-top:-2em;">
<input name="save" type="submit" value="<?php _e('Save changes','lightword'); ?>" class="button-primary" />
<input type="hidden" name="action" value="save" />
</p>
<div class="stuffbox">
<h3><label for="link_url"><?php _e('General settings','lightword'); ?></label></h3>
<div class="inside">
<?php
foreach ($options as $value) {
# Global variables used in conditionals within the switch block
global $lw_use_dumb_menu, $lw_show_categories;
switch ( $value['type'] ) {
case 'open': ?>
<table width="100%" border="0" style="padding:10px;">
<?php break; case 'close': ?>
</table><br />
<?php break; case 'text':?>
<tr><td width="20%" rowspan="2" valign="middle"><strong style="font-size:11px;"><?php _e("{$value['name']}",'lightword'); ?></strong></td>
<td width="80%"><input style="width:300px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_option( $value['id'] ) != '') { echo get_option( $value['id'] ); } else { echo $value['std']; } ?>" /></td>
</tr><tr><td><small><?php _e("{$value['desc']}",'lightword'); ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px solid #E1E1E1;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php break;case 'textarea':?>
<tr><td width="20%" rowspan="2" valign="middle"><strong><?php echo _e("{$value['name']}",'lightword'); ?></strong></td>
<td width="90%"><div class="toggle"><textarea name="<?php echo $value['id']; ?>" style="width:500px; height:150px;" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_option( $value['id'] ) != '') { echo get_option( $value['id'] ); } else { echo $value['std']; } ?></textarea></td></tr>
<tr><td><small><?php _e("{$value['desc']}",'lightword'); ?></small></td>
</tr><tr></tr><tr><td colspan="2"> </td></tr>
<?php break; case 'select': ?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong style="font-size:11px;"><?php _e("{$value['name']}",'lightword'); ?></strong></td>
<td width="80%"><select style="width:200px;" name="<?php _e("{$value['id']}",'lightword'); ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if ( get_option( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?> value="<?php echo $option; ?>"><?php _e("$option",'lightword'); ?></option><?php } ?></select></td>
</tr><tr><td><small><?php _e("{$value['desc']}",'lightword'); ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px solid #E1E1E1;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php break; case 'header_image_height': ?>
<?php if($lw_top_header_image == 'Enabled') : ?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong style="font-size:11px;"><?php _e("{$value['name']}",'lightword'); ?></strong></td>
<td width="80%"><input style="width:50px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_option( $value['id'] ) != '') { echo get_option( $value['id'] ); } else { echo $value['std']; } ?>" /></td>
</tr><tr><td></td></tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px solid #E1E1E1;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php endif; ?>
<?php break; case 'header_image_width': ?>
<?php if($lw_top_header_image == 'Enabled') : ?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong style="font-size:11px;"><?php _e("{$value['name']}",'lightword'); ?></strong></td>
<td width="80%"><input style="width:50px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_option( $value['id'] ) != '') { echo get_option( $value['id'] ); } else { echo $value['std']; } ?>" /></td>
</tr><tr><td></td></tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px solid #E1E1E1;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php endif; ?>
<?php break; case 'exclude_pages':
if( $lw_use_dumb_menu == 'false' || $lw_use_dumb_menu == '' ) { break; } ?>
<?php if($lw_show_categories == 'false' || $lw_show_categories == '') : ?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong style="font-size:11px;"><?php _e("{$value['name']}",'lightword'); ?></strong></td>
<td width="80%"><input style="width:300px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="text" value="<?php if ( get_option( $value['id'] ) != "") { echo get_option( $value['id'] ); } else { echo $value['std']; } ?>" /></td>
</tr><tr><td><small><?php _e("{$value['desc']}",'lightword'); ?></small></td></tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px solid #E1E1E1;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php endif; ?>
<?php break; case 'exclude_categories':
if( $lw_use_dumb_menu == 'false' || $lw_use_dumb_menu == '' ) { break; } ?>
<?php if($lw_show_categories == 'true') : ?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong style="font-size:11px;"><?php _e("{$value['name']}",'lightword'); ?></strong></td>
<td width="80%"><input style="width:300px;" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="text" value="<?php if ( get_option( $value['id'] ) != '') { echo get_option( $value['id'] ); } else { echo $value['std']; } ?>" /></td>
</tr><tr><td><small><?php _e("{$value['desc']}",'lightword'); ?></small></td></tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px solid #E1E1E1;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php endif; ?>
<?php break; case 'checkbox':
if( ( $value['id'] == 'lw_show_categories' || $value['id'] == 'lw_remove_homebtn' ) && ( $lw_use_dumb_menu == 'false' || $lw_use_dumb_menu == '' ) ) { break; } ?>
<tr>
<td width="25%" rowspan="2" valign="middle"><strong style="font-size:11px;"><?php _e("{$value['name']}",'lightword'); ?></strong></td>
<td width="75%"><?php if(get_option($value['id'])){ $checked = 'checked="checked"'; }else{ $checked = ''; } ?>
<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> /> <small><?php _e("{$value['desc']}",'lightword'); ?></small>
</td></tr><tr></tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px solid #E1E1E1;"> </td></tr><tr><td colspan="2"> </td></tr>
<?php break; } } ?>
</div></div>
<p class="submit" style="margin-top:-2em;">
<input name="save" type="submit" value="<?php _e('Save changes','lightword'); ?>" class="button-primary" />
<input type="hidden" name="action" value="save" />
</p>
</form>
<div class="stuffbox">
<h3><label for="link_url"><?php _e('Search for help','lightword'); ?> (<a href="http://www.lightworddesign.net/">blog</a> <?php _e('or','lightword'); ?> <a href="http://twitter.com/andreiluca">twitter</a>)</label></h3>
<div class="inside">
<?php // Get RSS Feed(s)
include_once(ABSPATH . WPINC . '/feed.php');
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed('http://wordpress.org/support/rss/tags/lightword');
if (!is_wp_error( $rss ) ) : // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity(5);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul>
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li>
<a href='<?php echo $item->get_permalink(); ?>'
title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
<?php echo substr($item->get_title(), 0,-6); ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php
else: echo 'Wordpress forums temporarily unavailable.';
endif;
?>
</div></div>
<div class="stuffbox">
<h3><label for="link_url"><?php _e('What is Cufón?','lightword'); ?> (<a href="http://cufon.shoqolate.com/generate/" target="_blank"><?php _e('website','lightword') ?></a>)</label></h3>
<div class="inside">
<p><?php _e('¹Cufón is dynamic text replacement, like sIFR but using JavaScript instead of Adobe Flash.','lightword') ?><br/>
<br/><?php _e('²Extra Cufón contains (~<b>300kb JS file</b>): Basic latin, uppercase, lowercase, numerals, punctuation, Latin-1 Supplement, Latin Extended-A, Cyrillic Alphabet, Russian Alphabet, Greek and Coptic; <strong>useful for some accents and special characters</strong>.','lightword') ?>
<br/><br/><?php _e('Korean characters are not supported (11,000+ glyphs is a bit too much—enormous file = slow loading).','lightword') ?></p>
</div></div>
<form method="post" style="float:right;">
<input name="reset" type="submit" value="<?php _e('Click here to reset all settings','lightword'); ?>" style="cursor:pointer;" />
<input type="hidden" name="action" value="reset" /><div style="clear:both;height:30px;"></div>
</form>
</div>
<?php
}
foreach ($options as $value) {
$id = ''; if (isset($value['id'])) { $id = $value['id']; }
$std = ''; if (isset($value['std'])) { $std = $value['std']; }
if (get_option( $id ) === FALSE) {
$$id= $std;
} else {
$$id = get_option( $id );
}
}
/**
* count for trackback, pingback, comment, pings
*
* embed like this:
* fb_comment_type_count('pings');
* fb_comment_type_count('comment');
* http://code.google.com/p/wp-basis-theme/
*/
function lightword_fb_get_comment_type_count( $type='all', $zero = false, $one = false, $more = false, $post_id = 0) {
global $cjd_comment_count_cache, $id, $post;
if ( !$post_id )
$post_id = $post->ID;
if ( !$post_id )
return;
if ( !isset($cjd_comment_count_cache[$post_id]) ) {
$p = get_post($post_id);
$p = array($p);
lightword_fb_update_comment_type_cache($p);
}
;
if ( $type == 'pingback' || $type == 'trackback' || $type == 'comment' )
$count = $cjd_comment_count_cache[$post_id][$type];
elseif ( $type == 'pings' )
$count = $cjd_comment_count_cache[$post_id]['pingback'] + $cjd_comment_count_cache[$post_id]['trackback'];
else
$count = array_sum((array) $cjd_comment_count_cache[$post_id]);
return apply_filters('lightword_fb_get_comment_type_count', $count);
}
if ( !function_exists('lightword_fb_update_comment_type_cache') ) {
function lightword_fb_update_comment_type_cache($queried_posts) {
$post_id_list = '';
global $cjd_comment_count_cache, $wpdb;
if ( !$queried_posts )
return $queried_posts;
foreach ( (array) $queried_posts as $post )
if ( !isset($cjd_comment_count_cache[$post->ID]) )
$post_id_list[] = $post->ID;
if ( $post_id_list ) {
$post_id_list = implode(',', $post_id_list);
foreach ( array('', 'pingback', 'trackback') as $type ) {
$counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount
FROM $wpdb->posts
LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID AND comment_approved = '1' AND comment_type='$type' )
WHERE (post_status = 'publish' OR (post_status = 'inherit' AND post_type = 'attachment')) AND ID IN ($post_id_list)
GROUP BY ID");
if ( $counts ) {
if ( '' == $type )
$type = 'comment';
foreach ( $counts as $count )
$cjd_comment_count_cache[$count->ID][$type] = $count->ccount;
}
}
}
return $queried_posts;
}
add_filter('the_posts', 'lightword_fb_update_comment_type_cache');
}
/** Added by Steven L from ISomehowHate.com and modifieed by Andrei on 07.4
| Fixes an issue that can occur when a user has magic_quotes switched to on.
| This ensures no \'s are added to the code which causes Google Adsense and perhaps other things to fail.
| Changes Made to Existing Code: Added stripslash_check to the update_option functions
**/
function lightword_stripslash_check($variable) {
$stripped = stripslashes($variable);
return $stripped;
}
// FRONT MENU / LIST PAGES OR CATEGORIES
function lightword_wp_list_pages(){
global $lw_show_categories, $lw_exclude_pages, $lw_exclude_categories;
if ($lw_show_categories == 'true') {
$top_list = wp_list_categories('echo=0&depth=2&title_li=&hide_empty=0&exclude='.$lw_exclude_categories);
$top_list = str_replace(array('">','</a>','<span><a','current-cat"><a'),array('"><span>','</span></a>','<a','"><a class="s"'), $top_list);
return $top_list;
} else {
$top_list = wp_list_pages('echo=0&depth=2&title_li=&exclude='.$lw_exclude_pages);
$top_list = str_replace(array('">','</a>','<span><a','current_page_item"><a'),array('"><span>','</span></a>','<a','"><a class="s"'), $top_list);
return $top_list;
}
}
/* "DUMB" MENU WRAPPER
* Used to display "dumb" menu and as a fallback for wp_nav_menu()
*/
function lightword_dumb_menu() {
global $lw_remove_searchbox;
$lw_menuclass_att = ( $lw_remove_searchbox == 'true' ) ? ' class="expand"' : '';
echo "<ul id=\"front_menu\"{$lw_menuclass_att}>\n";
echo lightword_homebtn(__('Home','lightword'));
echo lightword_wp_list_pages();
echo '</ul>';
}
// HEADER IMAGE
function lightword_header_image(){
global $lw_top_header_image, $lw_top_header_image_height, $lw_top_header_image_width, $top_header_image_path;
if($lw_top_header_image == 'Enabled') { ?>
<a name="top" title="<?php bloginfo('name'); ?>" href="<?php if(function_exists('home_url')) echo home_url(); else bloginfo('url'); ?>"><span id="top" style="background:url('<?php header_image(); ?>') no-repeat;height:<?php echo HEADER_IMAGE_HEIGHT; ?>px;width:<?php echo HEADER_IMAGE_WIDTH; ?>px"><strong><?php bloginfo('name'); ?></strong></span></a>
<?php }else{ ?>
<div id="top_cufon"><h1 id="logo"><a name="top" title="<?php bloginfo('name'); ?>" href="<?php if(function_exists('home_url')) echo home_url(); else bloginfo('url'); ?>"><?php bloginfo('name'); ?></a> <small><?php bloginfo('description'); ?></small></h1></div>
<?php
}
}
// COMMENTS PINGBACKS / TABS JQUERY
function lightword_comment_tabs(){
if(is_single()||is_page()){
?>
<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/tabs.js"></script>
<script type="text/javascript">jQuery(document).ready(function(){jQuery('tabs').lightword_tabs({linkClass : 'tabs',containerClass : 'tab-content',linkSelectedClass : 'selected',containerSelectedClass : 'selected',onComplete : function(){}});});</script>
<?php
}
}
// CUFON SETTINGS
if ($lw_cufon_settings == 'Enabled') {$cufon_enabled = 1; $cufon_extra = 0; $fontface = 0;}
if ($lw_cufon_settings == 'Extra') {$cufon_extra = 1; $cufon_enabled = 1; $fontface = 0;}
if ($lw_cufon_settings == 'CSS3 Font-face (lightweight)') {$cufon_extra = 0; $cufon_enabled = 0; $fontface = 1;}
function lightword_cufon_header(){
global $cufon_enabled, $cufon_extra, $fontface;
$cufon_header_script = "\n<script src=\"".get_template_directory_uri()."/js/cufon-yui.js\" type=\"text/javascript\"></script>\n<script src=\"".get_template_directory_uri()."/js/vera.font.js\" type=\"text/javascript\"></script>\n<script type=\"text/javascript\">/*<![CDATA[*/Cufon.replace(['h1','h2','h3#reply-title'], { fontFamily: 'Vera' });/*]]>*/</script>";
if($cufon_extra == 1) $cufon_header_script = str_replace('vera.font.js', 'vera_extra.font.js', $cufon_header_script);
if($cufon_enabled == 1) echo $cufon_header_script;
if($fontface == 1) echo "\n<style type=\"text/css\">@font-face { font-family: Vera; src: url(".get_template_directory_uri()."/alternatives/font-face/Vera-Bold.ttf);}</style>\n";
}
function lightword_cufon_footer(){
global $cufon_enabled;
$cufon_footer_script = "\n<script type=\"text/javascript\">/* <![CDATA[ */ Cufon.now(); /* ]]> */ </script>\n";
if($cufon_enabled == 1) echo $cufon_footer_script;
}
// HOME BUTTON
function lightword_homebtn($homebtn_value){
global $lw_remove_homebtn;
$selected = '';
if($lw_remove_homebtn == 'false') {
if(is_front_page()) $selected='s'; ?>
<li><a class="<?php echo $selected; ?>" title="<?php echo $homebtn_value; ?>" href="<?php if(function_exists('home_url')) echo home_url(); else bloginfo('url'); ?>"><span><?php echo $homebtn_value ?></span></a></li>
<?php
}
}
// CANONICAL COMMENTS
function lightword_canonical_for_comments() {
global $cpage, $post;
if ( $cpage > 1 ) :
echo "\n";
echo '<link rel="canonical" href="';
echo get_permalink( $post->ID );
echo "\" />\n";
endif;
}
// SEARCH BOX / WORDPRESS BASIC SEARCH OR GOOGLE CSE
function lightword_searchbox(){
global $lw_remove_searchbox, $lw_google_search_code;
$lw_google_search_code = trim(str_replace(' ','',$lw_google_search_code));
if($lw_remove_searchbox != 'true')
if(!empty($lw_google_search_code)){
?>
<form action="http://www.google.com/cse" method="get" id="searchform">
<input type="text" class="textfield" name="q" size="24" id="s"/>
<input type="submit" class="button" name="sa" value="" id="go"/>
<input type="hidden" name="cx" value="<?php echo $lw_google_search_code; ?>" />
<input type="hidden" name="ie" value="UTF-8" />
</form>
<?php }else{ ?>
<form method="get" id="searchform" action="<?php if(function_exists('home_url')) echo home_url(); else bloginfo('url'); ?>"> <input type="text" value="" name="s" id="s" /> <input type="submit" id="go" value="" alt="<?php _e('Search'); ?>" title="<?php _e('Search'); ?>" /></form>
<?php
}
}
// SIDEBOX
function lightword_show_sidebox(){
global $lw_sidebox_settings;
switch ($lw_sidebox_settings)
{
case 'Enabled':
default:
echo '<div class="comm_date"><span class="data"><span class="j">'.get_the_time('j').'</span>'.get_the_time('M/y').'</span><span class="nr_comm">';
echo '<a class="nr_comm_spot" href="'.get_permalink().'#comments">';
if(!comments_open()) _e('Off','lightword'); else echo lightword_fb_get_comment_type_count('comment');
echo "</a></span></div>\n";
break;
case 'Disabled':
break;
case 'Show only in posts':
if(is_single()){
echo '<div class="comm_date"><span class="data"><span class="j">'.get_the_time('j').'</span>'.get_the_time('M/y').'</span><span class="nr_comm">';
echo '<a class="nr_comm_spot" href="'.get_permalink().'#comments">';
if(!comments_open()) _e('Off','lightword'); else echo lightword_fb_get_comment_type_count('comment');
echo "</a></span></div>\n";
}
break;
case 'Show only date':
/* START ONLY DATE */
echo '<div class="comm_date only_date"><span class="data"><span class="j">'.get_the_time('j').'</span>'.get_the_time('M/y').'</span><span class="nr_comm">';
echo "</span></div>\n";
/* END ONLY DATE */
break;
case "Last two options together":
/* START LAST TWO */
if(is_single()){
echo '<div class="comm_date only_date"><span class="data"><span class="j">'.get_the_time('j').'</span>'.get_the_time('M/y').'</span><span class="nr_comm">';
echo "</span></div>\n";
}
/* END LAST TWO */
break;
} // end switch
} // end function
function lightword_sidebar(){
global $lw_sidebar_settings, $lw_layout_settings;
if($lw_layout_settings=='Wider'){
switch ($lw_sidebar_settings)
{
case 'One sidebar':
default:
break;
case 'Two sidebars':
include (TEMPLATEPATH . '/sidebar-child.php');
break;
} // end switch
}// end if
} // end function
function lightword_simple_date(){
global $lw_sidebox_settings;
if($lw_sidebox_settings == 'Disabled'){
# @TODO Rewrite get_the_time() call per WP i18n guidelines for date strings
echo '<div class="simple_date">'.__('Posted on','lightword').' '.get_the_time(__('F j, Y','lightword')).'</div>';
}
}
// LEGACY COMMENTS / FOR OLD VERSION OF WORDPRESS
function lightword_legacy_comments($file) {
if(!function_exists('wp_list_comments')) : // WP 2.7-only check
$file = TEMPLATEPATH.'/legacy.comments.php';
endif;
return $file;
}
// SPAM PROTECT
function check_referrer() {
if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == '') {
wp_die( __('Please enable referrers in your browser, or, if you\'re a spammer, bugger off!','lightword') );
}
}
// RSS FEED BADGE OPTIONS
function lightword_rss_feed_css_false(){
echo "<style type=\"text/css\">\n#content-body,x:-moz-any-link{float:left;margin-right:28px;}#content-body, x:-moz-any-link, x:default{float:none;margin-right:25px;} \n</style>\n";
}
function lightword_rss_feed_css_true(){
global $lw_layout_settings;
if($lw_layout_settings == 'Wider'){
echo "<style type=\"text/css\">\n#header{background:transparent url(".get_template_directory_uri()."/images/wider/content_top_no_rss.png) no-repeat; } #content-body,x:-moz-any-link{float:left;margin-right:28px;}#content-body, x:-moz-any-link, x:default{float:none;margin-right:25px;}\n</style>";
}else{
echo "<style type=\"text/css\">\n#header{background:transparent url(".get_template_directory_uri()."/images/content_top_no_rss.png) no-repeat; } #content-body,x:-moz-any-link{float:left;margin-right:28px;}#content-body, x:-moz-any-link, x:default{float:none;margin-right:25px;}\n</style>";
}
}
function lightword_rss_feed(){
global $lw_remove_rss;
if($lw_remove_rss == 'false'){ ?>
<a id="rss-feed" title="<?php _e('Syndicate this site using RSS','lightword'); ?>" href="<?php bloginfo('rss2_url'); ?>"><?php _e('Subscribe via RSS','lightword'); ?></a>
<?php } } if($lw_remove_rss == 'false') add_action('wp_head','lightword_rss_feed_css_false'); else add_action('wp_head','lightword_rss_feed_css_true');
// IE6 PNG CSS FIX
function lightword_ie_png_transparency(){
global $lw_remove_rss, $lw_layout_settings, $lw_sidebox_settings, $lw_sidebar_settings;
$lw_layout_wider = '';
if($lw_layout_settings == 'Wider') $lw_layout_wider = 'wider/';
if($lw_layout_settings == 'Wider' && $lw_sidebar_settings == 'Two sidebars') $lw_layout_wider = 'wider/two-sidebars/';
echo "\n<!--[if IE 6]><style type=\"text/css\">";
if($lw_remove_rss == 'false'){
echo '#header{background-image: none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''.get_template_directory_uri().'/images/'.$lw_layout_wider.'content_top.png\',sizingMethod=\'scale\'); }';
}else{
echo '#header{background-image: none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''.get_template_directory_uri().'/images/'.$lw_layout_wider.'content_top_no_rss.png\',sizingMethod=\'scale\'); }';
}
echo '#footer{background:transparent url('.get_template_directory_uri().'/images/'.$lw_layout_wider.'content_bottom.gif) no-repeat;height:8px;}';
if($lw_sidebox_settings == 'Show only date' || $lw_sidebox_settings == 'Last two options together'){
echo '.only_date{background-image: none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''.get_template_directory_uri().'/images/data_box.png\',sizingMethod=\'scale\'); }';
}else{
echo '.comm_date{background-image: none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''.get_template_directory_uri().'/images/date_comm_box.png\',sizingMethod=\'scale\'); }';
}
echo "</style><![endif]-->\n";
}
// THREADED COMMENTS
function lightword_nested_comments($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>"><div id="comment-<?php comment_ID(); ?>">
<div class="comment_content"><div class="comment-meta commentmetadata"><div class="alignleft avatar"><?php echo get_avatar($comment,$size='36'); ?></div>
<div class="alignleft" style="padding-top:5px;"><strong class="comment_author"><?php comment_author_link() ?></strong><br/><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date(__('F jS, Y - H:i','lightword')) /* @TODO Rewrite date function so it will properly localize */ ?></a></div><div class="clear"></div></div>
<?php comment_text() ?>
<div class="reply"><?php comment_reply_link(array_merge( $args, array('reply_text' => __('( REPLY )','lightword'), 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?></div>
<?php if ($comment->comment_approved == '0') : ?><span class="moderation"><?php _e('Your comment is awaiting moderation.','lightword'); ?></span><br /><?php endif; ?></div><div class="clear"></div></div>
<?php
}
// CUSTOM CSS
function lightword_custom_css(){
global $lw_custom_css;
if($lw_custom_css){
echo "\n<style type=\"text/css\">\n/*<![CDATA[*/\n".$lw_custom_css."\n /*]]>*/\n</style>\n";
}
}
// ADSENSE
function lightword_adsense_spot(){
global $lw_adsense_spot;
if($lw_adsense_spot){
echo '<div align="center" id="ad_spot"> ';
echo $lw_adsense_spot;
echo '</div>';
}
}
// LOCALIZATION
load_theme_textdomain('lightword', get_template_directory() . '/lang');
// DASHBOARD
add_action('wp_dashboard_setup', 'lightword_custom_dashboard_widgets');
function lightword_custom_dashboard_widgets() {
global $wp_meta_boxes;
wp_add_dashboard_widget('custom_help_widget', 'LightWord Theme', 'lightword_custom_dashboard_help');
}
function lightword_custom_dashboard_help() {
echo '<p>Thank you for using my precious LightWord theme.<br/>Currently you\'re using version 2.0 which fully supports WordPress 3 menus. Hooray!<br/><br/>- Andrei, ROMANIA<div style="float:right;">';
echo '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="5545477">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form></div><div style="clear:both;"></div>';
}
function nullit(&$varin) {
//must pass by reference, so there is no explicit copying of var data
//if undefined variable, then returns without doing an error, otherwise just returns the var.
//this is done so we dont get warning
if (isset($varin)) {
return ($varin);
}
else {
return ('');
}
}
// SIDEBAR WIDGETS
if ( function_exists('register_sidebar') ) { register_sidebar(array('name' =>'Sidebar','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>')); }
if ( function_exists('register_sidebar') && $lw_sidebar_settings == 'Two sidebars') { register_sidebar(array('name' =>'Sidebar Child','before_widget' => '','after_widget' => '','before_title' => '<h3>','after_title' => '</h3>')); }
// WORDPRESS 2.9+ FEATURES
if ( function_exists( 'add_theme_support' ) ) add_theme_support( 'post-thumbnails' );
if ( function_exists( 'add_theme_support' ) ) add_theme_support( 'menus' );
if ( function_exists( 'add_theme_support' ) ) add_theme_support( 'automatic-feed-links' );
if ( function_exists( 'add_custom_background' ) ) add_custom_background();
// WORDPRESS 3.0+ FEATURES
if ( function_exists( 'register_nav_menus' ) ) register_nav_menus( array(
'lightword_top_menu' => __( 'LightWord Navigation Bar', 'lightword' ),
) );
function register_custom_menu() {
register_nav_menu('lightword_top_menu', __( 'LightWord Navigation Bar', 'lightword' ));
}
add_action('after_setup_theme', 'register_custom_menu');
$commenter = wp_get_current_commenter();
function lightword_comment_fields ($fields) {
foreach ($fields as $name => $field) {
$fields[$name] = preg_replace('/(<label(?:.*?)>(?:.*?)<\/label>)\s*(<span class="required">\*<\/span>)?\s*(<input(?:.*?)\/>)/', '\3\1\2',$field);
$fields[$name] = str_replace('*', '(required)', $fields[$name]);
}
return $fields;
}
add_filter('comment_form_default_fields', 'lightword_comment_fields');
// CUSTOM HEADER
require_once(TEMPLATEPATH.'/custom_header.php');
// Include CSS in WP head
if ( !is_admin() ) {
$theme = get_theme( get_current_theme() );
wp_register_style( 'lightword_stylesheet', get_bloginfo( 'stylesheet_url' ), false, $theme['Version'] );
wp_enqueue_style( 'lightword_stylesheet' );
if($lw_layout_settings == 'Wider') :
wp_register_style( 'lightword_stylesheet_wider', get_template_directory_uri() . '/wider.css', false, $theme['Version'] );
wp_enqueue_style( 'lightword_stylesheet_wider' );
if($lw_sidebar_settings=='Two sidebars'):
wp_register_style( 'lightword_stylesheet_newsidebar', get_template_directory_uri() . '/new_sidebar.css', false, $theme['Version'] );
wp_enqueue_style( 'lightword_stylesheet_newsidebar' );
endif;
else:
wp_register_style( 'lightword_stylesheet_original', get_template_directory_uri() . '/original.css', false, $theme['Version'] );
wp_enqueue_style( 'lightword_stylesheet_original' );
endif;
}
// Single page template embed push css
function single_page_template_css(){
$theme = get_theme( get_current_theme() );
wp_register_style( 'lightword_single_page_template', get_template_directory_uri() . '/single-page-template.css', array('lightword_stylesheet_original'), $theme['Version'] );
wp_enqueue_style( 'lightword_single_page_template' );
}
/* FAVICON SETTING HANDLER */
$path_to_favicon = null;
if($lw_favicon_path) $path_to_favicon = $lw_favicon_path;
// ENABLE FUNCTIONS
add_action('admin_menu', 'lightword_admin');
add_action('wp_head', 'lightword_cufon_header');
add_action('wp_head', 'lightword_custom_css');
add_action('wp_head', 'lightword_ie_png_transparency');
add_action('wp_footer', 'lightword_cufon_footer');
add_action('wp_footer', 'lightword_comment_tabs');
add_action( 'wp_head', 'lightword_canonical_for_comments' );
add_filter('comments_template', 'lightword_legacy_comments');
remove_action('wp_head', 'wp_generator');
remove_filter('the_content', 'wptexturize');
/* ACTIVATION / UPDATE */
function lightword_has_been_activated() {
# Add current version to options database, for update handler
add_option( 'lw_theme_version', LW_CURRENT_VERSION );
}
register_activation_hook( __FILE__, 'lightword_has_been_activated' );
function lightword_has_been_updated() {
# Do removal of cruft from previous versions
delete_option( 'lw_christmas_joy' );
# Database changes
## Renamed WP Menus option
if( get_option('lw_use_wp_menus') ) {
add_option( 'lw_use_dumb_menu', get_option('lw_use_wp_menus') );
delete_option( 'lw_use_wp_menus' );
}
# Update database option so we don't keep running this code
update_option( 'lw_theme_version', LW_CURRENT_VERSION );
}
if( version_compare( get_option( 'lw_theme_version' ), LW_CURRENT_VERSION, '<' ) ) {
lightword_has_been_updated();
}
?>