} }); add_action('wp_insert_comment', function ($comment_id, $comment_object) { if (array_key_exists('xmaps-location-entry', $_POST)) { $location = wp_filter_nohtml_kses($_POST['xmaps-location-entry']); if ($comment_object->comment_approved) { XMapsDatabase::add_or_update_map_object_location($comment_id, 'map-object-comment', $location); } else { update_comment_meta($comment_id, 'xmaps-location', $location); } } }, 99, 2); add_action('comment_unapproved_to_approved', function ($comment) { $location = get_comment_meta($comment->comment_ID, 'xmaps-location', true); if (false !== $location) { XMapsDatabase::add_or_update_map_object_location($comment->comment_ID, 'map-object-comment', $location); } }); add_action('trashed_comment', function ($cid) { XMapsDatabase::delete_map_object_location($cid, 'map-object-comment'); }); add_action('comment_form_logged_in_after', function () { if (get_post_type() == 'map-object') { ?> <input id="xmaps-location-entry" name="xmaps-location-entry" type="hidden" /> <div id="xmaps-controls"> Drawing mode: <select id="xmaps-controls-mode"> <option value="point">Point</option> <option value="area">Area</option> </select>
/** * Save post metadata when a post is saved. * * @param int $post_id The post ID. * @param post $post The post object. * @param bool $update Whether this is an existing post being updated or not. */ public static function on_save_map_object($post_id, $post, $update) { XMapsDatabase::add_or_update_map_object_location($post_id, 'map-object', $_REQUEST['xmaps-location-entry']); XMapsDatabase::add_or_update_map_object_collections($post_id, $_REQUEST['xmaps-map-collection-entry']); }