<?php
/**
 * Theme Palace options
 *
 * @package Theme Palace
 * @subpackage enlightme Pro
 * @since enlightme Pro 1.0.0
 */

/**
 * List of pages for page choices.
 * @return Array Array of page ids and name.
 */
function enlightme_pro_page_choices() {
    $pages = get_pages();
    $choices = array();
    $choices[0] = esc_html__( '--Select--', 'enlightme-pro' );
    foreach ( $pages as $page ) {
        $choices[ $page->ID ] = $page->post_title;
    }
    return  $choices;
}

/**
 * List of posts for post choices.
 * @return Array Array of post ids and name.
 */
function enlightme_pro_post_choices() {
    $posts = get_posts( array( 'numberposts' => -1 ) );
    $choices = array();
    $choices[0] = esc_html__( '--Select--', 'enlightme-pro' );
    foreach ( $posts as $post ) {
        $choices[ $post->ID ] = $post->post_title;
    }
    return  $choices;
}

/**
 * List of products for post choices.
 * @return Array Array of post ids and name.
 */
function enlightme_pro_product_choices() {
    $posts = get_posts( array( 'numberposts' => -1, 'post_type' => 'product' ) );
    $choices = array();
    $choices[0] = esc_html__( '--Select--', 'enlightme-pro' );
    foreach ( $posts as $post ) {
        $choices[ $post->ID ] = $post->post_title;
    }
    return  $choices;
}

/**
 * List of posts for course choices.
 * @return Array Array of course ids and name.
 */
function enlightme_pro_course_choices() {
    $courses = get_posts( array( 'numberposts' => -1, 'post_type'=>'tp-course' ) );
    $choices = array();
    $choices[0] = esc_html__( '--Select--', 'enlightme-pro' );
    foreach ( $courses as $course ) {
        $choices[ $course->ID ] = $course->post_title;
    }
    return  $choices;
}

/**
 * List of posts for course choices.
 * @return Array Array of course ids and name.
 */
function enlightme_pro_event_choices() {
    $events = get_posts( array( 'numberposts' => -1, 'post_type'=>'tp-event' ) );
    $choices = array();
    $choices[0] = esc_html__( '--Select--', 'enlightme-pro' );
    foreach ( $events as $event ) {
        $choices[ $event->ID ] = $event->post_title;
    }
    return  $choices;
}

/**
 * List of posts for team choices.
 * @return Array Array of team ids and name.
 */
function enlightme_pro_team_choices() {
    $teams = get_posts( array( 'numberposts' => -1, 'post_type'=>'tp-team' ) );
    $choices = array();
    $choices[0] = esc_html__( '--Select--', 'enlightme-pro' );
    foreach ( $teams as $team ) {
        $choices[ $team->ID ] = $team->post_title;
    }
    return  $choices;
}

/**
 * List of pages for page choices.
 * @return Array Array of page ids and name.
 */
function enlightme_pro_testimonial_choices() {
    $testimonials = get_posts( array( 'numberposts' => -1, 'post_type'=>'tp-testimonial' ) );
    $choices = array();
    $choices[0] = esc_html__( '--Select--', 'enlightme-pro' );
    foreach ( $testimonials as $testimonial ) {
        $choices[ $testimonial->ID ] = $testimonial->post_title;
    }
    return  $choices;
}


if ( ! function_exists( 'enlightme_pro_typography_options' ) ) :
    function enlightme_pro_typography_options(){
    $font_family_arr = array();
    $font_family_arr[''] = esc_html__( '--Default--', 'enlightme-pro' );

    // Make the request
    $request = wp_remote_get( get_theme_file_uri( 'assets/webfonts.json' ) );

    if( is_wp_error( $request ) ) {
        return false; // Bail early
    }
     // Retrieve the data
    $body = wp_remote_retrieve_body( $request );
    $data = json_decode( $body );
    if ( ! empty( $data ) ) {
        foreach ( $data->items as $items => $fonts ) {
            $family_str_arr = explode( ' ', $fonts->family );
            $family_value = implode( '+', $family_str_arr );
            $font_family_arr[ $family_value ] = $fonts->family;
        }
    }

    return $font_family_arr;
}
endif;

if ( ! function_exists( 'enlightme_pro_selected_sidebar' ) ) :
    /**
     * Sidebars options
     * @return array Sidbar positions
     */
    function enlightme_pro_selected_sidebar() {
        $enlightme_pro_selected_sidebar = array(
            'sidebar-1'             => esc_html__( 'Default Sidebar', 'enlightme-pro' ),
            'optional-sidebar'      => esc_html__( 'Optional Sidebar 1', 'enlightme-pro' ),
            'optional-sidebar-2'    => esc_html__( 'Optional Sidebar 2', 'enlightme-pro' ),
            'optional-sidebar-3'    => esc_html__( 'Optional Sidebar 3', 'enlightme-pro' ),
            'optional-sidebar-4'    => esc_html__( 'Optional Sidebar 4', 'enlightme-pro' ),
        );

        $output = apply_filters( 'enlightme_pro_selected_sidebar', $enlightme_pro_selected_sidebar );

        return $output;
    }
endif;

if ( ! function_exists( 'enlightme_pro_site_layout' ) ) :
    /**
     * Site Layout
     * @return array site layout options
     */
    function enlightme_pro_site_layout() {
        $enlightme_pro_site_layout = array(
            'wide-layout'  => get_template_directory_uri() . '/assets/images/full.png',
            'boxed-layout' => get_template_directory_uri() . '/assets/images/boxed.png',
            'frame-layout' => get_template_directory_uri() . '/assets/images/framed.png',
        );

        $output = apply_filters( 'enlightme_pro_site_layout', $enlightme_pro_site_layout );
        return $output;
    }
endif;


if ( ! function_exists( 'enlightme_pro_global_sidebar_position' ) ) :
    /**
     * Global Sidebar position
     * @return array Global Sidebar positions
     */
    function enlightme_pro_global_sidebar_position() {
        $enlightme_pro_global_sidebar_position = array(
            'right-sidebar' => get_template_directory_uri() . '/assets/images/right.png',
            'left-sidebar'  => get_template_directory_uri() . '/assets/images/left.png',
            'no-sidebar'    => get_template_directory_uri() . '/assets/images/full.png',
        );

        $output = apply_filters( 'enlightme_pro_global_sidebar_position', $enlightme_pro_global_sidebar_position );

        return $output;
    }
endif;


if ( ! function_exists( 'enlightme_pro_sidebar_position' ) ) :
    /**
     * Sidebar position
     * @return array Sidbar positions
     */
    function enlightme_pro_sidebar_position() {
        $enlightme_pro_sidebar_position = array(
            'right-sidebar' => get_template_directory_uri() . '/assets/images/right.png',
            'left-sidebar'  => get_template_directory_uri() . '/assets/images/left.png',
            'no-sidebar'    => get_template_directory_uri() . '/assets/images/full.png',
            'no-sidebar-content'   => get_template_directory_uri() . '/assets/images/boxed.png',
        );

        $output = apply_filters( 'enlightme_pro_sidebar_position', $enlightme_pro_sidebar_position );

        return $output;
    }
endif;


if ( ! function_exists( 'enlightme_pro_pagination_options' ) ) :
    /**
     * Pagination
     * @return array site pagination options
     */
    function enlightme_pro_pagination_options() {
        $enlightme_pro_pagination_options = array(
            'numeric'   => esc_html__( 'Numeric', 'enlightme-pro' ),
            'default'   => esc_html__( 'Default(Older/Newer)', 'enlightme-pro' ),
            'infinite'  => esc_html__( 'Infinite', 'enlightme-pro' ),
        );

        $output = apply_filters( 'enlightme_pro_pagination_options', $enlightme_pro_pagination_options );

        return $output;
    }
endif;

if ( ! function_exists( 'enlightme_pro_get_spinner_list' ) ) :
    /**
     * List of spinner icons options.
     * @return array List of all spinner icon options.
     */
    function enlightme_pro_get_spinner_list() {
        $arr = array(
            'default'               => esc_html__( 'Default', 'enlightme-pro' ),
            'spinner-wheel'         => esc_html__( 'Wheel', 'enlightme-pro' ),
            'spinner-double-circle' => esc_html__( 'Double Circle', 'enlightme-pro' ),
            'spinner-two-way'       => esc_html__( 'Two Way', 'enlightme-pro' ),
            'spinner-umbrella'      => esc_html__( 'Umbrella', 'enlightme-pro' ),
            'spinner-dots'          => esc_html__( 'Dots', 'enlightme-pro' ),
            'spinner-one-way'       => esc_html__( 'One Way', 'enlightme-pro' ),
            'spinner-fidget'        => esc_html__( 'Fidget', 'enlightme-pro' ),
        );
        return apply_filters( 'enlightme_pro_spinner_list', $arr );
    }
endif;

if ( ! function_exists( 'enlightme_pro_switch_options' ) ) :
    /**
     * List of custom Switch Control options
     * @return array List of switch control options.
     */
    function enlightme_pro_switch_options() {
        $arr = array(
            'on'        => esc_html__( 'Enable', 'enlightme-pro' ),
            'off'       => esc_html__( 'Disable', 'enlightme-pro' )
        );
        return apply_filters( 'enlightme_pro_switch_options', $arr );
    }
endif;

if ( ! function_exists( 'enlightme_pro_hide_options' ) ) :
    /**
     * List of custom Switch Control options
     * @return array List of switch control options.
     */
    function enlightme_pro_hide_options() {
        $arr = array(
            'on'        => esc_html__( 'Yes', 'enlightme-pro' ),
            'off'       => esc_html__( 'No', 'enlightme-pro' )
        );
        return apply_filters( 'enlightme_pro_hide_options', $arr );
    }
endif;

if ( ! function_exists( 'enlightme_pro_sortable_sections' ) ) :
    /**
     * List of sections Control options
     * @return array List of Sections control options.
     */
    function enlightme_pro_sortable_sections() {
        $sections = array();
        $sections = array(
            'slider'                => esc_html__( 'Main Slider', 'enlightme-pro' ),
            'service'               => esc_html__( 'Service Section', 'enlightme-pro' ),
            'about'                 => esc_html__( 'About Section', 'enlightme-pro' ),
            'career'                => esc_html__( 'Career Section', 'enlightme-pro' ),
            'testimonial'           => esc_html__( 'Testimonial Section', 'enlightme-pro' ),
            'subscription'          => esc_html__( 'Subscription Section', 'enlightme-pro' ),
            'blog'                  => esc_html__( 'Blog Section', 'enlightme-pro' ),
            'team'                  => esc_html__( 'Team Section', 'enlightme-pro' ),
            'gallery'               => esc_html__( 'Gallery Section', 'enlightme-pro' ),
            'featured'              => esc_html__( 'Featured Section', 'enlightme-pro' ),
            'client'                => esc_html__( 'Client Section', 'enlightme-pro' ),
            'download'              => esc_html__( 'Download Section', 'enlightme-pro' ),
            'featured_products'     => esc_html__( 'Featured Products Section', 'enlightme-pro' ),
            'recent_products'       => esc_html__( 'Recent Products Section', 'enlightme-pro' ),
            'cta'                   => esc_html__( 'Call To Action Section', 'enlightme-pro' ),
            'latest_products'       => esc_html__( 'Latest Products Section', 'enlightme-pro' ),
            'latest_posts'          => esc_html__( 'Latest Posts Section', 'enlightme-pro' ),
            'featured_posts'        => esc_html__( 'Featured Posts Section', 'enlightme-pro' ),
            'popular_posts'         => esc_html__( 'Popular Posts Section', 'enlightme-pro' ),
            'advertisement'         => esc_html__( 'Advertisement Section', 'enlightme-pro' ),
            'blog_posts'            => esc_html__( 'Blog Posts Section', 'enlightme-pro' ),
            'promotion'             => esc_html__( 'Promotion Section', 'enlightme-pro' ),
            'counter'               => esc_html__( 'Counter Section', 'enlightme-pro' ),
            'medical_featured'      => esc_html__( 'Medical Feaatured Section', 'enlightme-pro' ),
        );
        return apply_filters( 'enlightme_pro_sortable_sections', $sections );
    }
endif;

if ( ! function_exists( 'enlightme_pro_popular_course_content_type' ) ) :
    /**
     * Destination Options
     * @return array site gallery options
     */
    function enlightme_pro_popular_course_content_type() {
        $enlightme_pro_popular_course_content_type = array(
            'page'      => esc_html__( 'Page', 'enlightme-pro' ),
            'post'      => esc_html__( 'Post', 'enlightme-pro' ),
            'category'  => esc_html__( 'Category', 'enlightme-pro' ),
        );

        if ( class_exists( 'TP_Education' ) ) {
            $enlightme_pro_popular_course_content_type_plugin = array();

            if ( post_type_exists( 'tp-course' ) ) {
                $enlightme_pro_popular_course_content_type_plugin['course'] = esc_html__('Course', 'enlightme-pro');
                $enlightme_pro_popular_course_content_type_plugin['course-category'] = esc_html__('Course Category', 'enlightme-pro');
            }
        }
         if ( !class_exists('TP_Education')) {
            $enlightme_pro_popular_course_content_type_plugin = array();
        }
        $enlightme_pro_popular_course_content_type = array_merge( $enlightme_pro_popular_course_content_type, $enlightme_pro_popular_course_content_type_plugin );
        $output = apply_filters( 'enlightme_pro_popular_course_content_type', $enlightme_pro_popular_course_content_type );


        return $output;
    }
endif;

if ( ! function_exists( 'enlightme_pro_popular_team_content_type' ) ) :
    /**
     * Destination Options
     * @return array site gallery options
     */
    function enlightme_pro_popular_team_content_type() {
        $enlightme_pro_popular_team_content_type = array(
            'page'      => esc_html__( 'Page', 'enlightme-pro' ),
            'post'      => esc_html__( 'Post', 'enlightme-pro' ),
            'category'  => esc_html__( 'Category', 'enlightme-pro' ),
        );

        if ( class_exists( 'TP_Education' ) ) {
            $custom_choices = array();
            if ( post_type_exists( 'tp-team' ) ) {
               $custom_choices['tp-team']   =  esc_html__( 'Team', 'enlightme-pro' );
               $custom_choices['tp-team-category']   =  esc_html__( 'Team Category', 'enlightme-pro' );    
            }
        }
        if ( !class_exists('TP_Education')) {
            $custom_choices = array();
        }
        $enlightme_pro_popular_team_content_type = array_merge( $enlightme_pro_popular_team_content_type, $custom_choices );
        $output = apply_filters( 'enlightme_pro_popular_team_content_type', $enlightme_pro_popular_team_content_type );


        return $output;
    }
endif;

if ( ! function_exists( 'enlightme_pro_popular_event_content_type' ) ) :
    /**
     * Destination Options
     * @return array site gallery options
     */
    function enlightme_pro_popular_event_content_type() {
        $enlightme_pro_popular_event_content_type = array(
                'page'      => esc_html__( 'Page', 'enlightme-pro' ),
                'post'      => esc_html__( 'Post', 'enlightme-pro' ),
                'category'  => esc_html__( 'Category', 'enlightme-pro' ),
            ) ;
        if ( class_exists( 'TP_Education' ) ) {
            $enlightme_pro_popular_event_content_type = array_merge($enlightme_pro_popular_event_content_type, array(
                'event'            => esc_html__( 'Event', 'enlightme-pro' ),
                'event-category'   => esc_html__( 'Event Category', 'enlightme-pro' ),
                ) );
        }
       
        $output = apply_filters( 'enlightme_pro_popular_event_content_type', $enlightme_pro_popular_event_content_type );


        return $output;
    }
endif;

if ( ! function_exists( 'enlightme_pro_testimonial_content_type' ) ) :
    /**
     * Package Options
     * @return array site testimonial options
     */
    function enlightme_pro_testimonial_content_type() {
        $enlightme_pro_testimonial_content_type = array(
            'page'      => esc_html__( 'Page', 'enlightme-pro' ),
            'post'      => esc_html__( 'Post', 'enlightme-pro' ),
            'category'  => esc_html__( 'Category', 'enlightme-pro' ),
        );

        if ( class_exists( 'TP_Education' ) ) {
            $enlightme_pro_testimonial_content_type = array_merge( $enlightme_pro_testimonial_content_type, array(
                'testimonial'            => esc_html__( 'Testimonial', 'enlightme-pro' ),
                ) );
        }

        $output = apply_filters( 'enlightme_pro_testimonial_content_type', $enlightme_pro_testimonial_content_type );

        return $output;
    }
endif;

if ( ! function_exists( 'enlightme_pro_career_content_type' ) ) :
    /**
     * Package Options
     * @return array site career options
     */
    function enlightme_pro_career_content_type() {
        $enlightme_pro_career_content_type = array(
            'category'  => esc_html__( 'Category', 'enlightme-pro' ),
        );

        if ( class_exists( 'TP_Education' ) ) {
            $enlightme_pro_career_content_type = array_merge( $enlightme_pro_career_content_type, array(
                'course-category'   => esc_html__( 'Course Category', 'enlightme-pro' ),
                ) );
        }

        $output = apply_filters( 'enlightme_pro_career_content_type', $enlightme_pro_career_content_type );

        return $output;
    }
endif;