# get_submit_button()

URL: https://chugunov.pro/api-wordpress/functions/get_submit_button/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 3.1.0.

## Сигнатура

```php
get_submit_button( string $text = '', string $type = 'primary large', string $name = 'submit', bool $wrap = true, array|string $other_attributes = '' ): string
```

## Описание

Возвращает кнопку отправки с заданным текстом и подходящим CSS-классом.

## Параметры

- `$text` `string` — необязательный, по умолчанию `''`. Текст кнопки. Значение по умолчанию — ‘Save Changes’.
- `$type` `string` — необязательный, по умолчанию `'primary large'`. Тип и CSS-класс(ы) кнопки. Значения ядра включают 'primary', 'small' и 'large'. Значение по умолчанию — ‘primary large’.
- `$name` `string` — необязательный, по умолчанию `'submit'`. HTML-имя кнопки отправки. Если в параметре $other_attributes не задан атрибут id, в качестве id кнопки будет использовано $name. Значение по умолчанию — 'submit'.
- `$wrap` `bool` — необязательный, по умолчанию `true`. True, если выводимая кнопка должна быть обёрнута в тег абзаца, иначе false.
- `$other_attributes` `array|string` — необязательный, по умолчанию `''`. Прочие атрибуты, которые нужно вывести вместе с кнопкой, в виде сопоставления атрибутов их значениям, например array( 'id' => 'search-submit' ).
  
  Эти пары ключ/значение будут выведены как attribute="value", где attribute — это ключ. Атрибуты также можно передать строкой, например id="search-submit", хотя формат массива обычно предпочтительнее.

## Возвращаемое значение

`string`

## Исходный код

Файл: `wp-admin/includes/template.php:2602`

```php
function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
	if ( ! is_array( $type ) ) {
		$type = explode( ' ', $type );
	}

	$button_shorthand = array( 'primary', 'small', 'large' );
	$classes          = array( 'button' );

	foreach ( $type as $t ) {
		if ( 'secondary' === $t || 'button-secondary' === $t ) {
			continue;
		}

		$classes[] = in_array( $t, $button_shorthand, true ) ? 'button-' . $t : $t;
	}

	// Remove empty items, remove duplicate items, and finally build a string.
	$class = implode( ' ', array_unique( array_filter( $classes ) ) );

	$text = $text ? $text : __( 'Save Changes' );

	// Default the id attribute to $name unless an id was specifically provided in $other_attributes.
	$id = $name;
	if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
		$id = $other_attributes['id'];
		unset( $other_attributes['id'] );
	}

	$attributes = '';
	if ( is_array( $other_attributes ) ) {
		foreach ( $other_attributes as $attribute => $value ) {
			$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important.
		}
	} elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string.
		$attributes = $other_attributes;
	}

	// Don't output empty name and id attributes.
	$name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
	$id_attr   = $id ? ' id="' . esc_attr( $id ) . '"' : '';

	$button  = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
	$button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';

	if ( $wrap ) {
		$button = '<p class="submit">' . $button . '</p>';
	}

	return $button;
}
```

## История изменений

- 3.1.0 — Introduced.

## Связанные

Использует: [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`esc_attr`](https://chugunov.pro/api-wordpress/functions/esc_attr/).
Используется в: [`submit_button`](https://chugunov.pro/api-wordpress/functions/submit_button/), [`_list_meta_row`](https://chugunov.pro/api-wordpress/functions/_list_meta_row/), [`wp_media_insert_url_form`](https://chugunov.pro/api-wordpress/functions/wp_media_insert_url_form/), [`get_media_item`](https://chugunov.pro/api-wordpress/functions/get_media_item/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/get_submit_button/
