Skip to content

Commit dc29eb2

Browse files
dd32claude
andcommitted
check reporter hasn't already flagged it
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 416e65f commit dc29eb2

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎public_html/wp-content/themes/wporg-pattern-directory-2024/functions.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ function do_pattern_actions() {
101101
}
102102
} else if ( 'report' === $action ) {
103103
if ( wp_verify_nonce( $nonce, 'report-' . $post_id ) && current_user_can( 'read' ) ) {
104+
$existing = new \WP_Query( array(
105+
'post_type' => FLAG_POST_TYPE,
106+
'post_parent' => $post_id,
107+
'post_status' => PENDING_STATUS,
108+
'author' => get_current_user_id(),
109+
) );
110+
if ( $existing->found_posts > 0 ) {
111+
wp_safe_redirect( add_query_arg( array( 'status' => 'already-reported' ), get_the_permalink() ) );
112+
return;
113+
}
114+
104115
$success = wp_insert_post(
105116
array(
106117
'post_type' => FLAG_POST_TYPE,

‎public_html/wp-content/themes/wporg-pattern-directory-2024/patterns/single-pattern.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
} else if ( 'reported' === $action_status ) {
1717
$notice_type = 'info';
1818
$notice = __( 'Your report has been submitted.', 'wporg-patterns' );
19+
} else if ( 'already-reported' === $action_status ) {
20+
$notice = __( 'You have already reported this pattern.', 'wporg-patterns' );
1921
}
2022

2123
?>

0 commit comments

Comments
 (0)