public function tree_species_debug_meta_box()
 {
     if (!defined('WP_DEBUG') || WP_DEBUG === false) {
         return;
     }
     //this template is located in the ajax plugin
     if (!defined('FOREST_CORE_ROOTDIR')) {
         return;
     }
     $loader = new ForestTemplateLoader(FOREST_CORE_ROOTDIR);
     $loader->get_template_part('post', 'debug-metabox');
 }
        /**
         * Render the field
         */
        public function render_plan_items_manager($field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object)
        {
            global $post;
            if (!class_exists('ForestTemplateLoader')) {
                $this->admin_error_notice(__("Missing the forest ajax plugin.", 'forest-manager'));
                return;
            }
            //used to load segments of html fom temeplates
            $template_loader = new ForestTemplateLoader(PLAN_MNGR_ROOTDIR);
            echo $field_type_object->input(array('type' => 'hidden', 'desc' => ''));
            $screen = get_current_screen();
            $is_new = isset($screen) && $screen->id == 'forest_plan' && $screen->action == 'add' && $screen->base == 'post';
            //Security nounce
            wp_nonce_field('plan_item_manager', '_plan_item_manager_nounce');
            //region ---------------Handle arguments--------------------
            //if the developer using this field forgot to set a custom type use posts
            if (!array_key_exists('post_type', $field->args)) {
                $field->args['post_type'] = array('posts');
            } elseif (!is_array($field->args['post_type'])) {
                $field->args['post_type'] = explode(',', trim($field->args['post_type']));
            }
            if (!array_key_exists('columns', $field->args)) {
                $field->args['columns'] = array('ID' => __('Id', 'forest-manager'), 'post_title' => __('Title', 'forest-manager'));
                //basic columns for posts...add your own
            }
            if (!array_key_exists('sort_by', $field->args)) {
                $field->args['sort_by'] = array('post_date' => 'DESC');
                //default sort
            }
            //endregion
            //the text translations...for js
            $lables = array('loading' => __('Loading...', 'forest-manager'), 'ServerError' => __('Server error. Please try again.', 'forest-manager'), 'PleaseSelect' => __('Please select', 'forest-manager'), 'NoItems' => __('No Items', 'forest-manager'), 'MissingSearchCreteria' => __('Missing Search Creteria.', 'forest-manager'), 'MissingItemType' => __('Missing Item Type.', 'forest-manager'), 'LinkBackVarId' => 'plan_id');
            ?>

			<!-- wrapper -->
			<div id="<?php 
            echo esc_js($field->args('id'));
            ?>
_wrapper">
				<div>

					<!-- Nav tabs -->
					<ul id="plan-tabs" class="nav nav-tabs" role="tablist">
						<li role="presentation">&nbsp;</li>
						<li role="presentation" class="active"><a href="#overview"  aria-controls="overview" role="tab" data-toggle="tab"><?php 
            _e('Overview', 'forest-manager');
            ?>
</a></li>
						<li role="presentation"<?php 
            echo $is_new ? ' class="disabled"' : '';
            ?>
><a href="#edit" aria-controls="edit" role="tab" data-toggle="tab"><?php 
            _e('Edit', 'forest-manager');
            ?>
</a></li>
						<li role="presentation"<?php 
            echo $is_new ? ' class="disabled"' : '';
            ?>
><a href="#maps" aria-controls="maps" role="tab" data-toggle="tab"><?php 
            _e('Maps', 'forest-manager');
            ?>
</a></li>
						<li role="presentation"<?php 
            echo $is_new ? ' class="disabled"' : '';
            ?>
><a href="#reports" aria-controls="reports" role="tab" data-toggle="tab"><?php 
            _e('Reports', 'forest-manager');
            ?>
</a></li>
						<li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab"><?php 
            _e('Settings', 'forest-manager');
            ?>
</a></li>
					</ul>

					<!-- Tab panes -->
					<div class="tab-content">
						
						<!-- OVERVIEW -->
						<div role="tabpanel" class="tab-pane padded active in" id="overview">
							<?php 
            if ($is_new) {
                $template_loader->get_template_part('plan', 'create');
            }
            ?>

							<?php 
            // wp_editor( __('Overview', 'forest-manager'), $field->args( 'id' ) . '_overview' , $settings = array() );
            ?>

						</div>

						<!-- EDIT -->
						<div role="tabpanel" class="tab-pane" id="edit">

							<div id="edit-tab-filter" class="filter-box bg-info">
								<label for="tree-card-title-search"><?php 
            _e('Filter', 'forest-manager');
            ?>
</label>
								<select style="width:180px;">
									<option value=""></option>
									<?php 
            $objects = $this->get_plan_object_types();
            foreach ($objects as $id => $name) {
                echo '<option value="' . $id . '">' . $name . '</option>';
            }
            ?>
								</select>
								<input type="text" class="search-term" placeholder="Name"/>
								<button class="btn btn-primary search" tooltip="<?php 
            _e('click to filter', 'forest-manager');
            ?>
">
									<i class="fa fa-filter"></i></button>
								<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#add-items-modal">
									<i class="fa fa-plus"></i>
								</button>
								<div class="btn-group alignright">
									<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
										Action <span class="caret"></span>
									</button>
									<ul class="dropdown-menu">
										<li><a href="#">Action</a></li>
										<li><a href="#">Another action</a></li>
										<li><a href="#">Something else here</a></li>
										<li role="separator" class="divider"></li>
										<li><a href="#">Separated link</a></li>
									</ul>
								</div>
							</div>

							<!--Main Plan Items Table-->
							<table class="post-type-table table table-hover table-condensed table-striped plan-items" data-filter-id="edit-tab-filter">

								<caption class="notice">
									<div class="river-waiting">
										<span class="spinner"></span>
									</div>
									<em class="query-notice-default"><?php 
            _e('Loaded recent objects. Enter a filter to search for more...', 'forest-manager');
            ?>
</em>
								</caption>

								<thead>
									<?php 
            $this->the_column_headers($field->args['columns'], $field->args['sort_by']);
            ?>
								</thead>

								<tbody>

								<?php 
            //Get post id for plan. If new -1.
            $plan_id = array_key_exists('post', $_GET) ? $_GET['post'] : -1;
            //get recent plan objects
            $query = new PlanDbQuery($plan_id);
            $items = $query->get_recent_plan_items();
            ?>

								<?php 
            if ($query->have_items()) {
                ?>

									<!-- the loop -->
									<?php 
                foreach ($items as $item) {
                    ?>

										<?php 
                    $edit_url = get_edit_post_link($item->ID) . '&' . $this->get_plan_link_id() . '=' . $plan_id;
                    ?>

										<tr>
											<td>
												<input type="checkbox" name="item_select"/>
											</td>

											<td>
												<?php 
                    echo sprintf('<a href="%s">%s</a>', $edit_url, $item->post_title);
                    ?>
											</td>

											<td>
												<?php 
                    echo $item->post_status;
                    ?>
											</td>

											<td>
												<?php 
                    echo $item->post_date;
                    ?>
											</td>

											<td>
												<?php 
                    echo $item->post_author_name;
                    ?>
											</td>

											<td>
												<?php 
                    echo $item->post_type;
                    ?>
											</td>
										</tr>

									<?php 
                }
                ?>
									<!-- end of the loop -->

								<?php 
            } else {
                ?>
									<tr><td colspan="6" class="no-items"><?php 
                _e('Sorry, no items found.');
                ?>
</td></tr>
								<?php 
            }
            ?>

								</tbody>

								<tfoot>
								<tr>

									<td colspan="6">
										<div class="pagination-container">
											<?php 
            $this->bootstrap_pagination($query);
            ?>
										</div>
									</td>

								</tr>
								</tfoot>
							</table>

							<?php 
            wp_reset_postdata();
            ?>

							<!-- Modal Dialog-->
							<div class="modal fade" id="add-items-modal" tabindex="-1" role="dialog" aria-labelledby="add-title-label">
								<div class="modal-dialog" role="document">
									<div class="modal-content">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
											<h4 class="modal-title" id="add-title-label"><?php 
            _e('The Title', 'forest-manager');
            ?>
</h4>
										</div>

										<div class="modal-body">

											<div id="add-items-filter" class="filter-box bg-info">

												<label for="filter-tree-species"><?php 
            _e('Find', 'forest-manager');
            ?>
</label>
												<select style="width:180px;">
													<option value=""></option>
													<?php 
            $objects = $this->get_plan_object_types();
            foreach ($objects as $id => $name) {
                echo '<option value="' . $id . '">' . $name . '</option>';
            }
            ?>
												</select>
												<input type="text" class="search-term" placeholder="<?php 
            _e('Enter a search string', 'forest-manager');
            ?>
">
												<button type="submit" class="btn btn-primary"><i class="fa fa-filter"></i></button>

											</div>

											<div class="items">

												<table class="post-type-table table table-hover table-condensed table-striped" data-filter-id="add-items-filter">

													<caption>
														<div class="river-waiting">
															<span class="spinner"></span>
														</div>
														<em><?php 
            _e('Loading...', 'forest-manager');
            ?>
</em>
													</caption>

													<thead>
													<?php 
            $this->the_column_headers($field->args['columns'], $field->args['sort_by']);
            ?>
													</thead>

													<tbody>
													<tr>
														<td colspan="6" class="message no-items"><?php 
            _e('No items', 'forest-manager');
            ?>
</td>
													</tr>
													<?php 
            //The rows and cells are added in the JS using Ajax call.
            //@see: cmb2-field-plan-items-manager.js
            ?>
													</tbody>

													<tfoot class="hidden">
													<tr>
														<td colspan="6">
															<div class="pagination-container">
																<?php 
            //The pagination control is created using js.
            //@see:cmb2-field-plan-items-manager.js
            ?>
															</div>
														</td>
													</tr>
													</tfoot>
												</table>

											</div>

										</div><!--modal body end-->

										<div class="modal-footer">
											<button type="button" class="btn btn-default" data-dismiss="modal"><?php 
            _e('Close', 'forest-manager');
            ?>
</button>
											<button type="button" class="btn btn-primary"><?php 
            _e('Add Item', 'forest-manager');
            ?>
</button>
										</div>
									</div>
								</div>
							</div>

						</div>

						<div role="tabpanel" class="tab-pane padded" id="maps">The Maps</div>

						<div role="tabpanel" class="tab-pane padded" id="reports">The Reports</div>

						<div role="tabpanel" class="tab-pane padded" id="settings">

							<?php 
            include $template_loader->get_template_part('plan', 'settings', false);
            ?>

						</div>
					</div>

				</div>

			</div><!--end wrapper-->

			<script type="application/javascript">
				jQuery(document).ready(function () {
					var cmb_post_type_tree_manager_obj = new PlanManagerMetaboxClass(
							 <?php 
            echo $plan_id;
            ?>
,
							'<?php 
            echo implode(',', $field->args['post_type']);
            ?>
',
							'<?php 
            echo esc_js($field->args('id'));
            ?>
',
							 <?php 
            echo json_encode($field->args['columns']);
            ?>
,
							 <?php 
            echo '{sortColId:\'post_date\', sortDirection:\'DESC\'}';
            ?>
,
							 '<?php 
            echo get_the_title();
            ?>
',
							 <?php 
            echo json_encode($lables);
            ?>
);
					cmb_post_type_tree_manager_obj.init();
				});
			</script>

			<?php 
        }