Skip to content

Commit

Permalink
Forms: Fixes permenatly delete form responses (#41321)
Browse files Browse the repository at this point in the history
* Forms: fix permenatly delete form response inline

* changelog

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/13009868937

Upstream-Ref: Automattic/jetpack@58a5a3b
  • Loading branch information
enejb authored and matticbot committed Jan 28, 2025
1 parent 613f079 commit 84291e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This is an alpha version! The changes listed here are not final.

### Fixed
- Forms: fix dark themes date picker styles
- Forms: Fix permently deleting form reponses via the quicklinks
- Forms: Prevent empty style values within form field block attributes

## [0.35.1] - 2025-01-27
Expand Down
2 changes: 1 addition & 1 deletion dist/contact-form/js/grunion-admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/contact-form/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,14 @@ public function grunion_ajax_spam() {
if ( ! wp_trash_post( $post_id ) ) {
wp_die( esc_html__( 'Error in moving to Trash.', 'jetpack-forms' ) );
}
} elseif ( $_POST['make_it'] === 'delete' ) {
if ( ! current_user_can( $post_type_object->cap->delete_post, $post_id ) ) {
wp_die( esc_html__( 'You are not allowed to move this item to the Trash.', 'jetpack-forms' ) );
}

if ( ! wp_delete_post( $post_id, true ) ) {
wp_die( esc_html__( 'Error in deleting post.', 'jetpack-forms' ) );
}
}

$sql = "
Expand Down
5 changes: 5 additions & 0 deletions src/contact-form/js/grunion-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ jQuery( function ( $ ) {
e.preventDefault();
updateStatus( postId, 'publish', '#59C859' );
}

if ( $( e.target ).parent().hasClass( 'delete' ) ) {
e.preventDefault();
updateStatus( postId, 'delete', '#FF7979' );
}
} );
} );

Expand Down

0 comments on commit 84291e4

Please sign in to comment.