Skip to content

Instantly share code, notes, and snippets.

View jtsternberg's full-sized avatar
😎
Awesome Motive-ing

Justin Sternberg jtsternberg

😎
Awesome Motive-ing
View GitHub Profile
@ColinHarrington
ColinHarrington / .gitconfig
Last active August 29, 2015 13:56
.gitconfig
[branch]
autosetuprebase = always
[mergetool "p4merge"]
cmd = /home/<username>/dir/to/p4v/bin/p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
keepTemporaries = false
trustExitCode = false
keepBackup = false
[merge]
@lswilson
lswilson / category-to-cpt.sql
Last active August 29, 2015 13:58
WordPress: SQL to migrate posts from a single category to its own custom post type
UPDATE wp_posts
inner join wp_term_relationships rel on wp_posts.id=rel.object_id
inner join wp_term_taxonomy tax on rel.term_taxonomy_id=tax.term_taxonomy_id
inner join wp_terms term on tax.term_id=term.term_id
set wp_posts.post_type='your_post_type'
WHERE
term.slug="category_name"
@jtsternberg
jtsternberg / wds-include-tlc-transients.php
Last active August 29, 2015 14:07
tlc-transients helper functions
<?php
// Include tlc lib
require_once WPMU_PLUGIN_DIR . '/wp-tlc-transients/tlc-transients.php';
/**
* Use in place of `get_posts`
*
* @param array $args Array of get_posts arguments
* @param integer $time Amount of time before cache expires
@jtsternberg
jtsternberg / modify-google-top-content-query-params.php
Created May 15, 2015 13:45
Modify the google analytics request params in the google top content plugin
<?php
/**
* Change metric from 'ga:pageViews' for top-content widget and shortcode
*
* @link https://ga-dev-tools.appspot.com/query-explorer/ Google's Query Explorer for more info
*
* @param array $params Array of request params
*
* @return array Modified array of request params
*/
@jtsternberg
jtsternberg / CMB2_Search_Get_Extra_Post_Data.php
Last active August 29, 2015 14:27
Update CMB2 Post Search Field to ajax-grab more post-data and use that to populate fields. https://github.com/WebDevStudios/CMB2-Post-Search-field
<?php
/**
* Modify CMB2-Post-Search-Field to output more than just an id
* @link https://github.com/WebDevStudios/CMB2-Post-Search-field
*/
class CMB2_Search_Get_Extra_Post_Data {
protected static $single_instance = null;
@bradp
bradp / say
Last active September 17, 2015 14:41
say
voices=(
Agnes
Albert
Alex
Alice
Alva
Amelie
Anna
Bad
Bahh
@jtsternberg
jtsternberg / instagram-importer-make-title-date.php
Last active April 27, 2016 01:34
Make instagram imported posts' titles to be the date of the imported image
<?php
/*
Plugin Name: DsgnWrks Instagram Importer - Make Title the Image Date
Plugin URI: http://dsgnwrks.pro/plugins/dsgnwrks-instagram-importer
Description: Set the title of your instagram posts to the date the image was taken
Author URI: http://dsgnwrks.pro
Author: DsgnWrks
Donate link: http://dsgnwrks.pro/give/
Version: 0.1.0
*/
@jtsternberg
jtsternberg / affection.js
Last active June 9, 2016 20:17
copy me to your console.
alert( [+[++[+[]][+[]]+[]+[[]+[][+[]]][+[]][++[++[++[+[]][+[]]][+[]]][+[]]]+[++[+[]][+[]]+[]][+[]]+[+[]]+[+[]]+[+[]]][+[]]+[]][+[]][+[]]+' <'+ ++[++[++[[]][+[]]][+[]]][+[]] +' '+[[][+[]]+[]][+[]][+[]] )
@jtsternberg
jtsternberg / wp.template-for-php.md
Last active June 30, 2016 17:14
First person to create a php parser for wp.template underscore templates wins my ♥️
@strangerstudios
strangerstudios / gist:5556801
Last active July 4, 2016 05:15
Replace backticks in WordPress posts, topics, replies, etc with <pre lang="PHP"></pre> so WP-Syntax will highlight it.
/*
Switch `` with <pre lang="PHP"></pre>
*/
function pmpro_code_wrap($content)
{
$content = preg_replace("/`(.*?)`/s", '<pre lang="PHP">$1</pre>', $content);
return $content;
}
add_filter("the_content", "pmpro_code_wrap", -1);