Skip to content

Instantly share code, notes, and snippets.

View butlerblog's full-sized avatar

Chad Butler butlerblog

View GitHub Profile
@butlerblog
butlerblog / header_overlap_fix.css
Created November 5, 2018 13:11
Fix header overlap with anchor links (Genesis)
: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 September 20, 2022 20:05
#utility to get plugin info
<?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 August 14, 2018 13:30
Code for description of adding label tags to radio field type items
<?php
/**
* Create form label.
*
* @since 3.1.7
*
* @param array $args {
* @type string $meta_key
* @type string $label_text
@butlerblog
butlerblog / login_out_menu_item.php
Last active August 4, 2018 22:27
login/out jQuery menu item
<?php
/**
* Now maintained on rocketgeek.com:
*
* https://rocketgeek.com/code-snippets/login-out-jquery-menu-item/
* https://rocketgeek.com/tips-and-tricks/use-jquery-to-create-a-log-inlog-out-menu-link/
* https://rocketgeek.com/plugins/wp-members/docs/login-logout-menu-link/
*/
@butlerblog
butlerblog / functions.php
Last active March 28, 2024 02:09
SMTP using wp-config.php for settings #smtp #wp_mail
<?php // Don't use this line.
/*
* Add the script below to wherever you store custom code snippets
* in your site, whether that's your child theme's functions.php,
* a custom plugin file, or through a code snippet plugin.
*/
/**
* This function will connect wp_mail to your authenticated
@butlerblog
butlerblog / filter_wp_mail_to_addr.php
Last active July 19, 2021 17:29
Change the #wp_mail "to" address based on subject
<?php
/**
* This is a filter for wp_mail(). It checks the subject
* for the presence of a given string (in this case "New
* User Registration"), and if that returns true it
* sets the "to" address/value.
*/
add_filter( 'wp_mail', 'my_wp_mail_filter' );
function my_wp_mail_filter( $args ) {
@butlerblog
butlerblog / wpmem_block.php
Last active January 28, 2017 02:42
blocking filters
<?php // ignore this line
add_filter( 'wpmem_block', 'my_block_function' );
function my_block_function( $block ) {
/*
* The plugin tests for pages and posts
* to be blocked or unblocked based on
* the plugin's settings, then tests for
* custom field overrides, then sends the
@butlerblog
butlerblog / lastname-firstname-user-sort.php
Created December 22, 2016 05:37 — forked from ramseyp/lastname-firstname-user-sort.php
Sorted the return of a Wp_User_Query by both the last name value and the first name value. This way, if multiple users have the same last name, those particular users are then sorted by first name.
<?php
function s25_member_loop() {
$args = array(
'role' => 'member', // the role we're targeting
'exclude' => '1', // exclude admin
'fields' => 'all_with_meta',
'meta_key' => 'last_name', //query on the last_name key
'meta_key' => 'first_name', // also the first_name key
);
$membersquery = new WP_User_Query( $args );
@butlerblog
butlerblog / add_wrappers.php
Last active August 9, 2018 22:03
Workarounds for builder plugin wrappers
<?php
// Now included with write up here:
// https://rocketgeek.com/tips-and-tricks/handling-form-layout-when-using-a-builder-plugin/
@butlerblog
butlerblog / wpmem_add_custom_email.php
Last active November 24, 2021 18:39
WP-Members #API functions
<?php
add_action( 'wpmem_after_admin_init', 'my_add_custom_wpmembers_email' );
function my_add_custom_wpmembers_email() {
// Required arguments for wpmem_add_custom_email()
$tag = 'my_unique_msg_tag';
$heading = 'Heading to display input in Emails tab';
$subject_input = 'my_unique_subj_tag';
$message_input = 'my_unique_body_tag';