Skip to content

Instantly share code, notes, and snippets.

View apisklov's full-sized avatar

Alexandr Pisklov apisklov

View GitHub Profile
@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 / scripts.js
Created March 2, 2018 15:17
js resize width
// Выполнение скрипта при изменении ширины
$('document').ready(function() {
// Начальное состояние
my_func();
$(window).resize(function() {
/**
* При изменении ширины окна
@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 ) ){
@apisklov
apisklov / Walker Menu
Last active December 14, 2017 08:37
Walker Menu Wordpress
class mainMenuWalker extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth=0, $args=array(), $id = 0) {
// назначаем атрибуты a-элементу
$attributes.= !empty( $item->url ) ? ' href="' .esc_attr($item->url). '"' : '';
// проверяем, на какой странице мы находимся
$current_url = (is_ssl()?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$item_url = esc_attr( $item->url );
if ( $item_url != $current_url ) {
$current = "";
$item_output.= '<a'. $attributes .'>'.$item->title.'</a>';