PageRenderTime 32ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/headway-208/library/generator/css.php

https://github.com/EthanBlast/Glam-Star-Life
PHP | 286 lines | 198 code | 77 blank | 11 comment | 44 complexity | 39752e4affdd39f7fe9be51d8d23ee86 MD5 | raw file
  1. <?php
  2. function headway_css_global(){
  3. $global = file_get_contents(TEMPLATEPATH.'/media/css/global.css');
  4. $global .= file_get_contents(TEMPLATEPATH.'/media/css/wrapper.css');
  5. $global .= file_get_contents(TEMPLATEPATH.'/media/css/forms.css');
  6. $global .= file_get_contents(TEMPLATEPATH.'/media/css/header.css');
  7. $global .= file_get_contents(TEMPLATEPATH.'/media/css/navigation.css');
  8. $global .= file_get_contents(TEMPLATEPATH.'/media/css/breadcrumbs.css');
  9. $global .= file_get_contents(TEMPLATEPATH.'/media/css/leafs.css');
  10. $global .= file_get_contents(TEMPLATEPATH.'/media/css/specific-leafs.css');
  11. $global .= file_get_contents(TEMPLATEPATH.'/media/css/entries.css');
  12. $global .= file_get_contents(TEMPLATEPATH.'/media/css/comments.css');
  13. $global .= file_get_contents(TEMPLATEPATH.'/media/css/widgets.css');
  14. $global .= file_get_contents(TEMPLATEPATH.'/media/css/footer.css');
  15. $global .= file_get_contents(TEMPLATEPATH.'/media/css/plugins.css');
  16. $options['template_directory'] = get_bloginfo('template_directory');
  17. $options['wrapper_width'] = str_replace('px', '', headway_get_skin_option('wrapper-width'));
  18. $options['wrapper_margin'] = (headway_get_skin_option('wrapper-margin', true) && headway_get_skin_option('wrapper-vertical-margin') == 30) ? headway_get_skin_option('wrapper-margin') : headway_get_skin_option('wrapper-vertical-margin').'px auto';
  19. $options['leaf_container_width'] = (str_replace('px', '', headway_get_skin_option('wrapper-width'))-str_replace('px', '', headway_get_skin_option('leaf-container-horizontal-padding'))*2);
  20. $options['leaf_container_padding'] = str_replace('px', '', headway_get_skin_option('leaf-container-vertical-padding')).'px '.str_replace('px', '', headway_get_skin_option('leaf-container-horizontal-padding')).'px';
  21. $options['leaf_margins'] = str_replace('px', '', headway_get_skin_option('leaf-margins'));
  22. $options['leaf_padding'] = str_replace('px', '', headway_get_skin_option('leaf-padding'));
  23. $options['leaf_resize_border'] = $options['leaf_margins']-1;
  24. $options['header_image_margin'] = (headway_get_skin_option('header-image-margin') || headway_get_skin_option('header-image-margin') == '0') ? headway_get_skin_option('header-image-margin') : '15px';
  25. $options['sub_nav_width'] = str_replace('px', '', headway_get_skin_option('sub-nav-width'));
  26. $options['sub_nav_margin_left'] = $options['sub_nav_width'] + 1;
  27. $options['wrapper_minus_twenty'] = $options['wrapper_width']-20;
  28. $options['placeholder_padding'] = $options['leaf_margins']-2+$options['leaf_padding'];
  29. $options['font'] = headway_get_font_family(headway_get_element_property_value('font', 'div-period-entry-content', 'font-family', true));
  30. $leaf_containers_border_style_query = (headway_get_skin_option('leaf-columns-border-style') == 'no border') ? 'none' : headway_get_skin_option('leaf-columns-border-style');
  31. $leaf_containers_border_color_query = headway_get_skin_option('leaf-columns-border-color');
  32. $options['leaf_containers_border_style'] = ($leaf_containers_border_style_query) ? $leaf_containers_border_style_query : 'solid';
  33. $options['leaf_containers_border_color'] = ($leaf_containers_border_color_query) ? $leaf_containers_border_color_query : 'dddddd';
  34. $options['leaf_containers_border_width'] = ($leaf_containers_border_style == 'none') ? 0 : ($leaf_containers_border_style == 'double') ? 3 : 1;
  35. $options['leaf_containers_padding'] = ($leaf_containers_border_style_query == 'double') ? 13 : 15;
  36. $options['leaf_columns_padding'] = ($leaf_containers_border_style == 'none') ? 10 : ($leaf_containers_border_style == 'double') ? 7 : 9;
  37. $options['resize_column_placeholder_padding'] = ($options['leaf_margins']*2)-4;
  38. $options['leafs_column_leaf_bottom_margin'] = str_replace('px', '', headway_get_skin_option('leaf-margins'))*2;
  39. $options['leafs_column_placeholder_bottom_margin'] = (str_replace('px', '', headway_get_skin_option('leaf-margins'))*2)-2;
  40. $conditionals['wrapper_border_top_fluid'] = (headway_get_skin_option('wrapper-vertical-margin') === 0) ? 'body.header-fluid div#wrapper { border-top: none !important; }' : null;
  41. $conditionals['meta_wordwrapping'] = (headway_get_option('post-below-title-left') == 'Written on %date% by %author% in %categories%' && headway_get_option('post-below-title-right') == '%comments% - %respond%') ? "div.meta-below-title div.left { width: 65%; }\ndiv.meta-below-title div.right { width: 30%; text-align: right; }\n" : null;
  42. foreach($options as $option => $value){
  43. $global = str_replace('%%'.$option.'%%', $value, $global);
  44. }
  45. foreach($conditionals as $conditional => $value){
  46. $global = str_replace('$$'.$conditional.'$$', $value, $global);
  47. }
  48. return $global;
  49. }
  50. function headway_css_leafs(){
  51. $leafs = headway_get_all_leafs();
  52. //If there are no leafs, stop now.
  53. if(!count($leafs)) return false;
  54. $return = "/* ------------------------- */\n/* -------Leaf Sizing------- */\n/* ------------------------- */\n\n";
  55. // Start foreach loop for every leaf/box.
  56. foreach($leafs as $leaf){
  57. //Store pages to build columns, if necessary
  58. if(!isset($pages)) $pages = array();
  59. $pages[] = $leaf['page'];
  60. $leaf = array_map('maybe_unserialize', $leaf);
  61. $leaf_config = $leaf['config'];
  62. $leaf_options = $leaf['options'];
  63. //If leaf is more than max width, fix it.
  64. if($leaf_config['width'] > headway_get_skin_option('wrapper-width')){
  65. $leaf_container = (int)headway_get_skin_option('wrapper-width')-((int)headway_get_skin_option('leaf-container-horizontal-padding')*2);
  66. $leaf_margins_padding = ((int)headway_get_skin_option('leaf-margins')*2)-((int)headway_get_skin_option('leaf-padding')*2);
  67. $leaf_config['width'] = $leaf_container - $leaf_margins_padding;
  68. }
  69. $return .= 'div#leaf-'.$leaf['id'].' {'."\n".' width:'.$leaf_config['width'].'px;'."\n".' height:'.$leaf_config['height'].'px;'."\n".' min-height:'.$leaf_config['height'].'px; }'."\n\n";
  70. }
  71. $return .= "\n";
  72. $return .= headway_css_leaf_columns($pages);
  73. return $return;
  74. }
  75. function headway_css_leaf_columns($pages){
  76. if(count($pages) === 0) return;
  77. $return = "/* ------------------------- */\n/* -------Leaf Columns------- */\n/* ------------------------- */\n\n";
  78. foreach(array_unique($pages) as $page){
  79. $leaf_columns = headway_get_page_option($page, 'leaf-columns');
  80. if($leaf_columns){
  81. $total_width = 0;
  82. $fixed_width = 0;
  83. for($i = $leaf_columns+1; $i <= 4; $i++){
  84. headway_delete_page_option($page, 'column-'.$i.'-width');
  85. }
  86. //Add up column widths to get total of all widths
  87. for($i = 1; $i <= $leaf_columns; $i++){
  88. $total_width = $total_width + headway_get_page_option($page, 'column-'.$i.'-width') + 20;
  89. }
  90. //If the total is within 10px of the wrapper width, add the difference to the last column
  91. if($total_width < headway_get_skin_option('wrapper-width') && $total_width >= headway_get_skin_option('wrapper-width')-10){
  92. $difference = headway_get_skin_option('wrapper-width') - $total_width;
  93. headway_update_page_option($page, 'column-'.$leaf_columns.'-width', headway_get_page_option($page, 'column-'.$leaf_columns.'-width')+$difference);
  94. }
  95. //If the total doesn't match the wrapper width by a long shot, make all columns equal to match wrapper.
  96. if((int)$total_width !== 0 && !($total_width <= headway_get_skin_option('wrapper-width') && $total_width >= headway_get_skin_option('wrapper-width')-10)){
  97. $divide_from_this = headway_get_skin_option('wrapper-width') - ($leaf_columns*20);
  98. $fixed_width = $divide_from_this / $leaf_columns;
  99. }
  100. for($i = 1; $i <= $leaf_columns; $i++){
  101. if($fixed_width === 0){
  102. $width = headway_get_page_option($page, 'column-'.$i.'-width');
  103. } else {
  104. $width = $fixed_width;
  105. headway_update_page_option($page, 'column-'.$i.'-width', $fixed_width);
  106. }
  107. $return .= "\n".'div#wrapper div#column-'.$i.'-page-'.$page.' { width: '.$width.'px; }';
  108. }
  109. }
  110. }
  111. return $return;
  112. }
  113. function headway_css_elements(){
  114. $return = "\n/* ------------------------- */\n/* -----Element Styling----- */\n/* ------------------------- */\n\n";
  115. //If skin is active, use default
  116. if(headway_get_option('active-skin') && headway_get_option('active-skin') != 'none') return file_get_contents(TEMPLATEPATH.'/media/css/misc/bare-elements.css');
  117. //If developer mode is enabled, use default
  118. if(headway_get_option('enable-developer-mode')) return file_get_contents(TEMPLATEPATH.'/media/css/misc/bare-elements.css');
  119. //If skin preview is being used, use default
  120. if(isset($_GET['headway-skin-preview']) && $_GET['headway-skin-preview'] != 'none') return file_get_contents(TEMPLATEPATH.'/media/css/misc/bare-elements.css');
  121. include 'elements.php';
  122. return headway_css_elements_generated();
  123. }
  124. function headway_css_body_background(){
  125. if(headway_get_skin_option('disable-body-background-image') || !headway_get_option('body-background-image', true, true)) return false;
  126. //Check if image is a URL or hosted locally
  127. if(strpos(headway_get_option('body-background-image', true, true), 'http') !== false){
  128. $url = headway_get_option('body-background-image', true, true);
  129. } else {
  130. $url = headway_upload_url().'/background-uploads/'.rawurlencode(headway_get_option('body-background-image', true, true));
  131. }
  132. $css = "/* Headway Body Background */\n";
  133. $css .= "body.headway-visual-editor-open { background: none; }\n\n";
  134. $css .= 'body, body.headway-visual-editor-open div#headway-visual-editor { background-image: url('.$url.'); background-repeat: '.headway_get_option('body-background-repeat').'; }'."\n";
  135. return $css;
  136. }
  137. function headway_css_live(){
  138. if(isset($_GET['visual-editor-open']) || !headway_get_option('live-css')) return false;
  139. return "\n\n/* Live CSS */\n\n".stripslashes(headway_get_option('live-css'));
  140. }
  141. function headway_css_comment_fix(){
  142. $bottom_border_color = headway_get_element_property_value('color', 'ol.commentlist li', 'bottom-border');
  143. $border_width = headway_get_element_property_value('sizing', 'ol.commentlist li', 'bottom-border-width');
  144. return "\n".'ol.commentlist, ol.commentlist li ul.children { border-top: '.$border_width.'px solid #'.$bottom_border_color.'; }';
  145. }
  146. function headway_css_border_radius_conditional(){
  147. $wrapper_border_radius = headway_get_skin_option('wrapper-border-radius');
  148. $leaf_border_radius = headway_get_skin_option('leaf-border-radius');
  149. $return = '';
  150. if($wrapper_border_radius > 0){
  151. $return .= 'div#wrapper {
  152. -webkit-border-radius: '.$wrapper_border_radius.'px;
  153. -moz-border-radius: '.$wrapper_border_radius.'px;
  154. border-radius: '.$wrapper_border_radius.'px;
  155. }
  156. body.header-fluid div#top-container {
  157. -webkit-border-top-left-radius: '.$wrapper_border_radius.'px;
  158. -webkit-border-top-right-radius: '.$wrapper_border_radius.'px;
  159. -moz-border-radius-topleft: '.$wrapper_border_radius.'px;
  160. -moz-border-radius-topright: '.$wrapper_border_radius.'px;
  161. border-top-left-radius: '.$wrapper_border_radius.'px;
  162. border-top-right-radius: '.$wrapper_border_radius.'px;
  163. }';
  164. if(headway_get_element_styles(array('element' => 'div#wrapper', 'property' => 'border-width')) <= 5){
  165. $return .= '
  166. div.header-rearrange-item-1 {
  167. -webkit-border-top-left-radius: '.$wrapper_border_radius.'px;
  168. -webkit-border-top-right-radius: '.$wrapper_border_radius.'px;
  169. -moz-border-radius-topleft: '.$wrapper_border_radius.'px;
  170. -moz-border-radius-topright: '.$wrapper_border_radius.'px;
  171. border-top-left-radius: '.$wrapper_border_radius.'px;
  172. border-top-right-radius: '.$wrapper_border_radius.'px;
  173. }
  174. div.header-rearrange-item-1 ul.navigation li:first-child a {
  175. -webkit-border-top-left-radius: '.$wrapper_border_radius.'px;
  176. -moz-border-radius-topleft: '.$wrapper_border_radius.'px;
  177. border-top-left-radius: '.$wrapper_border_radius.'px;
  178. }
  179. div.header-rearrange-item-1 ul.navigation-right li:last-child a {
  180. -moz-border-radius: 0;
  181. -webkit-border-radius: 0;
  182. border-radius: 0;
  183. -webkit-border-top-right-radius: '.$wrapper_border_radius.'px;
  184. -moz-border-radius-topright: '.$wrapper_border_radius.'px;
  185. border-top-right-radius: '.$wrapper_border_radius.'px;
  186. }';
  187. }
  188. $return .= 'div#footer {
  189. -webkit-border-bottom-left-radius: '.$wrapper_border_radius.'px;
  190. -webkit-border-bottom-right-radius: '.$wrapper_border_radius.'px;
  191. -moz-border-radius-bottomleft: '.$wrapper_border_radius.'px;
  192. -moz-border-radius-bottomright: '.$wrapper_border_radius.'px;
  193. border-bottom-left-radius: '.$wrapper_border_radius.'px;
  194. border-bottom-right-radius: '.$wrapper_border_radius.'px;
  195. }';
  196. }
  197. if($leaf_border_radius > 0){
  198. $return .= 'div.headway-leaf {
  199. -webkit-border-radius: '.$leaf_border_radius.'px;
  200. -moz-border-radius: '.$leaf_border_radius.'px;
  201. border-radius: '.$leaf_border_radius.'px;
  202. }';
  203. }
  204. return $return;
  205. }