[wp-hackers] register_post_type "variable array variable" callback

Vinicius Massuchetto viniciusandre at gmail.com
Sat Aug 28 16:57:37 UTC 2010


Hi!

If I do something like:

/* One file */
class custom_data {
	function custom_data () {}
	function register () {
		global $type, ${$type.'_register'};
		print_r(${$type.'_register'});
		register_post_type ($type, ${$type.'_register'}); // Error happens here
	}
}

/* Another file */
$type = 'something';
${$type.'_register'} = array ( ... );
$$type = new custom_data();
add_action ('init', array(&$$type, 'register'));

I get this error:
Catchable fatal error: Object of class custom_data could not be
converted to string in [path]/wp-includes/classes.php on line 277

On this line, If I stop forcing the string conversion (commented
section), things seems alright.
$this->query_vars[$wpvar] = /*(string)*/ $this->query_vars[$wpvar];

Is that a WordPress error? If not, what am I doing wrong?

Thanks!
-- 
Vinícius Massuchetto


More information about the wp-hackers mailing list