WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/14/2010 07:58:06 PM (10 years ago)
Author:
scribu
Message:

Introduce submit_button(). Props markjaquith for initial patch. See #15064

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r15802 r15810  
    20872087}
    20882088
     2089/**
     2090 * Echos a paragraph-wrapped submit button, with provided text and appropriate class
     2091 *
     2092 * @since 3.1.0
     2093 *
     2094 * @param string $text The text of the button (defaults to 'Save Changes')
     2095 * @param string $type The type of button. One of: primary, secondary, delete
     2096 * @param string $name The HTML name of the submit button. Defaults to "submit"
     2097 */
     2098function submit_button( $text = NULL, $type = 'primary', $name = 'submit' ) {
     2099    echo get_submit_button( $text, $type, $name );
     2100}
     2101
     2102/**
     2103 * Returns a paragraph-wrapped submit button, with provided text and appropriate class
     2104 *
     2105 * @since 3.1.0
     2106 *
     2107 * @param string $text The text of the button (defaults to 'Save Changes')
     2108 * @param string $type The type of button. One of: primary, secondary, delete
     2109 * @param string $name The HTML name of the submit button. Defaults to "submit"
     2110 */
     2111function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit' ) {
     2112    switch ( $type ) :
     2113        case 'primary' :
     2114        case 'secondary' :
     2115            $class = 'button-' . $type;
     2116            break;
     2117        case 'delete' :
     2118            $class = 'button-secondary delete';
     2119            break;
     2120        default :
     2121            $class = $type; // Custom cases can just pass in the classes they want to be used
     2122    endswitch;
     2123    $text = ( NULL == $text ) ? __( 'Save Changes' ) : $text;
     2124    return '<p class="submit"><input type="submit" name="' . esc_attr( $name ) . '" class="' . esc_attr( $class ) . '" value="' . esc_attr( $text ) . '" /></p>';
     2125}
     2126
Note: See TracChangeset for help on using the changeset viewer.