Browse Source

Standardize customizer color saving.

pull/11/head
Ned Zimmerman 7 years ago
parent
commit
915cf1ba91
No known key found for this signature in database
GPG Key ID: FF56334A013120CA
  1. 6
      app/admin.php
  2. 8
      app/helpers.php
  3. 13
      app/setup.php

6
app/admin.php

@ -18,7 +18,8 @@ add_action('customize_register', function (\WP_Customize_Manager $wp_customize)
// Add settings
$wp_customize->add_setting('pb_network_primary_color', [
'type' => 'option',
'default' => '#b01109',
'default' => 'b01109',
'sanitize_callback' => 'Aldine\remove_hash',
]);
$wp_customize->add_control(new \WP_Customize_Color_Control(
$wp_customize,
@ -32,7 +33,8 @@ add_action('customize_register', function (\WP_Customize_Manager $wp_customize)
));
$wp_customize->add_setting('pb_network_secondary_color', [
'type' => 'option',
'default' => '#015d75',
'default' => '015d75',
'sanitize_callback' => 'Aldine\remove_hash',
]);
$wp_customize->add_control(new \WP_Customize_Color_Control(
$wp_customize,

8
app/helpers.php

@ -136,3 +136,11 @@ function locate_template($templates)
{
return \locate_template(filter_templates($templates));
}
/**
* Remove hash from hex color string
*/
function remove_hash($color)
{
return ltrim($color, '#');
}

13
app/setup.php

@ -206,7 +206,8 @@ add_action('wp_head', function () {
$header_text_color = get_header_textcolor();
if ($primary || $secondary || $header_text_color) { ?>
<style type="text/css">
<?php if ($primary) { ?>
<?php if ($primary) {
$primary = '#' . $primary; ?>
a { color: <?= $primary ?>; }
.primary { color: <?= $primary ?>; }
.bg-primary { background-color: <?= $primary ?>; }
@ -241,7 +242,8 @@ add_action('wp_head', function () {
background: <?= $primary ?>;
}
<?php }
if ($secondary) { ?>
if ($secondary) {
$secondary = '#' . $secondary; ?>
.secondary { color: <?= $secondary ?>; }
.bg-secondary { background-color: <?= $secondary ?>; }
.b--secondary {
@ -274,13 +276,14 @@ if ($secondary) { ?>
color: <?= $secondary ?>;
}
<?php }
if ($header_text_color) { ?>
if ($header_text_color) {
$header_text_color = '#' . $header_text_color; ?>
.banner .branding p {
color: #<?= $header_text_color ?>;
color: <?= $header_text_color ?>;
}
@media (min-width: 1200px) {
.banner .primary-navigation a {
color: #<?= $header_text_color ?>;
color: <?= $header_text_color ?>;
}
}
<?php } ?>

Loading…
Cancel
Save