Instantly share code, notes, and snippets.
-
Star
(6)
6
You must be signed in to star a gist -
Fork
(3)
3
You must be signed in to fork a gist
-
Save SJ-James/60eb8809b27596ffce5928488b4169f9 to your computer and use it in GitHub Desktop.
<?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 Flikr 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__( "Flikr 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_flikr_icon', 'on' ) ) : ?> | |
<li class="et-social-icon et-social-flikr"> | |
<a href="<?php echo esc_url( et_get_option( 'divi_flikr_url', '#' ) ); ?>" class="icon"> | |
<span><?php esc_html_e( 'Flikr', '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'); |
@lpisati2, thanks for point that out.
hi @oga23 to fix this error decclear $i as an array and add an if statement just before this line of code
foreach ($options as $i => $optionArray) {
and end this statement just after this line of code
$options = $newOptions;
so new updated code will be
$i=array();
if ($options){
code starting from foreach($options as $i => $optionArray) { line
TO
code ending at $options = $newOptions; }
}
Still getting this error:
Notice: Undefined variable: options in /home/content/p3pnexwpnas15_data02/20/41777420/html/wp-content/themes/divi-child/functions.php on line 18
Referring to:
if ($options){
Any suggestions?
Hello!
It looks like ET have added Instagram so if you don't remove $urlOptions5, it'll ask for the URL twice under Divi Theme Options.
Hi, there is an inconsistency: Divi names the icon "et-social-flikr" but the name of the social network is "flickr" with a C, so you should rename every occurrence of "flikr" in the code with "flickr" except the icon "et-social-flikr' otherwise the switch doesn't control the icon.