@@ -761,65 +761,59 @@ function wp_allow_comment( $commentdata, $wp_error = false ) {
761761 }
762762 }
763763
764- // Notes require logged in users that can edit the current post, ignore flooding check.
765- if ( isset ( $ commentdata ['comment_type ' ] ) && 'note ' === $ commentdata ['comment_type ' ] ) {
766- if ( ! isset ( $ commentdata ['comment_post_ID ' ] ) || ! current_user_can ( 'edit_post ' , $ commentdata ['comment_post_ID ' ] ) ) {
767- return new WP_Error ( 'comment_note_permission ' , __ ( 'You do not have permission edit notes on this post. ' ), 403 );
768- }
769- } else {
770- /**
771- * Fires immediately before a comment is marked approved.
772- *
773- * Allows checking for comment flooding.
774- *
775- * @since 2.3.0
776- * @since 4.7.0 The `$avoid_die` parameter was added.
777- * @since 5.5.0 The `$avoid_die` parameter was renamed to `$wp_error`.
778- *
779- * @param string $comment_author_ip Comment author's IP address.
780- * @param string $comment_author_email Comment author's email.
781- * @param string $comment_date_gmt GMT date the comment was posted.
782- * @param bool $wp_error Whether to return a WP_Error object instead of executing
783- * wp_die() or die() if a comment flood is occurring.
784- */
785- do_action (
786- 'check_comment_flood ' ,
787- $ commentdata ['comment_author_IP ' ],
788- $ commentdata ['comment_author_email ' ],
789- $ commentdata ['comment_date_gmt ' ],
790- $ wp_error
791- );
792764
793- /**
794- * Filters whether a comment is part of a comment flood.
795- *
796- * The default check is wp_check_comment_flood(). See check_comment_flood_db().
797- *
798- * @since 4.7.0
799- * @since 5.5.0 The `$avoid_die` parameter was renamed to `$wp_error`.
800- *
801- * @param bool $is_flood Is a comment flooding occurring? Default false.
802- * @param string $comment_author_ip Comment author's IP address.
803- * @param string $comment_author_email Comment author's email.
804- * @param string $comment_date_gmt GMT date the comment was posted.
805- * @param bool $wp_error Whether to return a WP_Error object instead of executing
806- * wp_die() or die() if a comment flood is occurring.
807- */
808- $ is_flood = apply_filters (
809- 'wp_is_comment_flood ' ,
810- false ,
811- $ commentdata ['comment_author_IP ' ],
812- $ commentdata ['comment_author_email ' ],
813- $ commentdata ['comment_date_gmt ' ],
814- $ wp_error
815- );
765+ /**
766+ * Fires immediately before a comment is marked approved.
767+ *
768+ * Allows checking for comment flooding.
769+ *
770+ * @since 2.3.0
771+ * @since 4.7.0 The `$avoid_die` parameter was added.
772+ * @since 5.5.0 The `$avoid_die` parameter was renamed to `$wp_error`.
773+ *
774+ * @param string $comment_author_ip Comment author's IP address.
775+ * @param string $comment_author_email Comment author's email.
776+ * @param string $comment_date_gmt GMT date the comment was posted.
777+ * @param bool $wp_error Whether to return a WP_Error object instead of executing
778+ * wp_die() or die() if a comment flood is occurring.
779+ */
780+ do_action (
781+ 'check_comment_flood ' ,
782+ $ commentdata ['comment_author_IP ' ],
783+ $ commentdata ['comment_author_email ' ],
784+ $ commentdata ['comment_date_gmt ' ],
785+ $ wp_error
786+ );
816787
817- if ( $ is_flood ) {
818- /** This filter is documented in wp-includes/comment-template.php */
819- $ comment_flood_message = apply_filters ( 'comment_flood_message ' , __ ( 'You are posting comments too quickly. Slow down. ' ) );
788+ /**
789+ * Filters whether a comment is part of a comment flood.
790+ *
791+ * The default check is wp_check_comment_flood(). See check_comment_flood_db().
792+ *
793+ * @since 4.7.0
794+ * @since 5.5.0 The `$avoid_die` parameter was renamed to `$wp_error`.
795+ *
796+ * @param bool $is_flood Is a comment flooding occurring? Default false.
797+ * @param string $comment_author_ip Comment author's IP address.
798+ * @param string $comment_author_email Comment author's email.
799+ * @param string $comment_date_gmt GMT date the comment was posted.
800+ * @param bool $wp_error Whether to return a WP_Error object instead of executing
801+ * wp_die() or die() if a comment flood is occurring.
802+ */
803+ $ is_flood = apply_filters (
804+ 'wp_is_comment_flood ' ,
805+ false ,
806+ $ commentdata ['comment_author_IP ' ],
807+ $ commentdata ['comment_author_email ' ],
808+ $ commentdata ['comment_date_gmt ' ],
809+ $ wp_error
810+ );
820811
821- return new WP_Error ( 'comment_flood ' , $ comment_flood_message , 429 );
822- }
812+ if ( $ is_flood ) {
813+ /** This filter is documented in wp-includes/comment-template.php */
814+ $ comment_flood_message = apply_filters ( 'comment_flood_message ' , __ ( 'You are posting comments too quickly. Slow down. ' ) );
815+
816+ return new WP_Error ( 'comment_flood ' , $ comment_flood_message , 429 );
823817 }
824818
825819 return wp_check_comment_data ( $ commentdata );
0 commit comments