Skip to content

Instantly share code, notes, and snippets.

View JodiWarren's full-sized avatar
🎯
Focusing

Jodi Warren JodiWarren

🎯
Focusing
View GitHub Profile
@JodiWarren
JodiWarren / monospaceText.js
Last active December 14, 2021 18:14
Simple monospace text area for Sanity
import React from "react";
import { FormField } from "@sanity/base/components";
import { Card, Label, Stack, TextArea } from "@sanity/ui";
import PatchEvent, { set, unset } from "@sanity/form-builder/PatchEvent";
import { useId } from "@reach/auto-id"; // hook to generate unique IDs
const MonospaceTextArea = React.forwardRef((props, ref) => {
const {
type, // Schema information
value, // Current field value
const containerStyle = {
display: "inline-block",
position: "absolute",
visibility: "hidden",
zIndex: -1,
};
interface IEnhanceMeasurableNodeCallback {
(e: Node): Node;
}
@JodiWarren
JodiWarren / cf7-autocomplete.php
Created August 12, 2020 14:25
Naively add autocomplete attribute to Contact Form 7 inputs
<?php
/**
* @param $content
*
* @return string|string[]
*/
function imp_wpcf7_form_elements( $content ) {
$valid_autocomplete = [
'name',
<style>
.measurement-container {
position: fixed;
z-index: 999;
top: 30px;
left: 30px;
background: white;
padding: 15px;
border: 10px solid wheat;
}
@JodiWarren
JodiWarren / machine.js
Last active November 1, 2019 16:51
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@JodiWarren
JodiWarren / filter_search_wp.php
Created October 26, 2019 17:12
Filter SearchWP results by post type.
<?php
function filter_search_by_post_type( $included, $engine, $terms ) {
$post_type = get_query_var('post_type');
if (!is_array($post_type)) {
return $included;
}
$posts = new \WP_Query([
'no_found_rows' => true,
@JodiWarren
JodiWarren / one-line-jqueryish.js
Created November 30, 2018 13:02
A one-line jQuery replacement (not really)
const $ = (selector) => Array.from(document.querySelectorAll(selector));
<?php
class OutputTemplateDetails {
function init() {
add_action( 'all', [$this, 'output_template_data'], 10, 2);
}
function get_template_location($slug, $name) {
$templates = array();
@JodiWarren
JodiWarren / wp-get-plugin-names.js
Last active March 29, 2018 12:44
Get a list of plugin names from a WordPress plugins admin page. You can change the `[data-plugin]` selector to `.active` or `.inactive` to get a subset. Just pop it into the dev tools console.
jQuery.map(jQuery('[data-plugin]').map((index, element) => $(element).find('strong').first().html()), value => [value]).join('\n');