This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
$('.tax-filter').click( function(event) { | |
// Prevent default action - opening tag page | |
if (event.preventDefault) { | |
event.preventDefault(); | |
} else { | |
event.returnValue = false; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Enqueue JS file | |
* Be sure to update path to js | |
* | |
* @link https://gist.github.com/Bobz-zg/16578c3c173abfe2b22daffd67f6f1e0 | |
* | |
*/ | |
function ajax_filter_posts_scripts() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function assets() { | |
wp_enqueue_script('tuts/js', 'scripts/tuts.js', ['jquery'], null, true); | |
wp_localize_script( 'tuts/js', 'bobz', array( | |
'nonce' => wp_create_nonce( 'bobz' ), | |
'ajax_url' => admin_url( 'admin-ajax.php' ) | |
)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#container-async').on('click', 'a[data-filter], .pagination a', function(event) { | |
if(event.preventDefault) { event.preventDefault(); } | |
$this = $(this); | |
if ($this.data('filter')) { | |
/** | |
* Click on tag cloud | |
*/ | |
$this.closest('ul').find('.active').removeClass('active'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function vb_ajax_pager( $query = null, $paged = 1 ) { | |
if (!$query) | |
return; | |
$paginate = paginate_links([ | |
'base' => '%_%', | |
'type' => 'array', | |
'total' => $query->max_num_pages, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
function triggerError($err, $status) { | |
$msg = false; | |
$errors = { | |
'e100' : "Something went wrong, please try again later", | |
'e101' : "Please enter you'r username and password", | |
'e102' : "Please enter you'r email", | |
'e103' : "Please populate all fields marked with *", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.toggler { | |
overflow: hidden; | |
max-height: 0; | |
transition: max-height .3s ease-in; | |
} | |
.toggler.active { | |
max-height: 2000px; | |
transition: max-height .3s ease-out; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="#toggleMe" data-toggle="toggleMe">Toggle div</a> | |
<div id="toggleMe" class="toggler"> | |
Content goes here ... | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.toggler = function() { | |
return this.each( function() { | |
$(this).click(function(event) { | |
// Prevent click event on a tag | |
if ($(this).is('a')) { | |
if(event.preventDefault) { event.preventDefault(); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function vb_filter_posts() { | |
if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'bobz' ) ) | |
die('Permission denied'); | |
/** | |
* Default response | |
*/ | |
$response = [ |