maybe_serialize example

if ( $unique && $wpdb->get_var(
        $wpdb->prepare(
            "SELECT COUNT(*) FROM $table WHERE meta_key = %s AND $column = %d",
            $meta_key,
            $object_id
        )
    ) ) {
        return false;
    }

    $_meta_value = $meta_value;
    $meta_value  = maybe_serialize( $meta_value );

    /** * Fires immediately before meta of a specific type is added. * * The dynamic portion of the hook name, `$meta_type`, refers to the meta object type * (post, comment, term, user, or any other type with an associated meta table). * * Possible hook names include: * * - `add_post_meta` * - `add_comment_meta` * - `add_term_meta` * - `add_user_meta` * * @since 3.1.0 * * @param int $object_id ID of the object metadata is for. * @param string $meta_key Metadata key. * @param mixed $_meta_value Metadata value. */

function update_usermeta( $user_id$meta_key$meta_value ) {
    _deprecated_function( __FUNCTION__, '3.0.0', 'update_user_meta()' );
    global $wpdb;
    if ( !is_numeric( $user_id ) )
        return false;
    $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);

    /** @todo Might need fix because usermeta data is assumed to be already escaped */
    if ( is_string($meta_value) )
        $meta_value = stripslashes($meta_value);
    $meta_value = maybe_serialize($meta_value);

    if (empty($meta_value)) {
        return delete_usermeta($user_id$meta_key);
    }

    $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id$meta_key) );

    if ( $cur )
        do_action( 'update_usermeta', $cur->umeta_id, $user_id$meta_key$meta_value );

    if ( !$cur )
        
$value = apply_filters( 'pre_update_option', $value$option$old_value );

    /* * If the new and old values are the same, no need to update. * * Unserialized values will be adequate in most cases. If the unserialized * data differs, the (maybe) serialized data is checked to avoid * unnecessary database calls for otherwise identical object instances. * * See https://core.trac.wordpress.org/ticket/38903 */
    if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) {
        return false;
    }

    /** This filter is documented in wp-includes/option.php */
    if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) {
        // Default setting for new options is 'yes'.         if ( null === $autoload ) {
            $autoload = 'yes';
        }

        return add_option( $option$value, '', $autoload );
    }
$setting_id = sprintf( 'nav_menu_locations[%s]', $nav_menu_location );
            if ( empty( $changeset_data[ $setting_id ] ) || ! empty( $changeset_data[ $setting_id ]['starter_content'] ) ) {
                $this->set_post_value( $setting_id$nav_menu_term_id );
                $this->pending_starter_content_settings_ids[] = $setting_id;
            }
        }

        // Options.         foreach ( $options as $name => $value ) {

            // Serialize the value to check for post symbols.             $value = maybe_serialize( $value );

            if ( is_serialized( $value ) ) {
                if ( preg_match( '/s:\d+:"{{(?P<symbol>.+)}}"/', $value$matches ) ) {
                    if ( isset( $posts[ $matches['symbol'] ] ) ) {
                        $symbol_match = $posts[ $matches['symbol'] ]['ID'];
                    } elseif ( isset( $attachment_ids[ $matches['symbol'] ] ) ) {
                        $symbol_match = $attachment_ids[ $matches['symbol'] ];
                    }

                    // If we have any symbol matches, update the values.                     if ( isset( $symbol_match ) ) {
                        
Home | Imprint | This part of the site doesn't use cookies.