
/**
 * Convert any uploaded image file to WebP format for high-performance delivery
 *
 * @param string $file_path Absolute path to the uploaded image.
 * @return string Path to the converted WebP or original file if conversion failed.
 */
function beingbeginner_community_convert_to_webp( $file_path ) {
	if ( ! file_exists( $file_path ) ) {
		return $file_path;
	}

	$editor = wp_get_image_editor( $file_path );
	if ( ! is_wp_error( $editor ) ) {
		$path_info = pathinfo( $file_path );
		$webp_path = $path_info['dirname'] . '/' . $path_info['filename'] . '.webp';
		$saved     = $editor->save( $webp_path, 'image/webp' );
		if ( ! is_wp_error( $saved ) && ! empty( $saved['path'] ) && file_exists( $saved['path'] ) ) {
			if ( strtolower( $path_info['extension'] ?? '' ) !== 'webp' ) {
				@unlink( $file_path );
			}
			return $saved['path'];
		}
	}
	return $file_path;
}

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://beingbeginner.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://beingbeginner.com/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://beingbeginner.com/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://beingbeginner.com/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://beingbeginner.com/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
