Changeset 16061 for trunk/wp-admin/includes/template.php
- Timestamp:
- 10/28/2010 09:56:43 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r15976 r16061 496 496 $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />"; 497 497 498 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' "; 499 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />"; 500 $r .= "\n\t\t<input name='updatemeta' type='submit' tabindex='6' value='". esc_attr__( 'Update' ) ."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce updatemeta' /></div>"; 498 $r .= "\n\t\t<div class='submit'>"; 499 $r .= get_submit_button( __( 'Delete' ), "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta", "deletemeta[{$entry['meta_id']}]", false, array( 'tabindex' => '6' ) ); 500 $r .= "\n\t\t"; 501 $r .= get_submit_button( __( 'Update' ), "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce updatemeta" , 'updatemeta', false, array( 'tabindex' => '6' ) ); 502 $r .= "</div>"; 501 503 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); 502 504 $r .= "</td>"; … … 558 560 559 561 <tr><td colspan="2" class="submit"> 560 < input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php esc_attr_e( 'Add Custom Field' ) ?>" />562 <?php submit_button( __( 'Add Custom Field' ), 'add:the-list:newmeta', 'addmeta', false, array( 'id' => 'addmetasub', 'tabindex' => '9' ) ); ?> 561 563 <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?> 562 564 </td></tr> … … 844 846 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> 845 847 </p> 846 <?php submit_button( __('Upload file and import'), ' secondary' ); ?>848 <?php submit_button( __('Upload file and import'), 'button' ); ?> 847 849 </form> 848 850 <?php … … 1358 1360 <div class="find-box-buttons"> 1359 1361 <input id="find-posts-close" type="button" class="button alignleft" value="<?php esc_attr_e('Close'); ?>" /> 1360 < input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />1362 <?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?> 1361 1363 </div> 1362 1364 </div> … … 1890 1892 if ( !empty($per_page_label) ) 1891 1893 $return .= "<input type='text' class='screen-per-page' name='wp_screen_options[value]' id='$option' maxlength='3' value='$per_page' /> <label for='$option'>$per_page_label</label>\n"; 1892 $return .= "<input type='submit' class='button' value='" . esc_attr__('Apply') . "' />";1894 $return .= get_submit_button( __( 'Apply' ), 'button', '', false ); 1893 1895 $return .= "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />"; 1894 1896 $return .= "</div>\n"; … … 2087 2089 2088 2090 /** 2089 * Echos a paragraph-wrappedsubmit button, with provided text and appropriate class2091 * Echos a submit button, with provided text and appropriate class 2090 2092 * 2091 2093 * @since 3.1.0 … … 2093 2095 * @param string $text The text of the button (defaults to 'Save Changes') 2094 2096 * @param string $type The type of button. One of: primary, secondary, delete 2095 * @param string $name The HTML name of the submit button. Defaults to "submit" 2096 */ 2097 function submit_button( $text = NULL, $type = 'primary', $name = 'submit' ) { 2098 echo get_submit_button( $text, $type, $name ); 2099 } 2100 2101 /** 2102 * Returns a paragraph-wrapped submit button, with provided text and appropriate class 2097 * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute 2098 * is given in $other_attributes below, $name will be used as the button's id. 2099 * @param bool $wrap True if the output button should be wrapped in a paragraph tag, 2100 * false otherwise. Defaults to true 2101 * @param array|string $other_attributes Other attributes that should be output with the button, 2102 * mapping attributes to their values, such as array( 'tabindex' => '1' ). 2103 * These attributes will be ouput as attribute="value", such as tabindex="1". 2104 * Defaults to no other attributes. Other attributes can also be provided as a 2105 * string such as 'tabindex="1"', though the array format is typically cleaner. 2106 */ 2107 function submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) { 2108 echo get_submit_button( $text, $type, $name, $wrap, $other_attributes ); 2109 } 2110 2111 /** 2112 * Returns a submit button, with provided text and appropriate class 2103 2113 * 2104 2114 * @since 3.1.0 … … 2106 2116 * @param string $text The text of the button (defaults to 'Save Changes') 2107 2117 * @param string $type The type of button. One of: primary, secondary, delete 2108 * @param string $name The HTML name of the submit button. Defaults to "submit" 2109 */ 2110 function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit' ) { 2118 * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute 2119 * is given in $other_attributes below, $name will be used as the button's id. 2120 * @param bool $wrap True if the output button should be wrapped in a paragraph tag, 2121 * false otherwise. Defaults to true 2122 * @param array|string $other_attributes Other attributes that should be output with the button, 2123 * mapping attributes to their values, such as array( 'tabindex' => '1' ). 2124 * These attributes will be ouput as attribute="value", such as tabindex="1". 2125 * Defaults to no other attributes. Other attributes can also be provided as a 2126 * string such as 'tabindex="1"', though the array format is typically cleaner. 2127 */ 2128 function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) { 2111 2129 switch ( $type ) : 2112 2130 case 'primary' : … … 2121 2139 endswitch; 2122 2140 $text = ( NULL == $text ) ? __( 'Save Changes' ) : $text; 2123 return '<p class="submit"><input type="submit" name="' . esc_attr( $name ) . '" class="' . esc_attr( $class ) . '" value="' . esc_attr( $text ) . '" /></p>'; 2124 } 2125 2141 2142 $attributes = ''; 2143 if ( is_array( $other_attributes ) ) { 2144 foreach ( $other_attributes as $attribute => $value ) { 2145 $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important 2146 } 2147 } else if ( !empty( $other_attributes ) ) { // Attributes provided as a string 2148 $attributes = $other_attributes; 2149 } 2150 2151 // Default the id attribute to $name unless an id was specifically provided in $other_attributes 2152 $id = 'id="' . esc_attr( $name ) . '" '; 2153 if ( is_array( $other_attributes ) && array_key_exists( 'id', $other_attributes ) ) { 2154 $id = 'id="' . esc_attr( $other_attributes['id'] ) . '" '; 2155 } 2156 2157 $button = '<input type="submit" name="' . esc_attr( $name ) . '" id="' . $id . '" class="' . esc_attr( $class ); 2158 $button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />'; 2159 2160 if ( $wrap ) { 2161 $button = '<p class="submit">' . $button . '</p>'; 2162 } 2163 2164 return $button; 2165 } 2166
Note: See TracChangeset
for help on using the changeset viewer.