public function tree_species_meta_box() { global $post; //output the nounce field wp_nonce_field('tree_species_metabox', '_tree-species-nounce'); //get tree post meta fields $default_meta = array('tree_scientific_name' => '', 'tree_family_name' => '', 'tree_common_name' => '', 'tree_height' => '', 'tree_shape' => '', 'tree_diameter' => '10', 'tree_origin_name' => ''); $tree_meta_fields = wp_parse_args(get_post_custom($post->ID), $default_meta); //this next step pulls out the values from the array of arrays. get_post_custom retrieves a list of //single diemention arrays, this pulls the values and place it as a key value list. foreach ($tree_meta_fields as $key => $value) { if (sizeof($value) == 1) { $tree_meta_fields[$key] = $value[0]; } } //create the tree identification fields ?> <div id="tree_species_wrapper"> <!-- Nav tabs --> <ul id="tree_species_tabs" class="nav nav-tabs" role="tablist"> <li role="presentation"> </li> <li role="presentation" class="active"><a href="#overview" aria-controls="overview" role="tab" data-toggle="tab"><?php _etts('Overview'); ?> </a></li> <li role="presentation"><a href="#shape" aria-controls="shape" role="tab" data-toggle="tab"><?php _etts('Shape'); ?> </a></li> </ul> <!-- Tab panes --> <div class="tab-content"> <!-- OVERVIEW --> <div role="tabpanel" class="tab-pane active in" id="overview"> <div class="page-header"> <h1><?php _etts('Tree Properties'); ?> </h1> </div> <div class="inside"> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <div class="inside"> <!--Scientific name--> <div class="form-group"> <label for="tree_scientific_name" class="control-label"><?php _etts('Scientific Name'); ?> </label> <input id="tree_scientific_name" name="tree_scientific_name" type="text" class="form-control input-sm" value="<?php echo $tree_meta_fields['tree_scientific_name']; ?> " placeholder="<?php _etts('Scientific Name'); ?> "> </div> <!--Family name--> <div class="form-group"> <label for="post_tree_family_name" class="control-label"><?php _etts('Family Name'); ?> </label> <input id="tree_family_name" name="tree_family_name" type="text" class="form-control input-sm" value="<?php echo $tree_meta_fields['tree_family_name']; ?> " placeholder="<?php _etts('Family Name'); ?> "> </div> </div> </div> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <div class="inside"> <!--Common name--> <div class="form-group"> <label for="tree_common_name" class="control-label"><?php _etts('Common Name'); ?> </label> <input id="tree_common_name" name="tree_common_name" type="text" class="form-control input-sm" value="<?php echo $tree_meta_fields['tree_common_name']; ?> " placeholder="<?php _etts('Common Name'); ?> "> </div> <!--Origin--> <div class="form-group"> <label for="tree_origin_name" class="control-label"><?php _etts('Origin'); ?> </label> <input id="tree_origin_name" name="tree_origin_name" type="text" class="form-control input-sm" value="<?php echo $tree_meta_fields['tree_origin_name']; ?> " placeholder="<?php _etts('Origin'); ?> "> </div> </div> </div> </div> <div class="page-header"> <h1><?php _etts('Description'); ?> </h1> </div> <div class="padded"> <?php wp_editor($post->post_content, 'post_content', $settings = array()); ?> </div> </div> </div> <!--end overview panel--> <!--shape tab--> <div role="tabpanel" class="tab-pane in" id="shape"> <div class="page-header"> <h1><?php _etts('Tree Shape & Size'); ?> </h1> </div> <div class="inside"> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <div class="inside"> <!--Shape--> <div class="form-group"> <label for="tree_shape" class="control-label"><?php _etts('Diameter'); ?> </label> <select id="tree_shape" name="tree_shape" type="text" class="form-control input-sm"> <option id="columnar"><?php _etts('Columnar'); ?> </option> <option id="fastigiate"><?php _etts('Fastigiate'); ?> </option> <option id="open"><?php _etts('Open'); ?> </option> <option id="oval"><?php _etts('Oval'); ?> </option> <option id="pyramidal"><?php _etts('Pyramidal'); ?> </option> <option id="weeping"><?php _etts('Weeping'); ?> </option> <option id="umbrella"><?php _etts('Umbrella'); ?> </option> <option id="vase"><?php _etts('Vase'); ?> </option> <option id="weeping"><?php _etts('Weeping'); ?> </option> </select> </div> </div> </div> <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6"> <div class="inside"> <!--Diameter--> <div class="form-group"> <label for="tree_diameter" class="control-label"><?php _etts('Diameter'); ?> </label> <div class="input-group"> <input id="tree_diameter" name="tree_diameter" type="text" class="form-control input-sm" value="<?php echo $tree_meta_fields['tree_diameter']; ?> " placeholder="<?php _etts('Tree Diamter'); ?> "> <div class="input-group-addon"><?php _etts('cm'); ?> </div> </div> </div> <!--Height--> <div class="form-group"> <label for="tree_height" class="control-label"><?php _etts('Height'); ?> </label> <div class="input-group"> <input id="tree_height" name="tree_height" type="text" class="form-control input-sm" value="<?php echo $tree_meta_fields['tree_height']; ?> " placeholder="<?php _etts('Tree height'); ?> "> <div class="input-group-addon"><?php _etts('m'); ?> </div> </div> </div> </div> </div> </div> </div> </div> </div><!--end tab-content--> </div><!--end wrapper--> <?php //labels for the js client side $labels = array('Loading' => _tts('Loading'), 'Saving' => _tts('Saving...')); ?> <script type="application/javascript"> jQuery(document).ready(function(){ try { var treeSpeciesMetaBox = new TreeSpeciesMetaboxClass( <?php echo $post->ID; ?> , '<?php echo trailingslashit(FOREST_CORE_ROOTDIRURL) . 'assets/imgs/tree_shapes/small/'; ?> ', <?php echo json_encode($labels); ?> ); treeSpeciesMetaBox.init(); } catch(e){ console.log(e.message); } }); </script> <?php }
public function enter_title($input) { global $post_type; if (is_admin() && self::$post_type == $post_type) { return _tts('Enter tree name here'); } return $input; }