Making WordPress.org

Changeset 11383


Ignore:
Timestamp:
12/16/2021 07:37:44 AM (2 years ago)
Author:
dd32
Message:

Support Forums: Block links in reviews, force the reviewer to remove the links, and ultimately send the review to the moderation queue anyway.

If it turns out that reviewers seem to behave themselves, and remove the links (instead of evading the check), we can remove the moderation queue check.

Fixes #5748.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-ratings-compat.php

    r11382 r11383  
    342342    /**
    343343     * Replace warnings about 'topics' with warnings about 'reviews' when submitting a new review.
     344     * Add warnings about reviews containing links.
    344345     */
    345346    public function topic_pre_extras( $forum_id ) {
    346347        if ( Plugin::REVIEWS_FORUM_ID != $forum_id ) {
    347348            return;
     349        }
     350
     351        if (
     352            ! empty( $_POST['bbp_topic_content'] ) &&
     353            (
     354                false !== stripos( $_POST['bbp_topic_content'], 'https://' ) ||
     355                false !== stripos( $_POST['bbp_topic_content'], 'http://' )
     356            )
     357        ) {
     358            // Send this review to pending after it gets published.
     359            setcookie( 'wporg_review_to_pending', 'links_blocked', time() + HOUR_IN_SECONDS, '/support/', 'wordpress.org', true, true );
     360
     361            bbp_add_error(
     362                'no_links_please',
     363                sprintf(
     364                    /* translators: %s: Link to forum user guide explaining this. */
     365                    __( '<strong>Error</strong>: Please <a href="%s">do not add links to your review</a>, keep the review about your experience in text only.', 'wporg-forums' ),
     366                    'https://wordpress.org/support/forum-user-guide/faq/#why-are-links-not-allowed-in-reviews'
     367                )
     368            );
     369        } elseif ( ! empty( $_COOKIE['wporg_review_to_pending'] ) ) {
     370            add_filter( 'bbp_new_topic_pre_insert', function( $data ) {
     371                // If this is still for a review..
     372                if ( Plugin::REVIEWS_FORUM_ID == $data['post_parent'] ) {
     373                    // Clear the cookie.
     374                    setcookie( 'wporg_review_to_pending', '', time() - HOUR_IN_SECONDS, '/support/', 'wordpress.org', true, true );
     375
     376                    $data['post_status'] = bbp_get_pending_status_id();
     377                }
     378
     379                return $data;
     380            } );
    348381        }
    349382
Note: See TracChangeset for help on using the changeset viewer.