Legacy), so they're hidden otherwise.
// The Extra Blocks tab lands on the "general" content (Blocks icon color);
// it is not listed as a sub-tab. Maps / Forms / reCAPTCHA / Data Export are
// the only sub-tabs, shown when their legacy block is enabled.
$extra_blocks_subtabs = [];
if ($this->settingIsEnabled('enable_advgb_blocks')) {
$legacy_state = AdvancedGutenbergMain::getLegacyBlocksState();
// Map block -> Maps tab
if (! empty($legacy_state['map'])) {
$extra_blocks_subtabs[] = 'maps';
}
// Contact Form block -> Email & Forms, reCAPTCHA, Data Export tabs
if (! empty($legacy_state['contact-form'])) {
$extra_blocks_subtabs[] = 'forms';
$extra_blocks_subtabs[] = 'recaptcha';
$extra_blocks_subtabs[] = 'data';
}
}
// Allowed top-level tabs ("legacy" is now a top-level tab, not a sub-tab)
$allowed_top_tabs = ['extra-blocks', 'block-features', 'post-notes', 'legacy', 'license'];
$current_tab = 'extra-blocks';
$current_subtab = 'general';
$requested_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : '';
if (in_array($requested_tab, $extra_blocks_subtabs, true)) {
// Legacy deep-link to a sub-tab slug
$current_tab = 'extra-blocks';
$current_subtab = $requested_tab;
} elseif (in_array($requested_tab, $allowed_top_tabs, true)) {
$current_tab = $requested_tab;
if ($current_tab === 'extra-blocks') {
$requested_subtab = isset($_GET['subtab']) ? sanitize_text_field($_GET['subtab']) : '';
if (in_array($requested_subtab, $extra_blocks_subtabs, true)) {
$current_subtab = $requested_subtab;
}
}
}
?>
esc_html__('Extra Blocks', 'advanced-gutenberg'),
'slug' => 'extra-blocks'
],
[
'title' => esc_html__('Block Features', 'advanced-gutenberg'),
'slug' => 'block-features'
]
];
if ($this->settingIsEnabled('enable_post_notes')) {
array_push(
$tabs,
[
'title' => esc_html__('Post Notes', 'advanced-gutenberg'),
'slug' => 'post-notes'
]
);
}
// Legacy is a top-level tab (next to Extra Blocks, Block Features, Post Notes)
array_push(
$tabs,
[
'title' => esc_html__('Legacy', 'advanced-gutenberg'),
'slug' => 'legacy'
]
);
if (defined('ADVANCED_GUTENBERG_PRO_LOADED')) {
array_push(
$tabs,
[
'title' => esc_html__('License', 'advanced-gutenberg'),
'slug' => 'license'
]
);
}
// Output top-level tabs menu
echo $this->buildTabs(
'advgb_settings',
$current_tab,
$tabs
);
?>
esc_html__('Maps', 'advanced-gutenberg'),
'forms' => esc_html__('Email & Forms', 'advanced-gutenberg'),
'recaptcha' => esc_html__('reCAPTCHA', 'advanced-gutenberg'),
'data' => esc_html__('Data Export', 'advanced-gutenberg'),
];
if (! empty($extra_blocks_subtabs)) {
printf(
'
';
}
// Load active content (defaults to "general" = Blocks icon color)
$this->loadPageTab('settings', $current_subtab);
} else {
// Load active top-level tab content (block-features, post-notes, license)
$this->loadPageTab('settings', $current_tab);
}
?>