Skip to content

Instantly share code, notes, and snippets.

View mitchelldmiller's full-sized avatar

Mitchell D. Miller mitchelldmiller

View GitHub Profile
@mitchelldmiller
mitchelldmiller / banned_domain.php
Created January 11, 2021 02:18
Check for a banned domain from a standalone page.
<?php
/**
* Example of checking for a banned domain from a standalone page.
* Requires Quick Mail plugin version 4.0.5 or greater.
*/
require_once($_SERVER['DOCUMENT_ROOT'] . '/wp-load.php');
$domain = empty($_GET['domain']) ? 'example.com' : $_GET['domain'];
$desc = empty(QuickMailUtil::acceptable_domain($domain)) ? 'BANNED' : 'OK';
wp_die("{$domain} = {$desc}", $domain);
exit;
@mitchelldmiller
mitchelldmiller / clear_wp.sh
Last active January 25, 2019 18:53
Delete WordPress files before calmPress update
#! /bin/bash
rm -f index.php
rm -f license.txt
rm -f readme.html
rm -f wp-activate.php
rm -rf wp-admin
rm -f wp-blog-header.php
rm -f wp-comments-post.php
rm -f wp-config-sample.php
rm -f wp-cron.php
@mitchelldmiller
mitchelldmiller / qm_wp_roles.php
Created January 7, 2019 01:28
get email addresses for a WordPress role.
<?php
// get email addresses for a role.
// Usage: http://example.com/qm_wp_roles.php?role=author
require_once $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';
header( 'Content-type: text/plain' );
$input = empty( $_GET['role'] ) ? '' : strtolower( $_GET['role'] );
if ( empty( $input ) ) {
echo qm_show_usage();
exit;
@mitchelldmiller
mitchelldmiller / update_wp_plugin.sh
Created January 2, 2019 22:52
Update WordPress plugin on command line, from slug.
#! /bin/bash
if [ ! -z $1 ]; then
if [[ "$PWD" =~ "plugins" ]]; then
curl -OkLs https://downloads.wordpress.org/plugin/$1.zip
if [ -f $1.zip ]; then
if [ -d $1 ]; then
rm -rf $1
fi # if directory exists
unzip -qq $1.zip
rm -f $1.zip
@mitchelldmiller
mitchelldmiller / quick-mail-first-name-shortcode.php
Created May 14, 2017 17:29
shortcode to add recipient's first name to Quick Mail email message
<?php
// quick-mail-first-name-shortcode.php
/**
* get first name of Quick Mail recipient.
* for shortcode to add recipient's first name to Quick Mail email message.
* @return string first name of recipient or email address. question mark is n/a.
* @see https://wheredidmybraingo.com/tag/quick-mail/ Quick Mail WordPress Plugin
* @see https://wordpress.org/support/topic/add-user-name-to-email/ support request
*/
function qm_get_first_name() {
@mitchelldmiller
mitchelldmiller / quick_mail_filter_display_options.php
Created February 4, 2016 20:29
WordPress filter to allow editors to edit Quick Mail user display options
<?php
/**
* WordPress filter to allow editors to edit Quick Mail user display options.
*
* @param string $qm_user_capability
* @return string new requirement
* @link https://github.com/mitchelldmiller/quick-mail-wp-plugin
*/
function qm_setup_capability( $qm_user_capability )
{
@mitchelldmiller
mitchelldmiller / filter_quick_mail_sender_permission.php
Created February 4, 2016 19:32
How to modify Quick Mail sender permission
<?php
/**
* WordPress filter to modify the default Quick Mail sending permission.
*
* @param string $qm_user_capability
* @return string new requirement
* @link https://github.com/mitchelldmiller/quick-mail-wp-plugin
*/
function qm_sender_capability( $qm_user_capability )
{
@mitchelldmiller
mitchelldmiller / import_wordpress_db_to_localhost.sh
Created March 2, 2015 18:54
Import production WordPress database to localhost without plugin update error
#! /bin/bash
# import_wordpress_db_to_localhost.sh
#
# Easy to use to with multiple sites.
# Try:
# alias import_blog='import_wordpress_db_to_localhost.sh DB SQL user password'
#
if [ ! -z $1 ] && [ ! -z $2 ] && [ ! -z $3 ] && [ ! -z $4 ] && [ -f $2 ]; then
echo "Updating $1 with $2 and local settings"
# import database
@mitchelldmiller
mitchelldmiller / mdm_wp_multiple_categories.php
Last active August 29, 2015 14:08
Find out if your WordPress blog contains posts with more than one category
<?php
/**
* mdm_wp_multiple_categories.php
*
* Find out if your WordPress blog contains posts with more than one category.
*
* Use as a standalone page or a function with WordPress.
*
* Function uses param to return string message or count of posts with multiple categories.
*/