Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** 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 ssa_social_media_options()
- {
- return array(
- 'facebook' => 'Facebook',
- 'twitter' => 'Twitter',
- 'instagram' => 'Instagram',
- 'google-plus' => 'Google Plus',
- 'linkedin' => 'LinkedIn',
- 'play' => 'Youtube',
- 'pinterest' => 'Pinterest'
- );
- }
- /**
- * 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 ssa_social_media_active_icons()
- {
- $active_sites = array();
- $social_sites = ssa_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;
- }
- <?php
- /**
- * Theme Options
- * These are the theme options for adding the social links
- */
- function ssa_options($wp_customize)
- {
- $options = array(
- //Social Settings
- 'social_settings' => array(
- 'section' => array(
- 'title' => __('Social Media Links', 'ssa'),
- 'priority' => 103,
- ),
- 'settings' => array()
- )
- );
- $social_sites = ssa_social_media_options();
- foreach ($social_sites as $key => $value) {
- $options['social_settings']['settings'][$key] = array(
- 'setting' => array(
- 'type' => 'theme_mod',
- 'capability' => 'edit_theme_options',
- 'sanitize_callback' => 'esc_url_raw'
- ),
- 'control' => array(
- 'label' => __($value, 'ssa')
- )
- );
- }
- ssa_customise_add_options($options, $wp_customize);
- }
- add_action('customize_register', 'ssa_options');
- ?>
- /**
- HTML template structure with hook to get social links
- **/
- <div class="footer-block-social">
- <?php if ($active_sites = ssa_social_media_active_icons()) : ?>
- <?php foreach ($active_sites as $key => $value): ?>
- <div>
- <a href="<?php echo esc_url($value); ?>" target="_blank">
- <i class="<?php echo 'fa fa-' . $key; ?>" aria-hidden="true"></i>
- </a>
- </div>
- <?php endforeach; ?>
- <?php endif; ?>
- </div>
Add Comment
Please, Sign In to add comment