Skip to content

Instantly share code, notes, and snippets.

View daronspence's full-sized avatar

Daron daronspence

View GitHub Profile
<?php
class WPMDBPro_Addon extends WPMDB_Base {
protected $version_required;
function __construct( $plugin_file_path ) {
$this->is_addon = true;
parent::__construct( $plugin_file_path );
}
function meets_version_requirements( $version_required ) {
<?php
class acf_field_gravity_forms extends acf_field {
function __construct() {
$this->name = 'gravity_forms_field';
$this->label = __( 'Gravity Forms', 'acf' );
$this->category = __( "Relational", 'acf');
$this->defaults = array(
'multiple' => 0,
@daronspence
daronspence / remove_acf_options_page.php
Created April 15, 2015 03:18
Remove an options page from the ACF Locations dropdown.
<?php
/**
* Remove ACFE Options Page from ACF Feild Groups Location
*
* @since 1.0
*/
add_filter('acf/location/rule_values/options_page', function( $choices ) {
unset( $choices['acfe-licenses'] ); // options sub page menu-slug
@daronspence
daronspence / publish-halt.js
Last active August 29, 2015 14:19
WTV Project Category Must Be Assigned
jQuery('#publish').on('click', function(e){
var $checkboxes = jQuery('#project_categorieschecklist input[name*="project_categories"][type="checkbox"]');
var checked = false;
var loop = jQuery.each( $checkboxes, function( i, el ){
if ( true == jQuery( el ).prop('checked') ){
checked = true;
return false; // bail early
}
@daronspence
daronspence / acfw-custom-template-directory.php
Last active August 29, 2015 14:22
ACFW Custom Template Directory
add_filter( 'acfw_custom_template_dir', 'my_acfw_custom_directory' );
function my_acfw_custom_directory( $template_dir ){
$template_dir = get_stylesheet_directory() . '/my-templates/';
return $template_dir;
}
@daronspence
daronspence / quick-edit.php
Created July 8, 2015 01:49
Quick Edit Plugin
<?php
/**
* Plugin Name: Quick Edit Pro
* Plugin Author: Daron Spence
* Version: 0.1
*/
add_action( 'quick_edit_custom_box', function( $column_name, $post_type ){
if ( 'post' === $post_type && 'post_excerpt' === $column_name ){ ?>
@daronspence
daronspence / custom-fields-no-dep.php
Last active August 29, 2015 14:25
Rendering post meta from a plugin.
<?php
add_filter( 'the_content', function( $content ){
$extra_content = get_post_meta( 'extra_content', $post->ID );
if ( ! empty($extra_content ) )
return $content . $extra_content ;
else
return $content;
@daronspence
daronspence / custom-image-no-theme-hack.php
Created July 27, 2015 16:22
Add a background image via a custom field and no theme hacking.
<?php
add_filter( 'the_content', function( $content ){
// Just pretend you have a custom metabox that saves the ID for you.
$image_id = get_post_meta( 'custom_image', $post->ID );
$image_src = ''; // instantiate variable
if ( !empty( $image_id ) ){
$image_src = wp_get_attachment_image_src( $image_id, 'large');
}
<?php
/*
Template Name: Restuarant Menu Template
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
@daronspence
daronspence / invite.html
Created August 5, 2015 02:00
Mandrill ToDo Invite Template
<html>
<body>
<h2 mc:edit="title"></h2>
<p>
This message was generated from <a href="http://todo.daronspence.com/">ToDo App</a>. Come by and check out what we're all about :)
</p>
<div mc:edit="main""></div>