acf_add_internal_post_type_validation_error()
Adds a validation error for ACF internal post types.
Хуков нет.
Возвращает
null. Ничего (null).
Использование
acf_add_internal_post_type_validation_error( $name, $message, $post_type );
- $name(строка) (обязательный)
- The name of the input.
- $message(строка)
- An optional error message to display.
По умолчанию:'' - $post_type(строка)
- Optional post type the error message is for.
По умолчанию:''
Список изменений
| С версии 6.1 | Введена. |
Код acf_add_internal_post_type_validation_error() acf add internal post type validation error ACF 6.4.2
function acf_add_internal_post_type_validation_error( $name, $message = '', $post_type = '' ) {
if ( empty( $post_type ) ) {
$screen = isset( $_POST['_acf_screen'] ) ? (string) $_POST['_acf_screen'] : 'post_type'; // phpcs:ignore WordPress.Security -- Nonce verified upstream, value only used for comparison.
$post_type = acf_get_post_type_from_screen_value( $screen );
if ( ! $post_type ) {
return;
}
}
$input_prefix = str_replace( '-', '_', $post_type );
if ( substr( $name, 0, strlen( $input_prefix ) ) !== $input_prefix ) {
$name = "{$input_prefix}[$name]";
}
return acf_add_validation_error( $name, $message );
}