Skip to content

Instantly share code, notes, and snippets.

@pospi
pospi / reset-admin-ui.js
Created September 13, 2013 06:56
Reset the Wordpress admin UI to its default state after failing some clientside validation upon saving.
$('#publishing-action')
.find('.spinner').hide().end()
.find('#publish').removeClass('button-primary-disabled');
$('#save-action')
.find('.spinner').hide().end()
.find('#save-post').removeClass('button-disabled');
@pospi
pospi / wpengine-cdnurl.php
Last active October 14, 2016 08:11
Premodify URLs on WPEngine to directly point to your CDN. Avoids issues some link generators have with HTTP redirects.
<?php
function wpe_noRedirectUrl($srcURL)
{
if (class_exists('WpeCommon')) {
global $wpe_netdna_domains;
static $cdn_domain;
if (!isset($cdn_domain)) {
$wpe_common = new WpeCommon();
if ($wpe_common->is_cdn_enabled()) {
@pospi
pospi / adminboxshuffle.class.php
Last active July 5, 2020 15:18
Wordpress edit page metaboxes reshuffler: moves 'author' and 'revisions' boxes to the sidebar, and places the excerpt above the editor. Excerpt hint text is configurable.
<?php
add_action('add_meta_boxes', array('AdminBoxShuffle', 'repositionDefaultMetaboxes'), 0);
class AdminBoxShuffle
{
const EXCERPT_HINTTEXT = 'This excerpt is shown at the top of your posts and will form the preview text on gateway pages.';
/**
* Reposition default metaboxes
@pospi
pospi / hierarchy-sort.php
Last active December 22, 2015 10:19
Wordpress helper method for efficiently organising a hierarchical taxonomy into a hierarchical data structure. Similar code could be used to organise any hierarchical dataset.
<?php
/**
* Recursively sort an array of taxonomy terms hierarchically. Child categories will be
* placed under a 'children' member of their parent term.
*
* @param Array $cats taxonomy term objects to sort
* @param Array $into result array to put them in
* @param integer $parentId the current parent ID to put them in
*/
function sortHierarchicalTaxonomy(Array $cats, Array &$into, $parentId = 0)