如何创建自定义Divi模块? [英] How to create custom Divi module?

查看:234
本文介绍了如何创建自定义Divi模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为Divi Wordpress主题添加自定义模块? http://www.elegantthemes.com/gallery/divi/

How can I add a custom module for Divi Wordpress theme? http://www.elegantthemes.com/gallery/divi/

原始模块是在 main-modules.php

示例:

class ET_Builder_Module_Gallery extends ET_Builder_Module { .... }

但是在我的插件或主题 functions.php

But the ET_Builder_Module class is not accessible in my plugin, or in theme functions.php

推荐答案

这里的其他大多数解决方案都太复杂了.最简单的方法是将您的自定义模块加载到divi特定的动作挂钩et_builder_ready中,如下所示:

Most other solutions here are way too complex. The simplest way is to load your custom module in the divi specific action hook et_builder_ready, like this:

add_action( 'et_builder_ready', 'evr_initialize_divi_modules' );

function evr_initialize_divi_modules() {
    if ( ! class_exists( 'ET_Builder_Module' ) ) { return; }

    class EVR_Builder_Module_Testimonial extends ET_Builder_Module {
        function init() {
            $this->name       = esc_html__( 'Testimonial', 'evr' );
            $this->slug       = 'evr_pb_testimonial';
            $this->fb_support = true;

            // ...

        }
    }
}

您可以在github上找到完整的演示代码.连同一些说明,如何使它在全新的Divi 3前端构建器中工作:

You can find the full demo-code on github. Along with some instructions how to get it work in the all new Divi 3 frontend builder:

https://github.com/stracker-phil/divi3-vb -custom-modules/

这篇关于如何创建自定义Divi模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆