<?php

/**
 * Plugins main settings page.
 *
 * @package Flexible_FAQs
 */
namespace WPGO_Plugins\Flexible_Faqs;

/**
 * Main plugin settings page.
 */
class Settings
{
    /**
     * Common root paths/directories.
     *
     * @var $module_roots
     */
    protected  $module_roots ;
    /**
     * Main class constructor.
     *
     * @param Array $module_roots Root plugin path/dir.
     * @param Array $plugin_data Plugin data.
     * @param Array $custom_plugin_data Custom plugin data.
     * @param Array $utility Utility data.
     * @param Array $settings_fw Plugin framework settings.
     */
    public function __construct(
        $module_roots,
        $plugin_data,
        $custom_plugin_data,
        $utility,
        $settings_fw,
        $new_features_arr
    )
    {
        $this->module_roots = $module_roots;
        $this->custom_plugin_data = $custom_plugin_data;
        $this->hook_prefix = $this->custom_plugin_data->plugin_settings_prefix;
        $this->freemius_upgrade_url = $this->custom_plugin_data->freemius_upgrade_url;
        $this->utility = $utility;
        $this->settings_fw = $settings_fw;
        $this->plugin_data = $plugin_data;
        $this->new_features_arr = $new_features_arr;
        $this->pro_attribute = ( $this->custom_plugin_data->is_premium ? '' : '<span class="pro" title="Upgrade now for immediate access to this feature"><a href="' . $this->freemius_upgrade_url . '">PRO</a></span>' );
        $this->settings_slug = $this->custom_plugin_data->settings_pages['settings']['slug'];
        $this->new_features_slug = $this->custom_plugin_data->settings_pages['new-features']['slug'];
        $this->welcome_slug = $this->custom_plugin_data->settings_pages['welcome']['slug'];
        $this->faq_options = get_option( $this->custom_plugin_data->db_option_prefix . '_options', array() );
        add_action( 'admin_init', array( &$this, 'init' ) );
        add_action( 'admin_menu', array( &$this, 'add_options_page' ) );
        add_filter( 'custom_menu_order', array( &$this, 'filter_menu_order' ) );
        // enable custom menu ordering.
    }
    
    /**
     * Init plugin options to white list our options.
     */
    public function init()
    {
        $opt_pfx = $this->custom_plugin_data->db_option_prefix;
        $page_name = $this->settings_slug;
        add_settings_section(
            'faq_global_settings_section',
            '',
            array( $this, 'global_settings_section_callback' ),
            $page_name
        );
        // Register plugin settings.
        register_setting( $opt_pfx . '_options_group', $opt_pfx . '_options', array( &$this, 'validate_options' ) );
    }
    
    /**
     * A section to define all global settings.
     */
    public function global_settings_section_callback()
    {
        // @Todo will update as suggested later.
        echo  '' ;
    }
    
    /**
     * Sanitize and validate input. Accepts an array, return a sanitized array.
     *
     * @param Array $input An array of raw values from the submitted form on the settings page.
     * @return Array List of allowed plugin options submitted via plugin's settings page.
     */
    public function validate_options( $input )
    {
        // Validate all plugin settings.
        $new_input['collapse_inactive_faq_items'] = ( isset( $input['collapse_inactive_faq_items'] ) ? $input['collapse_inactive_faq_items'] : 0 );
        $new_input['load_faq_scripts'] = ( isset( $input['load_faq_scripts'] ) ? $input['load_faq_scripts'] : 0 );
        $new_input['google_font_options'] = ( isset( $input['google_font_options'] ) ? $input['google_font_options'] : '' );
        $new_input['new_features_numbered_icon'] = ( isset( $input['new_features_numbered_icon'] ) ? $input['new_features_numbered_icon'] : 'false' );
        $new_input['plugin_version'] = ( isset( $input['plugin_version'] ) ? $input['plugin_version'] : '' );
        return $new_input;
    }
    
    /**
     * Add admin menu page.
     */
    public function add_options_page()
    {
        
        if ( 'top' === $this->custom_plugin_data->menu_type ) {
            // Add main plugin settings page as a top-level menu item.
            add_menu_page(
                __( 'Flexible FAQs Settings Page', 'flexible-faqs' ),
                __( 'Flexible FAQs', 'flexible-faqs' ),
                'manage_options',
                $this->settings_slug,
                array( &$this, 'render_form' ),
                'dashicons-editor-help',
                82
            );
        } elseif ( 'top-cpt' === $this->custom_plugin_data->menu_type ) {
            // Add main plugin settings page as a submenu of a CPT.
            add_submenu_page(
                $this->custom_plugin_data->parent_slug,
                __( 'FAQ Settings', 'flexible-faqs' ),
                __( 'Settings', 'flexible-faqs' ),
                'manage_options',
                $this->settings_slug,
                array( $this, 'render_form' )
            );
        } elseif ( 'sub' === $this->custom_plugin_data->menu_type ) {
            // Add main plugin settings page as a submenu of 'Settings'.
            add_options_page(
                __( 'Flexible FAQs Settings Page', 'flexible-faqs' ),
                __( 'Flexible FAQs', 'flexible-faqs' ),
                'manage_options',
                $this->settings_slug,
                array( &$this, 'render_form' )
            );
        }
    
    }
    
    /**
     * Display the menu page.
     */
    public function render_form()
    {
        $tabs_list_html = $this->utility->build_settings_tabs_html( $this->plugin_data );
        $tab_classes = ( FFAQ_FREEMIUS_NAVIGATION === 'tabs' ? ' fs-section fs-full-size-wrapper' : ' no-tabs' );
        ?>
		<div class="wrap welcome main<?php 
        echo  $tab_classes ;
        ?>">
			<?php 
        // Display setting update messages.
        settings_errors();
        ?>

			<?php 
        echo  $tabs_list_html ;
        ?>
			
			<h2 style="visibility:none;"></h2>

			<div class="wpgo-settings-inner">
				<div class="wpgo-settings-page-header">
					<h1 class="heading">
							<img src="<?php 
        echo  $this->module_roots['uri'] . '/assets/images/flexible-faqs-thumb.jpg' ;
        ?>">
						<?php 
        _e( 'Flexible FAQs Settings', 'flexible-faqs' );
        ?>
					</h1>
					<div class="wpgo-header-btns">
						<a class="plugin-btn" href="<?php 
        echo  $this->custom_plugin_data->welcome_url ;
        ?>#getting-started">Start Here<span style="width:15px;height:15px;" class="dashicons dashicons-arrow-right-alt2"></span></a>
						<a style="background:#f5a356;border:2px #d9914e solid;" class="plugin-btn" href="https://flexiblefaqs.com/demo/accordion-faq-template/" target="_blank">FAQ Live Demo</a></span>
						<a style="background:#933c60;border:2px #6d314a solid;" class="plugin-btn" href="https://flexiblefaqs.com/docs/getting-started/" target="_blank">Plugin Docs</a>
					</div>
				</div>

				<div class="wpgo-header-description">
					<p class="description-txt">
						To see what's new at a glance and how to use the plugin we recommend visiting the <a href="<?php 
        echo  $this->custom_plugin_data->welcome_url ;
        ?>">About</a> plugin page. Or, why not take a look at the Flexible FAQs <a href="https://flexiblefaqs.com/demo/accordion-faq-template/" target="_blank">Live Demo</a> to see plenty of FAQ examples in action.
					</p>
				</div>

				<h2 style="margin:40px 0 0 0;">FAQ Blocks</h2>
				<p>Using blocks is the is the new preferred way to add content to posts and pages. The main benefit is that the editor view is exactly the same as the frontend. This means no more having to switch between the editor and frontend to check how everything looks.</p>

				<p>Expand the section directly below to see all editor blocks included with the Flexible FAQs plugin.</p>

				<div class="wpgo-expand-box" style="margin-top:20px;">
					<h4 style="font-size:14px;display:inline-block;margin:5px 10px 10px 0px">Available Blocks and Settings</h4><button id="blocks-btn" class="button">Expand <span style="vertical-align:sub;width:16px;height:16px;font-size:16px;" class="dashicons dashicons-arrow-down-alt2"></span></button>
					<div id="blocks-wrap">
						<p>There are three FAQ blocks currently available. Each template includes multiple FAQ themes to choose from.</p>
						<h3 style="margin:20px 0 0 0;">Text FAQs</h3>
						<p>This block displays FAQs using a text based template.</p>
						<p><img style="width:450px;" src="<?php 
        echo  $this->module_roots['uri'] . '/assets/images/text-faq-block.png' ;
        ?>"></p>
						<h3 style="margin:20px 0 0 0;">Box FAQs</h3>
						<p>This block displays FAQs using a box style template.</p>
						<p><img style="width:450px;" src="<?php 
        echo  $this->module_roots['uri'] . '/assets/images/box-faq-block.png' ;
        ?>"></p>
						<h3 style="margin:20px 0 0 0;">Accordion FAQs</h3>
						<p>This block displays FAQs using an accordion style template.</p>
						<p><img style="width:450px;" src="<?php 
        echo  $this->module_roots['uri'] . '/assets/images/accordion-faq-block.png' ;
        ?>"></p>
						<p>Each block has many settings in common that allow you to customize the look and feel of FAQs:</p>
						<ul style="line-height:1.3em;" class="shortcode-attributes">
							<li><code>Select FAQs</code> - <em>(required)</em> The set of FAQs to be displayed.</li>
							<li><code>Select FAQ Group</code> - The group of FAQs to be displayed.</li>
							<li><code>Expand Icon</code> - Icon used to trigger FAQ expand/collapse action.</li>
							<li><code>Rotate Icon</code> - Controls whether icon rotates when an FAQ item is expanded.</li>
							<li><code>Question Color</code> - Sets the FAQ question color.</li>
							<li><code>Question Background Color</code> - Sets the FAQ question background color.</li>
							<li><code>Answer Color</code> - Sets the FAQ answer color.</li>
							<li><code>FAQ Separator</code> - Enable a separator element between each FAQ item.</li>
							<li><code>Q/A Separator</code> - Enable separator between each Question & Answer.</li>
							<li><code>Question Background Color Expanded</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ question background color when in expanded state.</li>
							<li><code>Answer Background Color</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ answer background color.</li>
							<li><code>FAQ Border</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Border around each FAQ item.</li>
							<li><code>Question Separator Border</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Border between Question & Answer.</li>
							<li><code>FAQ Separator Border</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Border between FAQ items.</li>
							<li><code>FAQ Border Radius</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Border radius between FAQ items.</li>
							<li><code>Inner Question Border Radius</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Question border radius.</li>
							<li><code>Inner Answer Border Radius</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Answer border radius.</li>
							<li><code>Container Border</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ container border radius.</li>
							<li><code>Answer Padding</code> <?php 
        echo  $this->pro_attribute ;
        ?> - CSS padding around answer.</li>
							<li><code>Question Padding</code> <?php 
        echo  $this->pro_attribute ;
        ?> - CSS padding around question.</li>
							<li><code>Answer Margin</code> <?php 
        echo  $this->pro_attribute ;
        ?> - CSS margin around answer.</li>
							<li><code>Question Margin</code> <?php 
        echo  $this->pro_attribute ;
        ?> - CSS margin around question.</li>
							<li><code>Description</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ description. Displayed before the first FAQ item.</li>
							<li><code>Width</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ container width. Specify a numerical value only. Default unit is pixels.</li>
							<li><code>Container Width Unit</code> <?php 
        echo  $this->pro_attribute ;
        ?> - CSS unit used for the FAQ container width.</li>
							<li><code>Margin Between FAQs</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Margin between FAQ items. Specify a numerical value only. Default unit is pixels.</li>
							<li><code>Question Hover Color</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Question hover color style. Any valid CSS color.</li>
							<li><code>Question Hover Color Expanded=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Question hover color style when expanded. Any valid CSS color.</li>
							<li><code>FAQ Box Shadow</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ item box shadow. Any valid CSS box shadow.</li>
							<li><code>FAQ Container Box Shadow</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ container box shadow. Any valid CSS box shadow.</li>
							<li><code>Icon Align</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Aligns FAQ expand icon to the right if true, or left if false.</li>
							<li><code>No Icon</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Hides the FAQ expand icon if set to true.</li>
							<li><code>Icon Margin</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Margin around the FAQ expand icon.</li>
							<li><code>Icon Expand Color</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Icon color (when in collapsed state).</li>
							<li><code>Icon Collapse  Color</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Icon color (when in expanded state).</li>
							<li><code>Icon Expand Background Color</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Icon background color (when in collapsed state).</li>
							<li><code>Icon Collapse Background Color</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Icon background color (when in expanded state).</li>
							<li><code>Align FAQ Container</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Align FAQ container left, right, or center.</li>
							<li><code>FAQ Post Title</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Display the FAQ custom post title.</li>
							<li><code>Custom Title</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Override the default post title.</li>
							<li><code>Align To FAQ</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Align FAQ container to post title and description.</li>
							<li><code>Question Bold</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Display question text in bold format.</li>
						</ul>
					</div>
				</div>

				<h2 style="margin:35px 0 0 0;">FAQ Shortcodes</h2>
				<p>Shortcodes have been around for a long time in WordPress and, before blocks were available, they were the only really accessible way to add complex or dynamic content to the editor. We've included FAQ shortcodes for those who prefer them to blocks, or if you don't have any choice. e.g. If using a 3rd party page builder, or the block editor has been disabled.</p>

				<p>Expand the section directly below to see all FAQ shortcodes currently available, along with a full list of supported shortcode attributes.</p>

				<div class="wpgo-expand-box" style="margin-top:20px;">
					<h4 style="font-size:14px;display: inline-block;margin:5px 10px 10px 0px;">Available Shortcodes & Attributes</h4><button id="shortcodes-btn" class="button">Expand <span style="vertical-align:sub;width:16px;height:16px;font-size:16px;" class="dashicons dashicons-arrow-down-alt2"></span></button>

					<div id="shortcodes-wrap">
						<p>Click on the shortcode(s) below to view the full documentation for each shortcode. Default values are always used for missing shortcode attributes. i.e. Override only the values you want to change.</p>
						<p style="margin:20px 0 0 0;"><code><a class="code-link" href="https://flexiblefaqs.com/docs/" target="_blank"><strong>[flexible-faqs]</strong></a></code> <?php 
        printf( __( 'Displays a set of FAQ items as defined in the associated FAQ post.', 'flexible-faqs' ) );
        ?></p>
						<p>Here are the available shortcode attributes along with default values:</p>

						<ul style="line-height:1.3em;" class="shortcode-attributes">
							<li><code>id='123'</code> - <em>(required)</em> The post ID of the FAQs to be displayed. Find this via <strong>Flexible FAQs > All FAQs</strong> in the WordPress admin (ID column).</li>
							<li><code>group='123'</code> - Use this to display multiple sets of FAQs. Find this via <strong>Flexible FAQs > FAQ Groups</strong> (ID column).</li>
							<li><code>template='text-expand'</code> - Template used to render FAQs.</li>
							<li><code>icon='arrow1'</code> - Icon used to trigger FAQ expand/collapse action.</li>
							<li><code>icon_expand_color=''</code> - Icon color (when in collapsed state).</li>
							<li><code>rotate_icon='true'</code> - Controls whether icon rotates when an FAQ item is expanded.</li>
							<li><code>q_color=''</code> - FAQ question color.</li>
							<li><code>q_bg_color=''</code> - FAQ question background color.</li>
							<li><code>a_color=''</code> - FAQ answer color.</li>
							<li><code>faq_separator='true'</code> - Enable a separator element between each FAQ item.</li>
							<li><code>q_a_separator='true'</code> - Enable separator between each Question & Answer.</li>
							<li><code>q_bg_color_expanded=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ question background color when in expanded state.</li>
							<li><code>a_bg_color=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ answer background color.</li>
							<li><code>faq_border=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Border around each FAQ item. e.g. <code>'{"literal":"1 #a0d6d4 solid"}'</code></li>
							<li><code>q_a_separator_border=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Border between Question & Answer. e.g. <code>'{"literal":"1 #a0d6d4 solid"}'</code></li>
							<li><code>faq_separator_border=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Border between FAQ items. e.g. <code>'{"literal":"1 #a0d6d4 solid"}'</code></li>
							<li><code>faq_border_radius=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Border radius between FAQ items. e.g. <code>'{"literal":"5px"}'</code></li>
							<li><code>inner_q_border_radius=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Question border radius. e.g. <code>'{"literal":"5px"}'</code></li>
							<li><code>inner_a_border_radius=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Answer border radius. e.g. <code>'{"literal":"5px"}'</code></li>
							<li><code>container_border=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ container border radius. e.g. <code>'{"literal":"1 #a0d6d4 solid"}'</code></li>
							<li><code>a_padding=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Answer padding. e.g. <code>'{"literal":"10px 5px"}'</code></li>
							<li><code>q_padding=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Question padding. e.g. <code>'{"literal":"10px 5px"}'</code></li>
							<li><code>a_margin=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Answer margin. e.g. <code>'{"literal":"10px 5px"}'</code></li>
							<li><code>q_margin=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Question margin. e.g. <code>'{"literal":"10px 5px"}'</code></li>
							<li><code>description=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ description. Displayed before the first FAQ item.</li>
							<li><code>width=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ container width. Specify a numerical value only. Default unit is pixels.</li>
							<li><code>container_width_unit=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ container width unit.</li>
							<li><code>margin_between_faqs=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Margin between FAQ items. Specify a numerical value only. Default unit is pixels.</li>
							<li><code>q_hover_color=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Question hover color. Any valid CSS color.</li>
							<li><code>q_hover_color_expanded=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Question hover color when expanded. Any valid CSS color.</li>
							<li><code>q_bg_hover_color_expand=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Question background color hover color (when in collapsed state).</li>
							<li><code>q_bg_hover_color_collapse=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Question background color hover color (when in expanded state).</li>
							<li><code>faq_box_shadow=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ item box shadow. Any valid CSS box shadow.</li>
							<li><code>faq_container_box_shadow=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - FAQ container box shadow. Any valid CSS box shadow.</li>
							<li><code>icon_align='right'</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Aligns FAQ expand icon to the right if true, or left if false.</li>
							<li><code>no_icon='false'</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Hides the FAQ expand icon if true.</li>
							<li><code>icon_margin=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Margin around the FAQ expand icon. e.g. <code>'{"literal":"10px 5px"}'</code></li>
							<li><code>icon_collapse_color=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Icon color (when in expanded state).</li>
							<li><code>icon_expand_hover_color=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Icon hover color (when in collapsed state).</li>
							<li><code>icon_collapse_hover_color=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Icon hover color (when in expanded state).</li>
							<li><code>icon_expand_bg_color=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Icon background color (when in collapsed state).</li>
							<li><code>icon_collapse_bg_color=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Icon background color (when in expanded state).</li>
							<li><code>icon_expand_hover_bg_color=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Icon background hover color (when in expanded state).</li>
							<li><code>icon_collapse_hover_bg_color=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Icon background hover color (when in collapsed state).</li>
							<li><code>align_faq_container=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Align FAQ container.</li>
							<li><code>faq_post_title='true'</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Optionally display the FAQ post title.</li>
							<li><code>center_faq_post_title='false'</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Optionally center the FAQ post title.</li>
							<li><code>custom_title=''</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Override the default post title.</li>
							<li><code>q_hover_mode='true'</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Defines the region of the question content HTML that triggers hover styles.</li>
							<li><code>align_to_faq='false'</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Align FAQ container to post title and description.</li>
							<li><code>q_bold='true'</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Display question text in bold format.</li>
							<li><code>accordion_mode='none'</code> <?php 
        echo  $this->pro_attribute ;
        ?> - Change to <code>set</code> or <code>group</code> to only allow one FAQ to be expanded at a time.</li>
						</ul>
					</div>
				</div>

				<h2 style="margin:35px 0 0 0;"><?php 
        _e( 'Plugin Settings', 'flexible-faqs' );
        ?></h2>

				<div class="wpgo-expand-box" style="margin-top:20px;">
					<div id="plugin-settings">
						<?php 
        
        if ( !$this->custom_plugin_data->is_premium ) {
            echo  '<p style="font-style:italic;"><strong><a href="' . $this->custom_plugin_data->freemius_discount_upgrade_url . '">Upgrade</a> (30% discount)</strong> to access pro plugin settings.</p>' ;
        } else {
            ?>
							<p>Use this section to manage plugin options.</p>
							<form method="POST" action="options.php">
							<?php 
            $opt_pfx = $this->custom_plugin_data->db_option_prefix;
            $page_name = $this->settings_slug;
            settings_fields( $opt_pfx . '_options_group' );
            $options = get_option( $opt_pfx . '_options', array() );
            ?>
							<input type="hidden" name="flexible_faqs_options[new_features_numbered_icon]" value="<?php 
            echo  $options['new_features_numbered_icon'] ;
            ?>">
							<input type="hidden" name="flexible_faqs_options[plugin_version]" value="<?php 
            echo  $options['plugin_version'] ;
            ?>">
							<?php 
            do_settings_sections( $page_name );
            submit_button();
            echo  '</form>' ;
        }
        
        ?>
					</div>
				</div>

				<div style="margin-top:25px;"></div>

				<h2 style="margin:35px 0 0 0;">Stay In Touch!</h2>

				<table class="form-table">
					<?php 
        do_action( $this->hook_prefix . '_settings_row_section_1', 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=58MYUR58GFW9E' );
        echo  $this->settings_fw->try_our_other_plugins( basename( $this->module_roots['dir'] ) ) ;
        echo  $this->settings_fw->subscribe_to_newsletter( 'http://eepurl.com/bXZmmD' ) ;
        echo  $this->settings_fw->keep_in_touch() ;
        echo  $this->settings_fw->report_issues( $this->custom_plugin_data->contact_us_url ) ;
        ?>
				</table>
  
			</div>

		</div>
		<?php 
    }
    
    /**
     * Filters the order of menu.
     *
     * @param String $custom A custom request string.
     * @return Array List of items in the menu.
     * 
     * @todo Add this to the plugin framework.
     */
    public function filter_menu_order( $custom )
    {
        global  $submenu ;
        // selectively rearrange for 'tabs', and always for 'menu' .
        if ( FFAQ_FREEMIUS_NAVIGATION === 'tabs' ) {
            // don't bother to rearrange unless the submenu page is displayed.
            if ( !isset( $_GET['page'] ) || $_GET['page'] !== $this->new_features_slug && $_GET['page'] !== $this->welcome_slug ) {
                return $custom;
            }
        }
        $parent_slug = $this->custom_plugin_data->parent_slug;
        $menu_type = $this->custom_plugin_data->menu_type;
        $pricingpage_index = 0;
        $parent_index = 0;
        $subpage_index1 = 0;
        $subpage_index2 = 0;
        $wp_org_support_forum_index = 0;
        // if global menu array is empty then don't try to re-index. This is typically empty when the Freemius
        // opt-in is displayed.
        if ( empty($submenu[$parent_slug]) ) {
            return $custom;
        }
        // store menu indexes of settings pages.
        foreach ( $submenu[$parent_slug] as $menu_index => $val ) {
            $menu_slug = $val[2];
            if ( $menu_slug === $this->settings_slug ) {
                $parent_index = $menu_index;
            }
            if ( $menu_slug === $this->new_features_slug ) {
                $subpage_index1 = $menu_index;
            }
            if ( $menu_slug === $this->welcome_slug ) {
                $subpage_index2 = $menu_index;
            }
            if ( $menu_slug === $this->custom_plugin_data->plugin_cpt_slug . '-wp-support-forum' ) {
                $wp_org_support_forum_index = $menu_index;
            }
            if ( $val[2] === $this->custom_plugin_data->freemius_slug . '-pricing' ) {
                $pricingpage_index = $menu_index;
            }
            // in the case of a CPT being used as the parent menu the Freemius generated pages will use
            // a different prefix to the normal one
            // if ($this->custom_plugin_data->menu_type === 'top-cpt') {
            // if ($menu_slug === $this->custom_plugin_data->plugin_cpt_slug . '-pricing') {
            // $pricingpage_index = $menu_index;
            // }
            // } else {
            // if ($menu_slug === $this->settings_slug . '-pricing') {
            // $pricingpage_index = $menu_index;
            // }
            // } // .
        }
        // Only re-index new features page if menu type is 'sub'.
        if ( 'sub' === $menu_type ) {
            // Only re-index if tabs are active and we're on new feature settings page OR tabs are not active.
            
            if ( FFAQ_FREEMIUS_NAVIGATION === 'tabs' && $_GET['page'] === $this->new_features_slug || FFAQ_FREEMIUS_NAVIGATION === 'menu' ) {
                // Find the next available index after the main settings page.
                $tmp_parent_index1 = $parent_index;
                while ( isset( $submenu[$parent_slug][$tmp_parent_index1] ) ) {
                    $tmp_parent_index1++;
                }
                // Move new features page to next position after main settings page.
                $submenu[$parent_slug][$tmp_parent_index1] = $submenu[$parent_slug][$subpage_index1];
                unset( $submenu[$parent_slug][$subpage_index1] );
                ksort( $submenu[$parent_slug] );
            }
        
        }
        // Only re-index welcome (about) page if tabs are active and we're on welcome settings page, OR tabs are not active.
        
        if ( FFAQ_FREEMIUS_NAVIGATION === 'tabs' && $_GET['page'] === $this->welcome_slug || FFAQ_FREEMIUS_NAVIGATION === 'menu' ) {
            // Find the next available index after the pricing page unless tabs are active in which case get next.
            // Available index after main settings page.
            
            if ( FFAQ_FREEMIUS_NAVIGATION === 'tabs' ) {
                $tmp_parent_index2 = $parent_index;
            } else {
                $tmp_parent_index2 = $pricingpage_index;
            }
            
            // $pricingpage_index will be 0 when license has been activated
            // @todo perhaps better to always make the about page last menu item rather than dependent on pricing page (if it exists).
            if ( 0 === $pricingpage_index ) {
                $tmp_parent_index2 = $wp_org_support_forum_index;
            }
            while ( isset( $submenu[$parent_slug][$tmp_parent_index2] ) ) {
                $tmp_parent_index2++;
            }
            // Move welcome page to next position after pricing/support forum page.
            $submenu[$parent_slug][$tmp_parent_index2] = $submenu[$parent_slug][$subpage_index2];
            unset( $submenu[$parent_slug][$subpage_index2] );
            ksort( $submenu[$parent_slug] );
        }
        
        return $custom;
    }

}
/* End class definition */