[wp-trac] [WordPress Trac] #45282: Block Editor: Don't show the Custom Fields meta box option if the meta box has been removed

WordPress Trac noreply at wordpress.org
Mon Nov 5 03:16:45 UTC 2018


#45282: Block Editor: Don't show the Custom Fields meta box option if the meta box
has been removed
--------------------------+---------------------
 Reporter:  pento         |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  5.0
Component:  Editor        |     Version:  5.0
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+---------------------

Comment (by noisysocks):

 Nice! I think 45282.diff is the right approach, and it works well in my
 testing.

 To test this, I:

 1. Created a new post.
 2. Ran `wp.data.select( 'core/editor'
 ).getEditorSettings().enableCustomFields` in the console. It was `false`.
 3. Ran `document.getElementById( 'toggle-custom-fields-form' ).submit()`
 in the console to toggle the custom fields setting.
 4. Ran `wp.data.select( 'core/editor'
 ).getEditorSettings().enableCustomFields` again. It was `true` this time.
 5. Installed, activated, and set up the ACF plugin which I know
 deregisters the `postcustom` meta box.
 6. Created another post.
 4. Ran `wp.data.select( 'core/editor'
 ).getEditorSettings().enableCustomFields` again. It was now `undefined`.

 ----

 The code looks good. Some comments:

 1. It wasn't clear to me at first that `wp.editPost.initializeEditor()`
 was enqueued ''after'' the `block_editor_settings` filter had triggered.
 Could we move `$init_script`'s declaration in `edit-form-blocks.php:335`
 closer to where it is used in `edit-form-blocks.php:395`?
 2. Instead of setting `$editor_settings['enableCustomFields']` in `edit-
 form-blocks.php:300` and then later unsetting it in `edit-form-
 blocks.php:382`, I think it would be clearer if we conditionally set
 `enableCustomFields` in the one place after the meta box hook triggers. We
 do this for other editor settings e.g. `autosave`, `colors`, `fontSizes`.
 3. What does the change in `templates.php:1079` do?

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


More information about the wp-trac mailing list