Skip to content

Instantly share code, notes, and snippets.

View badfeather's full-sized avatar

Brad Thomason badfeather

View GitHub Profile
@johnregan3
johnregan3 / wp-amp-tutorial-primary-nav.php
Last active February 13, 2019 16:39
Adding a Primary Navigation Menu to an AMP WordPress Theme
<?php
/**
* Register the amp-sidebar component script with WP AMP.
*
* This goes in your amp.php
*/
function jr3_amp_sidebar_component_script( $data ) {
$data['amp_component_scripts']['amp-sidebar'] = 'https://cdn.ampproject.org/v0/amp-sidebar-0.1.js';
return $data;
}
@kirandash
kirandash / Gravity Forms + Bootstrap
Created July 14, 2016 10:00
Helpful function for adding Bootstrap classes to Gravity Forms fields.
<?php
/**
* Gravity Forms Bootstrap Styles
*
* Applies bootstrap classes to various common field types.
* Requires Bootstrap to be in use by the theme.
*
* Using this function allows use of Gravity Forms default CSS
* in conjuction with Bootstrap (benefit for fields types such as Address).
*
@nickmeagher
nickmeagher / functions.php
Created March 3, 2016 04:22
Taxonomy Term Template Children Inheritance - Children terms inherit the parent taxonomy template.
/**
* Filter the taxonomy hierarchy to inject a parent level of templates.
*
* @param string $template The current template.
* @return string Filtered taxonomy template.
*/
function new_tax_hierarchy( $template ) {
$term = get_queried_object();
// If not an object, or the object doesn't have a taxonomy, bail.
@gfscott
gfscott / wordpress-embed-soundcloud-mini-player.php
Last active February 14, 2023 14:21
Wordpress function to switch auto-embed Soundcloud player from large "visual" version to "mini"
<?php
/////////////////////////////////////////////////////////////////////////////////////
// Ask Wordpress to Embed Soundcloud’s Mini Player Instead of the Large Visual Player
/////////////////////////////////////////////////////////////////////////////////////
// Add function to theme’s functions.php file
// Relevant documentation:
// https://wordpress.org/support/topic/hookfilter-for-auto-embed-function-of-wp
// https://wordpress.org/support/topic/filter-hook-for-built-in-oembed-providers-eg-youtube
// https://developers.soundcloud.com/docs/oembed
@lumpysimon
lumpysimon / .gitignore
Last active April 5, 2022 00:37
A .gitignore file for WordPress that ignores pretty much everything except for the specified plugin(s), theme(s) and mu-plugins folder
# .gitignore file for WordPress that ignores everything except:
#
# - .gitignore
# - favicon.ico
# - wp-config.php
# - everything in mu-plugins
# - my-plugin
# - my-theme (except for .sass-cache)
#
# based on https://gist.github.com/jdbartlett/444295
@brenna
brenna / wp-autopopulate-taxonomy
Last active December 26, 2022 23:29
WordPress function to auto-populate a taxonomy with a custom post type's entries.
function custom_tax_init(){
//set some options for our new custom taxonomy
$args = array(
'label' => __( 'My Custom Taxonomy' ),
'hierarchical' => true,
'capabilities' => array(
// allow anyone editing posts to assign terms
'assign_terms' => 'edit_posts',
/* but you probably don't want anyone
@hucklesby
hucklesby / dabblet.css
Created October 18, 2013 23:02
Fit caption to the width of any image
/**
* Fit caption to the width of any image
*/
.captioned-figure {
display: table;
table-layout: fixed;
}
.captioned-figure img {
margin-bottom: 10px;
border: 0;
@bueltge
bueltge / attachment-taxononimies.php
Created December 6, 2012 11:38
WordPress Attachment Taxonomies with WP 3.5*
<?php
/**
* Plugin Name: Attachment Taxonomies
* Plugin URI: attachment_taxonomies
* Text Domain: addquicktag
* Domain Path: /languages
* Description:
* Version: 1.0.0
* Author: Frank Bültge
* Author URI: http://bueltge.de
@jo-snips
jo-snips / events-conditional-wrappers.php
Last active December 21, 2023 12:27
The Events Calendar: Basic Conditional Wrappers
<?php
/*-----------------------------------------------------------------------------------*/
/* Conditional Logic to Detect Various Event Related Views/Pages
/*-----------------------------------------------------------------------------------*/
if( tribe_is_month() && !is_tax() ) { // Month View Page
echo 'were on the month view page';
} elseif( tribe_is_month() && is_tax() ) { // Month View Category Page
@necolas
necolas / snippet.js
Created June 14, 2011 20:36
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],