Skip to content

Instantly share code, notes, and snippets.

View afragen's full-sized avatar

Andy Fragen afragen

View GitHub Profile
@afragen
afragen / auto-flush-object-cache.php
Last active December 25, 2022 10:25
Catches 'PHP Fatal error Allowed memory size of xxxxxxx bytes exhausted' and 'RedisException' debug.log messages and flushes object cache.
<?php
/**
* Auto-flush object cache.
*
* @package Fragen\Auto_Flush_Cache
*
* Plugin Name: Auto-Flush Object Cache
* Plugin URI: https://gist.github.com/afragen/d46d3cc2c7e07d99f921560dfbb70246
* Description: Auto-flush the object cache when error log records PHP Fatal error for allowed memory size.
* Version: 0.7.0
@afragen
afragen / instructions.md
Last active April 14, 2022 18:27
Change LocalWP wp-config.php for WP-CLI
@afragen
afragen / docker-compose-edits
Last active April 3, 2022 19:14
Add this file to root of wordpress-develop on Apple Silicon to pull correct mysql container.
# Add support for linux/amd64 mysql into docker-compose.yml
services:
mysql:
platform: linux/amd64 <--
<?php
/**
* Plugin Name: GlotPress for Git Updater
* Plugin URI: https://gist.github.com/afragen/4574e1ce54a621351e5eb18ac686f8f3
* Description: This plugin is used for site testing.
* Version: 0.1
* Author: Andy Fragen
* License: MIT
* Requires at least: 5.2
* Requires PHP: 7.1
<?php
/**
* Plugin Name: Count Filter Calls
* Plugin URI: https://gist.github.com/afragen/a8a89888c60c4836a21667531469c7a9
* Description: Count number of times certain filters are called and cumulative time spent for the call with almost no computing done.
* Version: 0.3
* Author: Andy Fragen
* License: MIT
* Requires at least: 5.2
* Requires PHP: 7.0
<?php
/**
* Plugin Name: Add Categories for WMPL translated sites and Category Colors
* Plugin URI: https://gist.github.com/afragen/f9f1a9558258065afe7dab30557c50f4
* Description: Add translated categories to The Events Calendar for The Events Calendar Category Colors.
* Version: 0.1
* Author: Andy Fragen
* License: MIT
* Requires at least: 5.2
* Requires PHP: 7.0
@afragen
afragen / add-plugin-dependency-api.php
Last active September 3, 2022 00:15
Add to Dependencies tab via Git Updater PRO REST API
<?php
/**
* Add Plugin Dependency via REST API.
*
* @package Fragen\Plugin_Dependency_API
*
* Plugin Name: Add Plugin Dependency via REST API
* Plugin URI: https://gist.github.com/afragen/ba3fc125fb0ecd242b1b162153d6adf9
* Description: Add plugin dependency data to Dependencies tab via REST API endpoint and allow for Install Now button to function.
* Version: 0.11.3
@afragen
afragen / change-wp-debugging-defaults.php
Created February 17, 2022 19:24
Single use plugin and filter showing how to change WP Debugging default constants.
<?php
/**
* Plugin Name: Change WP Debugging Defaults
* Plugin URI: https://gist.github.com/afragen/5c79984f154911be171c80468f676572
* Description: Single use plugin and filter showing how to change WP Debugging default constants.
* Version: 0.1
* Author: Andy Fragen
* License: MIT
* Requires at least: 5.2
* Requires PHP: 7.1
/**
* Moves a directory from one location to another via the rename() PHP function.
* If the renaming failed, falls back to copy_dir().
*
* Assumes that WP_Filesystem() has already been called and setup.
*
* @since 5.9.0
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
public function delete_temp_backup( $args ) {
global $wp_filesystem;
if ( empty( $args['slug'] ) || empty( $args['dir'] ) ) {
return false;
}
$temp_backup = trailingslashit( $wp_filesystem->wp_content_dir() . "upgrade/temp-backup/{$args['dir']}/{$args['slug']}" );
return $this->recursive_directory_delete( $temp_backup );