HEX
Server: Apache
System: Linux gains.arrowcloudlinux.com 4.18.0-553.69.1.lve.el8.x86_64 #1 SMP Wed Aug 13 19:53:59 UTC 2025 x86_64
User: mbkashyap (2642)
PHP: 8.1.33
Disabled: allow_url_include, show_source, symlink, system, passthru, exec, popen, pclose, proc_open, proc_terminate,proc_get_status, proc_close, proc_nice, allow_url_fopen, shell-exec, shell_exec, fpassthru, base64_encodem, escapeshellcmd, escapeshellarg, crack_check,crack_closedict, crack_getlastmessage, crack_opendict, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, dl, escap, phpinfo
Upload Files
File: /home/mbkashyap/public_html/wp-content/plugins/svg-support/integrations/wp-all-import.php
<?php
/**
 * Integration with WP All Import for processing SVG files.
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Hook into WP All Import to process SVG files correctly.
 *
 * @param int $attachment_id The ID of the uploaded attachment.
 */
function bodhi_svgs_wpallimport_handle_svg( $attachment_id ) {
	// Get the file path of the uploaded attachment.
	$file_path = get_attached_file( $attachment_id );
	$file_mime = get_post_mime_type( $attachment_id );

	// Check if the file is an SVG.
	if ( $file_mime === 'image/svg+xml' ) {
		// Sanitize the SVG file.
		if ( ! bodhi_svgs_sanitize_svg_on_import( $file_path ) ) {
			// Log the error without deleting the attachment.
			error_log( sprintf( 'SVG Sanitization failed for attachment ID %d during WP All Import.', $attachment_id ) );
		}

		// Generate attachment metadata for the SVG.
		$metadata = wp_generate_attachment_metadata( $attachment_id, $file_path );
		if ( ! empty( $metadata ) ) {
			if ( ! wp_update_attachment_metadata( $attachment_id, $metadata ) ) {
				error_log( sprintf( 'Failed to update metadata for SVG attachment ID %d during WP All Import.', $attachment_id ) );
			}
		} else {
			error_log( sprintf( 'Failed to generate metadata for SVG attachment ID %d during WP All Import.', $attachment_id ) );
		}
	}
}

/**
 * This function handles sanitization and any other processing needed for SVG files.
 *
 * @param string $file_path The file path of the SVG to be processed.
 * @return bool True if sanitization was successful, false otherwise.
 */
function bodhi_svgs_sanitize_svg_on_import( $file_path ) {
	// Check if the SVG file exists and is valid.
	if ( file_exists( $file_path ) && is_readable( $file_path ) ) {
		// Use the existing sanitize function.
		if ( bodhi_svgs_sanitize( $file_path ) ) {
			// Recalculate dimensions and regenerate metadata.
			$dimensions = bodhi_svgs_get_dimensions( $file_path );
			$metadata = array(
				'width'  => intval( $dimensions->width ),
				'height' => intval( $dimensions->height ),
				'file'   => basename( $file_path ),
			);
			return true;
		} else {
			error_log( sprintf( 'Sanitization failed for SVG file at path %s.', $file_path ) );
			return false;
		}
	}

	error_log( sprintf( 'SVG file at path %s is either missing or not readable.', $file_path ) );
	return false;
}

// Hook the function into WP All Import's `pmxi_attachment_uploaded`.
add_action( 'pmxi_attachment_uploaded', 'bodhi_svgs_wpallimport_handle_svg' );