Skip to content

Instantly share code, notes, and snippets.

@zackkatz
zackkatz / gravityview-calendar-specific-feed-start-day-monday.php
Created December 14, 2021 20:09
GravityView Calendar - Set start day to be Monday for a specific feed
<?php
/**
* Change the start day to something other than the WordPress settings.
*
* The value must be a number that represents the day of the week.
* Sunday=0, Monday=1, Tuesday=2, etc.
*
* @param array $calendar_options Calendar options
* @param int $form_id Form ID
@zackkatz
zackkatz / gravityview-calendar-start-day-monday.php
Created December 14, 2021 20:05
GravityView Calendar - Set start day to be Monday
<?php
/**
* Change the start day to something other than the WordPress settings.
*
* The value must be a number that represents the day of the week.
* Sunday=0, Monday=1, Tuesday=2, etc.
*
* @param array $calendar_options Calendar options
* @param int $form_id Form ID
@zackkatz
zackkatz / gravityview-reset-gravityflow.php
Created December 10, 2021 04:10
GravityView - Reset all Gravity Flow workflow statuses for a duplicated entry after duplicating
<?php
/**
* Reset all Gravity Flow workflow statuses for a duplicated entry after duplicating in GravityView.
*
* @param array $duplicated_entry The duplicated entry
*/
add_action( 'gravityview/duplicate-entry/duplicated', function( $duplicated_entry ) {
if ( ! class_exists( 'Gravity_Flow_API' ) ) {
<?php
$entries_url = 'https://try.gravityview.co/demo/wp-json/gravityview/v1/views/148/entries.json';
$nonce = wp_create_nonce( 'wp_rest' );
?>
<script type="text/javascript">
jQuery.ajax( {
url: <?php echo json_encode( $entries_url ); ?>,
method: 'GET',
beforeSend: function ( xhr ) {
xhr.setRequestHeader( 'X-WP-Nonce', <?php echo json_encode( $nonce ); ?> );
@zackkatz
zackkatz / gravityview-strict-search.php
Created July 29, 2021 17:41
GravityView - Exact-match search (not fuzzy) for a specific field and View
<?php
/**
* Return strict "is" comparison operator when processing a search on a specific View and field.
*
* @param string $operator Existing search operator
* @param array $filter array with `key`, `value`, `operator`, `type` keys
* @param \GV\View $view The View we're operating on.
*
* @return string
@zackkatz
zackkatz / gravityview-make-fields-visible.php
Created June 7, 2021 16:18
GravityView - Make all fields visible on Edit Entry
<?php
add_filter( 'gravityview/edit_entry/form_fields', 'gravityview_edit_entry_mark_fields_visible' );
/**
* Remove the "required" setting from Gravity Forms fields in GravityView Edit Entry
*
* @return GF_Field[]
*/
function gravityview_edit_entry_mark_fields_visible( $fields ) {
@zackkatz
zackkatz / gravityview-override-search-values.php
Created May 20, 2021 19:38
Override search field values in GravityView
<?php
/**
* This is as shown in the video here: https://www.loom.com/share/68f01c9661264f30bb43e9f5346c7b83
*/
/**
* @param \GravityView_Widget_Search $search_obj GravityView Widget instance
*/
add_action( 'gravityview_search_widget_fields_before', function( $search_obj ) {
@zackkatz
zackkatz / gv-button-styles.css
Created April 12, 2021 15:27
Modify the button styles for Edit Entry in GravityView (as seen on our blog)
/* Update button */
#publishing-action .gv-button-update {
background-color: #4CAF50;
border: 2px solid #4CAF50;
color: #ffffff;
padding: 15px 32px;
text-align: center;
font-size: 16px;
}
@zackkatz
zackkatz / gravityview-maps-remove-plugin-icons.php
Last active February 22, 2021 19:01
GravityView - Remove default icons from Maps icon picker
<?php
/**
* Removes plugin iconset so that only theme icons remain.
*
* @param array $icons Associative array of icon URLs with `plugin` and `theme` keys.
*/
add_filter( 'gravityview/maps/available_icons/icons', function( $icons = array() ) {
$icons['plugin'] = array();
@zackkatz
zackkatz / gravity-forms-survey-star-ratings-gravityview.txt
Created February 9, 2021 14:05
Custom Content to show star ratings. If you have different labels in the Gravity Forms field, make sure to use those labels instead!
[gvlogic if="{Star Rating:1}" is="Terrible"]
⭐️
[else if="{Star Rating:1}" is="Not so great"]
⭐️⭐️
[else if="{Star Rating:1}" is="Neutral"]
⭐️⭐️⭐️
[else if="{Star Rating:1}" is="Pretty good"]
⭐️⭐️⭐️⭐️
[else if="{Star Rating:1}" is="Excellent"]
⭐️⭐️⭐️⭐️⭐️