Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save resonancedesigns/03d428220b7cfb542930116b649ef262 to your computer and use it in GitHub Desktop.
Save resonancedesigns/03d428220b7cfb542930116b649ef262 to your computer and use it in GitHub Desktop.
Divi child theme social icons extension
Updated 2/21/19 9:32PM
Updated 2/21/19 9:31PM
/**
* Additional theme settings
* Add this section to your functions file and modify as needed.
*
*/
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;
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;
/* Stitcher Icon */
$showOptions6 = 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[] = $showOptions6;
}
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;
/* Stitcher URL */
$urlOptions6 = 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[] = $urlOptions6;
}
}
$options = $newOptions;
}
}
<!-- Add this section to your includes -> social_icons.php file and modify as needed. -->
<ul class="et-social-icons">
<?php /* Facebook */ if ( 'on' === et_get_option( 'divi_show_facebook_icon', 'on' ) ) : ?>
<li class="et-social-icon rm-social-facebook">
<a href="<?php echo esc_url( et_get_option( 'divi_facebook_url', '#' ) ); ?>" class="icon">
<i class="fab fa-facebook-f"></i>
</a>
</li>
<?php endif; ?>
<?php /* Twitter */ if ( 'on' === et_get_option( 'divi_show_twitter_icon', 'on' ) ) : ?>
<li class="et-social-icon rm-social-twitter">
<a href="<?php echo esc_url( et_get_option( 'divi_twitter_url', '#' ) ); ?>" class="icon">
<i class="fab fa-twitter"></i>
</a>
</li>
<?php endif; ?>
<?php /* Google + */ if ( 'on' === et_get_option( 'divi_show_google_icon', 'on' ) ) : ?>
<li class="et-social-icon rm-social-google-plus">
<a href="<?php echo esc_url( et_get_option( 'divi_google_url', '#' ) ); ?>" class="icon">
<i class="fab fa-google-plus-g"></i>
</a>
</li>
<?php endif; ?>
<?php /* Spotify */ if ( 'on' === et_get_option( 'divi_show_spotify_icon', 'on' ) ) : ?>
<li class="et-social-icon rm-social-spotify">
<a href="<?php echo esc_url( et_get_option( 'divi_spotify_url', '#' ) ); ?>" class="icon">
<i class="fab fa-spotify"></i>
</a>
</li>
<?php endif; ?>
<?php /* Soundcloud */ if ( 'on' === et_get_option( 'divi_show_soundcloud_icon', 'on' ) ) : ?>
<li class="et-social-icon rm-social-soundcloud">
<a href="<?php echo esc_url( et_get_option( 'divi_soundcloud_url', '#' ) ); ?>" class="icon">
<i class="fab fa-soundcloud"></i>
</a>
</li>
<?php endif; ?>
<?php /* Google Play */ if ( 'on' === et_get_option( 'divi_show_googleplay_icon', 'on' ) ) : ?>
<li class="et-social-icon rm-social-googleplay">
<a href="<?php echo esc_url( et_get_option( 'divi_googleplay_url', '#' ) ); ?>" class="icon">
<i class="fab fa-google-play"></i>
</a>
</li>
<?php endif; ?>
<?php /* iTunes */ if ( 'on' === et_get_option( 'divi_show_itunes_icon', 'on' ) ) : ?>
<li class="et-social-icon rm-social-itunes">
<a href="<?php echo esc_url( et_get_option( 'divi_itunes_url', '#' ) ); ?>" class="icon">
<i class="fab fa-itunes"></i>
</a>
</li>
<?php endif; ?>
<?php /* Stitcher */ if ( 'on' === et_get_option( 'divi_show_stitcher_icon', 'on' ) ) : ?>
<li class="et-social-icon rm-social-stitcher">
<a href="<?php echo esc_url( et_get_option( 'divi_stitcher_url', '#' ) ); ?>" class="icon">
<svg id="rm-stitcher-icon" xml:space="preserve" viewBox="0 0 305 127.3" version="1.1">
<metadata id="metadata19">
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs id="defs17" />
<path class="rm-stitcher-icon" d="M 0,23 H 56 V 123.96 H 0 Z" />
<path class="rm-stitcher-icon" d="m 62.25,6 h 56 v 110.46 h -56 z" />
<path class="rm-stitcher-icon" d="m 124.5,16 h 56 v 111.3 h -56 z" />
<path class="rm-stitcher-icon" d="m 186.75,0 h 56 v 115.96 h -56 z" />
<path class="rm-stitcher-icon" d="m 249,19.84003 h 56 v 87.11 h -56 z" />
</svg>
</a>
</li>
<?php endif; ?>
<?php /* Youtube */ if ( 'on' === et_get_option( 'divi_show_youtube_icon', 'on' ) ) : ?>
<li class="et-social-icon rm-social-youtube">
<a href="<?php echo esc_url( et_get_option( 'divi_youtube_url', '#' ) ); ?>" class="icon">
<i class="fab fa-youtube"></i>
</a>
</li>
<?php endif; ?>
<?php /* RSS Feed */ if ( 'on' === et_get_option( 'divi_show_rss_icon', 'on' ) ) : ?>
<?php
$et_rss_url = '' !== et_get_option( 'divi_rss_url' )
? et_get_option( 'divi_rss_url' )
: get_bloginfo( 'rss2_url' );
?>
<li class="et-social-icon rm-social-rss">
<a href="<?php echo esc_url( $et_rss_url ); ?>" class="icon">
<i class="fas fa-rss"></i>
</a>
</li>
<?php endif; ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment