Skip to content

Instantly share code, notes, and snippets.

@benmay
benmay / gist:3768884
Created September 23, 2012 04:34
tar website - excluding wp-uploads
tar -zcvf backup-name.tar.gz --exclude='wp-content/uploads/*' /var/www/site.com
@benmay
benmay / wp-cli.sh
Created July 9, 2013 11:58
Bash script used on dev server to create new WordPress sites.
#!/bin/sh
# Set DB Constants
DBHOST="localhost"
DBUSER="root"
DBPASS="123"
DBNAME="wp_$1"
# Set WP Constants
ADMIN_NAME="my_admin_account"
@benmay
benmay / single-user-loggin.php
Last active March 14, 2019 17:51
Ensures only one user at a time can be logged into WordPress, ie, 2 people can't login using the same account.
<?php
/*
Plugin name: Single user login
Plugin URI:
Description:
Author: Ben May
Author URI:
Version: 0.1
*/

Keybase proof

I hereby claim:

  • I am benmay on github.
  • I am benmay (https://keybase.io/benmay) on keybase.
  • I have a public key whose fingerprint is 5F8D B6B6 6366 342F E6E2 6CA7 0D9E 2C05 8DBA D0D8

To claim this, I am signing this object:

@benmay
benmay / media-uploader-tweak.php
Created December 7, 2013 09:58
Adds the ID col
<?php
Class MediaUploaderTweak {
static function run() {
add_filter( 'manage_media_columns', array( 'MediaUploaderTweak', 'cols' ), 1 );
add_action( 'manage_media_custom_column', array( 'MediaUploaderTweak', 'col' ), 1, 2 );
add_action( 'admin_head-upload.php', array( 'MediaUploaderTweak', 'admin_head' ) );
}
$email = $this->email;
global $wpdb;
- if($fix)
- {$fix = "comment_post_ID = $fix AND ";}
+ if($fix) {
+ $fix_comments = "comment_post_ID = $fix AND ";
+ $fix_postmeta = "post_ID = $fix AND ";
+ }
@benmay
benmay / js-cookies.js
Created April 24, 2013 06:16
js cookies
jQuery(document).ready(function($)
{
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
if (agentID)
{
if( $.cookie('my_cookie_name') == undefined )
{
$.cookie( 'my_cookie_name', 'true', { expires: 30 });
if ( confirm( "You're on an mobile device, you should download our app." ) ) {
@benmay
benmay / pippity.php
Last active December 16, 2015 14:28
Hacks to Pippity Version: 1.14.0.0 to remove jQuery and move JS to footer.
<?php
/*
Plugin Name: Pippity
Plugin URI: http://pippity.com
Description: Pippity is a popup plugin that your readers won't hate!
Version: 1.14.0.0
Author: Pippity LLC
Author URI: http://pippity.com
*/
if (is_category('some-category')):
query_posts('showposts=' . $limit . '&paged=' . $paged .'&cat=3');
jQuery(document).ready(function($) {
/* Array of ACF items we're working on */
var acf_items = new Array( 'acf-image', 'acf-pdf', 'acf-rtf', 'acf-audio_upload', 'acf-video_low_res', 'acf-video_high_res' );
/* hide all boxes */
acf_cleanup( 'none' );
/* check if there is a taxonomy set */
var selected_id = $('#mc-formatchecklist input:radio:checked').val();