WordPress.org

Make WordPress Core

Ticket #15765: 15765.patch

File 15765.patch, 7.0 KB (added by toscho, 16 months ago)

Add 'required' attribute to prevent accidental submissions. Fix code style violations en passant.

  • site-new.php

     
    1818 
    1919        get_current_screen()->add_help_tab( array( 
    2020                'id'      => 'overview', 
    21                 'title'   => __('Overview'), 
     21                'title'   => __( 'Overview' ), 
    2222                'content' => 
    23                         '<p>' . __('This screen is for Super Admins to add new sites to the network. This is not affected by the registration settings.') . '</p>' . 
    24                         '<p>' . __('If the admin email for the new site does not exist in the database, a new user will also be created.') . '</p>' 
     23                        '<p>' . __( 'This screen is for Super Admins to add new sites to the network. This is not affected by the registration settings.' ) . '</p>' . 
     24                        '<p>' . __( 'If the admin email for the new site does not exist in the database, a new user will also be created.' ) . '</p>' 
    2525) ); 
    2626 
    2727get_current_screen()->set_help_sidebar( 
    28         '<p><strong>' . __('For more information:') . '</strong></p>' . 
    29         '<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' . 
    30         '<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>' 
     28        '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 
     29        '<p>' . __( '<a href="http://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>' ) . '</p>' . 
     30        '<p>' . __( '<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>' ) . '</p>' 
    3131); 
    3232 
    3333if ( isset($_REQUEST['action']) && 'add-site' == $_REQUEST['action'] ) { 
     
    4747        if ( ! is_subdomain_install() ) { 
    4848                $subdirectory_reserved_names = apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed' ) ); 
    4949                if ( in_array( $domain, $subdirectory_reserved_names ) ) 
    50                         wp_die( sprintf( __('The following words are reserved for use by WordPress functions and cannot be used as blog names: <code>%s</code>' ), implode( '</code>, <code>', $subdirectory_reserved_names ) ) ); 
     50                        wp_die( sprintf( __( 'The following words are reserved for use by WordPress functions and cannot be used as blog names: <code>%s</code>' ), implode( '</code>, <code>', $subdirectory_reserved_names ) ) ); 
    5151        } 
    5252 
    5353        $email = sanitize_email( $blog['email'] ); 
     
    8989 
    9090Address: %2$s 
    9191Name: %3$s' ), $current_user->user_login , get_site_url( $id ), stripslashes( $title ) ); 
    92                 wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' ); 
     92                wp_mail( get_site_option( 'admin_email' ), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' ); 
    9393                wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) ); 
    9494                wp_redirect( add_query_arg( array( 'update' => 'added', 'id' => $id ), 'site-new.php' ) ); 
    9595                exit; 
     
    104104                $messages[] = sprintf( __( 'Site added. <a href="%1$s">Visit Dashboard</a> or <a href="%2$s">Edit Site</a>' ), esc_url( get_admin_url( absint( $_GET['id'] ) ) ), network_admin_url( 'site-info.php?id=' . absint( $_GET['id'] ) ) ); 
    105105} 
    106106 
    107 $title = __('Add New Site'); 
     107$title = __( 'Add New Site' ); 
    108108$parent_file = 'sites.php'; 
    109109 
    110 require('../admin-header.php'); 
     110require( '../admin-header.php' ); 
    111111 
    112112?> 
    113113 
    114114<div class="wrap"> 
    115 <?php screen_icon('ms-admin'); ?> 
    116 <h2 id="add-new-site"><?php _e('Add New Site') ?></h2> 
     115<?php screen_icon( 'ms-admin' ); ?> 
     116<h2 id="add-new-site"><?php _e( 'Add New Site' ); ?></h2> 
    117117<?php 
    118118if ( ! empty( $messages ) ) { 
    119119        foreach ( $messages as $msg ) 
    120120                echo '<div id="message" class="updated"><p>' . $msg . '</p></div>'; 
    121121} ?> 
    122 <form method="post" action="<?php echo network_admin_url('site-new.php?action=add-site'); ?>"> 
    123 <?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ) ?> 
     122<form method="post" action="<?php echo network_admin_url( 'site-new.php?action=add-site' ); ?>"> 
     123<?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ); ?> 
    124124        <table class="form-table"> 
    125125                <tr class="form-field form-required"> 
    126                         <th scope="row"><?php _e( 'Site Address' ) ?></th> 
     126                        <th scope="row"> 
     127                                <label for="blog[domain]"><?php _e( 'Site Address' ); ?>  
     128                                        <span class="description"><?php _e( '(required)' ); ?></span> 
     129                                </label> 
     130                        </th> 
    127131                        <td> 
    128132                        <?php if ( is_subdomain_install() ) { ?> 
    129                                 <input name="blog[domain]" type="text" class="regular-text" title="<?php esc_attr_e( 'Domain' ) ?>"/><span class="no-break">.<?php echo preg_replace( '|^www\.|', '', $current_site->domain ); ?></span> 
     133                                <input name="blog[domain]" type="text" class="regular-text" title="<?php esc_attr_e( 'Domain' ); ?>" required="required" /><span class="no-break">.<?php echo preg_replace( '|^www\.|', '', $current_site->domain ); ?></span> 
    130134                        <?php } else { 
    131                                 echo $current_site->domain . $current_site->path ?><input name="blog[domain]" class="regular-text" type="text" title="<?php esc_attr_e( 'Domain' ) ?>"/> 
     135                                echo $current_site->domain . $current_site->path ?><input name="blog[domain]" class="regular-text" type="text" title="<?php esc_attr_e( 'Domain' ); ?>" required="required" /> 
    132136                        <?php } 
    133137                        echo '<p>' . __( 'Only lowercase letters (a-z) and numbers are allowed.' ) . '</p>'; 
    134138                        ?> 
    135139                        </td> 
    136140                </tr> 
    137141                <tr class="form-field form-required"> 
    138                         <th scope="row"><?php _e( 'Site Title' ) ?></th> 
    139                         <td><input name="blog[title]" type="text" class="regular-text" title="<?php esc_attr_e( 'Title' ) ?>"/></td> 
     142                        <th scope="row"> 
     143                                <label for="blog[title]"><?php _e( 'Site Title' ); ?>  
     144                                        <span class="description"><?php _e( '(required)' ); ?></span> 
     145                                </label> 
     146                        </th> 
     147                        <td><input name="blog[title]" type="text" class="regular-text" title="<?php esc_attr_e( 'Title' ); ?>" required="required" /></td> 
    140148                </tr> 
    141149                <tr class="form-field form-required"> 
    142                         <th scope="row"><?php _e( 'Admin Email' ) ?></th> 
    143                         <td><input name="blog[email]" type="text" class="regular-text" title="<?php esc_attr_e( 'Email' ) ?>"/></td> 
     150                        <th scope="row"> 
     151                                <label for="blog[email]"><?php _e( 'Admin Email' ); ?>  
     152                                        <span class="description"><?php _e( '(required)' ); ?></span> 
     153                                </label> 
     154                        </th> 
     155                        <td><input name="blog[email]" type="text" class="regular-text" title="<?php esc_attr_e( 'Email' ); ?>" required="required" /></td> 
    144156                </tr> 
    145157                <tr class="form-field"> 
    146                         <td colspan="2"><?php _e( 'A new user will be created if the above email address is not in the database.' ) ?><br /><?php _e( 'The username and password will be mailed to this email address.' ) ?></td> 
     158                        <td colspan="2"><?php _e( 'A new user will be created if the above email address is not in the database.' ); ?><br /><?php _e( 'The username and password will be mailed to this email address.' ); ?></td> 
    147159                </tr> 
    148160        </table> 
    149         <?php submit_button( __('Add Site'), 'primary', 'add-site' ); ?> 
     161        <?php submit_button( __( 'Add Site' ), 'primary', 'add-site' ); ?> 
    150162        </form> 
    151163</div> 
    152164<?php 
    153 require('../admin-footer.php'); 
     165require( '../admin-footer.php' );