Skip to content

Commit 8100c3f

Browse files
authored
gw-one-click-delete-field.php: Added new snippet.
1 parent 75ec40f commit 8100c3f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Gravity Wiz // Gravity Forms // One-click Delete Field in Compact View
4+
* https://gravitywiz.com/
5+
*
6+
* This snippet adds a one-click delete button (no confirmation) to each field when viewing the
7+
* form in compact view.
8+
*
9+
* Instructions:
10+
*
11+
* 1. Install the snippet.
12+
* https://gravitywiz.com/documentation/managing-snippets/#where-do-i-put-snippets
13+
*/
14+
add_action('admin_footer', function() {
15+
if ( GFForms::get_page() !== 'form_editor' ) {
16+
return;
17+
}
18+
?>
19+
<style>
20+
.gform-editor--compact .gw-delete-field {
21+
display: block !important;
22+
}
23+
</style>
24+
<script>
25+
jQuery( '.gform-compact-view-overflow-menu' ).each( function() {
26+
var fieldId = jQuery( this )[0].id.split( '_' )[2];
27+
jQuery( this ).before( '<button class="gw-delete-field gform-droplist__item-trigger--info gform-compact-view-overflow-menu__item-delete" onclick="proceedWithDeletion( ' + fieldId + ' )" style="display: none;min-height: auto;background: transparent;box-shadow: none;padding: 0;border-color:transparent;"><span class="gform-icon gform-icon--trash gform-droplist__item-trigger-icon" style="margin-inline-end:0;cursor:pointer;"></span><div class="gform-text gform-text--color-port gform-typography--size-text-sm gform-typography--weight-regular gform-droplist__item-trigger-text" style="display:none;">Delete</div></button>' )
28+
} );
29+
</script>
30+
<?php
31+
} );

0 commit comments

Comments
 (0)