Skip to content

Instantly share code, notes, and snippets.

View joelworsham's full-sized avatar

Joel Worsham joelworsham

View GitHub Profile
@joelworsham
joelworsham / dynamic-shortcode-scripts-pt1.php
Created January 30, 2015 16:43
Dynamic Shortcode Scripts
<?php
// Add our action
add_action( 'wp_enqueue_scripts', 'joelworsham_add_shortcode_styles' );
/**
* Dynamically calls scripts and styles based on the presence
* of shortcodes in the post content.
*/
function joelworsham_add_shortcode_styles() {
@joelworsham
joelworsham / gist:ca39eeacace703c368a4
Last active January 11, 2016 00:49
PHP Version Check
<?php
...
if ( version_compare( '5.3', phpversion(), '>' ) ) {
add_action( 'admin_notices', '_myplugin_php_notice' );
// Do what you need to stop your plugin from loading
}
/**
* Displays an admin error about needing to update the server's PHP version.
@joelworsham
joelworsham / wp-gruntfile-4.2.0.js
Last active August 29, 2015 14:21
The WordPress Gruntfile
/* jshint node:true */
module.exports = function(grunt) {
var path = require('path'),
SOURCE_DIR = 'src/',
BUILD_DIR = 'build/',
mediaConfig = {},
mediaBuilds = ['audiovideo', 'grid', 'models', 'views'];
// Load tasks.
require('matchdep').filterDev(['grunt-*', '!grunt-legacy-util']).forEach( grunt.loadNpmTasks );
@joelworsham
joelworsham / custom-roles.php
Created March 23, 2016 16:18
Custom Roles for DZS
<?php
/**
* Plugin Name: DZS Roles
* Description: Provides custom roles for the Detroit Zoo website.
* Author: Joel Worsham
* Author URI: http://realbigmarketing.com
* Version: 1.0.1
*/
if ( ! defined( 'ABSPATH' ) ) {
<?php
add_filter( 'wlmapi_the_members', function ( $members ) {
if ( $members && isset( $members['members'] ) && isset( $members['members']['member'] ) ) {
foreach ( $members['members']['member'] as &$member ) {
$member['agent_ambassadors'] = get_user_meta( $member['id'], 'agent_ambassadors', true );
$member['lender_ambassadors'] = get_user_meta( $member['id'], 'lender_ambassadors', true );
$member['agent_ambassador_default'] = get_user_meta( $member['id'], 'agent_ambassador_default', true );
@joelworsham
joelworsham / ld-gb-reorder-grades-pregetposts.php
Created October 18, 2016 18:37
LearnDash Gradebook re-order grades example
<?php
function my_modify_gradebook_type_posts( $wp_query ) {
// Make sure it's the proper query
if ( $wp_query->is_main_query() ||
$wp_query->get('post_type') != array( 'sfwd-assignment', 'sfwd-quiz' ) ||
! $wp_query->get('tax_query')
) {
return;
@joelworsham
joelworsham / ld-gb-reorder-grades-filtercomponents.php
Created October 18, 2016 18:45
LearnDash Gradebook re-order grades example 2
<?php
function my_modify_gradebook_type_components( $components ) {
if ( ! $components ) {
return $components;
}
foreach ( $components as $type_id => &$component ) {
// Foundation for Sites Settings
// -----------------------------
//
// Table of Contents:
//
// 1. Global
// 2. Breakpoints
// 3. The Grid
// 4. Base Typography
// 5. Typography Helpers
<?php
/**
* Modifies WP Pro Quiz so I can get the dang answers in the results.
*
* @since 0.1.0
* @package ME10
*/
// Don't load directly
if ( ! defined( 'ABSPATH' ) ) {