Skip to content

Instantly share code, notes, and snippets.

View lightningspirit's full-sized avatar
🏠
Working from home

Vitor Carvalho lightningspirit

🏠
Working from home
View GitHub Profile
@lightningspirit
lightningspirit / README.md
Created August 22, 2022 00:30
Includes a WPGraphQL JWT token in every posts preview link

WPGraphQL JWT in Preview Link

Includes a WPGraphQL JWT token in every posts preview link. That can be used for an external application (e.g. Next.js) to include in the authorization header when contacting back the WordPress instance using the WPGraphQL.

Usage

  1. Install both WPGraphQL and WPGraphQL JWT Authentication
  2. Download this ZIP
  3. Upload to plugins
  4. Activate it
@lightningspirit
lightningspirit / ping-updates.php
Last active August 8, 2024 15:26
Intercepts WordPress posts and terms changes and pings an external service
<?php
/**
* Plugin Name: Ping Updates
* Plugin URI: https://gist.github.com/lightningspirit/7a4e5abd77b5b63b3409086f1ac6aa55
* Description: Intercepts posts and terms changes and pings an external service
* Author: Move Your Digital, Inc.
* Author URI: https://moveyourdigital.com
* Version: 0.2.0
* License: GPLv2
@lightningspirit
lightningspirit / README.md
Last active August 22, 2022 00:07
Fix WordPress REST base to use real URL

WordPress REST base on Site URL

If you change the site URL option to use a different one from your installed directory, the /wp-json/ is base changes too. This plugin fixes that.

Usage

  1. Download a ZIP of this plugin
  2. Upload to WordPress
@lightningspirit
lightningspirit / README.md
Last active June 22, 2022 18:50
WPGraphQL search by field with regular expressions support

WPGraphQL search by field with regular expressions support

Adds a where field to WPGraphQL content nodes (post, page and custom post types) to search by field using regexp or like. Supported fields are name, title, author, excerpt, status and mime_type.

Usage

  1. Install WPGraphQL
  2. Download or copy the wpgraphql-search-field.php file
  3. Place it under wp-content/mu-plugins
  4. Done
@lightningspirit
lightningspirit / README.md
Last active September 26, 2022 15:50
WPGraphQL add field format plain text

WPGraphQL add field format plain text

This small plugin adds a new format to retrieve excerpt or title in text plain format instead of rendered.

Usage

  1. Install WPGraphQL
  2. Download or copy the wpgraphql-field-format-text-plain.php file
  3. Place it under wp-content/mu-plugins
  4. Done
[{
"id": "year",
"type": "year",
"label": "Em que ano ficou desempregado/a",
"min": 2008
},
{
"id": "month",
"type": "select",
"label": "E em que mês",
@lightningspirit
lightningspirit / distributed-event-system.ts
Created April 29, 2022 16:55
A distributed event system for Node.js using Redis as storage system
import { createClient } from "redis"
type Listener = <E extends Event>(event: E) => void
/**
* Atomic distributed memory accross nodes
* backed by Redis server.
*/
class DistributedMemory {
/**
@lightningspirit
lightningspirit / contentdb.ts
Created April 29, 2022 16:54
ContentDB - A tiny JS cache-in-disk database for embeddable systems
import { promises as fs } from "fs"
import path from "path"
export interface NodeItem {
id: string
data: any
}
const cache: NodeItem[] = []
@lightningspirit
lightningspirit / elementor-s3-uploads.php
Created February 24, 2022 13:28
Some WordPress Mu-plugins
<?php
/**
* Plugin Name: Elementor S3
* Description: Elementor support for S3 Uploads plugins
* Plugin URI: https://gist.github.com/lightningspirit/73df703f0db1fef14bd30d64ea1e8631
* Author: Move Your Digital, Inc.
* Author URI: https://moveyourdigital.com
* Version: 0.1.0
*
@lightningspirit
lightningspirit / README.md
Created February 17, 2022 21:46
Disable WordPress Admin Bar MU-Plugin

Disable WordPress Admin Bar MU-Plugin

Disable the admin bar for all users automatically.

Usage

  1. Download or copy the disable-admin-bar.php file
  2. Place it under wp-content/mu-plugins
  3. Done