Elementor 自定义小部件 - _content_template 功能挂起
Elementor Custom Widget - _content_template function hanging
我有一个 _content_template()
函数,看起来像这样
所以我面临的问题是,如果我在这个函数内部调用 $this->get_settings_for_display();
,elementor 只会加载,什么也不会发生,它只会停留在加载屏幕上(见底部图片),我有render()
中的代码完全相同,我遇到了同样的问题。
protected function _content_template(){
$isInternational = false; // DEFAULT TO INTERNATIONAL
$settings = $this->get_settings_for_display();
// SOLO
$solo_pricing_monthly = $isInternational ? $settings['label_us_pricing_solo_monthly'] : $settings['label_za_pricing_solo_monthly'];
$solo_pricing_monthly_with_marketing = $isInternational ? $settings['label_us_pricing_solo_monthly_with_marketing'] : $settings['label_za_pricing_solo_monthly_with_marketing'];
$solo_pricing_yearly = $isInternational ? $settings['label_us_pricing_solo_yearly'] : $settings['label_za_pricing_solo_yearly'];
$solo_pricing_yearly_with_marketing = $isInternational ? $settings['label_us_pricing_solo_yearly_with_marketing'] : $settings['label_za_pricing_solo_yearly_with_marketing'];
// LITE
$lite_pricing_monthly = $isInternational ? $settings['label_us_pricing_lite_monthly'] : $settings['label_za_pricing_lite_monthly'];
$lite_pricing_monthly_with_marketing = $isInternational ? $settings['label_us_pricing_lite_monthly_with_marketing'] : $settings['label_za_pricing_lite_monthly_with_marketing'];
$lite_pricing_yearly = $isInternational ? $settings['label_us_pricing_lite_yearly'] : $settings['label_za_pricing_lite_yearly'];
$lite_pricing_yearly_with_marketing = $isInternational ? $settings['label_us_pricing_lite_yearly_with_marketing'] : $settings['label_za_pricing_lite_yearly_with_marketing'];
// BUSINESS LITE
$business_lite_pricing_monthly = $isInternational ? $settings['label_us_pricing_business_lite_monthly'] : $settings['label_za_pricing_business_lite_monthly'];
$business_lite_pricing_monthly_with_marketing = $isInternational ? $settings['label_us_pricing_business_lite_monthly_with_marketing'] : $settings['label_za_pricing_business_lite_monthly_with_marketing'];
$business_lite_pricing_yearly = $isInternational ? $settings['label_us_pricing_business_lite_yearly'] : $settings['label_za_pricing_business_lite_yearly'];
$business_lite_pricing_yearly_with_marketing = $isInternational ? $settings['label_us_pricing_business_lite_yearly_with_marketing'] : $settings['label_za_pricing_business_lite_yearly_with_marketing'];
// BUSINESS PRO
$business_pro_pricing_monthly = $isInternational ? $settings['label_us_pricing_business_pro_monthly'] : $settings['label_za_pricing_business_pro_monthly'];
$business_pro_pricing_monthly_with_marketing = $isInternational ? $settings['label_us_pricing_business_pro_monthly_with_marketing'] : $settings['label_za_pricing_business_pro_monthly_with_marketing'];
$business_pro_pricing_yearly = $isInternational ? $settings['label_us_pricing_business_pro_yearly'] : $settings['label_za_pricing_business_pro_yearly'];
$business_pro_pricing_yearly_with_marketing = $isInternational ? $settings['label_us_pricing_business_pro_yearly_with_marketing'] : $settings['label_za_pricing_business_pro_yearly_with_marketing'];
?>
<h2><?php echo $solo_pricing_monthly; ?></h2>
<?php
// more code here
_content_template()
函数从 Elementor 版本 2.9.0
弃用
protected function content_template(){ }
使用不带 _(下划线)字符的函数,它将完美运行。
我有一个 _content_template()
函数,看起来像这样
所以我面临的问题是,如果我在这个函数内部调用 $this->get_settings_for_display();
,elementor 只会加载,什么也不会发生,它只会停留在加载屏幕上(见底部图片),我有render()
中的代码完全相同,我遇到了同样的问题。
protected function _content_template(){
$isInternational = false; // DEFAULT TO INTERNATIONAL
$settings = $this->get_settings_for_display();
// SOLO
$solo_pricing_monthly = $isInternational ? $settings['label_us_pricing_solo_monthly'] : $settings['label_za_pricing_solo_monthly'];
$solo_pricing_monthly_with_marketing = $isInternational ? $settings['label_us_pricing_solo_monthly_with_marketing'] : $settings['label_za_pricing_solo_monthly_with_marketing'];
$solo_pricing_yearly = $isInternational ? $settings['label_us_pricing_solo_yearly'] : $settings['label_za_pricing_solo_yearly'];
$solo_pricing_yearly_with_marketing = $isInternational ? $settings['label_us_pricing_solo_yearly_with_marketing'] : $settings['label_za_pricing_solo_yearly_with_marketing'];
// LITE
$lite_pricing_monthly = $isInternational ? $settings['label_us_pricing_lite_monthly'] : $settings['label_za_pricing_lite_monthly'];
$lite_pricing_monthly_with_marketing = $isInternational ? $settings['label_us_pricing_lite_monthly_with_marketing'] : $settings['label_za_pricing_lite_monthly_with_marketing'];
$lite_pricing_yearly = $isInternational ? $settings['label_us_pricing_lite_yearly'] : $settings['label_za_pricing_lite_yearly'];
$lite_pricing_yearly_with_marketing = $isInternational ? $settings['label_us_pricing_lite_yearly_with_marketing'] : $settings['label_za_pricing_lite_yearly_with_marketing'];
// BUSINESS LITE
$business_lite_pricing_monthly = $isInternational ? $settings['label_us_pricing_business_lite_monthly'] : $settings['label_za_pricing_business_lite_monthly'];
$business_lite_pricing_monthly_with_marketing = $isInternational ? $settings['label_us_pricing_business_lite_monthly_with_marketing'] : $settings['label_za_pricing_business_lite_monthly_with_marketing'];
$business_lite_pricing_yearly = $isInternational ? $settings['label_us_pricing_business_lite_yearly'] : $settings['label_za_pricing_business_lite_yearly'];
$business_lite_pricing_yearly_with_marketing = $isInternational ? $settings['label_us_pricing_business_lite_yearly_with_marketing'] : $settings['label_za_pricing_business_lite_yearly_with_marketing'];
// BUSINESS PRO
$business_pro_pricing_monthly = $isInternational ? $settings['label_us_pricing_business_pro_monthly'] : $settings['label_za_pricing_business_pro_monthly'];
$business_pro_pricing_monthly_with_marketing = $isInternational ? $settings['label_us_pricing_business_pro_monthly_with_marketing'] : $settings['label_za_pricing_business_pro_monthly_with_marketing'];
$business_pro_pricing_yearly = $isInternational ? $settings['label_us_pricing_business_pro_yearly'] : $settings['label_za_pricing_business_pro_yearly'];
$business_pro_pricing_yearly_with_marketing = $isInternational ? $settings['label_us_pricing_business_pro_yearly_with_marketing'] : $settings['label_za_pricing_business_pro_yearly_with_marketing'];
?>
<h2><?php echo $solo_pricing_monthly; ?></h2>
<?php
// more code here
_content_template()
函数从 Elementor 版本 2.9.0
protected function content_template(){ }
使用不带 _(下划线)字符的函数,它将完美运行。