is_serialized_string example

<?php $options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" );

foreach ( (array) $options as $option ) :
    $disabled = false;

    if ( '' === $option->option_name ) {
        continue;
    }

    if ( is_serialized( $option->option_value ) ) {
        if ( is_serialized_string( $option->option_value ) ) {
            // This is a serialized string, so we should display it.             $value               = maybe_unserialize( $option->option_value );
            $options_to_update[] = $option->option_name;
            $class               = 'all-options';
        } else {
            $value    = 'SERIALIZED DATA';
            $disabled = true;
            $class    = 'all-options disabled';
        }
    } else {
        $value               = $option->option_value;
        
$options     = $wpdb->get_results( $query );

        foreach ( $options as $option ) {
            if ( 'default_role' === $option->option_name ) {
                $editblog_default_role = $option->option_value;
            }

            $disabled = false;
            $class    = 'all-options';

            if ( is_serialized( $option->option_value ) ) {
                if ( is_serialized_string( $option->option_value ) ) {
                    $option->option_value = esc_html( maybe_unserialize( $option->option_value ) );
                } else {
                    $option->option_value = 'SERIALIZED DATA';
                    $disabled             = true;
                    $class                = 'all-options disabled';
                }
            }

            if ( str_contains( $option->option_value, "\n" ) ) {
                ?> <tr class="form-field"> <th scope="row"><label for="
return '';
    }

    if ( ! $update_nonce ) {
        $update_nonce = wp_create_nonce( 'add-meta' );
    }

    $r = '';
    ++$count;

    if ( is_serialized( $entry['meta_value'] ) ) {
        if ( is_serialized_string( $entry['meta_value'] ) ) {
            // This is a serialized string, so we should display it.             $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
        } else {
            // This is a serialized array/object so we should NOT display it.             --$count;
            return '';
        }
    }

    $entry['meta_key']   = esc_attr( $entry['meta_key'] );
    $entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // Using a <textarea />.
Home | Imprint | This part of the site doesn't use cookies.