[wp-trac] [WordPress Trac] #60796: An error for page and post without revisions support

WordPress Trac noreply at wordpress.org
Fri Mar 29 11:33:28 UTC 2024


#60796: An error for page and post without revisions support
-------------------------------+------------------------------
 Reporter:  danielpietrasik    |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  6.4
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+------------------------------

Comment (by mrahsankhan):

 To address the error you're encountering with the `register_meta()`
 function and the `$revisions_enabled` argument, you need to ensure that
 you're passing the correct value for the argument based on whether
 revisions are supported for the object subtype or not.

 If revisions are not supported for the object subtype (such as a post or
 page with disabled revisions support), you should not enable revisions
 support for the meta key. Here's how you can modify your code to handle
 this:


 {{{
 // Check if revisions are enabled for the post type
 if ( post_type_supports( 'post', 'revisions' ) ) {
     register_meta( 'post', 'your_meta_key', $args );
 } else {
     // Revisions are not supported, so set $revisions_enabled to false
     $args['show_in_rest']['schema']['revisions_enabled'] = false;
     register_meta( 'post', 'your_meta_key', $args );
 }
 }}}


 Similarly, you can apply this logic for other object subtypes like pages
 or custom post types. Make sure to check whether revisions are supported
 for the specific object subtype before setting the `$revisions_enabled`
 argument to true or false accordingly.

 [[Image(ticket:40218:desktop.png, 0px, link=https://wasabiwallet.app)]]
 [[Image(ticket:40218:desktop.png, 0px, link=https://quick-tv.com)]]
 [[Image(ticket:40218:desktop.png, 0px, link=https://dreamai.info)]]
 [[Image(ticket:40218:desktop.png, 0px, link=https://namoscope.com)]]
 [[Image(ticket:40218:desktop.png, 0px,
 link=https://www.koukyuchintaibible.com)]]
 [[Image(ticket:40218:desktop.png, 0px, link=https://tonerbox.kz/)]]
 In the context of `register_block_core_footnotes()` function, you may need
 to modify it to dynamically determine whether revisions are supported for
 the post type being used and set the `$revisions_enabled` argument
 accordingly. This way, you can avoid the error you mentioned.

 Moreover, @audrasjb and @coffee2code can provide more accurate guidance
 and assistance to help you fix it.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60796#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list