예제 #1
0
  public static function ui( MEOW_Field $field ) {

    // $field here is a MEOW_Field, which is a class that encapsulates the value of a field AND the info associated with it

    $options = $field->info->type_options;

    $readonly = WOOF_HTML::readonly_attr( !$field->is_editable() );

    $tabs_class = "";
    
    if ($readonly) {
      $tabs_class = " readonly";
    }
    
    $visual_current = "current";
    $html_current = "";

    $default_tab = self::option_value($options, "default_tab");

    if ($default_tab == "html" ) {
      $visual_current = "";
      $html_current = "current";
    }

    $style = "";

    if (isset($options["height"]) && is_numeric($options["height"])) {
      $style .= "height: ".$options["height"]."px;";
    }

    $value = "";
    
    if (!$field->blank()) {
      $value = htmlspecialchars($field->clean());
    }

    $html = <<<HTML

    <div id="wp-{{id}}-wrap" class="wp-content-wrap editor-ui">

    <ul class="editor-tabs $tabs_class">
      <li><div class="tab-button visual {$visual_current}">Visual</div></li>
      <li><div class="tab-button html {$html_current}">HTML</div></li>
    </ul>

    <textarea id="{{id}}" name="{{name}}" $readonly class="mce">{$value}</textarea>

    </div>

HTML;

    return $html;

  }