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
// Takes you to the site's base url and appends '/wp-admin'
javascript:(function(){ var url = !window.location.origin ? window.location.protocol+'//'+window.location.host : window.location.origin; window.open(url+'/wp-admin'); })();
<?php
function prefix_show_latest_tweet() {
if ( ! class_exists( 'TwitterWP' ) )
require_once( 'path_to/TwitterWP.php' );
// get data for current post author
$curauth = get_userdata( $post->post_author );
$twitter_id = $curauth->twitter;
<?php
// Do this so that the chapel_get_client_options WP_Query/get_posts ONLY happens
// when the field is run (otherwise this query will run on EVERY wordpress page-load,
// whether page has CMB2 fields or not)
public function chapel_get_client_options_cb() {
return chapel_get_client_options( array( 'post_type' => ' clients ', 'numberposts' => -1 , 'orderby' => 'name', 'order' => 'ASC' ) );
}
function chapel_project_metaboxes() {
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Grid of products.
*
* @author WooThemes
* @category Widgets
@jtsternberg
jtsternberg / ugh.php
Last active June 9, 2016 17:20 — forked from bradp/ugh.php
dont_do_this
<?php
//dis like the best code ever
function register() {
$msg = '';
if ( empty( $_POST ) ) {
return 'Fill out the form, dummy!';
}
@jtsternberg
jtsternberg / gethooks
Last active July 8, 2016 02:02 — forked from ramiabraham/gethooks
Copy all actions and filters in a plugin and save to a file.
#!/bin/bash
#
# Prints all hooks in a dir to a .log file.
#
# Permissions issues:
# run: chmod +x gethooks
#
# gist: https://gist.github.com/ramiabraham/e8356e00130351ddcbe2c62125e6c52a
#
# Easy usage:
<?php
function maybe_disable_cmb2_styles( $enabled ) {
if ( ! is_admin() ) {
$enabled = false;
}
return $enabled;
}
add_filter( 'cmb2_enqueue_css', 'maybe_disable_cmb2_styles' );
@jtsternberg
jtsternberg / home.php
Created February 13, 2012 21:45 — forked from gregrickaby/home.php
Genesis Custom Loop w/ Featured Image
<?php
$odd_or_even = 'even';
$loop_2 = new WP_Query( 'cat=1&showposts=2&orderby=date&order=DESC' ); while ($loop_2->have_posts()) : $loop_2->the_post(); ?>
<div <?php post_class( $odd_or_even ); ?>>
<?php $odd_or_even = ( 'odd' == $odd_or_even ) ? 'even' : 'odd'; ?>
<div class="column-5 left">
<a href="<?php the_permalink(); ?>" /><?php the_post_thumbnail( 'thumbnail', array( 'class' => 'featured-image' ) ); ?></a>
<a href="<?php the_permalink(); ?>" /><span class="read-more">Read More</span></a>
<?php
/**
* A class filled with functions that will never go away upon theme deactivation
*
* @package WordPress
* @subpackage GRD
* @version 0.1.0
*/
class GRD_Functions {
@jtsternberg
jtsternberg / markdown.css
Last active June 30, 2018 22:42 — forked from imjasonh/markdown.css
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: #333;
cursor: default;
margin: 0;
padding: 0;