Skip to content

Instantly share code, notes, and snippets.

Avatar

Mitchell D. Miller mitchelldmiller

View GitHub Profile
@mitchelldmiller
mitchelldmiller / qm_wp_roles.php
Created Jan 7, 2019
get email addresses for a WordPress role.
View qm_wp_roles.php
<?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 Jan 2, 2019
Update WordPress plugin on command line, from slug.
View update_wp_plugin.sh
#! /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 / clear_wp.sh
Last active Jan 25, 2019
Delete WordPress files before calmPress update
View clear_wp.sh
#! /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 / quick-mail-first-name-shortcode.php
Created May 14, 2017
shortcode to add recipient's first name to Quick Mail email message
View quick-mail-first-name-shortcode.php
<?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 Feb 4, 2016
WordPress filter to allow editors to edit Quick Mail user display options
View quick_mail_filter_display_options.php
<?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 Feb 4, 2016
How to modify Quick Mail sender permission
View filter_quick_mail_sender_permission.php
<?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 Mar 2, 2015
Import production WordPress database to localhost without plugin update error
View import_wordpress_db_to_localhost.sh
#! /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 Aug 29, 2015
Find out if your WordPress blog contains posts with more than one category
View mdm_wp_multiple_categories.php
<?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.
*/
You can’t perform that action at this time.