Skip to content

Instantly share code, notes, and snippets.

@AntonLitvin
AntonLitvin / related-articles.liquid
Created May 31, 2023 11:04 — forked from atikju/related-articles.liquid
Show related articles based on article tags - Shopify
@AntonLitvin
AntonLitvin / acf-helper-functions.php
Created January 28, 2022 09:41 — forked from oion/acf-helper-functions.php
Advanced Custom Fields Helper Functions
<?php
/**
* Custom functions for the use of the Advanced Custom Fields plugin.
* These are helper functions that you can include in your theme
* which make it easier to your ACF. The purpose is to allow the
* inclusion of ACF fields while also checking to see if ACF is
* installed and activated. With these functions you may be able to
* deactivate ACF for debugging and your theme will not throw
* errors.
*
@AntonLitvin
AntonLitvin / Much much simpler option selector for Shopify
Created November 24, 2021 12:03 — forked from skillmatic-co/Much much simpler option selector for Shopify
Much simpler version of Shopify's option_selection.js for separating product options into their own dropdown menus.
<form action="/cart/add" method="post">
{% if product.variants.size > 1 %}
{% if product.options[0] %}
<label for="select-one">{{ product.options[0] }}</label>
<select id="select-one" onchange="letsDoThis()">
{% for value in product.options_with_values[0].values %}
<option value="{{ value }}" {% if product.options_with_values[0].selected_value == value %}selected{% endif %}>
{{ value }}
</option>
{% endfor %}
@AntonLitvin
AntonLitvin / add-wordpress-settings-page.php
Created August 19, 2021 16:11 — forked from DavidWells/add-wordpress-settings-page.php
WordPress :: Add Settings Page with All Fields
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
@AntonLitvin
AntonLitvin / Minify HTML
Created February 4, 2021 16:56 — forked from unfulvio/functions.php
WordPress HTML Minification Class to compress HTML (removal of whitespaces, line breaks, new lines, comments). Preserves script comments (if removed might break some javascripts like Google Analytics or Adsense) and IE specific tags.
/* Minifies HTML and removes comments (except IE tags and comments within script tags)
*
* To disable compression of code portions, use '<!--wp-html-compression no compression-->' tag
*
* @see http://forrst.com/posts/Wordpress_Minify_output_HTML-29q
* @see http://www.intert3chmedia.net/2011/12/minify-html-javascript-css-without.html
*/
class WP_HTML_Compression
{
// Settings
@AntonLitvin
AntonLitvin / viewport.js
Last active October 18, 2020 13:31 — forked from delphinpro/viewport.js
Conditional meta viewport
/*
* Paste into the end <head>
*/
(function(){
var width = screen.width;
var oldViewport = document.querySelector('meta[name="viewport"]');
var viewport = document.createElement('meta');
viewport.setAttribute('name', 'viewport');
viewport.setAttribute('content', 'width=' + (width <= 640 ? '640' : 'device-width'));
document.head.replaceChild(viewport, oldViewport);
@AntonLitvin
AntonLitvin / woocommerce-give-subcat-list-items-their-own-ul.php
Created June 1, 2020 16:52 — forked from twoelevenjay/woocommerce-give-subcat-list-items-their-own-ul.php
Move WooCommerce subcategory list items into their own <ul> separate from the product <ul>.
<?php
/**
* Move WooCommerce subcategory list items into
* their own <ul> separate from the product <ul>.
*/
add_action( 'init', 'move_subcat_lis' );
function move_subcat_lis() {
// Remove the subcat <li>s from the old location.
@AntonLitvin
AntonLitvin / functions.php
Created February 9, 2019 07:54 — forked from vishalbasnet23/functions.php
Simple Ajax Pagination WP
<?php
add_action('wp_ajax_infinite_scroll_home', 'infinite_scroll_home', 0);
add_action('wp_ajax_nopriv_infinite_scroll_home', 'infinite_scroll_home');
function infinite_scroll_home() {
$exclude_posts_json = $_POST['exclude_posts'];
$exclude_posts = json_decode($exclude_posts_json);
$post_offset = $_POST['post_offset'];
$infinite_scroll_args = array( 'post_type'=>'post', 'posts_per_page'=> 2,'post__not_in' => $exclude_posts, 'offset' => $post_offset);
$infinite_scroll_query = new WP_Query( $infinite_scroll_args );
while( $infinite_scroll_query->have_posts() ) : $infinite_scroll_query->the_post();
@AntonLitvin
AntonLitvin / form.html
Created February 9, 2019 07:53 — forked from vishalbasnet23/form.html
Custom jQuery validation for form without submit function.
<form id="form-id">
<div class="span6 form-table">
<label for="usr">First Name <b>*</b></label>
<input name="first_name" type="text" class="form-control" id="usr" data-required="yes">
<div class="cus-validation-error" style="display:none;">
Please Enter Your First Name.
</div>
</div>
<div class="span6 form-table">
<label for="">E-mail address<b>*</b></label>
@AntonLitvin
AntonLitvin / functions.php
Created February 8, 2019 20:29 — forked from vishalbasnet23/functions.php
Append async to wp_enqueue_script
<?php
function advanced_asyc_scripts($url) {
if ( strpos( $url, '#asyncload') === false ) {
return $url;
} else if ( is_admin() ) {
return str_replace( '#asyncload', '', $url );
} else {
return str_replace( '#asyncload', '', $url )."' async='async' defer='defer";
}
}