<?php
/**
 * Helper functions related to customizer and options.
 *
 * @package Classifyed
 */

if ( ! function_exists( 'classifyed_get_global_layout_options' ) ) :

	/**
	 * Returns global layout options.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_global_layout_options() {

		$choices = array(
			'left-sidebar'  => esc_html__( 'Primary Sidebar - Content', 'classifyed' ),
			'right-sidebar' => esc_html__( 'Content - Primary Sidebar', 'classifyed' ),
			'three-columns' => esc_html__( 'Three Columns', 'classifyed' ),
			'no-sidebar'    => esc_html__( 'No Sidebar', 'classifyed' ),
		);
		$output = apply_filters( 'classifyed_filter_layout_options', $choices );
		return $output;

	}

endif;

if ( ! function_exists( 'classifyed_get_site_layout_options' ) ) :

	/**
	 * Returns site layout options.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_site_layout_options() {

		$choices = array(
			'fluid' => esc_html__( 'Fluid', 'classifyed' ),
			'boxed' => esc_html__( 'Boxed', 'classifyed' ),
		);
		$output = apply_filters( 'classifyed_filter_site_layout_options', $choices );
		if ( ! empty( $output ) ) {
			ksort( $output );
		}
		return $output;

	}

endif;

if ( ! function_exists( 'classifyed_get_pagination_type_options' ) ) :

	/**
	 * Returns pagination type options.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_pagination_type_options() {

		$choices = array(
			'default' => esc_html__( 'Default (Older / Newer Post)', 'classifyed' ),
			'numeric' => esc_html__( 'Numeric', 'classifyed' ),
		);
		return $choices;

	}

endif;

if ( ! function_exists( 'classifyed_get_breadcrumb_type_options' ) ) :

	/**
	 * Returns breadcrumb type options.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_breadcrumb_type_options() {

		$choices = array(
			'disabled' => esc_html__( 'Disabled', 'classifyed' ),
			'simple'   => esc_html__( 'Simple', 'classifyed' ),
			'advanced' => esc_html__( 'Advanced', 'classifyed' ),
		);
		return $choices;

	}

endif;


if ( ! function_exists( 'classifyed_get_archive_layout_options' ) ) :

	/**
	 * Returns archive layout options.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_archive_layout_options() {

		$choices = array(
			'full'    => esc_html__( 'Full Post', 'classifyed' ),
			'excerpt' => esc_html__( 'Post Excerpt', 'classifyed' ),
		);
		$output = apply_filters( 'classifyed_filter_archive_layout_options', $choices );
		if ( ! empty( $output ) ) {
			ksort( $output );
		}
		return $output;

	}

endif;

if ( ! function_exists( 'classifyed_get_image_sizes_options' ) ) :

	/**
	 * Returns image sizes options.
	 *
	 * @since 1.0.0
	 *
	 * @param bool  $add_disable True for adding No Image option.
	 * @param array $allowed Allowed image size options.
	 * @return array Image size options.
	 */
	function classifyed_get_image_sizes_options( $add_disable = true, $allowed = array(), $show_dimension = true ) {

		global $_wp_additional_image_sizes;
		$get_intermediate_image_sizes = get_intermediate_image_sizes();
		$choices = array();
		if ( true === $add_disable ) {
			$choices['disable'] = esc_html__( 'No Image', 'classifyed' );
		}
		$choices['thumbnail'] = esc_html__( 'Thumbnail', 'classifyed' );
		$choices['medium']    = esc_html__( 'Medium', 'classifyed' );
		$choices['large']     = esc_html__( 'Large', 'classifyed' );
		$choices['full']      = esc_html__( 'Full (original)', 'classifyed' );

		if ( true === $show_dimension ) {
			foreach ( array( 'thumbnail', 'medium', 'large' ) as $key => $_size ) {
				$choices[ $_size ] = ucfirst( $_size ) . ' (' . get_option( $_size . '_size_w' ) . 'x' . get_option( $_size . '_size_h' ) . ')';
			}
		}

		if ( ! empty( $_wp_additional_image_sizes ) && is_array( $_wp_additional_image_sizes ) ) {
			foreach ( $_wp_additional_image_sizes as $key => $size ) {
				$choices[ $key ] = $key;
				if ( true === $show_dimension ){
					$choices[ $key ] .= ' ('. $size['width'] . 'x' . $size['height'] . ')';
				}
			}
		}

		if ( ! empty( $allowed ) ) {
			foreach ( $choices as $key => $value ) {
				if ( ! in_array( $key, $allowed ) ) {
					unset( $choices[ $key ] );
				}
			}
		}

		return $choices;

	}

endif;


if ( ! function_exists( 'classifyed_get_image_alignment_options' ) ) :

	/**
	 * Returns image options.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_image_alignment_options() {

		$choices = array(
			'none'   => _x( 'None', 'Alignment', 'classifyed' ),
			'left'   => _x( 'Left', 'Alignment', 'classifyed' ),
			'center' => _x( 'Center', 'Alignment', 'classifyed' ),
			'right'  => _x( 'Right', 'Alignment', 'classifyed' ),
		);
		return $choices;

	}

endif;

if ( ! function_exists( 'classifyed_get_featured_slider_transition_effects' ) ) :

	/**
	 * Returns the featured slider transition effects.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_featured_slider_transition_effects() {

		$choices = array(
			'fade'       => _x( 'fade', 'Transition Effect', 'classifyed' ),
			'fadeout'    => _x( 'fadeout', 'Transition Effect', 'classifyed' ),
			'none'       => _x( 'none', 'Transition Effect', 'classifyed' ),
			'scrollHorz' => _x( 'scrollHorz', 'Transition Effect', 'classifyed' ),
		);
		$output = apply_filters( 'classifyed_filter_featured_slider_transition_effects', $choices );
		if ( ! empty( $output ) ) {
			ksort( $output );
		}
		return $output;

	}

endif;

if ( ! function_exists( 'classifyed_get_featured_slider_content_options' ) ) :

	/**
	 * Returns the featured slider content options.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_featured_slider_content_options() {

		$choices = array(
			'home-page'   => esc_html__( 'Home Page / Front Page', 'classifyed' ),
			'entire-site' => esc_html__( 'Entire Site', 'classifyed' ),
			'disabled'    => esc_html__( 'Disabled', 'classifyed' ),
		);
		$output = apply_filters( 'classifyed_filter_featured_slider_content_options', $choices );
		if ( ! empty( $output ) ) {
			ksort( $output );
		}
		return $output;

	}

endif;

if ( ! function_exists( 'classifyed_get_featured_slider_type' ) ) :

	/**
	 * Returns the featured slider type.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_featured_slider_type() {

		$choices = array(
			'featured-page' => esc_html__( 'Featured Pages', 'classifyed' ),
		);
		$output = apply_filters( 'classifyed_filter_featured_slider_type', $choices );
		if ( ! empty( $output ) ) {
			ksort( $output );
		}
		return $output;

	}

endif;

if ( ! function_exists( 'classifyed_get_featured_content_status_options' ) ) :

	/**
	 * Returns the featured content options.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_featured_content_status_options() {

		$choices = array(
			'home-page' => esc_html__( 'Home Page Only', 'classifyed' ),
			'disabled'  => esc_html__( 'Disabled', 'classifyed' ),
		);
		$output = apply_filters( 'classifyed_filter_featured_content_status_options', $choices );
		if ( ! empty( $output ) ) {
			ksort( $output );
		}
		return $output;

	}

endif;

if ( ! function_exists( 'classifyed_get_featured_content_type' ) ) :

	/**
	 * Returns the featured content type.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_featured_content_type() {

		$choices = array(
			'featured-page' => esc_html__( 'Featured Pages', 'classifyed' ),
			'demo-content'  => esc_html__( 'Demo Content', 'classifyed' ),
		);
		$output = apply_filters( 'classifyed_filter_featured_content_type', $choices );
		if ( ! empty( $output ) ) {
			ksort( $output );
		}
		return $output;

	}

endif;

if ( ! function_exists( 'classifyed_get_featured_content_column_options' ) ) :

	/**
	 * Returns the featured content column.
	 *
	 * @since 1.0.0
	 *
	 * @return array Options array.
	 */
	function classifyed_get_featured_content_column_options() {

		$choices = array(
			'3' => sprintf( esc_html__( '%d Columns', 'classifyed' ), 3 ),
			'4' => sprintf( esc_html__( '%d Columns', 'classifyed' ), 4 ),
		);
		$output = apply_filters( 'classifyed_filter_featured_content_column_options', $choices );
		return $output;

	}

endif;
