Skip to content

Instantly share code, notes, and snippets.

View rafaehlers's full-sized avatar

Rafael Ehlers rafaehlers

View GitHub Profile
@rafaehlers
rafaehlers / gv-change-back-link.php
Last active June 11, 2018 17:15
Change the back link for just a specific View ID
@rafaehlers
rafaehlers / gv-add_swedish_alphabet.php
Created April 18, 2018 18:05
Add Swedish Alphabet support for A-Z Filters extension
<?php //don't copy this line
add_filter( 'gravityview_az_entry_filter_localization', 'add_swedish_gravityview_az_entry_filter_localization' );
function add_swedish_gravityview_az_entry_filter_localization( $languages = array() ) {
$languages['sv_FI'] = __( 'Swedish (Finland)', 'gravityview-az-filters' ),
$languages['sv_SE'] = __( 'Swedish (Sweden)', 'gravityview-az-filters' ),
$languages['sv'] = __( 'Swedish', 'gravityview-az-filters' ),
return $languages;
}
@rafaehlers
rafaehlers / gv-datatables-label-into-placeholder.html
Created April 19, 2018 22:42
Turns the search label into a placeholder for DataTable's Search field
<?php wp_footer(); ?><!-- DON'T COPY THIS LINE, IT'S JUST HERE SO YOU KNOW WHERE TO PLACE THE <SCRIPT> BELOW -->
<script type="text/javascript">
(function($){
$(document).ready(function(){
$("#DataTables_Table_0_filter :input").attr("placeholder", 'Search');
var divhtml = $("#DataTables_Table_0_filter label").html();
$("#DataTables_Table_0_filter label").html(divhtml.replace("Search:", " "));
@rafaehlers
rafaehlers / gravitywiz_modify_nested_modal_dimensions.php
Last active September 21, 2018 17:19
Modify the dimensions of the modal window for specific Nested Form fields
<?php
// List of arguments at gp-nested-forms/class-gp-nested-forms.php at line 1406
add_filter( 'gpnf_init_script_args', 'gravitywiz_modify_nested_modal_dimensions', 10, 3 );
function gravitywiz_modify_nested_modal_dimensions( $args, $field, $form ) {
if ($field['id'] == 3 && $form['id'] == 141){
$args['modalWidth'] = 500;
$args['modalHeight'] = 900;
return $args;
}
return $args;
@rafaehlers
rafaehlers / gv-send-form-notification-entry-approval.php
Last active June 5, 2018 21:41
Send a form notification when an entry is approved/disapproved
<?php
add_action('gravityview/approve_entries/disapproved','gv_send_form_notification_approval');
add_action('gravityview/approve_entries/approved','gv_send_form_notification_approval');
function gv_send_form_notification_approval($entry_id){
$entry = GFAPI::get_entry( $entry_id );
if( ! $entry || is_wp_error( $entry ) ) {
return;
}
$form = GFAPI::get_form( $entry['form_id'] );
if( ! $form || is_wp_error( $form ) ) {
@rafaehlers
rafaehlers / gv-remove-wpautop-custom-content.php
Last active April 14, 2020 06:52
Prevents the wpautop (BR and P tags) function from running on a custom content field.
<?php
/**
* Remove wpautop() when Gravity Forms is in the field content
*/
add_filter( 'gravityview/field_output/args', function( $args, $passed_args, $context = null ) {
if( $context && $context instanceof \GV\Template_Context ) {
$content = \GV\Utils::get( $args, 'value', '' );
if( has_shortcode( $content, 'gravityform') ) {
<?php
add_action('gform_after_update_entry_115', 'gv_change_entry_creator', 10, 2);
function gv_change_entry_creator( $form, $entry_id ){
$entry = GFAPI::get_entry($entry_id);
$new_entry_creator = $entry[1]; // field ID where the dropdown with usernames are (this will be the new entry creator)
GFAPI::update_entry_property( $entry_id, 'created_by', $new_entry_creator );
}
<?php
function gv_change_edit_entry_title( $previous_text = 'Edit Entry' ) {
$view_id = GravityView_View::getInstance()->getViewId();
if($view_id == 105){
return 'Edit Profile';
}
if( ($view_id == 106) || ($view_id == 107)){
return 'Edit Entry';
}
}
@rafaehlers
rafaehlers / gv_listify.php
Last active June 29, 2018 05:11
Shortcode that accepts a category field which is usually displayed as bullet points and turns into a comma separated values string
<?php
//usage [gv_listify field="{Field Merge Tag}"]
add_shortcode( 'gv_listify', 'gv_listify_shortcode' );
function gv_listify_shortcode( $atts ) {
extract( shortcode_atts(
array(
'field' => '',
), $atts )
);
@rafaehlers
rafaehlers / gv-ratings-reviews-form-stars.php
Last active April 8, 2020 22:31
Ratings and Reviews extension - Remove all fields from the review form, leaving only the thumbs/stars
<?php // DO NOT COPY THIS LINE
add_filter( 'comment_form_field_gv_review_title', '__return_empty_string' );
add_filter( 'gv_ratings_reviews_review_form_settings', 'gv_modify_review_form_labels',10,1);
function gv_modify_review_form_labels($defaults){
$defaults['author'] = '';
$defaults['email'] = '';