acf_admin_options_page::admin_head
This action will find and add field groups to the current edit page
Method of the class: acf_admin_options_page{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$acf_admin_options_page = new acf_admin_options_page(); $acf_admin_options_page->admin_head();
Changelog
| Since 3.1.8 | Introduced. |
acf_admin_options_page::admin_head() acf admin options page::admin head code ACF 6.8.8
public function admin_head() {
// get field groups
$field_groups = acf_get_field_groups(
array(
'options_page' => $this->page['menu_slug'],
)
);
// notices
if ( ! empty( $_GET['message'] ) && $_GET['message'] == '1' ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Used to display a notice.
acf_add_admin_notice( $this->page['updated_message'], 'success' );
}
// add submit div
add_meta_box( 'submitdiv', __( 'Publish', 'acf' ), array( $this, 'postbox_submitdiv' ), 'acf_options_page', 'side', 'high' );
if ( empty( $field_groups ) ) {
acf_add_admin_notice( sprintf( __( 'No Custom Field Groups found for this options page. <a href="%s">Create a Custom Field Group</a>', 'acf' ), admin_url( 'post-new.php?post_type=acf-field-group' ) ), 'warning' );
} else {
foreach ( $field_groups as $i => $field_group ) {
$id = "acf-{$field_group['key']}";
$context = $field_group['position'];
$priority = 'high';
$args = array( 'field_group' => $field_group );
// tweaks to vars
if ( $context == 'acf_after_title' ) {
$context = 'normal';
} elseif ( $context == 'side' ) {
$priority = 'core';
}
// filter for 3rd party customization
$priority = apply_filters( 'acf/input/meta_box_priority', $priority, $field_group );
// add meta box
add_meta_box(
$id,
acf_esc_html( acf_get_field_group_title( $field_group ) ),
array( $this, 'postbox_acf' ),
'acf_options_page',
$context,
$priority,
$args
);
}
// foreach
}
// if
}