Skip to content

Instantly share code, notes, and snippets.

View rafaehlers's full-sized avatar

Rafael M. Ehlers rafaehlers

View GitHub Profile
@rafaehlers
rafaehlers / gv-divi-widgets.php
Created March 6, 2019 23:29
Prevent a DIVI powered theme from disabling GravityView's widgets when the View is embedded in a page
<?php //Remove this line
add_filter( 'et_grab_image_setting', function( $default ) {
if ( gravityview()->request->is_view() ) return false;
return $default;
} );
@rafaehlers
rafaehlers / gv-remove-width.php
Created February 26, 2019 23:00
Remove the width=250 from img tag (file upload fields on GravityView)
<?php //MAKE SURE TO REMOVE THIS LINE
add_filter( 'gravityview/fields/fileupload/image_atts', function ( $image_atts ) {
$image_atts['width'] = NULL;
return $image_atts;
} );
@rafaehlers
rafaehlers / gv-no-entries-view-specific.php
Created February 15, 2019 02:15
Display a custom message when no entries are returned, for a specific View ID
<?php //MAKE SURE TO REMOVE THIS WHOLE LINE FIRST
add_filter( 'gravityview/template/text/no_entries', 'modify_gravityview_no_entries_text', 10, 3 );
function modify_gravityview_no_entries_text( $existing_text, $is_search = false, $context = null ) {
$view_id = $context->view->ID;
if($view_id == 8) //Change this number to your View ID
{
if( $is_search ) {
@rafaehlers
rafaehlers / gv-multiple-forms-hotfix.php
Created February 6, 2019 20:40
Hot Fix for the Multiple Forms 0.1-beta.2 issue
<?php // MAKE SURE TO REMOVE THIS WHOLE LINE FIRST, BEFORE COPYING THIS CODE TO YOUR THEME's FUNCTIONS.PHP FILE
add_action( 'gravityview/view/query', function( &$query, $view, $request ) {
$q = $query->_introspect();
foreach ( $q['joins'] as $join ) {
// Filter to active entries only
$condition = new \GF_Query_Condition(
new \GF_Query_Column( 'status', $join[0]->source ),
\GF_Query_Condition::EQ,
@rafaehlers
rafaehlers / gv_exact_match_fields.php
Last active December 19, 2018 00:43
Returns an exact match for two fields in a specific form
<?php // MAKE SURE TO REMOVE THIS FIRST LINE WHEN COPYING THIS to your THEME'S FUNCTIONS.PHP FILE
add_filter( 'gravityview_fe_search_criteria', 'gv_exact_match_fields', 10, 2 );
/**
* @param array $search_criteria
* @param int $form_id
*
* @return array Modified search, if it's the current form
*/
function gv_exact_match_fields( $search_criteria = array(), $form_id = 0 ) {
@rafaehlers
rafaehlers / gv-remove-approval-notes.php
Last active February 3, 2020 20:32
Use this code to prevent approval notes from showing up on your View
<?php // REMOVE THIS LINE BEFORE COPYING THIS CODE TO YOUR FUNCTIONS.PHP FILE
add_filter( 'gravityview/entry_notes/get_notes', 'gv_remove_entry_approval_notes', 10, 2 );
function gv_remove_entry_approval_notes( $notes, $entry_id ) {
foreach($notes as $key => $note){
if (strpos( $note->value, 'pproved') !== false){
unset( $notes[ $key] );
}
if (strpos( $note->value, 'WordPress') !== false){
unset( $notes[ $key] );
@rafaehlers
rafaehlers / table-view-vertical.css
Created November 5, 2018 20:36
Change a Table view from horizontal to vertical
.gv-table-view thead {
display: none;
}
.gv-table-view tr {
display: block;
position: relative;
padding: 1.2em 0;
overflow-x: auto;
}
@rafaehlers
rafaehlers / label-as-placeholder.html
Created October 30, 2018 04:55
Turn Search Bar labels into placeholders
<script type="text/javascript">
(function($){
$(document).ready(function(){
$("form.gv-widget-search :input").each(function(index, elem) {
var eId = $(elem).attr("id");
var label = null;
if (eId && (label = $(elem).parents("form").find("label[for="+eId+"]")).length == 1) {
$(elem).attr("placeholder", $(label).html());
$(label).remove();
<?php //do not copy this line to your functions.php file!
add_filter( 'gpls_rule_groups', function( $rule_groups, $form_id ) {
// Update "123" to the ID of your form.
$primary_form_id = 123;
if( $form_id == $primary_form_id ) {
return $rule_groups;
}
if(( $form_id == 4 ) || ( $form_id == 5 ) || ( $form_id == 6 ) || ( $form_id == 7 )) {
return $rule_groups;
@rafaehlers
rafaehlers / gv-datables-excel-export.php
Created August 17, 2018 05:25
Filter to change the filename of the exported .XLSX file and to remove the first row containing the document title
<?php // MAKE SURE TO REMOVE THIS FIRST LINE BEFORE COPYING THIS CODE TO YOUR FUNCTIONS.PHP FILE
add_filter('gravityview/datatables/button_excel','gravityview_excel_export_settings', 10 ,2);
function gravityview_excel_export_settings( $button_config = array(), $view_id){
$button_config['filename'] = 'dt-excel-test'; //you can change the filename here (don't type the extension)
$button_config['title'] = '';
return $button_config;
}