Setting Up A Custom Color Scheme For Divi

by | Sep 10, 2024 | Business, Design, WordPress

I have attached the file that I used my case.One Divi feature is”Color Scheme.” It presets for green, orange, pink, red and its default blue color schemes that influence the colors of borders, buttons and other accents on a baseline Divi theme. What happens if none of those colors jibe with your design? In our case, there were layers of styling rules: baseline WordPress, Divi, Woocommerce, and our styling. It’s great that Divi has Woo specific styling available, but it wasn’t helping what we were trying to accomplish.  That’s a lot to wade through and all of those style rendering decisions turn into processor use on your client machines. A site that is intensive to render may perform worse or appear to render in some unpredictable way on some browser. Rather than add to that, setting the color scheme in Divi is one way to output as little styling as possible. The following is my approach for overriding the Divi color schemes and adding a reference for your project.

The Divi color schemes can be appended by adding some filters and actions to your custom theme’s functions.php

In my case, I was working on a custom theme, named “hira,” so the prefixes in my example echo that.

The color scheme choices need to be appended.


// Add Hira color scheme to Divi color scheme choices
function hira_color_scheme_choices($color_choices = []) {
$color_choices['hira'] = esc_html__( 'Hira', 'Divi' );
return $color_choices;
}
add_filter('et_divi_color_scheme_choices', 'hira_color_scheme_choices');

The color schemes need to be appended with an entry for the new key (example here: ‘hira.’)


// Define the Hira custom color scheme
function hira_custom_color_scheme($color_schemes) {
$color_schemes['hira'] = array(
'Accent Color'         => '#FF5733',
'Secondary Color'      => '#33FF57',
'Footer Background Color'  => '#3357FF',
'Menu Background Color' => '#FF33F1',
'Menu Text Color'      => '#33FFF1',
);
return $color_schemes;
}
add_filter('et_builder_color_schemes', 'hira_custom_color_scheme');

After the color scheme is set, it can be referenced. In my case, I added a css sub-directory to my child theme, “css.” I made a stylesheet for this scheme. I called it “hira_scheme.css” and put it in that css file.


// Load the CSS only if Hira color scheme is selected
function load_hira_scheme_css() {
// Get current theme options
$settings = get_option('et_divi');

/* Check if 'hira' is selected as the color scheme */

if ( isset( $settings['color_schemes'] ) && $settings['color_schemes'] === 'hira' ) {
// Enqueue the Hira color scheme CSS file
wp_enqueue_style( 'hira-scheme', get_stylesheet_directory_uri() . '/css/hira_scheme.css', array(), null );
}
}
add_action( 'wp_enqueue_scripts', 'load_hira_scheme_css', 15 );

To build out the scheme elements, I cribbed from the main divi file,
/wp-content/themes/Divi/style-static.min.css
I looked for all of the color scheme relevant stylings with the “_scheme_red” phrase in the selectors and copy them into my [keyword]_scheme.css file. I then do a find-replace to swap
“_red” to match your phrase from your color scheme settings (in my example, I would be swapping _red or _hira

I have attached the file that I used my project.

 

What’s the Deal With Quality Content?

What makes content high-quality? When it comes to content marketing, quality goes beyond surface metrics like word count or citations. True quality lies in how well content achieves its purpose and connects with readers. Does it align with marketing goals? Resonate...

Turning Off The AI Bar on Divi

Divi (the theme system from Elegant Themes) has added an AI tool. Some people don’t like it. With the most recent copy of Divi, the element can be switched off.

Performance Improvements That Can Speed Up Your Website

Let’s explore how to achieve some WordPress performance improvements to ensure your website is as swift while keeping any of the pizazz delivered by Javascript and CSS, keeping your audience captivated and Google happy. Let’s supercharge your WordPress website!

7 WordPress Maintenance Services in 2023

If you are tired of spending hours on mundane upkeep tasks or need expert help improving your WordPress website, a maintenance service can help you take the hassle out of running your site.

Kite Dish.com Acquired by Web321

We are proud to pick up the mantle of Kite Dish. Back in the day, they provided WordPress Maintenance. As they said it, back then: Our service provides you a peace of mind with a secure, regularly backed up, bug-free and proactively updated site so you can concentrate...

Threads: ActivityPub and WordPress

Meta has released a new microblogging app: Threads. It leverages the user base of Instagram and the users’ followers to pre-build an audience for new members. This may be an excellent antidote to the death spiral of Twitter. How does it work with WordPress?

Why Custom WordPress Themes Are A Mistake

The same people who would never buy a custom coffee maker, a custom car or a custom word processor think nothing of going for a custom theme.  Why would you want a custom theme system?

Eleven Ways Digital Marketing Can Help Your Business Thrive

The 21st century has ushered in an era of innovation that has significantly impacted businesses across the spectrum. Digital marketing, in particular, has emerged as a game changer for many successful enterprises. Here are 11 tactics for Digital Marketing.

Why We Like Combining Divi and ACF

I want to show you how we can use ACF and Toolset to insert dynamic content into our text editor. With ACF, we can easily find available fields and insert them into our content. We can also enable raw HTML to display content verbatim. Toolset works similarly, but it...