resources_list
Signed-off-by: Jeff <jeff@gotenzing.com>
Showing
12 changed files
with
20 additions
and
32 deletions
This diff is collapsed.
Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
| ... | @@ -3,17 +3,24 @@ | ... | @@ -3,17 +3,24 @@ |
| 3 | add_shortcode('resources-list', 'resources_list'); | 3 | add_shortcode('resources-list', 'resources_list'); |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | function resources_list(){ | 6 | function resources_list($atts){ |
| 7 | 7 | $atts['tax']; | |
| 8 | try{ | 8 | try{ |
| 9 | 9 | ||
| 10 | $custom_args = array( | 10 | $custom_args = array( |
| 11 | 'post_type' => 'resource', | 11 | 'post_type' => 'attachment', |
| 12 | 'posts_per_page' => -1, | 12 | 'posts_per_page' => -1, |
| 13 | 'paged' => 1, | 13 | 'paged' => 1, |
| 14 | 'post_status' => 'any', | 14 | 'post_status' => 'any', |
| 15 | 'order' => 'DESC', | 15 | 'order' => 'DESC', |
| 16 | 'orderby' => 'rand', | 16 | 'orderby' => 'rand', |
| 17 | 'tax_query' => array( | ||
| 18 | array ( | ||
| 19 | 'taxonomy' => 'mlo-category', | ||
| 20 | 'field' => 'id', | ||
| 21 | 'terms' => $atts['tax'], | ||
| 22 | ) | ||
| 23 | ), | ||
| 17 | ); | 24 | ); |
| 18 | $custom_query = new \WP_Query($custom_args); | 25 | $custom_query = new \WP_Query($custom_args); |
| 19 | 26 | ||
| ... | @@ -33,11 +40,6 @@ function resources_list(){ | ... | @@ -33,11 +40,6 @@ function resources_list(){ |
| 33 | <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> | 40 | <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> |
| 34 | <?php }; ?> | 41 | <?php }; ?> |
| 35 | </div> | 42 | </div> |
| 36 | <div class="type"> | ||
| 37 | <?php $terms = get_terms( array( 'taxonomy' => 'resource_category' ,'parent' => 32) ); | ||
| 38 | foreach($terms as $term){ ?> | ||
| 39 | <div class="category-type"> <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> | ||
| 40 | <?php }; ?> | ||
| 41 | </div> | 43 | </div> |
| 42 | </div> | 44 | </div> |
| 43 | <div class="btn-group sort-button-group"> | 45 | <div class="btn-group sort-button-group"> |
| ... | @@ -47,7 +49,7 @@ function resources_list(){ | ... | @@ -47,7 +49,7 @@ function resources_list(){ |
| 47 | </div> | 49 | </div> |
| 48 | </div> | 50 | </div> |
| 49 | <table id="resources"> | 51 | <table id="resources"> |
| 50 | <thead><tr><th class="hidden"></th><th class="hidden"></th><th></th><th class="hidden"></th><th></th></tr></thead> | 52 | <thead><tr><th class="hidden"></th><th></th><th class="hidden"></th><th></th></tr></thead> |
| 51 | <tbody> | 53 | <tbody> |
| 52 | <?php while ($custom_query->have_posts()): $custom_query->the_post(); | 54 | <?php while ($custom_query->have_posts()): $custom_query->the_post(); |
| 53 | echo resources(get_the_ID()); | 55 | echo resources(get_the_ID()); |
| ... | @@ -120,31 +122,21 @@ function resources($id){ | ... | @@ -120,31 +122,21 @@ function resources($id){ |
| 120 | $text = wp_trim_words( $text, $excerpt_length, ' ...' ); | 122 | $text = wp_trim_words( $text, $excerpt_length, ' ...' ); |
| 121 | $categories = get_the_terms( $id, 'resource_category' ); | 123 | $categories = get_the_terms( $id, 'resource_category' ); |
| 122 | $cat =""; | 124 | $cat =""; |
| 123 | $type =""; | ||
| 124 | if(is_array( $categories)){ | 125 | if(is_array( $categories)){ |
| 125 | foreach( $categories as $category ) { | 126 | foreach( $categories as $category ) { |
| 126 | if($category->parent == 27){ | 127 | if($category->parent == 27){ |
| 127 | $cat .= " ".$category->slug; | 128 | $cat .= " ".$category->slug; |
| 128 | } | 129 | } |
| 129 | if($category->parent == 32){ | ||
| 130 | $type .= " ".$category->slug; | ||
| 131 | } | ||
| 132 | }; | 130 | }; |
| 133 | } ?> | 131 | } ?> |
| 134 | 132 | ||
| 135 | <tr class="table-like__item"> | 133 | <tr class="table-like__item"> |
| 136 | <td class="hidden"> <?php echo $type; ?></td> | 134 | <td class="item"><div class="item-content"><a role="button" href="<?php echo get_permalink($id); ?>"><?php echo $post->post_title; ?></a><div> |
| 137 | <td class="item <?php echo $type; ?>"><div class="item-content"><a role="button" href="<?php echo get_permalink($id); ?>"><?php echo $post->post_title; ?></a><br> | ||
| 138 | <?php echo $text; ?><div> | ||
| 139 | </td> | 135 | </td> |
| 140 | <td class="hidden"> <?php echo $cat; ?></td> | 136 | <td class="hidden"> <?php echo $cat; ?></td> |
| 141 | <td class="hidden"><?php echo get_post_time('U',false, $id ); ?></td> | 137 | <td class="hidden"><?php echo get_post_time('U',false, $id ); ?></td> |
| 142 | <td> | 138 | <td> |
| 143 | <?php if(!is_user_logged_in()){ ?> | 139 | |
| 144 | <button class="simplefavorite-button" data-bs-toggle="modal" data-bs-target="#login-window" style="">Favorite <i class="sf-icon-star-empty"></i></button> | ||
| 145 | <?php }else{ | ||
| 146 | echo do_shortcode('[favorite_button post_id="'.$id.'"]'); | ||
| 147 | } ?> | ||
| 148 | </td> | 140 | </td> |
| 149 | </tr> | 141 | </tr> |
| 150 | <?php | 142 | <?php | ... | ... |
| ... | @@ -20038,17 +20038,14 @@ | ... | @@ -20038,17 +20038,14 @@ |
| 20038 | if (!$('#resources').length) { | 20038 | if (!$('#resources').length) { |
| 20039 | return; | 20039 | return; |
| 20040 | } | 20040 | } |
| 20041 | var pageL = 10; | 20041 | var pageL = 8; |
| 20042 | if ($('#resources').hasClass('resources-fav')) { | ||
| 20043 | pageL = 4; | ||
| 20044 | } | ||
| 20045 | var myTable = $('#resources').DataTable({ | 20042 | var myTable = $('#resources').DataTable({ |
| 20046 | "pageLength": pageL, | 20043 | "pageLength": pageL, |
| 20047 | "searchable": false, | 20044 | "searchable": false, |
| 20048 | "paging": true, | 20045 | "paging": true, |
| 20049 | "info": false, | 20046 | "info": false, |
| 20050 | "order": [[2, 'desc']], | 20047 | "order": [[2, 'desc']], |
| 20051 | "dom": '<"top"<"clear">p<"clear">>rt<"bottom"<"clear">p<"clear">>' | 20048 | "dom": '<"top"<"clear"><"clear">>rt<"bottom"<"clear">p<"clear">>' |
| 20052 | }); | 20049 | }); |
| 20053 | 20050 | ||
| 20054 | // use value of search field to filter | 20051 | // use value of search field to filter | ... | ... |
This diff could not be displayed because it is too large.
| ... | @@ -118,5 +118,5 @@ let Ge=e;var Ze,tn,en,nn,rn=function(t,e){if(this instanceof rn)return Ge(t).Dat | ... | @@ -118,5 +118,5 @@ let Ge=e;var Ze,tn,en,nn,rn=function(t,e){if(this instanceof rn)return Ge(t).Dat |
| 118 | /*! DataTables Bootstrap 5 integration | 118 | /*! DataTables Bootstrap 5 integration |
| 119 | * 2020 SpryMedia Ltd - datatables.net/license | 119 | * 2020 SpryMedia Ltd - datatables.net/license |
| 120 | */ | 120 | */ |
| 121 | e.extend(!0,rn.defaults,{dom:"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>><'row dt-row'<'col-sm-12'tr>><'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",renderer:"bootstrap"}),e.extend(rn.ext.classes,{sWrapper:"dataTables_wrapper dt-bootstrap5",sFilterInput:"form-control form-control-sm",sLengthSelect:"form-select form-select-sm",sProcessing:"dataTables_processing card",sPageButton:"paginate_button page-item"}),rn.ext.renderer.pageButton.bootstrap=function(t,n,r,i,o,a){var s,l,c,u=new rn.Api(t),d=t.oClasses,f=t.oLanguage.oPaginate,h=t.oLanguage.oAria.paginate||{},p=function(n,i){var c,g,m,v,b=function(t){t.preventDefault(),e(t.currentTarget).hasClass("disabled")||u.page()==t.data.action||u.page(t.data.action).draw("page")};for(c=0,g=i.length;c<g;c++)if(v=i[c],Array.isArray(v))p(n,v);else{switch(s="",l="",v){case"ellipsis":s="…",l="disabled";break;case"first":s=f.sFirst,l=v+(o>0?"":" disabled");break;case"previous":s=f.sPrevious,l=v+(o>0?"":" disabled");break;case"next":s=f.sNext,l=v+(o<a-1?"":" disabled");break;case"last":s=f.sLast,l=v+(o<a-1?"":" disabled");break;default:s=v+1,l=o===v?"active":""}if(s){var _=-1!==l.indexOf("disabled");m=e("<li>",{class:d.sPageButton+" "+l,id:0===r&&"string"==typeof v?t.sTableId+"_"+v:null}).append(e("<a>",{href:_?null:"#","aria-controls":t.sTableId,"aria-disabled":_?"true":null,"aria-label":h[v],"aria-role":"link","aria-current":"active"===l?"page":null,"data-dt-idx":v,tabindex:t.iTabIndex,class:"page-link"}).html(s)).appendTo(n),t.oApi._fnBindAction(m,{action:v},b)}}},g=e(n);try{c=g.find(document.activeElement).data("dt-idx")}catch(t){}var m=g.children("ul.pagination");m.length?m.empty():m=g.html("<ul/>").children("ul").addClass("pagination"),p(m,i),void 0!==c&&g.find("[data-dt-idx="+c+"]").trigger("focus")},jQuery(document).ready((function(t){if(t("#resources").length){var e=10;t("#resources").hasClass("resources-fav")&&(e=4);var n,r=t("#resources").DataTable({pageLength:e,searchable:!1,paging:!0,info:!1,order:[[2,"desc"]],dom:'<"top"<"clear">p<"clear">>rt<"bottom"<"clear">p<"clear">>'}),i=t("#quicksearch").keyup((function(){console.log(i.val()),t("#resources").DataTable().column(1).search(i.val()).draw()})),o=t(".category-filter input");o.change((function(){var e=[];o.each((function(t,n){n.checked&&e.push(n.value)})),n=e.length?e.join("|"):"",console.log(n),t("#resources").DataTable().column(2).search(n,!0,!1).draw()}));var a,s=t(".category-type input");s.change((function(){var e=[];s.each((function(t,n){n.checked&&e.push(n.value)})),a=e.length?e.join("|"):"",t("#resources").DataTable().column(0).search(a,!0,!1).draw()})),t(".sort-button-group").on("click","button",(function(){var e=t(this).attr("data-sort-value"),n="asc"==t(this).attr("data-sort-direction"),i=n?"desc":"asc";console.log(e),console.log(n),t(this).attr("data-sort-direction",i),t(this).find(".glyphicon").toggleClass("glyphicon-chevron-up glyphicon-chevron-down"),r.order([e,i]).draw()})),t(document).on("click","#filter-more",(function(e){e.preventDefault(),t(".filter-group").toggleClass("open"),t(this).find(".glyphicon").toggleClass("glyphicon-chevron-up glyphicon-chevron-down")}))}}));var qi=document.querySelector(".blur-image");document.addEventListener("DOMContentLoaded",(function(){if(!qi)return!1;var t=qi.getAttribute("data-src"),e=document.querySelector(".full-image"),n=new Image;n.src=t,n.onload=function(){e.classList.add("image-loaded"),e.style.backgroundImage="url("+t+")"}})),t.Alert=C,t.Button=E,t.Carousel=N,t.Collapse=M,t.Dropdown=ye,t.Modal=Le,t.Offcanvas=ke,t.Popover=Be,t.Scrollspy=qe,t.Tab=ze,t.Toast=Ke,t.Tooltip=We})); | 121 | e.extend(!0,rn.defaults,{dom:"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>><'row dt-row'<'col-sm-12'tr>><'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",renderer:"bootstrap"}),e.extend(rn.ext.classes,{sWrapper:"dataTables_wrapper dt-bootstrap5",sFilterInput:"form-control form-control-sm",sLengthSelect:"form-select form-select-sm",sProcessing:"dataTables_processing card",sPageButton:"paginate_button page-item"}),rn.ext.renderer.pageButton.bootstrap=function(t,n,r,i,o,a){var s,l,c,u=new rn.Api(t),d=t.oClasses,f=t.oLanguage.oPaginate,h=t.oLanguage.oAria.paginate||{},p=function(n,i){var c,g,m,v,b=function(t){t.preventDefault(),e(t.currentTarget).hasClass("disabled")||u.page()==t.data.action||u.page(t.data.action).draw("page")};for(c=0,g=i.length;c<g;c++)if(v=i[c],Array.isArray(v))p(n,v);else{switch(s="",l="",v){case"ellipsis":s="…",l="disabled";break;case"first":s=f.sFirst,l=v+(o>0?"":" disabled");break;case"previous":s=f.sPrevious,l=v+(o>0?"":" disabled");break;case"next":s=f.sNext,l=v+(o<a-1?"":" disabled");break;case"last":s=f.sLast,l=v+(o<a-1?"":" disabled");break;default:s=v+1,l=o===v?"active":""}if(s){var _=-1!==l.indexOf("disabled");m=e("<li>",{class:d.sPageButton+" "+l,id:0===r&&"string"==typeof v?t.sTableId+"_"+v:null}).append(e("<a>",{href:_?null:"#","aria-controls":t.sTableId,"aria-disabled":_?"true":null,"aria-label":h[v],"aria-role":"link","aria-current":"active"===l?"page":null,"data-dt-idx":v,tabindex:t.iTabIndex,class:"page-link"}).html(s)).appendTo(n),t.oApi._fnBindAction(m,{action:v},b)}}},g=e(n);try{c=g.find(document.activeElement).data("dt-idx")}catch(t){}var m=g.children("ul.pagination");m.length?m.empty():m=g.html("<ul/>").children("ul").addClass("pagination"),p(m,i),void 0!==c&&g.find("[data-dt-idx="+c+"]").trigger("focus")},jQuery(document).ready((function(t){if(t("#resources").length){var e,n=t("#resources").DataTable({pageLength:8,searchable:!1,paging:!0,info:!1,order:[[2,"desc"]],dom:'<"top"<"clear"><"clear">>rt<"bottom"<"clear">p<"clear">>'}),r=t("#quicksearch").keyup((function(){console.log(r.val()),t("#resources").DataTable().column(1).search(r.val()).draw()})),i=t(".category-filter input");i.change((function(){var n=[];i.each((function(t,e){e.checked&&n.push(e.value)})),e=n.length?n.join("|"):"",console.log(e),t("#resources").DataTable().column(2).search(e,!0,!1).draw()}));var o,a=t(".category-type input");a.change((function(){var e=[];a.each((function(t,n){n.checked&&e.push(n.value)})),o=e.length?e.join("|"):"",t("#resources").DataTable().column(0).search(o,!0,!1).draw()})),t(".sort-button-group").on("click","button",(function(){var e=t(this).attr("data-sort-value"),r="asc"==t(this).attr("data-sort-direction"),i=r?"desc":"asc";console.log(e),console.log(r),t(this).attr("data-sort-direction",i),t(this).find(".glyphicon").toggleClass("glyphicon-chevron-up glyphicon-chevron-down"),n.order([e,i]).draw()})),t(document).on("click","#filter-more",(function(e){e.preventDefault(),t(".filter-group").toggleClass("open"),t(this).find(".glyphicon").toggleClass("glyphicon-chevron-up glyphicon-chevron-down")}))}}));var qi=document.querySelector(".blur-image");document.addEventListener("DOMContentLoaded",(function(){if(!qi)return!1;var t=qi.getAttribute("data-src"),e=document.querySelector(".full-image"),n=new Image;n.src=t,n.onload=function(){e.classList.add("image-loaded"),e.style.backgroundImage="url("+t+")"}})),t.Alert=C,t.Button=E,t.Carousel=N,t.Collapse=M,t.Dropdown=ye,t.Modal=Le,t.Offcanvas=ke,t.Popover=Be,t.Scrollspy=qe,t.Tab=ze,t.Toast=Ke,t.Tooltip=We})); |
| 122 | //# sourceMappingURL=child-theme.min.js.map | 122 | //# sourceMappingURL=child-theme.min.js.map |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff could not be displayed because it is too large.
| ... | @@ -4,17 +4,15 @@ jQuery(document).ready(function($) { | ... | @@ -4,17 +4,15 @@ jQuery(document).ready(function($) { |
| 4 | return; | 4 | return; |
| 5 | } | 5 | } |
| 6 | 6 | ||
| 7 | var pageL = 10; | 7 | var pageL = 8; |
| 8 | if($('#resources').hasClass('resources-fav')){ | 8 | |
| 9 | pageL = 4; | ||
| 10 | } | ||
| 11 | var myTable = $('#resources').DataTable({ | 9 | var myTable = $('#resources').DataTable({ |
| 12 | "pageLength": pageL, | 10 | "pageLength": pageL, |
| 13 | "searchable": false, | 11 | "searchable": false, |
| 14 | "paging": true, | 12 | "paging": true, |
| 15 | "info": false, | 13 | "info": false, |
| 16 | "order": [[2, 'desc']], | 14 | "order": [[2, 'desc']], |
| 17 | "dom": '<"top"<"clear">p<"clear">>rt<"bottom"<"clear">p<"clear">>' | 15 | "dom": '<"top"<"clear"><"clear">>rt<"bottom"<"clear">p<"clear">>' |
| 18 | 16 | ||
| 19 | }); | 17 | }); |
| 20 | 18 | ... | ... |
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment