Skip to content

Instantly share code, notes, and snippets.

View jbrinley's full-sized avatar

Jonathan Brinley jbrinley

View GitHub Profile
@jbrinley
jbrinley / opcache.preload.php
Created December 22, 2019 20:16
WordPress core opcache.preload
<?php
declare( strict_types=1 );
$wp_dir = '/application/www/wp/';
$preload_patterns = [
$wp_dir . "wp-includes/Text/Diff/Renderer.php",
$wp_dir . "wp-includes/Text/Diff/Renderer/inline.php",
$wp_dir . "wp-includes/SimplePie/**/*.php",
$wp_dir . "wp-includes/SimplePie/*.php",
@jbrinley
jbrinley / force-plugin-activation.php
Last active November 5, 2020 15:11
An mu-plugin that forces selected plugins to be active, without the capability to deactivate.
<?php
/*
Plugin Name: Force Plugin Activation/Deactivation (except if WP_DEBUG is on)
Plugin URI: http://tri.be/
Description: Make sure the required plugins are always active.
Version: 1.0
Author: Modern Tribe, Inc.
Author URI: http://tri.be/
*/
@jbrinley
jbrinley / README.md
Last active August 18, 2020 20:05
Run this from a WP CLI shell to generate sample item code data for all local products.

Run this from WP CLI to generate sample item code data for all local products. Drop the file in your mu-plugins directory, then run:

dev/docker/wp.sh shell
localdev_populate_itemcodes();
exit();
@jbrinley
jbrinley / catalog-data-sample.local.php
Created August 18, 2020 20:01
Run this from a WP CLI shell to generate sample item code data for all local products.
<?php
use Tribe\Project\Post_Meta\Catalog_Integration;
use Tribe\Project\Post_Types\Product\Product;
use Tribe\Project\Taxonomies\Item_Code\Item_Code;
use Tribe\Project\Taxonomies\Spec_Field\Spec_Field;
use Tribe\Project\Taxonomies\Warranty\Warranty;
use Tribe\Project\Taxonomy_Meta\Spec_Field_Attributes;
function localdev_populate_itemcodes() {
@jbrinley
jbrinley / disable-bigcommerce-cron-import.php
Last active October 13, 2019 00:56
A plugin to disable cron-initialized imports on a BigCommerce for WordPress site. Drop this file in /wp-content/mu-plugins, or add the snippet to your theme's functions.php.
<?php
/**
* Removes the cron trigger for a BigCommerce import. It is still possible to
* run an import manually by clicking the "Sync Products" button in the admin,
* or by running the import from the command line.
*/
add_action( 'bigcommerce/init', function( $plugin ) {
remove_action( 'bigcommerce_start_import', $plugin->import->cron_start, 10 );
}, 10, 1 );
@jbrinley
jbrinley / Dockerfile
Last active September 10, 2019 09:48
Install php7 memcached on alpine linux - dockerfile snippet
RUN
apk add --update \
autoconf \
file \
g++ \
gcc \
libc-dev \
make \
pkgconf \
re2c \
@jbrinley
jbrinley / disable-plugin-delete.php
Last active August 20, 2019 18:38
WordPress plugin to disable the deletion of plugin files when running the uninstaller. Drop this in your mu-plugins directory before running the uninstaller.
<?php
/**
* Plugin Name: Disable Plugin Deletion
* Description: Disables the deletion of plugin files when running the uninstaller
* Author: Jonathan Brinley
* Version: 1.0.0
* Author URI: https://xplus3.net/
* License: GPLv2 or later
*/
@jbrinley
jbrinley / bc_cats_to_wp_cats.php
Last active August 19, 2019 14:42
Convert BigCommerce category IDs to WordPress category IDs
<?php
function bc_cats_to_wp_cats( $category_ids ) {
$query = new \WP_Term_Query();
return $query->query( [
'taxonomy' => \BigCommerce\Taxonomies\Product_Category\Product_Category::NAME,
'meta_query' => [
[
'key' => 'bigcommerce_id',
@jbrinley
jbrinley / Image_Importer.php
Last active August 10, 2018 12:45
A utility class for importing images from an external URL into WordPress.
<?php
/**
* Class Image_Importer
*
* Imports an image from a URL and attaches it to a post
*/
class Image_Importer {
private $image_url;
private $attach_to_post_id;
[alias]
ci = commit
# View abbreviated SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph --abbrev-commit
lol = log --graph --decorate --pretty=format:\"%h %ad | %s%d [%an]\" --date=short --abbrev-commit
# View the current working tree status using the short format