I’m doing some work on a WordPress site built by someone else. They produced a custom plugin but are no longer with the company. The plugin loads on the live site but won’t load on the test server and therefore it’s very hard to work on the changes.

Loading the plugin on the test server gives the error:

Parse error: syntax error, unexpected '{', expecting ')' in wp-content/plugins/uni-todays-program/todays-program.php on line 221

Line 221 is:

 $query = new WP_Query( [

The surrounding code is:

// [today]
function today_func( $atts ) {
    // Retrieve current days schedule
    $today = getdate();
    $query = new WP_Query( [
      'post_type' => 'day_entry',
      'year' => $today["year"], 
      'monthnum' => $today["mon"], 
      'day' => $today["mday"] , 
      'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
    ]  );
    $day_type = $query->post->day_type;
    $query = new WP_Query( ['post_type' => 'day_type','name' => $day_type] );
    return $query->post->post_content;
}
add_shortcode( 'today', 'today_func' );

I’m just a frontend guy, so I my php is very limited but I can’t see the issue. There isn’t an opening ( that needs closing.

I did Google it and found something that suggested it was the php version but I’ve since had that changed so the live and test server are both 5.4.

Can anyone steer me in the right direction?

Read more here: WordPress plugin PHP Parse error: syntax error, unexpected ‘{‘, expecting ‘)’


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , , ,

Wordpress related questions and answers: