Skip to content

Instantly share code, notes, and snippets.

Avatar

A. Tate Barber tatemz

View GitHub Profile
@tatemz
tatemz / abstract-multi-singleton-factory.php
Last active Jul 11, 2019
Singleton factories for creating unique single and multi instance classes.
View abstract-multi-singleton-factory.php
<?php
abstract class Multi_Singleton_Factory extends Singleton_Factory {
public static function get_singleton_key( $class, $args ) {
// Create a unique key based on instance-specific information (i.e. classname + args)
return md5( $class . '_' . serialize( $args ) );
}
}
@tatemz
tatemz / docker-wpcli.sh
Last active Apr 16, 2018
A quick way to use one-off wp-cli commands with Docker. See Part 1: https://gist.github.com/tatemz/504383c921aa5898c49b82d4ee181362
View docker-wpcli.sh
#!/bin/bash
cd wordpress-site
cat >> docker-compose.yml <<EOL
my-wpcli:
image: tatemz/wp-cli
volumes_from:
- my-wp
links:
@tatemz
tatemz / docker-wordpress.sh
Last active Nov 2, 2019
A quick way to get a WordPress installation up and running with Docker
View docker-wordpress.sh
#!/bin/bash
mkdir wordpress-site && cd wordpress-site
touch docker-compose.yml
cat > docker-compose.yml <<EOL
version: "2"
services:
my-wpdb:
@tatemz
tatemz / HelloWorld.java
Last active Jul 6, 2016
A build system for sublime text using docker java containers. Edit to fit your own needs... Check out this page for more build variables http://docs.sublimetext.info/en/latest/reference/build_systems/configuration.html
View HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
@tatemz
tatemz / functions.php
Last active Dec 19, 2017
Fixing W3 Total Cache CDN with Beaver Builder CSS media
View functions.php
<?php
// W3 Total Cache Integration with Beaver Builder
add_filter( 'fl_builder_render_css', __NAMESPACE__ . '\bb_plugin_cdn_url' );
function bb_plugin_cdn_url( $css ) {
// Based on wp-content/plugins/w3-total-cache/extensions/WordPressSEO.php
if ( class_exists( 'W3_Plugin_CdnCommon' ) ) {
$site_url = wp_upload_dir();
@tatemz
tatemz / cmb2-fields.php
Created Nov 8, 2015
Add "Other" option to allow for custom radio input with CMB2
View cmb2-fields.php
<?php
if ( file_exists( dirname( __FILE__ ) . '/cmb2/init.php' ) ) {
require_once dirname( __FILE__ ) . '/cmb2/init.php';
} elseif ( file_exists( dirname( __FILE__ ) . '/CMB2/init.php' ) ) {
require_once dirname( __FILE__ ) . '/CMB2/init.php';
}
add_action( 'cmb2_admin_init', 'yourprefix_register_demo_metabox' );
/**
View config.xml
<!-- /app/code/local/MyCompany/MyModule/etc/config.xml -->
<?xml version="1.0"?>
<config>
<adminhtml>
<layout>
<updates>
<mycompany_mymodule>
<file>mycompany/mytemplate.xml</file>
@tatemz
tatemz / app.css
Last active Aug 29, 2015
An example how css-condense can optimize Foundation Apps (line breaks are turned on for better visual).
View app.css
/* AUTOCOMPLETE */
.autocomplete{
width: 100%;
position: relative;
}
.autocomplete input{
font-size: 1.2em;
width: 100%;
View date-to-title.php
<?php
if ( empty( $_POST['acf'] ) ) {
return;
}
if (
!isset( $_POST['acf']['field_543aee78c4176'] )
|| !isset( $_POST['acf']['field_543aee84c4177'] ) )
{
return;
@tatemz
tatemz / class-page-object.php
Created Aug 2, 2014
How to Optimize Your WordPress Metadata
View class-page-object.php
<?php
class Page_Object {
public $ID;
public $original_post;
public $data = array();
public function __construct( $id ) {
You can’t perform that action at this time.