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-entry-notes-from.php
Last active April 14, 2020 06:51
Modify the FROM address from entry notes
<?php // DO NOT COPY THIS LINE
add_filter( 'gravityview/field/notes/email_content', 'gv_modify_notes_email_content', 10, 4 );
function gv_modify_notes_email_content( $email_settings ) {
extract( $email_settings );
$email_settings['from'] = '[email protected]';
$email_settings['from_name'] = 'GravityView Website';
/*
$email_settings['to'] = $to; //[email protected]
$email_settings['bcc'] $bcc; //[email protected]
@rafaehlers
rafaehlers / gv-polish-az-filters-support.php
Created March 3, 2020 19:46
Add support for Polish alphabet in A-Z filters
<?php
add_filter( 'gravityview_az_entry_filter_localization', 'add_polish_gravityview_az_entry_filter_localization' );
function add_polish_gravityview_az_entry_filter_localization( $languages = array() ) {
$languages['pl_PL'] = __( 'Polish', 'gravityview-az-filters' );
return $languages;
}
add_filter( 'gravityview_alphabets', 'add_polish_alphabet' );
function add_polish_alphabet( $alphabet = array() ) {
@rafaehlers
rafaehlers / gv-disable-dt-search.php
Last active February 12, 2020 02:00
Disable the built-in search field on DataTables
<?php // Don't copy this line
add_filter( 'gravityview_datatables_js_options', 'disable_gravityview_datatables_search', 11, 3 );
function disable_gravityview_datatables_search( $dt_config, $view_id, $post ) {
$return_config = $dt_config;
if( $view_id == '81' ) { // change "81" to your View ID
$return_config['searching'] = false;
}
return $return_config;
}
@rafaehlers
rafaehlers / gv_math-percentage-bar.php
Last active August 28, 2019 04:34
Display a progress bar using the Math extension
<?php // DO NOT COPY THIS LINE
// usage inside a Custom Content field on a View: [gv_math_percentage field="{field Merge tag here:x}"]
add_shortcode("gv_math_percentage", "gv_math_custom_shortcode");
function gv_math_custom_shortcode( $atts ){
extract( shortcode_atts(
array(
'field' => '',
), $atts )
<?php //don't copy this line
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 ) {
$return = $existing_text;
$view_id = $context->view->ID;
if( $view_id == 3683 ) { // CHANGE TO THE VIEW ID YOU WANT TO TARGET
$return = 'View empty';
}
return $return;
@rafaehlers
rafaehlers / gv_modify_text.php
Created May 8, 2019 19:48
Change any GravityView text
<?php // don't copy this line
add_filter( 'gettext', 'gv_modify_text', 20, 3 );
function gv_modify_text( $translated_text, $text, $domain ) {
if ( $translated_text === 'You do not have permission to edit this entry.') {
$translated_text = __( 'You dont!', 'gravityview' );
}
@rafaehlers
rafaehlers / gv-remove-all-styles-and-scripts.php
Last active May 11, 2021 18:42
Dequeue/Deregister/Remove all scripts of GravityView from the front-end of your website
<?php // don't copy this line
add_action( 'wp_enqueue_scripts', 'gv_dequeue_main_css', 30 );
add_action( 'wp_print_scripts', 'gv_dequeue_main_css', 2 );
function gv_dequeue_main_css() {
wp_dequeue_style( 'gravityview_default_style' );
wp_dequeue_style( 'gravityview_style_default_table' );
wp_dequeue_style( 'gravityview_style_default_list' );
@rafaehlers
rafaehlers / gv-exact-match-view-id.php
Last active October 21, 2024 20:26
Returns an exact match
<?php // DO NOT copy this line
function gv_search_operator( $operator, $filter = array(), $context = null ){
return 'is';
}
add_filter( 'gravityview_search_operator', 'gv_search_operator');
// This disallows empty field values (It must be used in conjunction with the filter above)
add_filter( 'gravityview/search/ignore-empty-values', function() {
return false;
@rafaehlers
rafaehlers / gv-trigger-form-feed-on-approval.php
Last active August 6, 2019 23:00
Trigger form feeds on entry approval/disapproval
<?php // DON'T COPY THIS LINE
//add_action('gravityview/approve_entries/disapproved','gv_trigger_form_feed_on_approval');
add_action('gravityview/approve_entries/approved','gv_trigger_form_feed_on_approval');
function gv_send_form_notification_approval($entry_id = 0){
$entry = GFAPI::get_entry( $entry_id );
if( ! $entry || is_wp_error( $entry ) ) {
return;
}
$form = GFAPI::get_form( $entry['form_id'] );
@rafaehlers
rafaehlers / gv-dt-print-title.php
Last active March 19, 2019 02:16
Modify the title of the window when priting the View using the DataTables layout
<?php // Make sure to remove this line
add_filter('gravityview/datatables/button_print','gravityview_dtbuttons_print_title', 10 ,2);
function gravityview_dtbuttons_print_title( $button_config = array(), $view_id){
$button_config['title'] = 'Add your own title here';
return $button_config;
}