Skip to content

Instantly share code, notes, and snippets.

@PaulGwamanda
Created February 17, 2017 08:14
Show Gist options
  • Save PaulGwamanda/e1e9def817071070b46e4daedc6e5081 to your computer and use it in GitHub Desktop.
Save PaulGwamanda/e1e9def817071070b46e4daedc6e5081 to your computer and use it in GitHub Desktop.
Wordpress - build Theme options to insert each Social Media link and to output it in the theme
/**
* The list of Social Media options for the site
*
* This is used to build Theme options to insert each Social Media link and to output it in the theme
*
* @return array
*/
function cf_social_media_options()
{
return array(
'twitter' => 'Twitter',
'facebook' => 'Facebook',
'google-plus' => 'Google Plus',
'linkedin' => 'LinkedIn',
'youtube' => 'Youtube',
'pinterest' => 'Pinterest',
'instagram' => 'Instagram'
);
}
/**
* Generate an array of the active Social Media links
*
* To be active it must have been given a link in the Theme Options
*
* @return array
*/
function cf_social_media_active_icons()
{
$active_sites = array();
$social_sites = pcs_social_media_options();
foreach (array_keys($social_sites) as $social_site) {
if ($link = get_theme_mod($social_site)) {
$active_sites[$social_site] = $link;
}
}
return $active_sites;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment