Ejemplo n.º 1
0
 /**
  * Create a new attachment UI component.
  * 
  * @param array $model
  * <ul>
  * <li><b>name</b> <i>string</i> The component's name.</li>
  * <li><b>default</b> <i>string</i> Comma seperated list of values that will be checked by default.</li>
  * <li><b>disabled</b> <i>boolean</i> True to disabled component. False otherwise.</li>
  * <li><b>multi</b> <i>boolean</i> True to allow multiple attachments.</li>
  * <li><b>uploader_title</b> <i>string</i> The media uploader popup title.</li>
  * <li><b>uploader_button_text</b> <i>string</i> The media uploader button text.</li>
  * </ul>
  * 
  * <b>Usage Example:</b>
  * <pre>
  * $field = new Checkbox(array(
  *        'name'          => 'my_checkbox',
  *        'disabled'      => false,
  *        'default'       => 'val1',
  *        'multi'         => false,
  *        'uploader_title' => 'Insert Media',
  *        'uploader_button_text' => 'Insert'
  * ));
  * </pre>
  */
 public function __construct(array $model)
 {
     parent::__construct($model);
     add_action('admin_enqueue_scripts', function () {
         wp_enqueue_media();
     });
 }
Ejemplo n.º 2
0
 public function __construct($model)
 {
     parent::__construct($model);
     $callable = $this->model['callback'];
     if (is_callable($callable) && isset($_POST[$this->name])) {
         add_action($this->model['hook'], $callable, 4);
     }
 }
Ejemplo n.º 3
0
 public function __construct(array $model)
 {
     parent::__construct($model);
     $callable = $this->model['callout'];
     if (is_callable($callable)) {
         $callable();
     }
 }
Ejemplo n.º 4
0
 public function __construct($model)
 {
     parent::__construct($model);
     if (null != $this->file) {
         if (!file_exists($this->file)) {
             throw new \RuntimeException("The file {$this->file} could not be found");
         }
         // Overwrite the default value with the file contents
         $this->default = \file_get_contents($this->file);
         // Update file on save
         if (isset($_POST[$this->name]) && !$this->is_disabled()) {
             // NOTE: this is the content before the filter is applied! Will need to fix that.
             file_put_contents($this->file, filter_input(INPUT_POST, $this->name));
         }
     }
 }
Ejemplo n.º 5
0
 public function __construct(array $model)
 {
     parent::__construct($model);
     $this->pre_process();
 }
Ejemplo n.º 6
0
 /**
  * Update the component's value and the final instance with the
  * given value.
  * 
  * @param UI\AbstractComponent $component
  * @param string $value
  */
 private function update_value($component, $value)
 {
     $component->set_value($value);
     $this->final_instance[$component->get_name()] = $value;
 }