diff --git a/app/admin.php b/app/admin.php index e82c8e2..810d747 100644 --- a/app/admin.php +++ b/app/admin.php @@ -16,36 +16,95 @@ add_action('customize_register', function (\WP_Customize_Manager $wp_customize) ]); // Add settings - $wp_customize->add_setting('pb_network_primary_color', [ - 'type' => 'option', - 'default' => 'b01109', - 'sanitize_callback' => 'Aldine\remove_hash', - ]); - $wp_customize->add_control(new \WP_Customize_Color_Control( - $wp_customize, - 'pb_network_primary_color', + foreach ([ [ + 'slug' => 'primary', + 'hex' => '#b01109', 'label' => __('Primary Color', 'aldine'), - 'section' => 'colors', - 'description' => __('Used for links and primary elements.', 'aldine'), - 'settings' => 'pb_network_primary_color', - ] - )); - $wp_customize->add_setting('pb_network_secondary_color', [ - 'type' => 'option', - 'default' => '015d75', - 'sanitize_callback' => 'Aldine\remove_hash', - ]); - $wp_customize->add_control(new \WP_Customize_Color_Control( - $wp_customize, - 'pb_network_secondary_color', + 'description' => __('Used for primary elements.', 'aldine'), + ], + [ + 'slug' => 'accent', + 'hex' => '#015d75', + 'label' => __('Accent Color', 'aldine'), + 'description' => __('Used for accents.', 'aldine'), + ], + [ + 'slug' => 'link', + 'hex' => '#b01109', + 'label' => __('Link Color', 'aldine'), + 'description' => __('Used for links.', 'aldine'), + ], + [ + 'slug' => 'header_link', + 'hex' => '#b01109', + 'label' => __('Header Link Color', 'aldine'), + 'description' => __('Used for links in the header.', 'aldine'), + ], + [ + 'slug' => 'block_border', + 'hex' => '#b01109', + 'label' => __('Block Border Color', 'aldine'), + 'description' => __('Used for home button block border.', 'aldine'), + ], + [ + 'slug' => 'fg', + 'hex' => '#ffffff', + 'label' => __('Foreground Color', 'aldine'), + 'description' => __('Used for the foreground text of colored blocks.', 'aldine'), + ], + [ + 'slug' => 'bg', + 'hex' => '#015d75', + 'label' => __('Background Color', 'aldine'), + 'description' => __('Used for the background of colored blocks.', 'aldine'), + ], + [ + 'slug' => 'btn_text', + 'hex' => '#ffffff', + 'label' => __('Button Text Color', 'aldine'), + 'description' => __('Used for the foreground text of buttons.', 'aldine'), + ], + [ + 'slug' => 'btn_active_text', + 'hex' => '#b01109', + 'label' => __('Button Active Text Color', 'aldine'), + 'description' => __('Used for the foreground text of active buttons.', 'aldine'), + ], + [ + 'slug' => 'btn_bg', + 'hex' => '#b01109', + 'label' => __('Button Background Color', 'aldine'), + 'description' => __('Used for the background of buttons.', 'aldine'), + ], + [ + 'slug' => 'btn_inverse_text', + 'hex' => '#b01109', + 'label' => __('Inverse Button Text Color', 'aldine'), + 'description' => __('Used for the foreground text of buttons.', 'aldine'), + ], [ - 'label' => __('Secondary Color', 'aldine'), - 'section' => 'colors', - 'description' => __('Used for secondary elements.', 'aldine'), - 'settings' => 'pb_network_secondary_color', - ] - )); + 'slug' => 'btn_inverse_active_text', + 'hex' => '#ffffff', + 'label' => __('Inverse Button Active Text Color', 'aldine'), + 'description' => __('Used for the background of buttons.', 'aldine'), + ], + ] as $color) { + $wp_customize->add_setting("pb_network_color_{$color['slug']}", [ + 'type' => 'option', + 'default' => $color['hex'], + ]); + $wp_customize->add_control(new \WP_Customize_Color_Control( + $wp_customize, + "pb_network_color_{$color['slug']}", + [ + 'label' => $color['label'], + 'section' => 'colors', + 'description' => $color['description'], + 'settings' => "pb_network_color_{$color['slug']}", + ] + )); + } $wp_customize->add_section('pb_network_social', [ 'title' => __('Social Media', 'aldine'), 'priority' => 30, diff --git a/app/helpers.php b/app/helpers.php index e5c4014..442f2f3 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -137,14 +137,6 @@ function locate_template($templates) return \locate_template(filter_templates($templates)); } -/** - * Remove hash from hex color string - */ -function remove_hash($color) -{ - return ltrim($color, '#'); -} - /** * * Catch a contact form submission. diff --git a/app/setup.php b/app/setup.php index a7466c1..b597343 100644 --- a/app/setup.php +++ b/app/setup.php @@ -167,22 +167,59 @@ add_action('after_setup_theme', function () { }); add_action('wp_head', function () { - $primary = get_option('pb_network_primary_color'); - $secondary = get_option('pb_network_secondary_color'); - $header_text_color = get_header_textcolor(); - if ($primary || $secondary || $header_text_color) { ?> + $primary = get_option('pb_network_color_primary'); + $accent = get_option('pb_network_color_accent'); + $link = get_option('pb_network_color_link'); + $header_link = get_option('pb_network_color_header_link'); + $fg = get_option('pb_network_color_fg'); + $bg = get_option('pb_network_color_bg'); + $btn_text = get_option('pb_network_color_btn_text'); + $btn_active_text = get_option('pb_network_color_btn_active_text'); + $btn_bg = get_option('pb_network_color_btn_bg'); + $btn_inverse_text = get_option('pb_network_color_btn_inverse_text'); + $btn_inverse_active_text = get_option('pb_network_color_btn_inverse_active_text'); + $block_border = get_option('pb_network_color_block_border'); + $header_text = get_header_textcolor(); + if ($primary || $accent || $header_text) { ?>

-

+

diff --git a/resources/views/partials/footer.blade.php b/resources/views/partials/footer.blade.php index ef15ffa..c4d04f4 100644 --- a/resources/views/partials/footer.blade.php +++ b/resources/views/partials/footer.blade.php @@ -3,7 +3,7 @@ @if(get_option('pb_network_contact_form')) @include('partials.contact-form') @endif -