wp/lib/blobfolio/wp/bm/mime.php
public static function update_filename_extension($filename, $ext) {
		$ext = strtolower($ext);
		$ext = rtrim($ext, '.');
		$ext = ltrim($ext, '.');

		$filename_parts = explode('.', $filename);

		// Remove the old extension.
		if (count($filename_parts) > 1) {
			array_pop($filename_parts);
		}

		// Add the new extension.
		if (strlen($ext)) {
			$filename_parts[] = $ext;
		}

		return implode('.', $filename_parts);
	}
public static function update_filename_extension($filename, $ext) {
		$ext = strtolower($ext);
		$ext = rtrim($ext, '.');
		$ext = ltrim($ext, '.');

		$filename_parts = explode('.', $filename);

		// Remove the old extension.
		if (count($filename_parts) > 1) {
			array_pop($filename_parts);
		}

		// Add the new extension.
		if (strlen($ext)) {
			$filename_parts[] = $ext;
		}

		return implode('.', $filename_parts);
	}
Assign a new extension to a filename.

@param string $filename The original filename.
@param string $ext The new extension.
@return string The renamed file.