Overwrite the existing preset’s value using PHP
How do you modify the value of existing preset in Beaver Builder Theme? You are activating the BB child theme and default value of a preset is modifying automatically without open the theme customizer. In this article I am showing how you will do this via PHP.
Assuming that you will modify the default value of “Default Dark” preset.
Step 1
Creating the new PHP file “class-customizer-defaults.php” and putting into bb child theme’s classes folder. Now open the file and add the following PHP snippet:
Setting Default Values
'default-dark', 'fl-layout-width' => 'full-width', 'fl-content-width' => '1170', 'fl-body-bg-color' => '#ffffff', 'fl-scroll-to-top' => 'enable', 'fl-accent' => '#13afdf', 'fl-accent-hover' => '#2e2f33', /* Heading */ 'fl-heading-text-color' => '#2e2f33', 'fl-heading-font-family' => 'Libre Franklin', 'fl-heading-font-weight' => '300', 'fl-h1-font-size' => '26', 'fl-h2-font-size' => '24', 'fl-h3-font-size' => '20', 'fl-h4-font-size' => '18', 'fl-h5-font-size' => '16', 'fl-h6-font-size' => '15', /* Body */ 'fl-body-font-family' => 'Libre Franklin', 'fl-body-text-color' => '#333333', 'fl-body-font-weight' => '400', 'fl-body-font-size' => '16', 'fl-body-line-height' => '1.66', /* Top bar */ 'fl-topbar-text-color' => '#2e2f33', 'fl-topbar-link-color' => '#2e2f33', 'fl-topbar-hover-color' => '#13afdf', 'fl-header-padding' => '0', 'fl-fixed-header' => 'fixed', 'fl-header-text-color' => '#333333', 'fl-header-link-color' => '#2e2f33', 'fl-header-hover-color' => '#13afdf', /* Footer */ 'fl-footer-widgets-link-color' => '#2e2f33', 'fl-footer-widgets-hover-color' => '#13afdf', 'fl-footer-link-color' => '#2e2f33', 'fl-footer-hover-color' => '#13afdf', /* Logo */ 'fl-logo-font-family' => 'Libre Franklin', 'fl-logo-font-weight' => '800', 'fl-logo-font-size' => '35', 'fl-nav-font-family' => 'Libre Franklin', 'fl-nav-link-color' => '#2e2f33', 'fl-nav-hover-color' => '#13afdf', 'fl-nav-item-spacing' => '10' ); add_filter( 'fl_default_theme_mods', __CLASS__ . '::probb_theme_default_mods' ); // Setup the Theme Customizer settings and controls... add_action( 'customize_register' , __CLASS__ . '::register', 12 ); } static public function probb_theme_default_mods( $mods ) { $mods = wp_parse_args( self::$default_args, $mods ); return $mods; } static public function register( $wp_customize ) { foreach (self::$default_args as $key => $value) { $wp_customize->get_setting( $key )->default = $value; } } } CustomizerDefaultMods::init();
Step 2:
Open the functions.php of BB child theme and add the following PHP code below this line require_once ‘classes/class-fl-child-theme.php’;
Include the PHP file
require_once 'classes/class-customizer-defaults.php';
Now navigate to Dashboard->Appearance->Themes page and activate the BB child theme. Default value of “Default Dark” preset will overwrite with yours one automatically.