Skip to content

Instantly share code, notes, and snippets.

View joshuadavidnelson's full-sized avatar

Joshua Nelson joshuadavidnelson

View GitHub Profile
@joshuadavidnelson
joshuadavidnelson / gravity-form-cmb2-options.php
Last active August 5, 2018 17:28
A function to return an array of gravity forms for a CMB2 select field.
<?php
/**
* Get an array of gravity forms.
*
* @since 1.0.0
*
* @return void
*/
function jdn_gf_options() {
$form_array = array();
@joshuadavidnelson
joshuadavidnelson / remove-home-from-genesis-breadcrumps.php
Created February 21, 2016 21:12
Filter out the "home" from genesis breadcrumbs.
<?php
/**
* Remove the "home" value from the genesis breadcrumbs.
*
* @since 1.0.0
*
* @param array $crumbs
* @param array $args
* @return array
@joshuadavidnelson
joshuadavidnelson / basic-dropdown-usage.php
Last active February 27, 2023 13:44
Filter wp_dropdown_categories by post type.
<?php
/**
* Using wp_dropdown_categories with the post type filter applied.
*
* @link https://joshuadnelson.com/category-taxonomy-dropdown-filtered-by-post-type/
*/
// Taxonomy dropdown arguments
$args = array(
'taxonomy' => 'department',
@joshuadavidnelson
joshuadavidnelson / menu-breadcrumbs.php
Last active February 29, 2016 06:37
Possible route to passing duplicate menu items in Menu Breadcrumbs through a filter for use in the theme. Per https://github.com/jchristopher/menu-breadcrumb/issues/7
<?php
/**
* Retrieve the current Menu item object for the current Menu.
*
* @since 1.0.0
* @return bool|WP_Post The current Menu item
*/
public function get_current_menu_item_object() {
$current_menu_item = false;
@joshuadavidnelson
joshuadavidnelson / get-event-add-to-calendar.php
Last active February 5, 2016 18:13
Helper functions for compiling date and ical outputs with event calendar
<?php
/**
* Get the "Add to Calendar" button output, used with addevent.com service.
*
* @see https://www.addevent.com/buttons/add-to-calendar
*
* @uses event_is_multiday()
* @uses wp_trim_characters()
*
* @param int $post_id
@joshuadavidnelson
joshuadavidnelson / wp-darksky-weather-icon-example.php
Last active August 17, 2017 09:57
Extending the WP-DarkSky helper class and adding some Weather Icons by Eric Flowers.
<?php
/**
* A helper class for that extends the WP-DarkSky helper class with Weather Icons.
*
* You'll need to add the Weather Icons stylesheet, web fonts, etc and enqueue them correctly.
*
* @see weathericons.io
* @see https://developer.wordpress.org/reference/functions/wp_enqueue_style/
* @see https://darksky.net/dev/docs/
*
<?php
/**
* Basic example of WP-DarkSky useage.
*
* @since 01-04-2017 - Updated for new Dark Sky API & Naming
*
* @link https://github.com/joshuadavidnelson/wp-darksky
* @author Joshua David Nelson, [email protected]
*/
@joshuadavidnelson
joshuadavidnelson / forecast-io.php
Created February 1, 2016 06:11
Typical Forecast.io JSON Response (show here for
Array (
[latitude] => 48.7502
[longitude] => 122.475
[timezone] => Asia/Shanghai
[offset] => 8
[currently] => Array
(
[time] => 1454306959
[summary] => Clear
[icon] => clear-day
@joshuadavidnelson
joshuadavidnelson / wp-forecast-io.php
Last active February 1, 2016 04:47
A helper class for making Forecast.io calls in WordPress. Refer to the main git: https://github.com/joshuadavidnelson/wp-forecast-io This gist is for demo purposes and may not be up to date.
<?php
/**
* A helper class for the forecast.io api.
*
* Inspired by forecast-php by Guilherm Uhelski: https://github.com/guhelski/forecast-php
*
* @see https://developer.forecast.io/docs/v2
*
* @link https://github.com/joshuadavidnelson/wp-forecast-io
*
@joshuadavidnelson
joshuadavidnelson / basic-transient-function.php
Created January 3, 2016 20:49
Basic Transient function
<?php
/**
* Featured projects.
*
* @since 1.0.0
*
* @return void
*/
function child_home_projects() {