[wp-trac] [WordPress Trac] #53610: Remove references to Gutenberg specific functions

WordPress Trac noreply at wordpress.org
Tue Jul 6 18:30:55 UTC 2021


#53610: Remove references to Gutenberg specific functions
--------------------------+---------------------
 Reporter:  desrosj       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  5.8
Component:  Editor        |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  dev-feedback  |     Focuses:
--------------------------+---------------------

Comment (by hellofromTonya):

 >The `render_block_core_legacy_widget()` function has calls to
 `gutenberg_get_widget_key()` and `gutenberg_get_widget_object()` (source).
 It seems that this entire conditional block can be removed in favor of the
 first condition's code since WordPress >= 5.8 can be confident the methods
 exist.

 Code in question:
 {{{#!php
 if ( method_exists( $wp_widget_factory, 'get_widget_key' ) &&
 method_exists( $wp_widget_factory, 'get_widget_object' ) ) {
         $widget_key    = $wp_widget_factory->get_widget_key( $id_base );
         $widget_object = $wp_widget_factory->get_widget_object( $id_base
 );
 } else {
         $widget_key    = gutenberg_get_widget_key( $id_base );
         $widget_object = gutenberg_get_widget_object( $id_base );
 }
 }}}


 This `method_exists` and `else` conditional exist for the Gutenberg plugin
 and not for Core. They allow the plugin to run with older versions of
 WordPress. Core doesn't need them.

 They can be removed from Core, simplifying the code to:

 {{{#!php
 $widget_key    = $wp_widget_factory->get_widget_key( $id_base );
 $widget_object = $wp_widget_factory->get_widget_object( $id_base );
 }}}

 However in doing so, the packages in Gutenberg diverge from Core. Other
 parts of merged code have already diverged. But I don't believe the
 packages themselves have.

 Does modifying this function in Core run the risk of being overwritten
 when the Gutenberg packages are updated and merged in later?

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


More information about the wp-trac mailing list