08a81048 by Jeff Balicki

member

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent bfd00564
...@@ -13,6 +13,7 @@ include 'inc/shortcodes-resources.php'; ...@@ -13,6 +13,7 @@ include 'inc/shortcodes-resources.php';
13 include 'inc/menu.php'; 13 include 'inc/menu.php';
14 include 'inc/shortcodes-contest.php'; 14 include 'inc/shortcodes-contest.php';
15 include 'inc/shortcodes-disqus.php'; 15 include 'inc/shortcodes-disqus.php';
16 include 'inc/shortcodes-members.php';
16 17
17 18
18 19
......
1 <?php
2
3 add_shortcode('members-list', 'members_list');
4
5
6
7
8 function members_list(){
9
10 try{
11 $atts['tax'] = 1;
12 $args['filters'] = 1;
13 $args['search_fields'][0] = "department_branch";
14 $show_filters = empty( $args['roles_can_filter'] ) || ( ! empty( $priority_user_role ) && in_array( $priority_user_role, $args['roles_can_filter'] ) );
15 $search_filters = array();
16 if ( isset( $args['search_fields'] ) ) {
17 $search_filters = apply_filters( 'um_frontend_member_search_filters', array_unique( array_filter( $args['search_fields'] ) ) );
18 }
19
20 if ( ! empty( $search_filters ) ) {
21 $search_filters = array_filter( $search_filters, function( $item ) {
22 return in_array( $item, array_keys( UM()->member_directory()->filter_fields ) );
23 });
24
25 $search_filters = array_values( $search_filters );
26 }
27
28 $custom_args = array(
29 'post_type' => 'attachment',
30 'posts_per_page' => -1,
31 'paged' => 1,
32 'post_status' => 'any',
33 'order' => 'DESC',
34 'orderby' => 'rand',
35
36 );
37 $custom_query = new \WP_Query($custom_args);
38
39 ob_start();
40 $uniqid = uniqid();
41 if ($custom_query->have_posts()):
42 ?>
43 <div class="course-list resources">
44 <label for="quicksearch">Search:</label><input type="text" id="quicksearch" placeholder="" />
45 <div class="filters">
46 <a href="#" id="filter-more">FILTERS <span aria-hidden="true" class="glyphicon glyphicon-chevron-up"></span></a>
47 <div class="filter-group">
48 <div class="category-filter-group ">
49 <div class="category">
50 <?php $i = 0;
51 foreach ( $search_filters as $filter ) {
52 error_log(print_r($filter, true));
53 $filter_content = UM()->member_directory()->show_filter( $filter, $args );
54 if ( empty( $filter_content ) ) {
55 continue;
56 }
57
58 $type = UM()->member_directory()->filter_types[ $filter ]; ?>
59
60 <div class="um-search-filter um-<?php echo esc_attr( $type ) ?>-filter-type <?php echo ( $i != 0 && $i%2 !== 0 ) ? 'um-search-filter-2' : '' ?>">
61 <?php echo $filter_content; ?>
62 </div>
63
64 <?php $i++;
65 } ?>
66 <?php $terms = get_terms( array( 'taxonomy' => 'mlo-category' ) );
67 foreach($terms as $term){ ?>
68 <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>
69 <?php }; ?>
70 </div>
71 </div>
72 <div class="btn-group sort-button-group">
73 <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>
74 <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>
75 </div>
76 </div>
77
78 </div>
79 </div>
80 <table id="resources">
81 <thead><tr><th class="hidden"></th><th></th><th class="hidden"></th><th></th></tr></thead>
82 <tbody>
83 <?php while ($custom_query->have_posts()): $custom_query->the_post();
84 echo members(get_the_ID());
85 endwhile; ?>
86 </tbody>
87 </table>
88 </div>
89 <?php endif;
90 wp_reset_query();
91 $output = ob_get_clean();
92 return $output;
93
94 }catch(Throwable $e) {
95 error_log("resources_list()". $e->getMessage()) ;
96 }
97
98 }
99
100
101
102
103 function members($id, $tax){
104
105 ob_start();
106 $post = get_post($id);
107 $text = str_replace(']]>', ']]&gt;', apply_filters( 'the_content', strip_shortcodes($post->post_content)));
108 $excerpt_length = apply_filters( 'excerpt_length', 20 );
109 $text = wp_trim_words( $text, $excerpt_length, ' ...' );
110 $categories = get_the_terms( $id, 'mlo-category' );
111 $cat ="";
112 if(is_array( $categories)){
113 foreach( $categories as $category ) {
114 if($category->parent == $tax){
115 $cat .= " ".$category->slug;
116 }
117 };
118 } ?>
119
120 <tr class="table-like__item">
121 <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>
122 </td>
123 <td class="hidden"> <?php echo $cat; ?></td>
124 <td class="hidden"><?php echo get_post_time('U',false, $id ); ?></td>
125 <td>
126 <a target="_blank" role="button" href="<?php echo wp_get_attachment_url($id); ?>" class="button">View</a>
127 </td>
128 </tr>
129 <?php
130 $output = ob_get_clean();
131 return $output;
132 }
...\ No newline at end of file ...\ No newline at end of file