Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/includes/builder/module
File: Cta.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class ET_Builder_Module_CTA extends ET_Builder_Module {
[2] Fix | Delete
function init() {
[3] Fix | Delete
$this->name = esc_html__( 'Call To Action', 'et_builder' );
[4] Fix | Delete
$this->plural = esc_html__( 'Call To Actions', 'et_builder' );
[5] Fix | Delete
$this->slug = 'et_pb_cta';
[6] Fix | Delete
$this->vb_support = 'on';
[7] Fix | Delete
[8] Fix | Delete
$this->main_css_element = '%%order_class%%.et_pb_promo';
[9] Fix | Delete
[10] Fix | Delete
$this->settings_modal_toggles = array(
[11] Fix | Delete
'general' => array(
[12] Fix | Delete
'toggles' => array(
[13] Fix | Delete
'main_content' => et_builder_i18n( 'Text' ),
[14] Fix | Delete
),
[15] Fix | Delete
),
[16] Fix | Delete
'advanced' => array(
[17] Fix | Delete
'toggles' => array(
[18] Fix | Delete
'text' => array(
[19] Fix | Delete
'title' => et_builder_i18n( 'Text' ),
[20] Fix | Delete
'priority' => 49,
[21] Fix | Delete
),
[22] Fix | Delete
'width' => array(
[23] Fix | Delete
'title' => et_builder_i18n( 'Sizing' ),
[24] Fix | Delete
'priority' => 80,
[25] Fix | Delete
),
[26] Fix | Delete
),
[27] Fix | Delete
),
[28] Fix | Delete
);
[29] Fix | Delete
[30] Fix | Delete
$this->advanced_fields = array(
[31] Fix | Delete
'fonts' => array(
[32] Fix | Delete
'header' => array(
[33] Fix | Delete
'label' => et_builder_i18n( 'Title' ),
[34] Fix | Delete
'css' => array(
[35] Fix | Delete
'main' => "{$this->main_css_element} h2, {$this->main_css_element} h1.et_pb_module_header, {$this->main_css_element} h3.et_pb_module_header, {$this->main_css_element} h4.et_pb_module_header, {$this->main_css_element} h5.et_pb_module_header, {$this->main_css_element} h6.et_pb_module_header",
[36] Fix | Delete
'important' => 'all',
[37] Fix | Delete
),
[38] Fix | Delete
'header_level' => array(
[39] Fix | Delete
'default' => 'h2',
[40] Fix | Delete
),
[41] Fix | Delete
),
[42] Fix | Delete
'body' => array(
[43] Fix | Delete
'label' => et_builder_i18n( 'Body' ),
[44] Fix | Delete
'css' => array(
[45] Fix | Delete
'main' => "{$this->main_css_element} .et_pb_promo_description div",
[46] Fix | Delete
),
[47] Fix | Delete
'block_elements' => array(
[48] Fix | Delete
'tabbed_subtoggles' => true,
[49] Fix | Delete
'bb_icons_support' => true,
[50] Fix | Delete
'css' => array(
[51] Fix | Delete
'main' => "{$this->main_css_element}",
[52] Fix | Delete
),
[53] Fix | Delete
),
[54] Fix | Delete
),
[55] Fix | Delete
),
[56] Fix | Delete
'background' => array(
[57] Fix | Delete
'has_background_color_toggle' => true,
[58] Fix | Delete
'use_background_color' => true,
[59] Fix | Delete
'options' => array(
[60] Fix | Delete
'background_color' => array(
[61] Fix | Delete
'depends_show_if' => 'on',
[62] Fix | Delete
'default' => et_builder_accent_color(),
[63] Fix | Delete
),
[64] Fix | Delete
'use_background_color' => array(
[65] Fix | Delete
'default' => 'on',
[66] Fix | Delete
),
[67] Fix | Delete
),
[68] Fix | Delete
),
[69] Fix | Delete
'max_width' => array(
[70] Fix | Delete
'css' => array(
[71] Fix | Delete
'module_alignment' => '%%order_class%%.et_pb_promo.et_pb_module',
[72] Fix | Delete
),
[73] Fix | Delete
),
[74] Fix | Delete
'margin_padding' => array(
[75] Fix | Delete
'css' => array(
[76] Fix | Delete
'important' => 'all',
[77] Fix | Delete
),
[78] Fix | Delete
),
[79] Fix | Delete
'button' => array(
[80] Fix | Delete
'button' => array(
[81] Fix | Delete
'label' => et_builder_i18n( 'Button' ),
[82] Fix | Delete
'css' => array(
[83] Fix | Delete
'main' => "{$this->main_css_element} .et_pb_promo_button.et_pb_button",
[84] Fix | Delete
'limited_main' => "{$this->main_css_element} .et_pb_promo_button.et_pb_button",
[85] Fix | Delete
'alignment' => "{$this->main_css_element} .et_pb_button_wrapper",
[86] Fix | Delete
),
[87] Fix | Delete
'use_alignment' => true,
[88] Fix | Delete
'box_shadow' => array(
[89] Fix | Delete
'css' => array(
[90] Fix | Delete
'main' => '%%order_class%% .et_pb_button',
[91] Fix | Delete
),
[92] Fix | Delete
),
[93] Fix | Delete
'margin_padding' => array(
[94] Fix | Delete
'css' => array(
[95] Fix | Delete
'main' => "{$this->main_css_element} .et_pb_button_wrapper .et_pb_promo_button.et_pb_button",
[96] Fix | Delete
'important' => 'all',
[97] Fix | Delete
),
[98] Fix | Delete
),
[99] Fix | Delete
),
[100] Fix | Delete
),
[101] Fix | Delete
'text' => array(
[102] Fix | Delete
'use_background_layout' => true,
[103] Fix | Delete
'css' => array(
[104] Fix | Delete
'main' => '%%order_class%% .et_pb_promo_description, %%order_class%% .et_pb_module_header',
[105] Fix | Delete
'text_shadow' => '%%order_class%% .et_pb_promo_description',
[106] Fix | Delete
),
[107] Fix | Delete
'options' => array(
[108] Fix | Delete
'text_orientation' => array(
[109] Fix | Delete
'default' => 'center',
[110] Fix | Delete
),
[111] Fix | Delete
'background_layout' => array(
[112] Fix | Delete
'default' => 'dark',
[113] Fix | Delete
),
[114] Fix | Delete
),
[115] Fix | Delete
),
[116] Fix | Delete
);
[117] Fix | Delete
[118] Fix | Delete
$this->custom_css_fields = array(
[119] Fix | Delete
'promo_description' => array(
[120] Fix | Delete
'label' => esc_html__( 'Promo Description', 'et_builder' ),
[121] Fix | Delete
'selector' => '.et_pb_promo_description',
[122] Fix | Delete
),
[123] Fix | Delete
'promo_button' => array(
[124] Fix | Delete
'label' => esc_html__( 'Promo Button', 'et_builder' ),
[125] Fix | Delete
'selector' => '.et_pb_promo .et_pb_button.et_pb_promo_button',
[126] Fix | Delete
'no_space_before_selector' => true,
[127] Fix | Delete
),
[128] Fix | Delete
'promo_title' => array(
[129] Fix | Delete
'label' => esc_html__( 'Promo Title', 'et_builder' ),
[130] Fix | Delete
'selector' => '.et_pb_promo_description h2',
[131] Fix | Delete
),
[132] Fix | Delete
);
[133] Fix | Delete
[134] Fix | Delete
$this->help_videos = array(
[135] Fix | Delete
array(
[136] Fix | Delete
'id' => 'E3AEllqnCus',
[137] Fix | Delete
'name' => esc_html__( 'An introduction to the Call To Action module', 'et_builder' ),
[138] Fix | Delete
),
[139] Fix | Delete
);
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
function get_fields() {
[143] Fix | Delete
$fields = array(
[144] Fix | Delete
'title' => array(
[145] Fix | Delete
'label' => et_builder_i18n( 'Title' ),
[146] Fix | Delete
'type' => 'text',
[147] Fix | Delete
'option_category' => 'basic_option',
[148] Fix | Delete
'description' => esc_html__( 'Input your value to action title here.', 'et_builder' ),
[149] Fix | Delete
'toggle_slug' => 'main_content',
[150] Fix | Delete
'dynamic_content' => 'text',
[151] Fix | Delete
'mobile_options' => true,
[152] Fix | Delete
'hover' => 'tabs',
[153] Fix | Delete
),
[154] Fix | Delete
'button_url' => array(
[155] Fix | Delete
'label' => esc_html__( 'Button Link URL', 'et_builder' ),
[156] Fix | Delete
'type' => 'text',
[157] Fix | Delete
'option_category' => 'basic_option',
[158] Fix | Delete
'description' => esc_html__( 'Input the destination URL for your CTA button.', 'et_builder' ),
[159] Fix | Delete
'toggle_slug' => 'link_options',
[160] Fix | Delete
'dynamic_content' => 'url',
[161] Fix | Delete
),
[162] Fix | Delete
'url_new_window' => array(
[163] Fix | Delete
'label' => esc_html__( 'Button Link Target', 'et_builder' ),
[164] Fix | Delete
'type' => 'select',
[165] Fix | Delete
'option_category' => 'configuration',
[166] Fix | Delete
'options' => array(
[167] Fix | Delete
'off' => esc_html__( 'In The Same Window', 'et_builder' ),
[168] Fix | Delete
'on' => esc_html__( 'In The New Tab', 'et_builder' ),
[169] Fix | Delete
),
[170] Fix | Delete
'toggle_slug' => 'link_options',
[171] Fix | Delete
'description' => esc_html__( 'Here you can choose whether or not your link opens in a new window', 'et_builder' ),
[172] Fix | Delete
'default_on_front' => 'off',
[173] Fix | Delete
),
[174] Fix | Delete
'button_text' => array(
[175] Fix | Delete
'label' => et_builder_i18n( 'Button' ),
[176] Fix | Delete
'type' => 'text',
[177] Fix | Delete
'option_category' => 'basic_option',
[178] Fix | Delete
'description' => esc_html__( 'Input your desired button text, or leave blank for no button.', 'et_builder' ),
[179] Fix | Delete
'toggle_slug' => 'main_content',
[180] Fix | Delete
'dynamic_content' => 'text',
[181] Fix | Delete
'mobile_options' => true,
[182] Fix | Delete
'hover' => 'tabs',
[183] Fix | Delete
),
[184] Fix | Delete
'content' => array(
[185] Fix | Delete
'label' => et_builder_i18n( 'Body' ),
[186] Fix | Delete
'type' => 'tiny_mce',
[187] Fix | Delete
'option_category' => 'basic_option',
[188] Fix | Delete
'description' => esc_html__( 'Input the main text content for your module here.', 'et_builder' ),
[189] Fix | Delete
'toggle_slug' => 'main_content',
[190] Fix | Delete
'dynamic_content' => 'text',
[191] Fix | Delete
'mobile_options' => true,
[192] Fix | Delete
'hover' => 'tabs',
[193] Fix | Delete
),
[194] Fix | Delete
);
[195] Fix | Delete
[196] Fix | Delete
return $fields;
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
function get_max_width_additional_css() {
[200] Fix | Delete
$additional_css = 'center' === $this->get_text_orientation() ? '; margin: 0 auto;' : '';
[201] Fix | Delete
[202] Fix | Delete
return $additional_css;
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
/**
[206] Fix | Delete
* Renders the module output.
[207] Fix | Delete
*
[208] Fix | Delete
* @param array $attrs List of attributes.
[209] Fix | Delete
* @param string $content Content being processed.
[210] Fix | Delete
* @param string $render_slug Slug of module that is used for rendering output.
[211] Fix | Delete
*
[212] Fix | Delete
* @return string
[213] Fix | Delete
*/
[214] Fix | Delete
public function render( $attrs, $content, $render_slug ) {
[215] Fix | Delete
$multi_view = et_pb_multi_view_options( $this );
[216] Fix | Delete
$title = $multi_view->render_element(
[217] Fix | Delete
array(
[218] Fix | Delete
'tag' => et_pb_process_header_level( $this->props['header_level'], 'h2' ),
[219] Fix | Delete
'content' => '{{title}}',
[220] Fix | Delete
'attrs' => array(
[221] Fix | Delete
'class' => 'et_pb_module_header',
[222] Fix | Delete
),
[223] Fix | Delete
)
[224] Fix | Delete
);
[225] Fix | Delete
$button_url = $this->props['button_url'];
[226] Fix | Delete
$button_rel = $this->props['button_rel'];
[227] Fix | Delete
$button_text = $this->_esc_attr( 'button_text', 'limited' );
[228] Fix | Delete
$background_color = $this->props['background_color'];
[229] Fix | Delete
$use_background_colors = et_pb_responsive_options()->get_composite_property_values( $this->props, 'background', 'use_background_color' );
[230] Fix | Delete
$use_background_color_hover = et_pb_hover_options()->get_compose_value( 'use_background_color', 'background', $this->props, '' );
[231] Fix | Delete
$url_new_window = $this->props['url_new_window'];
[232] Fix | Delete
$button_custom = $this->props['custom_button'];
[233] Fix | Delete
$header_level = $this->props['header_level'];
[234] Fix | Delete
[235] Fix | Delete
$custom_icon_values = et_pb_responsive_options()->get_property_values( $this->props, 'button_icon' );
[236] Fix | Delete
$custom_icon = isset( $custom_icon_values['desktop'] ) ? $custom_icon_values['desktop'] : '';
[237] Fix | Delete
$custom_icon_tablet = isset( $custom_icon_values['tablet'] ) ? $custom_icon_values['tablet'] : '';
[238] Fix | Delete
$custom_icon_phone = isset( $custom_icon_values['phone'] ) ? $custom_icon_values['phone'] : '';
[239] Fix | Delete
[240] Fix | Delete
$video_background = $this->video_background();
[241] Fix | Delete
$parallax_image_background = $this->get_parallax_image_background();
[242] Fix | Delete
$button_url = trim( $button_url );
[243] Fix | Delete
[244] Fix | Delete
// Module classnames
[245] Fix | Delete
$this->add_classname(
[246] Fix | Delete
array(
[247] Fix | Delete
'et_pb_promo',
[248] Fix | Delete
$this->get_text_orientation_classname(),
[249] Fix | Delete
)
[250] Fix | Delete
);
[251] Fix | Delete
[252] Fix | Delete
// Background layout class names.
[253] Fix | Delete
$background_layout_class_names = et_pb_background_layout_options()->get_background_layout_class( $this->props );
[254] Fix | Delete
$this->add_classname( $background_layout_class_names );
[255] Fix | Delete
[256] Fix | Delete
// Background color class.
[257] Fix | Delete
foreach ( $use_background_colors as $mode => $value ) {
[258] Fix | Delete
// Ensure value is not empty.
[259] Fix | Delete
if ( empty( $value ) ) {
[260] Fix | Delete
continue;
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
$is_value_on = 'on' === $value;
[264] Fix | Delete
$infix_class = $is_value_on ? 'has' : 'no';
[265] Fix | Delete
[266] Fix | Delete
// Desktop doesn't need has background class.
[267] Fix | Delete
if ( 'desktop' === $mode && $is_value_on ) {
[268] Fix | Delete
continue;
[269] Fix | Delete
}
[270] Fix | Delete
[271] Fix | Delete
$this->add_classname( et_pb_responsive_options()->get_field_name( "et_pb_{$infix_class}_bg", $mode ) );
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
if ( ! empty( $use_background_color_hover ) ) {
[275] Fix | Delete
$is_value_hover_on = 'on' === $use_background_color_hover;
[276] Fix | Delete
$infix_class_hover = $is_value_hover_on ? 'has' : 'on';
[277] Fix | Delete
$this->add_classname( "et_pb_{$infix_class_hover}_bg_hover" );
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
// Remove automatically added classname
[281] Fix | Delete
$this->remove_classname( 'et_pb_cta' );
[282] Fix | Delete
[283] Fix | Delete
// Render button
[284] Fix | Delete
$button = $this->render_button(
[285] Fix | Delete
array(
[286] Fix | Delete
'button_classname' => array( 'et_pb_promo_button' ),
[287] Fix | Delete
'button_custom' => $button_custom,
[288] Fix | Delete
'button_rel' => $button_rel,
[289] Fix | Delete
'button_text' => $button_text,
[290] Fix | Delete
'button_text_escaped' => true,
[291] Fix | Delete
'button_url' => $button_url,
[292] Fix | Delete
'custom_icon' => $custom_icon,
[293] Fix | Delete
'custom_icon_tablet' => $custom_icon_tablet,
[294] Fix | Delete
'custom_icon_phone' => $custom_icon_phone,
[295] Fix | Delete
'url_new_window' => $url_new_window,
[296] Fix | Delete
'display_button' => ( '' !== $button_url && $multi_view->has_value( 'button_text' ) ),
[297] Fix | Delete
'multi_view_data' => $multi_view->render_attrs(
[298] Fix | Delete
array(
[299] Fix | Delete
'content' => '{{button_text}}',
[300] Fix | Delete
'visibility' => array(
[301] Fix | Delete
'button_text' => '__not_empty',
[302] Fix | Delete
'button_url' => '__not_empty',
[303] Fix | Delete
),
[304] Fix | Delete
)
[305] Fix | Delete
),
[306] Fix | Delete
)
[307] Fix | Delete
);
[308] Fix | Delete
[309] Fix | Delete
// Background layout data attributes.
[310] Fix | Delete
$data_background_layout = et_pb_background_layout_options()->get_background_layout_attrs( $this->props );
[311] Fix | Delete
[312] Fix | Delete
$content = $multi_view->render_element(
[313] Fix | Delete
array(
[314] Fix | Delete
'tag' => 'div',
[315] Fix | Delete
'content' => '{{content}}',
[316] Fix | Delete
)
[317] Fix | Delete
);
[318] Fix | Delete
[319] Fix | Delete
$content_wrapper = $multi_view->render_element(
[320] Fix | Delete
array(
[321] Fix | Delete
'tag' => 'div',
[322] Fix | Delete
'content' => "{$title}{$content}",
[323] Fix | Delete
'attrs' => array(
[324] Fix | Delete
'class' => 'et_pb_promo_description',
[325] Fix | Delete
),
[326] Fix | Delete
'classes' => array(
[327] Fix | Delete
'et_multi_view_hidden' => array(
[328] Fix | Delete
'title' => '__empty',
[329] Fix | Delete
'content' => '__empty',
[330] Fix | Delete
),
[331] Fix | Delete
),
[332] Fix | Delete
)
[333] Fix | Delete
);
[334] Fix | Delete
[335] Fix | Delete
// Render module output
[336] Fix | Delete
$output = sprintf(
[337] Fix | Delete
'<div%5$s class="%4$s"%8$s>
[338] Fix | Delete
%7$s
[339] Fix | Delete
%6$s
[340] Fix | Delete
%9$s
[341] Fix | Delete
%3$s
[342] Fix | Delete
</div>',
[343] Fix | Delete
et_core_esc_previously( $title ),
[344] Fix | Delete
et_core_esc_previously( $content ),
[345] Fix | Delete
$button,
[346] Fix | Delete
$this->module_classname( $render_slug ),
[347] Fix | Delete
$this->module_id(), // #5
[348] Fix | Delete
$video_background,
[349] Fix | Delete
$parallax_image_background,
[350] Fix | Delete
et_core_esc_previously( $data_background_layout ),
[351] Fix | Delete
et_core_esc_previously( $content_wrapper )
[352] Fix | Delete
);
[353] Fix | Delete
[354] Fix | Delete
return $output;
[355] Fix | Delete
}
[356] Fix | Delete
}
[357] Fix | Delete
[358] Fix | Delete
new ET_Builder_Module_CTA();
[359] Fix | Delete
[360] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function