Skip to content

Instantly share code, notes, and snippets.

View trepmal's full-sized avatar
🍪

Kailey Lampert trepmal

🍪
View GitHub Profile
@trepmal
trepmal / toggle-debug.php
Last active September 4, 2020 15:42
WordPress experiment. Toggle debug from admin bar
<?php
/*
Plugin Name: Toggle Debug
Description: Proof-of-concept for an admin-bar debug mode toggle. Needs some UX love.
*/
/*
// In wp-config.php, wrap debug constants in a cookie conditional
if ( isset( $_COOKIE['wp-debug'] ) && $_COOKIE['wp-debug'] == 'on' ) {
define('WP_DEBUG', true);
}
#!/bin/bash
echo "post_id,post_title,image_path";
while read -r post_row
do
# --format=csv always has a header
if [[ "ID,post_title" == $post_row ]]; then
continue;
#!/bin/bash
#
# Call this file with the URL to test for as the only param
# `bash testurl.sh ms.test/doesthissiteexist`
#
# This script also assumes the multisite you're looking in is at /srv/www/ms
#
colorreset="\033[0;0m"
@trepmal
trepmal / wp.media.query.php
Last active August 12, 2019 14:08
wp.media.query() works in the console, but not when run like this in a plugin. halp?
<?php
/*
* Plugin Name: wp.media.query
* Plugin URI: trepmal.com
* Description:
* Version: 0
* Author: Kailey Lampert
* Author URI: kaileylampert.com
* License: GPLv2 or later
* TextDomain:
# Find your files in /tmp older than 7 days
find /tmp -mtime +7 -user `whoami` -exec ls -lpdh {} \; | column -t
# Delete your files in /tmp older than 7 days
find /tmp -type f -mtime +7 -user `whoami` -delete
find /tmp -type d -mtime +7 -user `whoami` -empty -delete
# Find your files in /home (2 dirs deep) older than 7 days
find /home -maxdepth 2 -mtime +7 -user `whoami` -exec ls -lpdh {} \; | column -t
@trepmal
trepmal / wlo-widget.php
Last active May 17, 2019 20:15
Use https://github.com/voceconnect/wp-large-options/ as storage for specific widget types
<?php
// Plugin Name: WLO Widget
// register core 'text' widget
register_wlo_widget( 'text' ); // id base
/**
* hook in
*/
function register_wlo_widget( $widget_id ) {
@trepmal
trepmal / change-network-admin-color-scheme.php
Last active December 10, 2018 21:08
Swap the Color Scheme between regular and Network admins. For WP3.8 (and beyond, probably)
<?php
// Plugin Name: Change Network Admin Color Scheme
if ( is_multisite() ) {
add_filter( 'style_loader_src', 'cnacs_intercept_admin_color', 10, 2 );
add_action( 'admin_color_scheme_picker', 'cnacs_network_admin_color_scheme_picker');
add_action( 'personal_options_update', 'cnacs_update_network_admin_option' );
add_action( 'edit_user_profile_update', 'cnacs_update_network_admin_option' );
}
@trepmal
trepmal / wpmandrill-ms.php
Last active December 10, 2018 20:56
Network-wide options for wpMandrill. Options in Network Admin > Settings > wpMandrill MS Overwrites any per-site settings. Removes Mandrill from each site's menu (does not prevent direct access via URL).
<?php
/*
* Plugin Name: wpMandrill MS
* Plugin URI: trepmal.com
* Description: Network-wide settings for wpMandrill.
* Version: 2013.04.01
* Author: Kailey Lampert
* Author URI: kaileylampert.com
* License: GPLv2 or later
* TextDomain: wpmandrill-ms
@trepmal
trepmal / gist:1566525
Created January 5, 2012 18:29
WordPress: Breadcrumb Functions
<?php
/*
Plugin Name: Breadcrumb Functions
Description: Functions for displaying breadcrumbs when working with hierarchical post types. Does nothing out-of-the-box, functions must be added to theme (directly or via hooks, your discretion).
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
*/
/*
Basic:
echo get_breadcrumbs( $post );
@trepmal
trepmal / user-meta-upload.php
Created June 1, 2012 20:32
User Meta Upload
<?php
/*
Plugin Name: User Meta Upload
Plugin URI: http://trepmal.com
Description: Add a file-upload form to the user edit profile page
Version: 0.1
Author: Kailey Lampert
Author URI: http://kaileylampert.com
Copyright (C) 2012 Kailey Lampert