[wp-trac] [WordPress Trac] #51258: Fire an action when `replace_editor` is filtered to true

WordPress Trac noreply at wordpress.org
Sat Sep 5 23:30:22 UTC 2020


#51258: Fire an action when `replace_editor` is filtered to true
----------------------------+-----------------------------
 Reporter:  jeremyfelt      |      Owner:  (none)
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Editor          |    Version:  4.9
 Severity:  normal          |   Keywords:  has-patch
  Focuses:  administration  |
----------------------------+-----------------------------
 The `replace_editor` filter was added during the development of Gutenberg
 to make it possible to implement multiple editor options. See [41829].

 Gutenberg
 [https://github.com/WordPress/gutenberg/blame/08da64b407e95683946b34cf6ebca5d52ac28227/gutenberg.php
 previously used this filter] to inject necessary hooks and markup before
 returning `true` to indicate that the editor had been replaced.

 The `replace_editor` filter is no longer used by the block editor or the
 Gutenberg plugin—as it has become the editor. Instead, we rely on
 `use_block_editor_for_post()` to determine whether the block or classic
 interface should load.

 In the current state, if `true` is returned via `replace_editor`, the
 current screen is set and the admin footer markup is loaded. There is no
 clean opportunity to add markup or other logic. This can be done during
 the filter, but that does not provide a clean pattern, especially if one
 or more pieces of code may be making a decision on editor replacement. See
 #50216 for a description of how it may fire multiple times.

 The patch attached to this ticket adds a `replaced_editor` action in the
 `post-new.php` and `post.php` files so that plugins can cleanly inject
 replacement editor code.

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


More information about the wp-trac mailing list