Last active
July 25, 2018 08:06
-
-
Save MarieComet/d7852883e7a7cb8a0098c8d7091564e5 to your computer and use it in GitHub Desktop.
Add divi general settings theme options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* add this code in functions.php child theme | |
*/ | |
if ( is_admin() ) { | |
add_filter( 'et_epanel_layout_data', 'mc_et_epanel_layout_data' ); | |
} | |
/** | |
* Hooked into the et_epanel_layout_data filter | |
* Add additional social media options to the Divi Theme Options panel | |
* | |
* @param $options | |
* | |
* @return array | |
*/ | |
function mc_et_epanel_layout_data( $options ) { | |
// original Divi theme options | |
$original_options = $options; | |
// our custom options | |
$new_options = array(); | |
// loop on original options | |
foreach ( $original_options as $option ) { | |
// build new options array | |
$new_options[] = $option; | |
if ( ! isset( $option['id'] ) ) { | |
continue; | |
} | |
if ( 'divi_show_rss_icon' === $option['id'] ) { | |
$new_options[] = array( | |
'name' => esc_html__( 'Afficher l\'icône Instagram', 'divi' ), | |
'id' => 'show_divi_instagram', | |
'type' => 'checkbox2', | |
'desc' => esc_html__( 'Afficher l\'icône Instagram', 'divi' ), | |
); | |
} | |
// select our option position (below existing option, here logo) | |
if ( 'divi_rss_url' === $option['id'] ) { | |
$new_options[] = array( | |
'name' => esc_html__( 'URL Instagram', 'divi' ), | |
'id' => 'divi_instagram_url', | |
'type' => 'text', | |
'desc' => esc_html__( 'URL du compte Instagram', 'divi' ), | |
); | |
} | |
} | |
$options = $new_options; | |
return $options; | |
} | |
/** | |
* add this code in includes/social_icons.php child theme | |
*/ | |
// ... Divi originals icons | |
<?php if ( 'on' === et_get_option( 'show_divi_instagram', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-instagram"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_instagram_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Instagram', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment