<?php

// Exit if accessed directly
if (! defined('ABSPATH')) exit;

/**
 * @package Admin
 * @sub-package Admin SEO Display
 */
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template partial included within class method scope; variables are local, not global.
?>
<?php include('header.php'); ?>
<div id="seo">
    <div class="content-wrapper">
        <div class="header">
            <h3><?php esc_html_e('SEO', 'catch-web-tools'); ?></h3>
        </div> <!-- .header -->
        <div class="content">
            <form method="post" action="options.php">
                <?php settings_fields('seo-settings-group'); ?>
                <?php $settings    =    catchwebtools_get_options('catchwebtools_seo'); ?>
                <div class="option-container">
                    <h3 class="option-toggle option-active"><a href="#"><?php esc_html_e('Enable SEO Module', 'catch-web-tools'); ?></a></h3>
                    <div class="option-content inside open">
                        <table class="form-table">
                            <tbody>
                                <tr>
                                    <th scope="row"><?php esc_html_e('Enable SEO Module', 'catch-web-tools'); ?></th>
                                    <td>
                                        <?php
                                        $text    =    (! empty($settings['status']) && $settings['status']) ? 'checked' : '';
                                        echo '<input type="checkbox" ' . esc_html($text) . ' name="catchwebtools_seo[status]" value="1"/>&nbsp;&nbsp;' . esc_html__('Check to Enable', 'catch-web-tools');
                                        echo '<p class="description">' . esc_html__('Please make sure you have disabled all the SEO plugins before activating Catch Work Tools SEO Module.', 'catch-web-tools') . '</p>';
                                        echo '<p class="description">' . esc_html__('SEO for specific Pages or Posts, can be added via Catch Web Tools Custom Meta Box which shows up in Pages\' and Posts\' add/edit sections once this function is enabled. Same settings will show up in Categories\' add/edit pages.', 'catch-web-tools') . '</p>';
                                        ?>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <?php submit_button(esc_html__('Save Changes', 'catch-web-tools')); ?>
                    </div>

                    <h3 class="option-toggle"><a href="#"><?php esc_html_e('SEO Homepage Settings', 'catch-web-tools'); ?></a></h3>
                    <div class="option-content inside">
                        <table class="form-table">
                            <tbody>
                                <tr>
                                    <th scope="row"><?php esc_html_e('SEO Title', 'catch-web-tools'); ?></th>
                                    <td>
                                        <?php
                                        $text    =    (! empty($settings['title'])) ? esc_attr($settings['title']) :  get_bloginfo('name');
                                        echo '<input type="text" size="80" maxlength="70" id="catchwebtools_seo_title" name="catchwebtools_seo[title]" value="' . esc_html($text) . '" />';
                                        echo '<p class="description">' . esc_html__('Title display in search engines is limited to 70 characters. ', 'catch-web-tools') . '<span id="catchwebtools_seo_title_left">70</span> ' . esc_html__('character(s) left.', 'catch-web-tools') . '</p>';
                                        ?>
                                    </td>
                                </tr>

                                <tr>
                                    <th scope="row"><?php esc_html_e('Meta Description', 'catch-web-tools'); ?></th>
                                    <td>
                                        <?php
                                        $text    =    (! empty($settings['description'])) ? esc_attr($settings['description']) :  get_bloginfo('description');
                                        echo '<textarea cols="80" rows="7" id="catchwebtools_seo_description"  name="catchwebtools_seo[description]" maxlength="156" >' . esc_html($text) . '</textarea>';
                                        echo '<p class="description">' . esc_html__('The meta description is limited to 156 characters. ', 'catch-web-tools') . '<span id="catchwebtools_seo_description_left">156</span> ' . esc_html__('character(s) left.', 'catch-web-tools') . '</p>';
                                        ?>
                                    </td>
                                </tr>

                                <tr>
                                    <th scope="row"><?php esc_html_e('Focus Keywords', 'catch-web-tools'); ?></th>
                                    <td>
                                        <?php
                                        $text    =    (! empty($settings['keywords'])) ? esc_attr($settings['keywords']) : '';
                                        echo '<textarea cols="80" rows="7" name="catchwebtools_seo[keywords]">' . esc_attr($text) . '</textarea>';
                                        ?>
                                    </td>
                                </tr>

                                <tr>
                                    <th scope="row"><?php esc_html_e('Author', 'catch-web-tools'); ?></th>
                                    <td>
                                        <?php
                                        $text    =    (isset($settings['author']) && $settings['author'] != '') ? $settings['author'] : '';
                                        wp_dropdown_users(
                                            array(
                                                'name'         => 'catchwebtools_seo[author]',
                                                'selected'    => $text,
                                                'show_option_none'        => 'Disable', // string
                                            )
                                        );
                                        ?>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <?php submit_button(esc_html__('Save Changes', 'catch-web-tools')); ?>
                    </div>
                </div>
            </form>
        </div><!-- .content -->
    </div><!-- .content-wrapper -->
</div><!-- #customcss -->

<?php include('main-footer.php'); ?>