<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// to check whether accessed directly

//check class dependencies exist or not
if ( ! class_exists( 'ELEX_MV_Dependencies' ) ) {
	require_once 'elex-mv-dependencies.php' ;
}

//check woocommerce is active function exist
if ( ! function_exists( 'elex_mv_is_woocommerce_active' ) ) {

	function elex_mv_is_woocommerce_active() {
		return ELEX_MV_Dependencies::elex_mv_woocommerce_active_check();
	}
}

if ( ! function_exists( 'elex_mv_is_valid_image_file' ) ) {
	/**
	 * Check if the given file name represents a valid image file.
	 *
	 * @param string $file_name File name to check.
	 * @param string $file_path Optional actual file path to verify contents.
	 * @return bool True if valid image, false otherwise.
	 */
	function elex_mv_is_valid_image_file( $file_name, $file_path = '' ) {
		if ( empty( $file_name ) ) {
			return false;
		}
		if ( ! empty( $file_path ) && file_exists( $file_path ) ) {
			$file_info = wp_check_filetype_and_ext( $file_path, $file_name );
		} else {
			$file_info = wp_check_filetype( $file_name );
		}
		$allowed_mimes = wp_get_mime_types();
		if ( ! $file_info['ext'] || ! isset( $allowed_mimes[ $file_info['ext'] ] ) || strpos( $file_info['type'], 'image/' ) !== 0 ) {
			return false;
		}
		return true;
	}
}
