<div class="doc-read-wrap"> <div class="doc-read-menu"> <?php doc_get_section_menu($doc_id); ?> </div> <div class="doc-read-content"> <?php $document = get_post($doc_id); ?> <div class="doc-content-wrap"> <h1 class="doc-title"><?php echo $document->post_title; ?> </h1> <div class="doc-content"><?php echo $document->post_content; ?> </div> </div> <?php foreach ($menu['parent'] as $post_id) { if (isset($section[$post_id])) { ?> <div class="doc-menu-id-<?php echo $post_id; ?> " id="doc-cotent-id-<?php echo $post_id; ?>
function new_documentation() { check_ajax_referer('doc_nonce'); $is_update = empty($_POST['section_id']) ? false : true; $section_title = $_POST['section_title']; $section_content = $_POST['section_desc']; $doc_id = $_POST['post_id']; $args = array('post_title' => $section_title, 'post_content' => $section_content, 'post_parent' => $doc_id, 'post_status' => 'publish', 'post_type' => 'doc_section'); if ($is_update) { $args['ID'] = $_POST['section_id']; $post_id = wp_update_post($args); } else { $post_id = wp_insert_post($args); $menu = get_post_meta($doc_id, '_documenter_menu', true); if (empty($menu)) { $menu = array('child' => array(), 'parent' => array($post_id => $post_id)); } else { array_push($menu['parent'], $post_id); } update_post_meta($doc_id, '_documenter_menu', $menu); } ob_start(); doc_get_section_menu($doc_id); wp_send_json_success(array('msg' => __('Section Update Successfully'), 'menu' => ob_get_clean())); }