Skip to content

Commit

Permalink
Element & Widget: Fix - Don't render wrapper if the content is empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
matipojo committed Nov 1, 2018
1 parent b657d7c commit 6a9843a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
10 changes: 9 additions & 1 deletion includes/base/element-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/**
Expand Down Expand Up @@ -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();
Expand Down
27 changes: 16 additions & 11 deletions includes/base/widget-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -483,17 +499,6 @@ public function render_content() {
?>
<div class="elementor-widget-container">
<?php
ob_start();

$skin = $this->get_current_skin();
if ( $skin ) {
$skin->set_parent( $this );
$skin->render();
} else {
$this->render();
}

$widget_content = ob_get_clean();

/**
* Render widget content.
Expand Down

0 comments on commit 6a9843a

Please sign in to comment.