Making WordPress.org


Ignore:
Timestamp:
12/16/2021 07:07:11 AM (5 years ago)
Author:
dd32
Message:

Support Forums: Update two errors on the review form to reference review rather than topic.

Fixes #5295.

File:
1 edited

Legend:

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

    r10822 r11382  
    7373                add_action( 'bbp_new_topic_post_extras', array( $this, 'topic_post_extras' ) );
    7474                add_action( 'bbp_edit_topic_post_extras', array( $this, 'topic_post_extras' ) );
     75
     76                // Checks for review topics.
     77                add_action( 'bbp_new_topic_pre_extras', array( $this, 'topic_pre_extras' ) );
    7578
    7679                // Add the rating to the Feed body/title
     
    338341
    339342        /**
     343         * Replace warnings about 'topics' with warnings about 'reviews' when submitting a new review.
     344         */
     345        public function topic_pre_extras( $forum_id ) {
     346                if ( Plugin::REVIEWS_FORUM_ID != $forum_id ) {
     347                        return;
     348                }
     349
     350                if ( ! bbp_has_errors() ) {
     351                        return;
     352                }
     353
     354                // Replace the warnings about topics being too short with reviews.
     355
     356                // bbPress doesn't have a wrapper to check for specific errors, so we'll reach into bbPress.
     357                if ( bbpress()->errors->get_error_message( 'bbp_topic_title' ) && empty( $_POST['bbp_topic_title'] ) ) {
     358                        bbpress()->errors->remove( 'bbp_topic_title' );
     359                        bbp_add_error( 'bbp_topic_title', __( '<strong>Error</strong>: Your review needs a title.', 'wporg-forums' ) );
     360                }
     361
     362                if ( bbpress()->errors->get_error_message( 'bbp_topic_content' ) ) {
     363                        bbpress()->errors->remove( 'bbp_topic_content' );
     364                        bbp_add_error( 'bbp_topic_content', __( '<strong>Error</strong>: Your review cannot be empty.', 'wporg-forums' ) );
     365                }
     366        }
     367
     368        /**
    340369         * Check if the current user already has a review for the plugin or theme being viewed.
    341370         *
Note: See TracChangeset for help on using the changeset viewer.