Skip to content

Instantly share code, notes, and snippets.

View joshuadavidnelson's full-sized avatar

Joshua Nelson joshuadavidnelson

View GitHub Profile
@thomasgriffin
thomasgriffin / gist:d5fd056b8b3dbae1ecbe
Last active August 29, 2015 14:07
Remove any posts from the featured content slider that do not have images in Soliloquy.
<?php
add_filter( 'soliloquy_fc_slider_data', 'tgm_sol_remove_no_image' );
function tgm_sol_remove_no_image( $data ) {
// Loop through the data and remove any items that don't have images.
foreach ( (array) $data['slider'] as $id => $item ) {
if ( empty( $item['src'] ) ) {
unset( $data['slider'][$id] );
}
}
@jaredatch
jaredatch / gist:3764381
Last active October 10, 2015 22:58
Customize image size used in the loop by Genesis
<?php
/**
* Customize image size used in the loop by Genesis
*
* @author Jared Atchison
* @link http://jaredatchison.com/code/
* @param string $image_size
* @global array $wp_query
* @global int $loop_counter
* @return string
@WPsites
WPsites / gist:3935417
Created October 22, 2012 23:21
WPMU Gravity Form functions.php
<?php
/*
Filter the gravity form shortcode output to retreive the form from the main site
*/
add_filter('gform_shortcode_form', 'gform_shortcode_form_mu_override',10,3);
function gform_shortcode_form_mu_override( $shortcode_string, $attributes, $content ){
function remove_post_type_page_from_search() {
global $wp_post_types;
$wp_post_types['page']->exclude_from_search = true;
}
add_action('init', 'remove_post_type_page_from_search');
<?php
/**
* Project Quote
*
*/
function be_project_quote() {
global $wp_query, $be_testimonials;
if( !( ( 5 < $wp_query->found_posts && 5 == $wp_query->current_post % 6 ) || ( $wp_query->current_post == ( $wp_query->found_posts - 1 ) && 5 > $wp_query->found_posts ) ) )
@Drethic
Drethic / admin.js
Last active June 6, 2016 03:15
Basic example of how to use the jQuery Validate library to display errors on the admin side of WordPress in conjunction with jaredatch / Custom-Metaboxes-and-Fields-for-WordPress.
jQuery(document).ready(function($) {
$('.cmb_id__prefix_layout_option').find('td').append('<div id="_prefix_layout_option_error" class="alert alert-error text-center"></div>');
$('input[name="_prefix_layout_option"').addClass('layout_option');
$('.cmb_id__prefix_thank_you_url').find('td').append('<div id="_prefix_thank_you_url_error" class="alert alert-error text-center"></div>');
$('input[name="_prefix_thank_you_url"').addClass('thank_you_url');
$("#post").validate({
//debug: true,
ignore: [],
wrapper: 'p',
@adamplabarge
adamplabarge / gf-acf-image-attachment-maker.php
Last active October 27, 2016 20:41
GF-ACF image attachment maker
<?php
//* the the default upload path to work in normal WP structure
add_filter("gform_upload_path", "change_upload_path", 20, 2);
function change_upload_path($path_info, $form_id){
$wp_upload_path = wp_upload_dir();
$path_info["path"] = $wp_upload_path['path'] . '/';
$path_info["url"] = $wp_upload_path['url'] . '/';
return $path_info;
@jtsternberg
jtsternberg / cmb-toggle-fields.css
Last active May 11, 2017 20:30
hidden-toggle for cmb. Works like the WordPress metabox toggle (but for only a selection of fields)
.advanced-toggle .toggle-label {
cursor: pointer;
display: block;
line-height: 3em;
border-bottom: 1px solid #e9e9e9;
border-left: 1px solid #e9e9e9;
border-right: 1px solid #e9e9e9;
padding-left: .8em;
}
.advanced-toggle .inside .cmb-row {
@webaware
webaware / gravity-forms-fields-above.php
Created May 12, 2014 03:39
Move Gravity Forms field labels from below to above fields in compound fields (e.g. Address, Name)
<?php
/*
Plugin Name: Gravity Forms Fields Above
Plugin URI: https://gist.github.com/webaware/24e1bacb47b76a6aee7f
Description: move field labels from below to above fields in compound fields (e.g. Address, Name)
Version: 1
Author: WebAware
Author URI: http://webaware.com.au/
@link http://www.gravityhelp.com/forums/topic/change-position-of-sub-labels-on-advanced-fields
@amdrew
amdrew / gist:07cec5563ab95720dca5
Created December 18, 2014 04:43
Easy Digital Downloads - Add specific download to cart if it doesn't already exist
<?php
/**
* Add a specific download to the cart if not already there
*/
function sumobi_edd_add_download_to_cart_if_empty() {
$download_id = 123;
$cart = function_exists( 'edd_get_cart_contents' ) ? edd_get_cart_contents() : false;