-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
1506 lines (1228 loc) · 42.2 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
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Note:
Function file load order:
1) child
2) parent
*/
function soup_setupParentThemeClass(){
Class SoupThemeParent {
public $parent;
public $child;
public $siteNameTag;
public $pageNameTag;
public $postAlt;
public $inlineFooterJSarray = array();
/**
* PHP 4 Compatible Constructor
*/
function SoupThemeParent(){$this->__construct();}
/**
* PHP 5 Constructor
*/
function __construct(){
$this->defineParentURLs();
$this->defineChildURLs();
$this->defineMinimisedCode();
$this->defineParentVersions();
$this->defineChildVersions();
$this->postAlt = 1;
$this->initTheme();
}
function initTheme() {
//add hooks, filters, etc
$this->defineThemeOptions();
$this->registerSidebars();
$this->registerMenus();
$this->setThumbnailSizes();
$this->setupThemeOptions();
$this->initChildTheme();
add_action('wp_head', array(&$this, 'setHeaderTag'));
add_action('wp_head', array(&$this, 'favIcon'));
add_filter('body_class', array(&$this, 'bodyClass'),1, 2);
add_filter('post_class', array(&$this, 'postClass'),5, 3);
add_action('wp_print_styles', array(&$this,'registerCSS'), 50);
add_action('wp_print_styles', array(&$this,'registerJS'), 50);
add_action('wp_print_styles', array(&$this,'registerAdditionalCSSandJS'), 75);
add_action('wp_print_styles', array(&$this,'enqueueCSS'), 50);
add_action('wp_print_styles', array(&$this,'enqueueJS'), 100);
add_filter('script_loader_src', array(&$this, 'removeVersionQstring'));
add_filter('style_loader_src', array(&$this, 'removeVersionQstring'));
add_filter('wp_nav_menu', array(&$this, 'filterMenus'));
add_filter('wp_title', array(&$this, 'filterHtmlTitle'), 10, 2);
add_filter('wp_print_footer_scripts', array(&$this, 'inlineFooterJs'));
}
function initChildTheme(){
//placeholder function for additional initing by the child theme
}
function setHeaderTag() {
if (is_front_page()){
$this->siteNameTag = 'h1';
$this->pageNameTag = 'h2';
}
else {
$this->siteNameTag = 'p';
$this->pageNameTag = 'h1';
}
}
function defineParentURLs(){
$this->parent = array(
'url' => get_template_directory_uri(),
'assets'=> get_template_directory_uri() . '/assets/parent',
'css' => get_template_directory_uri() . '/assets/parent/c',
'js' => get_template_directory_uri() . '/assets/parent/j',
'img' => get_template_directory_uri() . '/assets/parent/i',
'php' => get_template_directory_uri() . '/assets/parent/p',
'phpPath' => TEMPLATEPATH . '/assets/parent/p'
);
}
function defineChildUrls() {
$this->child = array(
'url' => get_stylesheet_directory_uri(),
'assets'=> get_stylesheet_directory_uri() . '/assets/child',
'css' => get_stylesheet_directory_uri() . '/assets/child/c',
'js' => get_stylesheet_directory_uri() . '/assets/child/j',
'img' => get_stylesheet_directory_uri() . '/assets/child/i',
'php' => get_stylesheet_directory_uri() . '/assets/child/p',
'phpPath' => STYLESHEETPATH . '/assets/child/p'
);
}
function defineMinimisedCode() {
$this->parent['mincss'] = false;
$this->parent['minjs'] = false;
$this->child['mincss'] = false;
$this->child['minjs'] = false;
}
function defineParentVersions() {
$this->parent['cssVer'] = 20100706.01;
$this->parent['jsVer'] = 20100706.01;
}
function defineChildVersions() {
$this->child['cssVer'] = 20100706.01;
$this->child['jsVer'] = 20100706.01;
$this->child['jsDependencies'] = array (
'soup-base',
'prettyPhoto',
'hashchange',
'form-validation',
'jquery'
);
}
function defineThemeOptions(){
$this->options['thumbnails'] = true;
$this->options['feedLinks'] = false;
$this->options['headerWidgets'] = true;
$this->options['footerWidgets'] = true;
$this->options['contentBWidgets'] = true;
$this->options['contentCWidgets'] = true;
$this->options['showWPAdminBar'] = false;
$this->options['handheldCssMedia'] = ''; //use to customise @media query
$this->options['editorCSS'] = false; // if true, url is $this->child['css'] . '/all/editor-styles.css'
/* ********************************
If classes are to be added to the editor, add them to editorEnglishClasses as an array
otherwise leave the setting as false
EG:
$this->options['editorEnglishClasses'] = array(
'Leader Text' => 'leadertext',
'Highlighted' => 'hilight'
);
********************************* */
$this->options['editorEnglishClasses'] = false;
/* ********************
forge the header levels in the editor to keep inline with document layout
On pages, Header 1 is a h2 and so on
On pasts, Header 1 is a h4 and so on
also adds the class bxPage or bxPost as appropriate
********************* */
$this->options['editorFakeHeaderLevels'] = false;
}
function isSSL() {
if ((function_exists('getenv') AND ((getenv('HTTPS') != '' AND getenv('HTTPS') != 'off')
OR (getenv('SERVER_PORT') == '433'))) OR (isset($_SERVER) AND ((isset($_SERVER['HTTPS'])
AND $_SERVER['https'] !='' AND $_SERVER['HTTPS'] != 'off') OR (isset($_SERVER['SERVER_PORT'])
AND $_SERVER['SERVER_PORT'] == '443')))) {
return true;
}
else {
return false;
}
}
function setThumbnailSizes(){
if ($this->options['thumbnails'] == true) {
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150, true ); // 150x150 size
}
}
// add_image_size( '150x150', 150, 150, true); // 150x150 image size
// add_image_size( '270x150', 270, 150, true ); // 270x150 image size
// add_image_size( '310x150', 310, 150, true ); // 310x150 image size
// add_image_size( '310x310', 310, 310, true ); // 310x310 image size
// add_image_size( '590x400', 590, 400, true ); // 590x400 image size
// add_image_size( '590', 590, 9999 ); // 590 image size
// add_image_size( '950', 950, 9999 ); // 950 image size
}
function setupThemeOptions(){
if (function_exists('remove_theme_support')) {
if ($this->options['feedLinks'] == true) {
add_theme_support('automatic-feed-links');
}
elseif ($this->options['feedLinks'] == false) {
remove_theme_support('automatic-feed-links');
remove_action('wp_head','feed_links_extra', 3);
remove_action('wp_head','feed_links', 2);
}
}
if ((function_exists('add_editor_style')) AND ($this->options['editorCSS'] == true)) {
add_editor_style("assets/child/c/all/editor-style.css");
}
if (is_array($this->options['editorEnglishClasses']) == true) {
add_filter('mce_buttons_2', array(&$this, 'editorButtons'));
add_filter('tiny_mce_before_init', array(&$this, 'editorEnglishClasses'));
}
if ($this->options['editorFakeHeaderLevels'] == true) {
add_filter('tiny_mce_before_init', array(&$this, 'editorSettings'));
}
if ($this->options['showWPAdminBar'] != true) {
//credit due: http://yoast.com/disable-wp-admin-bar/
/* Disable the Admin Bar. */
add_filter( 'show_admin_bar', '__return_false' );
/* Remove the Admin Bar preference in user profile */
remove_action( 'personal_options', '_admin_bar_preferences' ); }
}
//register styles
function registerCSS(){
global $wp_styles;
if ($this->parent['mincss'] === false) {
$psuffix = '';
} else {
$psuffix = '-min';
}
if ($this->child['mincss'] === true) {
$csuffix = '-min';
}
else {
$csuffix = '';
}
if ($this->options['handheldCssMedia'] == '') {
'handheld, only screen and (min-width: 1px), only screen and (min-device-width: 1px)';
}
//register pretty photo css
wp_register_style(
'prettyPhoto-css',
$this->parent['css'] . "/prettyphoto$psuffix.css",
null,
'2.5.6',
'all'
);
//register all child styles
wp_register_style(
'soup-all',
$this->child['css'] . "/all/all$csuffix.css",
null,
$this->child['cssVer'],
'all'
);
wp_register_style(
'soup-all-ie6',
$this->child['css'] . "/all/all-ie6$csuffix.css",
array('soup-all'),
$this->child['cssVer'],
'all'
);
$wp_styles->registered['soup-all-ie6']->extra['conditional'] = 'IE 6';
wp_register_style(
'soup-all-ie7',
$this->child['css'] . "/all/all-ie7$csuffix.css",
array('soup-all'),
$this->child['cssVer'],
'all'
);
$wp_styles->registered['soup-all-ie7']->extra['conditional'] = 'IE 7';
wp_register_style(
'soup-all-ie8',
$this->child['css'] . "/all/all-ie8$csuffix.css",
array('soup-all'),
$this->child['cssVer'],
'all'
);
$wp_styles->registered['soup-all-ie8']->extra['conditional'] = 'IE 8';
wp_register_style(
'soup-all-ie9',
$this->child['css'] . "/all/all-ie9$csuffix.css",
array('soup-all'),
$this->child['cssVer'],
'all'
);
$wp_styles->registered['soup-all-ie9']->extra['conditional'] = 'IE 9';
//register mobile child styles
wp_register_style(
'soup-mobile',
$this->child['css'] . "/mobile/mobile$csuffix.css",
array('soup-all'),
$this->child['cssVer'],
$this->options['handheldCssMedia']
);
//register print child styles
wp_register_style(
'soup-print',
$this->child['css'] . "/print/print$csuffix.css",
array('soup-all'),
$this->child['cssVer'],
'print'
);
wp_register_style(
'soup-print-ie6',
$this->child['css'] . "/print/print-ie6$csuffix.css",
array('soup-print'),
$this->child['cssVer'],
'print'
);
$wp_styles->registered['soup-print-ie6']->extra['conditional'] = 'IE 6';
wp_register_style(
'soup-print-ie7',
$this->child['css'] . "/print/print-ie7$csuffix.css",
array('soup-print'),
$this->child['cssVer'],
'print'
);
$wp_styles->registered['soup-print-ie7']->extra['conditional'] = 'IE 7';
wp_register_style(
'soup-print-ie8',
$this->child['css'] . "/print/print-ie8$csuffix.css",
array('soup-print'),
$this->child['cssVer'],
'print'
);
$wp_styles->registered['soup-print-ie8']->extra['conditional'] = 'IE 8';
wp_register_style(
'soup-print-ie9',
$this->child['css'] . "/print/print-ie9$csuffix.css",
array('soup-print'),
$this->child['cssVer'],
'print'
);
$wp_styles->registered['soup-print-ie9']->extra['conditional'] = 'IE 9';
//register all-media child styles
wp_register_style(
'soup-all-media',
$this->child['css'] . "/all-media/all-media$csuffix.css",
null,
$this->child['cssVer'],
'all'
);
wp_register_style(
'soup-all-media-ie6',
$this->child['css'] . "/all-media/all-media-ie6$csuffix.css",
array('soup-all-media'),
$this->child['cssVer'],
'all'
);
$wp_styles->registered['soup-all-media-ie6']->extra['conditional'] = 'IE 6';
wp_register_style(
'soup-all-media-ie7',
$this->child['css'] . "/all-media/all-media-ie7$csuffix.css",
array('soup-all-media'),
$this->child['cssVer'],
'all'
);
$wp_styles->registered['soup-all-media-ie7']->extra['conditional'] = 'IE 7';
wp_register_style(
'soup-all-media-ie8',
$this->child['css'] . "/all-media/all-media-ie8$csuffix.css",
array('soup-all-media'),
$this->child['cssVer'],
'all'
);
$wp_styles->registered['soup-all-media-ie8']->extra['conditional'] = 'IE 8';
wp_register_style(
'soup-all-media-ie9',
$this->child['css'] . "/all-media/all-media-ie9$csuffix.css",
array('soup-all-media'),
$this->child['cssVer'],
'all'
);
$wp_styles->registered['soup-all-media-ie9']->extra['conditional'] = 'IE 9';
}
function enqueueCSS() {
//usually overwritten by child
if (!is_admin()) :
/*
never enqueue seperate media styles and
all-media styles at the same time.
*/
wp_enqueue_style('soup-all');
wp_enqueue_style('soup-all-ie6');
wp_enqueue_style('soup-all-ie7');
wp_enqueue_style('soup-all-ie8');
wp_enqueue_style('soup-all-ie9');
wp_enqueue_style('soup-mobile');
wp_enqueue_style('soup-print');
wp_enqueue_style('soup-print-ie6');
wp_enqueue_style('soup-print-ie7');
wp_enqueue_style('soup-print-ie8');
wp_enqueue_style('soup-print-ie9');
/* */
/*
never enqueue seperate media styles and
all-media styles at the same time.
wp_enqueue_style('soup-all-media');
wp_enqueue_style('soup-all-media-ie6');
wp_enqueue_style('soup-all-media-ie7');
wp_enqueue_style('soup-all-media-ie8');
wp_enqueue_style('soup-all-media-ie9');
/* */
endif; //if (!is_admin()):
}
function editorButtons($buttons){
array_unshift($buttons, 'styleselect');
return $buttons;
}
function editorEnglishClasses($settings) {
//Use english names for editor classes
// this should be overridden in the child theme
$classes = $this->options['editorEnglishClasses'];
if ( !empty($settings['theme_advanced_styles']) ) {
$settings['theme_advanced_styles'] .= ';';
}
else {
$settings['theme_advanced_styles'] = '';
}
$class_settings = '';
foreach ( $classes as $name => $value ) {
$class_settings .= "{$name}={$value};";
}
$settings['theme_advanced_styles'] .= trim($class_settings, '; ');
return $settings;
}
function editorSettings($settings) {
if ( !empty($settings['theme_advanced_blockformats']) )
$settings['theme_advanced_blockformats'] .= ';';
else
$settings['theme_advanced_blockformats'] = '';
if (get_post_type() == 'page') {
$formats = array(
'Paragraph' => 'p',
'Address' => 'address',
'Preformatted' => 'pre',
'Heading 1' => 'h2',
'Heading 2' => 'h3',
'Heading 3' => 'h4',
'Heading 4' => 'h5',
'Heading 5' => 'h6'
);
$settings['body_class'] .= 'bxPage';
}
else {
$formats = array(
'Paragraph' => 'p',
'Address' => 'address',
'Preformatted' => 'pre',
'Heading 1' => 'h4',
'Heading 2' => 'h5',
'Heading 3' => 'h6'
);
$settings['body_class'] .= 'bxPost';
}
$format_settings = '';
foreach ( $formats as $name => $value ) {
$format_settings .= "{$name}={$value};";
}
$settings['theme_advanced_blockformats'] .= trim($format_settings, '; ');
return $settings;
}
function registerJS() {
global $wp_scripts;
if ($this->parent['minjs'] === false) {
$psuffix = '';
if ($this->isSSL() == true) {
$validatorURL = 'https://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.js';
}
else {
$validatorURL = 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.js';
}
}
else {
$psuffix = '-min';
if ($this->isSSL() == true) {
$validatorURL = 'https://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.min.js';
}
else {
$validatorURL = 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.min.js';
}
}
if ($this->child['minjs'] === true) {
$csuffix = '-min';
}
else {
$csuffix = '';
}
wp_register_script(
'soup-base',
$this->parent['js'] . "/base$psuffix.js",
array('jquery'),
$this->parent['jsVer'],
true
);
wp_localize_script('soup-base', 'SOUPGIANT_wpURLS', array(
'register' => site_url('wp-login.php?action=register', 'login'),
'regoEnabled' => get_option('users_can_register') ? "y" : "n",
'lostpassword' => wp_lostpassword_url( site_url( $_SERVER['REQUEST_URI'] ) ),
'loginsubmit' => site_url( 'wp-login.php', 'login' ),
'currentURL' => site_url( $_SERVER['REQUEST_URI'] )
));
/* jQuery plugins */
wp_register_script(
'form-validation',
$validatorURL,
array('jquery'),
'1.7',
true
);
wp_register_script(
'prettyPhoto',
$this->parent['js'] . "/jqplugins/prettyphoto$psuffix.js",
array('jquery'),
'2.5.6',
true
);
wp_register_script(
'hashchange',
$this->parent['js'] . "/jqplugins/ba-hashchange$psuffix.js",
array('jquery'),
'1.2',
true
);
wp_register_script(
'modernizr',
$this->parent['js'] . "/modernizr$psuffix.js",
null,
'1.6',
true
);
wp_register_script(
'custom',
$this->child['js'] . "/custom$csuffix.js",
$this->child['jsDependencies'],
$this->child['jsVer'],
true
);
}
function registerAdditionalCSSandJS() {
// this is designed for child to register additional files without
// having to regregister them all
return true;
}
function enqueueChildJs(){
//this function is usually overwitten in child
wp_enqueue_script('custom');
}
function enqueueJS(){
//this function can be overwritten in child but usually isn't
$this->enqueueChildJs();
//threaded comments
//for the wp_script_is checks below, we need to manually enque 'custom' dependancies too
if (wp_script_is('custom') == true) {
foreach ($this->child['jsDependencies'] as $handle) {
wp_enqueue_script($handle);
}
}
if (wp_script_is('prettyPhoto') == true) {
wp_enqueue_style('prettyPhoto-css');
}
if (wp_script_is('prettyPhoto') && wp_script_is('hashchange')) {
global $wp_scripts;
if ($this->child['minjs'] === true) {
$psuffix = '-min';
}
else {
$psuffix = '';
}
$wp_scripts->query('prettyPhoto')->src = '';
$wp_scripts->query('hashchange')->src = $this->parent['js'] . "/jqplugins/prettyphoto-hashchange$psuffix.js";
$wp_scripts->query('hashchange')->ver = $wp_scripts->query('prettyPhoto')->ver . ',' . $wp_scripts->query('hashchange')->ver;
}
$this->commentReply();
}
function removeVersionQstring($src){
if ( preg_match( '/ajax\.googleapis\.com\/|ajax\.aspnetcdn\.com\/|ajax\.microsoft\.com\//', $src ) )
$src = remove_query_arg('ver',$src);
return $src;
}
function commentReply() {
if ((!is_admin()) AND is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) {
wp_enqueue_script( 'comment-reply' );
}
}
function bodyClass($classes, $class = null) {
//set classes on <body> tag
// based on same function in Sandbox
global $wp_query, $current_user, $wpdb;
//much of this function is sourced from the sandbox_body_class from the sandbox theme
$c = array();
$r = array(); //values that will be removed from the array
$c = array_merge($classes);
$c[] = 'nojs';
$c[] = 'nojswin';
is_front_page() ? $c[] = 'bxHome' : null; // For the front page, if set
is_home() ? $c[] = 'bxBlog bxList bxAllBlog' : null; // For the blog posts page, if set
is_archive() ? $c[] = 'bxArch bxList bxAllBlog' : null;
is_date() ? $c[] = 'bxDate' : null;
is_search() ? $c[] = 'bxSearch' : null;
is_singular() ? $c[] = 'bxSngl' : null;
is_paged() ? $c[] = 'bxPaged' : null;
is_attachment() ? $c[] = 'bxAtt' : null;
is_404() ? $c[] = 'bx404' : null; // CSS does not allow a digit as first character
if (is_front_page()) {
$c[] = 'bxHome';
$r[] = 'home';
}
if (is_home()) {
$c[] = 'bxBlog';
$c[] = 'bxList';
$c[] = 'bxAllBlog';
$r[] = 'blog';
}
if (is_archive()) {
$c[] = 'bxArch';
$c[] = 'bxList';
$c[] = 'bxAllBlog';
$r[] = 'archive';
}
if (is_date()) {
$c[] = 'bxDate';
$r[] = 'date';
}
if ( is_search() ) {
$c[] = 'bxSearch';
$r[] = 'search';
}
if ( is_paged() ) {
$c[] = 'bxPaged';
$r[] = 'paged';
}
if (is_singular()) {
$c[] = 'bxSngl';
}
if ( is_attachment() ) {
$c = 'bxAtt';
$r[] = 'attachment';
}
if ( is_404() ) {
$c[] = 'bx404';
$r[] = 'error404';
}
if ( is_single() ) {
$post_id = $wp_query->get_queried_object_id();
$post = $wp_query->get_queried_object();
$postSlug = $wp_query->post->post_name;
$c[] = 'bxAllBlog';
$c[] = 'bxPost';
$r[] = 'single';
$c[] = 'bxPTy-' . sanitize_html_class($post->post_type, $post_id);
$r[] = 'single-' . sanitize_html_class($post->post_type, $post_id);
$c[] = 'bxP-' . $postSlug;
$c[] = 'bxP-id' . $post_id;
$r[] = 'postid-' . $post_id;
// Adds category classes for each category on single posts
if ( $cats = get_the_category() )
foreach ( $cats as $cat )
$c[] = 'bxPC-' . $cat->slug;
// Adds tag classes for each tags on single posts
if ( $tags = get_the_tags() )
foreach ( $tags as $tag )
$c[] = 'bxPTag-' . $tag->slug;
if (function_exists('get_post_format')) {
$post_format = get_post_format( $post->ID );
if ( $post_format && !is_wp_error($post_format) ) {
$c[] = 'bxPF-' . sanitize_html_class( $post_format );
$r[] = 'single-format-' . sanitize_html_class( $post_format );
}
else {
$c[] = 'bxPF-standard';
$r[] = 'single-format-standard';
}
}
if ( is_attachment() ) {
$mime_type = get_post_mime_type($post_id);
$mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' );
$c[] = 'bxAtt';
$c[] = 'bxAtt-' . $postSlug;
$c[] = 'bxAtt-' . str_replace( $mime_prefix, "", "$mime_type" );
$r[] = 'attachmentid-' . $post_id;
$r[] = 'attachment-' . str_replace( $mime_prefix, '', $mime_type );
}
}
// Author name classes for BODY on author archives
elseif ( is_author() ) {
$author = $wp_query->get_queried_object();
$c[] = 'bxAuthor';
$c[] = 'bxA-' . $author->user_nicename;
$r[] = 'author';
$r[] = 'author-' . sanitize_html_class( $author->user_nicename , $author->ID );
}
// Category name classes for BODY on category archvies
elseif ( is_category() ) {
$cat = $wp_query->get_queried_object();
$c[] = 'bxCat';
$c[] = 'bxC-' . $cat->slug;
$r[] = 'category';
$r[] = 'category-' . sanitize_html_class( $cat->slug, $cat->cat_ID );
}
// Tag name classes for BODY on tag archives
elseif ( is_tag() ) {
$tags = $wp_query->get_queried_object();
$c[] = 'bxTag';
$c[] = 'bxTag-' . $tags->slug;
$r[] = 'tag';
$r[] = 'tag-' . sanitize_html_class( $tags->slug, $tags->term_id );
}
// Tag name classes for BODY on taxonomy archives
elseif (function_exists('is_tax') AND is_tax() ) {
$term = $wp_query->get_queried_object();
$c[] = 'bxTax-' . sanitize_html_class( $term->taxonomy );
$c[] = 'bxTerm-' . sanitize_html_class( $term->slug, $term->term_id );
$c[] = 'bxTerm-' . $term->term_id;
$r[] = 'tax-' . sanitize_html_class( $term->taxonomy );
$r[] = 'term-' . sanitize_html_class( $term->slug, $term->term_id );
$r[] = 'term-' . $term->term_id;
}
// Page author for BODY on 'pages'
elseif ( is_page() ) {
$pageID = $wp_query->post->ID;
$pageSlug = $wp_query->post->post_name;
$page_children = wp_list_pages("child_of=$pageID&echo=0");
$post = get_page($pageID);
$c[] = 'bxPage';
$r[] = 'page';
$r[] = 'page-id-' . $pageID;
$c[] = 'bxPg-' . $pageSlug;
$c[] = 'bxPgA-' . sanitize_title_with_dashes(strtolower(get_the_author('login')));
if ( $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status = 'publish' LIMIT 1", $page_id) ) ) {
$c[] = 'bxPgTree-' . $pageID;
$r[] = 'page-parent';
}
if ( $post->post_parent ) {
$r[] = 'page-child';
$r[] = 'parent-pageid-' . $post->post_parent;
$c[] = 'bxPgChild';
$c[] = 'bxPgTree-' . $post->post_parent;
}
if ( is_page_template() ) {
$c[] = 'bxPgTemplate';
$c[] = 'bxPgT-' . str_replace( '.php', '', get_post_meta( $pageID, '_wp_page_template', true ) );
$r[] = 'page-template';
$r[] = 'page-template-' . sanitize_html_class( str_replace( '.', '-', get_post_meta( $page_id, '_wp_page_template', true ) ), '' );
}
}
elseif ( is_search() ) {
if ( !empty( $wp_query->posts ) ) {
$c[] = 'bxSearchResults';
$r[] = 'search-results';
}
else {
$c[] = 'bxSearchNil';
$r[] = 'search-no-results';
}
}
// For when a visitor is logged in while browsing
if ( $current_user->ID ) {
$r[] = 'logged-in';
$c[] = 'bxLoggedIn';
}
//remove the default classes that have been replaced with the soupgiant equivs.
$soupClasses = array_diff($c, $r);
// Separates classes with a single space, collates classes for BODY
//$c = join( ' ', apply_filters( 'body_class', $c ) ); // Available filter: body_class
// And tada!
return $soupClasses;
}
function postClass($classes, $class = null, $post_ID = null) {
//set classes on post's <div> tag
// sourced from the sandbox theme
if (isset($post_ID)) {
$post = get_post($post_ID);
}
else {
global $post;
}
$r = array();
$c = array_merge($classes);
// hentry for hAtom compliace, gets 'alt' for every other post DIV, describes the post type and p[n]
$c[] = "p$this->postAlt";
$c[] = $post->post_type;
$c[] = $post->post_status;
// Author for the post queried
$c[] = 'author-' . sanitize_title_with_dashes(strtolower(get_the_author('login')));
// Category for the post queried
foreach ( (array) get_the_category() as $cat ) {
if ( empty($cat->slug ) ) {
continue;
}
$c[] = 'cat-' . sanitize_html_class($cat->slug, $cat->cat_ID);
$r[] = 'category-' . sanitize_html_class($cat->slug, $cat->cat_ID);
}
// Tags for the post queried; if not tagged, use .untagged
if ( get_the_tags() == null ) {
$c[] = 'untagged';
} else {
$c[] = 'tagged';
}
// For password-protected posts
if ( $post->post_password )
$c[] = 'protected';
// Applies the time- and date-based classes (below) to post DIV
//sandbox_date_classes( mysql2date( 'U', $post->post_date ), $c );
// If it's the other to the every, then add 'alt' class
if ( ++$this->postAlt % 2 )
$c[] = 'alt';
$soupClasses = array_diff($c, $r);
return $soupClasses;
}
function favIcon(){
$result = "";
$result .= '<link rel="shortcut icon" type="image/x-icon" href="' . $this->child['img'] . '/favicon.ico" />' . "\n";
$result .= '<link rel="icon" type="image/x-icon" href="' . $this->child['img'] . '/favicon.ico" />' . "\n";
echo $result;
return;
}
function getTree($post_id){
global $wp_query, $post;
if ($post_id === null) {
$post_id = $post->ID;
}
if (is_page($post_id)) {
//only works on pages.
$tree[] = $post_id;
$parent_id = get_post($post_id)->post_parent;
if($parent_id != 0){
$tree = array_merge($tree, soup_getTree($parent_id));
}