@@ -844,5 +846,5 @@
-
+
-
+
@@ -1890,5 +1892,5 @@
if ( !empty($per_page_label) )
$return .= " \n";
- $return .= "";
+ $return .= get_submit_button( __( 'Apply' ), 'button', '', false );
$return .= "";
$return .= "\n";
@@ -2087,5 +2089,5 @@
/**
- * Echos a paragraph-wrapped submit button, with provided text and appropriate class
+ * Echos a submit button, with provided text and appropriate class
*
* @since 3.1.0
@@ -2093,12 +2095,20 @@
* @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
+ * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
+ * is given in $other_attributes below, $name will be used as the button's id.
+ * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
+ * false otherwise. Defaults to true
+ * @param array|string $other_attributes Other attributes that should be output with the button,
+ * mapping attributes to their values, such as array( 'tabindex' => '1' ).
+ * These attributes will be ouput as attribute="value", such as tabindex="1".
+ * Defaults to no other attributes. Other attributes can also be provided as a
+ * string such as 'tabindex="1"', though the array format is typically cleaner.
+ */
+function submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) {
+ echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
+}
+
+/**
+ * Returns a submit button, with provided text and appropriate class
*
* @since 3.1.0
@@ -2106,7 +2116,15 @@
* @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' ) {
+ * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
+ * is given in $other_attributes below, $name will be used as the button's id.
+ * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
+ * false otherwise. Defaults to true
+ * @param array|string $other_attributes Other attributes that should be output with the button,
+ * mapping attributes to their values, such as array( 'tabindex' => '1' ).
+ * These attributes will be ouput as attribute="value", such as tabindex="1".
+ * Defaults to no other attributes. Other attributes can also be provided as a
+ * string such as 'tabindex="1"', though the array format is typically cleaner.
+ */
+function get_submit_button( $text = NULL, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = NULL ) {
switch ( $type ) :
case 'primary' :
@@ -2121,5 +2139,28 @@
endswitch;
$text = ( NULL == $text ) ? __( 'Save Changes' ) : $text;
- return '';
-}
-
+
+ $attributes = '';
+ if ( is_array( $other_attributes ) ) {
+ foreach ( $other_attributes as $attribute => $value ) {
+ $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
+ }
+ } else if ( !empty( $other_attributes ) ) { // Attributes provided as a string
+ $attributes = $other_attributes;
+ }
+
+ // Default the id attribute to $name unless an id was specifically provided in $other_attributes
+ $id = 'id="' . esc_attr( $name ) . '" ';
+ if ( is_array( $other_attributes ) && array_key_exists( 'id', $other_attributes ) ) {
+ $id = 'id="' . esc_attr( $other_attributes['id'] ) . '" ';
+ }
+
+ $button = '';
+
+ if ( $wrap ) {
+ $button = '