我已经使用其子模块创建了定制的divi构建器模块。现在我需要在其子模块的父atts值, 但我找不到解决此问题的方法。这是我的自定义模块类
父模块类:
class Wb_Custom_Module_Revision extends ET_Builder_Module {
function init () {
$this->name = __( 'Wb Revision Log', 'wb' );
$this->slug = 'et_pb_wb_revision';
$this->fb_support = true;
$this->child_slug = 'et_pb_wb_revision_child';
$this->child_item_text = esc_html__( 'Revision Item', 'et_builder' );
$this->whitelisted_fields = array('vertical_divider_line');
$this->fields_defaults = array(
'title' => array( 'Revision Log', 'add_default_setting' ), );
$this->main_css_element = '%%order_class%%';
}
function get_fields () {
$fields = array(
'vertical_divider_line' => array(
'label' => __( 'Horizontal line', 'wb' ), 'type' => 'text', 'description' => __( 'Leave empty to not display', 'wb' ), ), );
return $fields;
}
function shortcode_callback ( $atts, $content = null, $function_name ) {
//my shortcode function
return ;
}
}
new Wb_Custom_Module_Revision;
子模块类:
class Wb_Custom_Module_Revision_Item extends ET_Builder_Module {
function init() {
$this->name = esc_html__( 'Revision Item', 'et_builder' );
$this->slug = 'et_pb_wb_revision_child';
$this->fb_support = true;
$this->type = 'child';
$this->child_title_var = 'content_new';
function shortcode_callback( $atts, $content = null, $function_name ) {
//i need here it's parent "vertical_divider_line" field value.
return $output;
}
}
new Wb_Custom_Module_Revision_Item;
我需要在其子模块shortcode_callback函数中使用父模块字段值。请帮助我解决这个问题。谢谢
#1
你可以通过调用以下类方法来获取父模块:
$ parent_module = self :: get_parent_modules(‘page’)[‘et_pb_wb_revision’];
然后你可以获取所需的字段值:
$ parent_module-> shortcode_atts [‘vertical_divider_line’];
希望能帮助到你!
评论前必须登录!
注册