Advertisement
Beee

members-list.php

May 21st, 2015
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.68 KB | None | 0 0
  1. <?php
  2. // template to override member-list output
  3.  
  4. if(!defined('WPINC')) // MUST have WordPress.
  5.     exit("Do not access this file directly.");
  6.  
  7. /** @var $attr array */
  8. /** @var $s_var string */
  9. /** @var $p_var string */
  10. /** @var $member_list_query array */
  11. /** @var $query WP_User_Query */
  12. /** @var $pagination array */
  13. $query      = $member_list_query["query"];
  14. $pagination = $member_list_query["pagination"];
  15.  
  16. if(!empty($_REQUEST[$s_var]))
  17.     $s_val = trim(stripslashes($_REQUEST[$s_var]));
  18. else $s_val = ""; // No query yet.
  19. ?>
  20. <div class="ws-plugin--s2member-list-wrapper">
  21.     <div class="ws-plugin--s2member-list-container">
  22.         <div class="ws-plugin--s2member-list">
  23.  
  24.             <?php if($query->get_total()): ?>
  25.                
  26.                 <table class="member-list">
  27.                     <thead>
  28.                         <tr>
  29.                             <th class="">Name</td>
  30.                             <th class="">IDF #</td>
  31.                             <th class="">Nationality</td>
  32.                             <th class="">Category</td>
  33.                         </tr>
  34.                     </thead>
  35.                     <tbody>
  36.                     <?php foreach($query->get_results() as $_user): ?>
  37.                         <?php if(($_fields = preg_split('/[,]+/', $attr["show_fields"], NULL, PREG_SPLIT_NO_EMPTY))): ?>
  38.                             <tr>
  39.                             <?php foreach($_fields as $_field): ?>
  40.                                 <?php
  41.                                 if(strpos($_field, ":") !== FALSE)
  42.                                     list($_field_label, $_field) = explode(":", $_field, 2);
  43.                                 else $_field_label = ucwords(preg_replace('/[^a-z0-9]+/i', " ", $_field));
  44.  
  45.                                 if(!($_field_label = trim($_field_label)))
  46.                                     continue; // Empty.
  47.  
  48.                                 if(!($_field = trim($_field)))
  49.                                     continue; // Empty.
  50.  
  51.                                 $_field_value = get_user_field($_field, $_user->ID);
  52.                                 if($_field_value && is_array($_field_value))
  53.                                     $_field_value = implode(", ", $_field_value);
  54.                                 else $_field_value = (string)$_field_value;
  55.  
  56.                                 $_field_label = esc_html($_field_label);
  57.                                 $_field_value = wp_rel_nofollow(make_clickable(esc_html($_field_value)));
  58.                                 if(is_numeric($_field_value) && strlen($_field_value) === 10) // Convert timestamps to a date string.
  59.                                     $_field_value = date_i18n(get_option("date_format")." ".get_option("time_format"), (integer)$_field_value, TRUE);
  60.  
  61.                                 $_field_label = apply_filters("ws_plugin__s2member_pro_sc_member_list_field_label", $_field_label, get_defined_vars());
  62.                                 $_field_value = apply_filters("ws_plugin__s2member_pro_sc_member_list_field_value", $_field_value, get_defined_vars());
  63.                                 ?>
  64.                                 <?php if($_field_label && $_field_value): ?>
  65.                                     <td>
  66.                                         <span title="<?php echo esc_attr(strip_tags($_field_value)); ?>"><?php if ( $_field_value ) { echo $_field_value; } else { echo '&nbsp;'; } ?></span>
  67.                                     </td>
  68.                                 <?php endif; ?>
  69.                             <?php endforeach; ?>
  70.                             </tr>
  71.                         <?php endif; ?>
  72.                     <?php endforeach; ?>
  73.                     </tbody>
  74.                 </table>
  75.  
  76.                 <?php if(count($pagination) > 1): ?>
  77.                     <ul class="ws-plugin--s2member-list-pagination">
  78.                         <li><?php echo _x("Page:", "s2member-front", "s2member"); ?></li>
  79.                         <?php foreach($pagination as $_page): ?>
  80.                             <li><?php echo $_page["link"]; ?></li>
  81.                         <?php endforeach; ?>
  82.                     </ul>
  83.                 <?php endif; ?>
  84.  
  85.             <?php elseif($attr["enable_list_search"] && $s_val): ?>
  86.                 <p><?php echo _x('Sorry, your search returned 0 results.', "s2member-front", "s2member"); ?></p>
  87.  
  88.             <?php elseif(!$attr["enable_list_search"] && $s_val): ?>
  89.                 <p><?php echo _x('Sorry, search is not allowed here. The shortcode attribute `enable_list_search` is not enabled by the site owner.', "s2member-front", "s2member"); ?></p>
  90.  
  91.             <?php else: /* Generic message in this case. */ ?>
  92.                 <p><?php echo _x('Sorry, there are no users to list at this time.', "s2member-front", "s2member"); ?></p>
  93.             <?php endif; ?>
  94.  
  95.         </div>
  96.     </div>
  97. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement