Skip to content

Instantly share code, notes, and snippets.

View dotherightthing's full-sized avatar

Dan Smith dotherightthing

  • Do The Right Thing
  • Wellington, New Zealand
View GitHub Profile
@dotherightthing
dotherightthing / register-post-type.php
Created May 2, 2020 14:05
Register post type #wordpress #cheatsheet
/**
* This cannot use PHP variables without violating theme-check (i18n),
* but a static generator such as Mustache.php could be an option.
*
* Parts:
* 1. Register post type
*
* Variables
* 1. posttypeslug - plural, e.g. cameras
*/
@dotherightthing
dotherightthing / i18n.php
Created May 2, 2020 14:03
i18n (Internationalisation) helpers #wordpress #cheatsheet
<?php
/**
* Internationalisation (I18n)
* WP functions to make strings translatable in your application.
*
* WordPress uses the gettext libraries and tools for this purpose.
* Translations should not be considered trusted strings.
* 'text-domain' can also be added automatically, see `gulp-wp-pot`
* To add a comment for translators, prefix the comment with 'translators: '
*
@dotherightthing
dotherightthing / pluggable-function.php
Created May 2, 2020 14:01
Pluggable function #wordpress #cheatsheet #hooks #filters
/**
* Pluggable function
* Allows the function to be overridden/replaced
*
* This technique is only useful if the function
* is not attached to an 'action' or 'filter' hook
* as those can be overridden,
* or removed via remove_action() or remove_filter()
*
* @see http://wpcandy.com/teaches/custom-hooks-and-pluggable-functions/#.WZFYh3cjFlc
@dotherightthing
dotherightthing / default-editor-content.php
Created May 2, 2020 14:00
Default editor content #wordpress #cheatsheet
/**
* Add default content to the editor
*
* @param string $post_content Post content.
* @uses http://www.wpbeginner.com/wp-tutorials/how-to-add-default-content-in-your-wordpress-post-editor/
* @see https://developer.wordpress.org/reference/hooks/default_content/
* @example
* add_filter( 'default_content', 'wpdtrt_default_content' );
*/
function wpdtrt_default_content( $post_content ) {
@dotherightthing
dotherightthing / body-class.php
Created May 2, 2020 13:58
Add body class #wordpress #cheatsheet
/**
* Add a class to the body
*
* @example
* add_filter( 'body_class', 'my_body_classes' );
*/
function my_body_classes( $classes ) {
// Adds a class of custom-background-image to sites with a custom background image.
if ( some_condition() ) {
$classes[] = 'custom-background-image';
@dotherightthing
dotherightthing / filter-content.php
Created May 2, 2020 13:57
Filter content #wordpress #cheatsheet
/**
* Filter content
*
* @param string $content Content.
* @return string Content
* @example
* add_filter( 'the_content', 'wpdtrt_content_filter' );
*/
function wpdtrt_content_filter( $content ) {
$content = str_replace( '<h2>', '<div><h2>', $content );
@dotherightthing
dotherightthing / wordpress-rename-taxonomy.md
Last active May 2, 2020 13:56
Rename the assigned taxonomy in SequelPro #cheatsheet #wordpress
UPDATE `wp_posts` SET `post_type` = 'tourdiaries' WHERE `post_type` = 'tourdiaryday';
@dotherightthing
dotherightthing / blackfire-setup.md
Last active March 21, 2020 09:08
[Blackfire.io setup] #php #mamp #performance

Blackfire.io setup

A. Configure Homebrew - OK

B. Install the Packages - OK

C. Configure the Agent - OK

D. Install the PHP Probe (MacOS)

@dotherightthing
dotherightthing / exporting-korg-gadget-to-ableton-live-with-samples.md
Last active April 20, 2023 06:07
[Exporting Korg Gadget (iPad) to Ableton Live (MacOS) - with samples!] #ipados #macos #music #panoramica

Exporting Korg Gadget (iPad) to Ableton Live (MacOS) - with samples!

Korg Gadget is a great tool for jamming ideas within a touch environment, with mixer automation and a capable sequencer. Its samplers, Bilbao and Vancouver, fall far short of the standard set by Beatmaker 3, particularly where sample length is concerned, but the app is far more mature and stable, meaning less lost work and stress!

As I prefer to edit tracks in Ableton Live, I purchased the KORG Gadget 2 Plugins for Mac/PC for USD 199 (NZD 318). This allows me to export a Gadget set in Ableton Live format, so I can continue developing my musical ideas within a more familiar DAW.

Unfortunately, there's a major hole in Gadget's export functionality - samples are not exported with the project! I find this suprising given the cost of the KORG Gadget 2 Plugins for Mac/PC, and my use case for them.

The steps below are my approach to saving samples w

@dotherightthing
dotherightthing / high-performance-animations.md
Created February 15, 2020 21:17
[High Performance Animations] #transform #translate
We couldn’t find that file to show.