Skip to content

Instantly share code, notes, and snippets.

View NikV's full-sized avatar
🎯
Focusing

Nikhil Vimal NikV

🎯
Focusing
View GitHub Profile
<?php
/**
* Plugin Name: EDD Graph Dashboard Widget
* Description:
* Author: Nikhil Vimal
* Author URI: http://nik.techvoltz.com
* Version: 1.0
* Plugin URI:
* License: GNU GPLv2+
*/
<?php
/**
* Plugin Name: Gravity Forms for Admin Pages
* Description: Show a Gravity Form on an admin page.
* Author: Nikhil Vimal
* Author URI: http://nik.techvoltz.com
* Version: 1.0
* License: GNU GPLv2+
*/
@NikV
NikV / gfroms-examples.php
Created September 6, 2015 14:00
Modify The New Form Button
function modify_gform_new_form_button() {
return '<input id="save_new_form" type="button" class="button button-large button-primary my-custom-button-class" value="' . esc_html__( 'Build a Form', 'gravityforms' ) . '" onclick="saveNewForm();" tabindex="9002" />';
}
add_filter('gform_new_form_button', 'modify_gform_new_form_button');
@NikV
NikV / gfroms-examples.php
Created September 6, 2015 20:46
Change avatar size in an entry note
function modify_gform_notes_avatar( $note_avatar, $note ) {
$note_avatar = get_avatar( $note->user_id, 38 );
return $note_avatar;
}
add_filter('gform_notes_avatar', 'modify_gform_notes_avatar', 10, 2);
@NikV
NikV / gfroms-examples.php
Created September 7, 2015 15:51
Only allow users to save a form if they can use settings in the WordPress admin
function modify_gform_save_form_button( $save_button ) {
if ( current_user_can('manage_options')) {
return $save_button;
}
}
add_filter('gform_save_form_button', 'modify_gform_save_form_button');
@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');
@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 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
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: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');