diff --git a/includes/base/element-base.php b/includes/base/element-base.php index fd2857a7631..77bef1c906e 100644 --- a/includes/base/element-base.php +++ b/includes/base/element-base.php @@ -624,6 +624,14 @@ public function print_render_attribute_string( $element ) { * @access public */ public function print_element() { + ob_start(); + $this->_print_content(); + $content = ob_get_clean(); + + if ( empty( $content ) ) { + return; + } + $element_type = $this->get_type(); /** @@ -653,7 +661,7 @@ public function print_element() { $this->_add_render_attributes(); $this->before_render(); - $this->_print_content(); + echo $content; $this->after_render(); $this->enqueue_scripts(); diff --git a/includes/base/widget-base.php b/includes/base/widget-base.php index af39f7bb03f..f912ca1c647 100644 --- a/includes/base/widget-base.php +++ b/includes/base/widget-base.php @@ -465,6 +465,22 @@ protected function _add_render_attributes() { * @access public */ public function render_content() { + ob_start(); + + $skin = $this->get_current_skin(); + if ( $skin ) { + $skin->set_parent( $this ); + $skin->render(); + } else { + $this->render(); + } + + $widget_content = ob_get_clean(); + + if ( empty( $widget_content ) ) { + return; + } + /** * Before widget render content. * @@ -483,17 +499,6 @@ public function render_content() { ?>