Skip to content

Instantly share code, notes, and snippets.

View uamv's full-sized avatar
🏠
Working from home

Joshua Vandercar uamv

🏠
Working from home
View GitHub Profile
/**
* This snippet will add a datepicker to the list field of Gravity Forms.
* Just copy paste this snippet and complete the configuration at the bottom
* Also make sure that Jquery UI is loaded otherwise this won't work (<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>)
*
* @author Johan d'Hollander
* @link <https://geekontheroad.com>
**/
jQuery(document).ready(function() {
@webzunft
webzunft / canceled-subscriptions.sql
Last active October 4, 2022 13:15
SQL queries to analyse canceled subscriptions managed with EDD Recurring Payments
# Basic queries to analyse canceled subscriptions using EDD Recurring Payments pre EDD 3.0
# Use EXPLAIN if you have large stores since the "notes" column is not indexed and queries can take some time
# Some of these reports might be worth storing as Views and look at the graphs PHPMyAdmin can also create from them
# List subscription cancelation with creation and cancelation date, as well as the user who canceled
# good as a basis for further queries
SELECT ID,
created,
REGEXP_SUBSTR( REGEXP_SUBSTR( notes, '.* Status changed from active to cancelled .*' ), '^[a-z]+ [0-9]+, [0-9]+' ) AS 'date',
@carlalexander
carlalexander / expect-header-fix.php
Last active August 13, 2021 00:40
WordPress "Expect" header fix
<?php
/**
* By default, cURL sends the "Expect" header all the time which severely impacts
* performance. Instead, we'll send it if the body is larger than 1 mb like
* Guzzle does.
*/
function add_expect_header(array $arguments)
{
$arguments['headers']['expect'] = '';
add_filter( 'gform_form_post_get_meta_7', 'add_form_fields' );
function add_form_fields( $form ) {
// Don't make the parent form messy
if ( ! GFCommon::is_form_editor() ) {
// form we are adding fields to
$parent_id = $form['id'];
// template form ID
$childId = 5;
@generatepress
generatepress / gist:9fe556128433b11114b489406fc8dee4
Created February 14, 2019 22:36
Disable the Header Element if there isn't a featured image.
add_filter( 'generate_header_element_display', function( $display ) {
if ( ! has_post_thumbnail() ) {
return false;
}
return $display;
} );
@joedooley
joedooley / gform_stripe_api_mode.php
Created February 5, 2018 21:19
Change Stripe API mode for targeted form.
<?php
/**
* Filters the API mode for a specific form to 'test'.
*
* @param $api_mode string Either 'test' or 'live'
*
* @return string Returns 'test' for targeted form. Otherwise,
* will return the value for the $api_mode setting.
*/
@saltnpixels
saltnpixels / gform_stripe_subscriptions.php
Created October 10, 2017 15:25
Gravity forms stripe cancel from front end
<?php
/**
* Payment subscriptions and updating billing and cancelling subscriptions takes place with these hooks
* We need the stripe customer user id for updating billing
* we need the entry id of subscription so we can cancel it.
*/
/**
* @param $entry
@spivurno
spivurno / gw-gravity-forms-manual-entries.php
Last active February 21, 2023 20:45
Gravity Wiz // Gravity Forms // Manual Entries
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-manual-entries.php
*/
/**
* Gravity Wiz // Gravity Forms // Manual Entries
*
* Create entries manually for Gravity Forms. Adds an "Add New" button next to the page title on all entry-related pages.
@spivurno
spivurno / gw-gravity-forms-manual-notifications.php
Last active September 16, 2021 13:07
Gravity Wiz // Gravity Forms // Send Manual Notifications
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-manual-notifications.php
*/
/**
* Gravity Wiz // Gravity Forms // Send Manual Notifications
*
* Provides a custom notification event that allows you to create notifications that can be sent
@chriscoyier
chriscoyier / frontendplugins.md
Last active March 3, 2021 17:31
How WordPress Plugins Should Handle Front End Resources

How WordPress Plugins Should Handle Front End Resources

This is a WORK IN PROGRESS intended for fleshing out and feedback

It's very common for people to be unhappy with how a WordPress plugin adds front end resources to their site. If a plugin needs CSS, the plugin will add a <link> element to that CSS. If the plugin needs JavaScript, it will add a <script> to that JavaScript.

Plugins do this because it works. It's damn important for a WordPress plugin to work, even in adverse conditions. They rightfully want good ratings and little customer support.

But this comes at the cost of additional HTTP requests. In optimizing front end performance of a site, reducing the number of HTTP requests is a huge thing. Front end developers want to decide and control how front end resources are being handled, and WordPress plugins don't typically make this easy on them.