__construct() public method

It might also die, but only helpfully, to catch errors in development.
public __construct ( string $label = '', array $options = [] )
$label string title of form field
$options array with keys matching vars of the field in use.
 /**
  * Construct default attributes; 50x10 textarea
  * @param string $label
  * @param array $options
  */
 public function __construct($label = '', $options = array())
 {
     $this->attributes = array('cols' => '50', 'rows' => '10');
     // Sanitize the textarea to preserve newlines. Could be overriden.
     $this->sanitize = 'fm_sanitize_textarea';
     parent::__construct($label, $options);
 }
 /**
  * Construct default attributes and enqueue javascript
  * @param array $options
  */
 public function __construct($label, $options = array())
 {
     wp_enqueue_script('jquery-ui-datepicker');
     fm_add_style('fm-jquery-ui', 'css/jquery-ui/jquery-ui-1.10.2.custom.min.css');
     fm_add_script('fm_datepicker', 'js/fieldmanager-datepicker.js');
     parent::__construct($label, $options);
     if (empty($this->js_opts)) {
         $this->js_opts = array('showButtonPanel' => True, 'showOtherMonths' => True, 'selectOtherMonths' => True, 'dateFormat' => 'd M yy');
     }
 }
 /**
  * Add CSS, construct parent
  * @param string $label
  * @param mixed $options
  */
 public function __construct($label = '', $options = array())
 {
     $this->sanitize = array($this, 'sanitize');
     parent::__construct($label, $options);
     if (!empty($this->options)) {
         $this->add_options($this->options);
     }
     // Add the options CSS
     fm_add_style('fm_options_css', 'css/fieldmanager-options.css');
 }
 /**
  * Add scripts and styles and other setup tasks.
  * @param string $label
  * @param array $options
  */
 public function __construct($label = '', $options = array())
 {
     parent::__construct($label, $options);
     // Refuse to allow more than one instance of this field type.
     $this->limit = 1;
     wp_enqueue_script('jquery-ui-draggable');
     wp_enqueue_script('jquery-ui-droppable');
     wp_enqueue_script('jquery-ui-sortable');
     fm_add_script('fm_draggablepost_js', 'js/fieldmanager-draggablepost.js');
     fm_add_style('fm_draggablepost_css', 'css/fieldmanager-draggablepost.css');
 }
 /**
  * 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);
 }
 /**
  * Construct default attributes
  * @param string $label
  * @param array $options
  */
 public function __construct($label = '', $options = array())
 {
     $this->button_label = __('Attach a File', 'fieldmanager');
     $this->modal_button_label = __('Select Attachment', 'fieldmanager');
     $this->modal_title = __('Choose an Attachment', 'fieldmanager');
     add_action('admin_print_scripts', array($this, 'admin_print_scripts'));
     if (!self::$has_registered_media) {
         fm_add_script('fm_media', 'js/media/fieldmanager-media.js', array('jquery'), '1.0.4');
         self::$has_registered_media = true;
     }
     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;
     }
 }
 /**
  * Constructor which adds several scrips and CSS
  * @param string $label
  * @param array $options
  */
 public function __construct($label = '', $options = array())
 {
     $this->attributes = array('size' => '50');
     parent::__construct($label, $options);
     $this->sanitize = function ($row, $col, $values) {
         foreach ($values as $k => $val) {
             $values[$k] = sanitize_text_field($val);
         }
         return $values;
     };
     fm_add_script('handsontable', 'js/grid/jquery.handsontable.js');
     fm_add_script('contextmenu', 'js/grid/lib/jQuery-contextMenu/jquery.contextMenu.js');
     fm_add_script('ui_position', 'js/grid/lib/jQuery-contextMenu/jquery.ui.position.js');
     fm_add_script('grid', 'js/grid.js');
     fm_add_style('context_menu_css', 'js/grid/lib/jQuery-contextMenu/jquery.contextMenu.css');
     fm_add_style('handsontable_css', 'js/grid/jquery.handsontable.css');
 }
 /**
  * Add CSS, construct parent
  * @param string $label
  * @param mixed $options
  */
 public function __construct($label = '', $options = array())
 {
     parent::__construct($label, $options);
     if (!empty($this->options)) {
         $this->add_options($this->options);
     }
     // Add the options CSS
     fm_add_style('fm_options_css', 'css/fieldmanager-options.css');
     // Sanitization
     $this->sanitize = function ($value) {
         if (isset($value) && is_array($value) && !empty($value)) {
             return array_map('sanitize_text_field', $value);
         } else {
             return sanitize_text_field($value);
         }
     };
 }
 /**
  * Add libraries for autocomplete
  * @param string $label
  * @param array $options
  */
 public function __construct($label = '', $options = array())
 {
     $this->attributes = array('size' => '50');
     parent::__construct($label, $options);
     // Enqueue required scripts in the proper context
     add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
     add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
     fm_add_script('fm_autocomplete_js', 'js/fieldmanager-autocomplete.js', array('fieldmanager_script'), '1.0.5', false, 'fm_search', array('nonce' => wp_create_nonce('fm_search_nonce')));
     if (empty($this->datasource)) {
         $message = esc_html__('You must supply a datasource for the autocomplete field', 'fieldmanager');
         if (Fieldmanager_Field::$debug) {
             throw new FM_Developer_Exception($message);
         } else {
             wp_die($message, esc_html__('No Datasource', 'fieldmanager'));
         }
     }
     $this->datasource->allow_optgroups = False;
 }
 public function __construct($label = '', $options = array())
 {
     $this->template = FMZ_PATH . '/templates/field.php';
     $this->multiple = true;
     $this->sanitize = 'absint';
     parent::__construct($label, $options);
     // Hook after the field has been fully constructed, which is on `init`.
     add_action('wp_loaded', array($this, 'hook_ajax_action'));
     // Only enqueue assets once per request
     if (!self::$assets_enqueued) {
         self::$assets_enqueued = true;
         if (did_action('admin_enqueue_scripts')) {
             $this->assets();
         } else {
             add_action('admin_enqueue_scripts', array($this, 'assets'));
         }
     }
 }
 /**
  * Construct default attributes
  * @param string $label
  * @param array $options
  */
 public function __construct($label, $options = array())
 {
     $this->button_label = __('Attach a File', 'fieldmanager');
     $this->modal_button_label = __('Select Attachment', 'fieldmanager');
     $this->modal_title = __('Choose an Attachment', 'fieldmanager');
     add_action('admin_print_scripts', function () {
         $post = get_post();
         $args = array();
         if (isset($post) && $post->ID) {
             $args['post'] = $post->ID;
         }
         wp_enqueue_media($args);
         // generally on post pages this will not have an impact.
     });
     if (!self::$has_registered_media) {
         fm_add_script('fm_media', 'js/media/fieldmanager-media.js', array('jquery'), '1.0.1');
         self::$has_registered_media = True;
     }
     parent::__construct($label, $options);
 }
 /**
  * Constructor; add CSS if we're looking at a tabbed view
  */
 public function __construct($label = '', $options = array())
 {
     parent::__construct($label, $options);
     // Repeatable groups cannot used unserialized data
     $is_repeatable = 1 != $this->limit;
     if (!$this->serialize_data && $is_repeatable) {
         throw new FM_Developer_Exception(esc_html__('You cannot use `"serialize_data" => false` with repeating groups', 'fieldmanager'));
     }
     // If this is collapsed, collapsibility is implied
     if ($this->collapsed) {
         $this->collapsible = True;
     }
     // Convenient naming of child elements via their keys
     foreach ($this->children as $name => $element) {
         // if the array key is not an int, and the name attr is set, and they don't match, we got a problem.
         if ($element->name && !is_int($name) && $element->name != $name) {
             throw new FM_Developer_Exception(esc_html__('Group child name conflict: ', 'fieldmanager') . $name . ' / ' . $element->name);
         } elseif (!$element->name) {
             $element->name = $name;
         }
         // Catch errors when using serialize_data => false and index => true
         if (!$this->serialize_data && $element->index) {
             throw new FM_Developer_Exception(esc_html__('You cannot use `serialize_data => false` with `index => true`', 'fieldmanager'));
         }
         // A post can only have one parent, so if this saves to post_parent and
         // it's repeatable, we're doing it wrong.
         if ($element->datasource && !empty($element->datasource->save_to_post_parent) && $this->is_repeatable()) {
             _doing_it_wrong('Fieldmanager_Datasource_Post::$save_to_post_parent', __('A post can only have one parent, therefore you cannot store to post_parent in repeatable fields.', 'fieldmanager'), '1.0.0');
             $element->datasource->save_to_post_parent = false;
             $element->datasource->only_save_to_post_parent = false;
         }
         // Flag this group as having unserialized descendants to check invalid use of repeatables
         if (!$this->has_unserialized_descendants && (!$element->serialize_data || $element->is_group() && $element->has_unserialized_descendants)) {
             $this->has_unserialized_descendants = true;
         }
         // Form a child-parent bond
         $element->parent = $this;
     }
     // Check for invalid usage of repeatables and serialize_data
     if ($is_repeatable && $this->has_unserialized_descendants) {
         throw new FM_Developer_Exception(esc_html__('You cannot use `serialize_data => false` with repeating groups', 'fieldmanager'));
     }
     // Add the tab JS and CSS if it is needed
     if ($this->tabbed) {
         fm_add_script('jquery-hoverintent', 'js/jquery.hoverIntent.js', array('jquery'), '1.8.1');
         fm_add_script('fm_group_tabs_js', 'js/fieldmanager-group-tabs.js', array('jquery', 'jquery-hoverintent'), '1.0.4');
         fm_add_style('fm_group_tabs_css', 'css/fieldmanager-group-tabs.css', array(), '1.0.5');
     }
 }
 /**
  * Override constructor to set default size.
  * @param string $label
  * @param array $options
  */
 public function __construct($label = '', $options = array())
 {
     $this->attributes = array('size' => '50');
     parent::__construct($label, $options);
 }
 /**
  * Construct defaults for this field.
  *
  * @param string $label title of form field
  * @param array $options with keys matching vars of the field in use.
  */
 public function __construct($label = '', $options = array())
 {
     $this->sanitize = array($this, 'sanitize');
     fm_add_script('fm_richtext', 'js/richtext.js', array('jquery', 'fieldmanager_script'), '1.0.8');
     parent::__construct($label, $options);
 }
 /**
  * Construct default attributes
  *
  * @param string $label
  * @param array  $options
  */
 public function __construct($label, $options = array())
 {
     $this->plugin_dir = FM_GALLERY_PATH;
     $this->plugin_url = FM_GALLERY_URL;
     if (!empty($options['collection'])) {
         $this->button_label = __('Attach Gallery', 'fieldmanager');
         $this->modal_button_label = __('Select Attachments', 'fieldmanager');
         $this->modal_title = __('Choose Attachments', 'fieldmanager');
     } else {
         $this->button_label = __('Attach a File', 'fieldmanager');
         $this->modal_button_label = __('Select Attachment', 'fieldmanager');
         $this->modal_title = __('Choose an Attachment', 'fieldmanager');
     }
     add_action('admin_print_scripts', function () {
         $post = get_post();
         $args = array();
         if (isset($post) && $post->ID) {
             $args['post'] = $post->ID;
         }
         wp_enqueue_media($args);
         // generally on post pages this will not have an impact.
     });
     if (!self::$has_registered_gallery) {
         add_action('admin_enqueue_scripts', function () {
             wp_enqueue_style('fm_gallery', $this->plugin_url . 'css/fieldmanager-gallery.css', array());
             wp_enqueue_script('fm_gallery', $this->plugin_url . 'js/fieldmanager-gallery.js', array('jquery'));
             wp_localize_script('fm_gallery', 'fm_gallery', array('uploaded_file' => __('Uploaded file', 'fieldmanager'), 'remove' => __('remove', 'fieldmanager'), 'create_gallery' => __('Create Gallery', 'fieldmanager')));
             self::$has_registered_gallery = true;
         });
     }
     parent::__construct($label, $options);
 }