Make WordPress Core

Ticket #41810: 41810.2.diff

File 41810.2.diff, 1.1 KB (added by danieltj, 8 years ago)

Filters the value for checkbox and radio elements.

  • wp-includes/formatting.php

    diff --git wp-includes/formatting.php wp-includes/formatting.php
    index cb35f2d..c81073c 100644
    function sanitize_textarea_field( $str ) { 
    47154715}
    47164716
    47174717/**
     4718 * Sanitizes a checkbox or radio elements value.
     4719 *
     4720 * @since 4.9.0
     4721 *
     4722 * @param mixed $value Checkbox or radio value to sanitize.
     4723 * @return string Sanitized value.
     4724 */
     4725function sanitize_checkbox_radio( $value ) {
     4726        /* As checkboxes and radios can have custom values,
     4727         * we can't always return 'on'/'off' values each time. Instead
     4728         * we can sanitize the value using the text fields functions
     4729         * which will do everything we need it to.
     4730         */
     4731        $filtered = _sanitize_text_fields( $value, false );
     4732
     4733        /**
     4734         * Filters the value of a checkbox/radio.
     4735         *
     4736         * @param string $filtered The sanitized checkbox value.
     4737         * @param mixed  $value    The checkbox before being sanitized.
     4738         */
     4739        return apply_filters( 'sanitize_checkbox_radio', $filtered, $value );
     4740}
     4741
     4742/**
    47184743 * Internal helper function to sanitize a string from user input or from the db
    47194744 *
    47204745 * @since 4.7.0