Skip to content

Instantly share code, notes, and snippets.

View butlerblog's full-sized avatar

Chad Butler butlerblog

View GitHub Profile
@butlerblog
butlerblog / auto-login-from-reg-email.php
Last active November 5, 2021 15:44
WordPress auto login from native registration email
<?php
/*
This code snippet can be added to your functions.php file (without the <?php)
to add a query string to the login link emailed to the user upon registration
which when clicked will validate the user, log them in, and direct them to
the home page.
*/
/**
* This first function is hooked to the 'user_register' action which fires
@butlerblog
butlerblog / test_wp_mail.php
Last active August 25, 2019 03:25
File for testing the wp_mail function http://b.utler.co/9L
<?php
/**
* This file can be used to validate that the WordPress wp_mail() function is working.
* To use, change the email address in $to below, save, and upload to your WP root.
* Then browse to the file in your browser.
*
* For full discussion and instructions, see the associated post here:
* http://b.utler.co/9L
*
* Author: Chad Butler
@butlerblog
butlerblog / wp_config.php
Last active February 1, 2024 09:00
Configure WordPress #wp_mail function to send through #SMTP server https://b.utler.co/Y3
<?php
/*
* Set the following constants in wp-config.php.
* These should be added somewhere BEFORE the constant ABSPATH is defined.
*
* Author: Chad Butler
* Author URI: https://butlerblog.com
*
* For more information and instructions, see: https://b.utler.co/Y3
@butlerblog
butlerblog / qnd-wp-mail.php
Last active August 29, 2015 14:18
A quick-and-dirty plugin to filter the email from address and name
<?php
/*
Plugin Name: QnD wp_mail filter
Plugin URI: http://butlerblog.com/
Description: A quick and dirty plugin to change the wp_mail "from" address to be something other than wordpress@mydomain.com.
Version: 1.2
Author: Chad Butler
Author URI: http://butlerblog.com/
License: GPLv2
*/
@butlerblog
butlerblog / return_mirror_sender.php
Last active November 22, 2021 22:58
Set the mail return path to mirror the sender in #wp_mail to reduce likelihood of spam rejection
add_action( 'phpmailer_init', 'fix_my_email_return_path' );
function fix_my_email_return_path( $phpmailer ) {
$phpmailer->Sender = $phpmailer->From;
}
<?php
/**
* Customize Event Query using Post Meta
*
* @author Bill Erickson
* @link http://www.billerickson.net/customize-the-wordpress-query/
* @param object $query data
*
*/
@butlerblog
butlerblog / file-uploader.php
Last active March 12, 2016 16:48
Basic file upload handler for WP-Members
<?php
// Add to your functions.php file below this line.
/**
* Basic file uploader script for WP-Members.
*
* This code snippet handles file uploads when the "file" field type is
* selected for a registration field. Note that this snippet is basic and
* is not intended to be a full featured solution. Please do not ask me
* for support unless you are already a premium support subscriber at
@butlerblog
butlerblog / wp-members-disable-new-user-notify.php
Last active September 8, 2015 17:33
Plugin to disable the sending of the new user registration email when the user is created in the Users > All Users screen. This file can be saved to the /wp-content/plugins/ then activated from the plugins menu.
<?php
/*
Plugin Name: WP-Members Disable New User Notification
Plugin URI: http://rocketgeek.com
Description: Disables the WP new user notification email when user is created via the Users > Add New screen.
Version: 1.0
Author: Chad Butler
Author URI: http://butlerblog.com/
License: GPLv2
*/
<?php
add_action( 'admin_bar_menu', 'wpse15186_admin_bar_menu' );
function wpse15186_admin_bar_menu( &$wp_admin_bar )
{
$menu = wp_get_nav_menu_object( 'WPSE 15186 test menu' );
$menu_items = wp_get_nav_menu_items( $menu->term_id );
$wp_admin_bar->add_menu( array(
'id' => 'wpse15186-menu-0',
'title' => 'WPSE 15186 menu',
<?php
function keyword_density_js(){
?>
<script src="<?php bloginfo('template_url'); ?>/js/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.wordstats.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.wordstats.en.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/highlight.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
var count = 8;