Guest User

Untitled

a guest
Nov 18th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. /** The list of Social Media options for the site
  2. * This is used to build Theme options to insert each Social Media link and to output it in the theme
  3. * @return array
  4. */
  5. function ssa_social_media_options()
  6. {
  7. return array(
  8. 'facebook' => 'Facebook',
  9. 'twitter' => 'Twitter',
  10. 'instagram' => 'Instagram',
  11. 'google-plus' => 'Google Plus',
  12. 'linkedin' => 'LinkedIn',
  13. 'play' => 'Youtube',
  14. 'pinterest' => 'Pinterest'
  15. );
  16. }
  17.  
  18. /**
  19. * Generate an array of the active Social Media links
  20. * To be active it must have been given a link in the Theme Options
  21. * @return array
  22. */
  23. function ssa_social_media_active_icons()
  24. {
  25. $active_sites = array();
  26. $social_sites = ssa_social_media_options();
  27. foreach (array_keys($social_sites) as $social_site) {
  28. if ($link = get_theme_mod($social_site)) {
  29. $active_sites[$social_site] = $link;
  30. }
  31. }
  32. return $active_sites;
  33. }
  34.  
  35.  
  36. <?php
  37. /**
  38. * Theme Options
  39. * These are the theme options for adding the social links
  40. */
  41. function ssa_options($wp_customize)
  42. {
  43. $options = array(
  44. //Social Settings
  45. 'social_settings' => array(
  46. 'section' => array(
  47. 'title' => __('Social Media Links', 'ssa'),
  48. 'priority' => 103,
  49. ),
  50. 'settings' => array()
  51. )
  52. );
  53.  
  54. $social_sites = ssa_social_media_options();
  55. foreach ($social_sites as $key => $value) {
  56. $options['social_settings']['settings'][$key] = array(
  57. 'setting' => array(
  58. 'type' => 'theme_mod',
  59. 'capability' => 'edit_theme_options',
  60. 'sanitize_callback' => 'esc_url_raw'
  61. ),
  62. 'control' => array(
  63. 'label' => __($value, 'ssa')
  64. )
  65. );
  66. }
  67. ssa_customise_add_options($options, $wp_customize);
  68. }
  69. add_action('customize_register', 'ssa_options');
  70. ?>
  71.  
  72. /**
  73. HTML template structure with hook to get social links
  74. **/
  75. <div class="footer-block-social">
  76. <?php if ($active_sites = ssa_social_media_active_icons()) : ?>
  77. <?php foreach ($active_sites as $key => $value): ?>
  78. <div>
  79. <a href="<?php echo esc_url($value); ?>" target="_blank">
  80. <i class="<?php echo 'fa fa-' . $key; ?>" aria-hidden="true"></i>
  81. </a>
  82. </div>
  83. <?php endforeach; ?>
  84. <?php endif; ?>
  85. </div>
Add Comment
Please, Sign In to add comment