/**
  * Add a context to a fieldmanager
  * @param string $title
  * @param string|string[] $post_types
  * @param callback $column_not_empty_callback
  * @param callback $column_empty_callback
  * @param Fieldmanager_Field $fm
  */
 public function __construct($title, $post_types, $column_display_callback, $column_title = '', $fm = Null)
 {
     if (!fm_match_context('quickedit')) {
         return;
     }
     // make sure we only load up our JS if we're in a quickedit form.
     if (FM_DEBUG && !is_callable($column_display_callback)) {
         throw new FM_Developer_Exception(esc_html__('You must set a valid column display callback.', 'fieldmanager'));
     }
     // Populate the list of post types for which to add this meta box with the given settings
     if (!is_array($post_types)) {
         $post_types = array($post_types);
     }
     $this->post_types = $post_types;
     $this->title = $title;
     $this->column_title = !empty($column_title) ? $column_title : $title;
     $this->column_display_callback = $column_display_callback;
     $this->fm = $fm;
     if (is_callable($column_display_callback)) {
         foreach ($post_types as $post_type) {
             add_action('manage_' . $post_type . '_posts_columns', array($this, 'add_custom_columns'));
         }
         add_action('manage_posts_custom_column', array($this, 'manage_custom_columns'), 10, 2);
     }
     add_action('quick_edit_custom_box', array($this, 'add_quickedit_box'), 10, 2);
     add_action('save_post', array($this, 'save_fields_for_quickedit'));
     add_action('wp_ajax_fm_quickedit_render', array($this, 'render_ajax_form'), 10, 2);
     $post_type = !isset($_GET['post_type']) ? 'post' : sanitize_text_field($_GET['post_type']);
     if (in_array($post_type, $this->post_types)) {
         fm_add_script('quickedit-js', 'js/fieldmanager-quickedit.js');
     }
 }
 /**
  * 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');
 }
 /**
  * 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 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;
 }
 /**
  * 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);
 }
 /**
  * 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');
     }
 }
 /**
  * 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);
 }