Skip to content

Instantly share code, notes, and snippets.

View jaredrethman's full-sized avatar

Jared Rethman jaredrethman

View GitHub Profile
@jaredrethman
jaredrethman / _sDebugger.js
Last active January 18, 2024 16:26
Simple colorful console output
const COLOR_SCHEMES = {
success: [ '#FFFFFF', '#009b4b' ],
error: [ '#FFFFFF', '#ff3f71' ],
info: [ '#333333', '#11c7d7' ],
warning: [ '#FFFFFF', '#e87834' ],
};
const __sDebugger = ( {
type = 'info',
msg = null,
label = 'No Label',
@jaredrethman
jaredrethman / wp-plugins.js
Created November 20, 2019 18:04
A WP CLI equivalent for running `wp plugin list` as a Chrome Snippet. Will output a Markdown table of plugins.
(function() {
const pTable = document.getElementById('the-list');
const pRows = pTable.getElementsByTagName('TR');
let output = '| # | PLUGIN | ACTIVE | INSTALLED | CURRENT |\n';
output += '|-|-|-|-|-|\n';
for (let i = 0, m = pRows.length; i < m; i++) {
@jaredrethman
jaredrethman / polyfill-test.js
Last active October 27, 2019 01:08
Simple ES6+ Polyfill test. Transpile using babel.
window.POLYFILL_ALL_THE_THINGS = {
reduce: ['foo', 'bar', 'baz'].reduce( ( acc, v ) => {
return { ...acc, [`${v}_key`]: `${v}_value` };
}, [] ),
reduceRight: ['foo', 'bar', 'baz'].reduceRight( ( acc, v ) => {
return { ...acc, [`${v}_key`]: `${v}_value` };
}, {} ),
map: ['foo', 'bar', 'baz'].map( str => {
return str += ' 1';
} ),
<?php
/**
* Thumbnail Meta
*/
class Thumbnail_Meta
{
//Holds Media Fields
private $media_fields = [];
@jaredrethman
jaredrethman / taxonomy-image.php
Last active November 22, 2017 01:10
Small helper class for Wordpress Taxonomy image upload
//Based off - https://gist.github.com/mathetos/1eea92f71934442671a7
class Tax_Images {
public function __construct() {
//Enqueue Media JS/CSS
add_action( 'admin_enqueue_scripts', 'wp_enqueue_media' );
add_action( 'category_add_form_fields' , array( $this, 'ti_add_form_fields' ), 10, 2 );
add_action( 'category_edit_form_fields' , array( $this, 'ti_edit_form_fields' ), 10, 2 );
add_action( 'edited_category' , array( $this, 'ti_save_category_fields' ), 10, 2 );
// BASED on this article - http://www.bennadel.com/blog/2597-preloading-images-in-angularjs-with-promises.htm
// Preloading Images In AngularJS With Promises.
// I provide a utility class for preloading image objects.
TRMFullScreenApp.factory(
"preloader",
function( $q, $rootScope, $timeout ) {
// I manage the preloading of image objects. Accepts an array of image URLs.
function Preloader( imageLocations ) {
@jaredrethman
jaredrethman / buddypress_hasgroup.php
Last active February 3, 2020 08:14
Wordpress 3.9 TinyMCE 4 - Custom User state shortcode drop-down for loggedin, loggedout and loggedin and assigned to a buddypress group.
function my_user_has_group(){
global $bp;
if( !bp_has_groups( bp_ajax_querystring( 'groups' ).'&user_id='.bp_loggedin_user_id())) {
return false;
}else{
return true;
}
}