if (!function_exists('ls_extract_heading')) { function ls_extract_heading($paragraphs, $number) { if (empty($paragraphs)) return 'Section ' . $number; $first = $paragraphs[0]; $dash = mb_strpos($first, '—'); if ($dash !== false && $dash < 150) { $heading = mb_substr($first, 0, $dash); $heading = preg_replace('/^[0-9]+\[?\(?[0-9A-Za-z]*\)?\]?\.?\s*/', '', $heading); return trim($heading); } return 'Section ' . $number; } } if (!function_exists('ls_import_act')) { function ls_import_act($act_json_b64, $pdf_relative_path, $az_index_post_id = 480, $index_label = null) { $act = json_decode(base64_decode($act_json_b64), true); if (!$act || empty($act['sections'])) { return array('error' => 'invalid act json'); } $result = array(); $pdf_path = ABSPATH . $pdf_relative_path; if (!file_exists($pdf_path)) { return array('error' => 'pdf not found at ' . $pdf_path); } $filetype = wp_check_filetype(basename($pdf_path), null); $attachment = array( 'post_mime_type' => $filetype['type'], 'post_title' => $act['title'] . ' - Bare Act PDF', 'post_content' => '', 'post_status' => 'inherit', ); $pdf_attach_id = wp_insert_attachment($attachment, $pdf_path); $pdf_url = wp_get_attachment_url($pdf_attach_id); $result['pdf_url'] = $pdf_url; $section_post_ids = array(); $section_links = array(); foreach ($act['sections'] as $sec) { $heading = ls_extract_heading($sec['paragraphs'], $sec['number']); $title = 'Section ' . $sec['number'] . ' ' . $act['title'] . ' – ' . $heading; $content = ''; foreach ($sec['paragraphs'] as $p) { $content .= '

' . esc_html($p) . '

' . "\n"; } $post_id = wp_insert_post(array( 'post_title' => $title, 'post_content' => $content, 'post_status' => 'publish', 'post_type' => 'post', 'post_category' => array(87), )); $section_post_ids[$sec['number']] = $post_id; $section_links[] = array('number' => $sec['number'], 'heading' => $heading, 'id' => $post_id, 'url' => get_permalink($post_id)); } $result['sections'] = $section_links; $full_text = ''; foreach ($act['sections'] as $sec) { $sl = $section_links[array_search($sec['number'], array_column($section_links, 'number'))]; $full_text .= '

Section ' . esc_html($sec['number']) . ' – ' . esc_html($sl['heading']) . '

' . "\n"; foreach ($sec['paragraphs'] as $p) { $full_text .= '

' . esc_html($p) . '

' . "\n"; } } $content = '

Read the full text of the ' . esc_html($act['title']) . ' below, section by section. Click any section heading to open its dedicated page, or download the complete Bare Act as a PDF.

' . '

Download the full Bare Act (PDF)

' . '

Full Text — ' . esc_html($act['title']) . '

' . $full_text; $bare_act_id = wp_insert_post(array( 'post_title' => $act['title'] . ' – Bare Act', 'post_content' => $content, 'post_status' => 'publish', 'post_type' => 'post', 'post_category' => array(28), )); $result['bare_act_id'] = $bare_act_id; $result['bare_act_url'] = get_permalink($bare_act_id); $numbers = array_keys($section_post_ids); foreach ($numbers as $i => $num) { $post_id = $section_post_ids[$num]; $post = get_post($post_id); $nav = '

← Back to full Bare Act

'; if ($i > 0) { $prev_id = $section_post_ids[$numbers[$i - 1]]; $nav .= '← Previous Section  |  '; } if ($i < count($numbers) - 1) { $next_id = $section_post_ids[$numbers[$i + 1]]; $nav .= 'Next Section →'; } $nav .= '

'; wp_update_post(array('ID' => $post_id, 'post_content' => $post->post_content . $nav)); } $idx_post = get_post($az_index_post_id); $idx_content = $idx_post->post_content; $label = $index_label ?: $act['title']; $old = '
  • ' . $label . '
  • '; $new = '
  • ' . esc_html($label) . '
  • '; $updated = str_replace($old, $new, $idx_content, $count); $result['index_link_updated'] = $count; if ($count > 0) { wp_update_post(array('ID' => $az_index_post_id, 'post_content' => $updated)); } return $result; } } Page Not Found - Legal Sandook

    Page Not Found

    The page is not in this library.

    The link may be old, moved, or unpublished. Search Legal Sandook or jump into a main research shelf.

    Search the legal library

    Use a statute name, section number, case name, or legal topic.