Advertisement
prasannasp

Updated /graphene/includes/theme-head.php

Feb 24th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 23.25 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Get the custom style attributes, these are defined by theme options.
  4.  *
  5.  * @global type $graphene_settings
  6.  * @global type $graphene_defaults
  7.  * @global type $content_width
  8.  * @return string
  9.  */
  10. function graphene_get_custom_style(){
  11.     global $graphene_settings, $graphene_defaults, $content_width;
  12.    
  13.     $background = get_theme_mod( 'background_image', false);
  14.     $bgcolor = get_theme_mod( 'background_color', false);
  15.     $widgetcolumn = (is_front_page() && $graphene_settings['alt_home_footerwidget']) ? $graphene_settings['alt_footerwidget_column'] : $graphene_settings['footerwidget_column'];
  16.     $container_width = apply_filters( 'graphene_container_width', $graphene_settings['container_width'] );
  17.     $gutter = $graphene_settings['gutter_width'];
  18.     $grid_width = $graphene_settings['grid_width'];
  19.        
  20. $style = '';
  21.    
  22.     /* Disable default background if a custom background colour is defined */
  23.     if ( ! $background && $bgcolor ) {
  24.         $style .= 'body{background-image:none;}';
  25.     }
  26.        
  27.     /* Set the width of the bottom widget items if number of columns is specified */
  28.     if ( $widgetcolumn ) {
  29.         $widget_width = floor( ( ( ( $container_width - $gutter * 2 ) - 20 * ( $widgetcolumn - 1 ) ) / $widgetcolumn ) - 20 );
  30.         $style .= '#sidebar_bottom .sidebar-wrap{width:'.$widget_width.'px}';
  31.     }
  32.        
  33.     /* Set the width of the nav menu dropdown menu item width if specified */
  34.     if ( $graphene_settings['navmenu_child_width'] ) {
  35.         $nav_width = $graphene_settings['navmenu_child_width'];
  36.         $style .= '#nav li ul{width:'.$nav_width.'px;}';
  37.        
  38.         if ( ! is_rtl() ){
  39.             $background_left = -652-(200-$nav_width);
  40.             $tmp_width = $nav_width-35;
  41.            
  42.             $style .= ' #nav li ul ul{margin-left:'.$nav_width.'px}
  43.                         #header-menu ul li.menu-item-ancestor > a {
  44.                         background-position:'.$background_left.'px -194px;
  45.                         width:'.$tmp_width.'px;
  46.                        }
  47.                        #header-menu ul li.menu-item-ancestor:hover > a,
  48.                        #header-menu ul li.current-menu-item > a,
  49.                        #header-menu ul li.current-menu-ancestor > a {
  50.                         background-position:'.$background_left.'px -238px;
  51.                        }
  52.                         #secondary-menu ul li.menu-item-ancestor > a {
  53.                         background-position:'.$background_left.'px -286px;
  54.                         width:'.$tmp_width.'px;
  55.                         }
  56.                         #secondary-menu ul li.menu-item-ancestor:hover > a,
  57.                         #secondary-menu ul li.current-menu-item > a,
  58.                         #secondary-menu ul li.current-menu-ancestor > a {
  59.                         background-position:'.$background_left.'px -319px;
  60.                         }';
  61.         } else {
  62.             $style .= ' #nav li ul ul{margin-right:'.$nav_width.'px; margin-left: 0;}
  63.                         #header-menu ul li.menu-item-ancestor > a,
  64.                         #secondary-menu ul li.menu-item-ancestor > a {
  65.                         width:'.($nav_width-35).'px;
  66.                         }';
  67.         }
  68.        
  69.         $style .= '#header-menu ul li a{width:'.($nav_width-20).'px;}';
  70.         $style .= '#secondary-menu ul li a{width:'.($nav_width-30).'px;}';
  71.     }
  72.    
  73.     /* Header title text style */
  74.     $font_style = '';
  75.     $font_style .= ( $graphene_settings['header_title_font_type']) ? 'font-family:'.$graphene_settings['header_title_font_type'].';' : '';
  76.     $font_style .= ( $graphene_settings['header_title_font_lineheight']) ? 'line-height:'.$graphene_settings['header_title_font_lineheight'].';' : '';
  77.     $font_style .= ( $graphene_settings['header_title_font_size']) ? 'font-size:'.$graphene_settings['header_title_font_size'].';' : '';
  78.     $font_style .= ( $graphene_settings['header_title_font_weight']) ? 'font-weight:'.$graphene_settings['header_title_font_weight'].';' : '';
  79.     $font_style .= ( $graphene_settings['header_title_font_style']) ? 'font-style:'.$graphene_settings['header_title_font_style'].';' : '';
  80.     if ( $font_style ) { $style .= '.header_title { '.$font_style.' }'; }
  81.  
  82.     /* Header description text style */
  83.     $font_style = '';
  84.     $font_style .= ( $graphene_settings['header_desc_font_type']) ? 'font-family:'.$graphene_settings['header_desc_font_type'].';' : '';
  85.     $font_style .= ( $graphene_settings['header_desc_font_size']) ? 'font-size:'.$graphene_settings['header_desc_font_size'].';' : '';
  86.     $font_style .= ( $graphene_settings['header_desc_font_lineheight']) ? 'line-height:'.$graphene_settings['header_desc_font_lineheight'].';' : '';
  87.     $font_style .= ( $graphene_settings['header_desc_font_weight']) ? 'font-weight:'.$graphene_settings['header_desc_font_weight'].';' : '';
  88.     $font_style .= ( $graphene_settings['header_desc_font_style']) ? 'font-style:'.$graphene_settings['header_desc_font_style'].';' : '';
  89.     if ( $font_style ) { $style .= '.header_desc { '.$font_style.' }'; }
  90.    
  91.     /* Content text style */
  92.     $font_style = '';
  93.     $font_style .= ( $graphene_settings['content_font_type']) ? 'font-family:'.$graphene_settings['content_font_type'].';' : '';
  94.     $font_style .= ( $graphene_settings['content_font_size']) ? 'font-size:'.$graphene_settings['content_font_size'].';' : '';
  95.     $font_style .= ( $graphene_settings['content_font_lineheight']) ? 'line-height:'.$graphene_settings['content_font_lineheight'].';' : '';
  96.     $font_style .= ( $graphene_settings['content_font_colour'] != $graphene_defaults['content_font_colour']) ? 'color:'.$graphene_settings['content_font_colour'].';' : '';
  97.     if ( $font_style ) { $style .= '.entry-content, .sidebar, .comment-entry { '.$font_style.' }'; }
  98.    
  99.     /* Adjust post title if author's avatar is shown */
  100.     if ( $graphene_settings['show_post_avatar']) {
  101.         $tmp_margin = !is_rtl() ? 'margin-right' : 'margin-left';
  102.         $style .= '.post-title a, .post-title a:visited{display:block;'.$tmp_margin.':45px;padding-bottom:0;}';
  103.     }
  104.    
  105.     /* Slider height */
  106.     if ( $graphene_settings['slider_height']) {
  107.         $style .= '.featured_slider #slider_root{height:'.$graphene_settings['slider_height'].'px;}';
  108.     }
  109.    
  110.     /* Link header image */
  111.     if ( $graphene_settings['link_header_img'] && (HEADER_IMAGE_WIDTH != 900 || HEADER_IMAGE_HEIGHT != 198) ) {
  112.         $style .= '#header_img_link{width:'. HEADER_IMAGE_WIDTH .'px; height:'. HEADER_IMAGE_HEIGHT .'px;}';
  113.     }
  114.        
  115.     // Link style
  116.     if ( $graphene_settings['link_colour_normal'] != $graphene_defaults['link_colour_normal']) { $style.='a{color:'.$graphene_settings['link_colour_normal'].';}';}
  117.     if ( $graphene_settings['link_colour_visited'] != $graphene_defaults['link_colour_visited']) { $style.='a:visited{color:'.$graphene_settings['link_colour_visited'].';}';}
  118.     if ( $graphene_settings['link_colour_hover'] != $graphene_defaults['link_colour_hover']) { $style.='a:hover{color:'.$graphene_settings['link_colour_hover'].';}';}
  119.     if ( $graphene_settings['link_decoration_normal']) { $style.='a{text-decoration:'.$graphene_settings['link_decoration_normal'].';}';}
  120.     if ( $graphene_settings['link_decoration_hover']) { $style.='a:hover{text-decoration:'.$graphene_settings['link_decoration_hover'].';}';}
  121.    
  122.     // Custom column width
  123.     $style .= graphene_get_custom_column_width();
  124.    
  125.     return $style;
  126. }
  127.  
  128.  
  129. /**
  130.  * Get the custom colour style attributes defined by the theme colour settings
  131.  *
  132.  * @global type $graphene_settings
  133.  * @global type $graphene_defaults
  134.  * @return string
  135.  */
  136. function graphene_get_custom_colours(){
  137.     global $graphene_settings, $graphene_defaults;
  138.     $style = '';
  139.    
  140.     if ( ! is_admin() || strstr( $_SERVER["REQUEST_URI"], 'page=graphene_options&tab=display' ) ) {
  141.  
  142.         /* Customised colours */
  143.        
  144.         // Content area
  145.         if ( $graphene_settings['bg_content_wrapper'] != $graphene_defaults['bg_content_wrapper']) {$style .= '#content, .menu-bottom-shadow{background-color:'.$graphene_settings['bg_content_wrapper'].';}';}
  146.         if ( $graphene_settings['bg_content'] != $graphene_defaults['bg_content']) {$style .= '.post{background-color:'.$graphene_settings['bg_content'].';}';}
  147.         if ( $graphene_settings['bg_meta_border'] != $graphene_defaults['bg_meta_border']) {$style .= '.post-title, .post-title a, .post-title a:visited, .entry-footer{border-color:'.$graphene_settings['bg_meta_border'].';}';}
  148.         if ( $graphene_settings['bg_post_top_border'] != $graphene_defaults['bg_post_top_border']) {$style .= '.post{border-top-color:'.$graphene_settings['bg_post_top_border'].';}';}
  149.         if ( $graphene_settings['bg_post_bottom_border'] != $graphene_defaults['bg_post_bottom_border']) {$style .= '.post{border-bottom-color:'.$graphene_settings['bg_post_bottom_border'].';}';}
  150.         if ( $graphene_settings['bg_post_bottom_border'] != $graphene_defaults['bg_post_bottom_border']) {$style .= '.post{border-bottom-color:'.$graphene_settings['bg_post_bottom_border'].';}';}
  151.        
  152.         // Widgets
  153.         if ( $graphene_settings['bg_widget_item'] != $graphene_defaults['bg_widget_item']) {$style .= '.sidebar div.sidebar-wrap{background-color:'.$graphene_settings['bg_widget_item'].';}';}
  154.         if ( $graphene_settings['bg_widget_list'] != $graphene_defaults['bg_widget_list']) {$style .= '.sidebar ul li{border-color:'.$graphene_settings['bg_widget_list'].';}';}
  155.         if ( $graphene_settings['bg_widget_header_border'] != $graphene_defaults['bg_widget_header_border']) {$style .= '.sidebar h3{border-color:'.$graphene_settings['bg_widget_header_border'].';}';}
  156.         if ( $graphene_settings['bg_widget_title'] != $graphene_defaults['bg_widget_title']) {$style .= '.sidebar h3, .sidebar h3 a, .sidebar h3 a:visited{color:'.$graphene_settings['bg_widget_title'].';}';}
  157.         if ( $graphene_settings['bg_widget_title_textshadow'] != $graphene_defaults['bg_widget_title_textshadow']) {$style .= '.sidebar h3{text-shadow: 0 -1px '.$graphene_settings['bg_widget_title_textshadow'].';}';}
  158.         $grad_top = $graphene_settings['bg_widget_header_top'];
  159.         $grad_bottom = $graphene_settings['bg_widget_header_bottom'];
  160.         if ( $grad_bottom != $graphene_defaults['bg_widget_header_bottom'] || $grad_top != $graphene_defaults['bg_widget_header_top']) {$style .= '.sidebar h3{
  161.                 background: ' . $grad_top . ';
  162.                 background: -moz-linear-gradient( ' . $grad_top . ', ' . $grad_bottom . ' );
  163.                 background: -webkit-linear-gradient(top, ' . $grad_top . ', ' . $grad_bottom . ' );
  164.                 background: linear-gradient( ' . $grad_top . ', ' . $grad_bottom . ' );
  165.         }';}
  166.        
  167.         // Slider
  168.         $grad_top = $graphene_settings['bg_slider_top'];
  169.         $grad_bottom = $graphene_settings['bg_slider_bottom'];
  170.         if ( $grad_bottom != $graphene_defaults['bg_slider_bottom'] || $grad_top != $graphene_defaults['bg_slider_top']) {$style .= '.featured_slider {
  171.                 -pie-background: linear-gradient(left top, ' . $grad_top . ', ' . $grad_bottom . ' );
  172.                 background: ' . $grad_top . ';
  173.                 background: -moz-linear-gradient(left top, ' . $grad_top . ', ' . $grad_bottom . ' );
  174.                 background: -webkit-linear-gradient(left top, ' . $grad_top . ', ' . $grad_bottom . ' );
  175.                 background: linear-gradient(left top, ' . $grad_top . ', ' . $grad_bottom . ' );
  176.         }';}
  177.        
  178.         // Block button
  179.         $grad_top = $graphene_settings['bg_button'];
  180.         $grad_bottom = graphene_hex_addition( $grad_top, -26);
  181.         $grad_bottom_hover = graphene_hex_addition( $grad_top, -52);
  182.         $font_color = $graphene_settings['bg_button_label'];
  183.         $font_shadow = $graphene_settings['bg_button_label_textshadow'];
  184.         if ( $grad_top != $graphene_defaults['bg_button']) {
  185.             $style .= '.block-button, .block-button:visited, .Button, .button, #commentform #submit {
  186.                             background: ' . $grad_top . ';
  187.                             background: -moz-linear-gradient( ' . $grad_top . ', ' . $grad_bottom . ' );
  188.                             background: -webkit-linear-gradient(top, ' . $grad_top . ', ' . $grad_bottom . ' );
  189.                             background: linear-gradient( ' . $grad_top . ', ' . $grad_bottom . ' );
  190.                             border-color: ' . $grad_bottom . ';
  191.                             text-shadow: 0 -1px 1px ' . $font_shadow . ';
  192.                             color: ' . $font_color . ';
  193.                         }';
  194.             $style .= '.block-button:hover, .button:hover, #commentform #submit:hover {
  195.                             background: ' . $grad_top . ';
  196.                             background: -moz-linear-gradient( ' . $grad_top . ', ' . $grad_bottom_hover . ' );
  197.                             background: -webkit-linear-gradient(top, ' . $grad_top . ', ' . $grad_bottom_hover . ' );
  198.                             background: linear-gradient( ' . $grad_top . ', ' . $grad_bottom_hover . ' );
  199.                             color: ' . $font_color . ';
  200.                         }';
  201.         }
  202.                
  203.         // Archive
  204.         $grad_left = $graphene_settings['bg_archive_left'];
  205.         $grad_right = $graphene_settings['bg_archive_right'];
  206.         if ( $grad_left != $graphene_defaults['bg_archive_left'] || $grad_right != $graphene_defaults['bg_archive_right']) {$style .= '.page-title {
  207.                 -pie-background: linear-gradient(left top, ' . $grad_left . ', ' . $grad_right . ' );
  208.                 background: ' . $grad_top . ';
  209.                 background: -moz-linear-gradient(left top, ' . $grad_left . ', ' . $grad_right . ' );
  210.                 background: -webkit-linear-gradient(left top, ' . $grad_left . ', ' . $grad_right . ' );
  211.                 background: linear-gradient(left top, ' . $grad_left . ', ' . $grad_right . ' );
  212.         }';}
  213.         if ( $graphene_settings['bg_archive_label'] != $graphene_defaults['bg_archive_label']) {$style .= '.page-title{color:'.$graphene_settings['bg_archive_label'].';}';}
  214.         if ( $graphene_settings['bg_archive_text'] != $graphene_defaults['bg_archive_text']) {$style .= '.page-title span{color:'.$graphene_settings['bg_archive_text'].';}';}
  215.         if ( $graphene_settings['bg_archive_textshadow'] != $graphene_defaults['bg_archive_textshadow']) {$style .= '.page-title{text-shadow: 0 -1px 0 '.$graphene_settings['bg_archive_textshadow'].';}';}
  216.     }
  217.    
  218.     // Admin only
  219.     if ( is_admin() && strstr( $_SERVER["REQUEST_URI"], 'page=graphene_options&tab=display' ) ) {
  220.        
  221.         // Widgets
  222.         if ( $graphene_settings['content_font_colour'] != $graphene_defaults['content_font_colour']) {$style .= '.graphene, .graphene li, .graphene p{color:'.$graphene_settings['content_font_colour'].';}';}
  223.         if ( $graphene_settings['link_colour_normal'] != $graphene_defaults['link_colour_normal']) {$style .= '.graphene a{color:'.$graphene_settings['link_colour_normal'].';}';}
  224.         if ( $graphene_settings['link_colour_visited'] != $graphene_defaults['link_colour_visited']) {$style .= '.graphene a:visited{color:'.$graphene_settings['link_colour_visited'].';}';}
  225.         if ( $graphene_settings['link_colour_hover'] != $graphene_defaults['link_colour_hover']) {$style .= '.graphene a:hover{color:'.$graphene_settings['link_colour_hover'].';}';}
  226.        
  227.         // Slider
  228.         $grad_bottom = $graphene_settings['bg_slider_bottom'];
  229.         $grad_top = $graphene_settings['bg_slider_top'];
  230.         if ( $grad_bottom != $graphene_defaults['bg_slider_bottom'] || $grad_top != $graphene_defaults['bg_slider_top']) {$style .= '#grad-box {
  231.                 -pie-background: linear-gradient(left top, ' . $grad_top . ', ' . $grad_bottom . ' );
  232.                 background: ' . $grad_top . ';
  233.                 background: linear-gradient(left top, ' . $grad_top . ', ' . $grad_bottom . ' );
  234.                 background: -moz-linear-gradient(left top, ' . $grad_top . ', ' . $grad_bottom . ' );
  235.                 background: -webkit-gradient(linear, left top, right bottom, from( ' . $grad_top . ' ), to( ' . $grad_bottom . ' ) );
  236.                            }';
  237.                 }
  238.     }
  239.        
  240.     return $style;
  241. }
  242.  
  243.  
  244. /**
  245.  * Build and return the CSS styles custom column width
  246.  *
  247.  * @package Graphene
  248.  * @since 1.6
  249.  * @return string $style CSS styles
  250. */
  251. function graphene_get_custom_column_width(){
  252.     global $graphene_settings, $graphene_defaults;
  253.     $column_mode = graphene_column_mode();
  254.     $container = $graphene_settings['container_width'];
  255.     $grid = $graphene_settings['grid_width'];
  256.     $gutter = $graphene_settings['gutter_width'];
  257.     $style = '';
  258.    
  259.     /* Custom container width */
  260.     if ( $container != $graphene_defaults['container_width'] ){
  261.         $style .= ".container_16 {width:{$container}px}";
  262.         for ( $i = 1; $i <= 16; $i++ ){
  263.            
  264.             /* Grid */
  265.             $style .= '.container_16 .grid_' . $i . '{width:';
  266.             $style .= ( $grid * $i ) + ( $gutter * ( ( $i * 2 ) - 2) );
  267.             $style .= 'px}';
  268.            
  269.             /* Prefix */
  270.             $style .= '.container_16 .prefix_' . $i . '{padding-left:';
  271.             $style .= ( $grid * $i ) + ( $gutter * ( $i * 2 ) );
  272.             $style .= 'px}';
  273.            
  274.             /* Suffix */
  275.             $style .= '.container_16 .suffix_' . $i . '{padding-right:';
  276.             $style .= ( $grid * $i ) + ( $gutter * ( $i * 2 ) );
  277.             $style .= 'px}';
  278.            
  279.             /* Push */
  280.             $style .= '.container_16 .push_' . $i . '{left:';
  281.             $style .= ( $grid * $i ) + ( $gutter * ( $i * 2 ) );
  282.             $style .= 'px}';
  283.            
  284.             /* Pull */
  285.             $style .= '.container_16 .pull_' . $i . '{left:-';
  286.             $style .= ( $grid * $i ) + ( $gutter * ( $i * 2 ) );
  287.             $style .= 'px}';
  288.         }
  289.     }
  290.    
  291.     /* Custom column width - one-column mode */
  292.     if ( strpos( $column_mode, 'one-col' ) === 0 && ( $container != $graphene_defaults['container_width'] ) ){
  293.         $content = $container - $gutter * 2;
  294.        
  295.         $style .= '.one-column .comment-form-author, .one-column .comment-form-email, .one-column .comment-form-url {width:' . ( ( $content - $gutter * 6 ) / 3 ). 'px}';
  296.         $style .= '.one-column .graphene-form-field {width:' . ( ( ( $content - $gutter * 6 ) / 3 ) - 8 ) . 'px}';
  297.         $style .= '.one-column #commentform textarea {width:' . ( ( $content - $gutter * 2 ) - 8 ) . 'px}';
  298.     }
  299.    
  300.     /* Custom column width - two-column mode */
  301.     $content = $graphene_settings['column_width']['two-col']['content'];
  302.     $content_default = $graphene_defaults['column_width']['two-col']['content'];
  303.    
  304.     if ( strpos( $column_mode, 'two-col' ) === 0 && ( $content != $content_default ) ){
  305.         $sidebar = $graphene_settings['column_width']['two-col']['sidebar'];
  306.  
  307.         $style .= '#content-main, .container_16 .slider_post {width:' . $content . 'px}';
  308.         $style .= '#sidebar1, #sidebar2 {width:' . $sidebar . 'px}';
  309.         $style .= '.comment-form-author, .comment-form-email, .comment-form-url {width:' . ( ( $content - $gutter * 6 ) / 3 ). 'px}';
  310.         $style .= '.graphene-form-field {width:' . ( ( ( $content - $gutter * 6 ) / 3 ) - 8 ) . 'px}';
  311.         $style .= '#commentform textarea {width:' . ( ( $content - $gutter * 2 ) - 8 ) . 'px}';
  312.     }
  313.    
  314.     /* Custom column width - three-column mode */
  315.     $content = $graphene_settings['column_width']['three-col']['content'];
  316.     $sidebar_left = $graphene_settings['column_width']['three-col']['sidebar_left'];
  317.     $sidebar_right = $graphene_settings['column_width']['three-col']['sidebar_right'];
  318.     $content_default = $graphene_defaults['column_width']['three-col']['content'];
  319.     $sidebar_left_default = $graphene_defaults['column_width']['three-col']['sidebar_left'];
  320.     $sidebar_right_default = $graphene_defaults['column_width']['three-col']['sidebar_right'];
  321.    
  322.     if ( strpos( $column_mode, 'three-col' ) === 0 && ( $content != $content_default || $sidebar_left != $sidebar_left_default || $sidebar_right != $sidebar_right_default ) ){
  323.  
  324.         $style .= '#content-main, .container_16 .slider_post {width:' . $content . 'px}';
  325.         $style .= '#sidebar1 {width:' . $sidebar_right . 'px}';
  326.         $style .= '#sidebar2 {width:' . $sidebar_left . 'px}';
  327.         $style .= '.three-columns .comment-form-author, .three-columns .comment-form-email, .three-columns .comment-form-url {width:' . ( ( $content - $gutter * 6 ) / 3 ). 'px}';
  328.         $style .= '.three-columns .graphene-form-field {width:' . ( ( ( $content - $gutter * 6 ) / 3 ) - 8 ) . 'px}';
  329.         $style .= '.three-columns #commentform textarea {width:' . ( ( $content - $gutter * 2 ) - 8 ) . 'px}';
  330.     }
  331.    
  332.     return apply_filters( 'graphene_custom_column_width_style', $style );
  333. }
  334.  
  335.  
  336. /**
  337.  * Sets the various customised styling according to the options set for the theme.
  338.  *
  339.  * @package Graphene
  340.  * @since Graphene 1.0.8
  341. */
  342. function graphene_custom_style(){
  343.     global $graphene_settings;
  344.     $style = '';
  345.    
  346.     // the custom colours are needed in both the display and admin mode
  347.     $style .= graphene_get_custom_colours();
  348.    
  349.     // only get the custom css styles when were not in the admin mode
  350.     if ( ! is_admin() ) {
  351.         $style .= graphene_get_custom_style();
  352.    
  353.         // always the custom css at the end, this is the most important
  354.         if ( $graphene_settings['custom_css']) { $style .= $graphene_settings['custom_css']; }
  355.     }
  356.    
  357.     if ( $style ){ echo '<style type="text/css">'."\n".$style."\n".'</style>'."\n"; }
  358.     do_action( 'graphene_custom_style' );
  359. }
  360. add_action( 'wp_head', 'graphene_custom_style' );
  361. add_action( 'admin_head', 'graphene_custom_style' );
  362.  
  363.  
  364. /**
  365.  * Check to see if there's a favicon.ico in wordpress root directory and add
  366.  * appropriate head element for the favicon
  367. */
  368. function graphene_favicon(){
  369.     global $graphene_settings;
  370.     if ( $graphene_settings['favicon_url'] ) { ?>
  371.         <link rel="icon" href="<?php echo $graphene_settings['favicon_url']; ?>" type="image/x-icon" />
  372.     <?php
  373.     } elseif ( is_file( ABSPATH . 'favicon.ico' ) ){ ?>
  374.         <link rel="icon" href="<?php echo home_url(); ?>/favicon.ico" type="image/x-icon" />
  375.     <?php }
  376. }
  377. add_action( 'wp_head', 'graphene_favicon' );
  378.  
  379.  
  380. /**
  381.  * Add the .htc file for partial CSS3 support in Internet Explorer
  382. */
  383. function graphene_ie_css3(){ ?>
  384.     <!--[if lte IE 8]>
  385.       <style type="text/css" media="screen">
  386.         #footer, div.sidebar-wrap, .block-button, .featured_slider, #slider_root, #nav li ul, .pie{behavior: url(<?php echo get_template_directory_uri(); ?>/js/PIE.php);}
  387.         .featured_slider{margin-top:0 !important;}
  388.       </style>
  389.     <![endif]-->
  390.     <?php
  391. }
  392. add_action( 'wp_head', 'graphene_ie_css3' );
  393.  
  394.  
  395. /**
  396.  * Fix IE8 image scaling issues when using max-width property on images
  397. */
  398. function graphene_ie8_img(){ ?>
  399.     <!--[if IE 8]>
  400.     <script type="text/javascript">
  401.         (function( $) {
  402.             var imgs, i, w;
  403.             var imgs = document.getElementsByTagName( 'img' );
  404.             maxwidth = 0.98 * $( '.entry-content' ).width();
  405.             for( i = 0; i < imgs.length; i++ ) {
  406.                 w = imgs[i].getAttribute( 'width' );
  407.                 if ( w > maxwidth ) {
  408.                     imgs[i].removeAttribute( 'width' );
  409.                     imgs[i].removeAttribute( 'height' );
  410.                 }
  411.             }
  412.         })(jQuery);
  413.     </script>
  414.     <![endif]-->
  415. <?php
  416. }
  417. add_action( 'wp_footer', 'graphene_ie8_img' );
  418.  
  419.  
  420. /**
  421.  * Add Google Analytics code if tracking is enabled
  422.  */
  423. function graphene_google_analytics(){
  424.     global $graphene_settings;
  425.     if ( $graphene_settings['show_ga']) : ?>
  426.     <!-- BEGIN Google Analytics script -->
  427.         <?php echo stripslashes( $graphene_settings['ga_code']); ?>
  428.     <!-- END Google Analytics script -->
  429.     <?php endif;
  430. }
  431. add_action( 'wp_head', 'graphene_google_analytics', 1000);
  432.  
  433.  
  434. /**
  435.  * This function prints out the title for the website.
  436.  * If present, the theme will display customised site title structure.
  437. */
  438. function graphene_title( $title, $sep = '&raquo;', $seplocation = '' ){
  439.     global $graphene_settings;
  440.     $default_title = $title;
  441.    
  442.     if ( is_feed() ){
  443.        
  444.         $title = $default_title;
  445.        
  446.     } elseif ( is_front_page() ) {
  447.    
  448.         if ( $graphene_settings['custom_site_title_frontpage']) {
  449.             $title = $graphene_settings['custom_site_title_frontpage'];
  450.             $title = str_replace( '#site-name', get_bloginfo( 'name' ), $title);
  451.             $title = str_replace( '#site-desc', get_bloginfo( 'description' ), $title);
  452.         } else {
  453.             $title = get_bloginfo( 'name' ) . " &raquo; " . get_bloginfo( 'description' );
  454.         }
  455.        
  456.     } else {
  457.        
  458.         if ( $graphene_settings['custom_site_title_content'] ) {
  459.             $title = $graphene_settings['custom_site_title_content'];
  460.             $title = str_replace( '#site-name', get_bloginfo( 'name' ), $title );
  461.             $title = str_replace( '#site-desc', get_bloginfo( 'description' ), $title );
  462.             $title = str_replace( '#post-title', $default_title, $title );
  463.         } else {
  464.             $title = $default_title . " &raquo; " . get_bloginfo( 'name' );
  465.         }
  466.     }
  467.    
  468.     return ent2ncr( apply_filters( 'graphene_title', $title ) );
  469. }
  470. add_filter( 'wp_title', 'graphene_title', 10, 3 );
  471. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement