1. PROMO Upgrade to Pro Membership @ $99 / Lifetime & access all our 16+ premium Divi extensions: Divi Block, Carousel Toolkit, etc.LEARN MORE
Dismiss Notice
NEW Divi.Help Pro Carousel AI Toolkit - Magically turn your Divi design into carousel, simply by using our online toolkit. No plugins needed. Now it works with Divi 5 as well!Try our carousel AI toolkit
BEST Divi Block - A revolutionary drag & drop tool to easily mix & match 960+ premade blocks (Light & Dark) to kick start your Divi site design. Special module designs are included as well. Also newly added AI generator & color. Now it works with Divi 5 as well!
Learn More About Divi BlockFree Version ~ 340+ Free Blocks

Custom Theme Options In Child Theme

Discussion in 'Free Divi Community Forum' started by Resonance Designs, Sep 23, 2023.

  1. Resonance Designs

    Resonance Designs New Member

    Hello All,

    I upgraded Divi for the first time in a long while on a site from version 3.22.6 to version 4.22.2. I have a child theme for the site that adds some custom options to Divi > Theme Options > General. These no longer work after I upgraded. I assume I have to implement a new method for these custom options or they just aren't possible in later versions of Divi. Here is the code in my child theme's functions.php file:
    PHP:
    /**
    * Additional theme admin settings
    *
    */
    if ( ! function_exists'et_load_core_options' ) ) {
        function 
    et_load_core_options() {
            global 
    $shortname$themename;
            require_once 
    get_template_directory() . esc_attr"/options_{$shortname}.php" );
            
    $newOptions = [];
            foreach (
    $options as $i => $optionArray) {
                
    $newOptions[] = $optionArray;
                
    // Additional social icon settings
                
    if (isset($optionArray['id']) && $optionArray['id'] == 'divi_show_google_icon') {
                    
    // Spotify Icon
                    
    $showOptions = array(
                        
    "name" =>esc_html__"Show Spotify Icon"$themename ),
                        
    "id" => $shortname."_show_spotify_icon",
                        
    "type" => "checkbox2",
                        
    "std" => "on",
                        
    "desc" =>esc_html__"Here you can choose to display the Spotify Icon. "$themename ) );
                    
    $newOptions[] = $showOptions;
                    
    // Youtube icon
                    
    $showOptions2 = array(
                        
    "name" =>esc_html__"Show Youtube Icon"$themename ),
                        
    "id" => $shortname."_show_youtube_icon",
                        
    "type" => "checkbox2",
                        
    "std" => "on",
                        
    "desc" =>esc_html__"Here you can choose to display the Youtube Icon. "$themename ) );
                    
    $newOptions[] = $showOptions2;
                    
    // Soundcloud icon
                    
    $showOptions3 = array(
                        
    "name" =>esc_html__"Show Soundcloud Icon"$themename ),
                        
    "id" => $shortname."_show_soundcloud_icon",
                        
    "type" => "checkbox2",
                        
    "std" => "on",
                        
    "desc" =>esc_html__"Here you can choose to display the Soundcloud Icon. "$themename ) );
                    
    $newOptions[] = $showOptions3;
                    
    // Google Play icon
                    
    $showOptions4 = array(
                        
    "name" =>esc_html__"Show Google Play Icon"$themename ),
                        
    "id" => $shortname."_show_googleplay_icon",
                        
    "type" => "checkbox2",
                        
    "std" => "on",
                        
    "desc" =>esc_html__"Here you can choose to display the Google Play Icon. "$themename ) );
                    
    $newOptions[] = $showOptions4;
                    
    // iTunes icon
                    
    $showOptions5 = array(
                        
    "name" =>esc_html__"Show iTunes Icon"$themename ),
                        
    "id" => $shortname."_show_itunes_icon",
                        
    "type" => "checkbox2",
                        
    "std" => "on",
                        
    "desc" =>esc_html__"Here you can choose to display the iTunes Icon. "$themename ) );
                    
    $newOptions[] = $showOptions5;
                    
    // iTunes Podcast icon
                    
    $showOptions6 = array(
                        
    "name" =>esc_html__"Show iTunes Podcast Icon"$themename ),
                        
    "id" => $shortname."_show_itunes_podcast_icon",
                        
    "type" => "checkbox2",
                        
    "std" => "on",
                        
    "desc" =>esc_html__"Here you can choose to display the iTunes Podcast Icon. "$themename ) );
                    
    $newOptions[] = $showOptions6;
                    
    // Stitcher icon
                    
    $showOptions7 = array(
                        
    "name" =>esc_html__"Show Stitcher Icon"$themename ),
                        
    "id" => $shortname."_show_stitcher_icon",
                        
    "type" => "checkbox2",
                        
    "std" => "on",
                        
    "desc" =>esc_html__"Here you can choose to display the Stitcher Icon. "$themename ) );
                    
    $newOptions[] = $showOptions7;
                }
                
    // Additional social URL options
                
    if (isset($optionArray['id']) && $optionArray['id'] == 'divi_google_url') {
                    
    // Spotify URL
                    
    $urlOptions = array(
                        
    "name" =>esc_html__"Spotify Page Url"$themename ),
                        
    "id" => $shortname."_spotify_url",
                        
    "std" => "#",
                        
    "type" => "text",
                        
    "validation_type" => "url",
                        
    "desc" =>esc_html__"Enter the URL of your Spotify page. "$themename ) );
                    
    $newOptions[] = $urlOptions;
                    
    // Youtube URL
                    
    $urlOptions2 = array(
                        
    "name" =>esc_html__"Youtube Url"$themename ),
                        
    "id" => $shortname."_youtube_url",
                        
    "std" => "#",
                        
    "type" => "text",
                        
    "validation_type" => "url",
                        
    "desc" =>esc_html__"Enter the URL of your Youtube Channel. "$themename ) );
                    
    $newOptions[] = $urlOptions2;
                    
    // Soundcloud URL
                    
    $urlOptions3 = array(
                        
    "name" =>esc_html__"Soundcloud Url"$themename ),
                        
    "id" => $shortname."_soundcloud_url",
                        
    "std" => "#",
                        
    "type" => "text",
                        
    "validation_type" => "url",
                        
    "desc" =>esc_html__"Enter the URL of your Soundcloud page. "$themename ) );
                    
    $newOptions[] = $urlOptions3;
                    
    // Google Play URL
                    
    $urlOptions4 = array(
                        
    "name" =>esc_html__"Google Play Url"$themename ),
                        
    "id" => $shortname."_googleplay_url",
                        
    "std" => "#",
                        
    "type" => "text",
                        
    "validation_type" => "url",
                        
    "desc" =>esc_html__"Enter the URL of your Google Play profile. "$themename ) );
                    
    $newOptions[] = $urlOptions4;
                    
    // iTunes URL
                    
    $urlOptions5 = array(
                        
    "name" =>esc_html__"iTunes Url"$themename ),
                        
    "id" => $shortname."_itunes_url",
                        
    "std" => "#",
                        
    "type" => "text",
                        
    "validation_type" => "url",
                        
    "desc" =>esc_html__"Enter the URL of your iTunes page. "$themename ) );
                    
    $newOptions[] = $urlOptions5;
                    
    // iTunes Podcast URL
                    
    $urlOptions6 = array(
                        
    "name" =>esc_html__"iTunes Podcast Url"$themename ),
                        
    "id" => $shortname."_itunes_podcast_url",
                        
    "std" => "#",
                        
    "type" => "text",
                        
    "validation_type" => "url",
                        
    "desc" =>esc_html__"Enter the URL of your iTunes podcast page. "$themename ) );
                    
    $newOptions[] = $urlOptions6;
                    
    // Stitcher URL
                    
    $urlOptions7 = array(
                        
    "name" =>esc_html__"Stitcher Url"$themename ),
                        
    "id" => $shortname."_stitcher_url",
                        
    "std" => "#",
                        
    "type" => "text",
                        
    "validation_type" => "url",
                        
    "desc" =>esc_html__"Enter the URL of your Stitcher profile. "$themename ) );
                    
    $newOptions[] = $urlOptions7;
                }
            }
            
    $options $newOptions;
        }
    }
    Can anyone offer some insight?
     
    1. PRO MEMBER PERKS Divi Ultimate Footer Plugin - Custom global Divi footer (20 premade styles) + Revealing footer effect:Learn More
  2. Divi.Help

    Divi.Help Administrator
    Staff Member

    I believe this code should work: https://gist.github.com/MarieComet/d7852883e7a7cb8a0098c8d7091564e5
     
    Resonance Designs likes this.
  3. Resonance Designs

    Resonance Designs New Member

    1. PRO MEMBER PERKS Divi Block Pro - Premade before / after image slider for your Divi site without using any plugins:View Demo
  4. enzo5

    enzo5 New Member

    After upgrading to Divi 4.22.2, your custom theme options, including Spotify settings, may not work due to changes in Divi’s settings system. You may need to update your code to use Divi’s new API (ET_Theme_Options) or move your customizations to a plugin for easier maintenance.
     
  5. Divi Booster

    Divi Booster Divi Expert

    This line:

    Code:
    Log In or Sign Up to view this code.
    Waits until it sees the "Show Google Plus Icon" setting to add your additional options. But, as Google Plus is defunct, the setting has been removed from newer versions of Divi. This means your code never finds the Google Plus setting and as a result never adds your options. To fix it, update your code to look for a different option, e.g. the "Show RSS Icon", like so:

    Code:
    Log In or Sign Up to view this code.
     
    1. PRO MEMBER PERKS Divi Cart Count Plugin - Easily add cart count to your Divi cart icon. 6 different styles to choose from:Learn More