function thb_layout_global_options_container() { $thb_container = new THB_MetaboxFieldsContainer('', 'layout_container'); if (thb_check_template_config('core/layout', 'meta_options_subtitle')) { if (!empty($_POST) || !thb_text_startsWith(thb_get_admin_template(), 'single')) { $field = new THB_TextField('subtitle'); $field->setLabel(__('Page subtitle', 'thb_text_domain')); $thb_container->addField($field); } } if (thb_check_template_config('core/layout', 'meta_options_pageheader_disable')) { $field = new THB_CheckBoxField('pageheader_disable'); $field->setDefault(false); $field->setLabel(__('Disable page header', 'thb_text_domain')); $thb_container->addField($field); } if (thb_check_template_config('core/layout', 'meta_options_page_boxed')) { $field = new THB_CheckBoxField('page_boxed'); $field->setDefault(false); $field->setLabel(__('Box the page content and sidebar', 'thb_text_domain')); $field->setHelp(__('Checking this option, the page content and sidebar will both have a color background.', 'thb_text_domain')); $thb_container->addField($field); } if (thb_check_template_config('core/layout', 'meta_options_gutter')) { $thb_field = new THB_YesNoField('gutter'); $thb_field->setDefault(thb_config('core/layout', 'meta_options_gutter_default')); $thb_field->setLabel(__('Gutter', 'thb_text_domain')); $thb_container->addField($thb_field); } return $thb_container; }
function thb_get_post_type_from_template($template) { $post_type = 'page'; if ($template == 'single.php') { $post_type = 'post'; } elseif (thb_text_startsWith($template, 'single-')) { $post_type = str_replace('single-', '', $template); $post_type = str_replace('.php', '', $post_type); } return $post_type; }
/** * Retrieve the content of a local or remote file. * * @param $url The resource URL. * @return string */ function thb_read_url($url) { if (thb_text_startsWith($url, WP_CONTENT_URL)) { return file_get_contents(thb_system_get_path($url)); } else { $response = wp_remote_get($url); if (thb_response_is_ok($response)) { return $response['body']; } } return ''; }
<?php $class[] = $size; $style = ''; // Color if (thb_text_startsWith($color, '#')) { $style .= 'background-color: ' . $color; } else { $class[] = $color; } ?> <a class="<?php echo implode(' ', $class); ?> " href="<?php echo $url; ?> " style="<?php echo $style; ?> "> <?php echo thb_text_format($text); ?> </a>
function thb_color_lighten($color, $dif = 20) { if (!thb_text_startsWith($color, "#")) { $color = "#" . $color; } if ($color == "#") { return ""; } $dif = $dif / 100; $colorRgb = thb_color_hexToRgb($color); $colorHsl = thb_color_rgbToHsl($colorRgb); // Lightness $colorHsl[2] += $dif; if ($colorHsl[2] > 1) { $colorHsl[2] = 1; } $colorRgb = thb_color_hslToRgb($colorHsl); return thb_color_rgbToHex($colorRgb); }
/** * Print a well formed CSS stylesheet based on the registered settings. * * @param boolean $hideTag True to hide the <style> tag. * @return void */ public function render($hideTag = false) { if (!$hideTag) { thb_css_start('thb-style-customizer'); } $this->importFonts(); $style_rules = array(); $style_mixins = array(); foreach ($this->_sections as $section) { foreach ($section['settings'] as $setting) { $value = get_theme_mod($setting['key']); if (empty($value)) { $value = $setting['default']; } foreach ($setting['selectors'] as $selector => $rules) { if (!isset($style_rules[$selector])) { $style_rules[$selector] = array(); } foreach ($rules as $rule) { if (thb_text_startsWith($rule, 'mixin-')) { $mixin = str_replace('mixin-', '', $rule); if (function_exists($mixin)) { $style_mixins[] = call_user_func($mixin, $value, $selector); } } else { list($prefix, $suffix) = thb_css_prefix_suffix($rule); $style_rules[$selector][] = thb_get_css_rule($rule, $value, $prefix, $suffix); } } } } } foreach ($style_rules as $selector => $rules) { thb_css_selector($selector, $rules); } foreach ($style_mixins as $mixin) { echo $mixin; } ksort($this->additionalStyles); foreach ($this->additionalStyles as $style) { if (function_exists($style)) { echo ' ' . call_user_func($style); } } if (!$hideTag) { thb_css_end(); } }
<?php header('Content-type: text/javascript'); if (!isset($_GET['location']) || !(thb_text_startsWith($_GET['location'], 'header') || thb_text_startsWith($_GET['location'], 'footer'))) { die; } /** * The theme instance. */ $thb_theme = thb_theme(); /** * The loading location. */ $location = $_GET['location']; /** * The scripts. */ $scripts = $thb_theme->getFrontend()->getCompressedScripts($location); /** * Building the output. */ $output = ''; foreach ($scripts as $script) { $output .= thb_read_url($script) . "\n\n"; } /** * Printing the output. */ echo $output;