Skip to content

Instantly share code, notes, and snippets.

View joshuadavidnelson's full-sized avatar

Joshua Nelson joshuadavidnelson

View GitHub Profile
@joshuadavidnelson
joshuadavidnelson / search.php
Last active August 29, 2015 14:10
Search for limited to a caetgory
<?php
// Search form, limited to category
echo '<form method="get" action=" ' . home_url() . '/">';
echo '<input type="text" size="16" name="s" placeholder="Search" />';
// This will limit the search to the year shown on the template, if the year query var is present
if( $year = get_query_var( 'yr' ) ) {
echo '<input type="hidden" name="year" id="year" value="' . $year . '" />';
}
echo '<input type="hidden" name="cat" id="cat" value="19" />'; // replace value with category id
@joshuadavidnelson
joshuadavidnelson / query.php
Created December 8, 2014 06:32
SQL to get years of posts in specific category
<?php
// Custom query. Change the number in parenthesis on line 10 to your category id
$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts
FROM $wpdb->posts wp_posts INNER JOIN $wpdb->term_relationships
ON (wp_posts.ID = $wpdb->term_relationships.object_id)
INNER JOIN $wpdb->term_taxonomy
ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->term_taxonomy.term_id IN (1)
@joshuadavidnelson
joshuadavidnelson / remove-inpost-layout.php
Last active August 29, 2015 14:13
Remove Genesis Framework inpost layout box for posts only
<?php
/**
* Don't show layout box on posts, only pages
* @author Joshua David Nelson, josh@joshaudnelson.com
*/
add_action( 'init', 'jdn_remove_inpost_layouts' );
function jdn_remove_inpost_layouts() {
// Bail if it's not an admin
if( !is_admin() )
@joshuadavidnelson
joshuadavidnelson / plugin-dependency-check.php
Created January 21, 2015 23:00
Check for plugin requirements are met, deactivate and send up admin notice if not
<?php
/**
* Checks for dependencies, if not present it deactivates the plugin and sends up an admin notices
*
* Intended to be placed within a plugin singleton class, calling self::$instance->includes() or similar.
* Could be adapted to be in a regular class or classless
*
* @author Joshua David Nelson, josh@joshuadnelson.com
* @see http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*/
@joshuadavidnelson
joshuadavidnelson / custom-genesis-sidebar-alt.php
Created February 9, 2015 14:32
Custom sidebar(s) in Genesis Framwork - great for custom page templates and custom post types
<?php
/**
* Custom secondary sidebar for Genesis Framework.
*
* Use in your page template(s) or custom post type archive/single templates.
*
* @author Joshua David Nelson, josh@joshuadnelson.com
*/
// Custom Sidebar
@joshuadavidnelson
joshuadavidnelson / event-admin.js
Created February 19, 2015 21:02
All day toggle for BE Events Calendar with CMB
(function($){
$(document).ready(function(){
$(".cmb_option#event_all_day").bind("change",function(){
if ( $(this).is(':checked') ) {
$("#event_end_time").hide();
$("#event_start_time").hide();
if( $("#event_start_time").val() == '' ) {
$("#event_start_time").val("12:01 AM");
}

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

@joshuadavidnelson
joshuadavidnelson / cpt-helper.php
Last active August 29, 2015 14:16
post type helper functions
<?php
/**
* Remove post meta values.
*
* @since 1.0.0
*
* @uses remove_post_meta()
* @uses ic3_log_me()
*
* @param int|array|object $posts Accepts either the post ID, post object, or an array of either
jQuery.noConflict();
jQuery(document).ready(function(){
var table = jQuery( document.getElementsByClassName('agenda') );
var w = jQuery(window);
//Make a clone of our table
var fixedColumn = table.clone().insertBefore(table).addClass('fixed-column');
//Remove everything except for first column
fixedColumn.find('th:not(:first-child),td:not(:first-child)').remove();