<?php
function wppage_settings_page()
{
    settings_fields('coach-settings-group');

    $user_serial = get_option('wppage_serial_number');
    $package = wpp_package();
    if ($package == 'TRIAL' && !wpp_trial()) {
        add_option('wppage_serial_number', '');
        $user_serial = '';
    }
    ?>
<div class="wrap">
    <div id="icon-options-general" class="icon32"></div>
    <h2>Параметры</h2>
    <br>
    <form method="post" action="options.php">
        <?php settings_fields('coach-settings-group'); ?>
        <p>Вы используете <strong> <?php echo ($package == 'TRIAL')? 'Пробную версию': 'Пакет '.$package; ?></strong>
            <?php if ($package != 'GURU' && $package != 'START' && $package != 'PRO') { ?>
           . <a target="_blank" href="http://wppage.ru/buy">Подробнее о полной версии <span style="font-size:18px">→</span></a>
                <?php } ?>
        </p>
        <br>
        <label>Ваш серийный номер</label>
        <input type="text" style="width:400px;" value="<?php echo $user_serial; ?>" name="wppage_serial_number">
        <br><br>
        <hr class="h_line">
        <br style="clear: both">
        <div class="tabs_wrap options_wrap">
            <div id="settings_tabs">
                <ul class="wppage_tabs_nav">
                    <li><a href="#div_1">Главная</a></li>
                    <li><a href="#div_2">Facebook</a></li>
                    <li><a href="#div_3">вКонтакте</a></li>
                    <li><a href="#div_4">Twitter</a></li>
                    <li><a href="#div_5">Скрипты</a></li>
                </ul>

                <div id="div_1" class="tab_content_box">
                    <div class="triangle"></div>
                    <div class="wppage_content_round">

                            <?php
                            $use_as_home = get_option('use_as_home_page');
                            $args = array(
                                'post_type'      => 'page_selling',
                                'posts_per_page' => '-1'
                            );
                            query_posts($args);
                            ?>
                            <label>Сделать главной</label>
                            <select name="use_as_home_page">
                                <option value="no_page" <?php if ($use_as_home == 'no_page') echo 'selected="selected"';  ?>>-- Не использовать --</option>

                                <?php if (have_posts()): ?>
                                <?php
                                while (have_posts()): the_post();
                                    ?>
                                    <option value="<?php the_ID(); ?>" <?php if ($use_as_home == get_the_ID()) echo 'selected="selected"'; ?>><?php the_title(); ?></option>
                                    <?php endwhile; ?>

                                <?php endif; wp_reset_query(); ?>
                            </select>
                        <br style="clear: both">
                        <br style="clear: both">
                        <div style="width:500px;">
                            <div class="wpp_helper_box"><a onclick="open_win('http://www.youtube.com/watch?v=2FNODxiDI9w&list=PLI8Gq0WzVWvJ60avoe8rMyfoV5qZr3Atm&index=23')">Подробнее</a></div>
                        </div>
                    </div>

                </div>
                <div id="div_2" class="tab_content_box">
                    <div class="triangle"></div>
                    <div class="wppage_content_round">
                        <table class="wpp_settings_form-table">
                        <tr valign="top">
                            <th scope="row">facebook App ID</th>
                            <td><input type="text" name="facebook_app_id"
                                       value="<?php echo get_option('facebook_app_id'); ?>"/></td>
                        </tr>
                        <tr valign="top">
                            <th scope="row">facebook admin</th>
                            <td><input type="text" name="facebook_admin"
                                       value="<?php echo get_option('facebook_admin'); ?>"/></td>
                        </tr>
                        </table>
                        <br style="clear: both">
                        <div style="width:500px;">
                            <div class="wpp_helper_box"><a onclick="open_win('http://www.youtube.com/watch?v=vwjw0LHJzYc&list=PLI8Gq0WzVWvJ60avoe8rMyfoV5qZr3Atm&index=20')">Подробнее</a></div>
                        </div>
                    </div>

                </div>
                <div id="div_3" class="tab_content_box">
                    <div class="triangle"></div>
                    <div class="wppage_content_round">
                        <table class="wpp_settings_form-table">
                            <tr valign="top">
                                <th scope="row">ID приложения:</th>
                                <td><input type="text" name="vkontakte_apiId"
                                           value="<?php echo get_option('vkontakte_apiId'); ?>"/></td>
                            </tr>
                        </table>
                        <br style="clear: both">
                        <div style="width:500px;">
                            <div class="wpp_helper_box"><a onclick="open_win('http://www.youtube.com/watch?v=z-N-FFUKvVY&list=PLI8Gq0WzVWvJ60avoe8rMyfoV5qZr3Atm&index=21')">Подробнее</a></div>
                        </div>
                    </div>

                </div>
                <div id="div_4" class="tab_content_box">
                    <div class="triangle"></div>
                    <div class="wppage_content_round">
                        <table class="wpp_settings_form-table">
                            <tr valign="top">
                                <th scope="row">twitter nickname</th>
                                <td><input type="text" name="twetter_nickname"
                                           value="<?php echo get_option('twetter_nickname'); ?>"/></td>
                            </tr>
                        </table>
                        <br style="clear: both">
                        <div style="width:500px;">
                            <div class="wpp_helper_box"><a onclick="open_win('http://www.youtube.com/watch?v=EsIlI7y5wZU&list=PLI8Gq0WzVWvJ60avoe8rMyfoV5qZr3Atm&index=22')">Подробнее</a></div>
                        </div>
                    </div>

                </div>
                <div id="div_5" class="tab_content_box">
                    <div class="triangle"></div>
                    <div class="wppage_content_round">
                        <table class="wpp_settings_form-table">
                            <tr valign="top">
                                <th scope="row"><p>Коды статистик или другие скрипты.<br><br>Код добавляется перед закрывающим тегом <span class="text_green">&lt;/body&gt;</span></p>
                                </th>
                                <td><textarea name="coach_analytics" class="wpp_textarea"
                                              style="width:400px; height:200px;"><?php echo get_option('coach_analytics'); ?></textarea>
                                    <p><strong class="text_red" style="font-size: 16px">*</strong> Применяется ко всем страницам wppage</p>
                                </td>
                            </tr>
                        </table>
                        <br style="clear: both">
                        <div style="width:500px;">
                            <div class="wpp_helper_box"><a onclick="open_win('http://www.youtube.com/watch?v=WSG9ewb93dY&list=PLI8Gq0WzVWvJ60avoe8rMyfoV5qZr3Atm&index=24')">Подробнее</a></div>
                        </div>
                    </div>


                </div>

            </div>
            <br style="clear: both">
            <p class="submit settings_submit_box ">
                <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>"/>
            </p>
        </div>


    </form>

</div>
<script type="text/javascript">
    jQuery(function ($) {
        $('#settings_tabs').tabs({
            autoHeight:false,
            active:true,
            collapsible:false,
            fx:{
                opacity:'toggle',
                duration:'fast'
            }
        });
    });
</script>
<?php
}