_meta_box['fields'] as $key => $field) { if ('taxonomy' == $field['type'] && 'checkbox_list' == $field['options']['type']) { $this->_meta_box['fields'][$key]['multiple'] = true; } } } // show taxonomy list function show_field_taxonomy($field, $meta) { global $post; if (!is_array($meta)) $meta = (array) $meta; $this->show_field_begin($field, $meta); $options = $field['options']; $terms = get_terms($options['taxonomy'], $options['args']); // checkbox_list if ('checkbox_list' == $options['type']) { foreach ($terms as $term) { echo "slug, $meta), true, false) . " /> $term->name
"; } } // select else { echo ""; } $this->show_field_end($field, $meta); } } /********************* END EXTENDING CLASS ***********************/ /********************* BEGIN DEFINITION OF META BOXES ***********************/ // prefix of meta keys, optional // use underscore (_) at the beginning to make keys hidden, for example $prefix = '_rw_'; // you also can make prefix empty to disable it $prefix = 'dbt_'; $meta_boxes = array(); // first meta box $meta_boxes[] = array( 'id' => 'animal-info', // meta box id, unique per meta box 'title' => __('Animal Informations', 'ADA'), // meta box title 'pages' => array('pet'), // post types, accept custom post types as well, default is array('post'); optional 'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional 'priority' => 'high', // order of meta box: high (default), low; optional 'fields' => array( // list of meta fields array( 'name' => __('Gender', 'ADA'), 'id' => $prefix . 'genero', 'type' => 'radio', // radio box 'options' => array( // array of key => value pairs for radio options __('Male', 'ADA') => __('Male', 'ADA'), __('Female', 'ADA') => __('Female', 'ADA') ) ), array( 'name' => __('Spayed/Neutered', 'ADA'), 'id' => $prefix . 'cast', 'type' => 'radio', // radio box 'options' => array( // array of key => value pairs for radio options __('Yes', 'ADA') => __('Yes', 'ADA'), __('No', 'ADA') => __('No', 'ADA') ) ), array( 'name' => __('Age', 'ADA'), 'id' => $prefix . 'idade', 'type' => 'select', // select box 'options' => array( // array of key => value pairs for select box __('Baby (Under 1 year)', 'ADA') => __('Baby (Under 1 year)', 'ADA'), __('Adult (2 to 9 years)', 'ADA') => __('Adult (2 to 9 years)', 'ADA'), __('Senior (More than 10 years)', 'ADA') => __('Senior (More than 10 years)', 'ADA') ), 'multiple' => false // default value, can be string (single value) or array (for both single and multiple values) ), array( 'name' => __('Breed(s)', 'ADA'), // field name 'desc' => __('One or more breeds separated by commas. Example: Poodle, Unknown', 'ADA'), 'id' => $prefix . 'raca', // field id, i.e. the meta key 'type' => 'text' ), array( 'name' => __('Size', 'ADA'), 'id' => $prefix . 'porte', 'type' => 'select', // select box 'options' => array( // array of key => value pairs for select box __('Newborn (Imprecise)', 'ADA') => __('Newborn (Imprecise)', 'ADA'), __('Mini', 'ADA') => __('Mini', 'ADA'), __('Small', 'ADA') => __('Small', 'ADA'), __('Medium', 'ADA') => __('Medium', 'ADA'), __('Large', 'ADA') => __('Large', 'ADA'), __('Huge', 'ADA') => __('Huge', 'ADA') ), 'multiple' => false ), array( 'name' => __('Hair', 'ADA'), 'id' => $prefix . 'pelagem', 'type' => 'select', // select box 'options' => array( // array of key => value pairs for select box __('None', 'ADA') => __('None', 'ADA'), __('Short', 'ADA') => __('Short', 'ADA'), __('Medium', 'ADA') => __('Medium', 'ADA'), __('Long', 'ADA') => __('Long', 'ADA'), __('Mixed', 'ADA') => __('Mixed', 'ADA'), ), 'multiple' => false ), array( 'name' => __('Pattern', 'ADA'), 'id' => $prefix . 'padrao', 'type' => 'select', // select box 'options' => array( // array of key => value pairs for select box __('Solid', 'ADA') => __('Solid', 'ADA'), __('Brindle', 'ADA') => __('Brindle', 'ADA'), __('Patches', 'ADA') => __('Patches', 'ADA'), __('Spotted', 'ADA') => __('Spotted', 'ADA') ), 'multiple' => true, 'desc'=>__('Ctrl-click for multi-select', 'ADA') ), array( 'name' => __('Vaccines', 'ADA'), 'id' => $prefix . 'vacinas', 'type' => 'radio', // radio box 'options' => array( // array of key => value pairs for radio options __('Vaccinated', 'ADA') => __('Vaccinated', 'ADA'), __('None', 'ADA') => __('None', 'ADA'), __('Unknown', 'ADA') => __('Unknown', 'ADA'), __('Dose Interval', 'ADA') => __('Dose Interval', 'ADA') ) ), array( 'name' => __('Notes (optional)', 'ADA'), 'desc' => __('Physical conditions, aspects or any other info', 'ADA'), 'id' => $prefix . 'ob', 'type' => 'wysiwyg' ) ) ); $meta_boxes[] = array( 'id' => 'lost=pet-info', 'title' => __('Lost Pet Information', 'ADA'), 'pages' => array('lost'), 'fields' => array( array( 'name' => __('Gender', 'ADA'), 'id' => $prefix . 'p-genero', 'type' => 'radio', // radio box 'options' => array( // array of key => value pairs for radio options __('Male', 'ADA') => __('Male', 'ADA'), __('Female', 'ADA') => __('Female', 'ADA') ) ), array( 'name' => __('Spayed/Neutered', 'ADA'), 'id' => $prefix . 'p-cast', 'type' => 'radio', // radio box 'options' => array( // array of key => value pairs for radio options __('Yes', 'ADA') => __('Yes', 'ADA'), __('No', 'ADA') => __('No', 'ADA') ) ), array( 'name' => __('Age', 'ADA'), 'id' => $prefix . 'p-idade', 'type' => 'select', // select box 'options' => array( // array of key => value pairs for select box __('Baby (Under 1 year)', 'ADA') => __('Baby (Under 1 year)', 'ADA'), __('Adult (2 to 9 years)', 'ADA') => __('Adult (2 to 9 years)', 'ADA'), __('Senior (More than 10 years)', 'ADA') => __('Senior (More than 10 years)', 'ADA') ), 'multiple' => false // default value, can be string (single value) or array (for both single and multiple values) ), array( 'name' => __('Breed(s)', 'ADA'), // field name 'desc' => __('One or more breeds separated by commas. Example: Poodle, Unknown', 'ADA'), 'id' => $prefix . 'p-raca', // field id, i.e. the meta key 'type' => 'text', ), array( 'name' => __('Size', 'ADA'), 'id' => $prefix . 'p-porte', 'type' => 'select', // select box 'options' => array( // array of key => value pairs for select box __('Newborn (Imprecise)', 'ADA') => __('Newborn (Imprecise)', 'ADA'), __('Mini', 'ADA') => __('Mini', 'ADA'), __('Small', 'ADA') => __('Small', 'ADA'), __('Medium', 'ADA') => __('Medium', 'ADA'), __('Large', 'ADA') => __('Large', 'ADA'), __('Huge', 'ADA') => __('Huge', 'ADA') ), 'multiple' => false ), array( 'name' => __('Color(s)', 'ADA'), // field name 'desc' => __('One or more color separated by commas. Example: Black, White', 'ADA'), 'id' => $prefix . 'p-cor', // field id, i.e. the meta key 'type' => 'text' ), array( 'name' => __('Hair', 'ADA'), 'id' => $prefix . 'p-pelagem', 'type' => 'select', // select box 'options' => array( __('None', 'ADA') => __('None', 'ADA'), // array of key => value pairs for select box __('Short', 'ADA') => __('Short', 'ADA'), __('Medium', 'ADA') => __('Medium', 'ADA'), __('Long', 'ADA') => __('Long', 'ADA'), __('Mixed', 'ADA') => __('Mixed', 'ADA') ), 'multiple' => false ), array( 'name' => __('Pattern', 'ADA'), 'id' => $prefix . 'p-padrao', 'type' => 'select', // select box 'options' => array( // array of key => value pairs for select box __('Solid', 'ADA') => __('Solid', 'ADA'), __('Brindle', 'ADA') => __('Brindle', 'ADA'), __('Patches', 'ADA') => __('Patches', 'ADA'), __('Spotted', 'ADA') => __('Spotted', 'ADA') ), 'multiple' => true, 'desc'=>__('Ctrl-click for multi-select', 'ADA') ), array( 'name' => 'Vaccines', 'id' => $prefix . 'vacinas', 'type' => 'radio', // radio box 'options' => array( // array of key => value pairs for radio options __('Vaccinated', 'ADA') => __('Vaccinated', 'ADA'), __('None', 'ADA') => __('None', 'ADA'), __('Unknown', 'ADA') => __('Unknown', 'ADA'), __('Dose Interval', 'ADA') => __('Dose Interval', 'ADA') ) ), array( 'name' => __('Date lost', 'ADA'), 'id' => $prefix . 'p-data', 'type' => 'text', // time 'desc' => __('Format MM-DD-YYYY', 'ADA'), // time format, default hh:mm. Optional. See more formats here: http://goo.gl/hXHWz ), array( 'name' => __('Place & Time', 'ADA'), // field name 'desc' => __('The last place and time. Example: Lincoln Park', 'ADA'), 'id' => $prefix . 'p-rua', // field id, i.e. the meta key 'type' => 'text' // text box ), array( 'name' => __('Pictures', 'ADA'), 'desc' => __('Recomended width: 400px. Please note: the admin will choose a limited amount of images.', 'ADA'), 'id' => $prefix . 'p-pic', 'type' => 'image' // image upload ) ) ); // second meta box $meta_boxes[] = array( 'id' => 'contact-info', 'title' => __('Contact Information', 'ADA'), 'pages' => array('pet','lost'), 'fields' => array( array( 'name' => __('Contact Info', 'ADA'), 'id' => $prefix . 'contato', 'type' => 'textarea' // WYSIWYG editor ), array( 'name' => __('E-mail', 'ADA'), // field name 'desc' => __('Example: name@server.com', 'ADA'), 'id' => $prefix . 'email', // field id, i.e. the meta key 'type' => 'text', 'desc'=> __('Please Note:All These informations will be visible in our website. Be careful sharing personal information such e-mails and addresses. You can create a e-mail for this purpose only, check with your favorite e-mail provider.', 'ADA') ) ) ); foreach ($meta_boxes as $meta_box) { $my_box = new RW_Meta_Box_Taxonomy($meta_box); } /********************* END DEFINITION OF META BOXES ***********************/ /********************* BEGIN VALIDATION ***********************/ /** * Validation class * Define ALL validation methods inside this class * Use the names of these methods in the definition of meta boxes (key 'validate_func' of each field) */ class RW_Meta_Box_Validate { function check_name($text) { if ($text == 'Anh Tran') { return 'He is Rilwis'; } return $text; } } /********************* END VALIDATION ***********************/ ?>