Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion include/cpto-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,21 @@ function SortPage()
<h2><?php echo $this->current_post_type->labels->singular_name . ' - '. __('Re-Order', 'post-types-order') ?></h2>

<?php cpt_info_box(); ?>

<div class="group-buttom">
<div class="label">Order</div>
<button id="sort-button-asc" type="button">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-sort-alpha-up" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M10.082 5.629 9.664 7H8.598l1.789-5.332h1.234L13.402 7h-1.12l-.419-1.371h-1.781zm1.57-.785L11 2.687h-.047l-.652 2.157h1.351z"/>
<path d="M12.96 14H9.028v-.691l2.579-3.72v-.054H9.098v-.867h3.785v.691l-2.567 3.72v.054h2.645V14zm-8.46-.5a.5.5 0 0 1-1 0V3.707L2.354 4.854a.5.5 0 1 1-.708-.708l2-1.999.007-.007a.498.498 0 0 1 .7.006l2 2a.5.5 0 1 1-.707.708L4.5 3.707V13.5z"/>
</svg>
</button>
<button id="sort-button-desc" type="button">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-sort-alpha-down" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M10.082 5.629 9.664 7H8.598l1.789-5.332h1.234L13.402 7h-1.12l-.419-1.371h-1.781zm1.57-.785L11 2.687h-.047l-.652 2.157h1.351z"/>
<path d="M12.96 14H9.028v-.691l2.579-3.72v-.054H9.098v-.867h3.785v.691l-2.567 3.72v.054h2.645V14zM4.5 2.5a.5.5 0 0 0-1 0v9.793l-1.146-1.147a.5.5 0 0 0-.708.708l2 1.999.007.007a.497.497 0 0 0 .7-.006l2-2a.5.5 0 0 0-.707-.708L4.5 12.293V2.5z"/>
</svg>
</button>
</div>
<div id="ajax-response"></div>

<noscript>
Expand Down Expand Up @@ -174,6 +188,20 @@ function SortPage()
jQuery("#ajax-response div").delay(3000).hide("slow");
});
});

jQuery("#sort-button-asc").on("click", function() {
jQuery("#sortable li").sort(asc_sort).appendTo('#sortable');
function asc_sort(a, b){
return (jQuery(b).text()) < (jQuery(a).text()) ? 1 : -1;
}
});

jQuery("#sort-button-desc").on("click", function() {
jQuery("#sortable li").sort(desc_sort).appendTo('#sortable');
function desc_sort(a, b){
return (jQuery(b).text()) > (jQuery(a).text()) ? 1 : -1;
}
});
});
</script>

Expand Down