08a81048 by Jeff Balicki

member

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent bfd00564
......@@ -13,6 +13,7 @@ include 'inc/shortcodes-resources.php';
include 'inc/menu.php';
include 'inc/shortcodes-contest.php';
include 'inc/shortcodes-disqus.php';
include 'inc/shortcodes-members.php';
......
<?php
add_shortcode('members-list', 'members_list');
function members_list(){
try{
$atts['tax'] = 1;
$args['filters'] = 1;
$args['search_fields'][0] = "department_branch";
$show_filters = empty( $args['roles_can_filter'] ) || ( ! empty( $priority_user_role ) && in_array( $priority_user_role, $args['roles_can_filter'] ) );
$search_filters = array();
if ( isset( $args['search_fields'] ) ) {
$search_filters = apply_filters( 'um_frontend_member_search_filters', array_unique( array_filter( $args['search_fields'] ) ) );
}
if ( ! empty( $search_filters ) ) {
$search_filters = array_filter( $search_filters, function( $item ) {
return in_array( $item, array_keys( UM()->member_directory()->filter_fields ) );
});
$search_filters = array_values( $search_filters );
}
$custom_args = array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'paged' => 1,
'post_status' => 'any',
'order' => 'DESC',
'orderby' => 'rand',
);
$custom_query = new \WP_Query($custom_args);
ob_start();
$uniqid = uniqid();
if ($custom_query->have_posts()):
?>
<div class="course-list resources">
<label for="quicksearch">Search:</label><input type="text" id="quicksearch" placeholder="" />
<div class="filters">
<a href="#" id="filter-more">FILTERS <span aria-hidden="true" class="glyphicon glyphicon-chevron-up"></span></a>
<div class="filter-group">
<div class="category-filter-group ">
<div class="category">
<?php $i = 0;
foreach ( $search_filters as $filter ) {
error_log(print_r($filter, true));
$filter_content = UM()->member_directory()->show_filter( $filter, $args );
if ( empty( $filter_content ) ) {
continue;
}
$type = UM()->member_directory()->filter_types[ $filter ]; ?>
<div class="um-search-filter um-<?php echo esc_attr( $type ) ?>-filter-type <?php echo ( $i != 0 && $i%2 !== 0 ) ? 'um-search-filter-2' : '' ?>">
<?php echo $filter_content; ?>
</div>
<?php $i++;
} ?>
<?php $terms = get_terms( array( 'taxonomy' => 'mlo-category' ) );
foreach($terms as $term){ ?>
<div class="category-filter"> <input id="<?php echo $term->slug ; ?>" value="<?php echo $term->slug ; ?>" type="checkbox" class="sr-only"><label for="<?php echo $term->slug ; ?>"><?php echo $term->name ; ?></label></div>
<?php }; ?>
</div>
</div>
<div class="btn-group sort-button-group">
<button class="btn btn-light" data-sort-direction="asc" data-sort-value="0" type="button">Name <span aria-hidden="true" class="glyphicon glyphicon-chevron-up"></span></button>
<button class="btn btn-light" data-sort-direction="asc" data-sort-value="2" type="button">Date <span aria-hidden="true" class="glyphicon glyphicon-chevron-up"></span></button>
</div>
</div>
</div>
</div>
<table id="resources">
<thead><tr><th class="hidden"></th><th></th><th class="hidden"></th><th></th></tr></thead>
<tbody>
<?php while ($custom_query->have_posts()): $custom_query->the_post();
echo members(get_the_ID());
endwhile; ?>
</tbody>
</table>
</div>
<?php endif;
wp_reset_query();
$output = ob_get_clean();
return $output;
}catch(Throwable $e) {
error_log("resources_list()". $e->getMessage()) ;
}
}
function members($id, $tax){
ob_start();
$post = get_post($id);
$text = str_replace(']]>', ']]&gt;', apply_filters( 'the_content', strip_shortcodes($post->post_content)));
$excerpt_length = apply_filters( 'excerpt_length', 20 );
$text = wp_trim_words( $text, $excerpt_length, ' ...' );
$categories = get_the_terms( $id, 'mlo-category' );
$cat ="";
if(is_array( $categories)){
foreach( $categories as $category ) {
if($category->parent == $tax){
$cat .= " ".$category->slug;
}
};
} ?>
<tr class="table-like__item">
<td class="item"><div class="item-content"><a target="_blank" role="button" href="<?php echo wp_get_attachment_url($id); ?>"><?php echo $post->post_title; ?></a><div>
</td>
<td class="hidden"> <?php echo $cat; ?></td>
<td class="hidden"><?php echo get_post_time('U',false, $id ); ?></td>
<td>
<a target="_blank" role="button" href="<?php echo wp_get_attachment_url($id); ?>" class="button">View</a>
</td>
</tr>
<?php
$output = ob_get_clean();
return $output;
}
\ No newline at end of file