<?php

class Intense_Field_Widget_Type extends Intense_Field_Dropdown {
	private function set_default_options() {
		global $wp_roles;
     	$roles = $wp_roles->get_names();

		if ( empty( $this->args['options'] ) ) {
			$this->args['options'] = array();

			global $wp_widget_factory;

			foreach ( $wp_widget_factory->widgets as $key => $widget ) {
				$this->args['options'][ $key ] = $widget->name;
			}

			asort( $this->args['options'] );

			$this->args['options'] = array_merge(
				array(
				'' => __( 'Select', 'intense' ) . '...'
				), $this->args['options']);
		}
	}

	protected function render() {
		$this->set_default_options();

		return parent::render();
	}

	public function map_visual_composer() {
		$this->set_default_options();

		return parent::map_visual_composer();
	}
}
