doucheng4660 2019-05-16 09:43
浏览 132

如何在Avada子主题函数中覆盖Fusion Element容器?

Hi I am trying to change the way Fusion Builder container works. I want to add more custom fields, change the display html and the default variables. I need to override the /plugin/fusion-builder/shorcode/fusion-container.php

I am using a child theme of avada. What is the correct way to override it?

  • 写回答

1条回答 默认 最新

  • ds3016 2019-05-16 10:01
    关注

    Just right after I posted the question, I got the answer in GitHub: https://github.com/Theme-Fusion/Fusion-Builder-Sample-Add-On/issues/34

    The solution is to add to the functions.php in your child template the following code:

    /**
     * Filter already set maps, add in a new option to container.
     */
    function filter_available_element( $fusion_builder_elements ) {
        if ( isset( $fusion_builder_elements['fusion_builder_container'] ) ) {
            $fusion_builder_elements['fusion_builder_container']['params'][] = array(
                'type'        => 'radio_button_set',
                'heading'     => esc_attr__( 'Container Design Mode', 'fusion-builder' ),
                'description' => esc_attr__( 'Controls whether the container should be dark or light.', 'fusion-builder' ),
                'param_name'  => 'container_mode',
                'value'       => array(
                    'light' => esc_attr__( 'Light', 'fusion-builder' ),
                    'dark'  => esc_attr__( 'Dark', 'fusion-builder' ),
                ),
                'default'     => 'light',
                'group'       => esc_attr__( 'Design', 'fusion-builder' ),
            );
        }
        return $fusion_builder_elements;
    }
    add_filter( 'fusion_builder_all_elements', 'filter_available_element' );
    
    /**
     * Filter the parameters, check for container_mode and if set add to class parameter.
     */
    function filter_container_parameters( $out, $pairs, $atts, $shortcode ) {
    
        // If set, use it, otherwise set to default.
        $out['container_mode'] = isset( $atts['container_mode'] ) ? $atts['container_mode'] : 'light';
    
        // Set to class parameter which container already has and uses.
        if ( ! isset( $out['class'] ) || '' === $out['class'] ) {
            $out['class'] = 'my-class-' . $out['container_mode'];
        } else {
            $out['class'] .= ' my-class-' . $out['container_mode'];
        }
        return $out;
    }
    add_filter( 'shortcode_atts_fusion_builder_container', 'filter_container_parameters', 10, 4 );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程