ACF Archive is not working, Advanced Custom Fields is not installed.', 'acf-archive' ); ?>
get_custom_post_types();
foreach ( $post_types as $post_type => $post_type_object ) {
$menu = 'edit.php?post_type=' . $post_type;
if ( 'post' === $post_type ) {
$menu = 'edit.php';
}
$this->add_menu( $post_type_object->label, $menu );
}
}
/**
* Load the ACF Assets only on archive options page
* @param string $hook_suffix
* @return void
*/
public function admin_enqueue_scripts( $hook_suffix ) {
$screen = get_current_screen();
if ( $this->get_admin_page_slug( $screen->post_type ) === $hook_suffix ) {
acf_enqueue_scripts();
}
}
/**
* Load ACF spinner on page submit
* @return void
*/
public function admin_footer() {
$screen = get_current_screen();
if ( $this->get_admin_page_slug( $screen->post_type ) === $screen->id ) {
$this->print_spinner_script();
}
}
/**
* @param string $post_type
* @return string
*/
private function get_admin_page_slug( $post_type ) {
return $post_type . '_page_archive-options';
}
/**
* Print ACF spinner script
* @return void
*/
private function print_spinner_script() {
?>
$menu,
'page_title' => $page_name,
'menu_title' => $page_name,
'capability' => 'edit_posts',
'menu_slug' => 'archive-options',
];
add_submenu_page(
$options['parent_slug'],
$options['page_title'],
$options['menu_title'],
$options['capability'],
$options['menu_slug'],
[ $this, 'render_menu' ]
);
}
/**
* Render the archive options page
*/
public function render_menu() {
$screen = get_current_screen();
$post_type = $screen->post_type;
if ( isset( $_POST[ $post_type ] ) && acf_verify_nonce( $post_type ) && acf_validate_save_post(true ) ) {
acf_save_post( $post_type );
}
$field_groups = acf_get_field_groups( [ 'post_id' => $post_type ]);
if ( empty( $field_groups ) ) {
echo '