<?php

/**

 * Initialize the custom Theme Options.

 */

add_action( 'init', 'custom_theme_options' );



/**

 * Build the custom settings & update OptionTree.

 *

 * @return    void

 * @since     2.0

 */

function custom_theme_options() {



  /* OptionTree is not loaded yet, or this is not an admin request */

  if ( ! function_exists( 'ot_settings_id' ) || ! is_admin() )

    return false;



  /**

   * Get a copy of the saved settings array. 

   */

  $saved_settings = get_option( ot_settings_id(), array() );

  

  /**

   * Custom settings array that will eventually be 

   * passes to the OptionTree Settings API Class.

   */

  $custom_settings = array( 

    'contextual_help' => array( 

      'content'       => array( 

        array(

          'id'        => 'option_types_help',

          'title'     => __( 'Option Types', 'theme-text-domain' ),

          'content'   => '<p>' . __( 'Help content goes here!', 'theme-text-domain' ) . '</p>'

        )

      ),

      'sidebar'       => '<p>' . __( 'Sidebar content goes here!', 'theme-text-domain' ) . '</p>'

    ),

    'sections'        => array( 

      array(

        'id'          => 'general',

        'title'       => __( 'General', 'theme-text-domain' )

      ),

      array(

        'id'          => 'leadform',

        'title'       => __( 'Lead Form', 'theme-text-domain' )

      ),

      array(

        'id'          => 'style',

        'title'       => __( 'Style', 'theme-text-domain' )

      ),

      array(

        'id'          => 'header',

        'title'       => __( 'Header', 'theme-text-domain' )

      ),

      array(

        'id'          => 'footer',

        'title'       => __( 'Footer', 'theme-text-domain' )

      ),



    ),

    'settings'        => array(

        // General: Logo

        array(

        'id'          => 'logo_upload',

        'label'       => __( 'Upload Logo', 'tmbd' ),

        'desc'        => __( 'Upload your custom logo', 'tmbd' ),

        'std'         => '',

        'type'        => 'upload',

        'section'     => 'general',

        ),

        // General: Logo

        array(

        'id'          => 'banner_upload',

        'label'       => __( 'Upload Banner', 'tmbd' ),

        'desc'        => __( 'Upload your Page banner', 'tmbd' ),

        'std'         => '',

        'type'        => 'upload',

        'section'     => 'general',

        ),

        // General: Favicon

        array(

        'id'          => 'favicon',

        'label'       => __( 'Upload favicon', 'tmbd' ),

        'desc'        => __( 'Upload your favicon', 'tmbd' ),

        'std'         => get_template_directory_uri() . '/images/favicon.png',

        'type'        => 'upload',

        'section'     => 'general',

        ),

        // leadform: leadform

        array(

        'id'          => 'leadformcode',

        'label'       => __( 'Lead Form Iframe', 'tmbd' ),

        'desc'        => __( 'If you are a software member and have Lead form iframe please past it here', 'tmbd' ),

        'type'        => 'textarea-simple',

        'section'     => 'leadform',

        ),

        //Style

        array(

            'id'          => 'primary_color',

            'label'       => __( 'Primary Color', 'theme-text-domain' ),

            'desc'        => __( '', 'theme-text-domain' ),

            'std'         => '#0C4E77',

            'type'        => 'colorpicker',

            'section'     => 'style',

          ),

        //Style

        array(

            'id'          => 'secondary_color',

            'label'       => __( 'Secondary Color', 'theme-text-domain' ),

            'desc'        => __( '', 'theme-text-domain' ),

            'std'         => '#072D44',

            'type'        => 'colorpicker',

            'section'     => 'style',

          ),

        array(

            'id'          => 'h_color',

            'label'       => __( 'Headline Color', 'theme-text-domain' ),

            'desc'        => __( '', 'theme-text-domain' ),

            'std'         => '#000',

            'type'        => 'colorpicker',

            'section'     => 'style',

          ),

       



        // Header

        array(

        'id'          => 'client_login',

        'label'       => __( 'Client Login Link', 'tmbd' ),

        'desc'        => __( 'Put Client Login Link', 'tmbd' ),

        'std'         => '#',

        'type'        => 'text',

        'section'     => 'header',

        ),

        

         // Header

        array(

        'id'          => 'aff_login',

        'label'       => __( 'Affiliate Login Link', 'tmbd' ),

        'desc'        => __( 'Put Affiliate Login Link', 'tmbd' ),

        'std'         => '#',

        'type'        => 'text',

        'section'     => 'header',

        ),

         // Header

        array(

        'id'          => 'all_social-link',

        'label'       => __( 'Social Link', 'tmbd' ),

        'desc'        => __( '', 'tmbd' ),

        'std'         => '',

        'type'        => 'social-links',

        'section'     => 'footer',

        ),

        // footer

        array(

        'id'          => 'footer_text',

        'label'       => __( 'Footer Text', 'tmbd' ),

        'desc'        => __( 'Put footer text', 'tmbd' ),

        'std'         => '',

        'type'        => 'textarea-simple',

        'section'     => 'footer',

        ),

    )

  );

  

  /* allow settings to be filtered before saving */

  $custom_settings = apply_filters( ot_settings_id() . '_args', $custom_settings );

  

  /* settings are not the same update the DB */

  if ( $saved_settings !== $custom_settings ) {

    update_option( ot_settings_id(), $custom_settings ); 

  }

  

  /* Lets OptionTree know the UI Builder is being overridden */

  global $ot_has_custom_theme_options;

  $ot_has_custom_theme_options = true;

  

}