I have a simple code like so :
class o99_custom_fields {
/**
* @var string $prefix The prefix for storing custom fields in the postmeta table
*/
var $prefix = 'o99_';
/**
* @var array $customFields Defines the custom fields available
*/
var $customFields = array(
array(
"name" => "some_name",
"title" => "some Title",
"description" => "Some Desctiption Text",
"type" => "k_upload",
"scope" => array( "post" ),
"capability" => "edit_post"
),
array(
"name" => "some_name2",
"title" => "some Title",
"description" => "Some Desctiption Text",
"type" => "k_upload",
"scope" => array( "post" ),
"capability" => "edit_post"
),
array(
"name" => "some_name3",
"title" => "some Title",
"description" => "",
"type" => "k_textarea",
"scope" => array( "post" ),
"capability" => "edit_post"
),
);
... more functions and more code ...
} // End Class
And everything seems ok,
The problem begins when I am trying to change some array values , and put them inside Brackets ()
for example :
array(
"name" => "some_name",
"title" => __("some Title","text_domain"),// ERROR OCCUR
"description" => "Some Desctiption Text",
"type" => "k_upload",
"scope" => array( "post" ),
"capability" => "edit_post"
),
The Error message is :
Parse error: syntax error, unexpected '(', expecting ')' in E:\my_path\myfile.php on line 18
Note that it is not related to the function __() ( standard wordpress translation function ) and the error is not function related , but SYNTAX. ( I have used this function hundreds of times in the past , without any problems - and in this case , also _x() and _e() fail on the same syntax errors .. )
All my brackets are closed , I have checked and re checked , and Unless I am totally blind , I would say that it is ok , but I still getting this error , no matter where I put the brackets inside this class .
Another example : this will also fail with the same error :
class o99_custom_fields {
/**
* @var string $prefix The prefix for storing custom fields in the postmeta table
*/
var $prefix = 'o99_';
/**
* @var array $customFields Defines the custom fields available
*/
var $dummy_strings = array (
__('x1','text_domain'),
__('x2','text_domain'),
);
... more functions and more code ...
} // End Class
Again, the error appears to be SYNTAX related , even though all my brackets are closed .
I have also checked the file for proper php opening and closing tags , and even charset and encoding ( UTF-8 without BOM )
I have never encountered such a problem before - so any help / hint / insight would be greatly appreciated ..
EDIT I :
After those arrays, comes the constructors ..
/**
* PHP 4 Compatible Constructor
*/
function o99_custom_fields() { $this->__construct(); }
/**
* PHP 5 Constructor
*/
function __construct() {
add_action( 'admin_menu', array( &$this, 'createCustomFields' ) );
add_action( 'save_post', array( &$this, 'saveCustomFields' ) );
}