Skip to content

Instantly share code, notes, and snippets.

Avatar

david wolfpaw davidwolfpaw

View GitHub Profile
@davidwolfpaw
davidwolfpaw / gravity-forms-confirmation-remain.php
Created Mar 13, 2019
Keep Gravity Forms Displayed After Submission
View gravity-forms-confirmation-remain.php
// Allow the Gravity form to stay on the page when confirmation displays.
add_filter( 'gform_pre_submission_filter', 'dw_show_confirmation_and_form' );
function dw_show_confirmation_and_form( $form ) {
$shortcode = '[gravityform id="' . $form['id'] . '" title="true" description="false"]';
if ( array_key_exists( 'confirmations', $form ) ) {
foreach ( $form['confirmations'] as $key => $confirmation ) {
$form['confirmations'][ $key ]['message'] = $shortcode . '<div class="confirmation-message">' . $form['confirmations'][ $key ]['message'] . '</div>';
}
}
@davidwolfpaw
davidwolfpaw / wp-cli_site-setup.sh
Created Nov 9, 2018
A sample WP-CLI script to setup a new site with some defaults of our choosing.
View wp-cli_site-setup.sh
#!/bin/zsh
# delete the default plugins and themes that we don't need
wp plugin delete hello
wp theme delete twentyfifteen
wp theme delete twentysixteen
# install the themes and plugins that we do want
wp plugin install gutenberg --activate
wp plugin activate akismet
@davidwolfpaw
davidwolfpaw / genesis_post_link_shortcode.php
Created Sep 8, 2018
This is a custom shortcode to allow the link to a post while using the Genesis Framework for WordPress
View genesis_post_link_shortcode.php
<?php
/*
* This is a custom shortcode to allow the link to a post while using the Genesis Framework.
*
* It was created to fill the need of a loop that needed links to posts.
*/
add_shortcode( 'post_link', 'genesis_post_link_shortcode' );
/**
View class-cc-post-republisher-admin.php
/**
* Initializes the general settings by registering the Sections, Fields, and Settings.
*
* This function is registered with the 'admin_init' hook.
*/
public function initialize_general_settings() {
// Control title of republish
// Set Terms text
// Choose CC license to use
@davidwolfpaw
davidwolfpaw / wp_custom_install.sh
Created Jan 31, 2017
A starter script for creating a WordPress site on Vagrant using VVV, VV, VASSH, and WP-CLI
View wp_custom_install.sh
#!/bin/bash -e
# Ideas, Drawbacks, and Suggestions: https://davidlaietta.com/bash-scripting-to-automate-site-builds-with-wp-cli/
# Set up some defaults
wpuser='USERNAME'
email='USER@EMAIL.COM'
blueprint='BLUEPRINT-NAME'
clear
@davidwolfpaw
davidwolfpaw / gf_si_int.php
Created Sep 8, 2016
Gravity Forms / Sprout Invoices Pro Integration
View gf_si_int.php
/**
* Hook into all Gravity Form submissions, check to see if the form id
* matches the one we want to generate an invoice from, and process the
* submission if appropriate.
*
* @param arrat $entry Array of the GF entry
* @return null
*/
function maybe_process_gravity_form_and_create_invoice( $entry = array(), $form = array() ) {
@davidwolfpaw
davidwolfpaw / dynamic_date_dropdown_gravityforms.php
Created Aug 23, 2016
Dynamically generate list of dates in Gravity Forms Dropdown and remove past and previously selected dates
View dynamic_date_dropdown_gravityforms.php
<?php
/*
* Dynamically generate list of dates in Gravity Forms Dropdown and remove past and previously selected dates
*/
add_filter( 'gform_pre_render', 'dl_populate_dropdown' );
//Note: when changing drop down values, we also need to use the gform_pre_validation so that the new values are available when validating the field.
add_filter( 'gform_pre_validation', 'dl_populate_dropdown' );
@davidwolfpaw
davidwolfpaw / EDD_download_pre-restricted
Created Aug 4, 2014
Make pages automatically checked private in EDD, and select specific download buyers to restrict to
View EDD_download_pre-restricted
// Make pages automatically checked private in EDD, and select specific download buyers to restrict to
// Change val("86") to the option that you want pre-selected
add_action( 'admin_head', 'pw_edd_cr_admin_head', 20 );
function pw_edd_cr_admin_head() {
echo '<script type="text/javascript">jQuery(function($){ $("#edd_cr_active_only").attr("checked", "1"); $("#edd_cr_download_id").val("86"); });</script>';
}