WordPress.org

Make WordPress Core

Ticket #41021: 40951.0.diff

File 40951.0.diff, 2.6 KB (added by westonruter, 3 years ago)
  • src/wp-includes/widgets/class-wp-widget-media.php

    diff --git src/wp-includes/widgets/class-wp-widget-media.php src/wp-includes/widgets/class-wp-widget-media.php
    index c76989c873..1724b23780 100644
    abstract class WP_Widget_Media extends WP_Widget { 
    3434        );
    3535
    3636        /**
     37         * Whether or not the widget has been registered yet.
     38         *
     39         * @since 4.8.1
     40         * @var bool
     41         */
     42        protected $registered = false;
     43
     44        /**
    3745         * Constructor.
    3846         *
    3947         * @since 4.8.0
    abstract class WP_Widget_Media extends WP_Widget { 
    8795         * @since 4.8.0
    8896         * @access public
    8997         */
    90         public function _register() {
     98        public function _register_one() {
     99                parent::_register_one();
     100                if ( $this->registered ) {
     101                        return;
     102                }
     103                $this->registered = true;
    91104
    92105                // Note that the widgets component in the customizer will also do the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts().
    93106                add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) );
    abstract class WP_Widget_Media extends WP_Widget { 
    100113                add_action( 'admin_footer-widgets.php', array( $this, 'render_control_template_scripts' ) );
    101114
    102115                add_filter( 'display_media_states', array( $this, 'display_media_state' ), 10, 2 );
    103 
    104                 parent::_register();
    105116        }
    106117
    107118        /**
  • src/wp-includes/widgets/class-wp-widget-text.php

    diff --git src/wp-includes/widgets/class-wp-widget-text.php src/wp-includes/widgets/class-wp-widget-text.php
    index 7d149c0a0f..14dc7b38bb 100644
     
    1717class WP_Widget_Text extends WP_Widget {
    1818
    1919        /**
     20         * Whether or not the widget has been registered yet.
     21         *
     22         * @since 4.8.1
     23         * @var bool
     24         */
     25        protected $registered = false;
     26
     27        /**
    2028         * Sets up a new Text widget instance.
    2129         *
    2230         * @since 2.8.0
    class WP_Widget_Text extends WP_Widget { 
    4149         * @since 4.8.0
    4250         * @access public
    4351         */
    44         public function _register() {
     52        public function _register_one() {
     53                parent::_register_one();
     54                if ( $this->registered ) {
     55                        return;
     56                }
     57                $this->registered = true;
    4558
    4659                // Note that the widgets component in the customizer will also do the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts().
    4760                add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) );
    4861
    4962                // Note that the widgets component in the customizer will also do the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts().
    5063                add_action( 'admin_footer-widgets.php', array( $this, 'render_control_template_scripts' ) );
    51 
    52                 parent::_register();
    5364        }
    5465
    5566        /**