Skip to content

Instantly share code, notes, and snippets.

View danemorgan's full-sized avatar

Dane Morgan danemorgan

View GitHub Profile
@kingkool68
kingkool68 / basic-class-with-actions-and-filters.php
Created May 4, 2018 18:27
A basic example of a class using actions and filters in WordPress
<?php
class Thing {
/**
* Get an instance of this class
*/
static function get_instance() {
static $instance = null;
if ( null === $instance ) {
$instance = new static();
$instance->setup_actions();
@justintadlock
justintadlock / parent-theme-mod-fallback.php
Last active June 20, 2021 22:38
Get theme mods that fall back to the stored parent theme mod if child theme is active.
<?php
/**
* The purpose of this code is to show how you can use theme mods that will fall back to
* the already-set mods of the parent theme. So, when a child theme is active, the code
* checks, in the following order: 1) child theme mod, 2) parent theme mod, 3) default.
*/
function jt_get_theme_mod( $name, $default = false ) {
if ( is_child_theme() )
@davidakennedy
davidakennedy / a11y-theme-review.txt
Created February 14, 2016 21:37
A collection of review template responses for WordPress theme reviews.
Hi there!
Thanks for creating a WordPress theme and submitting it to the WordPress.org directory! Since your theme also includes the accessibility-ready tag, I've also reviewed it according to those requirements, which you can find here: https://make.wordpress.org/themes/handbook/review/accessibility/
Required
Anything in this section will need to be fixed before the theme can be approved.
Keyboard Navigation
@lyoshenka
lyoshenka / wget.sh
Created August 6, 2014 12:24
Archive/mirror a whole site with wget
wget --mirror --page-requisites --continue --convert-links --user-agent="" --execute robots=off --wait 1 URL
@wpexplorer
wpexplorer / gist:6416006
Last active December 22, 2015 04:19
Add slug to menu ID for pages in WordPress menu
add_filter('nav_menu_link_attributes' , 'att_add_menu_id', 3, 10);
if ( !function_exists( 'att_add_menu_id') ) {
function att_add_menu_id($atts, $item, $args) {
if( 'page' == $item->object ){
$id = $item->object_id;
$id = 'page-'. esc_attr( basename( get_permalink( $id ) ) );
$atts['id'] = $id;
}
return $atts;
}
@GaryJones
GaryJones / functions.php
Last active August 25, 2018 11:44
Conditionally add IE style sheets in WP
<?php
add_action( 'wp_print_styles', 'child_add_ie7_style_sheet', 200 );
/**
* Enqueue an IE-specific style sheet (for all browsers).
*
* @author Gary Jones
* @link https://garyjones.io/ie-conditional-style-sheets-wordpress
*/
function child_add_ie7_style_sheet() {