Skip to content

Instantly share code, notes, and snippets.

westonruter / WidgetWithBehaviorScript.widget.php
Created May 6, 2010
WidgetWithBehaviorScript: Template for a WordPress widget which enqueues an accompanying behavior script; script only output if widget is rendered.
View WidgetWithBehaviorScript.widget.php
class WidgetWithBehaviorScript extends WP_Widget {
function __construct() {
parent::__construct(__CLASS__, 'Widget with Accompanying Behavior Script', array(
'classname' => __CLASS__,
'description' => "This WordPress widget serves as a pattern for how to enqueue a script only if the widget is actually rendered."
justintadlock / customize-control-radio-image.php
Last active Sep 5, 2018
Customize Control: Radio Image
View customize-control-radio-image.php
* The radio image customize control extends the WP_Customize_Control class. This class allows
* developers to create a list of image radio inputs.
* Note, the `$choices` array is slightly different than normal and should be in the form of
* `array(
* $value => array( 'url' => $image_url, 'label' => $text_label ),
* $value => array( 'url' => $image_url, 'label' => $text_label ),
* )`
View gist:228af6f96433e6557c3f
<?php // image gallery content
if( has_shortcode( $post->post_content, 'gallery' ) ) {
// Grab the first gallery in the post
$gallery = get_post_gallery_images( $post->ID );
$image_list = '<div class="owl-carousel">';
// Loop through each image in each gallery
foreach( $gallery as $image ) {
View Lab: Git

Now that you have Git on your system, you’ll want to do a few things to customize your Git environment. You should have to do these things only once on any given computer; they’ll stick around between upgrades. You can also change them at any time by running through the commands again.

Git comes with a tool called git config that lets you get and set configuration variables that control all aspects of how Git looks and operates.

Let's take a look at some common configurations that you might want to do:


git config --global "John Doe"
esthezia / php-sanitize-multidimensional-array.php
Created Jun 18, 2013
PHP - Sanitize a multidimensional array
View php-sanitize-multidimensional-array.php
* Sanitize a multidimensional array
* @uses htmlspecialchars
* @param (array)
* @return (array) the sanitized array
wpscholar / functions.php
Last active Mar 1, 2021
Enqueueing IE conditional stylesheets in WordPress the right way
View functions.php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link
krusynth /
Last active Jun 15, 2021
A list of useful books to improve your skills

Recommended Books

A list of useful books to improve your skills

Recommendations from others are noted in (parentheses). The rest are my personal recommendations.


Building your core

  • The Pragmatic Programmer - Hunt & Thomas
megasmack /
Last active May 24, 2022
LWC Focus-Trapping Modal

LWC Focus-Trapping Modal

Using SLDS classes, build a modal Lightning Web Component that has focus-trapping for accessiblity.

Notes: The shadowdom presents some challenges with creating focus-trapping within modals. Making creating a reusable component tricky. So instead we can create a modal utility file with all our methods to keep things as DRY as possible.

karimnaaji / GoogleFonts.txt
Created Jan 9, 2017
Google fonts list (TTF)
View GoogleFonts.txt
"kind": "webfonts#webfontList",
"items": [
"kind": "webfonts#webfont",
"family": "ABeeZee",
"category": "sans-serif",
"variants": [
DanHerbert /
Last active Oct 19, 2022
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

READ THIS Very Important Update

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.