Guest User

Untitled

a guest
Jul 15th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.77 KB | None | 0 0
  1. <?php
  2.  
  3. /*-----------------------------------------------------------------------------------
  4.  
  5. TABLE OF CONTENTS
  6.  
  7. - Add custom styling to HEAD
  8. - Add custom typograhpy to HEAD
  9. - Add layout to body_class output
  10.  
  11. -----------------------------------------------------------------------------------*/
  12.  
  13.  
  14. add_action( 'woo_head','woo_custom_styling' ); // Add custom styling to HEAD
  15. add_action( 'woo_head','woo_custom_typography' ); // Add custom typography to HEAD
  16. add_filter( 'body_class','woo_layout_body_class' ); // Add layout to body_class output
  17.  
  18.  
  19. /*-----------------------------------------------------------------------------------*/
  20. /* Add Custom Styling to HEAD */
  21. /*-----------------------------------------------------------------------------------*/
  22. if (!function_exists( 'woo_custom_styling')) {
  23. function woo_custom_styling() {
  24.  
  25. global $woo_options;
  26.  
  27. $output = '';
  28. // Get options
  29. $body_color = $woo_options[ 'woo_body_color' ];
  30. $body_img = $woo_options[ 'woo_body_img' ];
  31. $body_repeat = $woo_options[ 'woo_body_repeat' ];
  32. $body_position = $woo_options[ 'woo_body_pos' ];
  33. $link = $woo_options[ 'woo_link_color' ];
  34. $hover = $woo_options[ 'woo_link_hover_color' ];
  35. $button = $woo_options[ 'woo_button_color' ];
  36.  
  37. // Add CSS to output
  38. if ($body_color)
  39. $output .= 'body {background:'.$body_color.'}' . "\n";
  40.  
  41. if ($body_img)
  42. $output .= 'body {background-image:url( '.$body_img.')}' . "\n";
  43.  
  44. if ($body_img && $body_repeat && $body_position)
  45. $output .= 'body {background-repeat:'.$body_repeat.'}' . "\n";
  46.  
  47. if ($body_img && $body_position)
  48. $output .= 'body {background-position:'.$body_position.'}' . "\n";
  49.  
  50. if ($link)
  51. $output .= 'a {color:'.$link.'}' . "\n";
  52.  
  53. if ($hover)
  54. $output .= 'a:hover, .post-more a:hover, .post-meta a:hover, .post p.tags a:hover {color:'.$hover.'}' . "\n";
  55.  
  56. if ($button) {
  57. $output .= 'a.button, a.comment-reply-link, #commentform #submit, #contact-page .submit {background:'.$button.';border-color:'.$button.'}' . "\n";
  58. $output .= 'a.button:hover, a.button.hover, a.button.active, a.comment-reply-link:hover, #commentform #submit:hover, #contact-page .submit:hover {background:'.$button.';opacity:0.9;}' . "\n";
  59. }
  60.  
  61. // Output styles
  62. if (isset($output) && $output != '') {
  63. $output = strip_tags($output);
  64. $output = "<!-- Woo Custom Styling -->\n<style type=\"text/css\">\n" . $output . "</style>\n";
  65. echo $output;
  66. }
  67.  
  68. }
  69. }
  70.  
  71. /*-----------------------------------------------------------------------------------*/
  72. /* Add custom typograhpy to HEAD */
  73. /*-----------------------------------------------------------------------------------*/
  74. if (!function_exists( 'woo_custom_typography')) {
  75. function woo_custom_typography() {
  76.  
  77. // Get options
  78. global $woo_options;
  79.  
  80. // Reset
  81. $output = '';
  82.  
  83. // Add Text title and tagline if text title option is enabled
  84. if ( $woo_options[ 'woo_texttitle' ] == "true" ) {
  85.  
  86. if ( $woo_options[ 'woo_font_site_title' ] )
  87. $output .= '#logo .site-title a {'.woo_generate_font_css($woo_options[ 'woo_font_site_title' ]).'}' . "\n";
  88. if ( $woo_options[ 'woo_tagline' ] == "true" AND $woo_options[ 'woo_font_tagline' ] )
  89. $output .= '#logo .site-description {'.woo_generate_font_css($woo_options[ 'woo_font_tagline' ]).'}' . "\n";
  90. }
  91.  
  92. if ( $woo_options[ 'woo_typography' ] == "true") {
  93.  
  94. if ( $woo_options[ 'woo_font_body' ] )
  95. $output .= 'body { '.woo_generate_font_css($woo_options[ 'woo_font_body' ], '1.5').' }' . "\n";
  96.  
  97. if ( $woo_options[ 'woo_font_nav' ] )
  98. $output .= '#navigation, #navigation .nav a, #rb_new_menu, #rb_new_menu .nav a { '.woo_generate_font_css($woo_options[ 'woo_font_nav' ], '1.4').' }' . "\n";
  99.  
  100. if ( $woo_options[ 'woo_font_about' ] )
  101. $output .= '#about .bio p { '.woo_generate_font_css($woo_options[ 'woo_font_about' ]).' }' . "\n";
  102.  
  103. if ( $woo_options[ 'woo_font_post_title' ] )
  104. $output .= '.post .title { '.woo_generate_font_css($woo_options[ 'woo_font_post_title' ]).' }' . "\n";
  105.  
  106. if ( $woo_options[ 'woo_font_post_date' ] )
  107. $output .= '.posttype span.day { '.woo_generate_font_css($woo_options[ 'woo_font_post_date' ]).' }' . "\n";
  108.  
  109. if ( $woo_options[ 'woo_font_post_meta' ] )
  110. $output .= '.post-meta { '.woo_generate_font_css($woo_options[ 'woo_font_post_meta' ]).' }' . "\n";
  111.  
  112. if ( $woo_options[ 'woo_font_post_entry' ] )
  113. $output .= '.entry, .entry p { '.woo_generate_font_css($woo_options[ 'woo_font_post_entry' ], '1.5').' } h1, h2, h3, h4, h5, h6 { font-family: '.stripslashes($woo_options[ 'woo_font_post_entry' ]['face']).', arial, sans-serif; }' . "\n";
  114.  
  115. if ( $woo_options[ 'woo_font_widget_titles' ] )
  116. $output .= '.widget h3, .widget_woo_subscribe .title { '.woo_generate_font_css($woo_options[ 'woo_font_widget_titles' ]).' }' . "\n";
  117.  
  118. // Add default typography Google Font
  119. } else {
  120.  
  121. // Set default font face
  122. $woo_options['woo_default_face'] = array('face' => 'Six Caps');
  123.  
  124. // Output default font face
  125. if ( !empty( $woo_options['woo_default_face'] ) )
  126. $output .= 'h1, h2, h3, h4, h5, h6, .widget h3, .post .title, .archive_header, .widget_woo_subscribe .title { '.woo_generate_font_css($woo_options['woo_default_face']).' }' . "\n";
  127.  
  128. }
  129.  
  130. // Output styles
  131. if (isset($output) && $output != '') {
  132.  
  133. // Enable Google Fonts stylesheet in HEAD
  134. if (function_exists( 'woo_google_webfonts')) woo_google_webfonts();
  135.  
  136. $output = "<!-- Woo Custom Typography -->\n<style type=\"text/css\">\n" . $output . "</style>\n\n";
  137. echo $output;
  138.  
  139. }
  140.  
  141. }
  142. }
  143.  
  144. // Returns proper font css output
  145. if (!function_exists( 'woo_generate_font_css')) {
  146. function woo_generate_font_css($option, $em = '1') {
  147.  
  148. // Test if font-face is a Google font
  149. global $google_fonts;
  150. foreach ( $google_fonts as $google_font ) {
  151.  
  152. // Add single quotation marks to font name and default arial sans-serif ending
  153. if ( $option[ 'face' ] == $google_font[ 'name' ] )
  154. $option[ 'face' ] = "'" . $option[ 'face' ] . "', arial, sans-serif";
  155.  
  156. } // END foreach
  157.  
  158. if ( !@$option["style"] && !@$option["size"] && !@$option["unit"] && !@$option["color"] )
  159. return 'font-family: '.stripslashes($option["face"]).';';
  160. else
  161. return 'font:'.$option["style"].' '.$option["size"].$option["unit"].'/'.$em.'em '.stripslashes($option["face"]).';color:'.$option["color"].';';
  162. }
  163. }
  164.  
  165. // Output stylesheet and custom.css after custom styling
  166. remove_action( 'wp_head', 'woothemes_wp_head' );
  167. add_action( 'woo_head', 'woothemes_wp_head' );
  168.  
  169.  
  170. /*-----------------------------------------------------------------------------------*/
  171. /* Add layout to body_class output */
  172. /*-----------------------------------------------------------------------------------*/
  173. if (!function_exists( 'woo_layout_body_class')) {
  174. function woo_layout_body_class($classes) {
  175.  
  176. global $woo_options;
  177. $layout = $woo_options[ 'woo_site_layout' ];
  178.  
  179. // Set main layout on post or page
  180. if ( is_singular() ) {
  181. global $post;
  182. $single = get_post_meta($post->ID, '_layout', true);
  183. if ( $single != "" AND $single != "layout-default" )
  184. $layout = $single;
  185. }
  186.  
  187. // Add layout to $woo_options array for use in theme
  188. $woo_options[ 'woo_layout' ] = $layout;
  189.  
  190. // Add classes to body_class() output
  191. $classes[] = $layout;
  192. return $classes;
  193.  
  194. }
  195. }
  196.  
  197. /*-----------------------------------------------------------------------------------*/
  198. /* Featured Slider Settings */
  199. /*-----------------------------------------------------------------------------------*/
  200.  
  201. add_filter('woo_head', 'woo_slider_options');
  202. function woo_slider_options() {
  203.  
  204. global $woo_options;
  205.  
  206. if ($woo_options[ 'woo_slider' ] == 'true' && is_home() && !is_paged()): ?>
  207.  
  208. <script type="text/javascript">
  209. jQuery(document).ready(function(){
  210.  
  211. //Show slider before applying slides JS when document is ready
  212. jQuery('#slides').removeClass('hidden');;
  213.  
  214. jQuery('#slides').slides({
  215. autoHeight: true,
  216. effect: '<?php echo $woo_options[ 'woo_slider_effect' ]; ?>',
  217. container: 'slides_container',
  218. <?php if ($woo_options[ 'woo_slider_random' ] == "true"): ?>
  219. randomize: true,
  220. <?php endif; ?>
  221. <?php if ($woo_options[ 'woo_slider_hover' ] == "true"): ?>
  222. hoverPause: true,
  223. <?php endif; ?>
  224. <?php if ($woo_options[ 'woo_slider_auto' ] == "true"): ?>
  225. play: <?php echo $woo_options[ 'woo_slider_interval' ] * 1000; ?>,
  226. <?php endif; ?>
  227. slideSpeed: <?php echo $woo_options[ 'woo_slider_speed' ] * 1000; ?>,
  228. fadeSpeed: <?php echo $woo_options[ 'woo_fade_speed' ] * 1000; ?>,
  229. crossfade: true
  230. });
  231.  
  232. jQuery( '#slides .pagination' ).wrap( '<div class="slider-pag" />' );
  233.  
  234. });
  235. </script>
  236.  
  237. <?php endif;
  238.  
  239. }
  240.  
  241. /*-----------------------------------------------------------------------------------*/
  242. /* END */
  243. /*-----------------------------------------------------------------------------------*/
  244. ?>
Add Comment
Please, Sign In to add comment