{"id":275,"date":"2026-01-12T03:57:14","date_gmt":"2026-01-12T03:57:14","guid":{"rendered":"https:\/\/nealxo.com\/?page_id=275"},"modified":"2026-01-14T05:04:10","modified_gmt":"2026-01-14T05:04:10","slug":"admin-claims","status":"publish","type":"page","link":"https:\/\/bosangtok.kstorytelling.com\/en\/admin-claims\/","title":{"rendered":"\uad00\ub9ac\uc790 \ud398\uc774\uc9c0"},"content":{"rendered":"<p>\/**<br \/>\n * \ubcf4\uc0c1\ud1a1 \uc0b0\uc7ac \uc2e0\uccad \uad00\ub9ac \uc2dc\uc2a4\ud15c<br \/>\n * (functions.php \ub9e8 \uc544\ub798\uc758 \uae30\uc874 \ucf54\ub4dc\ub97c \uc9c0\uc6b0\uace0 \uc774 \ucf54\ub4dc\ub85c \uad50\uccb4\ud574\uc8fc\uc138\uc694)<br \/>\n *\/<\/p>\n<p>\/\/ 1. \uc778\uc99d \ud1a0\ud070(Nonce)\uacfc API \uc815\ubcf4 \uc804\ub2ec (\ud5e4\ub354 \uc9c1\uc811 \ucd9c\ub825 \ubc29\uc2dd)<br \/>\nadd_action(&#8216;wp_head&#8217;, &#8216;sjt_print_api_config&#8217;);<br \/>\nfunction sjt_print_api_config()<br \/>\n{<br \/>\n    $config = array(<br \/>\n        &#8216;nonce&#8217; => wp_create_nonce(&#8216;wp_rest&#8217;), \/\/ REST API \uc778\uc99d\ud0a4<br \/>\n        &#8216;root&#8217; => esc_url_raw(rest_url()),    \/\/ API \uae30\ubcf8 \uc8fc\uc18c<br \/>\n        &#8216;submitUrl&#8217; => esc_url_raw(rest_url(&#8216;sjt\/v1\/submit&#8217;)),<br \/>\n        &#8216;listUrl&#8217; => esc_url_raw(rest_url(&#8216;sjt\/v1\/claims&#8217;))<br \/>\n    );<br \/>\n    ?><br \/>\n    <script>\n        \/* \ubcf4\uc0c1\ud1a1 API \uc124\uc815 *\/\n        window.sjtConfig = <?php echo json_encode($config); ?>;\n    <\/script><br \/>\n    <?php\n}\n\n\/\/ 2. Custom Post Type \ub4f1\ub85d (\uc0b0\uc7ac \uc2e0\uccad \ub0b4\uc5ed)\nfunction sjt_register_claim_post_type()\n{\n    register_post_type(\n        'sjt_claim',\n        array(\n            'labels' => array(<br \/>\n                &#8216;name&#8217; => __(&#8216;\uc0b0\uc7ac \uc2e0\uccad&#8217;, &#8216;textdomain&#8217;),<br \/>\n                &#8216;singular_name&#8217; => __(&#8216;\uc0b0\uc7ac \uc2e0\uccad&#8217;, &#8216;textdomain&#8217;),<br \/>\n            ),<br \/>\n            &#8216;public&#8217; => false,  \/\/ \uc678\ubd80\uc5d0 \ub178\ucd9c\ub418\uc9c0 \uc54a\uc74c<br \/>\n            &#8216;show_ui&#8217; => true,   \/\/ \uad00\ub9ac\uc790 \ud398\uc774\uc9c0\uc5d0 \uba54\ub274 \ud45c\uc2dc<br \/>\n            &#8216;has_archive&#8217; => false,<br \/>\n            &#8216;supports&#8217; => array(&#8216;title&#8217;, &#8216;editor&#8217;, &#8216;custom-fields&#8217;),<br \/>\n            &#8216;capability_type&#8217; => &#8216;post&#8217;,<br \/>\n        )<br \/>\n    );<br \/>\n}<br \/>\nadd_action(&#8216;init&#8217;, &#8216;sjt_register_claim_post_type&#8217;);<\/p>\n<p>\/\/ 3. REST API \uc5d4\ub4dc\ud3ec\uc778\ud2b8 \ub4f1\ub85d<br \/>\nadd_action(&#8216;rest_api_init&#8217;, function () {<br \/>\n    \/\/ (1) \uc2e0\uccad\uc11c \uc81c\ucd9c (POST \/wp-json\/sjt\/v1\/submit)<br \/>\n    register_rest_route(&#8216;sjt\/v1&#8217;, &#8216;\/submit&#8217;, array(<br \/>\n        &#8216;methods&#8217; => &#8216;POST&#8217;,<br \/>\n        &#8216;callback&#8217; => &#8216;sjt_handle_submission&#8217;,<br \/>\n        &#8216;permission_callback&#8217; => &#8216;__return_true&#8217;, \/\/ \ub204\uad6c\ub098 \uc81c\ucd9c \uac00\ub2a5<br \/>\n    ));<\/p>\n<p>    \/\/ (2) \uc2e0\uccad\uc11c \ubaa9\ub85d \uc870\ud68c (GET \/wp-json\/sjt\/v1\/claims)<br \/>\n    register_rest_route(&#8216;sjt\/v1&#8217;, &#8216;\/claims&#8217;, array(<br \/>\n        &#8216;methods&#8217; => &#8216;GET&#8217;,<br \/>\n        &#8216;callback&#8217; => &#8216;sjt_get_claims&#8217;,<br \/>\n        &#8216;permission_callback&#8217; => function () {<br \/>\n            \/\/ \uad00\ub9ac\uc790 \uad8c\ud55c \ud655\uc778<br \/>\n            return current_user_can(&#8216;manage_options&#8217;);<br \/>\n        },<br \/>\n    ));<\/p>\n<p>    \/\/ (3) \uc2e0\uccad\uc11c \uc0ad\uc81c (DELETE \/wp-json\/sjt\/v1\/claims)<br \/>\n    register_rest_route(&#8216;sjt\/v1&#8217;, &#8216;\/claims&#8217;, array(<br \/>\n        &#8216;methods&#8217; => &#8216;DELETE&#8217;,<br \/>\n        &#8216;callback&#8217; => &#8216;sjt_delete_claim&#8217;,<br \/>\n        &#8216;permission_callback&#8217; => function () {<br \/>\n            return current_user_can(&#8216;manage_options&#8217;);<br \/>\n        },<br \/>\n    ));<br \/>\n});<\/p>\n<p>\/\/ 4. (Callback) \uc2e0\uccad\uc11c \uc800\uc7a5 \ucc98\ub9ac<br \/>\nfunction sjt_handle_submission($request)<br \/>\n{<br \/>\n    $params = $request->get_json_params();<\/p>\n<p>    if (empty($params[&#8216;name&#8217;]) || empty($params[&#8216;contact&#8217;])) {<br \/>\n        return new WP_Error(&#8216;missing_data&#8217;, &#8216;\ud544\uc218 \uc815\ubcf4(\uc131\ud568, \uc5f0\ub77d\ucc98)\uac00 \ub204\ub77d\ub418\uc5c8\uc2b5\ub2c8\ub2e4.&#8217;, array(&#8216;status&#8217; => 400));<br \/>\n    }<\/p>\n<p>    \/\/ \uc81c\ubaa9 \uc0dd\uc131 (\uc774\ub984 + \uc720\ud615)<br \/>\n    $title = !empty($params[&#8216;title&#8217;]) ? sanitize_text_field($params[&#8216;title&#8217;]) : ($params[&#8216;name&#8217;] . &#8216;\ub2d8 \uc0b0\uc7ac \uc2e0\uccad (&#8216; . date(&#8216;Y-m-d H:i&#8217;) . &#8216;)&#8217;);<\/p>\n<p>    $post_id = wp_insert_post(array(<br \/>\n        &#8216;post_title&#8217; => sanitize_text_field($title),<br \/>\n        &#8216;post_content&#8217; => sanitize_textarea_field($params[&#8216;content&#8217;]),<br \/>\n        &#8216;post_status&#8217; => &#8216;publish&#8217;,<br \/>\n        &#8216;post_type&#8217; => &#8216;sjt_claim&#8217;,<br \/>\n    ));<\/p>\n<p>    if (is_wp_error($post_id)) {<br \/>\n        return $post_id;<br \/>\n    }<\/p>\n<p>    \/\/ &#8212; \uae30\ubcf8 \uc815\ubcf4 &#8212;<br \/>\n    update_post_meta($post_id, &#8216;sjt_name&#8217;, sanitize_text_field($params[&#8216;name&#8217;]));<br \/>\n    update_post_meta($post_id, &#8216;sjt_contact&#8217;, sanitize_text_field($params[&#8216;contact&#8217;]));<br \/>\n    update_post_meta($post_id, &#8216;sjt_company&#8217;, sanitize_text_field($params[&#8216;company&#8217;]));<br \/>\n    update_post_meta($post_id, &#8216;sjt_accident_date&#8217;, sanitize_text_field($params[&#8216;accidentDate&#8217;]));<\/p>\n<p>    \/\/ &#8212; 1\ub2e8\uacc4: \uc0b0\uc7ac \ubcf4\uc0c1 (\uac1d\uad00\uc801 \uc99d\ube59) &#8212;<br \/>\n    update_post_meta($post_id, &#8216;sjt_occupation&#8217;, sanitize_text_field($params[&#8216;occupation&#8217;])); \/\/ \uc9c1\uc885<br \/>\n    \/\/ * \ud30c\uc77c \uc5c5\ub85c\ub4dc\ub294 \ubcc4\ub3c4 \uc5d4\ub4dc\ud3ec\uc778\ud2b8 \uad6c\ud604 \ud544\uc694 (\ud604\uc7ac\ub294 \ud3fc\uc5d0\uc11c UI\ub9cc \uc81c\uacf5)<\/p>\n<p>    \/\/ &#8212; 2\ub2e8\uacc4: \uadfc\uc7ac \ubcf4\uc0c1 (\uc0c1\ud669 \ub370\uc774\ud130) &#8212;<br \/>\n    update_post_meta($post_id, &#8216;sjt_safety_edu&#8217;, sanitize_text_field($params[&#8216;safetyEdu&#8217;]));   \/\/ \uc548\uc804\uad50\uc721 \uc5ec\ubd80<br \/>\n    update_post_meta($post_id, &#8216;sjt_safety_gear&#8217;, sanitize_text_field($params[&#8216;safetyGear&#8217;])); \/\/ \ubcf4\ud638\uad6c \ucc29\uc6a9 \uc5ec\ubd80<br \/>\n    update_post_meta($post_id, &#8216;sjt_family&#8217;, sanitize_text_field($params[&#8216;family&#8217;]));         \/\/ \uac00\uc871 \uad00\uacc4<\/p>\n<p>    \/\/ &#8212; 3\ub2e8\uacc4: \uac1c\uc778 \ubcf4\ud5d8 &#8212;<br \/>\n    update_post_meta($post_id, &#8216;sjt_insurance_check&#8217;, sanitize_text_field($params[&#8216;insuranceCheck&#8217;])); \/\/ \ubcf4\ud5d8 \ud655\uc778 \uc694\uccad<\/p>\n<p>    update_post_meta($post_id, &#8216;sjt_status&#8217;, &#8216;\uc811\uc218&#8217;);<\/p>\n<p>    return new WP_REST_Response(array(&#8216;success&#8217; => true, &#8216;id&#8217; => $post_id), 200);<br \/>\n}<\/p>\n<p>\/\/ 5. (Callback) \ubaa9\ub85d \uc870\ud68c \ucc98\ub9ac (\uc911\uc694: \uad00\ub9ac\uc790\uc6a9)<br \/>\nfunction sjt_get_claims($request)<br \/>\n{<br \/>\n    \/\/ \ucd5c\uc2e0\uc21c \uc815\ub82c<br \/>\n    $args = array(<br \/>\n        &#8216;post_type&#8217; => &#8216;sjt_claim&#8217;,<br \/>\n        &#8216;posts_per_page&#8217; => -1,<br \/>\n        &#8216;post_status&#8217; => &#8216;publish&#8217;,<br \/>\n        &#8216;orderby&#8217; => &#8216;date&#8217;,<br \/>\n        &#8216;order&#8217; => &#8216;DESC&#8217;,<br \/>\n    );<\/p>\n<p>    $posts = get_posts($args);<br \/>\n    $data = array();<\/p>\n<p>    foreach ($posts as $post) {<br \/>\n        $data[] = array(<br \/>\n            &#8216;id&#8217; => $post->ID,<br \/>\n            &#8216;title&#8217; => $post->post_title,<br \/>\n            &#8216;content&#8217; => $post->post_content,<br \/>\n            &#8216;submittedAt&#8217; => $post->post_date,<\/p>\n<p>            \/\/ \uae30\ubcf8<br \/>\n            &#8216;name&#8217; => get_post_meta($post->ID, &#8216;sjt_name&#8217;, true),<br \/>\n            &#8216;contact&#8217; => get_post_meta($post->ID, &#8216;sjt_contact&#8217;, true),<br \/>\n            &#8216;company&#8217; => get_post_meta($post->ID, &#8216;sjt_company&#8217;, true),<br \/>\n            &#8216;accidentDate&#8217; => get_post_meta($post->ID, &#8216;sjt_accident_date&#8217;, true),<\/p>\n<p>            \/\/ Phase 1<br \/>\n            &#8216;occupation&#8217; => get_post_meta($post->ID, &#8216;sjt_occupation&#8217;, true),<\/p>\n<p>            \/\/ Phase 2<br \/>\n            &#8216;safetyEdu&#8217; => get_post_meta($post->ID, &#8216;sjt_safety_edu&#8217;, true),<br \/>\n            &#8216;safetyGear&#8217; => get_post_meta($post->ID, &#8216;sjt_safety_gear&#8217;, true),<br \/>\n            &#8216;family&#8217; => get_post_meta($post->ID, &#8216;sjt_family&#8217;, true),<\/p>\n<p>            \/\/ Phase 3<br \/>\n            &#8216;insuranceCheck&#8217; => get_post_meta($post->ID, &#8216;sjt_insurance_check&#8217;, true),<\/p>\n<p>            &#8216;status&#8217; => get_post_meta($post->ID, &#8216;sjt_status&#8217;, true),<br \/>\n        );<br \/>\n    }<\/p>\n<p>    return new WP_REST_Response($data, 200);<br \/>\n}<\/p>\n<p>\/\/ 6. (Callback) \uc0ad\uc81c \ucc98\ub9ac<br \/>\nfunction sjt_delete_claim($request)<br \/>\n{<br \/>\n    $id = $request->get_param(&#8216;id&#8217;);<\/p>\n<p>    $post = get_post($id);<br \/>\n    if (!$post || $post->post_type !== &#8216;sjt_claim&#8217;) {<br \/>\n        return new WP_Error(&#8216;invalid_id&#8217;, &#8216;\uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 \uc2e0\uccad \ub0b4\uc5ed\uc785\ub2c8\ub2e4.&#8217;, array(&#8216;status&#8217; => 404));<br \/>\n    }<\/p>\n<p>    $deleted = wp_delete_post($id, true);<\/p>\n<p>    if (!$deleted) {<br \/>\n        return new WP_Error(&#8216;delete_failed&#8217;, &#8216;\uc0ad\uc81c\uc5d0 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4.&#8217;, array(&#8216;status&#8217; => 500));<br \/>\n    }<\/p>\n<p>    return new WP_REST_Response(array(&#8216;success&#8217; => true, &#8216;id&#8217; => $id), 200);<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/** * \ubcf4\uc0c1\ud1a1 \uc0b0\uc7ac \uc2e0\uccad \uad00\ub9ac \uc2dc\uc2a4\ud15c * (functions.php \ub9e8 \uc544\ub798\uc758 \uae30\uc874 \ucf54\ub4dc\ub97c \uc9c0\uc6b0\uace0 \uc774 \ucf54\ub4dc\ub85c \uad50\uccb4\ud574\uc8fc\uc138\uc694) *\/ \/\/ 1. \uc778\uc99d \ud1a0\ud070(Nonce)\uacfc API \uc815\ubcf4 \uc804\ub2ec (\ud5e4\ub354 \uc9c1\uc811 \ucd9c\ub825 \ubc29\uc2dd) add_action(&#8216;wp_head&#8217;, &#8216;sjt_print_api_config&#8217;); function sjt_print_api_config() { $config = array( &#8216;nonce&#8217; => wp_create_nonce(&#8216;wp_rest&#8217;), \/\/ REST API \uc778\uc99d\ud0a4 &#8216;root&#8217; => esc_url_raw(rest_url()), \/\/ API \uae30\ubcf8 \uc8fc\uc18c &#8216;submitUrl&#8217; => esc_url_raw(rest_url(&#8216;sjt\/v1\/submit&#8217;)), &#8216;listUrl&#8217; &#8230; <a title=\"\uad00\ub9ac\uc790 \ud398\uc774\uc9c0\" class=\"read-more\" href=\"https:\/\/bosangtok.kstorytelling.com\/en\/admin-claims\/\" aria-label=\"Read more about \uad00\ub9ac\uc790 \ud398\uc774\uc9c0\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-275","page","type-page","status-publish"],"acf":[],"_links":{"self":[{"href":"https:\/\/bosangtok.kstorytelling.com\/en\/wp-json\/wp\/v2\/pages\/275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bosangtok.kstorytelling.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bosangtok.kstorytelling.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bosangtok.kstorytelling.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bosangtok.kstorytelling.com\/en\/wp-json\/wp\/v2\/comments?post=275"}],"version-history":[{"count":11,"href":"https:\/\/bosangtok.kstorytelling.com\/en\/wp-json\/wp\/v2\/pages\/275\/revisions"}],"predecessor-version":[{"id":301,"href":"https:\/\/bosangtok.kstorytelling.com\/en\/wp-json\/wp\/v2\/pages\/275\/revisions\/301"}],"wp:attachment":[{"href":"https:\/\/bosangtok.kstorytelling.com\/en\/wp-json\/wp\/v2\/media?parent=275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}