maybe_unserialize example

 else {
            $meta_cache = null;
        }
    }

    if ( ! $meta_key ) {
        return $meta_cache;
    }

    if ( isset( $meta_cache[ $meta_key ] ) ) {
        if ( $single ) {
            return maybe_unserialize( $meta_cache[ $meta_key ][0] );
        } else {
            return array_map( 'maybe_unserialize', $meta_cache[ $meta_key ] );
        }
    }

    return null;
}

/** * Retrieves default metadata value for the specified meta key and object. * * By default, an empty string is returned if `$single` is true, or an empty array * if it's false. * * @since 5.5.0 * * @param string $meta_type Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', * or any other object type with an associated meta table. * @param int $object_id ID of the object metadata is for. * @param string $meta_key Metadata key. * @param bool $single Optional. If true, return only the first value of the specified `$meta_key`. * This parameter has no effect if `$meta_key` is not specified. Default false. * @return mixed An array of default values if `$single` is false. * The default value of the meta field if `$single` is true. */

function upgrade_280() {
    global $wp_current_db_version$wpdb;

    if ( $wp_current_db_version < 10360 ) {
        populate_roles_280();
    }
    if ( is_multisite() ) {
        $start = 0;
        while ( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
            foreach ( $rows as $row ) {
                $value = maybe_unserialize( $row->option_value );
                if ( $value === $row->option_value ) {
                    $value = stripslashes( $value );
                }
                if ( $value !== $row->option_value ) {
                    update_option( $row->option_name, $value );
                }
            }
            $start += 20;
        }
        clean_blog_cache( get_current_blog_id() );
    }
}
$users_of_blog = $wpdb->get_col(
            " SELECT meta_value FROM {$wpdb->usermeta} INNER JOIN {$wpdb->users} ON user_id = ID WHERE meta_key = '{$blog_prefix}capabilities' "
        );

        foreach ( $users_of_blog as $caps_meta ) {
            $b_roles = maybe_unserialize( $caps_meta );
            if ( ! is_array( $b_roles ) ) {
                continue;
            }
            if ( empty( $b_roles ) ) {
                $avail_roles['none']++;
            }
            foreach ( $b_roles as $b_role => $val ) {
                if ( isset( $avail_roles[ $b_role ] ) ) {
                    $avail_roles[ $b_role ]++;
                } else {
                    $avail_roles[ $b_role ] = 1;
                }
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 />.     $entry['meta_id']    = (int) $entry['meta_id'];

    
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="<?php echo esc_attr( $option->option_name ); ?>" class="code"><?php echo esc_html( $option->option_name ); ?></label></th> <td><textarea class="

    return apply_filters( "option_{$option}", maybe_unserialize( $value )$option );
}

/** * Protects WordPress special option from being modified. * * Will die if $option is in protected list. Protected options are 'alloptions' * and 'notoptions' options. * * @since 2.2.0 * * @param string $option Option name. */
return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) );
    }

    if ( $signup->active ) {
        if ( empty( $signup->domain ) ) {
            return new WP_Error( 'already_active', __( 'The user is already active.' )$signup );
        } else {
            return new WP_Error( 'already_active', __( 'The site is already active.' )$signup );
        }
    }

    $meta     = maybe_unserialize( $signup->meta );
    $password = wp_generate_password( 12, false );

    $user_id = username_exists( $signup->user_login );

    if ( ! $user_id ) {
        $user_id = wpmu_create_user( $signup->user_login, $password$signup->user_email );
    } else {
        $user_already_exists = true;
    }

    if ( ! $user_id ) {
        
 elseif ( preg_match( '/^{{(?P<symbol>.+)}}$/', $value$matches ) ) {
                if ( isset( $posts[ $matches['symbol'] ] ) ) {
                    $value = $posts[ $matches['symbol'] ]['ID'];
                } elseif ( isset( $attachment_ids[ $matches['symbol'] ] ) ) {
                    $value = $attachment_ids[ $matches['symbol'] ];
                } else {
                    continue;
                }
            }

            // Unserialize values after checking for post symbols, so they can be properly referenced.             $value = maybe_unserialize( $value );

            if ( empty( $changeset_data[ $name ] ) || ! empty( $changeset_data[ $name ]['starter_content'] ) ) {
                $this->set_post_value( $name$value );
                $this->pending_starter_content_settings_ids[] = $name;
            }
        }

        // Theme mods.         foreach ( $theme_mods as $name => $value ) {

            // Serialize the value to check for post symbols.
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_to_update[] = $option->option_name;
        $class               = 'all-options';
    }
Home | Imprint | This part of the site doesn't use cookies.