Skip to content

Instantly share code, notes, and snippets.

View m-e-h's full-sized avatar
😐
...

Marty Helmick m-e-h

😐
...
View GitHub Profile
@justintadlock
justintadlock / theme.json
Created May 31, 2021 02:05
Block theme color naming scheme
{
"settings": {
"defaults": {
"color": {
"palette": [
{
"slug": "transparent",
"color": "transparent",
"name" : "Transparent"
},
@carlalexander
carlalexander / expect-header-fix.php
Last active August 13, 2021 00:40
WordPress "Expect" header fix
<?php
/**
* By default, cURL sends the "Expect" header all the time which severely impacts
* performance. Instead, we'll send it if the body is larger than 1 mb like
* Guzzle does.
*/
function add_expect_header(array $arguments)
{
$arguments['headers']['expect'] = '';
@rw3iss
rw3iss / build.js
Last active June 10, 2023 20:29
esbuild.js frontend build script
var fs = require("fs");
var path = require("path");
// Config params (relative to where npm/script is called from):
const APP_BASE = './src';
const ENTRY_FILE = `index.tsx`;
const OUTPUT_DIR = './build';
const OUTPUT_FILE = 'app.js';
const IS_DEV = false;
const TARGET = 'es2018';
@ideadude
ideadude / wordpress_colon_searches.php
Last active January 23, 2024 02:58
If a colon is in a user search query in the WP Users dashboard or the PMPro Members List, try to speed up the query.
<?php
/**
* Functions affecting admins and the admin dashboard.
*/
/**
* Return array of fields found in the wp_users table.
* This function used in the others below to determine if a key entered in a search like "email:[email protected]"
* is referencing the user_email column of the wp_users table or a unique meta key.
*/
function my_pmpro_get_user_table_columns() {
@pento
pento / php-block.js
Last active September 5, 2024 01:58
Converting a shortcode to a block: this method is fast to do, but a mediocre UX. You should only use this as a stopgap until you can implement a full block UI.
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
@cferdinandi
cferdinandi / vanilla-js-plugin.js
Created June 13, 2017 00:10
My starter template for vanilla JavaScript plugins.
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define([], factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== 'undefined' ? global : this.window || this.global, function (root) {
@brettsmason
brettsmason / croft-svg.php
Last active December 9, 2016 03:42
SVG icon helper functions for WordPress
/**
* Return SVG markup.
*
* @param string $icon Required. Use the icon filename, e.g. "facebook-square".
* @param array $args {
* Parameters needed to display an SVG.
*
* @param string $title Optional. SVG title, e.g. "Facebook".
* @param string $desc Optional. SVG description, e.g. "Share this post on Facebook".
* @param string $class Optional. SVG class, defaults to 'icon icon-{icon name}.
<?php
/**
* Plugin Name: Customize Post Preambles
* Author: Weston Ruter, XWP
* Description: Demo plugin for Customize Posts to add a section before each post in The Loop that contains a preamble content stored in postmeta.
*
* @package CustomizePostPreambles
*/
namespace CustomizePostPreambles;
@devinsays
devinsays / jetpack.php
Last active July 26, 2022 12:36
Query by JetPack Related Posts
<?php
/**
* Prevents Related Posts from displaying in content area
*/
function prefix_remove_rp() {
if ( class_exists( 'Jetpack_RelatedPosts' ) ) {
$jprp = Jetpack_RelatedPosts::init();
$callback = array( $jprp, 'filter_add_target_to_dom' );
remove_filter( 'the_content', $callback, 40 );
}
@joshua-moore
joshua-moore / gist:7c8f8355f217770bae56
Last active December 20, 2020 05:14
Virtual ZigBee RGBW Bulb (Used for OSRAM RGBW light groups)
/**
* Virtual ZigBee RGBW Bulb (Used for OSRAM RGBW light groups)
*
* Copyright 2016 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*