Skip to content

Instantly share code, notes, and snippets.

Avatar

Chad Butler butlerblog

View GitHub Profile
@butlerblog
butlerblog / find_callback.php
Last active Jul 19, 2021
#utility for finding callback functions hooked to a specific hook
View find_callback.php
<?php // do not use this line. Add below to functions.php
add_action( 'wp_footer', 'list_hooked_filters_and_actions' );
add_action( 'login_footer', 'list_hooked_filters_and_actions' );
add_action( 'admin_footer', 'list_hooked_filters_and_actions' );
function list_hooked_filters_and_actions() {
global $wp_filter;
@butlerblog
butlerblog / woocommerce-settings-tab-demo.php
Last active Nov 24, 2021 — forked from BFTrick/woocommerce-settings-tab-demo.php
A plugin demonstrating how to add a #WooCommerce settings tab.
View woocommerce-settings-tab-demo.php
<?php
/**
* Plugin Name: WooCommerce Settings Tab Demo
* Plugin URI: https://gist.github.com/BFTrick/b5e3afa6f4f83ba2e54a
* Description: A plugin demonstrating how to add a WooCommerce settings tab.
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@butlerblog
butlerblog / wp_mail_bcc.php
Last active Jul 19, 2021
#wp_mail add bcc based on contents of subject line
View wp_mail_bcc.php
<?php // DO NOT include this line. Add below to your theme functions.php
/**
* Add bcc address to email based on contents
* of the email subject line.
*
* Set email address and content of the subject
* line for the email being filtered.
*/
add_filter( 'wp_mail', 'custom_mails' );
@butlerblog
butlerblog / custom-queries.php
Created Nov 22, 2018 — forked from carlodaniele/custom-queries.php
An example plugin showing how to add custom query vars, rewrite tags and rewrite rules to WordPress
View custom-queries.php
<?php
/**
* @package Custom_queries
* @version 1.0
*/
/*
Plugin Name: Custom queries
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
@butlerblog
butlerblog / columns.css
Created Nov 14, 2018 — forked from studiopress/columns.css
Genesis column classes.
View columns.css
/* Column Classes
Link: http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css
--------------------------------------------- */
.five-sixths,
.four-sixths,
.one-fourth,
.one-half,
.one-sixth,
.one-third,
@butlerblog
butlerblog / 0.php
Last active Nov 12, 2018
How to use anonymous functions for simple filters
View 0.php
<?php
/**
* This gist is example code that goes with an article on how (and why/when) to use
* PHP anonymous functions. To view the entire post, go to:
* https://rocketgeek.com/basics/using-anonymous-functions-for-filters-and-actions/
*/
@butlerblog
butlerblog / mc_put_req.php
Last active Nov 24, 2021
#Mailchimp list subscribe "put" request
View mc_put_req.php
<?php
/**
* Utility function to subscribe a user to a MailChimp
* list using the MC API 3.0
*
* @param array $args {
* Array of settings.
*
* @type string $api_key Your MailChimp API key.
@butlerblog
butlerblog / header_overlap_fix.css
Created Nov 5, 2018
Fix header overlap with anchor links (Genesis)
View header_overlap_fix.css
:target::before {
content: "";
display: block;
height: 50px; /* fixed header height*/
margin: -50px 0 0; /* negative fixed header height */
}
@butlerblog
butlerblog / my_get_plugin_info.php
Last active Apr 12, 2022
#utility to get plugin info
View my_get_plugin_info.php
<?php // no need to use this line.
/**
* Utility to get information on installed plugins.
*
* Returns an array of all installed plugins and indicates which are
* plugin are active and which are not. Array is keyed by the plugin's
* folder/slug.php (which is how WP looks at them) and includes the
* name, version, and true/false whether it is active or not.
*
@butlerblog
butlerblog / create_field_label_orig.php
Last active Aug 14, 2018
Code for description of adding label tags to radio field type items
View create_field_label_orig.php
<?php
/**
* Create form label.
*
* @since 3.1.7
*
* @param array $args {
* @type string $meta_key
* @type string $label_text