acf_admin_options_page::get_options_page_allowed_field_keys
Returns the top-level $_POST['acf'] keys the current options page accepts on save.
Iterates the field groups assigned to this page and collects each field's top-level POST root, with special handling for seamless clone subfields whose input names nest below the parent clone's key.
Метод класса: acf_admin_options_page{}
Хуки из метода
Возвращает
array.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_options_page_allowed_field_keys();
Список изменений
| С версии 6.8.7 | Введена. |
Код acf_admin_options_page::get_options_page_allowed_field_keys() acf admin options page::get options page allowed field keys ACF 6.8.8
protected function get_options_page_allowed_field_keys() {
$keys = array();
foreach ( $this->get_options_page_field_groups() as $field_group ) {
$fields = acf_get_fields( $field_group );
if ( ! $fields ) {
continue;
}
foreach ( $fields as $field ) {
$prefix = $field['prefix'] ?? 'acf';
if ( $prefix === 'acf' ) {
if ( ! empty( $field['key'] ) ) {
$keys[] = $field['key'];
}
} elseif ( preg_match( '/^acf\[([^]]+)]$/', $prefix, $matches ) ) {
$keys[] = $matches[1];
}
}
}
$keys = array_values( array_unique( array_filter( $keys ) ) );
/**
* Filters the list of $_POST['acf'] keys an options page save is allowed to save.
*
* Use this to permit additional field keys when a developer dynamically injects fields
* into an options page via JavaScript that aren't part of any field group assigned to
* the page.
*
* @since 6.8.7
*
* @param array $keys The allowed top-level $_POST['acf'] keys.
* @param array $page The current options page configuration.
*/
$keys = apply_filters( 'acf/options_page/allowed_field_keys', $keys, $this->page );
// Re-normalize after the filter so a misbehaving callback can't break array_flip()
// downstream in admin_load() with non-scalar or empty values.
$keys = array_filter( (array) $keys, 'is_scalar' );
return array_values( array_unique( array_filter( array_map( 'strval', $keys ) ) ) );
}