public function save_post($post_id) { $sidebar_id = $_POST['custom-sidebar-select']; if (isset($_POST['custom-sidebar'])) { $sidebar_id = Custom_Sidebars::get_sidebar_id($post_id); } update_post_meta($post_id, '_custom_sidebar', (bool) $_POST['custom-sidebar']); update_post_meta($post_id, '_custom_sidebar_id', sanitize_text_field($sidebar_id)); }