WordPress.org

Make WordPress Core

Ticket #15064: 15064.diff

File 15064.diff, 3.3 KB (added by markjaquith, 4 years ago)

First swing, and a few sample implementations.

  • options-privacy.php

     
    5050 
    5151<?php do_settings_sections('privacy'); ?> 
    5252 
    53 <p class="submit"> 
    54         <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /> 
    55 </p> 
     53<?php submit_button(); ?> 
    5654</form> 
    5755 
    5856</div> 
  • includes/template.php

     
    20642064        $current_screen = apply_filters('current_screen', $current_screen); 
    20652065} 
    20662066 
     2067/** 
     2068 * Echos a paragraph-wrapped submit button, with provided text and appropriate class 
     2069 * @param string $text The text of the button (defaults to 'Save Changes') 
     2070 * @param string $type The type of button. One of: primary, secondary, delete 
     2071 * @param string $name The HTML name of the submit button. Defaults to "submit" 
     2072 */ 
     2073function submit_button( $text = NULL, $type = 'primary', $name = 'submit' ) { 
     2074        echo get_submit_button( $text, $type, $name ); 
     2075} 
     2076 
     2077/** 
     2078 * Returns a paragraph-wrapped submit button, with provided text and appropriate class 
     2079 * @param string $text The text of the button (defaults to 'Save Changes') 
     2080 * @param string $type The type of button. One of: primary, secondary, delete 
     2081 * @param string $name The HTML name of the submit button. Defaults to "submit" 
     2082 */ 
     2083function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit' ) { 
     2084        switch ( $type ) : 
     2085                case 'primary' : 
     2086                case 'secondary' : 
     2087                        $class = 'button-' . $type; 
     2088                        break; 
     2089                case 'delete' : 
     2090                        $class = 'button-secondary delete'; 
     2091                        break; 
     2092                default : 
     2093                        $class = $type; // Custom cases can just pass in the classes they want to be used 
     2094        endswitch; 
     2095        $text = ( NULL == $text ) ? __( 'Save Changes' ) : $text; 
     2096        return '<p class="submit"><input type="submit" name="' . esc_attr( $name ) . ' class="' . esc_attr( $class ) . '" value="' . esc_attr( $text ) . '" /></p>'; 
     2097} 
  • options-media.php

     
    132132 
    133133<?php do_settings_sections('media'); ?> 
    134134 
    135 <p class="submit"> 
    136         <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /> 
    137 </p> 
     135<?php submit_button(); ?> 
    138136 
    139137</form> 
    140138 
  • options-permalink.php

     
    221221 
    222222<?php do_settings_sections('permalink'); ?> 
    223223 
    224 <p class="submit"> 
    225         <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /> 
    226 </p> 
     224<?php submit_button(); ?> 
    227225  </form> 
    228226<?php if ( !is_multisite() ) { ?> 
    229227<?php if ( $iis7_permalinks ) : 
  • options-writing.php

     
    148148 
    149149<?php do_settings_sections('writing'); ?> 
    150150 
    151 <p class="submit"> 
    152         <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /> 
    153 </p> 
     151<?php submit_button(); ?> 
    154152</form> 
    155153</div> 
    156154