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.

 

ECommerce Transaction Alternatives For WordPress.

When choosing an alternative to WooCommerce, consider specific needs, such as the type of products you’re selling, payment requirements, and desired features. Each of these plugins offers unique strengths that may better suit your ecommerce goals.

Webflow Price Increases

Webflow's recent price increase of approximately 44% for its CMS plans has sparked significant reactions among its user base, particularly among freelancers, agencies, and developers. Here are some key points and side effects based on user feedback: User Reactions and...

NXDOMAIN and DNS_PROBE_FINISHED_NXDOMAIN

An NXDOMAIN error, which stands for “Non-Existent Domain,” occurs when a domain name cannot be resolved by DNS servers. This error is common in various contexts, including WordPress sites.

9 Trends & Flexes In 2024 Web Design

The landscape of web design continues to evolve, embracing new technologies and design philosophies that enhance user experience, accessibility, and visual appeal.

Give Marketers A Perk: A Marketing Job WITHOUT Website Management

With all of the talk of workplace overload and the heavy job requirements, taking something off of a marketer’s plate provides two big wins: it give the marketer more breathing room to accomplish the important things in their job; and it offers the business owner some continuity on the public face of their brand– their website. Here’s our exhaustive list of ways a WordPress maintenance plan can help a marketer do their job better.

The Juggling Act of Priorities for a WordPress Developer

Being a WordPress developer is akin to performing a delicate juggling act. With numerous tasks requiring attention, from translating visual designs into functional websites to ensuring optimal performance and security, managing priorities becomes crucial. We put a lot of effort putting together an in-depth look at how a WordPress developer can effectively balance these responsibilities.

SEO In the World of Artificial Intelligence

Getting An Audience via Search Engine Optimized Content There's a new sheriff in town. Its name is "Search Generative Experience." For a while now, Google has been moving from being the world's biggest index of web pages do being the destination unto itself. Its...

Stripe vs Square vs Paypal

Here’s a quick rundown of these three major ecommerce providers and how they compare to each other. In my 25+ years of ecommerce rollouts, I have dealt with Stripe, Square and Paypal implementations as well as deployments with other providers like Authorize.net, Beanstream (WorldPay), Moneris and others. I really think the three in this article can satisfy most use cases.

Five Tips For AI In Content Creation

There’s a lot to consider about the practical aspects of creating content with AI but also the creative collaboration between human intelligence and artificial intelligence.

Understanding CSS Media Queries

CSS media queries are a powerful tool that allow you to apply different styles based on the characteristics of the device or viewport. They enable you to create responsive designs that adapt to different screen sizes, resolutions, and device types (desktop, tablet, mobile, etc.).

Spring into 2024: 30 Great Backlink Sources

Creating backlinks, which are links from one website to another, is a fundamental aspect of search engine optimization (SEO). They act as a "vote of confidence" from one site to another, indicating to search engines that the content is valuable, credible, and useful....

Getting More from Your CRM: Integrating GlueUp with WordPress

Customer relationship management (CRM) systems like GlueUp are invaluable for managing contacts, deals, and business relationships. However, the data in these systems often remains locked away, unseen by your wider customer base. Integrating your CRM with your...

Empowering Legal Advocacy Through Digital Solutions

In an era where digital presence is crucial, Web321 stands at the forefront of offering custom web solutions tailored for groups embarking on legal advocacy, particularly those initiating or involved in class-action lawsuits. Our expertise caters to the unique needs...