Skip to content
bainternet edited this page Jun 15, 2012 · 1 revision

#Code Editor Field

To add a Code Editor field to your metabox simply use the addCode method of the metabox object:

$my_meta =  new AT_Meta_Box($config);
$my_meta->addCode('code_field_id',array('name'=> 'Code editor Field', 'syntax' => 'php','theme' => 'light'));

Method arguments:

  • ID : field id (string)
  • args: (mixed|array)
    •  'name' =>  field name/label, (string) optional
      
    •  'desc' =>  field description, (string) optional
      
    •  'std' =>   default value, (string) optional
      
    •  'style' => custom style for field, (string) optional
      
    •  'syntax' => syntax language to use in editor (php,javascript,css,html)
      
    •  'theme' => syntax highlight theme (string) optional (default,light,dark)
      
    •  'validate_func' => validate function name, (string) optional
      
  • reapeater: When adding this field to a repeater block set to true (default false)

Get Field Data:

$saved_data = get_post_meta($post->ID,'code_field_id',true);
echo $saved_data;
Clone this wiki locally