/**
 * Define gpp Admin Page Tab Markup
 *
 * @uses	gpp_get_current_tab()	defined in \functions\options.php
 * @uses	gpp_get_settings_page_tabs()	defined in \functions\options.php
 *
 * @link	http://www.onedesigns.com/tutorials/separate-multiple-theme-options-pages-using-tabs	Daniel Tara
 */
function gpp_get_page_tab_markup()
{
    global $gpp_tabs;
    $page = 'gpp-settings';
    $current = gpp_get_current_tab();
    if ('gpp-settings' == $page) {
        $tabs = $gpp_tabs;
    }
    $links = array();
    $i = 0;
    foreach ($tabs as $tab) {
        if (isset($tab['name'])) {
            $tabname = $tab['name'];
        }
        if (isset($tab['title'])) {
            $tabtitle = $tab['title'];
        }
        if ($tabname == $current) {
            $links[] = "<a class='nav-tab nav-tab-active' href='?page={$page}&tab={$tabname}&i={$i}'>{$tabtitle}</a>";
        } else {
            $links[] = "<a class='nav-tab' href='?page={$page}&tab={$tabname}&i={$i}'>{$tabtitle}</a>";
        }
        $i++;
    }
    gpp_utility_links();
    echo '<div id="icon-themes" class="icon32"><br /></div>';
    echo '<h2 class="nav-tab-wrapper">';
    foreach ($links as $link) {
        echo $link;
    }
    echo '</h2>';
}
/**
 * Settings Page Markup
 */
function gpp_admin_options_page()
{
    global $gpp_tabs;
    // Determine the current page tab
    $currenttab = gpp_get_current_tab();
    // Define the page section accordingly
    $settings_section = 'gpp_' . $currenttab . '_tab';
    ?>

    <div class="wrap">
        <?php 
    gpp_get_page_tab_markup();
    ?>
        <?php 
    if (isset($_GET['settings-updated'])) {
        if (isset($_GET['i'])) {
            $tabvalue = $_GET['i'];
        } else {
            $tabvalue = 0;
        }
        $current_tab_title = gpp_get_current_tab_title($tabvalue);
        echo '<div class="updated"><p>';
        echo '<strong>' . $current_tab_title . __(' settings updated successfully.', 'gpp') . '</strong>';
        echo '</p></div>';
    }
    ?>
        <form action="options.php" method="post">
            <?php 
    // Implement settings field security, nonces, etc.
    settings_fields(gpp_get_current_theme_id() . '_options');
    // Output each settings section, and each
    // Settings field in each section
    do_settings_sections($settings_section);
    ?>
            <?php 
    submit_button(__('Save Settings', 'gpp'), 'primary', gpp_get_current_theme_id() . "_options[submit-{$currenttab}]", false);
    ?>
            <?php 
    submit_button(__('Reset Defaults', 'gpp'), 'secondary', gpp_get_current_theme_id() . "_options[reset-{$currenttab}]", false);
    ?>
        </form>
    </div>
<?php 
}