Skip to content

Instantly share code, notes, and snippets.

@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 / keybase.md
Created April 14, 2020 03:49
keybase.md

Keybase proof

I hereby claim:

  • I am pospi on github.
  • I am pospi (https://keybase.io/pospi) on keybase.
  • I have a public key ASBxJoVjLhHN_8kL5a3J_EdAoEIQJM_yJ5Ho0Esk7e0giAo

To claim this, I am signing this object:

@pospi
pospi / escaped-implode-explode.php
Created September 24, 2013 01:54
Like PHP's implode() and explode(), but lets you escape the delimiters for splitting the strings with.
<?php
/**
* Same as implode, but escape the separator when it exists in the array elements being imploded
* If the separator is longer than 1 character, only the first character need be escaped (not every character of the delimiter).
*
* @param string $sep delimiter to stich the array together with
* @param array $arr array to combine
* @param char $escape escape character to escape any found delimiters with
* @return imploded string
@pospi
pospi / check-for-popup-blocking.js
Created August 28, 2014 23:47
Detect blocked popup windows in all browsers
window.isPopupBlocked = function(popup_window, cb)
{
var CHROME_CHECK_TIME = 2000; // the only way to detect this in Chrome is to wait a bit and see if the window is present
function _is_popup_blocked(popup)
{
return !popup.innerHeight;
}
if (popup_window) {
@pospi
pospi / .gitignore
Last active September 14, 2017 23:24
Detects old Slack channels for archival / cleanup
/.env
/node_modules

Keybase proof

I hereby claim:

  • I am pospi on github.
  • I am pospi (https://keybase.io/pospi) on keybase.
  • I have a public key whose fingerprint is 206C E2FF 7800 BCF2 5107 35A0 1874 6681 1287 C5D9

To claim this, I am signing this object:

@pospi
pospi / init-private-npm-modules-yarn.sh
Last active October 22, 2016 01:45
Sets up NPM module linkage when using private modules from your own registry (using Yarn instead of NPM)
#!/usr/bin/env bash
#
# Helper script to setup symlinks and modules for services integration during development
#
# @depends http://stedolan.github.io/jq/
# @depends https://yarnpkg.com/
#
# :WARNING:
# Your global npm packages must be installed for the current user in order for this script to work.
# If this is not the case, we recommend you nuke your global npm folder and replace with an nvm-managed
@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 / fix-wpmu-permastruct.php
Created December 5, 2013 04:41
Remove forced `/blog/` prefix added to main site permastruct in Wordpress multisite environments
<?php
global $WPMUPermastructFix;
$WPMUPermastructFix = new MultisitePermastructFix();
class MultisitePermastructFix
{
public function __construct()
{
// start the checking process for main multisite blog. Will strip forced '/blog/' from the start.
@pospi
pospi / init-private-npm-modules.sh
Last active October 10, 2016 06:34
Sets up NPM module linkage when using private modules from your own registry
#!/usr/bin/env bash
#
# Helper script to setup symlinks and modules for services integration during development
#
# @depends http://stedolan.github.io/jq/
#
# :WARNING:
# Your global npm packages must be installed for the current user in order for this script to work.
# If this is not the case, we recommend you nuke your global npm folder and replace with an nvm-managed
# node install in your homedir, which will have the correct permissions for `npm link` to function.