Skip to content

Instantly share code, notes, and snippets.

@scrawlon
Last active November 18, 2021 01:07
Show Gist options
  • Save scrawlon/62a87592c38bb2adbcc4 to your computer and use it in GitHub Desktop.
Save scrawlon/62a87592c38bb2adbcc4 to your computer and use it in GitHub Desktop.
<?php
require_once( get_template_directory() . esc_attr( "/options_divi.php" ) );
global $options;
$epanel_key = "name";
$epanel_value = "Show RSS Icon";
$custom_options = array (
array( "name" => esc_html__( "Show GitHub Icon", $themename ),
"id" => $shortname."_show_github_icon",
"type" => "checkbox",
"std" => "on",
"desc" => esc_html__( "Here you can choose to display the GitHub Icon. ", $themename ) ),
array( "name" => esc_html__( "Show LinkedIn Icon", $themename ),
"id" => $shortname."_show_linkedin_icon",
"type" => "checkbox2",
"std" => "on",
"desc" => esc_html__( "Here you can choose to display the LinkedIn Icon on your homepage. ", $themename ) ),
array( "name" => esc_html__( "GitHub Profile Url", $themename ),
"id" => $shortname."_github_url",
"std" => "#",
"type" => "text",
"validation_type" => "url",
"desc" => esc_html__( "Enter the URL of your GitHub feed. ", $themename ) ),
array( "name" => esc_html__( "LinkedIn Profile Url", $themename ),
"id" => $shortname."_linkedin_url",
"std" => "#",
"type" => "text",
"validation_type" => "url",
"desc" => esc_html__( "Enter the URL of your LinkedIn Profile. ", $themename ) )
);
foreach( $options as $index => $value ) {
if ( isset($value[$epanel_key]) && $value[$epanel_key] === $epanel_value ) {
foreach( $custom_options as $custom_index => $custom_option ) {
$options = insertArrayIndex($options, $custom_option, $index+$custom_index+1);
}
break;
}
}
function insertArrayIndex($array, $new_element, $index) {
$start = array_slice($array, 0, $index);
$end = array_slice($array, $index);
$start[] = $new_element;
return array_merge($start, $end);
}
return $options;
function load_custom_core_options() {
if ( ! function_exists( 'et_load_core_options' ) ) {
function et_load_core_options() {
$options = require_once( get_stylesheet_directory() . esc_attr( "/epanel/custom_options_divi.php" ) );
}
}
}
add_action( 'after_setup_theme', 'load_custom_core_options' )
<ul class="et-social-icons">
<?php
$social_sites = array(
"facebook" => "fa-facebook",
"twitter" => "fa-twitter",
"github" => "fa-github",
"linkedin" => "fa-linkedin",
"google" => "fa-google-plus"
);
?>
<?php foreach( $social_sites as $social_site => $social_icon ): ?>
<?php if ( 'on' === et_get_option( 'divi_show_' . $social_site . '_icon', 'on' ) ) : ?>
<li class="et-social-icon">
<a href="<?php echo esc_url( et_get_option( 'divi_' . $social_site . '_url', '#' ) ); ?>" target="_blank" class="icon">
<i class="fa <?php echo $social_icon; ?>"></i>
</a>
</li>
<?php endif; ?>
<?php endforeach; ?>
<?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">
<a href="<?php echo esc_url( $et_rss_url ); ?>" target="_blank" class="icon">
<i class="fa fa-rss"></i>
</a>
</li>
<?php endif; ?>
</ul>
@broham89
Copy link

How would you make Github option appear in the Social Media Follow module and Person module?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment