Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Fragen afragen

View GitHub Profile
@afragen
afragen / prevent-plugin-update-dot-org.php
Last active Feb 11, 2021
Prevent updating for specific WordPress plugins.
View prevent-plugin-update-dot-org.php
<?php
// Prevent updating of specific dot org plugins.
add_filter(
'site_transient_update_plugins',
function( $transient ) {
$plugin_arr = [ 'test-plugin2/test-plugin2.php', 'akismet/akismet.php' ];
foreach ( $plugin_arr as $plugin_file ) {
if ( isset( $transient->response[ $plugin_file ]->id )
&& false !== strpos( $transient->response[ $plugin_file ]->id, 'w.org/plugins' )
) {
@afragen
afragen / rollback-testing.php
Last active Feb 19, 2021
Plugin to simulate plugin/theme update failure for testing Rollback Update Failure feature plugin.
View rollback-testing.php
<?php
/**
* Rollback Update Testing
*
* @package rollback-update-testing
* @author Andy Fragen <andy@thefragens.com>
* @license MIT
*/
/**
@afragen
afragen / local-edd-store.php
Last active Jul 31, 2020
Needed for non https local EDD store to correctly run. Set $store_url to your local store URL.
View local-edd-store.php
<?php
/**
* Plugin Name: Local EDD Store
* Description: Set `reject_unsafe_urls` to false for $store_url. $store_url will need to be set for the URL of your local EDD store.
* Author: Andy Fragen
* Version: 0.3
* Gist Plugin URI: https://gist.github.com/afragen/ed00f34f8e03aeedb96bdbf6f3e50495
*/
add_filter(
@afragen
afragen / site-testing.php
Last active Aug 1, 2020
A simple plugin for adding filters/code for plugin testing.
View site-testing.php
<?php
/**
* Plugin Name: Site Testing
* Plugin URI: https://gist.github.com/afragen/a30b7766d8eb1aa22018130dfd5034f4
* Description: This plugin is used for site testing.
* Version: 0.3
* Author: Andy Fragen
* License: MIT
* Requires at least: 5.2
* Requires PHP: 7.1
@afragen
afragen / wp-mail-smtp-shim.php
Last active Jul 1, 2020
Shim to fix errors in WP 5.5-alpha+ and WP Mail SMTP
View wp-mail-smtp-shim.php
<?php
/**
* WP Mail SMTP Shim for WP 5.5 plugin bootstrap.
*
* @package WP_Mail_SMTP_Shim
* @author Andy Fragen
* @license MIT
*
* @wordpress-plugin
* Plugin Name: WP Mail SMTP Shim for WP 5.5
@afragen
afragen / switch-dependency-label.php
Last active Jun 27, 2020
Switch the Plugin Dependency label of wp-dependency-installer
View switch-dependency-label.php
<?php
/**
* Switch Plugin Dependency Label for WP Dependency Installer
*
* @package Switch_Plugin_Dependency_Label
* @author Andy Fragen
* @license MIT
*
* @wordpress-plugin
* Plugin Name: Switch Plugin Dependency Label
@afragen
afragen / .phpcs.xml
Last active Jul 18, 2020
My PHPCS rulesets using WPCS as a base.
View .phpcs.xml
<?xml version="1.0"?>
<ruleset name="WordPress-Beta-Tester">
<description>Keep long array syntax.</description>
<!-- Include main ruleset.xml -->
<rule ref="/Users/afragen/code-standards/ruleset.xml"/>
<rule ref="Generic.Arrays.DisallowShortArraySyntax" />
<!-- Use only long arrays -->
<rule ref="Generic.Arrays">
@afragen
afragen / set-category-colors-hash.php
Created Oct 30, 2019
Set the Category Colors options hash to pre-defined hash
View set-category-colors-hash.php
<?php
/**
* Plugin Name: Set Category Colors Options Hash
* Author: Andy Fragen
* Author URI: https://github.com/afragen
* Version: 0.1
* Requires PHP: 5.3
*/
add_filter( 'teccc_set_options_hash', function(){
@afragen
afragen / aliases.zsh
Last active Feb 7, 2021
My oh-my-zsh aliases
View aliases.zsh
alias wp-git-core="sh -c \"\$(curl -fsSL https://gist.github.com/afragen/e1aa3ffccf1a73618ee6e756bd95d297/raw/core-git-wp.sh)\";cd ."
alias wp-git-develop="sh -c \"\$(curl -fsSL https://gist.github.com/afragen/e1aa3ffccf1a73618ee6e756bd95d297/raw/develop-git-wp.sh)\";cd ."
alias local-socket="SOCKET=\$(mysqld --verbose --help | grep ^socket | awk '{print \$2, \$3, \$4}');ln -sfv \$SOCKET /tmp/mysql.sock"
alias brewup="brew update && brew upgrade && brew cleanup && brew doctor"
#lsof -i | grep LISTEN | grep 'nginx\|httpd'
alias http-listen="lsof -i | grep LISTEN | grep 'nginx\|httpd'"
@afragen
afragen / apply-trac-patch.sh
Last active Dec 13, 2019
Apply patches or change sets from core.trac.wordpress.org tickets.
View apply-trac-patch.sh
#!/usr/bin/env bash
# ====================================================================================
# Script to install patches or changesets to https://core.trac.wordpress.org
# I use with Local Lightning by Flywheel by installing in `/app` directory.
#
# Patches and changesets are saved in `/tmp/` as a default.
# You will use the patch URL in the script.
# ====================================================================================