Skip to content

Instantly share code, notes, and snippets.

View Bobz-zg's full-sized avatar
👨‍💻
working remotely

Vlado Bosnjak Bobz-zg

👨‍💻
working remotely
View GitHub Profile
@Bobz-zg
Bobz-zg / ajax-get-posts.php
Last active September 29, 2016 09:24
Filter WordPress posts by custom taxonomy term with AJAX
<?php
function vb_filter_posts() {
if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'bobz' ) )
die('Permission denied');
/**
* Default response
*/
$response = [
@Bobz-zg
Bobz-zg / filter-posts-mt.js
Last active September 8, 2022 08:22
Filter WordPress posts by multiple custom taxonomy terms with AJAX
(function($) {
$doc = $(document);
$doc.ready( function() {
/**
* Retrieve posts
*/
function get_posts($params) {
@Bobz-zg
Bobz-zg / filter-posts-mt.php
Last active February 26, 2022 00:41
Filter WordPress posts by multiple custom taxonomy terms with AJAX Raw
<?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');
/**
@Bobz-zg
Bobz-zg / filter-post-mt.js
Last active November 28, 2020 08:35
Filter WordPress posts by multiple taxonomy terms with AJAX and pagination
$('.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;
@Bobz-zg
Bobz-zg / filter-posts-mt.php
Last active November 14, 2016 08:11
Filter WordPress posts by multiple taxonomy terms with AJAX and pagination
<?php
function vb_filter_posts_mt() {
if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'bobz' ) )
die('Permission denied');
/**
* Default response
*/
$response = [
@Bobz-zg
Bobz-zg / filter-posts-mt-terms.php
Last active October 12, 2016 14:16
Filter WordPress posts by multiple taxonomy terms with AJAX and pagination
<?php
/**
* Check if term exists
*/
if (!is_array($terms)) :
$response = [
'status' => 501,
'message' => 'Term doesn\'t exist',
'content' => 0
];
(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 *",
@Bobz-zg
Bobz-zg / toggler.jquery.js
Last active September 9, 2016 16:37
Simple jquery toggle function
$.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(); }
}
@Bobz-zg
Bobz-zg / toggler.css
Created September 9, 2016 16:00
Simple jquery toggle function Raw
.toggler {
overflow: hidden;
max-height: 0;
transition: max-height .3s ease-in;
}
.toggler.active {
max-height: 2000px;
transition: max-height .3s ease-out;
}
@Bobz-zg
Bobz-zg / toggle.html
Created September 9, 2016 16:28
Simple reusable toggle with jquery
<a href="#toggleMe" data-toggle="toggleMe">Toggle div</a>
<div id="toggleMe" class="toggler">
Content goes here ...
</div>