Skip to content

Instantly share code, notes, and snippets.

View markjaquith's full-sized avatar

Mark Jaquith markjaquith

View GitHub Profile
@markjaquith
markjaquith / Laracon US 2023.md
Created July 20, 2023 21:29
Rough notes from Laracon US 2023

These notes are super rough, and I didn’t take notes for a couple sessions. Let me know if you found them useful or they helped you remember things presented at the conference! @markjaquith on Twitter.

Pest PHP

by Nuno Maduro

[!question] How do snapshots work in CI? Won’t there not be an existing snapshot when the tests run?

Cool new features

@markjaquith
markjaquith / alloptions-optimizer.php
Created September 11, 2022 23:08
Proof of concept alloptions optimizer
<?php
/**
* Plugin Name: Alloptions Optimizer
* Author: Mark Jaquith
*/
class AllOptionsOptimizer {
private static $usedOptions = [];
private static $allOptions = [];
private static $allOptionsBytes;
@markjaquith
markjaquith / commit.sh
Created August 1, 2022 15:48
git commit helper
#!/bin/zsh
function maybeBail() {
if [[ $? -ne 0 ]]; then
exit 1
fi
}
TYPE=$(gum choose "fix" "feat" "docs" "style" "refactor" "test" "chore" "revert")
maybeBail
@markjaquith
markjaquith / admin-links-new-tab.php
Created April 25, 2022 19:46
WordPress plugin to open external links in a new tab in the WordPress admin
@markjaquith
markjaquith / Disable-ACF-UI.php
Created January 12, 2021 08:28
Disable ACF UI
<?php
// Block the ACF settings UI entirely, except on local dev.
if (! defined('WP_LOCAL_DEV') || ! WP_LOCAL_DEV) {
add_filter('acf/settings/show_admin', '__return_false');
add_filter('acf/settings/capability', function () { return 'do_not_allow'; });
}
@markjaquith
markjaquith / README.md
Created April 11, 2019 17:29
Identify images that are displayed wider than their natural width (which results in them looking blurry)
  1. Paste this into your browser console.
  2. Start resizing the window.
  3. Any images that are ever displayed in a blurry fashion will throw an error and get faded out to 0.05 opacity.
@markjaquith
markjaquith / gform-stripe-use-older-api.php
Created February 25, 2018 01:56
Force Gravity Forms Stripe add-on to use an older version of the Stripe API, so subscriptions work
<?php
add_action( 'gform_stripe_post_include_api', function() {
if ( method_exists( '\Stripe\Stripe', 'setApiVersion' ) ) {
\Stripe\Stripe::setApiVersion( '2016-07-06' );
}
});
<?php
/**
* Plugin Name: YOUR PLUGIN NAME
*/
include( dirname( __FILE__ ) . '/lib/requirements-check.php' );
$your_plugin_requirements_check = new YOUR_PREFIX_Requirements_Check( array(
'title' => 'YOUR PLUGIN NAME',
'php' => '5.4',
<?php
/*
Plugin Name: Block WordPress attachment queries
Description: Blocks MySQL queries for WordPress attachments that are on domains we know will never resolve to a local WordPress attachment ID.
Author: Mark Jaquith
*/
add_filter( 'query', function( $query ) {
global $wpdb;
@markjaquith
markjaquith / readme.md
Last active June 11, 2017 15:19
For WordPress, a method to re-index a multi-dimensional array by the (unique) value of a given array key

Okay, so, let's say you have some data like this:

$things = [
  0 => [ 'id' => 123, 'title' => '123 Title', 'content' => '123 Content' ],
  1 => [ 'id' => 456, 'title' => '456 Title', 'content' => '456 Content' ],
  2 => [ 'id' => 789, 'title' => '789 Title', 'content' => '789 Content' ],
];