Skip to content

Instantly share code, notes, and snippets.

@phirebase
Forked from scrawlon/custom_options_divi.php
Created December 7, 2016 13:16
Show Gist options
  • Save phirebase/9d2bd1b4b346b87cf36ee875494d671a to your computer and use it in GitHub Desktop.
Save phirebase/9d2bd1b4b346b87cf36ee875494d671a 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment