Advertisement
designerken

Social Icons with ACF

Apr 16th, 2021
1,257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  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' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement