Skip to content

Instantly share code, notes, and snippets.

View trepmal's full-sized avatar
🍪

Kailey Lampert trepmal

🍪
View GitHub Profile
//track views
function pmpro_report_login_wp_views()
{
//don't track admin
if(is_admin())
return;
global $current_user;
//track for user
if(!empty($current_user->ID))
@trepmal
trepmal / debug-rest-api.php
Last active March 1, 2018 22:38
Intended for use alongside Debug Bar tools. Do not use in Production.
<?php
/**
* Plugin Name: Debug Bar for REST API
* Description: Enable Debug Bar for REST API endpoints (add ?debug). Not for production.
* Author: Kailey "trepmal" Lampert
*/
namespace trepmal\rest_debug;
/**
@trepmal
trepmal / pw-at-signup.php
Created December 20, 2011 21:58
WordPress: Choose password at registration (Multisite)
<?php
//Plugin Name: Choose password at registration (Multisite)
//Description: Doesn't change the confirmation screen or email
add_action('signup_extra_fields', 'ask_for_password');
function ask_for_password( $errors ) {
if ( $errmsg = $errors->get_error_message('bad_password') ) {
echo '<p class="error">'.$errmsg.'</p>';
}
<?php
if ( !defined( 'WP_CLI' ) ) return;
/**
*/
class trepmal_cURL_REST extends WP_CLI_Command {
/**
* Generate cURL command for REST API
@trepmal
trepmal / imageftbbox-output.txt
Created December 13, 2013 05:12
imageftbbox() returns an array with 8 elements representing four points making the bounding box of the text http://www.php.net/manual/en/function.imageftbbox.php
// attempting to understand imageftbbox()'s output
// Array
// (
// [0] => -1 lower left corner, X position
// [1] => 6 lower left corner, Y position
// [2] => 115 lower right corner, X position
// [3] => 6 lower right corner, Y position
// [4] => 115 upper right corner, X position
// [5] => -21 upper right corner, Y position
@trepmal
trepmal / ajax-password-protected.php
Last active July 16, 2017 12:14
[WordPress] Ajax Password Protected Posts. Updated and moved to https://github.com/trepmal/ajax-password-protected
<?php
/*
Plugin Name: Ajax Password Protected
Plugin URI: https://github.com/trepmal/ajax-password-protected
Description: Ajax-ified password-protected form
Version: 0.1
Author: Kailey Lampert
Author URI: http://kaileylampert.com
Copyright (C) 2012 Kailey Lampert
<?php
/**
* Plugin Name: Dev Plugins
*/
add_action( 'muplugins_loaded', function() {
// Plugins to activate automatically.
$auto_activate = [
'debug-bar/debug-bar.php',
'debug-bar-extender/debug-bar-extender.php',
<some-command> | tee some.log ; \
  ( [[ ${PIPESTATUS[0]} -eq 1 ]] \
  && (tail some.log | mail -s '<some-command> exited with error' you@example.com) \
  || (tail some.log | mail -s '<some-command> finished' you@example.com) )

breakdown:

| tee some.log;

@trepmal
trepmal / multi-feat-img.php
Created November 16, 2012 20:30
[WordPress] Do multiple featured-image-esque meta boxes
<?php
/*
Plugin Name: Multiple Featured Images
Description: NOT production ready. May cause tears.
Version: 2012.12.13
Author: Kailey Lampert
Author URI: kaileylampert.com
*/
new MFI_Meta_Box( 'derp', 'Derp Image', '200', '400', 'post' );
@trepmal
trepmal / gallery-conversion.php
Last active February 6, 2017 00:03
Extract attachment IDs from selection, reinsert as gallery shortcode.