Skip to content

Instantly share code, notes, and snippets.

View vralle's full-sized avatar

Vitaliy Ralle vralle

View GitHub Profile
@vralle
vralle / gallery.php
Last active November 4, 2022 21:08
Custom Gallery Shortcode output
@vralle
vralle / amp-images-map.php
Last active February 10, 2019 19:40
A map of amp images output:
/**
* Single image
* @link https://ampbyexample.com/components/amp-img/
*/
$single_image = array(
'element' => 'amp-img',
'attributes' => array(),
);
/**
@vralle
vralle / method-1.php
Last active January 31, 2022 23:11
The SEO Framework - Exclude WooCommerce account pages from SEO and Sitemap
<?php
/**
* Stop each TSF meta output.
*/
add_filter( 'the_seo_framework_sitemap_hpt_query_args', 'vralle_no_sitemap' );
add_filter( 'the_seo_framework_articles_data', 'vralle_no_article_json' );
add_filter( 'the_seo_framework_robots_meta_array', 'vralle_no_search_robots_meta' );
add_filter( 'the_seo_framework_use_og_tags', 'vralle_no_meta' );
add_filter( 'the_seo_framework_use_facebook_tags', 'vralle_no_meta' );
add_filter( 'the_seo_framework_use_twitter_tags', 'vralle_no_meta' );
@vralle
vralle / index.js
Created January 7, 2022 22:25
Use post meta in gutenberg
// https://make.wordpress.org/core/2020/03/02/general-block-editor-api-updates/
// https://github.com/WordPress/gutenberg/tree/trunk/packages/core-data
import {
PanelRow, TextControl,
} from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { useEntityProp } from '@wordpress/core-data';
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import { registerPlugin } from '@wordpress/plugins';
@vralle
vralle / array_iteration_thoughts.md
Created June 4, 2022 22:35 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu

@vralle
vralle / dynamic-sizes.php
Last active June 29, 2022 15:04
Dynamic SVG sizes for safe-svg WP plugin
<?php
add_action('init', removeSafeSvgOnePixelFix');
function removeSafeSvgOnePixelFix()
{
global $wp_filter;
if (! class_exists('safe_svg')) {
return;
}
@vralle
vralle / Dockerfile
Last active November 13, 2022 09:03
Install xdebug 3 in Docker container
# https://matthewsetter.com/setup-step-debugging-php-xdebug3-docker/
# ENV XDEBUG_PORT 9000
# ENV XDEBUG_IDEKEY docker
RUN set eux; \
pecl install "xdebug"; \
docker-php-ext-enable xdebug; \
rm -r /tmp/pear; \
{ \
echo "xdebug.mode=debug"; \
@vralle
vralle / PurgeCssMinimizer.js
Last active April 29, 2024 20:49
Webpack plugin using PurgeCSS for each html file separately
/* eslint-disable class-methods-use-this */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-continue */
/**
* @typedef {import('webpack').WebpackPluginInstance} WebpackPluginInstance
* @typedef {import('webpack').Compiler} Compiler
* @typedef {import('webpack').Compilation} Compilation
* @typedef {import('webpack').Asset} Asset
* @typedef {Record<string, import('webpack').sources.Source>} CompilationAssets
* @typedef {Object} CssOutput