elementor / elementor

The most advanced frontend drag & drop page builder. Create high-end, pixel perfect websites at record speeds. Any theme, any page, any design.
https://elementor.com/
GNU General Public License v3.0
6.51k stars 1.41k forks source link

Elementor calling shortcodes multiple times #9326

Open Bellian opened 4 years ago

Bellian commented 4 years ago

Hi, I am running into an issue where Elementor triggers the shortcodes inside a Widget_Shortcode multiple times per site render, leading to woocommerce notifications to be dropped (and apparently the site to rendered twice)

This may have something to do with the Theme builder, since i use a theme from the Elementor Theme Builder.

The shortcode I am using is:

[woocommerce_my_account] 

First stacktrace leading to woocommerce_output_all_notices:

woocommerce_output_all_notices (<webroot>\wp-content\plugins\woocommerce\includes\wc-template-functions.php:3622)
WP_Hook->apply_filters (<webroot>\wp-includes\class-wp-hook.php:286)
WP_Hook->do_action (<webroot>\wp-includes\class-wp-hook.php:310)
do_action (<webroot>\wp-includes\plugin.php:465)
include (<webroot>\wp-content\themes\storefront-child\woocommerce\myaccount\form-login.php:22)
wc_get_template (<webroot>\wp-content\plugins\woocommerce\includes\wc-core-functions.php:249)
WC_Shortcode_My_Account::output (<webroot>\wp-content\plugins\woocommerce\includes\shortcodes\class-wc-shortcode-my-account.php:57)
WC_Shortcodes::shortcode_wrapper (<webroot>\wp-content\plugins\woocommerce\includes\class-wc-shortcodes.php:72)
WC_Shortcodes::my_account (<webroot>\wp-content\plugins\woocommerce\includes\class-wc-shortcodes.php:115)
do_shortcode_tag (<webroot>\wp-includes\shortcodes.php:325)
preg_replace_callback (<webroot>\wp-includes\shortcodes.php:199)
do_shortcode (<webroot>\wp-includes\shortcodes.php:199)
Elementor\Widget_Shortcode->render (<webroot>\wp-content\plugins\elementor\includes\widgets\shortcode.php:130)
Elementor\Widget_Shortcode->render_content (<webroot>\wp-content\plugins\elementor\includes\base\widget-base.php:448)
Elementor\Widget_Shortcode->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\widget-base.php:578)
Elementor\Widget_Shortcode->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
Elementor\Element_Column->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:808)
Elementor\Element_Column->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
Elementor\Element_Section->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:808)
Elementor\Element_Section->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
Elementor\Core\DocumentTypes\Post->print_elements (<webroot>\wp-content\plugins\elementor\core\base\document.php:1162)
Elementor\Core\DocumentTypes\Post->print_elements_with_wrapper (<webroot>\wp-content\plugins\elementor\core\base\document.php:810)
Elementor\Frontend->get_builder_content (<webroot>\wp-content\plugins\elementor\includes\frontend.php:913)
ElementorPro\Modules\ThemeBuilder\Widgets\Post_Content->render (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\widgets\post-content.php:153)
ElementorPro\Modules\ThemeBuilder\Widgets\Post_Content->render_content (<webroot>\wp-content\plugins\elementor\includes\base\widget-base.php:448)
ElementorPro\Modules\ThemeBuilder\Widgets\Post_Content->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\widget-base.php:578)
ElementorPro\Modules\ThemeBuilder\Widgets\Post_Content->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
Elementor\Element_Column->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:808)
Elementor\Element_Column->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
Elementor\Element_Section->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:808)
Elementor\Element_Section->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
ElementorPro\Modules\ThemeBuilder\Documents\Single->print_elements (<webroot>\wp-content\plugins\elementor\core\base\document.php:1162)
ElementorPro\Modules\ThemeBuilder\Documents\Single->print_elements_with_wrapper (<webroot>\wp-content\plugins\elementor\core\base\document.php:810)
Elementor\Frontend->get_builder_content (<webroot>\wp-content\plugins\elementor\includes\frontend.php:913)
ElementorPro\Modules\ThemeBuilder\Documents\Single->get_content (<webroot>\wp-content\plugins\elementor\core\base\document.php:857)
ElementorPro\Modules\ThemeBuilder\Documents\Single->get_content (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\documents\theme-document.php:60)
ElementorPro\Modules\ThemeBuilder\Documents\Single->print_content (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\documents\theme-document.php:73)
ElementorPro\Modules\ThemeBuilder\Documents\Single->print_content (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\documents\single.php:98)
ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager->do_location (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\classes\locations-manager.php:305)
ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager->ElementorPro\Modules\ThemeBuilder\Classes\{closure:<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\classes\locations-manager.php:180-182} (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\classes\locations-manager.php:181)
call_user_func:{<webroot>\wp-content\plugins\elementor\modules\page-templates\module.php:193} (<webroot>\wp-content\plugins\elementor\modules\page-templates\module.php:193)
Elementor\Modules\PageTemplates\Module->print_content (<webroot>\wp-content\plugins\elementor\modules\page-templates\module.php:193)
include (<webroot>\wp-content\plugins\elementor\modules\page-templates\templates\header-footer.php:19)
require_once (<webroot>\wp-includes\template-loader.php:77)
require (<webroot>\wp-blog-header.php:19)
{main} (<webroot>\index.php:17)

Second stacktrace leading to woocommerce_output_all_notices:

wc_print_notices (<webroot>\wp-content\plugins\woocommerce\includes\wc-notice-functions.php:152)
woocommerce_output_all_notices (<webroot>\wp-content\plugins\woocommerce\includes\wc-template-functions.php:3622)
WP_Hook->apply_filters (<webroot>\wp-includes\class-wp-hook.php:286)
WP_Hook->do_action (<webroot>\wp-includes\class-wp-hook.php:310)
do_action (<webroot>\wp-includes\plugin.php:465)
include (<webroot>\wp-content\themes\storefront-child\woocommerce\myaccount\form-login.php:22)
wc_get_template (<webroot>\wp-content\plugins\woocommerce\includes\wc-core-functions.php:249)
WC_Shortcode_My_Account::output (<webroot>\wp-content\plugins\woocommerce\includes\shortcodes\class-wc-shortcode-my-account.php:57)
WC_Shortcodes::shortcode_wrapper (<webroot>\wp-content\plugins\woocommerce\includes\class-wc-shortcodes.php:72)
WC_Shortcodes::my_account (<webroot>\wp-content\plugins\woocommerce\includes\class-wc-shortcodes.php:115)
do_shortcode_tag (<webroot>\wp-includes\shortcodes.php:325)
preg_replace_callback (<webroot>\wp-includes\shortcodes.php:199)
do_shortcode (<webroot>\wp-includes\shortcodes.php:199)
Elementor\Widget_Shortcode->render (<webroot>\wp-content\plugins\elementor\includes\widgets\shortcode.php:130)
Elementor\Widget_Shortcode->render_content (<webroot>\wp-content\plugins\elementor\includes\base\widget-base.php:448)
Elementor\Widget_Shortcode->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\widget-base.php:578)
Elementor\Widget_Shortcode->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
Elementor\Element_Column->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:808)
Elementor\Element_Column->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
Elementor\Element_Section->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:808)
Elementor\Element_Section->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
Elementor\Core\DocumentTypes\Post->print_elements (<webroot>\wp-content\plugins\elementor\core\base\document.php:1162)
Elementor\Core\DocumentTypes\Post->print_elements_with_wrapper (<webroot>\wp-content\plugins\elementor\core\base\document.php:810)
Elementor\Frontend->get_builder_content (<webroot>\wp-content\plugins\elementor\includes\frontend.php:913)
Elementor\Frontend->apply_builder_in_content (<webroot>\wp-content\plugins\elementor\includes\frontend.php:827)
WP_Hook->apply_filters (<webroot>\wp-includes\class-wp-hook.php:286)
apply_filters (<webroot>\wp-includes\plugin.php:208)
ElementorPro\Modules\ThemeBuilder\Widgets\Post_Content->render (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\widgets\post-content.php:180)
ElementorPro\Modules\ThemeBuilder\Widgets\Post_Content->render_content (<webroot>\wp-content\plugins\elementor\includes\base\widget-base.php:448)
ElementorPro\Modules\ThemeBuilder\Widgets\Post_Content->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\widget-base.php:578)
ElementorPro\Modules\ThemeBuilder\Widgets\Post_Content->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
Elementor\Element_Column->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:808)
Elementor\Element_Column->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
Elementor\Element_Section->_print_content (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:808)
Elementor\Element_Section->print_element (<webroot>\wp-content\plugins\elementor\includes\base\element-base.php:592)
ElementorPro\Modules\ThemeBuilder\Documents\Single->print_elements (<webroot>\wp-content\plugins\elementor\core\base\document.php:1162)
ElementorPro\Modules\ThemeBuilder\Documents\Single->print_elements_with_wrapper (<webroot>\wp-content\plugins\elementor\core\base\document.php:810)
Elementor\Frontend->get_builder_content (<webroot>\wp-content\plugins\elementor\includes\frontend.php:913)
ElementorPro\Modules\ThemeBuilder\Documents\Single->get_content (<webroot>\wp-content\plugins\elementor\core\base\document.php:857)
ElementorPro\Modules\ThemeBuilder\Documents\Single->get_content (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\documents\theme-document.php:60)
ElementorPro\Modules\ThemeBuilder\Documents\Single->print_content (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\documents\theme-document.php:73)
ElementorPro\Modules\ThemeBuilder\Documents\Single->print_content (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\documents\single.php:98)
ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager->do_location (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\classes\locations-manager.php:305)
ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager->ElementorPro\Modules\ThemeBuilder\Classes\{closure:<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\classes\locations-manager.php:180-182} (<webroot>\wp-content\plugins\elementor-pro\modules\theme-builder\classes\locations-manager.php:181)
call_user_func:{<webroot>\wp-content\plugins\elementor\modules\page-templates\module.php:193} (<webroot>\wp-content\plugins\elementor\modules\page-templates\module.php:193)
Elementor\Modules\PageTemplates\Module->print_content (<webroot>\wp-content\plugins\elementor\modules\page-templates\module.php:193)
include (<webroot>\wp-content\plugins\elementor\modules\page-templates\templates\header-footer.php:19)
require_once (<webroot>\wp-includes\template-loader.php:77)
require (<webroot>\wp-blog-header.php:19)
{main} (<webroot>\index.php:17)

Apparently Post_Content->render first calls $content = Plugin::elementor()->frontend->get_builder_content( $post->ID, true ); which will trigger Widget_Shortcode->render and therefore trigger woocommerce_output_all_notices.

Later in Post_Content->render the the_content filter is triggered wich results in reevaluating the shortcode and again trigger woocommerce_output_all_notices.

mdca commented 3 years ago

Same here - fired twice so it breaks the wc_print_notices() function.