Make WordPress Core

Opened 8 years ago

Closed 4 years ago

Last modified 4 years ago

#37626 closed enhancement (maybelater)

Filter for _list_meta_row function to show the serialized array/object in the admin

Reported by: implenton's profile implenton Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.6
Component: Posts, Post Types Keywords:
Focuses: administration Cc:


At the moment when the meta_value is a serialized object or array it does not show up in the Admin Custom Fields.

While I understand that editing a serialized array/object is not the same as editing a string, I also find it useful to quickly peek at the meta value.

If the rationality behind this decision was not letting the user edit by mistake the serialized value, then by using a filter we could show the meta row with the textarea field set with the readonly attribute.

Something like this:


$skip_serialized_array_or_object_on_list_meta_row = apply_filters( 'skip_serialized_array_or_object_on_list_meta_row', '__return_true' );

if ( true == $skip_serialized_array_or_object_on_list_meta_row ) {
    return '';

and adding the readonly attribute for the textarea

if ( is_serialized( $entry['meta_value'] ) && ! is_serialized_string( $entry['meta_value'] ) ) {

    $skip_serialized_array_or_object_on_list_meta_row = apply_filters( 'skip_serialized_array_or_object_on_list_meta_row', '__return_true' );

    if ( true == $skip_serialized_array_or_object_on_list_meta_row ) {

        $r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>" . __( 'Value' ) . "</label><textarea readonly name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";


} else {

    $r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";


This implementation is just a quick prototype. In case this is considered by the community something useful, then I could provide some variations or somebody else.

Change History (4)

#1 @implenton
8 years ago

Just remembered, what I am suggesting is not something that is esoteric or unknown for WordPress, in wp-admin/options.php when the data is a serialized array/object you get "SERIALIZED DATA" with a disabled input.

What I am looking for is an option for something like this, but instead the "SERIALIZED DATA" the real data.

This ticket was mentioned in Slack in #core by noisysocks. View the logs.

4 years ago

#3 follow-up: @whyisjake
4 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

@implenton Thanks for contributing this ticket. While a great idea, there are some practical problems here with how a user could interact with unserialized data that needs to be serialized again before it hits the DB.

A misplaced comma, quote, or more could destroy the data. Going to close with a wontfix. For those that want to take it further, I would look into the API.

#4 in reply to: ↑ 3 @SergeyBiryukov
4 years ago

  • Component changed from General to Posts, Post Types
  • Resolution changed from wontfix to maybelater

Replying to whyisjake:

A misplaced comma, quote, or more could destroy the data.

Hence the suggested readonly attribute on the input. If understand the ticket correctly, it's not about editing the value, but about viewing it.

Changing the resolution to maybelater in case someone wants to pick this up.

Note: See TracTickets for help on using tickets.