Created
April 19, 2019 12:28
-
-
Save hemnathmouli/ef62597371948a46c71ce161d58fc2e0 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Social Media Customizer | |
*/ | |
add_action( "customize_register", "sparq_social_media_customizer" ); | |
function sparq_social_media_customizer( $wp_customize ) { | |
// Declare Sidebar option | |
$wp_customize->add_section('sparq_social_media', array( | |
'title' => __('Social Media', 'sparq'), | |
'priority' => 120, | |
)); | |
$fields = array( | |
"sparq_meta_facebook" => "https://facebook.com", | |
"sparq_meta_insta" => "https://instagram.com", | |
"sparq_meta_twitter" => "https://twitter.com", | |
"sparq_meta_lkdin" => "https://linkedin.com", | |
"sparq_meta_vimeo" => "https://vimeo.com", | |
"sparq_meta_drble" => "https://dribbble.com", | |
); | |
$labels = array( | |
"sparq_meta_facebook" => "Facebook", | |
"sparq_meta_insta" => "Instagram", | |
"sparq_meta_twitter" => "Twitter", | |
"sparq_meta_lkdin" => "LinkedIn", | |
"sparq_meta_vimeo" => "Vimeo", | |
"sparq_meta_drble" => "Dribbble" | |
); | |
foreach ( $fields as $key => $field ) { | |
$wp_customize->add_setting("sparq_social_media_op[{$key}]", array( | |
'default' => $field, | |
'capability' => 'edit_theme_options', | |
'type' => 'option', | |
)); | |
$wp_customize->add_control('sparq_'.$key, array( | |
'label' => __($labels[$key], 'sparq'), | |
'section' => 'sparq_social_media', | |
'settings' => "sparq_social_media_op[{$key}]", | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get the options:
<?php $social_media = maybe_unserialize( get_option('sparq_social_media_op') ); ?>