Skip to content

Instantly share code, notes, and snippets.

View jakejackson1's full-sized avatar

Jake Jackson jakejackson1

View GitHub Profile
@jakejackson1
jakejackson1 / matryoshka-gvlogic-shortcodes.php
Last active February 9, 2024 22:05
Alias [gvlogic] 1000 times for deep nesting
<?php
/*
* Plugin Name: Alias [gvlogic] 1000 times for deep nesting
* Description: Because we can (but really shouldn't)
* License:GPLv2
*/
add_action( 'plugins_loaded', function () {
if ( ! class_exists( '\GV\Shortcodes\gvlogic' ) ) {
@jakejackson1
jakejackson1 / functions.php
Created January 27, 2022 23:28
Auto-create a Save and Continue link every time the Partial Entry add-on triggers a save. This ensures the partial entry can always be resumed from the admin with up to date info.
add_action( 'gform_partialentries_post_entry_saved', 'force_save_and_continue_partial_entry_post_save', 10, 2 );
add_action( 'gform_partialentries_post_entry_updated', 'force_save_and_continue_partial_entry_post_save', 10, 2 );
function force_save_and_continue_partial_entry_post_save( $partial_entry, $form ) {
if ( ! rgars( $form, 'save/enabled' ) ) {
return;
}
/* Generate a new save and continue link */
$field_values = \GFForms::post( 'gform_field_values' );
@jakejackson1
jakejackson1 / gravityforms_wp_offload_media_integration.php
Last active October 1, 2021 01:32
Support the current version of WP Offload Media (as of Oct 2021) for Gravity Forms Single and Multi File Upload field. If WP Offload Media is configured to delete local files after offloading, this will do it too.
<?php
add_action( 'init', function() {
/** @var $as3cf Amazon_S3_And_Cloudfront */
global $as3cf;
if ( ! $as3cf instanceof Amazon_S3_And_Cloudfront || ! $as3cf->is_plugin_setup( true ) ) {
return;
}
@jakejackson1
jakejackson1 / gravitypdf.php
Last active April 11, 2021 22:53
Make page numbering show in upper roman for all Gravity PDF documents
<?php
add_filter( 'gfpdf_mpdf_class_config', function( $config ) {
$config['defaultPageNumStyle'] = 'upper-roman';
return $config;
} );
add_filter( 'gfpdf_mpdf_class_config', function( $config, $form, $entry, $settings ) {
@jakejackson1
jakejackson1 / functions.php
Last active May 19, 2019 23:42
Convert Multi-Column List to Single Column
<?php
add_filter( 'gfpdf_pdf_field_content', function( $value, $field, $entry, $form, $pdf_field ) {
if ( $field->type === 'list' ) {
/* get out field value */
$value = $pdf_field->value();
$columns = is_array( $value[0] );
/* exit early if list field is empty */
@jakejackson1
jakejackson1 / disable-w3-total-cache-nags.php
Last active December 22, 2017 00:56
Remove Support Nag W3 Total Cache
<?php
/*
Plugin Name: Disable W3 Total Cache Nags
Version: 1.0
Author: Blue Liquid Designs
*/
add_action( 'wp_loaded', 'bld_disable_w3_total_cache_nags' );
function bld_disable_w3_total_cache_nags()
@jakejackson1
jakejackson1 / dont-remove-filter-action.php
Last active July 4, 2016 06:36
An example showing why you don't remove a WP filter/action when it's currently being called.
<?php
/*
* A basic proof of concept showing how you shouldn't remove an action/filter when it's currently being called
* The $array is the basic structure of $GLOBALS['wp_filter'][ $tag ] while the do/while loop is how WordPress
* loops through the current action/filter being called.
*/
$array = [
1 => ['1-1'],