operator not supported for strings slider_markup_init.php [SOLVED]

This error comes from an older version of the   WordPress LayerSlider plugin after an upgrade to PHP 7.

In case you are unable to upgrade your LayerSlider plugin, or do not wish to,  here is a patch to fix the issue. Don’t worry it’s pretty easy.  : )

How to resolve error: operator not supported for strings slider_markup_init.php

Locate the file. Your particular error will tell you where the file is located. The file is usually located in the following directory:

/wp-content/plugins/LayerSlider/includes/slider_markup_init.php       
The line number is likely line 84.

 

This error results from using the short array push syntax on a string.

//... The following causes error in PHP 7 ...
// Fix multiple jQuery issue
$data[] = '<script data-cfasync="false" type="text/javascript">';
$data[] = 'var lsjQuery = jQuery;';
$data[] = '</script>'

How to fix the PHP 7 ERROR in slider_markup_init.php

// Patch for PHP 7 Upgrade in slider_markup_init.php
if (!is_array($data)) {
    $data = array();
}

// Fix multiple jQuery issue
$data[] = '<script data-cfasync="false" type="text/javascript">';
$data[] = 'var lsjQuery = jQuery;';
$data[] = '</script>'

 

3 thoughts on “operator not supported for strings slider_markup_init.php [SOLVED]

Leave a Reply

Your email address will not be published. Required fields are marked *