/**
  * 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');
 }
 /**
  * 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 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');
 }
 /**
  * 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);
         }
     };
 }
 /**
  * Override constructor to add chosen.js maybe
  * @param string $label
  * @param array $options
  */
 public function __construct($label = '', $options = array())
 {
     $this->attributes = array('size' => '1');
     // Add the Fieldmanager Select javascript library
     fm_add_script('fm_select_js', 'js/fieldmanager-select.js', array(), '1.0.1', false, 'fm_select', array('nonce' => wp_create_nonce('fm_search_terms_nonce')));
     parent::__construct($label, $options);
     // You can make a select field multi-select either by setting the attribute
     // or by setting `'multiple' => true`. If you opt for the latter, the
     // attribute will be set for you.
     if (array_key_exists('multiple', $this->attributes)) {
         $this->multiple = true;
     } elseif ($this->multiple) {
         $this->attributes['multiple'] = 'multiple';
     }
     // Add the chosen library for type-ahead capabilities
     if ($this->type_ahead) {
         fm_add_script('chosen', 'js/chosen/chosen.jquery.js');
         fm_add_style('chosen_css', 'js/chosen/chosen.css');
     }
 }
 /**
  * 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');
     }
 }