/** * Constructor. * * @param array $config Field declaration. * @param array $merge Array of property should be merged. * * @return void */ public function __construct($config, $merge = array('attributes', 'choices')) { // Get all post types $post_types = get_post_types(array('public' => true), 'objects'); // Prepare post types foreach ($post_types as $slug => $defines) { $post_types[$slug] = $defines->labels->name; } // Update choices $this->choices = $post_types; // Call parent method to do remaining initialization parent::__construct($config, $merge); // Prepare value if ('all' == $this->value) { $this->value = array_map('strlen', $this->choices); } }