Skip to content

Instantly share code, notes, and snippets.

View proweb's full-sized avatar

Sergey Mochalov proweb

View GitHub Profile
@HardeepAsrani
HardeepAsrani / useMeta.js
Last active December 15, 2023 22:00
useMeta.js
/**
* WordPress dependencies.
*/
import { useDispatch, useSelect } from '@wordpress/data';
/**
* useMeta Hook.
*
* useMeta hook to get/update WordPress' meta fields.
*
@bph
bph / psl-theme-test.txt
Last active October 19, 2023 15:21
Blocks for Themes Test
<!-- 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
@tomazzaman
tomazzaman / README.md
Last active September 17, 2023 20:59
Gulp workflow for WordPress theme development

Gulp workflow for WordPress theme development

Requirements

In order for Livereload to work, you need a Firefox or Chrome extension as Gulp doesn't inset it automatically. Alternatively, you can also manually put the livereload script in footer.php, just make sure to insert it only on development environment:

<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
@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
<?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
*/
@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
// 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
<?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.
@mihdan
mihdan / wp-image-placeholder.php
Last active December 12, 2022 23:59
Заменяет битые ссылки на кратинки в WordPress на заглушки. Удобно, например на тестовом сайте, чтобы не переносить фотки с боевого.
<?php
/**
* Plugin Name: Mihdan: Image Placeholder
*/
namespace Mihdan\Image_Placeholder;
$images = array(
// Обычные
'https://placeimg.com/640/480/animals',
@tommcfarlin
tommcfarlin / add-custom-post-type-menu.php
Created April 25, 2013 12:38
[WordPress] Add a custom post type menu as a child of an existing custom post type menu.
<?php
// Define the 'Portfolio' post type. This is used to represent galleries
// of photos. This will be our top-level custom post type menu
$args = array(
'labels' => array(
'all_items' => 'Gallery',
'menu_name' => 'Portfolio',
'singular_name' => 'Gallery',
'edit_item' => 'Edit Gallery',
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';
var isIE = /*@cc_on!@*/false || !!document.documentMode, // Internet Explorer 6-11
isEdge = !isIE && !!window.StyleMedia; // Edge 20+
if(isIE || isEdge) {
// do something...
}