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.
*
<div id="grid-posts">
<form id="grid-posts-block" action="https://dev.itlvl.com/nashi-raboty/" method="get" style="">
<div id="tabs-bar" class="grid-posts__block">
<ul id="tabs-nav">
<li>
<input class="js-submit-form" id="service-id-all" type="radio" name="service-id" value="all" checked="checked">
<label class="btn-3" for="service-id-all"><span>Все</span></label>
</li>
<li>
<input class="js-submit-form" id="service-id-63" type="radio" name="service-id" value="63">
@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 / Floating labels.html
Created March 25, 2021 12:52
Bootstrap 5 floating labels
<div class="form-floating mb-3">
<input type="email" class="form-control" id="floatingInput" placeholder="name@example.com">
<label for="floatingInput">Email address</label>
</div>
<div class="form-floating">
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea2" style="height: 100px"></textarea>
<label for="floatingTextarea2">Comments</label>
</div>
@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 / Walker_nav_menu.php
Created January 8, 2021 18:41
Добавление к последнему по вложенности подменю дополнительного класса
<?php
class example_walker extends Walker_Nav_Menu {
// в этом свойстве сохраняем значение максимального вложения
public $last_sub_menu_depth = 0;
public function start_lvl( &$output, $depth = 0, $args = null ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
@AntonLitvin
AntonLitvin / JS snippets.js
Last active January 11, 2022 09:54
Разные полезные сниппеты
// lasy load
img.js-lazyload {
visibility: hidden;
}
img.js-lazyload.lazyloaded {
visibility: visible;
}
const options = {
@AntonLitvin
AntonLitvin / Wordpress snippets.php
Last active April 22, 2024 14:16
Разные полезные функции и фильтры
// Замена в чакауте лейб бна плейсхолдеры
function true_labels_as_placeholders( $checkout_fields ) {
// как вы помните, поля делятся на секции (Billing, Shipping и так далее)
// для каждой секции
foreach ( $checkout_fields as $section => $section_fields ) {
// для каждого поля внутри секции
foreach ( $section_fields as $section_field => $section_field_settings ) {
// да, вот так легко
$checkout_fields[ $section ][ $section_field ][ 'placeholder' ] = $checkout_fields[ $section ][ $section_field ][ 'label' ];
$checkout_fields[ $section ][ $section_field ][ 'label' ] = '';