Skip to content

Instantly share code, notes, and snippets.

View Tusko's full-sized avatar

Tusko Trush Tusko

View GitHub Profile
@Tusko
Tusko / func.php
Created October 24, 2018 11:21
Set random dates for events ACF/WP
<?php
$allevents = wp_get_recent_posts(array(
'showposts' => '-1',
'post_type' => 'events'
));
$start = strtotime("10 October 2018");
//End point of our date range.
$end = strtotime("22 November 2020");
@Tusko
Tusko / dom-helper.js
Created October 16, 2018 18:14 — forked from LasMD/dom-helper.js
Mini jQuery, sort of.
/**
* A collection of helper prototype for everyday DOM traversal, manipulation,
* and event binding. Sort of a minimalist jQuery, mainly for demonstration
* purposes. MIT @ m3g4p0p
*/
window.$ = (function (undefined) {
/**
* Duration constants
* @type {Object}
@Tusko
Tusko / acf-cpt-custom.php
Created June 25, 2018 11:55
ACF CPT customize
<?php
function ex_project_archive_options($cptmenu) {
$cptmenu['page_title'] = 'Projects Archive';
$cptmenu['menu_title'] = 'Projects Archive';
$cptmenu['slug'] = 'my-projects-archive';
return $cptmenu;
}
add_filter('cpt_project_acf_page_args', 'ex_project_archive_options');
/*
@Tusko
Tusko / style_basic.css
Created June 7, 2018 13:26
Wordpress Taxonomy Tree
.is-current-cat {
color: red !important
}
.cat-parent > li > ul {
padding-left: 20px;
display: none
}
.cat-parent > li > .is-current-cat + ul {
display: block
}
@Tusko
Tusko / gallery.php
Created March 19, 2018 11:30
Horizontal swiper gallery like masonry
@Tusko
Tusko / selectric.woo.js
Created February 27, 2018 09:07
woocommerce + selectrict.js
$(document).ajaxComplete(function(){
$('.selectric-wrapper').each(function () {
var t = $(this),
s = $('select', t),
Selectric = s.data('selectric');
if($('input.input-text', t).length > 0) {
$('input.input-text', t).clone().appendTo('#billing_state_field');
t.remove();
}
if(typeof Selectric !== 'undefined') {
@Tusko
Tusko / closest.js
Created February 14, 2018 10:27
ClosestWord.js
var threshold = 3;
function distancer(s1, s2) {
// sift3: http://siderite.blogspot.com/2007/04/super-fast-and-accurate-string-distance.html
if (s1 == null || s1.length === 0) {
if (s2 == null || s2.length === 0) {
return 0;
} else {
return s2.length;
}
@Tusko
Tusko / init.js
Created January 23, 2018 18:08
Sync Swiper + Fancybox
$('.mod-fmslider').each(function(i){
var t = this;
setTimeout(function(){
window.FMSlider[i] = new Swiper( t, {
navigation: {
nextEl : $('.swiper-btn-prev', t)[0],
prevEl : $('.swiper-btn-next', t)[0]
},
slidesPerView : 'auto',
freeModeSticky : true,
@Tusko
Tusko / parse.php
Last active December 2, 2017 01:39
Parse CSV by line (acf repeater)
<?php
$file = file_get_contents('/wp-content/themes/themename/analyzers.csv');
$lines = explode(PHP_EOL, $file);
$array = array();
foreach ($lines as $line) {
$l = str_getcsv($line);
$array[] = array(
'brand' => $l[1],
'model' => $l[0],
);
@Tusko
Tusko / loadPosts.js
Last active December 2, 2017 01:40 — forked from moskalukigor/functions.php
Wordpress Ajax
//JS
var ajaxcontent = $('.products');
$.ajax({
type: 'POST',
url: window.wp_data.ajax_url,
data: {
action: "loadPosts",
},
success: function (html) {