1

私はそのような機能を持っています:

     function textarea(array $attributes){

         if(isset($attributes['name'])){
             $this->name = 'name="'.$attributes['name'].'"';
         }

         if(isset($attributes['id'])){
             $this->id = 'id="'.$attributes['id'].'"';
         }

         if(isset($attributes['class'])){
             $this->class = 'class="'.$attributes['class'].'"';
         }else{
             $this->class = 'class="aisisTextElement"';
         }

         if(isset($attributes['rows'])){
             $this->rows = 'rows="'.$attributes['rows'].'"';
         }

         if(isset($attributes['cols'])){
             $this->cols = 'cols="'.$attributes['cols'].'"';
         }

         if(isset($attributes['value'])){
             $this->value = $attributes['value'];
         }

         if(isset($attributes['style'])){
             $this->style = 'style="'.$attributes['style'].'"';
         }

         $build_aisis_element = "<textarea {$this->id} {$this->class} {$this->name} {$this->disabled}>{$this->value}</textarea>";                   
         echo $build_aisis_element;
     }

そして、それをレンダリングするたびに、たとえば、値がBob Illの場合、次のようになります。

bob
<textarea></textarea>

何かご意見は?

私はすべてのJavaScriptを有効にしているので、100%の精度でこれを行うのはjsではないと言えます。

要求に応じて.....

テキスト領域が作成される場所

function aisis_custom_text(){
    $option = get_option('aisis_core');
    $aisis_form = new AisisForm();

    $aisis_form->create_aisis_form_element('label', array('value'=>'Remove the Mini   Feed(s) from the site?'));
    $aisis_form->create_aisis_form_element('textarea', array(
        'rows'=>50,
        'cols'=>50,
        'name'=>'aisis_core[404_message]',
        'value'=>get_value('404_message')
    ));
}

その値は、WordPressのオプションテーブルを通過してそのキーを探すメソッドを介して取得されます。つまり、testと入力すると、テキストの値がtestになります。

基本的に、テストが入力されると、テストが返され、テキスト領域にテストが入力されます

これがレンダリングするhtml:

    test<textarea class="aisisTextElement"name="aisis_core[404_message]"rows="50"cols="50"></textarea>
4

1 に答える 1

0

最も可能性の高い問題は、値にエスケープする必要のある文字が含まれていることです。

これは、次を使用して解決できます。

     if(isset($attributes['value'])){
         $this->value = htmlspecialchars($attributes['value']);
     }

htmlに出力し、html(タグ)を含まないはずのすべての文字列は、その方法でエスケープする必要があります。

于 2012-08-31T20:07:29.147 に答える