Making WordPress.org

Changeset 12393


Ignore:
Timestamp:
02/13/2023 05:40:44 PM (8 months ago)
Author:
Clorith
Message:

Support Forums: Always require a reason for topic reports.

When reporting a topic, users have had the option to choose from a set of pre-determined reasons, or if none of the reasons were applicable, choosing the "other" alternative would give them a freeform text-field.

Using a pre-determined reason may leave reports short on context, where it could be down to the reporters interpretation why a reason was chosen, and would not be clear to those looking over reports.
This change addresses that by always requiring a user to not just choose a reason, but also provide context via the field asking "Why are you reporting this topic" when using the report tool in the sidebar.

Fixes #5706.

File:
1 edited

Legend:

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

    r10492 r12393  
    106106            wp_add_object_terms( $_POST['wporg-support-report-topic'], 'modlook', 'topic-tag' );
    107107
    108             $reason = $_POST['topic-report-reason'];
    109 
    110             if ( 'other-input' === $reason ) {
    111                 $reason = $_POST['topic-report-reason-other'];
    112             }
     108            $reason = sprintf(
     109                '%s: %s',
     110                $_POST['topic-report-reason'],
     111                $_POST['topic-report-reason-details']
     112            );
    113113
    114114            $this->add_modlook_history( $_POST['wporg-support-report-topic'], $reason );
     
    173173
    174174                <label for="topic-report-reason"><?php _e( 'Report this topic for:', 'wporg-forums' ); ?></label>
    175                 <select name="topic-report-reason" id="topic-report-reason" required="required" onchange="wporg_report_topic_change()">
     175                <select name="topic-report-reason" id="topic-report-reason" required="required">
    176176                    <option value=""><?php _ex( '&mdash; Choose one &mdash;', 'Report a topic reason', 'wporg-forums' ); ?></option>
    177177                    <option><?php _ex( 'Guideline violation', 'Report a topic reason', 'wporg-forums' ); ?></option>
     
    181181                    <option value="other-input"><?php _ex( 'Other', 'Report a topic reason', 'wporg-forums' ); ?></option>
    182182                </select>
    183                 <aside id="report-topic-other" style="display: none;">
    184                     <label for="topic-report-reason-other"><?php _e( 'Your own reason:', 'wporg-forums' ); ?></label>
    185                     <input type="text" name="topic-report-reason-other" id="topic-report-reason-other">
     183                <aside id="report-topic-other">
     184                    <label for="topic-report-reason-details"><?php _e( 'Why are you reporting this topic:', 'wporg-forums' ); ?></label>
     185                    <input type="text" name="topic-report-reason-details" id="topic-report-reason-details" required="required">
    186186                </aside>
    187187                <input type="submit" name="submit" value="<?php esc_attr_e( 'Report', 'wporg-forums' ); ?>">
    188188            </form>
    189 
    190             <script type="text/javascript">
    191                 function wporg_report_topic_change() {
    192                     if ( 'other-input' === document.getElementById('topic-report-reason').value ) {
    193                         document.getElementById( 'report-topic-other' ).style.display = 'block';
    194                     } else {
    195                         document.getElementById( 'report-topic-other' ).style.display = 'none';
    196                     }
    197                 }
    198             </script>
    199189<?php
    200190            $report_text = ob_get_clean();
Note: See TracChangeset for help on using the changeset viewer.