Skip to content

Instantly share code, notes, and snippets.

<?php
$email = isset( $_GET['email'] ) ? $_GET['email'] : 'null';
$salt = isset( $_GET['salt'] ) ? $_GET['salt'] : '';
// hash email, split it up
$hash = str_split( sha1( $email . $salt ), 2 );
// use first 3 values for foreground
$foreground = "{$hash[0]}{$hash[1]}{$hash[2]}";
@ninnypants
ninnypants / sync-ms-users.php
Created April 13, 2013 23:49
Sync all users to newly created blogs
<?php
/*
Plugin Name: Sync Users
Plugin URI: http://ninnypants.com
Description: Sync users to new blogs as a subscriber
Version: 1.0
Author: ninnypants
Author URI: http://ninnypants.com
License: GPL2
@ninnypants
ninnypants / gist:5170883
Created March 15, 2013 15:54
Download latest WordPress unzip and add keys
<?php
$fp = fopen('wordpress.zip', 'w');
$ch = curl_init('http://wordpress.org/latest.zip');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
exec('unzip wordpress.zip');
exec('cp -R wordpress/* .');
exec('rm wordpress.zip');
@ninnypants
ninnypants / gist-oembed.php
Created February 28, 2013 05:51
Quick WordPress plugin to add gists to oEmbed
<?php
/*
Plugin Name: Gist oEmbed
Plugin URI: http://ninnypants.com
Description: Embed gists into posts
Version: 1.0
Author: ninnypants
Author URI: http://ninnypants.com
License: GPL2
@ninnypants
ninnypants / display-site-ids.php
Created February 28, 2013 04:38
Show ID column in multisite Sites list table
<?php
/*
Plugin Name: Show Multisite IDs
Plugin URI: http://ninnypants.com
Description: Adds table column to show site ID
Version: 1.0
Author: ninnypants
Author URI: http://ninnypants.com
License: GPL2
@trepmal
trepmal / easy-albums.php
Last active December 14, 2015 02:09
Put a group of galleries into an album, then put the album in a page.
<?php
// Better version over here:
// https://github.com/trepmal/Easy-Albums
//Plugin Name: Easy Albums
//Description: Put a group of galleries into an album, then put the album in a page.
/*
Quick release!
@trepmal
trepmal / gallery-conversion.php
Last active February 6, 2017 00:03
Extract attachment IDs from selection, reinsert as gallery shortcode.
@trepmal
trepmal / resize-original-upload.php
Last active September 30, 2020 10:38
resize new uploads to fit max dimensions
<?php
/*
Plugin Name: Resize Original Upload
*/
add_filter('wp_handle_upload', 'max_dims_for_new_uploads', 10, 2 );
function max_dims_for_new_uploads( $array, $context ) {
// $array = array( 'file' => $new_file, 'url' => $url, 'type' => $type )
// $context = 'upload' || 'sideload'
@ninnypants
ninnypants / allow-iframes.php
Created February 15, 2013 20:15
Allow iframe tags in wp editor
<?php
/*
Plugin Name: Frameitron
Plugin URI: http://ninnypants.com
Description: Allow iframes in tinymce for all user levels
Version: 1.0
Author: ninnypants
Author URI: http://ninnypants.com
License: GPL2
@trepmal
trepmal / password-form-referer.php
Created September 21, 2012 02:44
[WordPress] Referer for password protected posts
<?php
/*
On an archive-type page, password-protected posts can be odd.
If the post is near the bottom, hitting submit reloads the page
taking you back to the top. This will simply change the referer
so that you are brought back to the post after clicking the
submit button on the password form.
*/