_wp_json_convert_string example


function _wp_json_sanity_check( $data$depth ) {
    if ( $depth < 0 ) {
        throw new Exception( 'Reached depth limit' );
    }

    if ( is_array( $data ) ) {
        $output = array();
        foreach ( $data as $id => $el ) {
            // Don't forget to sanitize the ID!             if ( is_string( $id ) ) {
                $clean_id = _wp_json_convert_string( $id );
            } else {
                $clean_id = $id;
            }

            // Check the element type, so that we're only recursing if we really have to.             if ( is_array( $el ) || is_object( $el ) ) {
                $output[ $clean_id ] = _wp_json_sanity_check( $el$depth - 1 );
            } elseif ( is_string( $el ) ) {
                $output[ $clean_id ] = _wp_json_convert_string( $el );
            } else {
                $output[ $clean_id ] = $el;
            }
Home | Imprint | This part of the site doesn't use cookies.