Advertisement
brettshumaker

user-view-show-staff.php

Mar 5th, 2013
988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.00 KB | None | 0 0
  1. <?php
  2.  
  3. function sslp_staff_member_listing_shortcode_func($atts) {
  4.     extract(shortcode_atts(array(
  5.       'single' => 'no',
  6.       'group' => '',
  7.       'wrap_class' => '',
  8.       'order' => 'ASC',
  9.       'image_thumbnail' => '',
  10.     ), $atts));
  11.    
  12.     // Get Template and CSS
  13.    
  14.     $custom_html                = stripslashes_deep(get_option('_staff_listing_custom_html'));
  15.     $custom_css                 = stripslashes_deep(get_option('_staff_listing_custom_css'));
  16.     $default_tags               = get_option('_staff_listing_default_tags');
  17.     $default_formatted_tags     = get_option('_staff_listing_default_formatted_tags');
  18.     $output                     = '';
  19.     $group                      = strtolower($group);
  20.     $order                      = strtoupper($order);
  21.     $staff = '';
  22.    
  23.     /**
  24.       * Set up our WP_Query
  25.       */
  26.    
  27.     $args = array( 'post_type' => 'staff-member', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'post_status' => 'publish' );
  28.    
  29.     // Check user's 'order' value
  30.     if ($order != 'ASC' && $order != 'DESC') {
  31.         $order = 'ASC';
  32.     }
  33.    
  34.     // Set 'order' in our query args
  35.     $args['order'] = $order;
  36.    
  37.     // Check user's 'group' value
  38.     $group_terms = get_sslp_terms('staff-member-group');
  39.     if (in_array($group, $group_terms)){
  40.         // if it's an actual term, set it in query args
  41.         $args['staff-member-group'] = $group;
  42.     }
  43.    
  44.     $staff = new WP_Query( $args );
  45.    
  46.    
  47.     /**
  48.       * Set up our loop_markup
  49.       */
  50.    
  51.     $loop_markup = $loop_markup_reset = str_replace("[staff_loop]", "", substr($custom_html, strpos($custom_html, "[staff_loop]"), strpos($custom_html, "[/staff_loop]") - strpos($custom_html, "[staff_loop]")));
  52.    
  53.    
  54.     // Doing this so I can concatenate class names for current and possibly future use.
  55.     $staff_member_classes = $wrap_class;
  56.    
  57.    
  58.     $i = 0;
  59.    
  60.     if( $staff->have_posts() ) {
  61.    
  62.         $output .= '<div class="staff-member-listing '.$group.'">';
  63.        
  64.     while( $staff->have_posts() ) : $staff->the_post();
  65.        
  66.         if ($i == ($staff->found_posts)-1) {
  67.             $staff_member_classes .= " last";
  68.         }
  69.        
  70.         if ($i % 2) {
  71.             $output .= '<div class="staff-member odd '.$staff_member_classes.'">';
  72.         } else {
  73.             $output .= '<div class="staff-member even '.$staff_member_classes.'">';
  74.         }
  75.        
  76.         global $post;
  77.        
  78.         $custom     = get_post_custom();
  79.         $name       = get_the_title();
  80.         $name_slug  = basename(get_permalink());
  81.         $title      = $custom["_staff_member_title"][0];
  82.         $email      = $custom["_staff_member_email"][0];
  83.         $phone      = $custom["_staff_member_phone"][0];
  84.         $bio        = $custom["_staff_member_bio"][0];
  85.         if ($image_thumbnail == 'yes') {
  86.             $image_size = 'thumbnail';
  87.         } else {
  88.             $image_size = 'full';
  89.         }
  90.        
  91.        
  92.         if(has_post_thumbnail()){
  93.            
  94.             $photo_url = wp_get_attachment_image_src( get_post_thumbnail_id(), $image_size );
  95.             $photo_url = $photo_url[0];
  96.             $photo = '<img class="staff-member-photo" src="'.$photo_url.'" alt = "'.$title.'">';
  97.         }else{
  98.             $photo_url = '';
  99.             $photo = '';
  100.         }
  101.        
  102.        
  103.         if (function_exists('wpautop')){
  104.             $bio_format = '<div class="staff-member-bio">'.wpautop($bio).'</div>';
  105.         }
  106.        
  107.        
  108.         $email_mailto = '<a class="staff-member-email" href="mailto:'.antispambot( $email ).'" title="Email '.$name.'">'.antispambot( $email ).'</a>';
  109.         $email_nolink = antispambot( $email );
  110.        
  111.         $accepted_single_tags = $default_tags;
  112.         $replace_single_values = array($name, $name_slug, $photo_url, $title, $email_nolink, $phone, $bio);
  113.    
  114.         $accepted_formatted_tags = $default_formatted_tags;
  115.         $replace_formatted_values = array('<h3 class="staff-member-name">'.$name.'</h3>', '<h4 class="staff-member-position">'.$title.'</h4>', $photo, $email_mailto, $bio_format);
  116.    
  117.         $loop_markup = str_replace($accepted_single_tags, $replace_single_values, $loop_markup);
  118.         $loop_markup = str_replace($accepted_formatted_tags, $replace_formatted_values, $loop_markup);
  119.    
  120.         $output .= $loop_markup;
  121.    
  122.         $loop_markup = $loop_markup_reset;
  123.        
  124.        
  125.        
  126.         $output .= '</div> <!-- Close staff-member -->';
  127.         $i += 1;
  128.    
  129.        
  130.     endwhile;
  131.    
  132.     $output .= "</div> <!-- Close staff-member-listing -->";
  133.     }
  134.     return $output;
  135. }
  136. add_shortcode('simple-staff-list', 'sslp_staff_member_listing_shortcode_func');
  137.  
  138. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement