Skip to content

Instantly share code, notes, and snippets.

View apisklov's full-sized avatar

Alexandr Pisklov apisklov

View GitHub Profile
@apisklov
apisklov / gulpfile.js
Created April 27, 2018 11:32 — forked from iiiBird/gulpfile.js
gulp + open server
var gulp = require('gulp');
var browserSync = require('browser-sync');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var htmlreplace = require('gulp-html-replace');
var clean = require('gulp-clean');
var imagemin = require('gulp-imagemin');
var cache = require('gulp-cache');
@apisklov
apisklov / woo_rename_checkout.php
Created March 28, 2018 08:27 — forked from cryptexvinci/woo_rename_checkout.php
Rename WooCommerce checkout field label & placeholder
// WooCommerce Rename Checkout Fields
add_filter( 'woocommerce_checkout_fields' , 'custom_rename_wc_checkout_fields' );
// Change placeholder and label text
function custom_rename_wc_checkout_fields( $fields ) {
$fields['billing']['billing_first_name']['placeholder'] = 'Wonka';
$fields['billing']['billing_first_name']['label'] = 'Your Awesome First Name';
return $fields;
}
jQuery(document).ready(function($){
var woocommerce_form = $( '.woocommerce-cart form' );
woocommerce_form.on('change', '.qty', function(){
form = $(this).closest('form');
// emulates button Update cart click
$("<input type='hidden' name='update_cart' id='update_cart' value='1'>").appendTo(form);
// get the form data before disable button...
formData = form.serialize();
@apisklov
apisklov / better-webfont-loading-with-localstorage-and-woff2.js
Created January 24, 2018 09:22 — forked from meritt/better-webfont-loading-with-localstorage-and-woff2.js
Улучшение загрузки веб-шрифтов с использованием localStorage и поддержкой формата WOFF2
// Этот скрипт должен быть размещён в <head> над всеми внешними объявлениями стилей (link[rel=stylesheet])
function loadFont(fontName, woffUrl, woff2Url) {
// 0. Многие неподдерживаемые браузеры должны останавливать работу тут.
var nua = navigator.userAgent;
var noSupport = !window.addEventListener // IE8 и ниже
|| (nua.match(/(Android (2|3|4.0|4.1|4.2|4.3))|(Opera (Mini|Mobi))/) && !nua.match(/Chrome/)) // Android Stock Browser до 4.4 и Opera Mini
if (noSupport) {
return;
}
@apisklov
apisklov / random_repeater.php
Created January 18, 2018 16:36 — forked from mattradford/random_repeater.php
Super-easy get random ACF repeater row :)
<div class="testimonials__content">
<?php
$repeater = get_field( 'testimonial','options' );
$rand = rand(0, (count($repeater) - 1));
echo $repeater[$rand]['quote'];
echo $repeater[$rand]['citation'];
?>
</div>
@apisklov
apisklov / random-repeater.php
Created January 18, 2018 16:35 — forked from wesrice/random-repeater.php
Return a random row of data from an ACF repeater field
<?php
// Get the repeater field
$repeater = get_field( 'repeater_field_name' );
// Get a random rows. Change the second parameter in array_rand() to how many rows you want.
$random_rows = array_rand( $repeater, 2 );
// Loop through the random rows if more than one is returned
if( is_array( $random_rows ) ){