WordPress.org

Making WordPress.org

Changeset 9345


Ignore:
Timestamp:
12/16/2019 02:09:35 AM (2 years ago)
Author:
dd32
Message:

Theme Directory: Convert the uploads page into a real shortcode (That returns content) and hard-code the strings on the upload page to allow translation.

Props dingo_d.
Fixes #4839.

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
2 edited

Legend:

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

    r4116 r9345  
    1414function wporg_themes_render_upload_shortcode() {
    1515    if ( ! defined( 'THEME_TRACBOT_PASSWORD' ) || ! defined( 'THEME_DROPBOX_PASSWORD' ) ) {
    16         printf( '<!-- %s -->', 'Please define SVN and Trac passwords.' );
    17         return;
     16        return '<!-- Please define SVN and Trac passwords. -->';
    1817    }
    1918
    20     if ( is_user_logged_in() ) :
     19    if ( ! is_user_logged_in() ) {
    2120
    22         if ( ! empty( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'wporg-themes-upload' ) && 'upload' === $_POST['action'] ) {
    23             $message = wporg_themes_process_upload();
    24 
    25             if ( ! empty( $message ) ) {
    26                 echo "<div class='notice notice-warning'><p>{$message}</p></div>\n";
    27             }
    28         }
    29     ?>
    30         <h4><?php _e( 'Select your zipped theme file', 'wporg-themes' ); ?></h4>
    31         <form enctype="multipart/form-data" id="upload_form" method="POST" action="" onsubmit="jQuery('#upload_button').attr('disabled','disabled'); return true;">
    32             <?php wp_nonce_field( 'wporg-themes-upload' ); ?>
    33             <input type="hidden" name="action" value="upload"/>
    34             <input type="file" id="zip_file" name="zip_file" size="25"/>
    35             <input id="upload_button" class="button" type="submit" value="<?php esc_attr_e( 'Upload', 'wporg-themes' ); ?>"/>
    36 
    37             <p>
    38                 <small><?php printf( __( 'Maximum allowed file size: %s', 'wporg-themes' ), esc_html( wporg_themes_get_max_allowed_file_size() ) ); ?></small>
    39             </p>
    40         </form>
    41     <?php else : ?>
    42         <p><?php printf(
     21        $log_in_text = sprintf(
    4322            __( 'Before you can upload a new theme, <a href="%s">please log in</a>.', 'wporg-themes' ),
    4423            add_query_arg(
     
    4726                'https://login.wordpress.org/'
    4827            )
    49         ); ?><p>
    50     <?php endif;
     28        );
     29
     30        return '<p>' . $log_in_text . '</p>';
     31    }
     32
     33    $notice = '';
     34
     35    if ( ! empty( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'wporg-themes-upload' ) && 'upload' === $_POST['action'] ) {
     36        $message = wporg_themes_process_upload();
     37
     38        if ( ! empty( $message ) ) {
     39            $notice = "<div class='notice notice-warning'><p>{$message}</p></div>";
     40        }
     41    }
     42
     43    $form = '<h4>' . __( 'Select your zipped theme file', 'wporg-themes' ) . '</h4>
     44        <form enctype="multipart/form-data" id="upload_form" method="POST" action="" onsubmit="jQuery(\'#upload_button\').attr(\'disabled\',\'disabled\'); return true;">
     45            ' . wp_nonce_field( 'wporg-themes-upload', '_wpnonce', true, false ) . '
     46            <input type="hidden" name="action" value="upload"/>
     47            <input type="file" id="zip_file" name="zip_file" size="25"/>
     48            <button id="upload_button" class="button" type="submit" value="' . esc_attr__( 'Upload', 'wporg-themes' ) . '">' . esc_html__( 'Upload', 'wporg-themes' ) . '</button>
     49            <p>
     50                <small>' . sprintf( __( 'Maximum allowed file size: %s', 'wporg-themes' ), esc_html( wporg_themes_get_max_allowed_file_size() ) ) . '</small>
     51            </p>
     52        </form>';
     53
     54    return $notice . $form;
    5155}
    5256
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/page-upload.php

    r9211 r9345  
    3838            <div class="entry-content">
    3939                <p><?php esc_html_e( 'Your theme will be submitted for review to be distributed on the official WordPress.org Theme Directory.', 'wporg-themes' ); ?></p>
    40                 <?php the_content(); // do_shortcode( '[wporg-themes-upload]' ); ?>
     40                <h3><?php esc_html_e( 'Read the requirements before updating a theme', 'wporg-themes' ); ?></h3>
     41                <p><?php printf(
     42                    /* translators: 1: Link to WordPress.org; 2: Link to the Theme Handbook Requied Review items. */
     43                    __( 'In order to have your theme hosted on <a href="%1$s">WordPress.org</a>, your code is required to comply with all the <a href="%2$s">requirements on the Theme Review Teams handbook page</a>.'),
     44                    esc_url( 'https://wordpress.org/' ),
     45                    esc_url( 'https://make.wordpress.org/themes/handbook/review/required/' )
     46                ); ?></p>
     47                <div style="height: 20px;" aria-hidden="true" class="wp-block-spacer"></div>
     48                <?php the_content(); ?>
     49                <div style="height: 20px;" aria-hidden="true" class="wp-block-spacer"></div>
     50                <h3><?php esc_html_e( 'How to upload a theme update', 'wporg-themes' ); ?></h3>
     51                <p><?php printf(
     52                    /* translators: 1: style.css; 2: themename.zip */
     53                    __( 'If you are uploading a theme update, simply increase the version inside of %1$s and upload the %2$s file again, just like you do with a new theme.', 'wporg-themes' ),
     54                    '<code>style.css</code>',
     55                    '<code>themename.zip</code>'
     56                ); ?></p>
    4157            </div><!-- .entry-content -->
    4258
Note: See TracChangeset for help on using the changeset viewer.