| 1 |
<?php // Prismatic - Display Settings |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) exit; |
| 4 |
|
| 5 |
function prismatic_menu_pages() { |
| 6 |
|
| 7 |
// add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function ) |
| 8 |
add_options_page('Prismatic', 'Prismatic', 'manage_options', 'prismatic', 'prismatic_display_settings'); |
| 9 |
|
| 10 |
} |
| 11 |
|
| 12 |
function prismatic_get_tabs() { |
| 13 |
|
| 14 |
$tabs = array( |
| 15 |
'tab1' => esc_html__('General', 'prismatic'), |
| 16 |
'tab2' => esc_html__('Prism.js', 'prismatic'), |
| 17 |
'tab3' => esc_html__('Highlight.js', 'prismatic'), |
| 18 |
'tab4' => esc_html__('Plain Flavor', 'prismatic'), |
| 19 |
); |
| 20 |
|
| 21 |
return $tabs; |
| 22 |
|
| 23 |
} |
| 24 |
|
| 25 |
function prismatic_display_settings() { |
| 26 |
|
| 27 |
$tab_active = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'tab1'; |
| 28 |
|
| 29 |
$tab_href = admin_url('options-general.php?page=prismatic'); |
| 30 |
|
| 31 |
$tab_names = prismatic_get_tabs(); |
| 32 |
|
| 33 |
?> |
| 34 |
|
| 35 |
<div class="wrap wrap-<?php echo $tab_active; ?>"> |
| 36 |
<h1><span class="fa fa-pad fa-code"></span> <?php echo PRISMATIC_NAME; ?> <span class="prismatic-version"><?php echo PRISMATIC_VERSION; ?></span></h1> |
| 37 |
<h2 class="nav-tab-wrapper"> |
| 38 |
|
| 39 |
<?php |
| 40 |
|
| 41 |
foreach ($tab_names as $key => $value) { |
| 42 |
|
| 43 |
$active = ($tab_active === $key) ? ' nav-tab-active' : ''; |
| 44 |
|
| 45 |
echo '<a href="'. $tab_href .'&tab='. $key .'" class="nav-tab nav-'. $key . $active .'">'. $value .'</a>'; |
| 46 |
|
| 47 |
} |
| 48 |
|
| 49 |
?> |
| 50 |
|
| 51 |
</h2> |
| 52 |
<form method="post" action="options.php"> |
| 53 |
|
| 54 |
<?php |
| 55 |
|
| 56 |
if ($tab_active === 'tab1') { |
| 57 |
|
| 58 |
settings_fields('prismatic_options_general'); |
| 59 |
do_settings_sections('prismatic_options_general'); |
| 60 |
|
| 61 |
} elseif ($tab_active === 'tab2') { |
| 62 |
|
| 63 |
settings_fields('prismatic_options_prism'); |
| 64 |
do_settings_sections('prismatic_options_prism'); |
| 65 |
|
| 66 |
} elseif ($tab_active === 'tab3') { |
| 67 |
|
| 68 |
settings_fields('prismatic_options_highlight'); |
| 69 |
do_settings_sections('prismatic_options_highlight'); |
| 70 |
|
| 71 |
} elseif ($tab_active === 'tab4') { |
| 72 |
|
| 73 |
settings_fields('prismatic_options_plain'); |
| 74 |
do_settings_sections('prismatic_options_plain'); |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
submit_button(); |
| 79 |
|
| 80 |
?> |
| 81 |
|
| 82 |
</form> |
| 83 |
</div> |
| 84 |
|
| 85 |
<?php } |
| 86 |
|