Skip to content

Instantly share code, notes, and snippets.

View keybase.md

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 / gist:222db7df6aecedb2c5e7
Created Jun 4, 2014
Get files from prod if they don't exist on local dev / staging. Put this snippet BEFORE the WordPress rule in htaccess.
View gist:222db7df6aecedb2c5e7
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule wp-content/uploads/(.*) http://PRODUCTION_SERVER/wp-content/uploads/$1 [NC,L]
</IfModule>
@benmay
benmay / reset_user_roles.sql
Last active Aug 29, 2015
resets WP default user roles
View reset_user_roles.sql
UPDATE `wp_options` SET `option_value` = 'a:7:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:63:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1
View media-uploader-tweak.php
<?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' ) );
}
View subscribe-to-comments.php.diff
$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 / wp-cli.sh
Created Jul 9, 2013
Bash script used on dev server to create new WordPress sites.
View wp-cli.sh
#!/bin/sh
# Set DB Constants
DBHOST="localhost"
DBUSER="root"
DBPASS="123"
DBNAME="wp_$1"
# Set WP Constants
ADMIN_NAME="my_admin_account"
View js-cookies.js
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 Dec 16, 2015
Hacks to Pippity Version: 1.14.0.0 to remove jQuery and move JS to footer.
View pippity.php
<?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
*/
View category.php
if (is_category('some-category')):
query_posts('showposts=' . $limit . '&paged=' . $paged .'&cat=3');
View retune-admin.js
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();
You can’t perform that action at this time.