Skip to content

Instantly share code, notes, and snippets.

View NikV's full-sized avatar
🎯
Focusing

Nikhil Vimal NikV

🎯
Focusing
View GitHub Profile
@NikV
NikV / gfroms-examples.php
Created September 8, 2015 03:22
Example for how to use the gquiz_answer_indicator filter
//advanced - more control
add_filter( 'gquiz_answer_indicator', 'gquiz_answer_indicator', 10, 7);
function gquiz_answer_indicator ($indicator_markup, $form, $field, $choice, $lead, $is_response_correct, $is_response_wrong){
if ( $is_response_correct )
$indicator_markup = ' (you got this one right!)';
elseif ( $is_response_wrong ) {
if ( $field['inputType'] == 'checkbox' && rgar( $choice, 'gquizIsCorrect' ) )
$indicator_markup = ' (you missed this one!)';
else
$indicator_markup = ' (you got this one wrong!)';
@NikV
NikV / gfroms-examples.php
Created September 7, 2015 23:17
Disable SSL verification in Hipchat
add_filter('gform_hipchat_verify_ssl', '__return_false');
@NikV
NikV / gfroms-examples.php
Created September 7, 2015 21:42
Custom label and change in text hover for the button
function modify_gform_uninstall_button() {
return '<input type="submit" name="uninstall" value="' . esc_attr__( 'Say Goodbye to Gravity Forms', 'gravityforms' ) . '" class="button" onclick="return confirm(\'' . esc_js( __( "Hi Client, just a quick Warning. ALL Gravity Forms data, including form entries will be deleted. This cannot be undone. 'OK' to delete, 'Cancel' to stop. If you'd like to keep anything, please export your form data", 'gravityforms' ) ) . '\');"/>';
}
add_filter('gform_uninstall_button', 'modify_gform_uninstall_button');
@NikV
NikV / gfroms-examples.php
Created September 7, 2015 21:37
Modify the Entry Delete Link
function modify_gform_delete_entry_link() {
global $lead;
return '<a data-wp-lists="delete:gf_entry_list:lead_row_' . esc_attr( $lead['id'] ) . '::status=delete&entry=' . esc_attr( $lead['id'] ) . '" title="' . esc_attr__( 'Delete this entry permanently', 'gravityforms' ) . '" href="' . wp_nonce_url( '?page=gf_entries', 'gf_delete_entry' ) . '">' . esc_html__( 'Delete', 'gravityforms' ) . '</a>';
}
add_filter('gform_delete_entry_link', 'modify_gform_delete_entry_link');
@NikV
NikV / gfroms-examples.php
Created September 7, 2015 21:36
Custom class and custom label for Entry Detail Save button
function modifygform_entrydetail_update_button() {
$mode = empty( $_POST['screen_mode'] ) ? 'view' : $_POST['screen_mode'];
$button_text = $mode == 'view' ? __( 'Update Entry', 'gravityforms' ) : __( 'Update Entry', 'gravityforms' );
$disabled = $mode == 'view' ? '' : ' disabled="disabled" ';
$update_button_id = $mode == 'view' ? 'gform_edit_button' : 'gform_update_button';
$button_click = $mode == 'view' ? "jQuery('#screen_mode').val('edit');" : "jQuery('#action').val('update'); jQuery('#screen_mode').val('view');";
$update_button = '<input id="' . $update_button_id . '" ' . $disabled . ' class="button button-large button-primary my-custom-button-class" type="submit" tabindex="4" value="' . esc_attr( $button_text ) . '" name="save" onclick="' . $button_click . '"/>';
return $update_button;
@NikV
NikV / gfroms-examples.php
Created September 7, 2015 21:35
Change the label for the overall Gravity Forms Settings Save Button
function modify_gform_settings_save_button() {
return '<input type="submit" name="submit" value="' . esc_html__( 'Confirm Settings', 'gravityforms' ) . '" class="button-primary gfbutton my-button class"/> Remember, be responsible with what you save here!';
}
add_filter('gform_settings_save_button', 'modify_gform_settings_save_button');
@NikV
NikV / gfroms-examples.php
Last active September 7, 2015 22:55
Change the trash link when deleting a form, also changing the format of the input into a button. And few inline styles.
function modify_gfroms_trash_link() {
return '<button style="background: red; color: white; border: none;" class="submitdelete" title="' . __( 'Move this form to the trash', 'gravityforms' ) . '" onclick="if(confirm(\'' . __( "Would you like to move this form to the trash? \'Cancel\' to stop. \'OK\' to continue", 'gravityforms' ) . '\')){ gf_vars.isFormTrash = true; jQuery(\'#form_trash\')[0].submit();} else{return false;}">' . __( 'Trash', 'gravityforms' ) . '</button>';
}
add_filter('gform_form_trash_link', 'modify_gfroms_trash_link');
@NikV
NikV / gfroms-examples.php
Created September 7, 2015 21:28
Add some text to the form preview footer
function modify_gform_preview_footer() {
echo "<p style='text-align: center'> I am adding some more info to this preview</p>";
}
add_action('gform_preview_footer', 'modify_gform_preview_footer');
@NikV
NikV / gfroms-examples.php
Created September 7, 2015 21:23
Change the label in the addnote button
//Adding a custom ID and change label
function modify_addnote_button_gforms() {
$new_addnote_button = '<input type="submit" id="my-custom-addnote-styles" name="add_note" value="' . esc_attr__( 'Create Note', 'gravityforms' ) . '" class="button" style="width:auto;padding-bottom:2px;" onclick="jQuery(\'#action\').val(\'add_note\');"/>';
return $new_addnote_button;
}
add_filter('gform_addnote_button', 'modify_addnote_button_gforms');
@NikV
NikV / gfroms-examples.php
Created September 7, 2015 15:54
Never allow empty fields to be shown in an entry view
add_filter('gform_entry_detail_grid_display_empty_fields', '__return_false');