Skip to content

Instantly share code, notes, and snippets.

@zackkatz
zackkatz / eddsl-auto-activate.php
Last active Oct 21, 2020
Auto-activate sites on Easy Digital Downloads Software Licensing
View eddsl-auto-activate.php
<?php
add_filter( 'edd_sl_is_site_active', 'your_namespace_is_site_active_auto_activate_site', 10, 3 );
/**
* Allow active licenses to get updates if they're not at the limit, no matter what.
*
* @param false $is_active
* @param int $license_id
* @param string $passed_site_url
@zackkatz
zackkatz / gravityview-modify-field-settings.php
Last active Oct 16, 2020
GravityView - Modify Field Settings to always have some settings checked
View gravityview-modify-field-settings.php
<?php
// Run after 10 priority to make sure all the fields are added
add_filter( 'gravityview_template_field_options', 'gv_modify_field_setting_defaults', 20, 6 );
/**
* Always check "Show Label" and "Visible to Logged-in Viewers" field settings
*
* @param array $field_options Array of field options with `label`, `value`, `type`, `default` keys
* @param string $template_id Table slug
@zackkatz
zackkatz / gravityview-gravity-flow-clear-cache.php
Last active Jul 29, 2020
GravityView - Clears results cache after running Gravity Flow workflow
View gravityview-gravity-flow-clear-cache.php
<?php
// Add the code below to your functions.php file. Will be included in GravityView 2.9 release.
add_action( 'gravityflow_post_process_workflow', 'gv_clear_cache_after_workflow', 10, 4 );
/**
* Clears GravityView entry cache after running a Gravity Flow Workflow
*
* Thanks to @CodenomadIndia for improved code!
@zackkatz
zackkatz / gravityview-anchor-after-search.php
Last active Jun 1, 2020
GravityView - How to navigate to an anchor after search
View gravityview-anchor-after-search.php
<?php
/**
* Modify the action of the Search Bar form to navigate to #site-content anchor after search
*
* @param string $url Where the form submits to.
*
* @returns string Modified URL with anchor added
*/
add_filter( 'gravityview/widget/search/form/action', function ( $url ) {
@zackkatz
zackkatz / gv-calendar-remove-time-display.php
Last active May 24, 2020 — forked from rafaehlers/gv_calendar_remove_time_display.php
Gravity Forms Calendar - Prevent time from being displayed in the calendar
View gv-calendar-remove-time-display.php
<?php // DO NOT COPY THIS LINE
/**
* Remove the time from being displayed on a GravityView calendar
*
* @see https://docs.gravityview.co/category/647-calendar
*
* @param array $calendar_options Array of FullCalendar options
*
* @return mixed
@zackkatz
zackkatz / gravityview-update-approval.php
Created Mar 17, 2020
GravityView - Update Entry Approval Status using PHP
View gravityview-update-approval.php
<?php
// Check to make sure GravityView is loaded
if ( ! class_exists( 'GravityView_Entry_Approval' ) ) {
return;
}
/**
* There are three options that should be used when updating entry approval statuses:
* GravityView_Entry_Approval_Status::APPROVED - Approved/Accepted entries
@zackkatz
zackkatz / gravityview-check-has-entry-revisions.php
Created Feb 27, 2020
GravityView Entry Revisions - How to check whether an entry is a revision
View gravityview-check-has-entry-revisions.php
<?php
$entry = GFAPI::get_entry( 1234 ); // Replace '1234' with your own Entry ID
if( 'gv-revision' === $entry['status'] ) {
// This entry is actually a revision!
}
@zackkatz
zackkatz / gravityview-calendar-modify-events.php
Last active Mar 28, 2020
GravityView Calendar - Modify the settings for a single event
View gravityview-calendar-modify-events.php
<?php
/**
* Modify event array that is output to FullCalendar
* In this sample code, we add a background color to a specific event
*
* @param array $events Array of events
* @param object $form Calendar form
* @param object $feed Calendar feed
* @param array $field_map Array of feed fields mapped to calendar settings (e.g., start_time, end_time)
@zackkatz
zackkatz / gravityview-show-checkbox-as-csv.php
Created Feb 25, 2020
GravityView - Display checkbox values as comma-separated instead of a bullet list
View gravityview-show-checkbox-as-csv.php
<?php
/**
* Convert checkbox <ul> to CSV values
*
* @param string $output The current output.
* @param \GV\Template_Context The template context this is being called from.
*/
add_filter( 'gravityview/template/field/checkbox/output', function( $output, $context ) {
@zackkatz
zackkatz / prevent-adding-revision.php
Last active Apr 14, 2020
Entry Revisions - Prevent adding revisions for a specific form
View prevent-adding-revision.php
<?php
/**
* Prevent adding revisions for a specific form
*
* @param bool $add_revision Should a revision be added?
* @param integer $entry_id The entry ID that was updated
* @param array $form The form object for the entry.
* @param array $original_entry The entry object before being updated
*
You can’t perform that action at this time.