/**
  * Build CSS from Tonesque
  *
  * @uses get_the_ID(), is_single(), get_post_meta(), colorposts_get_post_image(), update_post_meta(), apply_filters()
  *
  * @since Color Posts 1.0
  */
 function colors()
 {
     $thumb_id = get_post_thumbnail_id($this->post_id);
     $thumb_url = wp_get_attachment_image_src($thumb_id);
     $thumb_url = $thumb_url[0];
     $value = array();
     if ($thumb_url) {
         // Grab color from post meta
         $tonesque = get_post_meta($thumb_id, '_post_colors', true);
         // No color? Let's get one
         if (empty($tonesque)) {
             $tonesque = new Tonesque($thumb_url);
             $tonesque = array('color' => $tonesque->color(), 'contrast' => $tonesque->contrast());
             if ($tonesque['color']) {
                 update_post_meta($this->post_id, '_post_colors', $tonesque);
             } else {
                 return;
             }
         }
         extract($tonesque);
     }
     if (!isset($color) || !$color) {
         $color = 'FFFFFF';
     }
     $value['color'] = '#' . $color;
     $white = new Jetpack_Color('#FFFFFF');
     $color = new Jetpack_Color('#' . $color);
     $value['luminosity'] = $color->toLuminosity();
     $value['fontcolor'] = $value['luminosity'] < 0.5 ? '#FFFFFF' : '#222222';
     $value['readable'] = '#' . $color->getReadableContrastingColor($white, 6)->toHex();
     return $value;
 }
Exemple #2
0
/**
 * Build an array of the available variables.
 * These variables are basically the variables.less file from bootstrap,
 * formatted as an array.
 */
function maera_bootstrap_get_variables()
{
    $color = get_theme_mod('body_bg_color', '#ffffff');
    $color = false !== strpos($color, 'rgba') ? Kirki_Color::rgba2hex($color) : $color;
    $body_obj = new Jetpack_Color($color);
    $body_bg = '#' . $body_obj->toHex();
    $body_lum = $body_obj->toLuminosity();
    $color = get_theme_mod('color_brand_primary', '#428bca');
    $color = false !== strpos($color, 'rgba') ? Kirki_Color::rgba2hex($color) : $color;
    $b_p_obj = new Jetpack_Color($color);
    $brand_primary = '#' . $b_p_obj->toHex();
    $brand_primary_lum = $b_p_obj->toLuminosity();
    $color_success = new Jetpack_Color('#5cb85c');
    $brand_success = '#' . $color_success->getReadableContrastingColor($body_obj, 1.5)->toHex();
    $b_s_obj = new Jetpack_Color($brand_success);
    $brand_success_lum = $b_s_obj->toLuminosity();
    $color_warning = new Jetpack_Color('#f0ad4e');
    $brand_warning = '#' . $color_warning->getReadableContrastingColor($body_obj, 1.5)->toHex();
    $b_w_obj = new Jetpack_Color($brand_warning);
    $brand_warning_lum = $b_w_obj->toLuminosity();
    $color_danger = new Jetpack_Color('#d9534f');
    $brand_danger = '#' . $color_danger->getReadableContrastingColor($body_obj, 1.5)->toHex();
    $b_d_obj = new Jetpack_Color($brand_danger);
    $brand_danger_lum = $b_d_obj->toLuminosity();
    $color_info = new Jetpack_Color('#5bc0de');
    $brand_info = '#' . $color_info->getReadableContrastingColor($body_obj, 1.5)->toHex();
    $b_i_obj = new Jetpack_Color($brand_info);
    $brand_info_lum = $b_i_obj->toLuminosity();
    $color = get_theme_mod('navbar_bg', '#f8f8f8');
    $color = false !== strpos($color, 'rgba') ? Kirki_Color::rgba2hex($color) : $color;
    $nav_col_obj = new Jetpack_Color($color);
    $color = get_theme_mod('jumbo_bg', '#ffffff');
    $color = false !== strpos($color, 'rgba') ? Kirki_Color::rgba2hex($color) : $color;
    $jumbotron_obj = new Jetpack_Color($color);
    $navbar_border = 0.6 < $brand_primary_lum ? 'lighten(@navbar-default-bg, 6.5%)' : 'darken(@navbar-default-bg, 6.5%)';
    $screen_sm = filter_var(get_theme_mod('screen_tablet', 768), FILTER_SANITIZE_NUMBER_INT);
    $screen_md = filter_var(get_theme_mod('screen_desktop', 992), FILTER_SANITIZE_NUMBER_INT);
    $screen_lg = filter_var(get_theme_mod('screen_large_desktop', 1200), FILTER_SANITIZE_NUMBER_INT);
    $gutter = filter_var(get_theme_mod('gutter', 30), FILTER_SANITIZE_NUMBER_INT);
    $gutter = $gutter < 2 ? 2 : $gutter;
    $site_style = get_theme_mod('site_style', 'wide');
    $screen_xs = $site_style == 'static' ? '50px' : '480px';
    $screen_sm = $site_style == 'static' ? '50px' : $screen_sm;
    $screen_md = $site_style == 'static' ? '50px' : $screen_md;
    $gfb = get_theme_mod('grid_float_breakpoint', 'screen_sm_min');
    $grid_float_breakpoint = isset($gfb) ? $gfb : '@screen-sm-min';
    $grid_float_breakpoint = $gfb == 'min' ? '10px' : $grid_float_breakpoint;
    $grid_float_breakpoint = $gfb == 'screen_xs_min' ? '@screen-xs-min' : $grid_float_breakpoint;
    $grid_float_breakpoint = $gfb == 'screen_sm_min' ? '@screen-sm-min' : $grid_float_breakpoint;
    $grid_float_breakpoint = $gfb == 'screen_md_min' ? '@screen-md-min' : $grid_float_breakpoint;
    $grid_float_breakpoint = $gfb == 'screen_lg_min' ? '@screen-lg-min' : $grid_float_breakpoint;
    $grid_float_breakpoint = $gfb == 'max' ? '9999px' : $grid_float_breakpoint;
    $grid_float_breakpoint = $gfb == 'screen-lg-min' ? '0 !important' : $grid_float_breakpoint;
    $font_size_base = get_theme_mod('font_base_size', 14) . 'px';
    $variables = array('gray-base' => 0.4 < $body_lum ? '#000000' : '#FFFFFF', 'gray-darker' => 0.4 < $body_lum ? 'darken(' . $body_bg . ', 13.5%)' : 'lighten(' . $body_bg . ', 13.5%)', 'gray-dark' => 0.4 < $body_lum ? 'darken(' . $body_bg . ', 20%)' : 'lighten(' . $body_bg . ', 20%)', 'gray' => 0.4 < $body_lum ? 'darken(' . $body_bg . ', 33.5%)' : 'lighten(' . $body_bg . ', 33.5%)', 'gray-light' => 0.4 < $body_lum ? 'darken(' . $body_bg . ', 60%)' : 'lighten(' . $body_bg . ', 60%)', 'gray-lighter' => 0.4 < $body_lum ? 'darken(' . $body_bg . ', 93.5%)' : 'lighten(' . $body_bg . ', 93.5%)', 'brand-primary' => '#' . $b_p_obj->getReadableContrastingColor(3)->toHex(), 'brand-success' => '#' . $color_success->getReadableContrastingColor(3)->toHex(), 'brand-info' => '#' . $color_info->getReadableContrastingColor(3)->toHex(), 'brand-warning' => '#' . $color_warning->getReadableContrastingColor(3)->toHex(), 'brand-danger' => '#' . $color_danger->getReadableContrastingColor(3)->toHex(), 'body-bg' => $body_bg, 'text-color' => '#' . $body_obj->getGrayscaleContrastingColor(10)->toHex(), 'link-color' => '#' . $b_p_obj->getReadableContrastingColor($body_obj, 2)->toHex(), 'link-hover-color' => 0.3 < $brand_primary_lum ? 'darken(@link-color, 15%)' : 'lighten(@link-color, 15%)', 'link-hover-decoration' => 'underline', 'font-family-sans-serif' => get_theme_mod('font_base_family', '"Helvetica Neue", Helvetica, Arial, sans-serif'), 'font-family-serif' => 'Georgia, "Times New Roman", Times, serif', 'font-family-monospace' => 'Menlo, Monaco, Consolas, "Courier New", monospace', 'font-family-base' => '@font-family-sans-serif', 'font-size-base' => $font_size_base, 'font-size-large' => 'ceil((@font-size-base * 1.25))', 'font-size-small' => 'ceil((@font-size-base * 0.85))', 'font-size-h1' => 'floor((@font-size-base * ' . get_theme_mod('font_headers_size', 1) * 2.6 . '))', 'font-size-h2' => 'floor((@font-size-base * ' . get_theme_mod('font_headers_size', 1) * 2.15 . '))', 'font-size-h3' => 'ceil((@font-size-base * ' . get_theme_mod('font_headers_size', 1) * 1.7 . '))', 'font-size-h4' => 'ceil((@font-size-base * ' . get_theme_mod('font_headers_size', 1) * 1.25 . '))', 'font-size-h5' => '@font-size-base', 'font-size-h6' => 'ceil((@font-size-base * ' . get_theme_mod('font_headers_size', 1) * 0.85 . '))', 'line-height-base' => get_theme_mod('font_base_height', 1.43), 'line-height-computed' => 'floor((@font-size-base * @line-height-base))', 'headings-font-family' => get_theme_mod('headers_font_family', '"Helvetica Neue", Helvetica, Arial, sans-serif'), 'headings-font-weight' => get_theme_mod('font_headers_weight', 500), 'headings-line-height' => get_theme_mod('font_headers_height', 1.1), 'headings-color' => 'inherit', 'icon-font-path' => '"' . MAERA_BS_SHELL_URL . '/assets/fonts/"', 'icon-font-name' => '"glyphicons-halflings-regular"', 'icon-font-svg-id' => '"glyphicons_halflingsregular"', 'padding-base-vertical' => round(get_theme_mod('padding_base', 6) * (6 / 6)) . 'px', 'padding-base-horizontal' => round(get_theme_mod('padding_base', 6) * (10 / 6)) . 'px', 'padding-large-vertical' => round(get_theme_mod('padding_base', 6) * (10 / 6)) . 'px', 'padding-large-horizontal' => round(get_theme_mod('padding_base', 6) * (16 / 6)) . 'px', 'padding-small-vertical' => round(get_theme_mod('padding_base', 6) * (5 / 6)) . 'px', 'padding-small-horizontal' => round(get_theme_mod('padding_base', 6) * (10 / 6)) . 'px', 'padding-xs-vertical' => round(get_theme_mod('padding_base', 6) * (1 / 6)) . 'px', 'padding-xs-horizontal' => round(get_theme_mod('padding_base', 6) * (5 / 6)) . 'px', 'line-height-large' => '1.33', 'line-height-small' => '1.5', 'border-radius-base' => round(get_theme_mod('border_radius', 4) * (4 / 4)) . 'px', 'border-radius-large' => round(get_theme_mod('border_radius', 4) * (6 / 4)) . 'px', 'border-radius-small' => round(get_theme_mod('border_radius', 4) * (3 / 4)) . 'px', 'component-active-color' => '@body-bg', 'component-active-bg' => '@brand-primary', 'caret-width-base' => '4px', 'caret-width-large' => '5px', 'table-cell-padding' => round(get_theme_mod('padding_base', 6) * (8 / 6)) . 'px', 'table-condensed-cell-padding' => round(get_theme_mod('padding_base', 6) * (5 / 6)) . 'px', 'table-bg' => 'transparent', 'table-bg-accent' => 0.3 < $body_lum ? 'darken(@body-bg, 2.5%)' : 'lighten(@body-bg, 2.5%)', 'table-bg-hover' => 0.3 < $body_lum ? 'darken(@body-bg, 4%)' : 'lighten(@body-bg, 4%)', 'table-bg-active' => '@table-bg-hover', 'table-border-color' => 0.3 < $body_lum ? 'darken(@body-bg, 13.35%)' : 'lighten(@body-bg, 13.35%)', 'btn-font-weight' => 'normal', 'btn-default-color' => '@text-color', 'btn-default-bg' => '@body-bg', 'btn-default-border' => 0.6 < $body_lum ? 'darken(@btn-primary-bg, 5%)' : 'lighten(@btn-primary-bg, 5%)', 'btn-primary-color' => '@body-bg', 'btn-primary-bg' => '@brand-primary', 'btn-primary-border' => 0.6 < $brand_primary_lum ? 'darken(@btn-primary-bg, 5%)' : 'lighten(@btn-primary-bg, 5%)', 'btn-success-color' => '@body-bg', 'btn-success-bg' => '@brand-success', 'btn-success-border' => 0.6 < $brand_success_lum ? 'darken(@btn-success-bg, 5%)' : 'lighten(@btn-success-bg, 5%)', 'btn-info-color' => '@body-bg', 'btn-info-bg' => '@brand-info', 'btn-info-border' => 0.6 < $brand_info_lum ? 'darken(@btn-info-bg, 5%)' : 'lighten(@btn-info-bg, 5%)', 'btn-warning-color' => '@body-bg', 'btn-warning-bg' => '@brand-warning', 'btn-warning-border' => 0.6 < $brand_warning_lum ? 'darken(@btn-warning-bg, 5%)' : 'lighten(@btn-warning-bg, 5%)', 'btn-danger-color' => '@body-bg', 'btn-danger-bg' => '@brand-danger', 'btn-danger-border' => 0.6 < $brand_danger_lum ? 'darken(@btn-danger-bg, 5%)' : 'lighten(@btn-danger-bg, 5%)', 'btn-link-disabled-color' => '@gray-light', 'input-bg' => '@body-bg', 'input-bg-disabled' => '@gray-lighter', 'input-color' => '@gray-dark', 'input-border' => 0.3 < $body_lum ? 'darken(@body-bg, 20%)' : 'lighten(@body-bg, 20%)', 'input-border-radius' => '@border-radius-base', 'input-border-radius-large' => 'border-radius-large', 'input-border-radius-small' => 'border-radius-small', 'input-border-focus' => 0.6 < $brand_primary_lum ? 'lighten(@brand-primary, 10%)' : 'darken(@brand-primary, 10%)', 'input-color-placeholder' => '@gray-light', 'input-height-base' => '(@line-height-computed + (@padding-base-vertical * 2) + 2)', 'input-height-large' => '(ceil(@font-size-large * @line-height-large) + (@padding-large-vertical * 2) + 2)', 'input-height-small' => '(floor(@font-size-small * @line-height-small) + (@padding-small-vertical * 2) + 2)', 'legend-color' => '@gray-dark', 'legend-border-color' => 0.3 < $body_lum ? 'darken(@body-bg, 10.2%)' : 'lighten(@body-bg, 10.2%)', 'input-group-addon-bg' => '@gray-lighter', 'input-group-addon-border-color' => '@input-border', 'cursor-disabled' => 'not-allowed', 'dropdown-bg' => '@body-bg', 'dropdown-border' => 'rgba(0,0,0,.15)', 'dropdown-fallback-border' => 0.3 < $body_lum ? 'darken(@body-bg, 20%)' : 'lighten(@body-bg, 20%)', 'dropdown-divider-bg' => 0.3 < $body_lum ? 'darken(@body-bg, 10.2%)' : 'lighten(@body-bg, 10.2%)', 'dropdown-link-color' => '@navbar-default-color', 'dropdown-link-hover-color' => '#' . $nav_col_obj->getGrayscaleContrastingColor(11)->toHex(), 'dropdown-link-hover-bg' => 0.3 < $body_lum ? 'darken(@body-bg, 4%)' : 'lighten(@body-bg, 4%)', 'dropdown-link-active-color' => '@component-active-color', 'dropdown-link-active-bg' => '@component-active-bg', 'dropdown-link-disabled-color' => '@gray-light', 'dropdown-header-color' => '@gray-light', 'dropdown-caret-color' => '@gray-darker', 'zindex-navbar' => '1000', 'zindex-dropdown' => '1000', 'zindex-popover' => '1060', 'zindex-tooltip' => '1070', 'zindex-navbar-fixed' => '1030', 'zindex-modal' => '1040', 'screen-xs' => '480px', 'screen-xs-min' => '@screen-xs', 'screen-phone' => '@screen-xs-min', 'screen-sm' => $screen_sm . 'px', 'screen-sm-min' => '@screen-sm', 'screen-tablet' => '@screen-sm-min', 'screen-md' => $screen_md . 'px', 'screen-md-min' => '@screen-md', 'screen-desktop' => '@screen-md-min', 'screen-lg' => $screen_lg . 'px', 'screen-lg-min' => '@screen-lg', 'screen-lg-desktop' => '@screen-lg-min', 'screen-xs-max' => '(@screen-sm-min - 1)', 'screen-sm-max' => '(@screen-md-min - 1)', 'screen-md-max' => '(@screen-lg-min - 1)', 'grid-columns' => '12', 'grid-gutter-width' => $gutter . 'px', 'grid-float-breakpoint' => $grid_float_breakpoint, 'grid-float-breakpoint-max' => '(@grid-float-breakpoint - 1)', 'container-tablet' => $screen_sm - $gutter / 2 . 'px', 'container-sm' => '@container-tablet', 'container-desktop' => $screen_md - $gutter / 2 . 'px', 'container-md' => '@container-desktop', 'container-large-desktop' => $screen_lg - $gutter . 'px', 'container-lg' => '@container-large-desktop', 'navbar-height' => filter_var(get_theme_mod('navbar_height', 50), FILTER_SANITIZE_NUMBER_INT) . 'px', 'navbar-margin-bottom' => '@line-height-computed', 'navbar-border-radius' => '@border-radius-base', 'navbar-padding-horizontal' => 'floor((@grid-gutter-width / 2))', 'navbar-padding-vertical' => '((@navbar-height - @line-height-computed) / 2)', 'navbar-collapse-max-height' => '340px', 'navbar-default-color' => '#' . $nav_col_obj->getGrayscaleContrastingColor(7)->toHex(), 'navbar-default-bg' => '#' . $nav_col_obj->toHex(), 'navbar-default-border' => 0.3 > $nav_col_obj->toLuminosity() ? 'lighten(@navbar-default-bg, 6.5%)' : 'darken(@navbar-default-bg, 6.5%)', 'navbar-default-link-color' => '@navbar-default-color', 'navbar-default-link-hover-color' => '#' . $nav_col_obj->getGrayscaleContrastingColor(11)->toHex(), 'navbar-default-link-hover-bg' => 'transparent', 'navbar-default-link-active-color' => 'mix(@navbar-default-color, @navbar-default-link-hover-color, 50%)', 'navbar-default-link-active-bg' => 0.6 > $nav_col_obj->toLuminosity() ? 'darken(@navbar-default-bg, 6.5%)' : 'lighten(@navbar-default-bg, 6.5%)', 'navbar-default-link-disabled-color' => 0.6 > $nav_col_obj->toLuminosity() ? 'darken(@navbar-default-bg, 6.5%)' : 'lighten(@navbar-default-bg, 6.5%)', 'navbar-default-link-disabled-bg' => 'transparent', 'navbar-default-brand-color' => '@navbar-default-link-color', 'navbar-default-brand-hover-color' => 'darken(@navbar-default-brand-color, 10%)', 'navbar-default-brand-hover-bg' => 'transparent', 'navbar-default-toggle-hover-bg' => 0.3 > $nav_col_obj->toLuminosity() ? 'lighten(@navbar-default-bg, 6.5%)' : 'darken(@navbar-default-bg, 6.5%)', 'navbar-default-toggle-icon-bar-bg' => '#' . $nav_col_obj->getGrayscaleContrastingColor(7)->toHex(), 'navbar-default-toggle-border-color' => '@navbar-default-toggle-hover-bg', 'navbar-inverse-color' => 'lighten(@gray-light, 15%)', 'navbar-inverse-bg' => '#222', 'navbar-inverse-border' => 'darken(@navbar-inverse-bg, 10%)', 'navbar-inverse-link-color' => 'lighten(@gray-light, 15%)', 'navbar-inverse-link-hover-color' => '@body-bg', 'navbar-inverse-link-hover-bg' => 'transparent', 'navbar-inverse-link-active-color' => '@navbar-inverse-link-hover-color', 'navbar-inverse-link-active-bg' => 'darken(@navbar-inverse-bg, 10%)', 'navbar-inverse-link-disabled-color' => '#444', 'navbar-inverse-link-disabled-bg' => 'transparent', 'navbar-inverse-brand-color' => '@navbar-inverse-link-color', 'navbar-inverse-brand-hover-color' => '@body-bg', 'navbar-inverse-brand-hover-bg' => 'transparent', 'navbar-inverse-toggle-hover-bg' => '#333', 'navbar-inverse-toggle-icon-bar-bg' => '@body-bg', 'navbar-inverse-toggle-border-color' => '#333', 'nav-link-padding' => round(get_theme_mod('padding_base', 6) * (10 / 6)) . 'px ' . round(get_theme_mod('padding_base', 6) * (15 / 6)) . 'px', 'nav-link-hover-bg' => '@gray-lighter', 'nav-disabled-link-color' => '@gray-light', 'nav-disabled-link-hover-color' => '@gray-light', 'nav-tabs-border-color' => 0.3 < $body_lum ? 'darken(@body-bg, 13.35%)' : 'lighten(@body-bg, 13.35%)', 'nav-tabs-link-hover-border-color' => '@gray-lighter', 'nav-tabs-active-link-hover-bg' => '@body-bg', 'nav-tabs-active-link-hover-color' => '@gray', 'nav-tabs-active-link-hover-border-color' => 0.3 < $body_lum ? 'darken(@body-bg, 13.35%)' : 'lighten(@body-bg, 13.35%)', 'nav-tabs-justified-link-border-color' => 0.3 < $body_lum ? 'darken(@body-bg, 13.35%)' : 'lighten(@body-bg, 13.35%)', 'nav-tabs-justified-active-link-border-color' => '@body-bg', 'nav-pills-border-radius' => '@border-radius-base', 'nav-pills-active-link-hover-bg' => '@component-active-bg', 'nav-pills-active-link-hover-color' => '@component-active-color', 'pagination-color' => '@link-color', 'pagination-bg' => '@body-bg', 'pagination-border' => 0.3 < $body_lum ? 'darken(@body-bg, 13.35%)' : 'lighten(@body-bg, 13.35%)', 'pagination-hover-color' => '@link-hover-color', 'pagination-hover-bg' => '@gray-lighter', 'pagination-hover-border' => 0.3 < $body_lum ? 'darken(@body-bg, 13.35%)' : 'lighten(@body-bg, 13.35%)', 'pagination-active-color' => '@body-bg', 'pagination-active-bg' => '@brand-primary', 'pagination-active-border' => '@brand-primary', 'pagination-disabled-color' => '@gray-light', 'pagination-disabled-bg' => '@body-bg', 'pagination-disabled-border' => 0.3 < $body_lum ? 'darken(@body-bg, 13.35%)' : 'lighten(@body-bg, 13.35%)', 'pager-bg' => '@pagination-bg', 'pager-border' => '@pagination-border', 'pager-border-radius' => round(get_theme_mod('border_radius', 4) * (15 / 4)) . 'px', 'pager-hover-bg' => '@pagination-hover-bg', 'pager-active-bg' => '@pagination-active-bg', 'pager-active-color' => '@pagination-active-color', 'pager-disabled-color' => '@pagination-disabled-color', 'jumbotron-padding' => round(get_theme_mod('padding_base', 6) * (30 / 6)) . 'px', 'jumbotron-color' => 'inherit', 'jumbotron-bg' => '#' . $jumbotron_obj->toHex(), 'jumbotron-heading-color' => 'inherit', 'jumbotron-font-size' => get_theme_mod('font_jumbotron_size', 20), 'state-success-text' => '@brand-success', 'state-success-bg' => 'mix(@body-bg, @brand-success, 70%)', 'state-success-border' => 'darken(spin(@state-success-bg, -10), 5%)', 'state-info-text' => '@brand-info', 'state-info-bg' => 'mix(@body-bg, @brand-info, 70%)', 'state-info-border' => 'darken(spin(@state-info-bg, -10), 7%)', 'state-warning-text' => '@brand-warning', 'state-warning-bg' => 'mix(@body-bg, @brand-warning, 70%)', 'state-warning-border' => 'darken(spin(@state-warning-bg, -10), 5%)', 'state-danger-text' => '@brand-danger', 'state-danger-bg' => 'mix(@body-bg, @brand-danger, 70%)', 'state-danger-border' => 'darken(spin(@state-danger-bg, -10), 5%)', 'tooltip-max-width' => '200px', 'tooltip-color' => '@body-bg', 'tooltip-bg' => 'darken(@gray-darker, 15%)', 'tooltip-opacity' => '.9', 'tooltip-arrow-width' => '5px', 'tooltip-arrow-color' => '@tooltip-bg', 'popover-bg' => '@body-bg', 'popover-max-width' => '276px', 'popover-border-color' => 'rgba(0,0,0,.2)', 'popover-fallback-border-color' => 0.3 < $body_lum ? 'darken(@body-bg, 20%)' : 'lighten(@body-bg, 20%)', 'popover-title-bg' => 'darken(@popover-bg, 3%)', 'popover-arrow-width' => '10px', 'popover-arrow-color' => '@popover-bg', 'popover-arrow-outer-width' => '(@popover-arrow-width + 1)', 'popover-arrow-outer-color' => 'fadein(@popover-border-color, 5%)', 'popover-arrow-outer-fallback-color' => 'darken(@popover-fallback-border-color, 20%)', 'label-default-bg' => '@gray-light', 'label-primary-bg' => '@brand-primary', 'label-success-bg' => '@brand-success', 'label-info-bg' => '@brand-info', 'label-warning-bg' => '@brand-warning', 'label-danger-bg' => '@brand-danger', 'label-color' => '@body-bg', 'label-link-hover-color' => '@body-bg', 'modal-inner-padding' => round(get_theme_mod('padding_base', 6) * (15 / 6)) . 'px', 'modal-title-padding' => round(get_theme_mod('padding_base', 6) * (15 / 6)) . 'px', 'modal-title-line-height' => '@line-height-base', 'modal-content-bg' => '@body-bg', 'modal-content-border-color' => 'rgba(0,0,0,.2)', 'modal-content-fallback-border-color' => '#999', 'modal-backdrop-bg' => '#000', 'modal-backdrop-opacity' => '.5', 'modal-header-border-color' => 0.3 < $body_lum ? 'darken(@body-bg, 10.2%)' : 'lighten(@body-bg, 10.2%)', 'modal-footer-border-color' => '@modal-header-border-color', 'modal-lg' => round($screen_md - 3 * $gutter) . 'px', 'modal-md' => round($screen_sm - 3 * $gutter) . 'px', 'modal-sm' => round($screen_xs - 3 * $gutter) . 'px', 'alert-padding' => round(get_theme_mod('padding_base', 6) * (15 / 6)) . 'px', 'alert-border-radius' => '@border-radius-base', 'alert-link-font-weight' => 'bold', 'alert-success-bg' => '@state-success-bg', 'alert-success-text' => '@state-success-text', 'alert-success-border' => '@state-success-border', 'alert-info-bg' => '@state-info-bg', 'alert-info-text' => '@state-info-text', 'alert-info-border' => '@state-info-border', 'alert-warning-bg' => '@state-warning-bg', 'alert-warning-text' => '@state-warning-text', 'alert-warning-border' => '@state-warning-border', 'alert-danger-bg' => '@state-danger-bg', 'alert-danger-text' => '@state-danger-text', 'alert-danger-border' => '@state-danger-border', 'progress-bg' => 0.3 < $body_lum ? 'darken(@body-bg, 4%)' : 'lighten(@body-bg, 4%)', 'progress-bar-color' => '@body-bg', 'progress-border-radius' => 'border-radius-base', 'progress-bar-bg' => '@brand-primary', 'progress-bar-success-bg' => '@brand-success', 'progress-bar-warning-bg' => '@brand-warning', 'progress-bar-danger-bg' => '@brand-danger', 'progress-bar-info-bg' => '@brand-info', 'list-group-bg' => '@body-bg', 'list-group-border' => 0.3 < $body_lum ? 'darken(@body-bg, 13.35%)' : 'lighten(@body-bg, 13.35%)', 'list-group-border-radius' => '@border-radius-base', 'list-group-hover-bg' => 0.3 < $body_lum ? 'darken(@body-bg, 4%)' : 'lighten(@body-bg, 4%)', 'list-group-active-color' => '@component-active-color', 'list-group-active-bg' => '@component-active-bg', 'list-group-active-border' => '@list-group-active-bg', 'list-group-active-text-color' => 'lighten(@list-group-active-bg, 40%)', 'list-group-disabled-color' => 'gray-light', 'list-group-disabled-bg' => 'gray-lighter', 'list-group-disabled-text-color' => 'list-group-disabled-color', 'list-group-link-color' => '@gray', 'list-group-link-hover-color' => '@list-group-link-color', 'list-group-link-heading-color' => '@gray-dark', 'panel-bg' => '@body-bg', 'panel-body-padding' => round(get_theme_mod('padding_base', 6) * (15 / 6)) . 'px', 'panel-heading-padding' => round(get_theme_mod('padding_base', 6) * (10 / 6)) . 'px ' . round(get_theme_mod('padding_base', 6) * (15 / 6)) . 'px', 'panel-footer-padding' => '@panel-heading-padding', 'panel-border-radius' => '@border-radius-base', 'panel-inner-border' => 0.3 < $body_lum ? 'darken(@body-bg, 13.35%)' : 'lighten(@body-bg, 13.35%)', 'panel-footer-bg' => 0.3 < $body_lum ? 'darken(@body-bg, 4%)' : 'lighten(@body-bg, 4%)', 'panel-default-text' => '@gray-dark', 'panel-default-border' => 0.3 < $body_lum ? 'darken(@body-bg, 13.35%)' : 'lighten(@body-bg, 13.35%)', 'panel-default-heading-bg' => 0.3 < $body_lum ? 'darken(@body-bg, 4%)' : 'lighten(@body-bg, 4%)', 'panel-primary-text' => '@body-bg', 'panel-primary-border' => '@brand-primary', 'panel-primary-heading-bg' => '@brand-primary', 'panel-success-text' => '@state-success-text', 'panel-success-border' => '@state-success-border', 'panel-success-heading-bg' => '@state-success-bg', 'panel-info-text' => '@state-info-text', 'panel-info-border' => '@state-info-border', 'panel-info-heading-bg' => '@state-info-bg', 'panel-warning-text' => '@state-warning-text', 'panel-warning-border' => '@state-warning-border', 'panel-warning-heading-bg' => '@state-warning-bg', 'panel-danger-text' => '@state-danger-text', 'panel-danger-border' => '@state-danger-border', 'panel-danger-heading-bg' => '@state-danger-bg', 'thumbnail-padding' => round(get_theme_mod('padding_base', 6) * (4 / 6)) . 'px', 'thumbnail-bg' => '@body-bg', 'thumbnail-border' => 0.3 < $body_lum ? 'darken(@body-bg, 13.35%)' : 'lighten(@body-bg, 13.35%)', 'thumbnail-border-radius' => '@border-radius-base', 'thumbnail-caption-color' => '@text-color', 'thumbnail-caption-padding' => round(get_theme_mod('padding_base', 6) * (9 / 6)) . 'px', 'well-bg' => 0.3 < $body_lum ? 'darken(@body-bg, 4%)' : 'lighten(@body-bg, 4%)', 'well-border' => 'darken(@well-bg, 7%)', 'badge-color' => '@body-bg', 'badge-link-hover-color' => '@body-bg', 'badge-bg' => '@gray-light', 'badge-active-color' => '@link-color', 'badge-active-bg' => '@body-bg', 'badge-font-weight' => 'bold', 'badge-line-height' => '1', 'badge-border-radius' => round(get_theme_mod('border_radius', 4) * (10 / 4)) . 'px', 'breadcrumb-padding-vertical' => round(get_theme_mod('padding_base', 6) * (8 / 6)) . 'px', 'breadcrumb-padding-horizontal' => round(get_theme_mod('padding_base', 6) * (15 / 6)) . 'px', 'breadcrumb-bg' => 0.3 < $body_lum ? 'darken(@body-bg, 4%)' : 'lighten(@body-bg, 4%)', 'breadcrumb-color' => 0.3 < $body_lum ? 'darken(@body-bg, 20%)' : 'lighten(@body-bg, 20%)', 'breadcrumb-active-color' => '@gray-light', 'breadcrumb-separator' => '"/"', 'carousel-text-shadow' => '0 1px 2px rgba(0,0,0,.6)', 'carousel-control-color' => '@body-bg', 'carousel-control-width' => '15%', 'carousel-control-opacity' => '.5', 'carousel-control-font-size' => '20px', 'carousel-indicator-active-bg' => '@body-bg', 'carousel-indicator-border-color' => '@body-bg', 'carousel-caption-color' => '@body-bg', 'close-font-weight' => 'bold', 'close-color' => '#000', 'close-text-shadow' => '0 1px 0 #fff', 'code-color' => '#c7254e', 'code-bg' => '#f9f2f4', 'kbd-color' => '@body-bg', 'kbd-bg' => '#333', 'pre-bg' => 0.3 < $body_lum ? 'darken(@body-bg, 4%)' : 'lighten(@body-bg, 4%)', 'pre-color' => '@gray-dark', 'pre-border-color' => 0.3 < $body_lum ? 'darken(@body-bg, 20%)' : 'lighten(@body-bg, 20%)', 'pre-scrollable-max-height' => '340px', 'component-offset-horizontal' => '180px', 'text-muted' => '@gray-light', 'abbr-border-color' => '@gray-light', 'headings-small-color' => '@gray-light', 'blockquote-small-color' => '@gray-light', 'blockquote-font-size' => '(@font-size-base * 1.25)', 'blockquote-border-color' => '@gray-lighter', 'page-header-border-color' => '@gray-lighter', 'hr-border' => '@gray-lighter', 'dl-horizontal-offset' => '@component-offset-horizontal');
    return $variables;
}
 function navbar_css($styles)
 {
     $nav_bg_obj = new Jetpack_Color(get_theme_mod('nav_bg', '#333333'));
     $nav_bg_lum = $nav_bg_obj->toLuminosity();
     $nav_typo_color = '#' . $nav_bg_obj->getGrayscaleContrastingColor(10)->toHex();
     $styles .= '.top-bar .name h1 a, .top-bar-section ul li > a { color: ' . $nav_typo_color . ';}';
     $styles .= '#nav-toggle span, #nav-toggle span:before, #nav-toggle span:after { background: ' . $nav_typo_color . ';}';
     $styles .= '.top-bar-section .dashicons, .top-bar-section .dashicons-before:before { line-height: inherit; height: inherit;}';
     return $styles;
 }
 /**
  * Adjusts brightness of the $hex color.
  *
  * @param   string  $hex    The hex value of a color
  * @param   integer $steps  should be between -255 and 255. Negative = darker, positive = lighter
  * @return  string          returns hex color
  */
 public static function adjust_brightness($hex, $steps)
 {
     $color_obj = new self($hex);
     $steps_percent = round($steps * 100 / 255, 2);
     $new_color = $color_obj->color->incrementLightness($steps_percent);
     $new_color_obj = new Jetpack_Color($new_color);
     return self::sanitize_hex($new_color_obj->toCSS('hex'));
 }
Exemple #5
0
 /**
  *
  * Get a Color object using /lib class.color
  * Convert to appropriate type
  *
  * @return string
  *
  */
 function get_color($color, $type)
 {
     $c = new Jetpack_Color($color, 'rgb');
     $this->color = $c;
     switch ($type) {
         case 'rgb':
             $color = implode($c->toRgbInt(), ',');
             break;
         case 'hex':
             $color = $c->toHex();
             break;
         case 'hsv':
             $color = implode($c->toHsvInt(), ',');
             break;
         default:
             return $color = $c->toHex();
     }
     return $color;
 }
 /**
  * Parse the array of variables to readable format by the less compiler
  */
 function less()
 {
     global $wp_customize;
     $variables = maera_bootstrap_get_variables();
     // define the $content to avoid PHP notices
     $content = '';
     foreach ($variables as $variable => $value) {
         $content .= '@' . $variable . ': ' . $value . ';';
     }
     // Utilities
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/hide-text.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/opacity.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/image.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/labels.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/reset-filter.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/resize.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/responsive-visibility.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/size.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/tab-focus.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/text-emphasis.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/text-overflow.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/vendor-prefixes.less');
     // Components
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/alerts.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/buttons.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/panels.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/pagination.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/list-group.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/nav-divider.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/forms.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/progress-bar.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/table-row.less');
     // Skins
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/background-variant.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/border-radius.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/gradients.less');
     // Layout
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/clearfix.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/center-block.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/nav-vertical-align.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/grid-framework.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/mixins/grid.less');
     // Reset
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/normalize.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/print.less');
     // Core CSS
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/scaffolding.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/type.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/code.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/grid.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/tables.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/forms.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/buttons.less');
     // Components
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/component-animations.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/glyphicons.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/dropdowns.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/button-groups.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/input-groups.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/navs.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/navbar.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/breadcrumbs.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/pagination.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/pager.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/labels.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/badges.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/jumbotron.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/thumbnails.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/alerts.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/progress-bars.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/media.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/list-group.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/panels.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/wells.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/close.less');
     // Components w/ JavaScript
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/modals.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/tooltip.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/popovers.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/carousel.less');
     // Utility classes
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/utilities.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/vendor/bootstrap/responsive-utilities.less');
     $content .= file_get_contents(MAERA_SHELL_PATH . '/assets/less/app.less');
     $content .= get_theme_mod('gradients_toggle', 0) ? file_get_contents(MAERA_SHELL_PATH . '/assets/less/gradients.less') : '';
     $content .= 'static' == get_theme_mod('site_style') ? '@screen-xs-max: 0 !important; .container { max-width: none !important; width: @container-large-desktop; } html { overflow-x: auto !important; }' : '';
     $less = get_theme_mod('less', '');
     $content .= !empty($less) ? $less : '';
     $body_obj = new Jetpack_Color(get_theme_mod('body_bg_color', '#ffffff'));
     $b_p_obj = new Jetpack_Color(get_theme_mod('color_brand_primary', '#428bca'));
     $body_bg = '#' . str_replace('#', '', $body_obj->toHex());
     $body_lum = $body_obj->toLuminosity();
     // Base font settings
     // TODO: use getReadableContrastingColor() from Jetpack_Color class.
     // See https://github.com/Automattic/jetpack/issues/1068
     $font_base_color = '#' . $body_obj->getGrayscaleContrastingColor(10)->toHex();
     $font_base_size = get_theme_mod('font_base_size', 14);
     $content .= 'body, h1,.h1,h2,.h2,h3,.h3,h4,.h4,h5,.h5,h6,.h6{';
     $content .= 'color: ' . $font_base_color . ';';
     $content .= '}';
     $content .= 'h1, .h1 { font-size: ' . 2.6 * get_theme_mod('font_headers_size', 1) * $font_base_size . 'px; }';
     $content .= 'h2, .h2 { font-size: ' . 2.15 * get_theme_mod('font_headers_size', 1) * $font_base_size . 'px; }';
     $content .= 'h3, .h3 { font-size: ' . 1.7 * get_theme_mod('font_headers_size', 1) * $font_base_size . 'px; }';
     $content .= 'h4, .h4 { font-size: ' . 1.1 * get_theme_mod('font_headers_size', 1) * $font_base_size . 'px; }';
     $content .= 'h5, .h5 { font-size: ' . 1 * get_theme_mod('font_headers_size', 1) * $font_base_size . 'px; }';
     $content .= 'h6, .h6 { font-size: ' . 0.85 * get_theme_mod('font_headers_size', 1) * $font_base_size . 'px; }';
     // Jumbotron font
     $jumbotron_obj = new Jetpack_Color(get_theme_mod('jumbo_bg', '#ffffff'));
     $content .= '.jumbotron{';
     $content .= 'color: ' . '#' . $body_obj->getGrayscaleContrastingColor(10)->toHex() . ';';
     $content .= '}';
     // Make sure links are readable
     $links_color = $b_p_obj->getReadableContrastingColor($body_obj, 2);
     // Use "body a" instead of plain "a" to override the defaults
     $content .= 'a, a:visited, a:hover { color: #' . $links_color->toHex() . ';}';
     return $content;
 }
 public function getMaxContrastColor()
 {
     $lum = $this->toLuminosity();
     $color = new Jetpack_Color();
     $hex = $lum >= 0.5 ? '000000' : 'ffffff';
     return $color->fromHex($hex);
 }
/**
 * Gather Options
 *
 * @since  1.0.0
 *
 * @return array $options
 */
function gather_options()
{
    // Theme defaults
    $primary_color = '#5bc08c';
    $secondary_color = '#f99868';
    // Stores all the controls that will be added
    $options = array();
    // Stores all the sections to be added
    $sections = array();
    // Header section
    $section = 'title_tagline';
    $options['logo'] = array('id' => 'logo', 'label' => __('Logo', 'gather'), 'section' => $section, 'type' => 'upload', 'default' => '', 'priority' => 10);
    $options['center-branding'] = array('id' => 'center-branding', 'label' => __('Center Header Text/Logo', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 0, 'priority' => 20);
    $options['header-background-color'] = array('id' => 'header-background-color', 'label' => __('Header Background Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => '#ffffff', 'priority' => 30);
    $options['header-background-image'] = array('id' => 'header-background-image', 'label' => __('Header Background Image', 'gather'), 'section' => $section, 'type' => 'upload', 'default' => '', 'priority' => 40);
    $choices = array('image-scale' => 'Image Scale', 'image-repeat' => 'Image Repeat');
    $options['header-background-image-style'] = array('id' => 'header-background-image-style', 'label' => __('Background Image Style', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => $choices, 'default' => 'image-scale', 'priority' => 50);
    // Navigation Styles
    $section = 'navigation-styles';
    $sections[] = array('id' => $section, 'title' => __('Navigation Styles', 'gather'), 'priority' => '30');
    $menus = array('primary', 'secondary');
    foreach ($menus as $menu) {
        if (!has_nav_menu($menu)) {
            break;
        }
        if ($menu == 'primary') {
            $label = __('Primary Menu');
        }
        if ($menu == 'secondary') {
            $label = __('Secondary Menu');
        }
        $options[$menu . '-menu-background'] = array('id' => $menu . '-menu-background', 'label' => __(sprintf('Background (%s)', $label), 'gather'), 'section' => $section, 'type' => 'color', 'default' => $primary_color);
        $mod = get_theme_mod($menu . '-menu-background', $primary_color);
        $color = sanitize_hex_color($mod);
        // 5% lighter
        $color_obj = new Jetpack_Color($color);
        $lighten5 = $color_obj->lighten(5)->toHex();
        // 20% lighter
        $color_obj = new Jetpack_Color($color);
        $lighten20 = $color_obj->lighten(20)->toHex();
        // Contrasting text
        $color_obj = new Jetpack_Color($color);
        $contrast = $color_obj->getGrayscaleContrastingColor()->lighten(40)->toHex();
        $options[$menu . '-menu-background-hover'] = array('id' => $menu . '-menu-background-hover', 'label' => __(sprintf('Background Hover (%s)', $label), 'gather'), 'section' => $section, 'type' => 'color', 'default' => $lighten5);
        $options[$menu . '-menu-color'] = array('id' => $menu . '-menu-color', 'label' => __(sprintf('Text (%s)', $label), 'gather'), 'section' => $section, 'type' => 'color', 'default' => $contrast);
        $options[$menu . '-menu-border'] = array('id' => $menu . '-menu-border', 'label' => __(sprintf('Border (%s)', $label), 'gather'), 'section' => $section, 'type' => 'color', 'default' => $lighten20);
        $options[$menu . '-menu-search'] = array('id' => $menu . '-menu-search', 'label' => __(sprintf('Search Box (%s)', $label), 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 0);
    }
    // Colors
    $section = 'colors';
    $sections[] = array('id' => $section, 'title' => __('Colors', 'gather'), 'priority' => '80');
    $options['primary-color'] = array('id' => 'primary-color', 'label' => __('Primary Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => $primary_color);
    $options['secondary-color'] = array('id' => 'secondary-color', 'label' => __('Secondary Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => $secondary_color);
    $options['site-title-color'] = array('id' => 'site-title-color', 'label' => __('Site Title Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => $primary_color);
    $options['site-title-hover-color'] = array('id' => 'site-title-hover-color', 'label' => __('Site Title Hover Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => $secondary_color);
    $options['site-tagline-color'] = array('id' => 'site-tagline-color', 'label' => __('Site Tagline Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => $primary_color);
    // Layout
    $section = 'layout';
    $sections[] = array('id' => $section, 'title' => __('Layout', 'gather'), 'priority' => '70');
    $choices = array('sidebar-right' => 'Sidebar Right', 'sidebar-left' => 'Sidebar Left');
    $options['standard-layout'] = array('id' => 'standard-layout', 'label' => __('Standard Layout', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => $choices, 'default' => 'sidebar-right');
    $choices = array('standard' => 'Standard Layout', 'column-masonry-2' => '2 Column Masonry', 'column-masonry-3' => '3 Column Masonry', 'column-masonry-4' => '4 Column Masonry');
    $options['archive-layout'] = array('id' => 'archive-layout', 'label' => __('Archive Layout', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => $choices, 'default' => 'column-masonry-3');
    $options['archive-sidebar'] = array('id' => 'archive-sidebar', 'label' => __('Display Sidebar on Archives', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 0);
    // Typography
    $section = 'typography';
    $sections[] = array('id' => $section, 'title' => __('Typography', 'gather'), 'priority' => '75');
    $options['site-title-font'] = array('id' => 'site-title-font', 'label' => __('Site Title Font', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => customizer_library_get_font_choices(), 'default' => 'Monoton');
    $options['primary-font'] = array('id' => 'primary-font', 'label' => __('Primary Font', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => customizer_library_get_font_choices(), 'default' => 'Roboto');
    $options['secondary-font'] = array('id' => 'secondary-font', 'label' => __('Secondary Font', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => customizer_library_get_font_choices(), 'default' => 'Merriweather');
    // Archive Settings
    $section = 'archive';
    $sections[] = array('id' => $section, 'title' => __('Archive', 'gather'), 'priority' => '80');
    $options['archive-excerpts'] = array('id' => 'archive-excerpts', 'label' => __('Display Excerpts', 'gather'), 'description' => __('Display excerpts instead of full content.', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 0);
    $options['archive-featured-images'] = array('id' => 'archive-featured-images', 'label' => __('Display Featured Images', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 1);
    // Post Settings
    $section = 'post';
    $sections[] = array('id' => $section, 'title' => __('Post', 'gather'), 'priority' => '80');
    $options['display-post-dates'] = array('id' => 'display-post-dates', 'label' => __('Display Post Dates', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 1);
    $options['post-featured-images'] = array('id' => 'post-featured-images', 'label' => __('Display Featured Images', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 1);
    // Footer Settings
    $section = 'footer';
    $sections[] = array('id' => $section, 'title' => __('Footer', 'gather'), 'priority' => '100');
    $options['footer-text'] = array('id' => 'footer-text', 'label' => __('Footer Text', 'gather'), 'section' => $section, 'type' => 'textarea', 'default' => gather_get_default_footer_text());
    // Adds the sections to the $options array
    $options['sections'] = $sections;
    $customizer_library = Customizer_Library::Instance();
    $customizer_library->add_options($options);
}
 /**
  * Build CSS from Tonesque
  *
  * @uses get_the_ID(), is_single(), get_post_meta(), colorposts_get_post_image(), update_post_meta(), apply_filters()
  *
  * @since Color Posts 1.0
  */
 function colorposts_build_css($styles)
 {
     $src = $this->custom_header_url();
     if ($src && get_template_directory_uri() . '/core-shell/assets/images/grid-back.png' != $src) {
         $attachment_id = $this->pn_get_attachment_id_from_url($src);
         // Grab color from post meta
         $tonesque = get_post_meta($attachment_id, '_post_colors', true);
         // No color? Let's get one
         if (empty($tonesque)) {
             $tonesque = new Tonesque($src);
             $tonesque = array('color' => $tonesque->color(), 'contrast' => $tonesque->contrast());
             if ($tonesque['color']) {
                 update_post_meta(get_the_ID(), '_post_colors', $tonesque);
             }
         }
         // Add the CSS to our page
         extract($tonesque);
         if (!empty($color)) {
             $white = new Jetpack_Color('#FFFFFF');
             $color = new Jetpack_Color('#' . $color);
             $luminosity = $color->toLuminosity();
             $fontcolor = $luminosity < 0.5 ? '#FFFFFF' : '#222222';
             $background = $fontcolor == '#FFFFFF' ? 'rgba(0,0,0,0.3)' : 'rgba(255,255,255,0.3)';
             $styles .= 'a{color:#' . $color->getReadableContrastingColor($white, 6)->toHex() . ';}';
             $styles .= '#menu.menu-wrap, .menu-button {background-color:#' . $color->getReadableContrastingColor($white)->toHex() . ';}';
             $styles .= '.page-header{color:' . $fontcolor . ' !important; background: ' . $background . ';box-shadow:0px 0px 5px ' . $color . ';}';
         }
     } else {
         $styles .= '.page-header:before{background-color:#0C6890;background-image:url("' . get_template_directory_uri() . '/core-shell/assets/images/grid-back.png' . '");background-size:auto !important;background-repeat:repeat;}';
     }
     return $styles;
 }
/**
 * Takes the background color and works out contrasts for text and borders
 *
 * This uses Jetpack class.color.php if JetPack exists, otherwise it uses the bundled color.php
 *
 */
function tonal_style_output()
{
    // Check to see if JetPack class.color.php exists - we bundle one just incase
    if (!class_exists('Jetpack_Color')) {
        require_once dirname(__FILE__) . '/class.color.php';
    }
    // We are going to base everything from the background color so load that up
    $hexColor = get_background_color();
    if (empty($hexColor)) {
        $hexColor = 'ffffff';
    }
    // We are going to next declare an new object from the Jetpack_Color class
    $color = new Jetpack_Color($hexColor);
    // Will out put 000000 or ffffff so can use as a guide whether a dark or light background
    $contrastColor = $color->getMaxContrastColor();
    // If a dark background then load up the white background tones
    if ($contrastColor == "#000000") {
        $toneColor = $color->darken(10);
        $bodyColor = $color->getGrayscaleContrastingColor()->lighten(10);
        $headerColor = $color->getGrayscaleContrastingColor();
        tonal_tone('dark');
    } else {
        $toneColor = $color->lighten(10);
        $bodyColor = $color->getGrayscaleContrastingColor()->darken(10);
        $headerColor = $color->getGrayscaleContrastingColor()->darken();
        tonal_tone('light');
    }
    // Lets now output the CSS for creating the tonal effects
    ?>
	<style type="text/css">
		body {
			background: #<?php 
    echo $hexColor;
    ?>
;
		}
		#page{
			z-index: 9999;
		}
		#page:before, #page:after {
    		background-color: <?php 
    echo $toneColor;
    ?>
;
			z-index: 9999;
		}
		#page {
	    	border-left: 20px solid <?php 
    echo $toneColor;
    ?>
;
    		border-right: 20px solid <?php 
    echo $toneColor;
    ?>
;
			z-index: 9999;
		}
		h1,
		h2,
		h3,
		h4,
		h5,
		h6,
		a,
		a:visited {
			color: <?php 
    echo $headerColor;
    ?>
;
		}
		body,
		button,
		input,
		select,
		textarea,
		a:hover {
			color: <?php 
    echo $bodyColor;
    ?>
;
		}
	</style>
	<?php 
}
Exemple #11
0
 /**
  * Process user options to generate CSS needed to implement the choices.
  *
  * @since  1.0.0.
  *
  * @return void
  */
 function gather_styles()
 {
     // Primary Color
     $setting = 'primary-color';
     $mod = get_theme_mod($setting, customizer_library_get_default($setting));
     if ($mod !== customizer_library_get_default($setting)) {
         $color = sanitize_hex_color($mod);
         $color_obj = new Jetpack_Color($color);
         // Link Styling
         Customizer_Library_Styles()->add(array('selectors' => array('a', '.site-title a'), 'declarations' => array('color' => $color)));
         // Button Styling
         Customizer_Library_Styles()->add(array('selectors' => array('button', '.button', 'input[type="button"]', 'input[type="reset"]', 'input[type="submit"]', '.masonry .entry-footer-meta a:hover'), 'declarations' => array('background-color' => $color)));
         // Button Hover State
         Customizer_Library_Styles()->add(array('selectors' => array('button:hover', '.button:hover', 'input[type="button"]:hover', 'input[type="reset"]:hover', 'input[type="submit"]:hover'), 'declarations' => array('background-color' => $color_obj->darken(5))));
         // Border Colors
         Customizer_Library_Styles()->add(array('selectors' => array('#content blockquote', '.page-header'), 'declarations' => array('border-color' => $mod)));
     }
     // Secondary Color
     $setting = 'secondary-color';
     $mod = get_theme_mod($setting, customizer_library_get_default($setting));
     if ($mod !== customizer_library_get_default($setting)) {
         // Colors
         Customizer_Library_Styles()->add(array('selectors' => array('.site-title a:hover', '.bypostauthor .comment-author .fn:after'), 'declarations' => array('color' => sanitize_hex_color($color))));
     }
     // Primary Font
     $setting = 'primary-font';
     $mod = get_theme_mod($setting, customizer_library_get_default($setting));
     $stack = customizer_library_get_font_stack($mod);
     if ($mod != customizer_library_get_default($setting)) {
         Customizer_Library_Styles()->add(array('selectors' => array('body', '.site-description', '.widget-title', '.comments-title', '#reply-title'), 'declarations' => array('font-family' => $stack)));
     }
     // Secondary Font
     $setting = 'secondary-font';
     $mod = get_theme_mod($setting, customizer_library_get_default($setting));
     $stack = customizer_library_get_font_stack($mod);
     if ($mod != customizer_library_get_default($setting)) {
         Customizer_Library_Styles()->add(array('selectors' => array('h1, h2, h3, h4, h5, h6', '.comment-author'), 'declarations' => array('font-family' => $stack)));
     }
     // Menu Styling
     $menus = array('primary', 'secondary');
     foreach ($menus as $menu) {
         if (!has_nav_menu($menu)) {
             break;
         }
         if ($menu == 'primary') {
             $selector = '#primary-navigation' . ' ';
         }
         if ($menu == 'secondary') {
             $selector = '#secondary-navigation' . ' ';
         }
         // Background
         $setting = $menu . '-menu-background';
         $mod = get_theme_mod($setting, false);
         if ($mod) {
             Customizer_Library_Styles()->add(array('selectors' => array($selector, $selector . 'ul ul a:hover'), 'declarations' => array('background-color' => $mod)));
         }
         // Background Hover
         $setting = $menu . '-menu-background-hover';
         $mod = get_theme_mod($setting, false);
         if ($mod) {
             Customizer_Library_Styles()->add(array('selectors' => array($selector . 'a:hover', $selector . 'li:hover a'), 'declarations' => array('background-color' => $mod)));
         }
         // Navigation Text
         $setting = $menu . '-menu-color';
         $mod = get_theme_mod($setting, false);
         if ($mod) {
             Customizer_Library_Styles()->add(array('selectors' => array($selector . 'a', $selector . 'a:hover', $selector . 'li:hover a', $selector . '.dropdown-toggle:after'), 'declarations' => array('color' => $mod)));
         }
         // Border
         $setting = $menu . '-menu-border';
         $mod = get_theme_mod($setting, false);
         if ($mod) {
             Customizer_Library_Styles()->add(array('selectors' => array($selector . 'ul', $selector . 'a', $selector . '.dropdown-toggle', $selector . 'ul ul', $selector . 'ul ul a', $selector . 'ul li:hover ul a', $selector . 'ul ul ul'), 'declarations' => array('border-color' => $mod)));
         }
     }
     // Header Background Color
     $setting = 'header-background-color';
     $mod = get_theme_mod($setting, customizer_library_get_default($setting));
     if ($mod != customizer_library_get_default($setting)) {
         Customizer_Library_Styles()->add(array('selectors' => array('.site-branding'), 'declarations' => array('background-color' => $mod)));
     }
     // Header Background Image
     $setting = 'header-background-image';
     $mod = get_theme_mod($setting, false);
     if ($mod) {
         Customizer_Library_Styles()->add(array('selectors' => array('.site-branding'), 'declarations' => array('background-image' => 'url(' . $mod . ')')));
     }
     // Header Background Image Styles
     $setting = 'header-background-image-style';
     $mod = get_theme_mod($setting, customizer_library_get_default($setting));
     if ($mod != customizer_library_get_default($setting)) {
         Customizer_Library_Styles()->add(array('selectors' => array('.site-branding'), 'declarations' => array('background-size' => 'auto auto', 'background-repeat' => 'repeat', 'background-position' => '0 0')));
     }
     // Center Header Text
     $setting = 'center-branding';
     $mod = get_theme_mod($setting, customizer_library_get_default($setting));
     if ($mod) {
         Customizer_Library_Styles()->add(array('selectors' => array('.site-branding'), 'declarations' => array('text-align' => 'center')));
     }
     // Site Title Color
     $setting = 'site-title-color';
     $mod = get_theme_mod($setting, customizer_library_get_default($setting));
     if ($mod != customizer_library_get_default($setting)) {
         Customizer_Library_Styles()->add(array('selectors' => array('.site-title a'), 'declarations' => array('color' => $mod)));
     }
     // Site Title Color
     $setting = 'site-title-hover-color';
     $mod = get_theme_mod($setting, customizer_library_get_default($setting));
     if ($mod != customizer_library_get_default($setting)) {
         Customizer_Library_Styles()->add(array('selectors' => array('.site-title a:hover'), 'declarations' => array('color' => $mod)));
     }
     // Site Title Font
     $setting = 'site-title-font';
     $mod = get_theme_mod($setting, customizer_library_get_default($setting));
     $stack = customizer_library_get_font_stack($mod);
     if ($mod != customizer_library_get_default($setting)) {
         Customizer_Library_Styles()->add(array('selectors' => array('.site-title'), 'declarations' => array('font-family' => $stack)));
     }
     // Site Tagline Color
     $setting = 'site-tagline-color';
     $mod = get_theme_mod($setting, customizer_library_get_default($setting));
     if ($mod != customizer_library_get_default($setting)) {
         Customizer_Library_Styles()->add(array('selectors' => array('.site-description'), 'declarations' => array('color' => $mod)));
     }
 }
Exemple #12
0
 public function getMaxContrastColor()
 {
     $withBlack = $this->getDistanceLuminosityFrom(new Jetpack_Color('#000'));
     $withWhite = $this->getDistanceLuminosityFrom(new Jetpack_Color('#fff'));
     $color = new Jetpack_Color();
     $hex = $withBlack >= $withWhite ? '#000000' : '#ffffff';
     return $color->fromHex($hex);
 }