designerken

Social Icons with ACF

Apr 16th, 2021
802
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // =============================================================================
  2. // Add Custom Icons to Social Icons list (AFC DEPENDENT)
  3. // =============================================================================
  4. function new_x_social_global() {
  5.  
  6.   $output = '<div class="x-social-global">';
  7.  
  8.   // Check the AFC Options page for Social Links
  9.   if ( have_rows( 'additional__links', 'option' ) ) :
  10.     while ( have_rows( 'additional__links', 'option' ) ): the_row();
  11.  
  12.     // Get the vars
  13.     $name = get_sub_field( 'media_name' );
  14.     $slug = strtolower( preg_replace( '/[[:space:]]+/', '-', $name ) );
  15.     $glyph = get_sub_field( 'glyph' );
  16.     $link = get_sub_field( 'profile_url' );
  17.    
  18.     if ($link == ''){
  19.       $link = '#';
  20.     }
  21.  
  22.     $output .= '<a href="' . $link . '" class="' . $slug .'" title="' . $name .'" target="blank" rel="noopener noreferrer">';
  23.     $output .= '<i class="x-icon-'. $slug .'" data-x-icon-b="&#x'. $glyph .'" aria-hidden="true"></i></a>';
  24.  
  25.     endwhile;
  26.   endif;
  27.  
  28.   return $output;
  29. }
  30. add_filter( 'x_social_global_before', 'new_x_social_global' );
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×