forked from jeremyclark13/Techozoic-Fluid
/
functions.php
1134 lines (988 loc) · 36.6 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
/**
* Theme Functions
*
* Holds functions used in various areas of theme.
*
* @package Techozoic Fluid
* @author Jeremy Clark <jeremy@clark-technet.com>
* @copyright Copyright (c) 2011, Jeremy Clark
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.0
*
*/
if ( !function_exists( 'optionsframework_init' ) ) {
/*-----------------------------------------------------------------------------------*/
/* Options Framework
/*-----------------------------------------------------------------------------------*/
/* Set the file path based on whether the Options Framework Theme is a parent theme or child theme */
if ( get_stylesheet_directory() == get_template_directory() ) {
define('OPTIONS_FRAMEWORK_URL', get_template_directory() . '/admin/');
define('OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/admin/');
} else {
define('OPTIONS_FRAMEWORK_URL', get_stylesheet_directory() . '/admin/');
define('OPTIONS_FRAMEWORK_DIRECTORY', get_stylesheet_directory_uri() . '/admin/');
}
require_once (OPTIONS_FRAMEWORK_URL . 'options-framework.php');
}
include(get_template_directory() . '/functions/tech-meta-box.php');
// Loads custom meta boxes on single post and page edit screen
if (!isset($content_width)) {
$content_width = tech_content_width();
}
add_action( 'after_setup_theme', 'techozoic_setup' );
/**
* Techozoic Theme setup
*
* Setup theme translation, theme features, menus, and custom header
*
*
* @access private
* @since 2.0
*/
function techozoic_setup() {
global $content_width;
load_theme_textdomain( 'techozoic', get_template_directory() . '/languages');
$locale = get_locale();
$locale_file = get_template_directory() . "/languages/$locale.php";
if ( is_readable($locale_file) )
require_once($locale_file);
// Include other custom functions files
include(get_template_directory() . '/functions/tech-widget.php');
include(get_template_directory() . '/functions/tech-comments-functions.php');
include(get_template_directory() . '/functions/tech-css.php');
add_theme_support( 'post-thumbnails' );
add_image_size( 'single-post-thumbnail', $content_width, 9999 );
//WP 2.9 Post Thumbnail Support
add_theme_support('automatic-feed-links');
//WP Auto Feed Links
add_theme_support( 'post-formats', array( 'aside', 'gallery', 'quote', 'status') );
//WP Post Format
register_nav_menus( array(
'primary' => __( 'Header Navigation', 'techozoic' ),
'sidebar' => __( 'Sidebar Navigation', 'techozoic'),
'footer' => __('Footer Navigation', 'techozoic'),
) );
//WP Navigation Menu
add_theme_support( 'custom-header', array( 'random-default' => true ) );
//WP Custom Header - random roation by default
define( 'HEADER_TEXTCOLOR', '' );
define( 'HEADER_IMAGE', '' );
define( 'HEADER_IMAGE_HEIGHT', of_get_option('header_height','200') );
define( 'HEADER_IMAGE_WIDTH', of_get_option('header_width','1000') );
define('NO_HEADER_TEXT', true );
add_custom_image_header( 'techozoic_header_style', 'techozoic_admin_header_style', 'techozoic_admin_header_image' );
register_default_headers( array(
'grunge' => array(
'url' => '%s/images/headers/Grunge.jpg',
'thumbnail_url' => '%s/images/headers/Grunge-thumbnail.jpg',
'description' => __( 'Grunge', 'techozoic' )
),
'landscape' => array(
'url' => '%s/images/headers/Landscape.jpg',
'thumbnail_url' => '%s/images/headers/Landscape-thumbnail.jpg',
'description' => __( 'Landscape', 'techozoic' )
),
'random_lines_1' => array(
'url' => '%s/images/headers/Random_Lines_1.jpg',
'thumbnail_url' => '%s/images/headers/Random_Lines_1-thumbnail.jpg',
'description' => __( 'Random Lines 1', 'techozoic' )
),
'random_lines_2' => array(
'url' => '%s/images/headers/Random_Lines_2.jpg',
'thumbnail_url' => '%s/images/headers/Random_Lines_2-thumbnail.jpg',
'description' => __( 'Random Lines 2', 'techozoic' )
),
'technology' => array(
'url' => '%s/images/headers/Technology.jpg',
'thumbnail_url' => '%s/images/headers/Technology-thumbnail.jpg',
'description' => __( 'Technology', 'techozoic' )
),
) );
}
/**
* Techozoic header style
*
* Custom header frontend style.
*
*
* @access private
* @since 2.0
*/
function techozoic_header_style() {
?>
<style type="text/css">
#header {
background-image: url(<?php header_image(); ?>);
}
</style>
<?php
}
/**
* Techozoic admin header style
*
* Custom header admin page style.
*
*
* @access private
* @since 2.0
*/
function techozoic_admin_header_style() {
?>
<style type="text/css">
#headimg img {
max-width: 1000px;
height: auto;
}
</style>
<?php
}
/**
* Techozoic admin header html
*
* Custom admin header html.
*
*
* @access private
* @since 2.0
*/
function techozoic_admin_header_image() { ?>
<div id="headimg">
<?php $header_image = get_header_image();
if ( ! empty( $header_image ) ) : ?>
<img src="<?php echo esc_url( $header_image ); ?>" alt="" />
<?php endif; ?>
</div>
<?php }
/**
* Techozoic comment reply enqueue
*
* function enqueuing comment reply script, to be added to header if needed.
*
*
* @access private
* @since 2.0.1
*/
function techozoic_enqueue_comment_reply() {
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'techozoic_enqueue_comment_reply' );
/**
* Techozoic Theme Logo
*
* function for option page hook to output css to head to change icon.
*
*
* @access private
* @since 2.0
*/
add_action('admin_head-appearance_page_options-framework', 'techozoic_theme_logo');
add_action('admin_head-appearance_page_options-backup', 'techozoic_theme_logo');
function techozoic_theme_logo(){
?>
<style type="text/css">
#icon-themes, #icon-import-export {
background: url(" <?php echo get_template_directory_uri() ?>/images/techozoic-logo-small.png") no-repeat scroll 2px 0px transparent;
}
</style>
<?php
}
/**
* Techozoic custom menu walker
*
* Outputs custom menu class if menu has children.
*
* @access private
* @since 2.0
*/
class techozoic_menu_walker extends Walker_Nav_Menu {
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ){
$id_field = $this->db_fields['id'];
if ( is_object( $args[0] ) ) {
$args[0]->has_children = ! empty( $children_elements[$element->$id_field] );
}
return parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = $childclass = '';
if ($args->has_children){
$childclass = 'has_children';
}
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
$class_names = ' class="' . esc_attr( $class_names ) . ' ' . $childclass . '"';
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
$id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
$output .= $indent . '<li' . $id . $value . $class_names .'>';
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
}
/**
* Techozoic change saniziation
*
* Removes standard options page filter and applies custom filter
*
* @access private
* @since 2.0
*/
add_action('admin_init','optionscheck_change_santiziation', 10,2);
function optionscheck_change_santiziation() {
remove_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' );
add_filter( 'of_sanitize_textarea', 'tech_sanitize_textarea' );
}
/**
* Techozoic Sanitize Textarea Filter
*
* Used to filter textarea input fields from option page
*
* @param string unfiltered text from option page
* @return string filtered text to store in database
*
* @access private
* @since 2.0
*/
function tech_sanitize_textarea($input) {
global $allowedposttags;
$custom_allowedtags["embed"] = array(
"src" => array(),
"type" => array(),
"allowfullscreen" => array(),
"allowscriptaccess" => array(),
"height" => array(),
"width" => array()
);
$custom_allowedtags["small"] = array();
$custom_allowedtags["script"] = array(
"src" => array(),
"type" => array()
);
$custom_allowedtags["iframe"] = array(
"src" => array(),
"height" => array(),
"width" => array(),
"frameborder" => array(),
"allowfullscreen" => array()
);
$custom_allowedtags = array_merge($custom_allowedtags, $allowedposttags);
$output = wp_kses( $input, $custom_allowedtags);
return $output;
}
/**
* Techozoic Exclude aside/status post format from RSS
*
* Remove certain post formats from feed query
*
* @param string wp_query from hook
* @return string wp_query with post formats removed.
*
* @access public
* @since 2.0
*/
add_action( 'pre_get_posts', 'tech_exclude_post_formats_from_feeds' );
function tech_exclude_post_formats_from_feeds( &$wp_query ) {
// Only do this for feed queries:
if ( $wp_query->is_feed() ) {
// Array of post formats to exclude, by slug,
$post_formats_to_exclude = array(
'post-format-status',
'post-format-aside'
);
// Extra query to hack onto the $wp_query object:
$extra_tax_query = array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => $post_formats_to_exclude,
'operator' => 'NOT IN'
);
$tax_query = $wp_query->get( 'tax_query' );
if ( is_array( $tax_query ) ) {
$tax_query = $tax_query + $extra_tax_query;
} else {
$tax_query = array( $extra_tax_query );
}
$wp_query->set( 'tax_query', $tax_query );
}
}
/**
* Techozoic Google Plus one JS
*
* Output javascript need for plus one button.
*
*
* @access public
* @since 2.0
*/
add_action('wp_footer', 'tech_plus_one');
function tech_plus_one() {
echo "<script type=\"text/javascript\">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>";
}
/**
* Techozoic Theme Links
*
* Used to output links to theme support and rss feed of theme news
*
* @param string CSS class to be applied to div around theme links
* @return string HTML for theme links box
*
* @access public
* @since 1.9.3
*/
function techozoic_links_box($class="tech_links_box") {
$output =' <div class="' . $class . '" style="float:right;width: 48%;">';
// Get RSS Feed(s)
$feed_address = "http://techozoic.clark-technet.com/category/news/feed";
$feed_items = 5;
$tech_changelog = get_template_directory_uri() . '/changelog.php';
$output .= "<h3 style='background:none;cursor:default;'>" . __('Techozoic News','techozoic') . "</h3>";
include_once(ABSPATH . WPINC . '/feed.php');
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed($feed_address);
if (!is_wp_error( $rss ) ) {
// Checks that the object is created correctly
// Figure out how many total items there are, but limit it to $feed_items.
$maxitems = $rss->get_item_quantity($feed_items);
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items(0, $maxitems);
$output .='<ul>';
if (isset($maxitems) && $maxitems == 0) {
$output .= '<li>' . __("No News.","techozoic") . '</li>';
} else {
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) {
$output .= "<li>
<a href='{$item->get_permalink()}' target='_blank' title='{$item->get_title()}'>
{$item->get_title()}</a>
</li>";
}
$output.='</ul>';
}
}
$output .="<h3 style='background:none;cursor:default'>" . __('Techozoic Links','techozoic') . "</h3>
<ul>
<li>
<a href='http://clark-technet.com/theme-support/techozoic'>" . __('Support Forum','techozoic') . "</a>
</li>
<li>
<a href='http://techozoic.clark-technet.com/documentation/'>" . __('Documentation','techozoic') . "</a>
</li>
<li>
<a href='http://techozoic.clark-technet.com/documentation/faq/'>" . __('FAQ','techozoic') . "</a>
</li>
<li>
<a href='$tech_changelog' onclick='return changelog(\"$tech_changelog\")'>" . __('Change Log','techozoic') . "</a>
</li>
</div>";
echo $output;
}
/**
* Techozoic All Image Size Links
*
* Used to output links to all available images sizes of wp_attachment
* Code adapted from Justin Tadlock
* http://justintadlock.com/archives/2011/01/28/linking-to-all-image-sizes-in-wordpress
*
* @return string Joined array of all image size links.
*
* @access public
* @since 1.9.3
*/
function tech_image_links() {
if ( !wp_attachment_is_image( get_the_ID() ) ){
return;
}
$links = array();
$sizes = get_intermediate_image_sizes();
$sizes[] = 'full';
foreach ( $sizes as $size ) {
$image = wp_get_attachment_image_src( get_the_ID(), $size );
if ( !empty( $image ) && ( true == $image[3] || 'full' == $size ) ) {
$links[] = "<a class='image-size-link' href='{$image[0]}'>{$image[1]} × {$image[2]}</a>";
}
}
return join( ' <span class="sep">|</span> ', $links );
}
/**
* Techozoic excerpt location
*
* Used to check whether current page type is in excerpt locations set in options
*
* @param string Current page type
* @return bool Return if current page is in excerpt_location array
*
* @access public
* @since 1.9.3
*/
function tech_excerpt($where){
$locs = of_get_option('excerpt_location', array("tag" => '1'));
if ($locs[$where] == '1'){
return true;
} else {
return false;
}
}
/**
* Techozoic social icons location
*
* Used to check whether current page type is in post social media locations set in options
*
* @param string Current page type
* @return bool Return if current page is in post_social_media_location array
*
* @access public
* @since 1.9.3
*/
function tech_icons($where){
$locs = of_get_option('post_social_media_location', array("main" =>"1",'single'=>'1'));
if ($locs[$where] == '1'){
return true;
} else {
return false;
}
}
/**
* Techozoic excerpt filter
*
* Filter that replaces ellipses with proper html ententity and link to single post page
*
* @param string exceprt text
* @return string string replaced excerpt text
*
* @access private
* @since 1.9.3
*/
add_filter('the_excerpt', 'tech_excerpt_filter'); // Replaces [...] at end of excerpt with link to single post page.
function tech_excerpt_filter($text){
global $post;
return str_replace('[...]', '<a href="'. get_permalink($post->ID) . '">' . ' [… ' . __('Read More', 'techozoic') . ']' . '</a>', $text);
}
if (of_get_option('google_font','0') == '1') {
/**
* Techozoic google font
*
* Enqueues google font stylesheet based on google_fonts option
*
*
* @access private
* @since 1.9.3
*/
add_action('wp_enqueue_scripts','tech_google_font');
function tech_google_font() {
global $tech;
$font_name = of_get_option('google_font_family','');
$tech_google_font = str_ireplace(' ', '+', $font_name);
$tech_google_font_decoration = of_get_option('google_font_decoration','none');
if ($tech_google_font_decoration != "none"){
wp_enqueue_style('google_fonts' , "http://fonts.googleapis.com/css?family={$tech_google_font}:{$tech_google_font_decoration}", '', '', 'screen');
} else {
wp_enqueue_style('google_fonts' , "http://fonts.googleapis.com/css?family={$tech_google_font}", '', '', 'screen');
}
}
}//End if goolge_font check
/**
* Techozoic comment count
*
* Filter that displays correct comment count.
* http://www.wpbeginner.com/wp-tutorials/display-the-most-accurate-comment-count-in-wordpress/
*
*
* @param string filter variable
* @return string correct comment count
*
* @access private
* @since 1.9.3
*/
add_filter('get_comments_number', 'tech_comment_count', 0);
function tech_comment_count( $count ) {
if ( ! is_admin() ) {
global $id;
$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
return count($comments_by_type['comment']);
} else {
return $count;
}
}
/**
* Techozoic WP 3 menu fallback
*
* Callback for use in wp_nav_menu when no menu is assigned.
*
*
* @access private
* @since 1.9.1
*/
function tech_menu_fallback(){
$output = ' <ul id="dropdown"> ';
$clean_page_list = wp_list_pages('sort_column=menu_order&title_li=&echo=0');
$clean_page_list = preg_replace('/title=\"(.*?)\"/','',$clean_page_list);
$output .= $clean_page_list;
$output .= '</ul>';
echo $output;
}
/**
* Techozoic Font Resize Script
*
* Enqueues and register font resize script used for Techozoic font resize widget.
*
*
* @access private
* @since 1.9.1
*/
if ( is_active_widget(false ,false, 'techozoic_font_size') ) {
add_action('template_redirect', 'tech_font_size_script');
}
function tech_font_size_script() {
$script_dir = get_template_directory_uri() . '/js/';
wp_register_script('font-size', $script_dir .'font-resize.js', array('jquery'), '1.0');
wp_enqueue_script('font-size');
}
/**
* Techozoic $content_width Function
*
* Sets $content_width variable used for image sizes by WordPress based on whether the
* options are set to fixed or fluid width. If set to fluid width, set to 500 otherwise
* width is calculated from fixed widths set.
*
* @return int content width
*
* @access private
* @since 1.8.8
*/
function tech_content_width(){
global $tech;
$p_width = of_get_option('page_width','90');
$c_width = of_get_option('main_column_width','50');
$page = of_get_option('page_type','fluid');
if ($page == "fixed" && $p_width != 0 && $c_width != 0) {
$c_width = $c_width /100;
$output = $p_width * $c_width;
} else {
$output = 500;
}
return $output;
}
/**
* Techozoic footer text function
*
* Used to replace shortcodes used in footer_text option with correct values.
*
*
* @access public
* @since 1.8.8
*/
add_action('tech_footer', 'tech_footer_text'); // Adds custom footer text defined on option page to footer.
function tech_footer_text(){
$theme_data = get_theme_data(get_template_directory() . '/style.css');
$version = $theme_data['Version'];
$string = of_get_option('footer_text','%COPYRIGHT% %BLOGNAME% | %THEMENAME% %THEMEVER% by %THEMEAUTHOR%. | %TOP% <br /> <small>%MYSQL%</small>');
$shortcode = array('/%BLOGNAME%/i','/%THEMENAME%/i','/%THEMEVER%/i','/%THEMEAUTHOR%/i','/%TOP%/i','/%COPYRIGHT%/i','/%MYSQL%/i');
$output = array(get_bloginfo('name'),"Techozoic",$version,'<a href="http://clark-technet.com/"> Jeremy Clark</a>','<a href="#top">'. __('Top' ,'techozoic') .'</a>','© '. date('Y'),sprintf(__('%1$d mySQL queries in %2$s seconds.','techozoic'), get_num_queries(),timer_stop(0)));
echo preg_replace($shortcode, $output, $string);
}
/**
* Techozoic Sidebar Display Function
*
* Determine which sidebar template should be shown based on options.
*
*
* @param string location of current template function called from
*
* @access public
* @since 1.8.8
*/
function tech_show_sidebar($loc) {
if (of_get_option('column','3') > 1) {
switch (of_get_option('sidebar_pos','3-col')) {
case "3-col":
$left = 1;
$right = 1;
break;
case "3-col-right":
$left = 0;
$right = 2;
break;
case "3-col-left":
$left = 2;
$right = 0;
break;
case "2-col-right":
$left = 0;
$right = 1;
break;
case "2-col-left":
$left = 1;
$right = 0;
break;
}
if ($loc == "l" && $left > 0){
get_template_part('sidebar','left');
if ($left > 1){
get_sidebar();
}
}
if ($loc == "r" && $right > 0){
get_sidebar();
if ($right > 1){
get_template_part('sidebar','left');
}
}
}
}
/**
* Techozoic Social Media Icons Function
*
* Echos the social media icon links and images as set in options.
*
*
* @param bool function called from home page or single page
*
* @access public
* @since 1.8.8
*/
function tech_social_icons($home=true){
global $tech, $post;
$short_link = home_url()."/?p=".$post->ID;
$home_icons = of_get_option('home_social_icons',array('delicious'=>'1','digg'=>'1','rss'=>'1'));
$single_icons = of_get_option('single_social_icons',array('delicious'=>'1','digg'=>'1','rss'=>'1'));
$image = get_template_directory_uri() . "/images/icons";
$link = get_permalink();
$title = $post->post_title;
$email_title = preg_replace('/&/i', 'and',$title);
$url_title = urlencode($post->post_title);
$excerpt = urlencode(wp_trim_excerpt($post->post_excerpt));
$excerpt_mail = wp_trim_excerpt($post->post_excerpt);
$excerpt_mail = preg_replace("/&#?[a-z0-9]{2,8};/i","",$excerpt_mail);
$home_title = urlencode(get_bloginfo( 'name' ));
$social_links = array(
"delicious" => "<a href=\"http://delicious.com/post?url={$link}&title={$url_title}\" title=\"" . __('del.icio.us this!','techozoic') . "\" target=\"_blank\"><img src=\"{$image}/delicious_16.png\" alt=\"" . __('del.icio.us this!','techozoic') . "\" /></a>",
"digg" => "<a href=\"http://digg.com/submit?phase=2&url={$link}&title={$url_title} \" title=\"" . __('Digg this!','techozoic') . "\" target=\"_blank\"><img src=\"{$image}/digg_16.png\" alt=\"" . __('Digg this!','techozoic') . "\"/></a>",
"email" => "<a href=\"mailto:?subject={$email_title}&body={$excerpt_mail} {$link}\" title=\"" . __('Share this by email.','techozoic') . "\"><img src=\"{$image}/email_16.png\" alt=\"" . __('Share this by email.','techozoic') . "\"/></a>",
"facebook" => "<a href=\"http://www.facebook.com/share.php?u={$link}&t={$url_title}\" title=\"" . __('Share on Facebook!','techozoic') . "\" target=\"_blank\"><img src=\"{$image}/facebook_16.png\" alt=\"" . __('Share on Facebook!','techozoic') . "\"/></a>",
"linkedin" => "<a href =\"http://www.linkedin.com/shareArticle?mini=true&url={$link}&title={$url_title}&summary={$excerpt}&source={$home_title}\" title=\"" . __('Share on LinkedIn!','techozoic') . "\" target=\"_blank\"><img src=\"{$image}/linkedin_16.png\" alt=\"" . __('Share on LinkedIn!','techozoic') . "\" /></a>",
"myspace" => "<a href=\"http://www.myspace.com/Modules/PostTo/Pages/?u={$link}&t={$url_title}\" title=\"" . __('Share on Myspace!','techozoic') . "\" target=\"_blank\"><img src=\"{$image}/myspace_16.png\" alt=\"" . __('Share on Myspace!','techozoic') . "\"/></a>",
"newsvine" => "<a href=\"http://www.newsvine.com/_tools/seed&save?u={$link}\" title=\"" . __('Share on NewsVine!','techozoic') . "\" target=\"_blank\"><img src=\"{$image}/newsvine_16.png\" alt=\"" . __('Share on NewsVine!','techozoic') . "\"/></a>",
"stumbleupon" => "<a href=\"http://www.stumbleupon.com/submit?url={$link}&title={$url_title}\" title=\"" . __('Stumble Upon this!','techozoic') . "\" target=\"_blank\"><img src=\"{$image}/stumbleupon_16.png\" alt=\"" . __('Stumble Upon this!','techozoic') . "\"/></a>",
"twitter" => "<a href=\"http://twitter.com/home?status=Reading%20{$url_title}%20on%20{$short_link}\" title=\"" . __('Tweet this!','techozoic') . "\" target=\"_blank\"><img src=\"{$image}/twitter_16.png\" alt=\"" . __('Tweet this!','techozoic') . "\"/></a>",
"reddit" => "<a href=\"http://reddit.com/submit?url={$link}&title={$url_title}\" title=\"" . __('Share on Reddit!','techozoic') . "\" target=\"_blank\"><img src=\"{$image}/reddit_16.png\" alt=\"" . __('Share on Reddit!','techozoic') . "\" /></a>",
"rss" => "<a href=\"".get_post_comments_feed_link()."\" title=\"".__('Subscribe to Feed','techozoic')."\"><img src=\"{$image}/rss_16.png\" alt=\"" . __('RSS 2.0','techozoic') . "\"/></a>",
"google" => "<g:plusone size=\"small\" annotation=\"none\" expandto=\"right\" href=\"$link\"></g:plusone>");
if ($home == true){
if (is_array($home_icons)){
foreach ($home_icons as $key => $value){
if ($value == "1"){
echo $social_links[$key] ." ";
}
}
}
} else {
if(is_array($single_icons)){
foreach ($single_icons as $key => $value){
if ($value == "1"){
echo $social_links[$key] ." ";
}
}
}
}
}
/**
* Techozoic About Icons Function
*
* Used to display social media profile links for Techozoic About widget.
*
*
* @param int if facebook profile link is checked
* @param int if myspace profile link is checked
* @param int if twitter profile link is checked
*
* @access public
* @since 1.8.8
*/
function tech_about_icons($fb=0,$my=0,$twitter=0){
global $tech;
$fb_profile = $tech['facebook_profile'];
$my_profile = $tech['myspace_profile'];
$twitter_profile = $tech['twitter_profile'];
$image = get_template_directory_uri() . "/images/icons";
if ($fb !=0){
echo "<li><a href=\"{$fb_profile}\" title=\"".__('Follow me on Facebook','techozoic')."\"><img src=\"{$image}/facebook_32.png\"></a></li>";
}
if ($my !=0){
echo "<li><a href=\"{$my_profile}\" title=\"".__('Follow me on Myspace','techozoic')."\"><img src=\"{$image}/myspace_32.png\"></a></li>";
}
if ($twitter !=0){
echo "<li><a href=\"{$twitter_profile}\" title=\"".__('Follow me on Twitter','techozoic')."\"><img src=\"{$image}/twitter_32.png\"></a></li>";
}
}
/**
* Techozoic Home Page Comment Preview
*
* Comment preview section on home page. Pull comment excerpt for approved comments
* displays in an unordered list at bottom of each post.
*
* @param string id of current post to pull comments for
*
* @access public
* @since 1.8.7
*/
function tech_comment_preview($ID){
global $comment;
$tech_comment_num = of_get_option('comment_preview_num','3');
$output = "";
$comment_array = get_comments(array('post_id'=>$ID,'number'=>$tech_comment_num,'type'=>'comment','status'=>'approve'));
if ($comment_array) {
$output .= '<ul class="comment-preview">';
foreach($comment_array as $comment){
$output .= '<li class="comments-link">';
$output .= '<div class="comment-author">';
$output .= '<a href="'. get_comment_link() .'" title="'. $comment->comment_author . __(' posted on ','techozoic') . get_comment_date() .'">';
$output .= $comment->comment_author . __(' posted on ','techozoic') . get_comment_date();
$output .= '</a>';
$output .= '</div>';
$output .= '<div class="comment-text">';
$output .= get_comment_excerpt($comment->comment_ID);
$output .= '</div>';
$output .= '</li>';
}
$output .= '</ul>';
}
print $output;
}
if ( is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ){
/**
* Techozoic Custom Activation Message
*
* Used to show a custom activation message with links to theme options page and
* change log.
*
* @access private
* @since 1.8.6
*/
add_action( 'admin_notices', 'techozoic_show_notice' ); // Shows custom theme activation notice with links to option page and changelog
function techozoic_show_notice() { ?>
<div id="message" class="updated fade">
<p><?php printf( __( 'Theme activated! This theme contains <a href="%s">theme options</a> and <a href="%s">custom sidebar widgets</a>.<br /> See <a href="%s">Change Log</a>.', 'techozoic' ), admin_url( 'themes.php?page=options-framework' ), admin_url( 'widgets.php' ) , get_template_directory_uri() . "/changelog.php\" onclick=\"return changelog('". get_template_directory_uri() ."/changelog.php')\"") ?></p>
</div>
<style type="text/css">#message2, #message0 { display: none; }</style>
<?php
}
} //End If activation page check
if ( is_admin() && (isset($_GET['page'] ) && $_GET['page'] == 'custom-header') && $pagenow == "themes.php" ){
/**
* Techozoic header notice
*
* Used to show that header height and width can be set on the options page.
*
*
* @access private
* @since 2.0
*/
add_action( 'admin_notices', 'techozoic_header_notice' ); // Shows custom theme activation notice with links to option page and changelog
function techozoic_header_notice() { ?>
<div id="message" class="updated fade">
<p><?php printf(__('Header height and width and aligment can be set on the <a href="%s">theme options</a> page.','techozoic'),admin_url( 'themes.php?page=options-framework' )); ?></p>
</div>
<?php
}
}//End if custom header page
/**
* Techozoic add dashboard widget
*
* Add dashboard widget defined in techozoic_dashboard_widget.
*
* @access private
*/
function tech_dashboard_widgets() {
global $wp_meta_boxes;
wp_add_dashboard_widget('techozoic_dashboard_widget', 'Techozoic Theme Setup', 'techozoic_dashboard_widget');
}
/**
* Techozoic dashboard widget content
*
* Adds dashboard widget with links to options pages, support, documentation, and
* donate links.
*
*
*
* @access private
* @since 1.9.3
*/
add_action('wp_dashboard_setup', 'tech_dashboard_widgets'); //Add Techozoic dashboard widget with info for theme and donate button
function techozoic_dashboard_widget() { ?>
<div style="float:left;width: 46%;margin:1% 10px;">
<div class="alignleft">
<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="10999960">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.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>
<p>
<?php _e('Thank you for using the Techozoic Theme. ' ,'techozoic');
if (current_user_can('edit_theme') || current_user_can('edit_theme_options')) {
printf(__('Visit the %s to start customizing Techozoic. ' ,'techozoic'),'<a href="themes.php?page=options-framework" title="' . __("options page" ,"techozoic").'">'.__("options page" ,"techozoic").'</a>');
}
printf(__('If your having problems or would like to suggest a new feature, please visit the %s.' ,'techozoic'), '<a href="http://clark-technet.com/theme-support/techozoic/" title="' .__('Support Forum' ,'techozoic').'"> '.__('support forum' ,'techozoic').'</a>')?>
</p>
</div>
<?php techozoic_links_box('tech_links_front'); ?>
<div class="clear"> </div>
<?php
}
/**
* Techozoic breadcrumb navigation
*
* Displays breadcrumb navigation if option is set.
*
* @access public
*/
function tech_breadcrumbs() {
// Thanks to dimox for the code
//http://dimox.net/wordpress-breadcrumbs-without-a-plugin/
global $tech;
$delimiter = '»';
$name = __('Home' ,'techozoic');
$currentBefore = '<span class="current">';
$currentAfter = '</span>';
if ( !is_home() || !is_front_page() || is_paged() ) {
echo '<div id="crumbs">';
global $post;
$home = home_url();
echo '<a href="' . $home . '">' . $name . '</a> ' . $delimiter . ' ';
if ( is_category() ) {
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$thisCat = $cat_obj->term_id;
$thisCat = get_category($thisCat);
$parentCat = get_category($thisCat->parent);
if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
echo $currentBefore . __('Archive for category '' ,'techozoic');
single_cat_title();