acf_admin_options_page::admin_head()publicACF 3.1.8

admin_head

This action will find and add field groups to the current edit page

Метод класса: acf_admin_options_page{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

$acf_admin_options_page = new acf_admin_options_page();
$acf_admin_options_page->admin_head();

Список изменений

С версии 3.1.8 Введена.

Код acf_admin_options_page::admin_head() ACF 6.0.4

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 ) {

			// vars
			$id       = "acf-{$field_group['key']}";
			$title    = $field_group['title'];
			$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( $title ), array( $this, 'postbox_acf' ), 'acf_options_page', $context, $priority, $args );

		}
		// foreach

	}
	// if
}