Пример #1
0
 /**
  * Enqueue Required Assets
  */
 public function enqueue($hook)
 {
     if (parent::enqueue($hook)) {
         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
         wp_enqueue_media();
         wp_enqueue_script('youxi-file-uploader', self::field_assets_url("js/youxi.form.upload{$suffix}.js"), array('youxi-form-manager', 'jquery-ui-sortable', 'media-views'), YOUXI_CORE_VERSION, true);
     }
 }
Пример #2
0
 /**
  * Apply form item attributes filtering
  * 
  * @param array The current attributes of the field
  *
  * @return array The filtered attributes of the field
  */
 public function filter_field_attr($attr)
 {
     if (isset($attr['class'])) {
         $attr['class'] = Youxi_Form::normalize_class('youxi-icon-chooser-select', $attr['class']);
     } else {
         $attr['class'] = Youxi_Form::normalize_class('youxi-icon-chooser-select');
     }
     return parent::filter_field_attr($attr);
 }
Пример #3
0
 /**
  * Apply form item attributes filtering
  * 
  * @param array The current attributes of the field
  *
  * @return array The filtered attributes of the field
  */
 public function filter_field_attr($attr)
 {
     if (isset($attr['class'])) {
         $attr['class'] = Youxi_Form::normalize_class('youxi-ui-slider', $attr['class']);
     } else {
         $attr['class'] = Youxi_Form::normalize_class('youxi-ui-slider');
     }
     return parent::filter_field_attr($attr);
 }
Пример #4
0
 /**
  * Apply form item attributes filtering
  * 
  * @param array The current attributes of the field
  *
  * @return array The filtered attributes of the field
  */
 public function filter_field_attr($attr)
 {
     if (isset($attr['class'])) {
         $attr['class'] = Youxi_Form::normalize_class('youxi-code-editor-textarea', $attr['class']);
     } else {
         $attr['class'] = Youxi_Form::normalize_class('youxi-code-editor-textarea');
     }
     return parent::filter_field_attr($attr);
 }
Пример #5
0
 /**
  * Apply form item attributes filtering
  * 
  * @param array The current attributes of the field
  *
  * @return array The filtered attributes of the field
  */
 public function filter_field_attr($attr)
 {
     $attr['multiple'] = true;
     if (isset($attr['class'])) {
         $attr['class'] = Youxi_Form::normalize_class('youxi-multiselect', $attr['class']);
     } else {
         $attr['class'] = Youxi_Form::normalize_class('youxi-multiselect');
     }
     return parent::filter_field_attr($attr);
 }
Пример #6
0
 /**
  * Enqueue Required Assets
  */
 public function enqueue($hook)
 {
     if (parent::enqueue($hook)) {
         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
         wp_enqueue_script('youxi-tabular-input', self::field_assets_url("js/youxi.form.tabular{$suffix}.js"), array('jquery-ui-widget', 'media-models', 'youxi-form-manager'), YOUXI_CORE_VERSION, true);
         wp_enqueue_style('youxi-tabular-input', self::field_assets_url("css/youxi.form.tabular{$suffix}.css"), array('youxi-form'), YOUXI_CORE_VERSION);
         if (!self::$media_template_printed) {
             add_action('print_media_templates', array(get_class(), 'print_media_templates'));
         }
     }
 }
Пример #7
0
 /**
  * Apply form item attributes filtering
  * 
  * @param array The current attributes of the field
  *
  * @return array The filtered attributes of the field
  */
 public function filter_field_attr($attr)
 {
     $class = 'youxi-form-list';
     if ($this->get_option('inline')) {
         $class .= ' inline';
     }
     if (isset($attr['class'])) {
         $attr['class'] = Youxi_Form::normalize_class($class, $attr['class']);
     }
     return parent::filter_field_attr($attr);
 }
Пример #8
0
 /**
  * Apply form item attributes filtering
  * 
  * @param array The current attributes of the field
  *
  * @return array The filtered attributes of the field
  */
 public function filter_field_attr($attr)
 {
     $attr['maxlength'] = 7;
     $attr['data-hide'] = $this->get_option('hide');
     $attr['data-palette'] = $this->get_option('palette');
     $attr['data-default-color'] = $this->get_option('std');
     if (isset($attr['class'])) {
         $attr['class'] = Youxi_Form::normalize_class('youxi-wp-color-picker', $attr['class']);
     } else {
         $attr['class'] = Youxi_Form::normalize_class('youxi-wp-color-picker');
     }
     return parent::filter_field_attr($attr);
 }
Пример #9
0
 /**
  * Enqueue Required Assets
  */
 public function enqueue($hook)
 {
     if (parent::enqueue($hook)) {
         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
         wp_register_script('youxi-richtext', self::field_assets_url("js/youxi.form.richtext{$suffix}.js"), array('youxi-form-manager'), YOUXI_CORE_VERSION, true);
         wp_enqueue_script('youxi-richtext');
         if (is_admin()) {
             add_action('admin_print_footer_scripts', array($this, 'add_editor_settings'), 40);
         } else {
             add_action('wp_print_footer_scripts', array($this, 'add_editor_settings'), 40);
         }
     }
 }
Пример #10
0
 /**
  * Constructor
  */
 public function __construct($shortcode, $form_data)
 {
     $this->shortcode = $shortcode;
     $this->form_data = $form_data;
     $this->fields = array();
     /* Loop through the shortcode attributes generating field objects */
     foreach (array_merge($shortcode->atts, array('content' => $shortcode->content)) as $name => $atts) {
         $options = array_merge(compact('name'), (array) $atts);
         $field = Youxi_Form_Field::factory($shortcode->tag, $options);
         if (is_a($field, 'Youxi_Form_Field')) {
             $this->fields[] = $field;
         }
     }
 }
 /**
  * Enqueue Required Assets
  */
 public function enqueue($hook)
 {
     if (parent::enqueue($hook)) {
         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
         wp_enqueue_script('youxi-togglable-fieldsets', self::field_assets_url("js/youxi.form.togglable-fieldsets{$suffix}.js"), array('youxi-form-manager'), YOUXI_CORE_VERSION, true);
         wp_enqueue_style('youxi-togglable-fieldsets', self::field_assets_url("css/youxi.form.togglable-fieldsets{$suffix}.css"), array('youxi-form'), YOUXI_CORE_VERSION);
         wp_enqueue_script('switchery', self::field_assets_url("plugins/switchery/switchery{$suffix}.js"), array('jquery'), '0.6.3', true);
         wp_enqueue_style('switchery', self::field_assets_url("plugins/switchery/switchery{$suffix}.css"), array(), '0.6.3');
         foreach ((array) $this->get_option('fieldsets') as $fieldset) {
             if (!isset($fieldset['fields'])) {
                 continue;
             }
             foreach ($fieldset['fields'] as $name => $field) {
                 if (is_a($field, 'Youxi_Form_Field')) {
                     $field->enqueue($hook);
                 }
             }
         }
     }
 }
Пример #12
0
 /**
  * Helper method to generate the form object
  *
  * @param string The current metabox post type name
  *
  * @return Youxi_Form The generated form instance
  */
 public function get_form($post_type)
 {
     $metabox_id = "{$post_type}_{$this->id}";
     if (isset($this->form_cache[$metabox_id]) && is_a($this->form_cache[$metabox_id], 'Youxi_Form')) {
         return $this->form_cache[$metabox_id];
     }
     /* Instantiate the form fields */
     $fields = array();
     foreach ($this->fields as $id => $field) {
         $fields[$id] = Youxi_Form_Field::factory("{$post_type}[{$this->id}]", $field);
     }
     /* Generate the form */
     $form = new Youxi_Form($fields, array('form_tag' => 'div', 'form_attr' => array('class' => 'youxi-form youxi-form-inline'), 'before_fields' => wp_nonce_field("youxi_mb_{$metabox_id}", "{$metabox_id}_nonce", true, false), 'group_attr' => array('class' => array('youxi-form-row', 'youxi-form-block' => array('type' => array('checkbox', 'gallery')))), 'control_attr' => array('class' => 'youxi-form-item'), 'label_attr' => array('class' => 'youxi-form-label'), 'field_attr' => array('class' => array('youxi-form-large' => array('type' => array('text', 'textarea', 'code', 'url', 'select', 'iconchooser')))), 'fieldsets' => $this->fieldsets));
     /* Cache the form object */
     $this->form_cache[$metabox_id] = $form;
     return $form;
 }
Пример #13
0
 /**
  * Enqueue Required Assets
  */
 public function enqueue($hook)
 {
     if (parent::enqueue($hook)) {
         $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
         wp_enqueue_script('youxi-repeater', self::field_assets_url("js/youxi.form.repeater{$suffix}.js"), array('youxi-form-manager', 'jquery-ui-widget', 'media-models'), YOUXI_CORE_VERSION, true);
         wp_enqueue_style('youxi-repeater', self::field_assets_url("css/youxi.form.repeater{$suffix}.css"), array('youxi-form'), YOUXI_CORE_VERSION);
         wp_enqueue_style('dashicons');
         foreach ((array) $this->get_option('fields') as $field) {
             if (is_a($field, 'Youxi_Form_Field')) {
                 $field->enqueue($hook);
             }
         }
     }
 }
Пример #14
0
 /**
  * Apply form item attributes filtering
  * 
  * @param array The current attributes of the field
  *
  * @return array The filtered attributes of the field
  */
 public function filter_field_attr($attr)
 {
     $attr['rows'] = $this->get_option('rows');
     return parent::filter_field_attr($attr);
 }
Пример #15
0
 /**
  * Constructor
  */
 public function __construct($scope, $options, $allowed_hooks = array())
 {
     // Merge default options
     $this->default_options = array_merge($this->default_options, array('choices' => array()));
     parent::__construct($scope, $options, $allowed_hooks);
 }
Пример #16
0
 /**
  * Enqueue the shortcode related admin assets
  */
 public function admin_enqueue_scripts($hook)
 {
     /* 
     	No need to enqueue any asset if the current post type does not support 
     	wp_editor as there won't be anyway to edit the shortcode.
     */
     if (!post_type_supports(get_post_type(), 'editor')) {
         return;
     }
     $content = $this->content;
     $props = array_merge($this->atts, compact('content'));
     foreach ($props as $name => $prop) {
         if (is_array($prop)) {
             $prop['name'] = $name;
             Youxi_Form_Field::force_enqueue($this->tag, $prop, $hook);
         }
     }
 }
Пример #17
0
 /**
  * Parse a field's value, by default it loads the default if value is empty
  * 
  * @param mixed The value to parse
  *
  * @return mixed The parsed value
  */
 public function parse_value($value)
 {
     return (array) parent::parse_value($value);
 }