Skip to content

Instantly share code, notes, and snippets.

Avatar

Joshua Nelson joshuadavidnelson

View GitHub Profile
@joshuadavidnelson
joshuadavidnelson / example-output.html
Last active Sep 22, 2020
Using WordPress responsive images for css background-image property, in-line styling
View example-output.html
<style>
.header {
background-image: url(http://local.dev/wp-content/uploads/2016/04/image-300x151.png)
}
@media only screen and (min-width: 300px) {.header {
background-image: url(http://local.dev/wp-content/uploads/2016/04/image-768x386.png)
}}
@media only screen and (min-width: 768px) {.header {
background-image: url(http://local.dev/wp-content/uploads/2016/04/image-1024x515.png)
}}
@joshuadavidnelson
joshuadavidnelson / basic-dropdown-usage.php
Last active Sep 2, 2020
Filter wp_dropdown_categories by post type.
View basic-dropdown-usage.php
<?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 / allow-shortcodes-in-genesis-archive-intro.php
Created Jan 27, 2017
Allow shortcodes in the intro text output of Genesis archives.
View allow-shortcodes-in-genesis-archive-intro.php
<?php
/**
* Allow shortcodes in genesis archive intro text.
*
* @author Joshua David Nelson, josh@joshuadnelson.com
**/
// Custom Post Type Archive Intro Text
add_filter( 'genesis_cpt_archive_intro_text_output', 'do_shortcode' );
@joshuadavidnelson
joshuadavidnelson / git-commit-after-plugin-update.php
Last active Jun 27, 2020
Create a commit for every plugin update.
View git-commit-after-plugin-update.php
<?php
/**
* Plugin Name: Commit on Update
* Plugin Author: Joshua David Nelson
**/
defined( 'ABSPATH' ) or die( 'Nope!' );
class Commit_On_Update {
@joshuadavidnelson
joshuadavidnelson / get-responsive-image.php
Created Mar 22, 2017
Generate a img tag for responsive images in WordPress
View get-responsive-image.php
<?php
/**
* Get the responsive image.
*
* @param string $image_id
* @param string $image_size optional
*
* @return string $output
*/
function get_respsonsive_image( $image_id, $size = 'medium' ) {
@joshuadavidnelson
joshuadavidnelson / gf-upload-file-to-media-library.php
Last active Apr 29, 2020
Create a media file on upload, requires the JDN_Create_Media_File class from https://gist.github.com/joshuadavidnelson/164a0a0744f0693d5746
View gf-upload-file-to-media-library.php
<?php
/**
* Create a new media library entry with a file upload on gravity form submission.
* @see https://joshuadnelson.com/connect-gravity-forms-file-upload-to-acf-gallery-field/
* @author Joshua David Nelson, josh@joshuadnelson.com
*/
$gravity_form_id = 1; // gravity form id, or replace {$gravity_form_id} below with this number
add_filter( "gform_after_submission_{$gravity_form_id}", 'jdn_add_image_to_media_library', 10, 2 );
function jdn_add_image_to_media_library( $entry, $form ) {
View gravity-form-to-acf-image-field-fornt-end-posting.php
<?php
/**
* Connect a Gravity Form File Upload Field to an ACF Image Field.
* @see https://joshuadnelson.com/connect-gravity-forms-file-upload-to-acf-gallery-field/
*/
$gravity_form_id = 1; // gravity form id, or replace {$gravity_form_id} below with this number
add_filter( "gform_after_submission_{$gravity_form_id}", 'jdn_set_acf_gallery_field', 10, 2 );
function jdn_set_acf_gallery_field( $entry, $form ) {
$gf_images_field_id = 7; // the upload field id
@joshuadavidnelson
joshuadavidnelson / add-upload-attachments.php
Last active Feb 19, 2020
User Dropdown List and Custom Notification Routing in Gravity Forms. See the walkthrough:
View add-upload-attachments.php
<?php
/**
* Add the file uploads to the emails
*
* @author Joshua David Nelson, josh@joshuadnelson.com
*
* @link http://www.gravityhelp.com/documentation/page/Gform_user_notification_attachments
* @link http://www.gravityhelp.com/documentation/page/Gform_notification
**/
@joshuadavidnelson
joshuadavidnelson / remove-genesis-cpt-metaboxes.php
Last active Jan 3, 2020
Remove Genesis Custom Post Type Archive Settings Metaboxes
View remove-genesis-cpt-metaboxes.php
<?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 / remove-genesis-layout-settings-from-customizer.php
Created Jan 1, 2020
Remove the Genesis Layout settings in Customizer
View remove-genesis-layout-settings-from-customizer.php
<?php
// Remove layout settings from customizer
add_filter( 'genesis_customizer_theme_settings_config', 'jdn_filter_genesis_customizer_theme_settings' );
function jdn_filter_genesis_customizer_theme_settings( $config ) {
if( isset( $config['genesis']['sections']['genesis_layout'] ) )
unset( $config['genesis']['sections']['genesis_layout'] );
return $config;
You can’t perform that action at this time.