$sub_item ) { // Check user can access page. if ( ! current_user_can( $sub_item[1] ) ) { continue; } // Ignore "Add New". if ( $i === 1 ) { continue; } // Define tab. $tab = array( 'text' => $sub_item[0], 'url' => $sub_item[2], ); // Convert submenu slug "test" to "$parent_slug&page=test". if ( ! strpos( $sub_item[2], '.php' ) ) { $tab['url'] = add_query_arg( array( 'page' => $sub_item[2] ), $parent_slug ); } // Detect active state. if ( $submenu_file === $sub_item[2] || $plugin_page === $sub_item[2] ) { $tab['is_active'] = true; } // Special case for "Add New" page. if ( $i === 0 && $submenu_file === 'post-new.php?post_type=acf-field-group' ) { $tab['is_active'] = true; } $tabs[] = $tab; } } /** * Filters the admin navigation tabs. * * @date 27/3/20 * @since 5.9.0 * * @param array $tabs The array of navigation tabs. */ $tabs = apply_filters( 'acf/admin/toolbar', $tabs ); // Bail early if set to false. if ( $tabs === false ) { return; } ?>