Skip to content

Instantly share code, notes, and snippets.

@ryelle
ryelle / edit.js
Last active September 1, 2021 20:59
Demo of `test-unit-js` failure for Gutenberg issue
import { __ } from '@wordpress/i18n';
import { useBlockProps } from '@wordpress/block-editor';
/**
* The edit function describes the structure of your block in the context of the
* editor. This represents what the editor will render when the block is used.
*
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#edit
*
* @return {WPElement} Element to render.
@ryelle
ryelle / admin-bar-items.php
Created March 25, 2021 18:27
Add extra items to the top level of the WordPress admin bar
<?php
/**
* Plugin Name: Admin Bar Items
*/
add_action(
'admin_bar_menu',
function( $admin_bar ) {
$admin_bar->add_menu( array(
'id' => 'ryelle-demo-1',
@ryelle
ryelle / index.js
Last active December 4, 2020 23:29
Demo block to test an entity records request with a `_fields` subset
const { registerBlockType } = wp.blocks;
const { createElement } = wp.element;
const { useSelect } = wp.data;
registerBlockType("ryelle/select-fields-test", {
title: "Fields Test",
category: "common",
icon: "flag",
edit: () => {
@ryelle
ryelle / demo.php
Last active October 7, 2020 21:09
Example container block
<?php
/**
* Plugin Name: Internationalization Block
* Description: This is some demo for i18n support.
* Version: 0.1.0
* Author: ryelle
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: ryelle-i18n
*
@ryelle
ryelle / svg-icon.php
Last active July 3, 2020 23:15
Add a demo page with a custom SVG icon to wp-admin
<?php
/**
* Plugin Name: SVG Icon Test
* Description: Add a menu with an SVG icon to test the icon colorer
*/
add_action( 'admin_menu', function(){
add_menu_page(
'SVG Icon Test Page',
'SVG Icon',
@ryelle
ryelle / docker-compose.yml
Last active October 12, 2020 15:20
Simple WP site for theme & plugin dev, with wp-cli
version: '3.2'
services:
db:
image: mysql:latest
volumes:
- db_data:/var/lib/mysql
container_name: db
environment:
MYSQL_ROOT_PASSWORD: rootroot
@ryelle
ryelle / remove-colors.js
Created April 22, 2020 23:03
PostCSS plugin to remove colors from a CSS file
const postcss = require( 'postcss' );
const getColors = require( 'get-css-colors' );
/* A size is any number, optionally with a unit. */
const isSize = ( value ) => /^\d+\s?([a-zA-Z]+)?$/.test( value.trim() );
/* If the value has a color in it, getColors will return an array. */
const isColor = ( value ) => null !== getColors( value );
/* A line style is from a set of values */
@ryelle
ryelle / index.md
Created February 26, 2020 18:44
CampTix accessibility changes

Ticket Selection

 <tr class="tix-ticket-1664">
-	<td class="tix-column-description">
-		<strong class="tix-ticket-title">Test Ticket</strong><br>
+	<th class="tix-column-description" scope="row">
+		<label for="tix-qty-1664" class="tix-ticket-title">Test Ticket</label><br>
 		<span class="tix-ticket-excerpt">This ticket will be used to test Notify features.</span>
-	</td>
@ryelle
ryelle / readme.md
Last active October 15, 2020 21:50
About Page documentation

Building the About Page(s)

Color Variables

Until we have something like postcss-custom-properties to create the fallback hex codes for IE, these will need to be manually updated in the about.css file.

  • --text: Used for the text color.
  • --background: This is the base background for section blocks.
  • --subtle-background: Used for section backgrounds if given the class has-subtle-background-color.
  • --nav-background: The nav banner background
@ryelle
ryelle / manifest.json
Created December 13, 2018 00:20
A super-simple chrome extension to disable falling snow on wp.com sites
{
"name": "No Falling Snow",
"content_scripts": [
{
"matches": ["https://*.wordpress.com/*", "https://*.wordpress.com/"],
"css": ["p2s.css"]
}
],
"version": "1.0.0",
"description": "A super-simple chrome extension to disable falling snow on wp.com sites",