Skip to content

Instantly share code, notes, and snippets.

View joshuadavidnelson's full-sized avatar

Joshua Nelson joshuadavidnelson

View GitHub Profile
@joshuadavidnelson
joshuadavidnelson / modify-soliloquy-slider.php
Created August 7, 2014 17:10
Modify a Soliloquy Slider's content
<?php
/**
* Modify a static image slider by adding recent posts.
*
* @author Joshua David Nelson, josh@joshuadnelson.com
*/
add_filter( 'soliloquy_output_after_container', 'jdn_soliloquy_add_custom_slides', 11, 2 );
function jdn_soliloquy_add_custom_slides( $slider, $data ) {
global $soliloquy_data;
@joshuadavidnelson
joshuadavidnelson / gf-geo-lat-long.php
Last active August 29, 2015 14:05
Save latitude and longitude to fields in Gravity Form submission using Geo My WP Input for Address
<?php
/**
* Save latitude and longitude to fields in Gravity Form submission using Geo My WP Plugin
*
* @author Joshua David Nelson, josh@joshuadnelson.com
*/
add_filter( 'gform_pre_submission', 'jdn_set_lat_long_values', 10, 5 );
function jdn_set_lat_long_values( $form ){
// find the location value
@joshuadavidnelson
joshuadavidnelson / debug-wordpress.php
Created August 11, 2014 14:39
Change the debug settings depending on the environment
<?php
/**
* Change the debug settings depending on the environment
*
* Add this to your wp-config file
*
* @link http://www.paulund.co.uk/debugging-wordpress
*/
switch( $_SERVER['SERVER_NAME']) {
@joshuadavidnelson
joshuadavidnelson / obfuscate-email.php
Last active April 17, 2024 08:34
Obfuscate an email address output with PHP and CSS
<?php
/**
* Obfuscate an email address php output with some CSS help
*
* @author Joshua David Nelson, josh@joshuadnelson.com
* Based on:
* @link http://perishablepress.com/best-method-for-email-obfuscation/
*/
// PHP Output - replace the $instance['email'] with whatever input/variable is storing your clean email address
@joshuadavidnelson
joshuadavidnelson / gform-notification-to-email-address.php
Created August 27, 2014 16:48
Replace the notifcation 'to' email address for a gravity form (untested code, example for comment reply)
<?php
/**
* @link http://joshuadnelson.com/user-dropdown-list-custom-notification-routing-gravity-forms/#comment-2611
*/
add_filter( 'gform_notification_1', 'route_user_email_notification', 10, 3 ); // replace the '_1' with your form id
function route_user_email_notification( $notification, $form , $entry ) {
$location = '';
$service = '';
foreach( $form['fields'] as &$field ) {
@joshuadavidnelson
joshuadavidnelson / remove-genesis-cpt-metaboxes.php
Last active January 3, 2020 01:46
Remove Genesis Custom Post Type Archive Settings Metaboxes
<?php
/**
* Remove metaboxes from Genesis Custom Post Type Archive Settings
*
* @author Joshua David Nelson, josh@joshuadnelson.com
*/
add_action( 'genesis_cpt_archives_settings_metaboxes', 'jdn_remove_genesis_cpt_metabozes' );
function jdn_remove_genesis_cpt_metabozes( $_genesis_cpt_settings_pagehook ) {
@joshuadavidnelson
joshuadavidnelson / gform-state-abbriv.php
Last active August 29, 2015 14:06
Change gravity form default state names to abbreviations
<?php
/**
* Replace default state names with abbreviations
*
* @author Joshua David Nelson, josh@joshuadnelson.com
*/
add_filter('gform_address_types', 'jdn_gform_address_types', 10, 2);
function us_address($address_types, $form_id){
$address_types['us'] = array(
'label' => 'United States',
@joshuadavidnelson
joshuadavidnelson / slug-body-class.php
Created September 11, 2014 00:24
Add page/post slug to the body class in WordPress
<?php
/**
* Add the post/page slug to the body class
*/
add_filter( 'body_class', 'jdn_slug_body_class' );
function jdn_slug_body_class( $classes ) {
global $post;
$classes[] = $post->post_name;
return $classes;
<?php
// Variables used in this script:
// $summary - text title of the event
// $datestart - the starting date (in seconds since unix epoch)
// $dateend - the ending date (in seconds since unix epoch)
// $address - the event's address
// $uri - the URL of the event (add http://)
// $description - text description of the event
// $filename - the name of this file for saving (e.g. my-event-name.ics)
//
@joshuadavidnelson
joshuadavidnelson / style.css
Created September 18, 2014 20:13
Style for complex helper text in gravity form
div.gform_wrapper .ginput_complex label {
font-size: 14px;
font-style: italic;
color: #a1a1a1;
padding-left: 5px;
}