Making WordPress.org


Ignore:
Timestamp:
10/11/2021 04:35:48 AM (3 years ago)
Author:
dd32
Message:

Theme Directory: Add a set of checkboxes authors must agree to before uploads can be processed.

This ensures that authors are aware of the requirements prior to the upload being processed (and we can now assume they are aware of it).

The result of these checkboxes are not stored anywhere, but the upload cannot proceed unless they're checked, so all uploads after now will have agreed with them.

Fixes #1514.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/upload.php

    r11176 r11271  
    3030function wporg_themes_render_upload_shortcode() {
    3131    if ( ! is_user_logged_in() ) {
    32 
    33         $log_in_text = sprintf(
    34             __( 'Before you can upload a new theme, <a href="%s">please log in</a>.', 'wporg-themes' ),
     32        return sprintf(
     33            '<p>' . __( 'Before you can upload a new theme, <a href="%s">please log in</a>.', 'wporg-themes' ) . '</p>',
    3534            add_query_arg(
    3635                'redirect_to',
     
    3938            )
    4039        );
    41 
    42         return '<p>' . $log_in_text . '</p>';
    4340    }
    4441
    45     $notice = '';
     42    $notice       = '';
     43    $terms_notice = '';
    4644
    4745    if (
     
    5351
    5452        $notice_content = '';
     53        $code           = '';
    5554
    5655        if ( is_wp_error( $messages ) ) {
     
    6362        }
    6463
    65         $notice = "<div class='notice notice-warning notice-large'><ul>{$notice_content}</ul></div>";
     64        if ( 'pre_upload_terms' === $code ) {
     65            $terms_notice = "<div class='notice notice-error notice-large'><ul>{$notice_content}</ul></div>";
     66        } else {
     67            $notice = "<div class='notice notice-warning notice-large'><ul>{$notice_content}</ul></div>";
     68        }
    6669    }
    6770
    68     $form = '<h2>' . __( 'Select your zipped theme file', 'wporg-themes' ) . '</h2>
     71    return $notice . '<h2>' . __( 'Select your zipped theme file', 'wporg-themes' ) . '</h2>
    6972        <form enctype="multipart/form-data" id="upload_form" method="POST" action="" onsubmit="jQuery(\'#upload_button\').attr(\'disabled\',\'disabled\'); return true;">
    7073            ' . wp_nonce_field( 'wporg-themes-upload', '_wpnonce', true, false ) . '
    7174            <input type="hidden" name="action" value="upload"/>
    7275            <input type="file" id="zip_file" name="zip_file" size="25"/>
    73             <button id="upload_button" class="button" type="submit" value="' . esc_attr__( 'Upload', 'wporg-themes' ) . '">' . esc_html__( 'Upload', 'wporg-themes' ) . '</button>
    7476            <p>
    7577                <small>' . sprintf( __( 'Maximum allowed file size: %s', 'wporg-themes' ), esc_html( size_format( wp_max_upload_size() ) ) ) . '</small>
    7678            </p>
     79
     80            ' . $terms_notice . '
     81
     82            <p>
     83                <label><input type="checkbox" required="required" name="required_terms[permission]"> ' . __( 'I have permission to upload this theme to WordPress.org for others to use and share.', 'wporg-themes' ) . '</label><br>
     84                <label><input type="checkbox" required="required" name="required_terms[guidelines]"> ' . sprintf( __( 'The theme complies with all <a href="%s">Theme Guidelines</a>.', 'wporg-themes' ), 'https://make.wordpress.org/themes/handbook/review/required/' ) . '</label><br>
     85                <label><input type="checkbox" required="required" name="required_terms[gpl]"> ' . sprintf( __( 'The theme, and all included assets, <a href="%s">are licenced as GPL or are under a GPL compatible license</a>.', 'wporg-themes' ), 'https://make.wordpress.org/themes/handbook/review/required/#1-licensing-copyright' ) . '</label><br>
     86            </p>
     87
     88            <button id="upload_button" class="button" type="submit" value="' . esc_attr__( 'Upload', 'wporg-themes' ) . '">' . esc_html__( 'Upload', 'wporg-themes' ) . '</button>
    7789        </form>';
    78 
    79     return $notice . $form;
    8090}
    8191
     
    100110    }
    101111
     112    if ( empty( $_POST['required_terms'] ) || count( $_POST['required_terms'] ) !== 3 ) {
     113        return new WP_Error(
     114            'pre_upload_terms',
     115            __( 'Please agree to terms below.', 'wporg-themes' )
     116        );
     117    }
     118
    102119    if ( ! class_exists( 'WPORG_Themes_Upload' ) ) {
    103120        include_once __DIR__ . '/class-wporg-themes-upload.php';
Note: See TracChangeset for help on using the changeset viewer.