<?php
/**
 * Display for Pages Settings tab
 */
?>

<form method="post" action="options.php">
    <?php settings_fields('subscription_pages_settings'); ?>
    
    <h2>Pages Settings</h2>
    <p class="description">Select pages for different functions and use the corresponding shortcodes on those pages.</p>
    
    <table class="form-table">
        <tr>
            <th scope="row">Login Page</th>
            <td>
                <?php
                wp_dropdown_pages(array(
                    'name' => 'login_page',
                    'show_option_none' => 'Select a page',
                    'option_none_value' => '0',
                    'selected' => esc_attr(get_option('login_page')),
                ));
                ?>
                <p class="description">Shortcode: <code>[subscriptionsystem_login]</code></p>
            </td>
        </tr>
        
        <tr>
            <th scope="row">Account Page</th>
            <td>
                <?php
                wp_dropdown_pages(array(
                    'name' => 'account_page',
                    'show_option_none' => 'Select a page',
                    'option_none_value' => '0',
                    'selected' => esc_attr(get_option('account_page')),
                ));
                ?>
                <p class="description">Shortcode: <code>[subscriptionsystem_account]</code></p>
            </td>
        </tr>
        
        <tr>
            <th scope="row">Registration Page</th>
            <td>
                <?php
                wp_dropdown_pages(array(
                    'name' => 'register_page',
                    'show_option_none' => 'Select a page',
                    'option_none_value' => '0',
                    'selected' => esc_attr(get_option('register_page')),
                ));
                ?>
                <p class="description">Shortcode: <code>[subscriptionsystem_register]</code></p>
            </td>
        </tr>
        
        <tr>
            <th scope="row">Thank You Page</th>
            <td>
                <?php
                wp_dropdown_pages(array(
                    'name' => 'thank_you_page',
                    'show_option_none' => 'Select a page',
                    'option_none_value' => '0',
                    'selected' => esc_attr(get_option('thank_you_page')),
                ));
                ?>
                <p class="description">Shortcode: <code>[subscription_success]</code></p>
            </td>
        </tr>
        
        <tr>
            <th scope="row">Pricing Plans Page</th>
            <td>
                <?php
                wp_dropdown_pages(array(
                    'name' => 'pricing_plans_page',
                    'show_option_none' => 'Select a page',
                    'option_none_value' => '0',
                    'selected' => esc_attr(get_option('pricing_plans_page')),
                ));
                ?>
                <p class="description">Shortcode: <code>[pricing_plans]</code></p>
            </td>
        </tr>
        
        <tr>
            <th scope="row">Edit Profile Page</th>
            <td>
                <?php
                wp_dropdown_pages(array(
                    'name' => 'edit_profile_page',
                    'show_option_none' => 'Select a page',
                    'option_none_value' => '0',
                    'selected' => esc_attr(get_option('edit_profile_page')),
                ));
                ?>
                <p class="description">Shortcode: <code>[edit_profile]</code></p>
            </td>
        </tr>
        
        <tr>
            <th scope="row">Forgot Password Page</th>
            <td>
                <?php
                wp_dropdown_pages(array(
                    'name' => 'forgot_password_page',
                    'show_option_none' => 'Select a page',
                    'option_none_value' => '0',
                    'selected' => esc_attr(get_option('forgot_password_page')),
                ));
                ?>
                <p class="description">Shortcode: <code>[subscriptionsystem_forgot_password]</code></p>
            </td>
        </tr>
        
        <tr>
            <th scope="row">Contact Page</th>
            <td>
                <?php
                wp_dropdown_pages(array(
                    'name' => 'contact_page',
                    'show_option_none' => 'Select a page',
                    'option_none_value' => '0',
                    'selected' => esc_attr(get_option('contact_page')),
                ));
                ?>
                <p class="description">No shortcode needed - used for system links</p>
            </td>
        </tr>
        
        <tr>
            <th scope="row">Subscription Cancel Page</th>
            <td>
                <?php
                wp_dropdown_pages(array(
                    'name' => 'subscription_cancel_page',
                    'show_option_none' => 'Select a page',
                    'option_none_value' => '0',
                    'selected' => esc_attr(get_option('subscription_cancel_page')),
                ));
                ?>
                <p class="description">Shortcode: <code>[checkout_failed]</code></p>
            </td>
        </tr>
        
        <tr>
            <th scope="row">Content Subscription Success Page</th>
            <td>
                <?php
                wp_dropdown_pages(array(
                    'name' => 'content_subscription_success_page',
                    'show_option_none' => 'Select a page',
                    'option_none_value' => '0',
                    'selected' => esc_attr(get_option('content_subscription_success_page')),
                ));
                ?>
                <p class="description">Shortcode: <code>[content_subscription_success]</code></p>
                <p class="description">This page will be used to display success messages after content subscription payments.</p>
            </td>
        </tr>
    </table>
    
    <div class="subscription-pages-info">
        <h3>How to Use These Pages</h3>
        <ol>
            <li>Create a new page for each function in WordPress</li>
            <li>Select each page in the dropdowns above</li>
            <li>Add the corresponding shortcode to each page's content</li>
            <li>Save your changes</li>
        </ol>
        <p>These pages will be used throughout the subscription system for redirects and links.</p>
    </div>
    
    <?php submit_button('Save Changes'); ?>
</form>

<style>
.subscription-pages-info {
    background: #fff;
    border-left: 4px solid #2271b1;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
    margin: 20px 0;
    padding: 12px;
}
.subscription-pages-info h3 {
    margin-top: 0;
}
.description code {
    background: #f0f0f1;
    padding: 3px 5px;
    border-radius: 3px;
}
</style> 
 