0

I downloaded this theme from themeforest : https://themeforest.net/item/hata-real-estate/16828651

There are couple of plugins I need to install with this theme in order to load demo content and make it work.

One of the plugin is called "HATA Plugin". When I try to activate it, it gives me this error.

Parse error: syntax error, unexpected '[' in /home/content/99/10169899/html/chaitanya/wp-content/plugins/pixar-hata/includes/shortcodes.php on line 22

This is the line 22 :

  $output .= ( !empty( $photo ) ? '<figure><img src="'.esc_url( wp_get_attachment_image_src( $photo, 'full' )[0] ).'" alt="'.esc_attr( $name ).'" class="img-responsive"></figure>' : '' );
krtek
  • 26,334
  • 5
  • 56
  • 84

1 Answers1

2

The syntax where you can use an array accessor (ie []) directly on the function return value without using an intermediary variable is new to PHP 5.4 (see http://php.net/manual/en/migration54.new-features.php).

I imagine you are hosting the website on an older PHP version.

If this is the case, you can modify the code as such :

$src = wp_get_attachment_image_src( $photo, 'full' );
$output .= ( !empty( $photo ) ? '<figure><img src="'.esc_url( $src[0] ).'" alt="'.esc_attr( $name ).'" class="img-responsive"></figure>' : '' );

By the way, if I am correct about your PHP version, I strongly recommend you to upgrade to at least PHP 5.6 because you will run in such issues more and more as people upgrade their plugins. Also, all previous PHP version are end of life and doesn't receive security fixes anymore. See http://php.net/supported-versions.php.

krtek
  • 26,334
  • 5
  • 56
  • 84