Advertisement
Guest User

Untitled

a guest
Oct 20th, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1.  
  2. function phalancs_group_meta_function($atts) {
  3.     $atts = shortcode_atts([
  4.         'type' => 'ul', //ul, ol, div
  5.         'class' => 'group-meta', //ul, ol list
  6.         'icon' => 'external-link',     
  7.         'meta_select' => '',
  8.         'fallback' => 'No elements selected.',
  9.         'post_id' => 0,    
  10.     ], $atts, 'phalancs_group_meta');
  11.  
  12.     if ($atts['meta_select'] != "") {
  13.         $meta_select = get_post_meta( get_the_ID(), $atts['meta_select'], true );
  14.         //print_r($meta_select);
  15.     }
  16.  
  17.     if ( is_array($meta_select) ) {
  18.         $html .= '<div class="vcex-module vcex-bullets custom-icon '.$atts['class'].'">';
  19.         $html .= '<'.$atts['type'].'>';
  20.         foreach ($meta_select as $key => $item) {
  21.            
  22.             if ($atts['type'] == 'ul' || $atts['type'] == 'ol') $html .= '<li>';
  23.             $html .= $item;
  24.             if ($atts['type'] == 'ul' || $atts['type'] == 'ol') $html .= '</li>';
  25.  
  26.         }
  27.         $html .= '</'.$atts['type'].'>';
  28.         $html .= '</div>';
  29.  
  30.     } else {
  31.         $html = $atts['fallback'];
  32.     }
  33.  
  34.     return $html;
  35.  
  36. }
  37. add_shortcode('phalancs_group_meta', 'phalancs_group_meta_function');
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement