Skip to content

Instantly share code, notes, and snippets.

View proweb's full-sized avatar

Sergey Mochalov proweb

View GitHub Profile
@justintadlock
justintadlock / pattern-query-grid-cover-stack.html
Created December 21, 2023 14:09
Query Loop pattern with stretched Stack block nested in Cover
View pattern-query-grid-cover-stack.html
<!-- wp:query {"queryId":0,"query":{"perPage":"7","pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"parents":[]},"align":"full","className":"pattern-post-grid-cover","layout":{"type":"constrained"}} -->
<div class="wp-block-query alignfull pattern-post-grid-cover"><!-- wp:group {"align":"full","style":{"spacing":{"padding":{"right":"var:preset|spacing|plus-3","left":"var:preset|spacing|plus-3","top":"var(\u002d\u002dtheme-spacing\u002d\u002dplus-3)","bottom":"var(\u002d\u002dtheme-spacing\u002d\u002dplus-3)"}}},"layout":{"type":"default"}} -->
<div class="wp-block-group alignfull" style="padding-top:var(--theme-spacing--plus-3);padding-right:var(--wp--preset--spacing--plus-3);padding-bottom:var(--theme-spacing--plus-3);padding-left:var(--wp--preset--spacing--plus-3)"><!-- wp:post-template {"align":"full","style":{"spacing":{"blockGap":"var:preset|spacing|minus-3"}},"className":"is-style-no-gap is-style-flex-grow is-style-fe
@bobmonsour
bobmonsour / getDescription.js
Created April 13, 2023 04:45
An Eleventy filter that extracts the meta description from within the <head> element of a web page
View getDescription.js
// getDescription - given a url, this Eleventy filter extracts the meta
// description from within the <head> element of a web page using the cheerio
// library.
//
// The full html content of the page is fetched using the eleventy-fetch plugin.
// If you have a lot of links from which you want to extract descriptions, the
// initial build time will be slow. However, the plugin will cache the content
// for a duration of your choosing (in this example, it's set to 1 day).
//
// The description is extracted from the <meta> element with the name attribute
@aguilar1181
aguilar1181 / wp-preload.php
Last active February 11, 2023 20:50
add to WordPress themes functions.php to preload assets without a plugin
View wp-preload.php
<?php
/**
* Preloading WordPress assets without a plugin.
* Change function name to something more unique.
* Priority is set to 0 to include as high in the <head> DOM as possible. Change priority if needed.
* Use WordPress is_page() to target specific page or is_front_page() to target ONLY homepage as in Option #1
* If asset needs to be preloaded globally use Option #2.
* For multiple assets clone the link tag instead of the entire echo block.
* Change 'as' attribute accordingly. Values for 'as' can be found here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as.
* Use abolute paths. For external assets paste the url, for internal assets use WordPress functions to construct URL.
View extraButton.js
import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Fragment } from 'react';
import { BlockControls } from '@wordpress/block-editor';
import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
import {
ToolbarButton,
ToolbarGroup,
} from '@wordpress/components';
@homu9
homu9 / gist:7d68b59aeb24c6f02455b776263041a2
Created April 13, 2022 19:54
Bulk update plugins for runcloud
View gist:7d68b59aeb24c6f02455b776263041a2
#!/bin/bash
# Change directory to /home
cd /home
# Iterate through all users directories
for user in * ; do
# For every webapp under the user directory
# Count wp-config files to make sure its Wordpess
@HardeepAsrani
HardeepAsrani / useSettings.js
Last active December 15, 2023 22:00
useSettings.js
View useSettings.js
/**
* WordPress dependencies.
*/
import api from '@wordpress/api';
import { __ } from '@wordpress/i18n';
import { dispatch } from '@wordpress/data';
import {
@HardeepAsrani
HardeepAsrani / useMeta.js
Last active December 15, 2023 22:00
useMeta.js
View useMeta.js
/**
* WordPress dependencies.
*/
import { useDispatch, useSelect } from '@wordpress/data';
/**
* useMeta Hook.
*
* useMeta hook to get/update WordPress' meta fields.
*
@ivandoric
ivandoric / wl-api.php
Last active September 3, 2023 00:16
WordPress Rest API Custom Endpoints Video Tutorials Notes - Check out the videos: https://www.youtube.com/watch?v=C2twS9ArdCI and https://www.youtube.com/watch?v=76sJL9fd12Y
View wl-api.php
<?php
/**
* Plugin Name: Custom API
* Plugin URI: http://chrushingit.com
* Description: Crushing it!
* Version: 1.0
* Author: Art Vandelay
* Author URI: http://watch-learn.com
*/
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active February 19, 2024 03:08
Minimal Analytics Snippet
View minimal-analytics-snippet.js
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@mihdan
mihdan / wp-image-placeholder.php
Last active December 12, 2022 23:59
Заменяет битые ссылки на кратинки в WordPress на заглушки. Удобно, например на тестовом сайте, чтобы не переносить фотки с боевого.
View wp-image-placeholder.php
<?php
/**
* Plugin Name: Mihdan: Image Placeholder
*/
namespace Mihdan\Image_Placeholder;
$images = array(
// Обычные
'https://placeimg.com/640/480/animals',