This file contains hidden or 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 | |
/** | |
* Check if term exists | |
*/ | |
if (!is_array($terms)) : | |
$response = [ | |
'status' => 501, | |
'message' => 'Term doesn\'t exist', | |
'content' => 0 | |
]; |
This file contains hidden or 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_mt() { | |
if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'bobz' ) ) | |
die('Permission denied'); | |
/** | |
* Default response | |
*/ | |
$response = [ |
This file contains hidden or 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
$('.sc-ajax-filter-multi').on('click', 'a[data-filter], .pagination a', function(event) { | |
if(event.preventDefault) { event.preventDefault(); } | |
$this = $(this); | |
/** | |
* Set filter active | |
*/ | |
if ($this.data('filter')) { | |
$page = 1; |
This file contains hidden or 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 | |
/** | |
* AJAC filter posts by taxonomy term | |
*/ | |
function vb_filter_posts_mt() { | |
if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'bobz' ) ) | |
die('Permission denied'); | |
/** |
This file contains hidden or 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($) { | |
$doc = $(document); | |
$doc.ready( function() { | |
/** | |
* Retrieve posts | |
*/ | |
function get_posts($params) { |
This file contains hidden or 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 = [ |
This file contains hidden or 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 hidden or 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 get_posts($params) { | |
$container = $('#container-async'); | |
$content = $container.find('.content'); | |
$status = $container.find('.status'); | |
$status.text('Loading posts ...'); | |
$.ajax({ | |
url: bobz.ajax_url, |
This file contains hidden or 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 hidden or 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' ) | |
)); | |
} |