Last active
November 18, 2021 01:07
-
-
Save scrawlon/62a87592c38bb2adbcc4 to your computer and use it in GitHub Desktop.
code from blog post: http://scrawlon.com/2015/09/21/add-more-social-media-options-to-wordpress-divi-theme/
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 | |
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; |
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
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' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How would you make Github option appear in the
Social Media Follow
module andPerson
module?