Skip to content

Instantly share code, notes, and snippets.

View ControlledChaos's full-sized avatar

Controlled Chaos Design ControlledChaos

View GitHub Profile
@ControlledChaos
ControlledChaos / abstract-example.php
Created September 23, 2018 16:42
WordPress: Customize Page & Post Metaboxes
<?php
$wp_meta_boxes[ 'post' ][ 'normal' ][ 'core' ][ 'post excerpt' ][ 'title' ] = 'Abstract';
$wp_meta_boxes[ 'post' ][ 'normal' ][ 'core' ][ 'post excerpt' ][ 'id' ] = 'postabstract';
@ControlledChaos
ControlledChaos / youtube_id_regex.php
Created September 22, 2018 22:06 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@ControlledChaos
ControlledChaos / gist:ff1608f7885b3d8859f21d389b333ff3
Created August 8, 2018 00:20 — forked from dnavarrojr/acf_form_shortcode.php
ACF Form Shortcode Plugin for the Front End
<?php
/*
Plugin Name: ACF Front End Forms
Plugin URI: https://navarrojr.com
Description: Create forms on the front end of the site from ACF field groups.
Version: 0.0.1
Author: Dave Navarro, Jr.
Author URI: https://navarrojr.com
*/
@ControlledChaos
ControlledChaos / acf_href.php
Created August 8, 2018 00:19 — forked from dnavarrojr/acf_href.php
Create an HREF link with a shortcode using ACF fields
<?php
/*****************************************************************************************************************************************************
*
* Usage: [acf_href href_before="mailto:" href="acf:field_name" text="acf:field_name"]
*
* acf:fieldname will retrieve the value of the specified "fieldname" and use that.
* get:url_variable will grab a variable from the URL and use that.
*
* [acf_href href="acf:my_link" text="Link to web site"]
@ControlledChaos
ControlledChaos / wp-singleton-namespace-example.php
Created July 29, 2018 22:02 — forked from szbl/wp-singleton-namespace-example.php
Quick Singleton class to be included in WordPress plugin (or theme functions.php file) that will create a simple Person post type and shows some methods of encapsulating functionality in a class as a "namespace," as well as applying filters to things, allowing other users to extend your code.
<?php
class Sizeable_Person
{
const POST_TYPE_SLUG = 'szbl-person';
public static $instance;
public static function init()
{
if ( is_null( self::$instance ) )
@ControlledChaos
ControlledChaos / README.md
Last active July 25, 2018 17:16
Disable the "Try Gutenberg" notice on the WordPress dashboard.

Disable the Try Gutenberg Notice

WordPress Snippet

@ControlledChaos
ControlledChaos / registerblock-custom-icon-gutenberg.js
Created July 21, 2018 04:08 — forked from zgordon/registerblock-custom-icon-gutenberg.js
Example for how to create use a custom SVG icon for a block in Gutenberg
// Import __ from i18n internationalization library
const { __ } = wp.i18n;
// Import registerBlockType() from block building libary
const { registerBlockType } = wp.blocks;
// Import the element creator function (React abstraction layer)
const el = wp.element.createElement;
/**
* Example of a custom SVG path taken from fontastic
*/
@ControlledChaos
ControlledChaos / README.md
Last active July 17, 2018 13:08
Stop WordPress attempts to guess the "correct" URL.

Disable Redirect Guess

WordPress Snippet

@ControlledChaos
ControlledChaos / per-site-user-fields.php
Created July 9, 2018 22:59 — forked from GaryJones/per-site-user-fields.php
WordPress plugin to store custom and built-in user fields on a per-site basis for WP multisite. Good for multilingual setups. Customise to your needs.
<?php
/**
* Per-Site User Fields
*
* @package GaryJones\PerSiteUserfields
* @author Gary Jones
* @copyright 2018 Gary Jones, Gamajo
* @license GPL-2.0-or-later
*
* @wordpress-plugin
@ControlledChaos
ControlledChaos / README-Template.md
Created July 9, 2018 15:44 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites