|
|
|
@ -6,6 +6,9 @@
|
|
|
|
|
|
|
|
|
|
namespace Aldine\Actions; |
|
|
|
|
|
|
|
|
|
use Spatie\Color\Hex; |
|
|
|
|
use Spatie\Color\Rgb; |
|
|
|
|
use Spatie\Color\Rgba; |
|
|
|
|
use PressbooksMix\Assets; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -165,35 +168,9 @@ function content_width() {
|
|
|
|
|
* @return void |
|
|
|
|
*/ |
|
|
|
|
function output_custom_colors() { |
|
|
|
|
$colors = [ |
|
|
|
|
'primary', |
|
|
|
|
'accent', |
|
|
|
|
'primary_fg', |
|
|
|
|
'accent_fg', |
|
|
|
|
'header_text', |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$values = []; |
|
|
|
|
|
|
|
|
|
foreach ( $colors as $k ) { |
|
|
|
|
$v = get_option( "pb_network_color_$k" ); |
|
|
|
|
if ( $v ) { |
|
|
|
|
$values[ $k ] = $v; |
|
|
|
|
if ( defined( 'PB_PLUGIN_VERSION' ) ) { |
|
|
|
|
echo \Pressbooks\Admin\Branding\get_customizer_colors(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$output = ''; |
|
|
|
|
|
|
|
|
|
if ( ! empty( $values ) ) { |
|
|
|
|
$output .= '<style type="text/css">:root{'; |
|
|
|
|
foreach ( $values as $k => $v ) { |
|
|
|
|
$k = str_replace( '_', '-', $k ); |
|
|
|
|
$output .= "--$k:$v;"; |
|
|
|
|
} |
|
|
|
|
$output .= '}</style>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo $output; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -220,3 +197,25 @@ function hide_catalog_content_editor() {
|
|
|
|
|
remove_post_type_support( 'page', 'thumbnail' ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Add dark and alpha variants for customizer colors on update. |
|
|
|
|
* |
|
|
|
|
* @since 1.0.0 |
|
|
|
|
*/ |
|
|
|
|
function add_color_variants( $option, $old_value, $value ) { |
|
|
|
|
if ( ! in_array( $option, [ 'pb_network_color_primary', 'pb_network_color_accent' ], true ) ) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$color = Hex::fromString( $value ); |
|
|
|
|
$color = $color->toRgb(); |
|
|
|
|
$color_alpha = $color->toRgba( 0.25 ); |
|
|
|
|
$color_dark = new Rgb( |
|
|
|
|
$color->red() * 0.9, |
|
|
|
|
$color->green() * 0.9, |
|
|
|
|
$color->blue() * 0.9 |
|
|
|
|
); |
|
|
|
|
update_option( $option . '_dark', (string) $color_dark ); |
|
|
|
|
update_option( $option . '_alpha', (string) $color_alpha ); |
|
|
|
|
} |
|
|
|
|