Fix: WooCommerce – Sorry, this file type is not permitted for security reasons.

Solution:

Add below filter to fix the file permission issue of WooCommerce.

The reason of this issue is:

Getting different REAL MIME type from function finfo_file.

The issue maybe the different Operating Systems or due to Different PHP versions.

But, While debugging the issue, When I try to upload the XML on localhost I got the text/xml as a real MIME type and on live site its application/xml.

Below is the debugging steps:

File: /wp-includes/functions.php line 2346

// Validate files that didn't get validated during previous checks.
if ( $type && ! $real_mime && extension_loaded( 'fileinfo' ) ) {
	$finfo = finfo_open( FILEINFO_MIME_TYPE );
	$real_mime = finfo_file( $finfo, $file );
	finfo_close( $finfo );

	// @DEBUGGING...
	echo '<pre>';
	var_dump( FILEINFO_MIME_TYPE ) . '<br/>';
	var_dump( $finfo ) . '<br/>';
	var_dump( $file ) . '<br/>';
	var_dump( $real_mime ) . '<br/>';
	wp_die();

The output of the above code is below on LOCALHOST:

  • PHP: Version 7.2.4
  • System: Windows NT M 6.3 build 9600 (Windows 8.1 Professional Edition) i586
int(16)
resource(767) of type (Unknown)
string(46) "C:\Users\Yum\AppData\Local\Temp/wxr-LccAYF.tmp"
string(8) "text/xml"

But, It is different on the LIVE site.

  • PHP: Version 7.0.32-4+ubuntu16.04.1+deb.sury.org+1
  • System: Linux ip-172-31-25-204 4.4.0-134-generic #160-Ubuntu SMP Wed Aug 15 14:58:00 UTC 2018 x86_64
int(16)
resource(747) of type (Unknown)
string(19) "/tmp/wxr-YNkiH5.tmp"
string(15) "application/xml"

Testing on different PHP versions:

PHP Code

echo 'PHP Version: ' . phpversion() . "<br/><br/>";
echo 'file.vtt | ' . mime_content_type( 'file.vtt') . "<br/>";
echo 'file.xml | ' . mime_content_type( 'file.xml') . "<br/>";

On Localhost – PHP Version: 7.2.4

PHP Version: 7.2.4
file.vtt | text/plain
file.xml | text/xml

On Live – PHP Version: 7.0.32

PHP Version: 7.0.32-4+ubuntu16.04.1+deb.sury.org+1
file.vtt | text/plain
file.xml | application/xml
Advertisements

Finally plugin Sample Data approved!

You can now download the Theme Unit Test for testing your theme or import the WooCommercebbPress plugin sample data with simple ONE click using WordPress plugin Sample Data.

Note: Use Sample Data plugin on your testing/staging environment.

Quick Start:

Follow below simple steps to import the dummy content:

  • Install & Activate plugin.
  • Click on Get Started » from plugin/theme. It read the file and get import content.
  • Click on Start Import and confirm to import the data.
  • For more details check below screenshots or youtube video.

Screenshots:

screenshot-1
Step 1: Install & Activate plugin

screenshot-2
Step 2: Click on `Get Started`

screenshot-3
Step 3: It get the content from file

screenshot-4
Step 4: Click on `Start Import`

screenshot-5
Step 5: Click `Ok` to confirm import

screenshot-6
Step 6: Import Started!

screenshot-7
Step 7: Import Completed!

screenshot-8
Step 8: Imported Contents.

Plugin import the data form the XML file. For now plugin added in-build support for:

  • Theme Unit Test Data
  • WooCommerce
  • bbPress

Do you want another plugin support? Request for support »

Do you know coding? Let’s fork & extend it from Github.

You can download it from wp.orgVisit plugin page Sample Data.

Importing WooCommerce Dummy Data – ( XML )

1) Quick Import:

I have created a simple plugin which imports the WooCommerce dummy data on your site within a few minutes. Check below video:

The plugin will approve on wp.org in this week. For now, you can download it from Github repo Sample Data.

Click on the download plugin to download.


2) Manual Download

you can use below XML files to import dummy content of the WooCommerce.

As of version 1.5.3, the plugin comes bundled with dummy data that can be imported to instantly give you a working store with products to test different WooCommerce features.

Below is the list of all (XML) files for download.

version 3.3.3 – download
version 3.3.2-rc.1 – download
version 3.3.2 – download
version 3.3.1 – download
version 3.3.0 – download
version 3.2.6 – download
version 3.2.5 – download
version 3.2.4 – download
version 3.2.3 – download
version 3.2.2 – download
version 3.2.1 – download
version 3.2.0 – download
version 3.1.2 – download
version 3.1.1 – download
version 3.1.0 – download
version 3.0.9 – download
version 3.0.8 – download
version 3.0.7 – download
version 3.0.6 – download
version 3.0.5 – download
version 3.0.4 – download
version 3.0.3 – download
version 3.0.2 – download
version 3.0.1 – download
version 3.0.0 – download
version 2.6.9 – download
version 2.6.8 – download
version 2.6.7 – download
version 2.6.6 – download
version 2.6.5 – download
version 2.6.4 – download
version 2.6.3 – download
version 2.6.2 – download
version 2.6.14 – download
version 2.6.13 – download
version 2.6.12 – download
version 2.6.11 – download
version 2.6.10 – download
version 2.6.1 – download
version 2.6.0 – download
version 2.5.5 – download
version 2.5.4 – download
version 2.5.3 – download
version 2.5.2 – download
version 2.5.1 – download
version 2.5.0 – download
version 2.4.9 – download
version 2.4.8 – download
version 2.4.7 – download
version 2.4.6 – download
version 2.4.5 – download
version 2.4.4 – download
version 2.4.3 – download
version 2.4.2 – download
version 2.4.13 – download
version 2.4.12 – download
version 2.4.11 – download
version 2.4.10 – download
version 2.4.1 – download
version 2.4.0 – download
version 2.3.9 – download
version 2.3.8 – download
version 2.3.7 – download
version 2.3.6 – download
version 2.3.5 – download
version 2.3.4 – download
version 2.3.3 – download
version 2.3.2 – download
version 2.3.13 – download
version 2.3.12 – download
version 2.3.11 – download
version 2.3.10 – download
version 2.3.1 – download
version 2.3.0 – download
version 2.2.9 – download
version 2.2.8 – download
version 2.2.7 – download
version 2.2.6 – download
version 2.2.5 – download
version 2.2.4 – download
version 2.2.3 – download
version 2.2.2 – download
version 2.2.11 – download
version 2.2.10 – download
version 2.2.1 – download
version 2.2.0 – download
version 2.1.9 – download
version 2.1.8 – download
version 2.1.7 – download
version 2.1.6 – download
version 2.1.5 – download
version 2.1.4 – download
version 2.1.3 – download
version 2.1.2 – download
version 2.1.12 – download
version 2.1.11 – download
version 2.1.10 – download
version 2.1.1 – download
version 2.1.0 – download
version 2.0.20 – download
version 1.6.6 – download

After download goto Importing WooCommerce Dummy Data.