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
<?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 {
var some_var = 'something';
var func = function() {
console.log( some_var ); // logs "something"
};
func();

Disable Plugins

Quickly disable all plugins in WordPress.

Usage

This plugin needs to go into the wp-content/mu-plugins/ directory. Provided you have SSH access to the server where WordPress lives, you can do this:

cd $SITE_ROOT/wp-content/mu-plugins
@jtsternberg
jtsternberg / colliding.js
Last active October 31, 2022 18:43 — forked from JayWood/colliding.js
Detect if two elements are colliding/overlapping
/**
* Detects if two elements are colliding
*
* Credit goes to BC on Stack Overflow, cleaned up a little bit
*
* @link http://stackoverflow.com/questions/5419134/how-to-detect-if-two-divs-touch-with-jquery
* @param $div1
* @param $div2
* @returns {boolean}
*/
@jtsternberg
jtsternberg / wdscamp_noms.md
Last active September 21, 2015 19:28 — forked from ramiabraham/wdscamp_noms.md
[wdscamp 2015 wednesday dinner]

Chana Masala

feed like 5-6 people

  • 1 (15 ounce) can chickpeas
  • 1 onion, chopped
  • 1 tomatoes, chopped
  • 1 green chili pepper, chopped
  • 4 -5 garlic cloves, chopped
  • 1 inch gingerroot, chopped
<?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' );