Skip to content

Instantly share code, notes, and snippets.

View IAmAdamTaylor's full-sized avatar

Adam Taylor IAmAdamTaylor

View GitHub Profile
@IAmAdamTaylor
IAmAdamTaylor / transpose.js
Created January 12, 2018 11:27
JavaScript - Transpose a 2D array
/**
* Transpose an array of arrays using matrix transposition.
* The array is returned, *NOT* transposed in place.
*
* Handles matrixes where the number of rows != number of columns.
* The number of columns in each row must be the same.
* E.g.
[ | [
[1,2,3], | [1,2],
[4,5,6], | [3,4],
@IAmAdamTaylor
IAmAdamTaylor / .bash_profile
Created November 26, 2019 10:01
App Specific Dark Mode in Mac OS X (Tested on 10.15.1 Catalina)
lightMode() {
if [[ "$#" != 2 ]]; then
echo "Must pass exactly 2 arguments."
echo "Usage: lightMode <App_Name> <Yes|No>"
return 2
fi
if [[ "$2" != "Yes" && "$2" != "No" ]]; then
echo "2nd argument must be Yes or No."
echo "Usage: lightMode <App_Name> <Yes|No>"
@IAmAdamTaylor
IAmAdamTaylor / .bash_profile
Last active November 26, 2019 10:10
App Specific Dark/Light Mode in Mac OS X (Tested on 10.15.1 Catalina)
lightMode() {
if [[ "$#" != 2 ]]; then
echo "Must pass exactly 2 arguments."
echo "Usage: lightMode <App_Name> <Yes|No>"
return 2
fi
if [[ "$2" != "Yes" && "$2" != "No" ]]; then
echo "2nd argument must be Yes or No."
echo "Usage: lightMode <App_Name> <Yes|No>"
<?php
add_filter( 'get_the_categories', 'adt_remove_uncategorised_post_category', 20, 2 );
function adt_remove_uncategorised_post_category( $categories, $id ) {
return array_filter($categories, function($a) {
return 'uncategorised' === $a->slug ? false : $a;
});
}
@IAmAdamTaylor
IAmAdamTaylor / show-media-attachments-in-link-dialog.php
Last active April 8, 2020 08:37
Show WordPress Media Attachments in Insert/Edit Link dialog
@IAmAdamTaylor
IAmAdamTaylor / acf-drag-flexible-content-across-repeater.php
Last active August 20, 2020 11:45
ACF Connect Flexible Content Fields Across Repeater
<?php
/**
* Main plugin file.
*
* @package ACF Connect Flexible Content Fields Across Repeater
* @license GPL2
* Author: Adam Taylor <hi@adamtaylor.dev>
*/
@IAmAdamTaylor
IAmAdamTaylor / ReadMe.md
Last active November 28, 2022 03:41
WordPress & WPMU Dev: Regenerate Smush Pro Local WebP images programatically

Enable Media Replace & WPMU Dev Connector (WordPress plugin)

Connects the Enable Media Replace and WPMU Dev (Smush Pro, Hummingbird) plugins together. When an image is replaced using Enable Media Replace, local WebP files created by Smush Pro will be regenerated, and Hummingbird cache will be cleared.

Regnerate Smush Pro Local WebP images programatically when the original image changes.

Tested and working with these versions:

  • WordPress v6.0.1
  • Enable Media Replace v3.6.3
@IAmAdamTaylor
IAmAdamTaylor / array_insert_assoc_at_key.php
Last active April 17, 2024 10:07
PHP — Insert an associative array into another associative array, before or after, a specific key in the original array
<?php
/**
* Inserts an associative array (keys & values) into another
* associative array, with the inserted array being placed
* before or after a specific key in the original array.
*
* If any keys in $insert exist in the original $array, their values
* will be overwritten with the values from $insert.
* Those keys will also be moved to the place they are being inserted.