Making WordPress.org


Ignore:
Timestamp:
12/16/2019 02:09:35 AM (7 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.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.