Fix: EventSource’s response has a charset (“iso-8859-1”) that is not UTF-8. Aborting the connection.

The issue is with the mismatch charset. You have default charset charset : iso-8859-1 and you are trying to use content which have charset=UTF-8.

To fix the error you need to set the charset=UTF-8 in which you have set the header. In my case, I have fix the error by setting the charset=UTF-8 in header. Check below code for reference:

header( 'Content-Type: text/event-stream, charset=UTF-8' );

I have created the PR for this fix for WordPress Importer created by



Setup WP CLI (WordPress Command Line Interface) on Windows Operating System

Step 1

Create folder wp-cli in C drive.

Step 2

Download wp-cli.phar from

Step 3

Move downloaded wp-cli.phar file in C:\wp-cli\

Step 4

Create wp.bat file in C:\wp-cli\ and write below code in it.

php "C:\wp-cli\wp-cli.phar" %*

Or download file from gist

Step 5

Open system environment and set C:\wp-cli as environment path.


Open Command Prompt and type command wp and press Enter. It’ll show you the like the below screenshot.

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


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 );

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

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
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
  • 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
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:
file.vtt | text/plain
file.xml | application/xml

WordPress 5.0.1 MIME validation for uploaded files fix for wp_handle_sideload()

Sorry, this file type is not permitted for security reasons due to WordPress 5.0.1 MIME validation for uploaded files fix for wp_handle_sideload()

If you have used function wp_handle_sideload() in any of your plugin/theme then you need to pass the mimes types too.

Because WordPress 5.0.1 Security Released. In which the uploaded files are validated with the real MIME type.

E.g. If you have set the application/xml MIME type though filter upload_mimes to upload the XML file and if the real MIME type of uploaded file is text/xml then the file was not uploaded. And it shows the below message.

Sorry, this file type is not permitted for security reasons.

To fix this you need to set the mimes for function wp_handle_sideload().

Check below code for reference.

For more details visit:

Using Alignment Package in Sublime Text 3

It is nice to see the code if it is aligned well. Check out below example of aligning and misaligned code.

Mis Aligned Code

$data = array(
    'one' => 'One',
    'two' => 'two',
    'three' => 'Three',
    'four' => 'Four',
    'five' => 'Five',

Aligned Code

$data = array(
    'one'   => 'One',
    'two'   => 'two',
    'three' => 'Three',
    'four'  => 'Four',
    'five'  => 'Five',

I’m using the Sublime Text 3 (Unregistered). IMO it is best for the development. It has a lot of awesome features.

In this article, I’m explaining the Alignment package (It is in TOP 25 today).

Alignment Git Repo –

How to Install Alignment Package?

Just follow below simple steps:

  1. Press Command+Shift+P to open Command Palette.
  2. Type Install Package until you see Package Control: Install Package.
  3. When the list of packages appears, type Alignment until you find it.
  4. Press Enter to install Sublime Alignment.

Check out below GIF for reference to know How to Install the alignment package.

Now, Open the preferences file for Sublime Alignment:

Windows: Preferences > Package Settings > Alignment > Settings-User
Linux: Preferences > Package Settings > Alignment > Settings-User
Mac OS X: Sublime Text 2 > Preferences > Package Settings > Alignment > Settings-User

    // The mid-line characters to align in a multi-line selection, changing
    // this to an empty array will disable mid-line alignment
    "alignment_chars": [
        "=", ":"

Here, We have added the = and : So, When you select the code which include the = or : then it aligns with these characters.

How to Use Alignment Package?

Select the lines you wish to align. Press Ctrl+Alt+A (Windows & Linux) or Command+Ctrl+A (Mac OS X)

Check out below example to align the code.


$data = array(
    'one' => 'One',
    'two' => 'two',
    'three' => 'Three',
    'four' => 'Four',
    'five' => 'Five',


$data = array(
    'one'   => 'One',
    'two'   => 'two',
    'three' => 'Three',
    'four'  => 'Four',
    'five'  => 'Five',

Check out the below GIF example for reference.

Keyboard shortcut/aliases for the WP CLI, Git, Grunt & PHPCS commands for windows

In development, We spend a lot of time on the command line. We type a lot of commands on regularly.

I have created a shortcut for the most of the commands which I use on a daily basis some of them are below:


Command Keyboard Shortcut/Aliases
wp theme list wpthl
wp plugin list wppll

Check all the available WP CLI commands etc. (all WP CLI commands list)

Example 1. Using shortcut wpthl instead of wp theme list

Example 2. Using shortcut wppll instead of wp plugin list

Some more commands with keyboard shortcuts/aliases are below:


Command Keyboard Shortcut/Aliases
grunt release grr
grunt minify grm


Command Keyboard Shortcut/Aliases
phpcs pb
phpcbf pbf


Command Keyboard Shortcut/Aliases
git add . gaa
git commit –message gcm
git checkout gco
git pull origin gpu
git push origin gpp
git status gs

To create keyboard shortcuts using aliases is very simple. We can create any command shortcut/aliases.

Follow below simple steps:

  1. Open the file .bashrc which is found in location  C:\Users\USERNAME\.bashrc and
  2. Add below sample commands of Git & Grunt.

I found the article Terminal/Bash Command-Line Shortcuts with Aliases written by @jonsuh to create keyboard shortcuts for the Terminal/Git Bash.

I have added some more commands of Grunt, WP CLI & PHPCS on my local environment.

Using absint() in WordPress

It convert a value to non-negative integer.

Internally this function used abs( intval( $maybeint ) ).

You can try below examples yourself.

Examples Output var_dump
absint( 0 ) 0 int(0)
absint( '0' ) 0 int(0)
absint( 1 ) 1 int(1)
absint( '8' ) 8 int(8)
absint( -27 ) 27 int(27)
absint( '-8' ) 8 int(8)
absint( 'abc' ) 0 int(0)
echo absint( 0 );
// Output: 0 
// var_dump() int(0)

echo absint( '0' );
// Output: 0 
// var_dump() int(0)

echo absint( 1 );
// Output: 1 
// var_dump() int(1)

echo absint( '8' );
// Output: 8 
// var_dump() int(8)

echo absint( -27 );
// Output: 27 
// var_dump() int(27)

echo absint( '-8' );
// Output: 8 
// var_dump() int(8)

echo absint( 'abc' );
// Output: 0 
// var_dump() int(0)