예제 #1
0
 /**
  * Sanitize social networks setting.
  *
  * @param string $input
  * @return string
  */
 public static function sanitize_social_networks($input)
 {
     $clean = array();
     $available_links = edutheme_available_social_links();
     $networks = explode(' ', $input);
     foreach ($networks as $network) {
         if ('google+' == $network) {
             $key = 'google_plus';
         } else {
             $key = $network;
         }
         if (array_key_exists($key, $available_links)) {
             $clean[] = $network;
         }
     }
     return implode(' ', $clean);
 }
예제 #2
0
 /**
  * Get HTML of the social networks links.
  *
  * @return string
  */
 function edutheme_social_links()
 {
     $enabled_networks = explode(' ', get_theme_mod('toolbar_links', 'facebook google+ twitter linkedin youtube vimeo instagram'));
     if (empty($enabled_networks)) {
         return '';
     }
     $theme_settings = get_option('educator_settings');
     if (!is_array($theme_settings)) {
         $theme_settings = array();
     }
     $output = '<ul class="toolbar-social">';
     // Get available social links.
     $links = edutheme_available_social_links();
     foreach ($enabled_networks as $network) {
         if ('google+' == $network) {
             $network = 'google_plus';
         }
         if (isset($links[$network])) {
             $href = '';
             $nw_data = $links[$network];
             if (!empty($nw_data['href'])) {
                 $href = $nw_data['href'];
             } elseif (!empty($theme_settings[$network])) {
                 $href = $theme_settings[$network];
             } else {
                 continue;
             }
             $output .= '<li class="' . esc_attr(str_replace('_', '-', $network)) . '">' . '<a href="' . esc_url($href) . '" title="' . esc_attr($nw_data['title']) . '" target="_blank">' . $nw_data['html'] . '</a>' . '</li>';
         }
     }
     $output .= '</ul>';
     return $output;
 }