<?php
if ( ! defined( 'ABSPATH' ) ){ exit; }
if ( ! class_exists( 'WPCTP_Theme_Option' ) ) :
    class WPCTP_Theme_Option {	
        public function __construct() {		
            $this->includes();		
            $this->init_hooks();	
        }	
        private function init_hooks() {
            add_action( 'admin_print_styles', array( $this, 'admin_styles' ) );
            add_action( 'admin_print_scripts', array( $this, 'admin_scripts' ) );
            add_action( 'admin_init', array( $this, 'register_setting' ) );
            add_action( 'admin_menu', array( $this, 'admin_menu' ) );	
        }
        public function includes() {
            include_once( WPCTP_TO_DIR . '/functions.php' );
            include_once( WPCTP_TO_DIR . '/settings.php' );
            include_once( WPCTP_TO_DIR . '/class-walker-page-checkbox.php' );
            include_once( WPCTP_TO_DIR . '/fields.php' );	
        }	
        public function admin_styles(){		
            wp_register_style( 'wpctp-admin', WPCTP_CSS_URL . '/admin.css' );		
            wp_enqueue_style( 'wpctp-admin' );	
        }		
        public function admin_scripts() {
            wp_enqueue_style( 'wp-color-picker' );
            wp_enqueue_script( 'wp-color-picker' );
            wp_enqueue_media();
            wp_register_script( 'wpctp-admin', WPCTP_JS_URL . '/admin.js', array( 'jquery' ) );
            wp_enqueue_script( 'wpctp-admin' );
            wp_localize_script(
                'wpctp-admin',
                'wpctp',
                array(
                    'ajaxurl' => admin_url( 'admin-ajax.php' ),
                    'slug' => 'wpctp'
                    )
            );	
        }	
        public function register_setting(){
            register_setting( 'wpctp', 'wpctp' );	
        }	
        public function admin_menu(){
            add_menu_page(
                WPCTP_NAME,
                __( 'Theme Options' ),
                'manage_options',
                'wpctp-settings',
                'wpctp_settings_html',
                WPCTP_IMAGES_URL . '/wpctp-icon.png',
                3
            );	
        }
    }
    new WPCTP_Theme_Option;
endif;