Skip to content

Instantly share code, notes, and snippets.

View afragen's full-sized avatar

Andy Fragen afragen

View GitHub Profile
@afragen
afragen / phpcs.xml
Last active September 10, 2023 16:55
phpcs files for my plugins and core plugins
<?xml version="1.0"?>
<ruleset name="AJF Coding Standards">
<description>A custom ruleset to take in account both WordPress and personal standards.</description>
<!-- Show progress and sniff codes in all reports -->
<arg value="ps"/>
<arg value="sp"/>
<arg name="colors"/>
<!-- Only check PHP files. -->
@afragen
afragen / remove_hook.php
Last active September 4, 2023 20:34
Kludge for removing hook in WordPress when you don't have the exact callback object.
<?php
/**
* Kludge to remove hooks when I can't pass the precise object instance.
*
* @param string $hook_name The filter hook to which the function to be removed is hooked.
* @param callable|string|array $callback The callback to be removed from running when the filter is applied.
* This method can be called unconditionally to speculatively remove
* a callback that may or may not exist.
* @param int $priority The exact priority used when adding the original filter callback.
<?php
/**
* Plugin Name: RAU Edge Case - Defining Constants in main plugin file.
* Description: Defining Constants in main plugin file.
* Version: 0.1.0
* Author: Andy Fragen
* License: MIT
* Requires at least: 6.2
* Requires PHP: 7.1
* Gist Plugin URI: https://gist.github.com/afragen/89cb21b5de301b28e65ceb56d264659a
<?php
/**
* Plugin Name: RAU Edge Case - Defining Class in main plugin file.
* Description: Defining class in main plugin file.
* Version: 0.1.0
* Author: Andy Fragen
* License: MIT
* Requires at least: 6.2
* Requires PHP: 7.1
* Gist Plugin URI: https://gist.github.com/afragen/efd22a5bcd527374a7843dec24463f47
@afragen
afragen / .phpcs.xml
Last active June 15, 2023 20:58
My PHPCS rulesets using WPCS as a base.
<?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 / core-git-wp.sh
Last active June 10, 2023 22:19
Create WP Core development environments in Local Lightning
cd ..
mv ./public/wp-config.php .
rm -rf ./public
git clone git://core.git.wordpress.org/ public
ln -sv $PWD/wp-config.php $PWD/public/wp-config.php
curl -o ./public/.gitignore https://gist.githubusercontent.com/afragen/43dfff563e942353d866c81904498cb2/raw/.gitignore
curl -o setup-phpunit.sh https://raw.githubusercontent.com/afragen/setup-phpunit/master/setup-phpunit.sh
curl -o apply-trac-patch.sh https://gist.githubusercontent.com/afragen/977d765414189d5f5fae42215fe92a27/raw/apply-trac-patch.sh
bash setup-phpunit.sh --wp-version=trunk --wp-ts-version=trunk
cd public/
@afragen
afragen / .wp-env.json
Created May 24, 2023 19:26
Just an example, doesn't work for core development.
{
"core": "WordPress/wordpress-develop#trunk",
"phpVersion": "8.1",
"plugins": [
"https://downloads.wordpress.org/plugin/query-monitor.zip"
],
"port": 8888,
"testsPort": 8889,
"config": {
"WP_DEBUG": true,
@afragen
afragen / stop-auto-update-success-email.php
Last active May 2, 2023 16:52
Stop success update email for plugin/theme auto updates.
<?php
/**
* Stop success email from auto-updates.
*
* @package StopAutoUpdateSuccessEmail
*
* Plugin Name: Stop Auto-update Success Email
* Plugin URI: https://gist.github.com/afragen/e2f40ed2e71e590a127e8adc1db05948
* Description: Stop success email from auto-updates.
* Version: 0.2.0
@afragen
afragen / aliases.zsh
Last active April 29, 2023 19:40
My oh-my-zsh aliases
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 / php.ini.hbs
Last active January 11, 2023 22:29
Stuff for xDebug 3.x and Local
; Add to all lightning services PHP conf files using xDebug 3.x
xdebug.mode=debug
xdebug.client_port=9003
xdebug.start_with_request=trigger
xdebug.discover_client_host=yes
xdebug.idekey=VSCODE
; Add to all lightning services PHP conf files using xDebug 2.x
xdebug.remote_enable=1
xdebug.remote_connect_back=Off