public function setUp()
 {
     parent::setUp();
     // Spoof is_admin() for fm_add_script().
     $this->screen = get_current_screen();
     set_current_screen('dashboard-user');
     // Re-init scripts. @see Tests_Dependencies_Scripts.
     $this->old_wp_scripts = isset($GLOBALS['wp_scripts']) ? $GLOBALS['wp_scripts'] : null;
     remove_action('wp_default_scripts', 'wp_default_scripts');
     $GLOBALS['wp_scripts'] = new WP_Scripts();
     $GLOBALS['wp_scripts']->default_version = get_bloginfo('version');
     // Some fields will only register a script once, so hack around that.
     Fieldmanager_Media::$has_registered_media = false;
     Fieldmanager_Colorpicker::$has_registered_statics = false;
     // Instantiate field classes that register scripts.
     new Fieldmanager_Autocomplete('Test', array('datasource' => new Fieldmanager_Datasource_Post()));
     new Fieldmanager_Datepicker('Test');
     new Fieldmanager_DraggablePost('Test');
     new Fieldmanager_Grid('Test');
     new Fieldmanager_Group('Test', array('tabbed' => 'horizontal'));
     new Fieldmanager_Media('Test');
     new Fieldmanager_Select('Test');
     new Fieldmanager_RichTextArea('Test');
     new Fieldmanager_Colorpicker('Test');
     do_action('wp_enqueue_scripts');
     do_action('admin_enqueue_scripts');
 }
 /**
  * Build the colorpicker object and enqueue assets.
  *
  * @param string $label
  * @param array $options
  */
 public function __construct($label = '', $options = array())
 {
     if (!self::$has_registered_statics) {
         add_action('admin_enqueue_scripts', function () {
             wp_enqueue_style('wp-color-picker');
         });
         fm_add_script('fm_colorpicker', 'js/fieldmanager-colorpicker.js', array('jquery', 'wp-color-picker'), '1.0', true);
         self::$has_registered_statics = true;
     }
     $this->sanitize = array($this, 'sanitize_hex_color');
     parent::__construct($label, $options);
 }
 /**
  * Build the colorpicker object and enqueue assets.
  *
  * @param string $label
  * @param array $options
  */
 public function __construct($label = '', $options = array())
 {
     if (!self::$has_registered_statics) {
         add_action('admin_enqueue_scripts', function () {
             wp_enqueue_style('wp-color-picker');
         });
         fm_add_script('fm_colorpicker', 'js/fieldmanager-colorpicker.js', array('jquery', 'wp-color-picker'), '1.0', true);
         self::$has_registered_statics = true;
     }
     $this->sanitize = array($this, 'sanitize_hex_color');
     parent::__construct($label, $options);
     // If we have a default_value and default_color was not explicitly set
     // to be empty, set default_color to default_value.
     if (!isset($this->default_color) && !empty($this->default_value)) {
         $this->default_color = $this->default_value;
     }
 }