Make WordPress Core

Ticket #55448: 55448.patch

File 55448.patch, 1.4 KB (added by stiofansisland, 3 years ago)

Fix

  • src/wp-includes/widgets/class-wp-widget-block.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    5959        public function widget( $args, $instance ) {
    6060                $instance = wp_parse_args( $instance, $this->default_instance );
    6161
    62                 echo str_replace(
    63                         'widget_block',
    64                         $this->get_dynamic_classname( $instance['content'] ),
    65                         $args['before_widget']
    66                 );
    67 
    6862                /**
    6963                 * Filters the content of the Block widget before output.
    7064                 *
     
    7468                 * @param array           $instance Array of settings for the current widget.
    7569                 * @param WP_Widget_Block $widget   Current Block widget instance.
    7670                 */
    77                 echo apply_filters(
     71                $content = apply_filters(
    7872                        'widget_block_content',
    7973                        $instance['content'],
    8074                        $instance,
    8175                        $this
    8276                );
    8377
    84                 echo $args['after_widget'];
     78                // only output content if it exists, this prevents empty boxes on pages.
     79                if ( ! empty( $content ) ) {
     80
     81                        echo str_replace(
     82                                'widget_block',
     83                                $this->get_dynamic_classname( $instance['content'] ),
     84                                $args['before_widget']
     85                        );
     86
     87                        echo $content;
     88
     89                        echo $args['after_widget'];
     90
     91                }
     92
    8593        }
    8694
    8795        /**