Skip to content

Instantly share code, notes, and snippets.

@technosailor
technosailor / gist:7976564
Created December 15, 2013 18:45
Saves default WordPress edit page filters as usermeta
<?php
/*
Plugin Name: AB Edit Filter Save
Version: 0.1
Author: Aaron Brazell
Author URI: http://technosailor.com
Description: Saves default WordPress edit page filters as usermeta
License: GPLv2
*/
class AB_Filter_Save {
<<<<<<< HEAD
filterLists.init($('.filter-list-item'), function (o) {
for (var i = 0; i < o.length; i++) {
var closestBucket = $('.filter-'+o[i]+'-bucket').parents('.filter-bucket').find('.filter-toggle-btn');
filterCollapse.closed(closestBucket);
}
$('.sidebar .filter-bucket').slideDown();
});
=======
<?php
class Some_Child_Theme {
public function __construct() {
$this->hooks();
}
public function hooks() {
@technosailor
technosailor / gist:5365754
Last active December 16, 2015 02:49
When moving a WordPress Multisite blog to a standalone WordPress install that will then be converted to Multisite with new subsites... we can't have users having capabilities and other usermeta that are iodentified for a particular blog id that will change in the future. So this monstrosity selects everything except options that are prefixed wp_…
CREATE OR REPLACE
VIEW v AS
SELECT DISTINCT(meta_key)
FROM wp_usermeta
WHERE NOT( meta_key REGEXP '^wp_5_{1}')
AND (meta_key REGEXP '^wp_(.)+');
DELETE FROM wp_usermeta
WHERE meta_key IN
(SELECT * FROM v);
UPDATE wp_usermeta
@technosailor
technosailor / ab-duplicate-blog-ms.php
Last active December 14, 2015 12:59
Class to duplicate one Multisite blog to another
<?php
/*
Plugin Name: AB Duplicate Blog
Author: Aaron Brazell
Version: 1.0-beta
Description: Duplicate a WordPress Multisite blog into a new one, transferring options, taxonomies, etc
*/
class AB_Duplicate_Blog {
<?php
class AF_Metaboxes {
public function __construct() {
$this->hooks();
}
public function hooks() {
add_action( 'add_meta_boxes', array( $this, 'metaboxes' ) );
<?php
class Example_Plugin_Class {
public function __construct()
{
$this->hooks();
}
protected function hooks()
{
<?php
/**
* Logs messages/variables/data to browser console from within php
*
* @param $name: message to be shown for optional data/vars
* @param $data: variable (scalar/mixed) arrays/objects, etc to be logged
* @param $jsEval: whether to apply JS eval() to arrays/objects
*
* @return none
* @author Sarfraz
@technosailor
technosailor / HTML5 Foirms jQuery
Created September 5, 2012 20:35
BAsic HTML5 form structure with HTML5 validation and jQuery/JS handling of the form based on HTML5 validation status
<form onsubmit="return false;">
<input title="U.S. or Canadian Zip or Postal code is required" pattern="(\d{5}([\-]\d{4})?)|[A-Za-z][0-9][A-Za-z][ -]?[0-9][A-Za-z][0-9]" type="text" name="zip" value="" placeholder="Zip/Postal Code *" required />
<input title="Phone number in form 123-456-7890 is required" pattern="(\d{3}-?\d{3}-?\d{4})" type="tel" name="phone" placeholder="Phone *" required />
<input type="submit" name="submit" value="Submit" />
</form>
<script>
jQuery(document).ready(function(){
HTML5 U.S. Zip Code/Canadian Postal code Validation
<input class="lead-zip full-wide" title="U.S. or Canadian Zip or Postal code is required" pattern="(\d{5}([\-]\d{4})?)|[A-Za-z][0-9][A-Za-z] [0-9][A-Za-z][0-9]" type="text" name="lead-zip" placeholder="Zip Code *" required />