diff --git wp-includes/formatting.php wp-includes/formatting.php
index cb35f2d..c81073c 100644
--- wp-includes/formatting.php
+++ wp-includes/formatting.php
@@ -4715,6 +4715,31 @@ function sanitize_textarea_field( $str ) {
 }
 
 /**
+ * Sanitizes a checkbox or radio elements value.
+ *
+ * @since 4.9.0
+ *
+ * @param mixed $value Checkbox or radio value to sanitize.
+ * @return string Sanitized value.
+ */
+function sanitize_checkbox_radio( $value ) {
+	/* As checkboxes and radios can have custom values,
+	 * we can't always return 'on'/'off' values each time. Instead
+	 * we can sanitize the value using the text fields functions
+	 * which will do everything we need it to.
+	 */
+	$filtered = _sanitize_text_fields( $value, false );
+
+	/**
+	 * Filters the value of a checkbox/radio.
+	 * 
+	 * @param string $filtered The sanitized checkbox value.
+	 * @param mixed  $value    The checkbox before being sanitized.
+	 */
+	return apply_filters( 'sanitize_checkbox_radio', $filtered, $value );
+}
+
+/**
  * Internal helper function to sanitize a string from user input or from the db
  *
  * @since 4.7.0
