<?php
/**
 * The sanitize file.
 *
 * @package Smart_Post_Show_Pro
 * @subpackage Smart_Post_Show_Pro/admin/views
 */

if ( ! defined( 'ABSPATH' ) ) {
	die;
} // Cannot access directly.

if ( ! function_exists( 'spf_sanitize_replace_a_to_b' ) ) {
	/**
	 *
	 * Sanitize
	 * Replace letter a to letter b
	 *
	 * @param mixed $value value.
	 * @since 1.0.0
	 * @version 1.0.0
	 */
	function spf_sanitize_replace_a_to_b( $value ) {

		return str_replace( 'a', 'b', $value );
	}
}

if ( ! function_exists( 'pcp_sanitize_number_array_field' ) ) {
	/**
	 *
	 * Sanitize number
	 *
	 * @param  mixed $arr_items value.
	 * @since 1.0.0
	 * @version 1.0.0
	 */
	function pcp_sanitize_number_array_field( $arr_items ) {
		if ( ! is_array( $arr_items ) ) {
			return array();
		}

		foreach ( $arr_items as $key => $value ) {
			if ( 'unit' === $key ) {
				$arr_items[ $key ] = wp_filter_nohtml_kses( $value );
			} elseif ( ! empty( $value ) ) {
				$arr_items[ $key ] = intval( $value );
			}
		}
		return $arr_items;
	}
}

if ( ! function_exists( 'pcp_sanitize_number_field' ) ) {
	/**
	 *
	 * Sanitize number
	 *
	 * @param  mixed $value value.
	 * @since 1.0.0
	 * @version 1.0.0
	 */
	function pcp_sanitize_number_field( $value ) {
		if ( ! empty( $value ) ) {
			return intval( $value );
		}
	}
}

if ( ! function_exists( 'pcp_sanitize_title' ) ) {
	/**
	 *
	 * Sanitize title
	 *
	 * @param mixed $value title.
	 * @since 1.0.0
	 * @version 1.0.0
	 */
	function pcp_sanitize_title( $value ) {

		return sanitize_title( $value );
	}
}
