Skip to content

Instantly share code, notes, and snippets.

View adamsilverstein's full-sized avatar
💭
Working remotely, as usual

Adam Silverstein adamsilverstein

💭
Working remotely, as usual
View GitHub Profile
@johnbillion
johnbillion / wp_mail.md
Last active July 7, 2025 13:21
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@krogsgard
krogsgard / template-file.php
Last active January 29, 2016 17:21
Stuff for wrangling Jetpack. End result is along these lines: https://cldup.com/8x050WNF_L.png
<?php echo krogs_output_related_posts(); ?>
#!/bin/bash
REV=$1
svn up --ignore-externals . > /dev/null
svn merge -c$REV ../../trunk .
LOG=$(svn log -r$REV ../../trunk | grep -v '\-------' | tail -n +3)
BRANCH=$(basename $(pwd))
echo -en "$LOG\n\nMerges [$REV] to the $BRANCH branch." | pbcopy
echo ""
pbpaste
@danielbachhuber
danielbachhuber / disable-logged-out-users.php
Last active September 5, 2024 01:55
Disable WP REST API requests for logged out users
<?php
add_filter( 'rest_authentication_errors', function( $result ) {
if ( ! empty( $result ) ) {
return $result;
}
if ( ! is_user_logged_in() ) {
return new WP_Error( 'restx_logged_out', 'Sorry, you must be logged in to make a request.', array( 'status' => 401 ) );
}
return $result;
@JayWood
JayWood / wpcli-posts-generator.php
Created May 6, 2016 14:14
A robust random posts generator with support for multisite, taxonomies, term counts, post counts, post types, featured images, featured image types, and more.
<?php
if ( defined( 'WP_CLI' ) && WP_CLI ) {
class JW_Random_Posts extends WP_CLI_Command {
private $args, $assoc_args;
/**
* Generates a Random set of posts
*
@omarreiss
omarreiss / wpjs.md
Last active February 20, 2018 13:59

Setting up your development environment

[better title needed]

[insert table of contents]

System requirements

Node.js and npm

WordPress uses a JavaScript task runner called Grunt to build its files. It requires the most recent LTS version of the Node.js runtime. It also requires dependencies fetched via npm. npm is packaged with Node.js, so if your computer has Node.js installed you are ready to go.

@westonruter
westonruter / list-document-images.js
Last active August 7, 2018 09:55
Prior to Performance Timeline API getting list of all images in document would require looking at document.images and inspectomg stylesheets to find any referenced background-images; but now with the Performance Timeline API it's easy to get a list of all images (assuming they have image filename extensions)
function getDocumentImages() {
return performance.getEntriesByType('resource')
.map( ( entry ) => entry.name )
.filter( ( url ) => {
const parsedUrl = new URL( url );
return /\.(png|jpe?g|gif|webp|svg)$/i.test( parsedUrl.pathname );
} );
}
@greatislander
greatislander / theme-testing.md
Last active December 14, 2018 15:30
Theme Testing
  • Proof of concept E2E testing using Jest + aXe (branch)
  • Proof of concept E2E testing using Jest + aXe in Docker (branch)
  • Create NPM package of test requirements
  • Improve formatting of reports from Jest + aXe
  • Different test commands for audit and pass/fail
  • Enable scaffolding basic E2E tests for themes (issue)
  • Enable running E2E tests locally via CLI (environment-agnostic)
  • Enable E2E tests for themes in CI (using Docker with sample content)
@westonruter
westonruter / gist-wp-plugin-installation.md
Last active June 30, 2023 03:43
How to install a WordPress plugin from a Gist
<?php
/**
* AMP Validation Error Logger plugin initialization file.
*
* @package AMP_Validation_Error_Logger
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin