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

/**
 * List of pages for page choices.
 * @return Array Array of page ids and name.
 */
function raise_charity_pro_page_choices() {
    $pages = get_pages();
    $choices = array();
    $choices[0] = esc_html__( '--Select--', 'raise-charity-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 raise_charity_pro_post_choices() {
    $posts = get_posts( array( 'numberposts' => -1 ) );
    $choices = array();
    $choices[0] = esc_html__( '--Select--', 'raise-charity-pro' );
    foreach ( $posts as $post ) {
        $choices[ $post->ID ] = $post->post_title;
    }
    return  $choices;
}

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

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

function raise_charity_pro_product_choices() {
    $full_product_list = array();
    $product_id = array();
    $loop = new WP_Query(array('post_type' => array('product', 'product_variation'), 'posts_per_page' => -1));
    while ($loop->have_posts()) : $loop->the_post();
        $product_id[] = get_the_id();
    endwhile;
    wp_reset_postdata();
    $choices = array();
    $choices[0] = esc_html__( '--Select--', 'raise-charity-pro' );
    foreach ( $product_id  as $id ) {
        $choices[ $id ] = get_the_title( $id );
    }
    return  $choices;
}

if ( ! function_exists( 'raise_charity_pro_typography_options' ) ) :
    /**
     * Returns list of typography
     * @return array font styles
     */
    function raise_charity_pro_typography_options(){
        $font_family_arr = array();
        $font_family_arr[''] = esc_html__( '--Default--', 'raise-charity-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( 'raise_charity_pro_selected_sidebar' ) ) :
    /**
     * Sidebars options
     * @return array Sidbar positions
     */
    function raise_charity_pro_selected_sidebar() {
        $raise_charity_pro_selected_sidebar = array(
            'sidebar-1'             => esc_html__( 'Default Sidebar', 'raise-charity-pro' ),
            'optional-sidebar'      => esc_html__( 'Optional Sidebar 1', 'raise-charity-pro' ),
            'optional-sidebar-2'    => esc_html__( 'Optional Sidebar 2', 'raise-charity-pro' ),
            'optional-sidebar-3'    => esc_html__( 'Optional Sidebar 3', 'raise-charity-pro' ),
            'optional-sidebar-4'    => esc_html__( 'Optional Sidebar 4', 'raise-charity-pro' ),
        );

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

        return $output;
    }
endif;

if ( ! function_exists( 'raise_charity_pro_site_layout' ) ) :
    /**
     * Site Layout
     * @return array site layout options
     */
    function raise_charity_pro_site_layout() {
        $raise_charity_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( 'raise_charity_pro_site_layout', $raise_charity_pro_site_layout );
        return $output;
    }
endif;


if ( ! function_exists( 'raise_charity_pro_global_sidebar_position' ) ) :
    /**
     * Global Sidebar position
     * @return array Global Sidebar positions
     */
    function raise_charity_pro_global_sidebar_position() {
        $raise_charity_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( 'raise_charity_pro_global_sidebar_position', $raise_charity_pro_global_sidebar_position );

        return $output;
    }
endif;


if ( ! function_exists( 'raise_charity_pro_sidebar_position' ) ) :
    /**
     * Sidebar position
     * @return array Sidbar positions
     */
    function raise_charity_pro_sidebar_position() {
        $raise_charity_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( 'raise_charity_pro_sidebar_position', $raise_charity_pro_sidebar_position );

        return $output;
    }
endif;


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

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

        return $output;
    }
endif;

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

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

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

if ( ! function_exists( 'raise_charity_pro_sortable_sections' ) ) :
    /**
     * List of sections Control options
     * @return array List of Sections control options.
     */
    function raise_charity_pro_sortable_sections() {
        $sections = array(
            'slider'                => esc_html__( 'Slider', 'raise-charity-pro' ),
            'featured_posts'        => esc_html__( 'Featured Posts', 'raise-charity-pro' ),
            'popular_posts'         => esc_html__( 'Popular Posts', 'raise-charity-pro' ),
            'recent_posts'          => esc_html__( 'Recent Posts', 'raise-charity-pro' ),
            'about'                 => esc_html__( 'About', 'raise-charity-pro' ),
            'courses'               => esc_html__( 'Courses', 'raise-charity-pro' ),
            'recent_cause'          => esc_html__( 'Recent Cause', 'raise-charity-pro' ),
            'service'               => esc_html__( 'Services', 'raise-charity-pro' ),
            'event'                 => esc_html__( 'Event', 'raise-charity-pro' ),
            'promotion'             => esc_html__( 'Promotion', 'raise-charity-pro' ),
            'gallery'               => esc_html__( 'Gallery', 'raise-charity-pro' ),
            'counter'               => esc_html__( 'Counter', 'raise-charity-pro' ),
            'team'                  => esc_html__( 'Team', 'raise-charity-pro' ),
            'skills'                => esc_html__( 'Skills', 'raise-charity-pro' ),
            'testimonial'           => esc_html__( 'Testimonial', 'raise-charity-pro' ),
            'latest_posts'          => esc_html__( 'Latest Post', 'raise-charity-pro' ),
            'contact'               => esc_html__( 'Contact Us', 'raise-charity-pro' ),
            'sponsor'               => esc_html__( 'Sponsor', 'raise-charity-pro' ),
            'cta'                   => esc_html__( 'CTA', 'raise-charity-pro' ),
            'latest_products'       => esc_html__( 'Latest Products', 'raise-charity-pro' ),
            'popular_products'      => esc_html__( 'Popular Products', 'raise-charity-pro' ),
            'collection'            => esc_html__( 'Products Collection', 'raise-charity-pro' ),
            'recent_products'       => esc_html__( 'Recent Products', 'raise-charity-pro' ),
            'featured_products'     => esc_html__( 'Featured Products', 'raise-charity-pro' ),
            'trending_product'      => esc_html__( 'Trending Products', 'raise-charity-pro' ),
        );
        return apply_filters( 'raise_charity_pro_sortable_sections', $sections );
    }
endif;

if ( ! function_exists( 'raise_charity_pro_heading_tags' ) ) :
    /**
     * Destination Options
     * @return array site gallery options
     */
    function raise_charity_pro_heading_tags() {
        
        $raise_charity_pro_heading_tags = array(
			'h1'	=> esc_html__('H1', 'raise-charity-pro'),
			'h2'	=> esc_html__('H2', 'raise-charity-pro'),
			'h3'	=> esc_html__('H3', 'raise-charity-pro'),
			'h4'	=> esc_html__('H4', 'raise-charity-pro'),
			'h5'	=> esc_html__('H5', 'raise-charity-pro'),
			'h6'	=> esc_html__('H6', 'raise-charity-pro'),
			'p'		=> esc_html__('Paragraph', 'raise-charity-pro'),
		);

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


        return $output;
    }
endif;