Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/includes/builder/module
File: Sidebar.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class ET_Builder_Module_Sidebar extends ET_Builder_Module {
[2] Fix | Delete
function init() {
[3] Fix | Delete
$this->name = esc_html__( 'Sidebar', 'et_builder' );
[4] Fix | Delete
$this->plural = esc_html__( 'Sidebars', 'et_builder' );
[5] Fix | Delete
$this->slug = 'et_pb_sidebar';
[6] Fix | Delete
$this->vb_support = 'on';
[7] Fix | Delete
[8] Fix | Delete
$this->main_css_element = '%%order_class%%.et_pb_widget_area';
[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( 'Content' ),
[14] Fix | Delete
),
[15] Fix | Delete
),
[16] Fix | Delete
'advanced' => array(
[17] Fix | Delete
'toggles' => array(
[18] Fix | Delete
'layout' => et_builder_i18n( 'Layout' ),
[19] Fix | Delete
'text' => array(
[20] Fix | Delete
'title' => et_builder_i18n( 'Text' ),
[21] Fix | Delete
'priority' => 49,
[22] Fix | Delete
),
[23] Fix | Delete
),
[24] Fix | Delete
),
[25] Fix | Delete
);
[26] Fix | Delete
[27] Fix | Delete
$this->advanced_fields = array(
[28] Fix | Delete
'fonts' => array(
[29] Fix | Delete
'header' => array(
[30] Fix | Delete
'label' => et_builder_i18n( 'Title' ),
[31] Fix | Delete
'css' => array(
[32] Fix | Delete
'main' => "{$this->main_css_element} h3:first-of-type, {$this->main_css_element} h4:first-of-type, {$this->main_css_element} h5:first-of-type, {$this->main_css_element} h6:first-of-type, {$this->main_css_element} h2:first-of-type, {$this->main_css_element} h1:first-of-type, {$this->main_css_element} .widget-title, {$this->main_css_element} .widgettitle",
[33] Fix | Delete
),
[34] Fix | Delete
),
[35] Fix | Delete
'body' => array(
[36] Fix | Delete
'label' => et_builder_i18n( 'Body' ),
[37] Fix | Delete
'css' => array(
[38] Fix | Delete
'main' => "{$this->main_css_element}, {$this->main_css_element} li, {$this->main_css_element} li:before, {$this->main_css_element} a",
[39] Fix | Delete
'line_height' => "{$this->main_css_element} p",
[40] Fix | Delete
),
[41] Fix | Delete
),
[42] Fix | Delete
),
[43] Fix | Delete
'margin_padding' => array(
[44] Fix | Delete
'css' => array(
[45] Fix | Delete
'main' => '%%order_class%%',
[46] Fix | Delete
'important' => array( 'custom_margin' ), // needed to overwrite last module margin-bottom styling
[47] Fix | Delete
),
[48] Fix | Delete
),
[49] Fix | Delete
'text' => array(
[50] Fix | Delete
'use_background_layout' => true,
[51] Fix | Delete
'options' => array(
[52] Fix | Delete
'background_layout' => array(
[53] Fix | Delete
'default' => 'light',
[54] Fix | Delete
'hover' => 'tabs',
[55] Fix | Delete
),
[56] Fix | Delete
),
[57] Fix | Delete
'css' => array(
[58] Fix | Delete
'main' => '%%order_class%%, %%order_class%% .widgettitle',
[59] Fix | Delete
),
[60] Fix | Delete
),
[61] Fix | Delete
'button' => false,
[62] Fix | Delete
);
[63] Fix | Delete
$this->custom_css_fields = array(
[64] Fix | Delete
'widget' => array(
[65] Fix | Delete
'label' => esc_html__( 'Widget', 'et_builder' ),
[66] Fix | Delete
'selector' => '.et_pb_widget',
[67] Fix | Delete
),
[68] Fix | Delete
'title' => array(
[69] Fix | Delete
'label' => et_builder_i18n( 'Title' ),
[70] Fix | Delete
'selector' => 'h4.widgettitle',
[71] Fix | Delete
),
[72] Fix | Delete
);
[73] Fix | Delete
[74] Fix | Delete
$this->help_videos = array(
[75] Fix | Delete
array(
[76] Fix | Delete
'id' => '468VROeyKq4',
[77] Fix | Delete
'name' => esc_html__( 'An introduction to the Sidebar module', 'et_builder' ),
[78] Fix | Delete
),
[79] Fix | Delete
);
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
function get_fields() {
[83] Fix | Delete
$fields = array(
[84] Fix | Delete
'orientation' => array(
[85] Fix | Delete
'label' => esc_html__( 'Alignment', 'et_builder' ),
[86] Fix | Delete
'type' => 'select',
[87] Fix | Delete
'option_category' => 'layout',
[88] Fix | Delete
'options' => array(
[89] Fix | Delete
'left' => et_builder_i18n( 'Left' ),
[90] Fix | Delete
'right' => et_builder_i18n( 'Right' ),
[91] Fix | Delete
),
[92] Fix | Delete
'default_on_front' => 'left',
[93] Fix | Delete
'tab_slug' => 'advanced',
[94] Fix | Delete
'toggle_slug' => 'layout',
[95] Fix | Delete
'description' => esc_html__( 'Choose which side of the page your sidebar will be on. This setting controls text orientation and border position.', 'et_builder' ),
[96] Fix | Delete
),
[97] Fix | Delete
'area' => array(
[98] Fix | Delete
'label' => esc_html__( 'Widget Area', 'et_builder' ),
[99] Fix | Delete
'type' => 'select_sidebar',
[100] Fix | Delete
'option_category' => 'basic_option',
[101] Fix | Delete
'description' => esc_html__( 'Select a widget-area that you would like to display. You can create new widget areas within the Appearances > Widgets tab.', 'et_builder' ),
[102] Fix | Delete
'toggle_slug' => 'main_content',
[103] Fix | Delete
'computed_affects' => array(
[104] Fix | Delete
'__sidebars',
[105] Fix | Delete
),
[106] Fix | Delete
),
[107] Fix | Delete
'show_border' => array(
[108] Fix | Delete
'label' => esc_html__( 'Show Border Separator', 'et_builder' ),
[109] Fix | Delete
'description' => esc_html__( 'Disabling the border separator will remove the solid line that appears to the left or right of sidebar widgets.', 'et_builder' ),
[110] Fix | Delete
'type' => 'yes_no_button',
[111] Fix | Delete
'option_category' => 'layout',
[112] Fix | Delete
'options' => array(
[113] Fix | Delete
'on' => et_builder_i18n( 'Yes' ),
[114] Fix | Delete
'off' => et_builder_i18n( 'No' ),
[115] Fix | Delete
),
[116] Fix | Delete
'default_on_front' => 'on',
[117] Fix | Delete
'tab_slug' => 'advanced',
[118] Fix | Delete
'toggle_slug' => 'layout',
[119] Fix | Delete
),
[120] Fix | Delete
'__sidebars' => array(
[121] Fix | Delete
'type' => 'computed',
[122] Fix | Delete
'computed_callback' => array( 'ET_Builder_Module_Sidebar', 'get_sidebar' ),
[123] Fix | Delete
'computed_depends_on' => array(
[124] Fix | Delete
'area',
[125] Fix | Delete
),
[126] Fix | Delete
),
[127] Fix | Delete
);
[128] Fix | Delete
return $fields;
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
static function get_default_area() {
[132] Fix | Delete
global $wp_registered_sidebars;
[133] Fix | Delete
[134] Fix | Delete
if ( ! empty( $wp_registered_sidebars ) ) {
[135] Fix | Delete
// Pluck sidebar ids
[136] Fix | Delete
$sidebar_ids = wp_list_pluck( $wp_registered_sidebars, 'id' );
[137] Fix | Delete
[138] Fix | Delete
// Return first sidebar id
[139] Fix | Delete
return array_shift( $sidebar_ids );
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
return '';
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
/**
[146] Fix | Delete
* Get sidebar data for sidebar module
[147] Fix | Delete
*
[148] Fix | Delete
* @param string comma separated gallery ID
[149] Fix | Delete
* @param string on|off to determine grid / slider layout
[150] Fix | Delete
* @param array passed current page params
[151] Fix | Delete
*
[152] Fix | Delete
* @return string JSON encoded array of attachments data
[153] Fix | Delete
*/
[154] Fix | Delete
static function get_sidebar( $args = array(), $conditional_tags = array(), $current_page = array() ) {
[155] Fix | Delete
$defaults = array(
[156] Fix | Delete
'area' => '',
[157] Fix | Delete
);
[158] Fix | Delete
[159] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[160] Fix | Delete
[161] Fix | Delete
// Get any available widget areas so it isn't empty
[162] Fix | Delete
if ( '' === $args['area'] ) {
[163] Fix | Delete
$args['area'] = self::get_default_area();
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
// Outputs sidebar
[167] Fix | Delete
$widgets = '';
[168] Fix | Delete
[169] Fix | Delete
ob_start();
[170] Fix | Delete
[171] Fix | Delete
if ( is_active_sidebar( $args['area'] ) ) {
[172] Fix | Delete
dynamic_sidebar( $args['area'] );
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
$widgets = ob_get_contents();
[176] Fix | Delete
[177] Fix | Delete
ob_end_clean();
[178] Fix | Delete
[179] Fix | Delete
return $widgets;
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
/**
[183] Fix | Delete
* Renders the module output.
[184] Fix | Delete
*
[185] Fix | Delete
* @param array $attrs List of attributes.
[186] Fix | Delete
* @param string $content Content being processed.
[187] Fix | Delete
* @param string $render_slug Slug of module that is used for rendering output.
[188] Fix | Delete
*
[189] Fix | Delete
* @return string
[190] Fix | Delete
*/
[191] Fix | Delete
public function render( $attrs, $content, $render_slug ) {
[192] Fix | Delete
$orientation = $this->props['orientation'];
[193] Fix | Delete
$area = '' === $this->props['area'] ? self::get_default_area() : $this->props['area'];
[194] Fix | Delete
$show_border = $this->props['show_border'];
[195] Fix | Delete
[196] Fix | Delete
$video_background = $this->video_background();
[197] Fix | Delete
$parallax_image_background = $this->get_parallax_image_background();
[198] Fix | Delete
[199] Fix | Delete
$widgets = '';
[200] Fix | Delete
[201] Fix | Delete
ob_start();
[202] Fix | Delete
[203] Fix | Delete
if ( is_active_sidebar( $area ) ) {
[204] Fix | Delete
dynamic_sidebar( $area );
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
$widgets = ob_get_contents();
[208] Fix | Delete
[209] Fix | Delete
ob_end_clean();
[210] Fix | Delete
[211] Fix | Delete
// Module classnames
[212] Fix | Delete
$this->add_classname(
[213] Fix | Delete
array(
[214] Fix | Delete
'et_pb_widget_area',
[215] Fix | Delete
'clearfix',
[216] Fix | Delete
"et_pb_widget_area_{$orientation}",
[217] Fix | Delete
$this->get_text_orientation_classname(),
[218] Fix | Delete
)
[219] Fix | Delete
);
[220] Fix | Delete
[221] Fix | Delete
// Background layout class names.
[222] Fix | Delete
$background_layout_class_names = et_pb_background_layout_options()->get_background_layout_class( $this->props );
[223] Fix | Delete
$this->add_classname( $background_layout_class_names );
[224] Fix | Delete
[225] Fix | Delete
if ( 'on' !== $show_border ) {
[226] Fix | Delete
$this->add_classname( 'et_pb_sidebar_no_border' );
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
// Remove automatically added classnames
[230] Fix | Delete
$this->remove_classname(
[231] Fix | Delete
array(
[232] Fix | Delete
$render_slug,
[233] Fix | Delete
)
[234] Fix | Delete
);
[235] Fix | Delete
[236] Fix | Delete
// Background layout data attributes.
[237] Fix | Delete
$data_background_layout = et_pb_background_layout_options()->get_background_layout_attrs( $this->props );
[238] Fix | Delete
[239] Fix | Delete
$output = sprintf(
[240] Fix | Delete
'<div%3$s class="%2$s"%6$s>
[241] Fix | Delete
%5$s
[242] Fix | Delete
%4$s
[243] Fix | Delete
%1$s
[244] Fix | Delete
</div> <!-- .et_pb_widget_area -->',
[245] Fix | Delete
$widgets,
[246] Fix | Delete
$this->module_classname( $render_slug ),
[247] Fix | Delete
$this->module_id(),
[248] Fix | Delete
$video_background,
[249] Fix | Delete
$parallax_image_background, // #5
[250] Fix | Delete
et_core_esc_previously( $data_background_layout )
[251] Fix | Delete
);
[252] Fix | Delete
[253] Fix | Delete
return $output;
[254] Fix | Delete
}
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
new ET_Builder_Module_Sidebar();
[258] Fix | Delete
[259] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function