如何在divi builder插件中为自定义模块添加字段
我已经在divi生成器中创建了自定义模块。下面给出的是代码:如何在divi builder插件中为自定义模块添加字段
function ex_divi_child_theme_setup() {     if (class_exists('ET_Builder_Module')) { 
     class ET_Builder_Module_Image2 extends ET_Builder_Module { 
     function init() { 
      $this->name = __('Image_1', 'et_builder'); 
      $this->slug = 'et_pb_image2'; 
      // a whole bunch of php code that defines how the class functions 
     } 
     } 
     $et_builder_module_image2 = new ET_Builder_Module_Image2(); 
     add_shortcode('et_pb_image2', array($et_builder_module_image2, '_shortcode_callback')); 
    } 
} 
add_action('et_builder_ready', 'ex_divi_child_theme_setup'); 
我需要添加字段到这个自定义模块。我怎么能做到这一点。
回答:
如果你想添加自定义模块中的自定义字段,你必须使用“$这个 - > whitelisted_fields”财产和get_fields()功能。生病给你举一些例子,如何添加文本字段。
class ET_Builder_Module_Image2 extends ET_Builder_Module {     function init() { 
     $this->name = __('Image_1', 'et_builder'); 
     $this->slug = 'et_pb_image2'; 
     // a whole bunch of php code that defines how the class functions 
    } 
$this->whitelisted_fields = array(
     'my_title', 
    ); 
function get_fields() { 
    $fields = array(
     'my_title' => array(
      'label' => __('My Title', 'wb'), 
      'type' => 'text', 
     ), 
    ); 
    return $fields; 
} 
添加自定义归档塞在whitelisted_fields然后 propertys在get_fields()功能添加细节。我希望它能解决你的问题。
以上是 如何在divi builder插件中为自定义模块添加字段 的全部内容, 来源链接: utcz.com/qa/263627.html

