Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Prevent revslider from adding a query on every request.
*
* Calling `update_option('rs_tables_created', true)` causes
* a database query to run since it's get_option value ("1")
* does not match the value it is called to set it to.
*
* Since the query casts `true` to "1" the update query is run on every request as true !== '1'.
@aaemnnosttv
aaemnnosttv / drop-by-prefix.sql
Created November 16, 2015 23:44
mysql: Drop all tables by prefix
SET GROUP_CONCAT_MAX_LEN=10000;
SET FOREIGN_KEY_CHECKS = 0;
SET @tbls = (SELECT GROUP_CONCAT(CONCAT('`', TABLE_NAME, '`'))
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'tablename_goes_here'
AND TABLE_NAME LIKE 'thetableprefix_%');
SET @delStmt = CONCAT('DROP TABLE ', @tbls);
-- SELECT @delStmt;
PREPARE stmt FROM @delStmt;
EXECUTE stmt;
@aaemnnosttv
aaemnnosttv / details.md
Last active September 28, 2019 08:51 — forked from ericclemmons/example.md
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue, pull request, or just leaving a comment and you have a lot of supporting content to provide, such as:

  • Log excerpts
  • Code snippets
  • Large screenshots
  • Any other form of content spanning a large vertical space

To optimize readability, wrap it in a `` tag!

@aaemnnosttv
aaemnnosttv / env.php
Created January 27, 2020 09:06
WordPress Environment Configuration
<?php
/**
* Plugin Name: Environment Configuration
* Description: Enforces environment-specific settings for the current environment.
*/
namespace App\Environment;
function disable_plugins( $disable_plugins ) {
add_filter(
@aaemnnosttv
aaemnnosttv / jest.test.js
Created May 26, 2020 16:08
Jest order of operations
describe( 'level 0', () => {
beforeAll( () => console.log( 'beforeAll', 'Level 0' ) );
afterAll( () => console.log( 'afterAll', 'Level 0' ) );
beforeEach( () => console.log( 'beforeEach', 'Level 0' ) );
afterEach( () => console.log( 'afterEach', 'Level 0' ) );
describe( 'level 1A', () => {
beforeAll( () => console.log( 'beforeAll', 'Level 1A' ) );
afterAll( () => console.log( 'afterAll', 'Level 1A' ) );
beforeEach( () => console.log( 'beforeEach', 'Level 1A' ) );
@aaemnnosttv
aaemnnosttv / ray.php
Created September 24, 2022 19:37
Ray config file for use within Docker
<?php // Save this in a file called "ray.php"
return [
/*
* The host used to communicate with the Ray app.
*/
'host' => 'host.docker.internal',
/*
* The port number used to communicate with the Ray app.
@aaemnnosttv
aaemnnosttv / mamp-to-valet.md
Last active March 1, 2023 14:40
MAMP to Valet

MAMP to Valet

One-time Dependency Setup/Configuration

Install Composer

wget https://getcomposer.org/download/1.1.0/composer.phar && chmod +x composer.phar && sudo mv /usr/local/bin/composer && composer self-update
@aaemnnosttv
aaemnnosttv / gravity-forms-select-optgroupify.php
Created October 5, 2018 09:58
GravityForms filter to allow for grouping select choices into labelled groups using special choice options.
<?php
/**
* Filter for GravityForms to group select field choices by a special "optgroup" choice.
*
* Simply add a new choice with a value of 'optgroup' to the dropdown to start a group of options.
* All following choices will be grouped under it using its label for the group.
* Any number of groups can be created, as each optgroup choice will start a new group.
* Supports field placeholder & ungrouped options, but must be before the first group.
*
* This snippet can be added to your theme's functions.php, or a custom plugin.
@aaemnnosttv
aaemnnosttv / as3cf-upload-missing-media-library-items-to-s3.php
Last active December 2, 2023 00:40
AS3CF - Upload all missing media library items to S3
<?php
/**
* For use with Amazon S3 and CloudFront by Delicious Brains
*
* Upload this file to your installation and trigger it with WP-CLI:
* wp eval-file as3cf-upload-missing-media-library-items-to-s3.php
*/
global $as3cf;
@aaemnnosttv
aaemnnosttv / google-site-kit-ipv6-workaround.php
Created December 14, 2023 20:26
Site Kit helper plugin for sites impacted by IPv6 connection issues
<?php
/**
* Plugin Name: Site Kit by Google – IPv6 Support Helper
* Description: Helper plugin for sites impacted by IPv6 connection issues.
* Author: Evan Mattson
* Version: 0.2
*/
add_action(
'plugins_loaded',