| | 1599 | * Optional $attributes contents: |
| | 1600 | * |
| | 1601 | * - type - The type of button. One of: primary, secondary, delete. Defaults to primary |
| | 1602 | * - name - The HTML name of the submit button. Defaults to "submit". If no id attribute |
| | 1603 | * is given, this parameter will be used as the button's id. |
| | 1604 | * - wrap - True if the output button should be wrapped in a paragraph tag, |
| | 1605 | * false otherwise. Defaults to true |
| | 1606 | * |
| | 1607 | * Any other attribute name/value pairs can be passed to the $attributes argument and they |
| | 1608 | * will be applied to the button. |
| | 1609 | * |
| 1600 | | * @param string $type The type of button. One of: primary, secondary, delete |
| 1601 | | * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute |
| 1602 | | * is given in $other_attributes below, $name will be used as the button's id. |
| 1603 | | * @param bool $wrap True if the output button should be wrapped in a paragraph tag, |
| 1604 | | * false otherwise. Defaults to true |
| 1605 | | * @param array|string $other_attributes Other attributes that should be output with the button, |
| 1606 | | * mapping attributes to their values, such as array( 'tabindex' => '1' ). |
| 1607 | | * These attributes will be output as attribute="value", such as tabindex="1". |
| 1608 | | * Defaults to no other attributes. Other attributes can also be provided as a |
| 1609 | | * string such as 'tabindex="1"', though the array format is typically cleaner. |
| | 1611 | * @param array $attributes Attributes that should be output with the button, |
| | 1612 | * mapping attributes to their values. See above for description. |
| 1611 | | function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) { |
| 1612 | | echo get_submit_button( $text, $type, $name, $wrap, $other_attributes ); |
| | 1614 | function submit_button( $text = null, $attributes = array() ) { |
| | 1615 | echo call_user_func_array( 'get_submit_button', func_get_args() ); |
| | 1623 | * Optional $attributes contents: |
| | 1624 | * |
| | 1625 | * - type - The type of button. One of: primary, secondary, delete. Defaults to primary |
| | 1626 | * - name - The HTML name of the submit button. Defaults to "submit". If no id attribute |
| | 1627 | * is given, this parameter will be used as the button's id. |
| | 1628 | * - wrap - True if the output button should be wrapped in a paragraph tag, |
| | 1629 | * false otherwise. Defaults to true |
| | 1630 | * |
| | 1631 | * Any other attribute name/value pairs can be passed to the $attributes argument and they |
| | 1632 | * will be applied to the button. |
| | 1633 | * |
| 1621 | | * @param string $type The type of button. One of: primary, secondary, delete |
| 1622 | | * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute |
| 1623 | | * is given in $other_attributes below, $name will be used as the button's id. |
| 1624 | | * @param bool $wrap True if the output button should be wrapped in a paragraph tag, |
| 1625 | | * false otherwise. Defaults to true |
| 1626 | | * @param array|string $other_attributes Other attributes that should be output with the button, |
| 1627 | | * mapping attributes to their values, such as array( 'tabindex' => '1' ). |
| 1628 | | * These attributes will be output as attribute="value", such as tabindex="1". |
| 1629 | | * Defaults to no other attributes. Other attributes can also be provided as a |
| 1630 | | * string such as 'tabindex="1"', though the array format is typically cleaner. |
| | 1635 | * @param array $attributes Attributes that should be output with the button, |
| | 1636 | * mapping attributes to their values. See above for description. |
| 1632 | | function get_submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) { |
| 1633 | | switch ( $type ) : |
| | 1638 | function get_submit_button( $text = null, $attributes = array() ) { |
| | 1639 | |
| | 1640 | if ( count( ( $args = func_get_args() ) > 2 ) ) { |
| | 1641 | |
| | 1642 | _deprecated_argument( __FUNCTION__, 3.4, __( 'Button attributes should be passed to the <code>$attributes</code> argument as an associative array.' ) ); |
| | 1643 | |
| | 1644 | $attributes = array( |
| | 1645 | 'type' => $attributes |
| | 1646 | ); |
| | 1647 | |
| | 1648 | if ( isset( $args[2] ) ) |
| | 1649 | $attributes['name'] = $args[2]; |
| | 1650 | if ( isset( $args[3] ) ) |
| | 1651 | $attributes['wrap'] = $args[3]; |
| | 1652 | |
| | 1653 | if ( isset( $args[4] ) ) { |
| | 1654 | if ( is_array( $args[4] ) ) { |
| | 1655 | $attributes = wp_parse_args( $args[4], $attributes ); |
| | 1656 | } else { |
| | 1657 | $_atts = array(); |
| | 1658 | wp_parse_str( $args[4], $_atts ); // Other attributes provided as a string |
| | 1659 | $attributes = wp_parse_args( $_atts, $attributes ); |
| | 1660 | } |
| | 1661 | } |
| | 1662 | |
| | 1663 | } else if ( !is_array( $attributes ) ) { |
| | 1664 | |
| | 1665 | _doing_it_wrong( __FUNCTION__, __( 'Button attributes should be passed to the <code>$attributes</code> argument as an associative array.' ), 3.4 ); |
| | 1666 | |
| | 1667 | $attributes = array( |
| | 1668 | 'type' => $attributes |
| | 1669 | ); |
| | 1670 | |
| | 1671 | } |
| | 1672 | |
| | 1673 | $attributes = wp_parse_args( $attributes, array( |
| | 1674 | 'type' => 'primary', |
| | 1675 | 'wrap' => true, |
| | 1676 | 'name' => 'submit', |
| | 1677 | 'value' => ( null == $text ) ? __( 'Save Changes' ) : $text |
| | 1678 | ) ); |
| | 1679 | |
| | 1680 | switch ( $attributes['type'] ) : |