class ET_Builder_Module_Code extends ET_Builder_Module {
$this->name = esc_html__( 'Code', 'et_builder' );
$this->plural = esc_html__( 'Codes', 'et_builder' );
$this->slug = 'et_pb_code';
$this->vb_support = 'on';
$this->use_raw_content = true;
$this->settings_modal_toggles = array(
'main_content' => et_builder_i18n( 'Text' ),
'title' => et_builder_i18n( 'Sizing' ),
$this->advanced_fields = array(
'margin_padding' => array(
'important' => array( 'custom_margin' ), // needed to overwrite last module margin-bottom styling
// Don't add text-shadow fields since they already are via font-options
$this->help_videos = array(
'name' => esc_html__( 'An introduction to the Code module', 'et_builder' ),
// wptexturize is often incorrectly parsed single and double quotes
// This disables wptexturize on this module
add_filter( 'no_texturize_shortcodes', array( $this, 'disable_wptexturize' ) );
'label' => esc_html__( 'Code', 'et_builder' ),
'option_category' => 'basic_option',
'description' => esc_html__( 'Here you can create the content that will be used within the module.', 'et_builder' ),
'toggle_slug' => 'main_content',
'mobile_options' => true,
* Renders the module output.
* @param array $attrs List of attributes.
* @param string $content Content being processed.
* @param string $render_slug Slug of module that is used for rendering output.
public function render( $attrs, $content, $render_slug ) {
$multi_view = et_pb_multi_view_options( $this );
$video_background = $this->video_background();
$parallax_image_background = $this->get_parallax_image_background();
$this->add_classname( $this->get_text_orientation_classname() );
$raw_content = $multi_view->render_element(
'content' => '{{raw_content}}',
'class' => 'et_pb_code_inner',
</div> <!-- .et_pb_code -->',
$this->module_classname( $render_slug ),
$parallax_image_background
* Filter multi view value.
* @see ET_Builder_Module_Helper_MultiViewOptions::filter_value
* @param mixed $raw_value Props raw value.
* @type string $context Context param: content, attrs, visibility, classes.
* @type string $name Module options props name.
* @type string $mode Current data mode: desktop, hover, tablet, phone.
* @type string $attr_key Attribute key for attrs context data. Example: src, class, etc.
* @type string $attr_sub_key Attribute sub key that availabe when passing attrs value as array such as styes. Example: padding-top, margin-botton, etc.
public function multi_view_filter_value( $raw_value, $args ) {
$name = isset( $args['name'] ) ? $args['name'] : '';
$mode = isset( $args['mode'] ) ? $args['mode'] : 'desktop';
if ( $raw_value && 'raw_content' === $name ) {
if ( 'desktop' !== $mode ) {
$raw_value = et_builder_convert_line_breaks( et_builder_replace_code_content_entities( $raw_value ) );
$raw_value = $this->fix_wptexturized_scripts( $raw_value );
new ET_Builder_Module_Code();