[wp-trac] [WordPress Trac] #37626: Filter for _list_meta_row function to show the serialized array/object in the admin

WordPress Trac noreply at wordpress.org
Wed Aug 10 18:01:41 UTC 2016


#37626: Filter for _list_meta_row function to show the serialized array/object in
the admin
----------------------------+-----------------------------
 Reporter:  implenton       |      Owner:
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  General         |    Version:  trunk
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 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.

 [[Image(https://cldup.com/W-7mNEs_Vk.png)]]

 Something like this:

 wp-admin/includes/template.php:544

 {{{
 $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 ) {
     --$count;
     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.''

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37626>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list