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

git-svn-id: http://svn.automattic.com/wordpress/trunk@15810 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-10-14 19:58:06 +00:00
parent ff2348047e
commit 1cce7d7830
8 changed files with 45 additions and 21 deletions

View File

@ -2086,3 +2086,41 @@ function set_current_screen( $id = '' ) {
$current_screen = apply_filters('current_screen', $current_screen);
}
/**
* Echos a paragraph-wrapped submit button, with provided text and appropriate class
*
* @since 3.1.0
*
* @param string $text The text of the button (defaults to 'Save Changes')
* @param string $type The type of button. One of: primary, secondary, delete
* @param string $name The HTML name of the submit button. Defaults to "submit"
*/
function submit_button( $text = NULL, $type = 'primary', $name = 'submit' ) {
echo get_submit_button( $text, $type, $name );
}
/**
* Returns a paragraph-wrapped submit button, with provided text and appropriate class
*
* @since 3.1.0
*
* @param string $text The text of the button (defaults to 'Save Changes')
* @param string $type The type of button. One of: primary, secondary, delete
* @param string $name The HTML name of the submit button. Defaults to "submit"
*/
function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit' ) {
switch ( $type ) :
case 'primary' :
case 'secondary' :
$class = 'button-' . $type;
break;
case 'delete' :
$class = 'button-secondary delete';
break;
default :
$class = $type; // Custom cases can just pass in the classes they want to be used
endswitch;
$text = ( NULL == $text ) ? __( 'Save Changes' ) : $text;
return '<p class="submit"><input type="submit" name="' . esc_attr( $name ) . '" class="' . esc_attr( $class ) . '" value="' . esc_attr( $text ) . '" /></p>';
}

View File

@ -240,9 +240,7 @@ echo apply_filters('default_avatar_select', $avatar_list);
<?php do_settings_sections('discussion'); ?>
<p class="submit">
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
</p>
<?php submit_button(); ?>
</form>
</div>

View File

@ -347,9 +347,7 @@ endfor;
<?php do_settings_sections('general'); ?>
<p class="submit">
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
</p>
<?php submit_button(); ?>
</form>
</div>

View File

@ -132,9 +132,7 @@ include('./admin-header.php');
<?php do_settings_sections('media'); ?>
<p class="submit">
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
</p>
<?php submit_button(); ?>
</form>

View File

@ -221,9 +221,7 @@ $structures = array(
<?php do_settings_sections('permalink'); ?>
<p class="submit">
<input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
</p>
<?php submit_button(); ?>
</form>
<?php if ( !is_multisite() ) { ?>
<?php if ( $iis7_permalinks ) :

View File

@ -50,9 +50,7 @@ include('./admin-header.php');
<?php do_settings_sections('privacy'); ?>
<p class="submit">
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
</p>
<?php submit_button(); ?>
</form>
</div>

View File

@ -94,9 +94,7 @@ include( './admin-header.php' );
<?php do_settings_sections( 'reading' ); ?>
<p class="submit">
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes' ); ?>" />
</p>
<?php submit_button(); ?>
</form>
</div>
<?php include( './admin-footer.php' ); ?>

View File

@ -148,9 +148,7 @@ wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_categor
<?php do_settings_sections('writing'); ?>
<p class="submit">
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
</p>
<?php submit_button(); ?>
</form>
</div>