d5ecde18 by Jeff Balicki

resources

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent fc938ea7
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.
......@@ -9,6 +9,7 @@
defined( 'ABSPATH' ) || exit;
include 'inc/shortcodes.php';
include 'inc/blocks.php';
include 'inc/shortcodes-resources.php';
/**
......
<?php
add_shortcode('resources-list', 'resources_list');
function resources_list(){
try{
$custom_args = array(
'post_type' => 'resource',
'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 programs:</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 $terms = get_terms( array( 'taxonomy' => 'resource_category' ,'parent' => 27) );
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 class="type">
<?php $terms = get_terms( array( 'taxonomy' => 'resource_category' ,'parent' => 32) );
foreach($terms as $term){ ?>
<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>
<?php }; ?>
</div>
</div>
<div class="btn-group sort-button-group">
<button class="btn btn-light" data-sort-direction="asc" data-sort-value="1" 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="3" type="button">Date <span aria-hidden="true" class="glyphicon glyphicon-chevron-up"></span></button>
</div>
</div>
</div>
<table id="resources">
<thead><tr><th class="hidden"></th><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 resources(get_the_ID());
endwhile; ?>
</tbody>
</table>
</div>
<div class="modal fade" id="login-window" tabindex="-1" aria-labelledby="login-window" aria-hidden="true" style="display: none;">
<div class="modal-dialog modal-dialog-centered ">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn-close align-self-sm-end" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body d-flex justify-content-center flex-column">
<h2 class="modal-title align-self-center">You must be logged in to add resources to your dashboard</h2>
<a title="LOG IN" href="my-account/" class="login-btn">Login now</a>
<p class="align-self-center">Don’t have a login? <a title="Sign up" href="my-account/" class="">Sign up</a> for an account.<p>
</div>
</div>
</div>
</div>
<?php endif;
wp_reset_query();
$output = ob_get_clean();
return $output;
}catch(Throwable $e) {
error_log("resources_list()". $e->getMessage()) ;
}
}
add_shortcode('resources-fav', 'resources_fav');
function resources_fav(){
$favorites = get_user_favorites(get_current_user_id());
ob_start();
$uniqid = uniqid();
if (is_array( $favorites)): ?>
<div class="course-list resources">
<table id="resources" class="resources-fav">
<thead><tr><th class="hidden"></th><th class="hidden"></th><th></th><th class="hidden"></th><th></th></tr></thead>
<tbody>
<?php foreach($favorites as $fav){
echo resources($fav);
}; ?>
</tbody>
</table>
</div>
<?php endif;
wp_reset_query();
$output = ob_get_clean();
return $output;
}
function resources($id){
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, 'resource_category' );
$cat ="";
$type ="";
if(is_array( $categories)){
foreach( $categories as $category ) {
if($category->parent == 27){
$cat .= " ".$category->slug;
}
if($category->parent == 32){
$type .= " ".$category->slug;
}
};
} ?>
<tr class="table-like__item">
<td class="hidden"> <?php echo $type; ?></td>
<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>
<?php echo $text; ?><div>
</td>
<td class="hidden"> <?php echo $cat; ?></td>
<td class="hidden"><?php echo get_post_time('U',false, $id ); ?></td>
<td>
<?php if(!is_user_logged_in()){ ?>
<button class="simplefavorite-button" data-bs-toggle="modal" data-bs-target="#login-window" style="">Favorite <i class="sf-icon-star-empty"></i></button>
<?php }else{
echo do_shortcode('[favorite_button post_id="'.$id.'"]');
} ?>
</td>
</tr>
<?php
$output = ob_get_clean();
return $output;
}
\ No newline at end of file
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.
This diff could not be displayed because it is too large.
......@@ -1819,6 +1819,23 @@
}
}
},
"datatables.net": {
"version": "1.13.2",
"resolved": "https://registry.npmjs.org/datatables.net/-/datatables.net-1.13.2.tgz",
"integrity": "sha512-u5nOU+C9SBp1SyPmd6G+niozZtrBwo1E8xzdOk3JJaAkFYgX/KxF3Gd79R8YLbUfmIs2OLnLe5gaz/qs5U8UDA==",
"requires": {
"jquery": ">=1.7"
}
},
"datatables.net-bs5": {
"version": "1.13.2",
"resolved": "https://registry.npmjs.org/datatables.net-bs5/-/datatables.net-bs5-1.13.2.tgz",
"integrity": "sha512-p1JOXFi+VD4wS0AxRmJPHBylJ8AC4xGJ3j0TZ+8hMspuZ+QvAhEqEPt8OEAGVzlN1ElfQimZjBeAoES/9nsuig==",
"requires": {
"datatables.net": ">=1.12.1",
"jquery": ">=1.7"
}
},
"debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
......@@ -2630,6 +2647,11 @@
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"dev": true
},
"jquery": {
"version": "3.6.3",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.3.tgz",
"integrity": "sha512-bZ5Sy3YzKo9Fyc8wH2iIQK4JImJ6R0GWI9kL1/k7Z91ZBNgkRXE6U0JfHIizZbort8ZunhSI3jw9I6253ahKfg=="
},
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
......
......@@ -41,7 +41,10 @@
"url": "https://github.com/understrap/understrap-child/issues"
},
"homepage": "https://understrap.com",
"dependencies": {},
"dependencies": {
"datatables.net-bs5": "^1.13.2",
"jquery": "^3.6.3"
},
"devDependencies": {
"@babel/core": "^7.19.6",
"@babel/preset-env": "^7.19.4",
......
jQuery(document).ready(function($) {
if (!$('#resources').length) {
return;
}
var pageL = 10;
if($('#resources').hasClass('resources-fav')){
pageL = 4;
}
var myTable = $('#resources').DataTable({
"pageLength": pageL,
"searchable": false,
"paging": true,
"info": false,
"order": [[2, 'desc']],
"dom": '<"top"<"clear">p<"clear">>rt<"bottom"<"clear">p<"clear">>'
});
// use value of search field to filter
var $quicksearch = $('#quicksearch').keyup(function() {
console.log($quicksearch.val());
$('#resources').DataTable().column(1).search($quicksearch.val()).draw();
});
// filter with selects and checkboxes
var $checkboxes = $('.category-filter input');
var filterValue;
$checkboxes.change(function() {
// map input values to an array
var inclusives = [];
// inclusive filters from checkboxes
$checkboxes.each(function(i, elem) {
// if checkbox, use value if checked
if (elem.checked) {
inclusives.push(elem.value);
}
});
// combine inclusive filters
filterValue = inclusives.length ? inclusives.join('|') : '';
console.log(filterValue);
$('#resources').DataTable().column(2).search(filterValue,true,false).draw();
});
// filter with selects and checkboxes
var $typecheckboxes = $('.category-type input');
var typeFilterValue;
$typecheckboxes.change(function() {
// map input values to an array
var inclusives = [];
// inclusive filters from checkboxes
$typecheckboxes.each(function(i, elem) {
// if checkbox, use value if checked
if (elem.checked) {
inclusives.push(elem.value);
}
});
// combine inclusive filters
typeFilterValue = inclusives.length ? inclusives.join('|') : '';
$('#resources').DataTable().column(0).search(typeFilterValue,true,false).draw();
});
$('.sort-button-group').on('click', 'button', function() {
var sortValue = $(this).attr('data-sort-value');
var direction = $(this).attr('data-sort-direction');
var isAscending = (direction == 'asc');
var newDirection = (isAscending) ? 'desc' : 'asc';
console.log(sortValue);
console.log(isAscending);
$(this).attr('data-sort-direction', newDirection);
var span = $(this).find('.glyphicon');
span.toggleClass('glyphicon-chevron-up glyphicon-chevron-down');
myTable.order([sortValue, newDirection]).draw();
});
$(document).on("click", "#filter-more", function(e) {
e.preventDefault();
$('.filter-group').toggleClass('open');
var span = $(this).find('.glyphicon');
span.toggleClass('glyphicon-chevron-up glyphicon-chevron-down');
});
});
\ No newline at end of file
// Add your custom JS here.
import jQuery from 'jquery';
import DataTable from 'datatables.net-bs5';
import "./_resources_list";
var a = document.querySelector('.blur-image');
......
......@@ -15,6 +15,7 @@
@import "theme/login";
@import "theme/body";
@import "theme/link_block";
@import "theme/resources_list";
// @import "assets/understrap/theme/colors"; // <-------- This creates the necessary bootstrap color classes.
// @import "assets/understrap/theme/blocks"; // <-------- This adds Bootstrap styles to blocks.
// @import "assets/understrap/theme/contact-form7"; // <-------- Contact Form 7 - Bootstrap 4 support
......
......@@ -7,7 +7,7 @@
}
}
#content,
#page-wrapper {
position: relative;
display: inline-block;
......@@ -25,9 +25,13 @@
.wrapper .container{
padding:0 160px 40px 50px;
@media only screen and (max-width: 1260px) {
padding:0;
padding:0 15px;
}
}
.um-um_account_id {
margin-top: 50px;
width: 80%!important;
}
h2{
......
......@@ -87,7 +87,7 @@
}
}
}
.um{
.um:not(.um-um_account_id){
width: 275px !important;
display: flex!important;
flex-basis: auto;
......