Skip to content

Commit d65cdf4

Browse files
committed
Expand submit_button() capabilities. Replace all (or almost all) manual HTML instances in WP. props sbressler. see #15064
git-svn-id: https://develop.svn.wordpress.org/trunk@16061 602fd350-edb4-49c9-b593-d223f7449a82
1 parent bd29ca8 commit d65cdf4

56 files changed

Lines changed: 197 additions & 164 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

wp-admin/comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function comment_footer_die( $msg ) {
180180
<table width="100%">
181181
<tr>
182182
<td><a class="button" href="<?php echo admin_url('edit-comments.php'); ?>"><?php esc_attr_e('No'); ?></a></td>
183-
<td class="textright"><input type='submit' class="button" value='<?php echo esc_attr($button); ?>' /></td>
183+
<td class="textright"><?php submit_button( $button, 'button' ); ?></td>
184184
</tr>
185185
</table>
186186

wp-admin/custom-background.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function admin_page() {
210210
<td>
211211
<form method="post" action="">
212212
<?php wp_nonce_field('custom-background-remove', '_wpnonce-custom-background-remove'); ?>
213-
<input type="submit" class="button" name="remove-background" value="<?php esc_attr_e('Remove Background Image'); ?>" /><br/>
213+
<?php submit_button( __( 'Remove Background Image' ), 'button', 'remove-background', false ); ?><br/>
214214
<?php _e('This will remove the background image. You will not be able to restore any customizations.') ?>
215215
</form>
216216
</td>
@@ -223,7 +223,7 @@ function admin_page() {
223223
<td>
224224
<form method="post" action="">
225225
<?php wp_nonce_field('custom-background-reset', '_wpnonce-custom-background-reset'); ?>
226-
<input type="submit" class="button" name="reset-background" value="<?php esc_attr_e('Restore Original Image'); ?>" /><br/>
226+
<?php submit_button( __( 'Restore Original Image' ), 'button', 'reset-background', false ); ?><br/>
227227
<?php _e('This will restore the original background image. You will not be able to restore any customizations.') ?>
228228
</form>
229229
</td>
@@ -236,7 +236,7 @@ function admin_page() {
236236
<label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" />
237237
<input type="hidden" name="action" value="save" />
238238
<?php wp_nonce_field('custom-background-upload', '_wpnonce-custom-background-upload') ?>
239-
<input type="submit" class="button" value="<?php esc_attr_e('Upload'); ?>" />
239+
<?php submit_button( __( 'Upload' ), 'button', 'submit', false ); ?>
240240
</p>
241241
</form>
242242
</td>

wp-admin/custom-header.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ function step_1() {
468468
<input type="file" id="upload" name="import" />
469469
<input type="hidden" name="action" value="save" />
470470
<?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ) ?>
471-
<input type="submit" class="button" value="<?php esc_attr_e( 'Upload' ); ?>" />
471+
<?php submit_button( __( 'Upload' ), 'button', 'submit', false ); ?>
472472
</p>
473473
</form>
474474
</td>
@@ -501,7 +501,7 @@ function step_1() {
501501
<th scope="row"><?php _e( 'Remove Image' ); ?></th>
502502
<td>
503503
<p><?php _e( 'This will remove the header image. You will not be able to restore any customizations.' ) ?></p>
504-
<input type="submit" class="button" name="removeheader" value="<?php esc_attr_e( 'Remove Header Image' ); ?>" />
504+
<?php submit_button( __( 'Remove Header Image' ), 'button', 'removeheader', false ); ?>
505505
</td>
506506
</tr>
507507
<?php endif;
@@ -511,7 +511,7 @@ function step_1() {
511511
<th scope="row"><?php _e( 'Reset Image' ); ?></th>
512512
<td>
513513
<p><?php _e( 'This will restore the original header image. You will not be able to restore any customizations.' ) ?></p>
514-
<input type="submit" class="button" name="resetheader" value="<?php esc_attr_e( 'Restore Original Header Image' ); ?>" />
514+
<?php submit_button( __( 'Restore Original Header Image' ), 'button', 'resetheader', false ); ?>
515515
</td>
516516
</tr>
517517
<?php endif; ?>
@@ -550,7 +550,7 @@ function step_1() {
550550
<th scope="row"><?php _e('Reset Text Color'); ?></th>
551551
<td>
552552
<p><?php _e( 'This will restore the original header text. You will not be able to restore any customizations.' ) ?></p>
553-
<input type="submit" class="button" name="resettext" value="<?php esc_attr_e( 'Restore Original Header Text' ); ?>" />
553+
<?php submit_button( __( 'Restore Original Header Text' ), 'button', 'resettext', false ); ?>
554554
</td>
555555
</tr>
556556
<?php } ?>
@@ -563,7 +563,7 @@ function step_1() {
563563

564564
wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
565565

566-
<?php submit_button(); ?>
566+
<?php submit_button( null, 'primary', 'save-header-options' ); ?>
567567
</form>
568568
</div>
569569

wp-admin/edit-comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
<p class="search-box">
203203
<label class="screen-reader-text" for="comment-search-input"><?php _e( 'Search Comments' ); ?>:</label>
204204
<input type="text" id="comment-search-input" name="s" value="<?php _admin_search_query(); ?>" />
205-
<input type="submit" value="<?php esc_attr_e( 'Search Comments' ); ?>" class="button" />
205+
<?php submit_button( __( 'Search Comments' ), 'button', 'submit', false ); ?>
206206
</p>
207207

208208
<input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />

wp-admin/edit-form-comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=" . ( !EMPTY_TRASH_DAYS ? 'deletecomment' : 'trashcomment' ) . "&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . ( !EMPTY_TRASH_DAYS ? __('Delete Permanently') : __('Move to Trash') ) . "</a>\n"; ?>
7272
</div>
7373
<div id="publishing-action">
74-
<input type="submit" name="save" value="<?php esc_attr_e('Update Comment'); ?>" tabindex="4" class="button-primary" />
74+
<?php submit_button( __( 'Update Comment' ), 'primary', 'save', true, array( 'tabindex' => '4' ) ); ?>
7575
</div>
7676
<div class="clear"></div>
7777
</div>

wp-admin/edit-tags.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
<p class="search-box">
226226
<label class="screen-reader-text" for="tag-search-input"><?php echo $tax->labels->search_items; ?>:</label>
227227
<input type="text" id="tag-search-input" name="s" value="<?php _admin_search_query(); ?>" />
228-
<input type="submit" value="<?php echo esc_attr( $tax->labels->search_items ); ?>" class="button" />
228+
<?php submit_button( $tax->labels->search_items, 'button', 'submit', false ); ?>
229229
</p>
230230
</form>
231231
<br class="clear" />
@@ -334,9 +334,9 @@
334334
if ( ! is_taxonomy_hierarchical($taxonomy) )
335335
do_action('add_tag_form_fields', $taxonomy);
336336
do_action($taxonomy . '_add_form_fields', $taxonomy);
337-
?>
338-
<p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" /></p>
339-
<?php
337+
338+
submit_button( $tax->labels->add_new_item );
339+
340340
// Back compat hooks. Deprecated in preference to {$taxonomy}_add_form
341341
if ( 'category' == $taxonomy )
342342
do_action('edit_category_form', (object)array('parent' => 0) );

wp-admin/edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
<p class="search-box">
224224
<label class="screen-reader-text" for="post-search-input"><?php echo $post_type_object->labels->search_items; ?>:</label>
225225
<input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
226-
<input type="submit" value="<?php echo esc_attr( $post_type_object->labels->search_items ); ?>" class="button" />
226+
<?php submit_button( $post_type_object->labels->search_items, 'button', 'submit', false ); ?>
227227
</p>
228228

229229
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_REQUEST['post_status']) ? esc_attr($_REQUEST['post_status']) : 'all'; ?>" />

wp-admin/export.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.'); ?></p>
5454
<p><?php _e('Once you&#8217;ve saved the download file, you can use the Import function on another WordPress site to import this site.'); ?></p>
5555
<form action="" method="get">
56-
<?php submit_button( __('Download Export File'), 'secondary' ); ?>
56+
<?php submit_button( __('Download Export File'), 'button' ); ?>
5757
<input type="hidden" name="download" value="true" />
5858
</p>
5959
</form>

wp-admin/includes/class-wp-list-table.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ function bulk_actions() {
253253
echo "\t<option value='$name'>$title</option>\n";
254254
echo "</select>\n";
255255

256-
echo "<input type='submit' value='" . esc_attr__( 'Apply' ) . "' name='doaction$two' id='doaction$two' class='button-secondary action' />\n";
256+
submit_button( __( 'Apply' ), 'button-secondary action', "doaction$two", false );
257+
echo "\n";
257258
}
258259

259260
/**

wp-admin/includes/dashboard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ function wp_dashboard_quick_press_output() {
479479
<input type="hidden" name="quickpress_post_ID" value="<?php echo $post_ID; ?>" />
480480
<input type="hidden" name="post_type" value="post" />
481481
<?php wp_nonce_field('add-post'); ?>
482-
<input type="submit" name="save" id="save-post" class="button" tabindex="4" value="<?php esc_attr_e('Save Draft'); ?>" />
482+
<?php submit_button( __( 'Save Draft' ), 'button', 'save', false, array( 'id' => 'save-post', 'tabindex'=> 4 ) ); ?>
483483
<input type="reset" value="<?php esc_attr_e( 'Reset' ); ?>" class="button" />
484484
<span id="publishing-action">
485485
<input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?>" />

0 commit comments

Comments
 (0)