Skip to content

Instantly share code, notes, and snippets.

Avatar
🐒
Working

Sergey Mochalov proweb

🐒
Working
View GitHub Profile
@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
@ivandoric
ivandoric / wl-api.php
Last active January 11, 2023 21:53
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 March 6, 2023 04:04
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',
@leurdo
leurdo / gist:c81f10472cfdd403cf608068b0f054d7
Last active September 9, 2018 14:03
wiki post type and taxonomy registration, gives permalink structure http://site.ru/wiki/category/subcategory/post
View gist:c81f10472cfdd403cf608068b0f054d7
<?php
// don't load directly
if (!defined('ABSPATH')) die('-1');
class CreditznatokAddwiki
{
private static $_instance;
static function getInstance()
View regolith.sh
#!/bin/bash
# Regolith aka Un-Bedrock
# "But what if we need to hand it off to another agency?" No more!
# This script converts a Bedrock site to a normal WordPress structure.
# Run it from the root of a Bedrock project.
# Created by Nathan Knowler and Daniel Roe
echo "Converting Bedrock to a normal WordPress file structure..."
@bph
bph / psl-theme-test.txt
Last active April 12, 2022 15:40
Blocks for Themes Test
View psl-theme-test.txt
<!-- wp:paragraph -->
<p><a href="https://gist.github.com/bph/335ddef358bb41efdcd159cbc76f582e">https://gist.github.com/bph/335ddef358bb41efdcd159cbc76f582e</a></p>
<!-- /wp:paragraph -->
<!-- wp:heading {"className":"eplus-oOhLNH"} -->
<h2 class="eplus-oOhLNH">Common Blocks / Formatting / Layout Elements / Widgets and Embeds</h2>
<!-- /wp:heading -->
<!-- wp:list {"className":"eplus-eI3gin"} -->
<ul class="eplus-eI3gin"><li><a href="#images">Images</a> (Single image, cover image, gallery </li><li><a href="#quotes">Pull Quote / Quote</a></li><li><a href="#verse">Verse</a></li><li><a href="#buttons">Buttons</a></li><li><a href="#socialicons" data-type="internal" data-id="#socialicons">Social Icons</a></li><li><a href="#columns">Columns </a> Text (only) columns / Columns experimental</li><li><a href="#cover" data-type="internal" data-id="#cover">Cover</a> with CAT + button</li><li><a href="#paragraphs">Paragraph</a> </li><li><a href="#audio">Audio</a> </li><li><a href="#video">Video</a></li><li><a href="#w
@srikat
srikat / test.html
Created May 8, 2018 06:48
Dummy Content for Gutenberg
View test.html
<!-- wp:heading -->
<h2>Heading Block (H2)</h2>
<!-- /wp:heading -->
<!-- wp:heading -->
<h3>You are looking at one. (H3)</h3>
<!-- /wp:heading -->
<!-- wp:heading -->
<h2>Subhead Block</h2>