Skip to content

Instantly share code, notes, and snippets.

@richaber
richaber / functions.php
Last active August 29, 2015 14:26
Ad Code Manager Admin Screen Pagination and Per Page Filters
<?php
/**
* Increase the number of ACM posts that can be displayed in the ACM admin screen.
*
* For some unknown reason, ACM limits the display of ad codes on it's own management screens to 50 ads total out of the box.
* More than 50 ad codes may actually exist in the database, but the ACM screen will only show 2 pages, 25 each, for a total of 50,
* even if you have hundreds of ads codes stored in the database! Because of this you can never edit the ads that are on pages 3+!
* Increase the number of posts that ACM will retrieve for the admin screen with acm_ad_code_count filter.
* Increase the number of ads per paginated page with the acm_list_table_per_page filter.
* It appears some sort of caching may be involved, leading to this unexpected/unwanted behavior.
@richaber
richaber / front-page.php
Created September 24, 2015 01:03
Display WP [gallery] shortcode, outside of the_content, on static front-page, then remove that shortcode from the_content on static front-page with a filter function attached to the_content filter
<?php
/**
* A "Proof Of Concept" Front Page template that displays the first gallery found in the_content, above the_content.
*
* The concept could be applied to any singular template, single posts, single pages, single custom post types, static
* front page, etc (not really for archive pages, or blog home). The function
* yourthemeprefix_remove_first_gallery_shortcode will then remove the first gallery shortcode that it finds in the
* content, from the front page, so that we only output the first one once, above our content, and not again, within
* our content.
*
@richaber
richaber / filter_oembed.php
Created January 11, 2016 05:08
Filter the WordPress oembed_fetch_url and oembed_result to maintain URL query args
<?php
/**
* Add params back to oEmbed provider request URL.
*
* WordPress runs the embed URL through urlencode prior to constructing it's oEmbed provider endpoint call.
* This renders any passed in URL query params useless for Vimeo embeds (and probably others).
* This filter function will decode those URL query param, and add them as proper query args to the provider URL.
*
* The first function param, $provider, is the oEmbed provider endpoint.
@richaber
richaber / README.md
Last active February 29, 2016 16:19
VVV

I use HomeBrew as my OSX package manager.

I'm using Varying Vagrant Vagrants (VVV) from 10up as a MAMP replacement.

I use Variable VVV (vv) as a wizard to spin up new sites in VVV.

It is worth noting that VVV uses NGINX, not Apache. Not a deal breaker for me, but could be for others.

Install HomeBrew (assuming this is Mac OS X)

<?php
class StephanisAddition {
public static function add_two_numbers( $number_one, $number_two ) {
if ( ! is_numeric( $number_one ) || ! is_numeric( $number_two ) ) {
return null;
}
return $number_one + $number_two;
}
@richaber
richaber / replace-zero-width-space.php
Created July 7, 2016 01:07 — forked from ahmadazimi/replace-zero-width-space.php
PHP replace Zero Width Space using preg_replace
<?php
/**
* http://stackoverflow.com/questions/11305797/remove-zero-width-space-characters-from-a-javascript-string
* U+200B zero width space
* U+200C zero width non-joiner Unicode code point
* U+200D zero width joiner Unicode code point
* U+FEFF zero width no-break space Unicode code point
*/
@richaber
richaber / gitflow-breakdown.md
Created July 7, 2016 22:14 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

@richaber
richaber / README.md
Created August 1, 2017 22:29
Install WordPress Coding Standards (WPCS), WordPressVIPMinimum, and PHPCompatibility

Install the WordPress Coding Standards (WPCS), WordPressVIPMinimum, and PHPCompatibility sniffs for use with PHPCS.

Install the sniffs, with git, into home dir…

cd ~
git clone https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git
git clone https://github.com/Automattic/VIP-Coding-Standards.git
git clone https://github.com/wimg/PHPCompatibility.git
@richaber
richaber / GIF-Screencast-OSX.md
Created August 17, 2017 21:50 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@richaber
richaber / README.md
Created October 12, 2017 21:06
Don't try adding SVG support to WordPress yourself

Don't do this:

/**
 * Enable SVG mime types.
 *
 * @param array $mimes Current allowed mime types.
 * @return array Updated allowed mime types.
 */
function prfx_custom_mime_types( $mimes ) {