I"m getting an unexpected T_FUNCTION php error after uploading my Wordpress files to a server running php version 5.2.17.
The theme works fine on localhost (with MAMP) and there are also no errors on my own server which runs php version 5.3.10.
What can be wrong or what can be done to solve this error?
This is the line that causes the error:
add_action('init', function() use($name, $args) {
And the entire functions.php file looks like this:
<?php
/* Add Post Type */
function add_post_type($name, $args = array() ) {
if ( !isset($name) ) return;
$name = strtolower(str_replace(' ', '_', $name));
add_action('init', function() use($name, $args) {
$args = array_merge(
array(
'label' => 'Members ' . ucwords($name) . '',
'labels' => array('add_new_item' => "Add New $name"),
'singular_name' => $name,
'public' => true,
'supports' => array('title', 'editor', 'comments'),
),
$args
);
register_post_type( $name, $args);
});
}
add_post_type('Netherlands', array(
'supports' => array('title', 'editor', 'thumbnail', 'comments')
));
add_post_type('Belgium', array(
'supports' => array('title', 'editor', 'thumbnail', 'comments')
));
add_post_type('Germany', array(
'supports' => array('title', 'editor', 'thumbnail', 'comments')
));
add_post_type('France', array(
'supports' => array('title', 'editor', 'thumbnail', 'comments')
));
add_post_type('United-Kingdom', array(
'supports' => array('title', 'editor', 'thumbnail', 'comments')
));
add_post_type('Ireland', array(
'supports' => array('title', 'editor', 'thumbnail', 'comments')
));
add_post_type('Spain', array(
'supports' => array('title', 'editor', 'thumbnail', 'comments')
));
add_post_type('Portugal', array(
'supports' => array('title', 'editor', 'thumbnail', 'comments')
));
add_post_type('Italy', array(
'supports' => array('title', 'editor', 'thumbnail', 'comments')
));
I'm really new to php and only use it for Wordpress theming. Any help is really appreciated.