<?php
/**
 * @version    $Id$
 * @package    IT_Theme_Framework
 * @author     InnoThemes Team <support@innothemes.com>
 * @copyright  Copyright (C) 2012 InnoThemes.com. All Rights Reserved.
 * @license    GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
 *
 * Websites: http://www.innothemes.com
 */

/**
 * Helper class providing methods for doing common action.
 *
 * @package  IT_Theme_Framework
 * @since    1.0.0
 */
class IT_Helper {
	/**
	 * Hook into WordPress.
	 *
	 * @return  void
	 */
	public static function hook() {
		// Register action to load assets
		static $registered;

		if ( ! isset( $registered ) ) {
			add_filter( 'wp_handle_upload_prefilter', 'wp_handle_upload_prefilter', 100 );

			$registered = true;
		}
	}

	/**
	 * Apply filter 'wp_handle_upload_prefilter'.
	 *
	 * @param   array  $file  Array containing uploaded file details.
	 *
	 * @return  string
	 */
	public static function wp_handle_upload_prefilter( $file ) {
		if ( $name = iconv( 'utf-8', 'ascii//TRANSLIT//IGNORE', $file['name'] ) ) {
			$file['name'] = $name;
		}

		return $file;
	}
}
