Skip to content

Instantly share code, notes, and snippets.

View gv-rest-api-nonce.php
<?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 Jul 29, 2021
GravityView - Exact-match search (not fuzzy) for a specific field and View
View gravityview-strict-search.php
<?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 Jun 7, 2021
GravityView - Make all fields visible on Edit Entry
View gravityview-make-fields-visible.php
<?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
Override search field values in GravityView
View gravityview-override-search-values.php
<?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 Apr 12, 2021
Modify the button styles for Edit Entry in GravityView (as seen on our blog)
View gv-button-styles.css
/* 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 Feb 22, 2021
GravityView - Remove default icons from Maps icon picker
View gravityview-maps-remove-plugin-icons.php
<?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 Feb 9, 2021
Custom Content to show star ratings. If you have different labels in the Gravity Forms field, make sure to use those labels instead!
View gravity-forms-survey-star-ratings-gravityview.txt
[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"]
⭐️⭐️⭐️⭐️⭐️
@zackkatz
zackkatz / gravityview-plugins-filter.php
Created Feb 1, 2021
GravityView - Add a "GravityView Plugins" filter to the Plugins list ("active", "inactive", etc…)
View gravityview-plugins-filter.php
<?php
/**
* Add to your functions.php file
*
* Note: this does the same thing as searching for "GravityView.co" in the plugins search box!
*/
add_filter( 'views_plugins', function( $views = array() ) {
$link = esc_html__( 'GravityView Plugins', 'gravityview' );
@zackkatz
zackkatz / gv-calendar-process-field-shortcodes.php
Last active Dec 9, 2020
GravityView Calendar - Process shortcodes contained within field values
View gv-calendar-process-field-shortcodes.php
<?php
add_filter( 'gravityview/calendar/events', 'gv_calendar_process_field_value_shortcode' );
/**
* Sometimes field values contain shortcodes you want to process. This does that.
*
* @param array $events Array of events to display on the calendar.
*
* @return array $events, but with `title` and `description` keys processed.
@zackkatz
zackkatz / add-promotion-method-affiliatewp.php
Created Dec 3, 2020
Add Promotion Method to the Affiliates table in AffiliateWP
View add-promotion-method-affiliatewp.php
<?php
/**
* Add Promotion Method to AffiliateWP affiliates table columns
*
* @since December 3, 2020
*
* @param array $prepared_columns Prepared columns.
* @param array $columns The columns for this list table.
* @param \AffWP_Affiliates_Table $this List table instance.