Instantly share code, notes, and snippets.
Forked from SJ-James/more-divi-social-icons.php
Last active
November 24, 2018 13:45
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save robhob/d859c42d7216988d10fb89d1e6167721 to your computer and use it in GitHub Desktop.
Divi social icons extension
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
<?php // << Remove opener if adding to functions.php | |
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') { | |
$showOptions = array( | |
"name" =>esc_html__( "Show Linked In Icon", $themename ), | |
"id" => $shortname."_show_linkedin_icon", | |
"type" => "checkbox2", | |
"std" => "on", | |
"desc" =>esc_html__( "Here you can choose to display the LINKED IN Icon. ", $themename ) ); | |
$newOptions[] = $showOptions; | |
$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; | |
$showOptions3 = array( | |
"name" =>esc_html__( "Show Pinterest Icon", $themename ), | |
"id" => $shortname."_show_pinterest_icon", | |
"type" => "checkbox2", | |
"std" => "on", | |
"desc" =>esc_html__( "Here you can choose to display the Pinterest Icon. ", $themename ) ); | |
$newOptions[] = $showOptions3; | |
$showOptions4 = array( | |
"name" =>esc_html__( "Show Tumblr Icon", $themename ), | |
"id" => $shortname."_show_tumblr_icon", | |
"type" => "checkbox2", | |
"std" => "on", | |
"desc" =>esc_html__( "Here you can choose to display the Tumblr Icon. ", $themename ) ); | |
$newOptions[] = $showOptions4; | |
$showOptions5 = array( | |
"name" =>esc_html__( "Show Instagram Icon", $themename ), | |
"id" => $shortname."_show_instagram_icon", | |
"type" => "checkbox2", | |
"std" => "on", | |
"desc" =>esc_html__( "Here you can choose to display the Instagram Icon. ", $themename ) ); | |
$newOptions[] = $showOptions5; | |
$showOptions6 = array( | |
"name" =>esc_html__( "Show Skype Icon", $themename ), | |
"id" => $shortname."_show_skype_icon", | |
"type" => "checkbox2", | |
"std" => "on", | |
"desc" =>esc_html__( "Here you can choose to display the Skype Icon. ", $themename ) ); | |
$newOptions[] = $showOptions6; | |
$showOptions7 = array( | |
"name" =>esc_html__( "Show Flickr Icon", $themename ), | |
"id" => $shortname."_show_flickr_icon", | |
"type" => "checkbox2", | |
"std" => "on", | |
"desc" =>esc_html__( "Here you can choose to display the Flickr Icon. ", $themename ) ); | |
$newOptions[] = $showOptions7; | |
$showOptions8 = array( | |
"name" =>esc_html__( "Show MySpace Icon", $themename ), | |
"id" => $shortname."_show_myspace_icon", | |
"type" => "checkbox2", | |
"std" => "on", | |
"desc" =>esc_html__( "Here you can choose to display the MySpace Icon... Tom will be pleased. ", $themename ) ); | |
$newOptions[] = $showOptions8; | |
$showOptions9 = array( | |
"name" =>esc_html__( "Show Dribbble Icon", $themename ), | |
"id" => $shortname."_show_dribbble_icon", | |
"type" => "checkbox2", | |
"std" => "on", | |
"desc" =>esc_html__( "Here you can choose to display the Dribbble Icon. ", $themename ) ); | |
$newOptions[] = $showOptions9; | |
$showOptions10 = array( | |
"name" =>esc_html__( "Show Vimeo Icon", $themename ), | |
"id" => $shortname."_show_vimeo_icon", | |
"type" => "checkbox2", | |
"std" => "on", | |
"desc" =>esc_html__( "Here you can choose to display the Vimeo Icon. ", $themename ) ); | |
$newOptions[] = $showOptions10; | |
} | |
if (isset($optionArray['id']) && $optionArray['id'] == 'divi_google_url') { | |
$urlOptions = array( "name" =>esc_html__( "Linked In Profile Url", $themename ), | |
"id" => $shortname."_linkedin_url", | |
"std" => "#", | |
"type" => "text", | |
"validation_type" => "url", | |
"desc" =>esc_html__( "Enter the URL of your LinkedIn Profile. ", $themename ) ); | |
$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 ) ); | |
$urlOptions3 = array( "name" =>esc_html__( "Pinterest Url", $themename ), | |
"id" => $shortname."_pinterest_url", | |
"std" => "#", | |
"type" => "text", | |
"validation_type" => "url", | |
"desc" =>esc_html__( "Enter the URL of your Pinterest Profile. ", $themename ) ); | |
$urlOptions4 = array( "name" =>esc_html__( "Tumblr Url", $themename ), | |
"id" => $shortname."_tumblr_url", | |
"std" => "#", | |
"type" => "text", | |
"validation_type" => "url", | |
"desc" =>esc_html__( "Enter the URL of your Tumblr Profile. ", $themename ) ); | |
$urlOptions5 = array( "name" =>esc_html__( "Instagram Url", $themename ), | |
"id" => $shortname."_instagram_url", | |
"std" => "#", | |
"type" => "text", | |
"validation_type" => "url", | |
"desc" =>esc_html__( "Enter the URL of your Instagram Profile. ", $themename ) ); | |
$urlOptions6 = array( "name" =>esc_html__( "Skype Url", $themename ), | |
"id" => $shortname."_skype_url", | |
"std" => "#", | |
"type" => "text", | |
"validation_type" => "url", | |
"desc" =>esc_html__( "Enter the URL of your Skype Profile. ", $themename ) ); | |
$urlOptions7 = array( "name" =>esc_html__( "Flickr Url", $themename ), | |
"id" => $shortname."_flickr_url", | |
"std" => "#", | |
"type" => "text", | |
"validation_type" => "url", | |
"desc" =>esc_html__( "Enter the URL of your Flickr Profile. ", $themename ) ); | |
$urlOptions8 = array( "name" =>esc_html__( "MySpace Url", $themename ), | |
"id" => $shortname."_myspace_url", | |
"std" => "#", | |
"type" => "text", | |
"validation_type" => "url", | |
"desc" =>esc_html__( "Enter the URL of your MySpace Profile. ", $themename ) ); | |
$urlOptions9 = array( "name" =>esc_html__( "Dribbble Url", $themename ), | |
"id" => $shortname."_dribbble_url", | |
"std" => "#", | |
"type" => "text", | |
"validation_type" => "url", | |
"desc" =>esc_html__( "Enter the URL of your Dribbble Profile. ", $themename ) ); | |
$urlOptions10 = array( "name" =>esc_html__( "Vimeo Url", $themename ), | |
"id" => $shortname."_vimeo_url", | |
"std" => "#", | |
"type" => "text", | |
"validation_type" => "url", | |
"desc" =>esc_html__( "Enter the URL of your Vimeo Profile. ", $themename ) ); | |
$newOptions[] = $urlOptions; | |
$newOptions[] = $urlOptions2; | |
$newOptions[] = $urlOptions3; | |
$newOptions[] = $urlOptions4; | |
$newOptions[] = $urlOptions5; | |
$newOptions[] = $urlOptions6; | |
$newOptions[] = $urlOptions7; | |
$newOptions[] = $urlOptions8; | |
$newOptions[] = $urlOptions9; | |
$newOptions[] = $urlOptions10; | |
} | |
} | |
$options = $newOptions; | |
} | |
} | |
if ( ! function_exists( 'replace_social_icons' ) ) { | |
function replace_social_icons() {?> | |
<ul id="new-icons"> | |
<?php if ( 'on' === et_get_option( 'divi_show_facebook_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-facebook"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_facebook_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Facebook', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_twitter_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-twitter"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_twitter_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Twitter', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_google_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-google-plus"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_google_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Google', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php 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 et-social-rss"> | |
<a href="<?php echo esc_url( $et_rss_url ); ?>" class="icon"> | |
<span><?php esc_html_e( 'RSS', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_linkedin_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-linkedin"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_linkedin_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Linked In', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_youtube_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-youtube"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_youtube_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Youtube', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_pinterest_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-pinterest"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_pinterest_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Pinterest', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_tumblr_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-tumblr"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_tumblr_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Tumblr', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_instagram_icon', '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; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_skype_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-skype"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_skype_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Skype', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_flickr_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-flickr"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_flickr_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Flickr', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_myspace_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-myspace"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_myspace_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'MySpace', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_dribbble_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-dribbble"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_dribbble_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Dribbble', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
<?php if ( 'on' === et_get_option( 'divi_show_vimeo_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-vimeo"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_vimeo_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Vimeo', 'Divi' ); ?></span> | |
</a> | |
</li> | |
<?php endif; ?> | |
</ul> | |
<!-- Push New List --> | |
<script> | |
jQuery(function($){ | |
// Above header - Added inside #main-header wrap | |
$('.et-social-icons').empty(); | |
$('#new-icons').contents().appendTo('.et-social-icons'); | |
}); | |
</script> | |
<?php | |
} | |
} | |
add_action('wp_footer', 'replace_social_icons'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment