Hestia lite在页脚中带有3个小部件区域。我创建了一个子主题,并且试图添加2个其他小部件区域,但是它不起作用。进行修改后,我仍然只能在定制程序中看到3个窗口小部件区域。
这是我在class-hestia-footer.php中修改的行。我在$ footer_sidebars_array中添加了第五个元素,并将“ 3”更改为“ 5”。
/**
* Get an array of footer sidevars slugs.
*
* @return array
*/
private function get_footer_sidebars() {
$footer_sidebars_array = array(
'footer-one-widgets',
'footer-two-widgets',
'footer-three-widgets',
'footer-four-widgets',
'footer-five-widgets'
);
$number_of_sidebars = get_theme_mod( 'hestia_nr_footer_widgets', '5' );
$footer_sidebars_array = array_slice( $footer_sidebars_array, 0, $number_of_sidebars );
return $footer_sidebars_array;
}
/**
* Get the sidebars class.
*
* @return string the sidebar class
*/
private function the_sidebars_class() {
$number_of_sidebars = get_theme_mod( 'hestia_nr_footer_widgets', '5' );
if ( empty( $number_of_sidebars ) ) {
return 'col-md-4';
}
$suffix = abs( 12 / $number_of_sidebars );
$class = 'col-md-' . $suffix;
return $class;
}
这是我在class-hestia-public.php中修改的代码:
/**
* Array of sidebars registered in the footer area.
* The hestia_footer_widget_areas_array filter is used in the PRO version to add the extra forth sidebar.
*/
$footer_sidebars_array = apply_filters(
'hestia_footer_widget_areas_array',
array(
'footer-one-widgets' => esc_html__( 'Footer One', 'hestia' ),
'footer-two-widgets' => esc_html__( 'Footer Two', 'hestia' ),
'footer-three-widgets' => esc_html__( 'Footer Three', 'hestia' ),
'footer-four-widgets' => esc_html__( 'Footer Four', 'hestia' ),
'footer-five-widgets' => esc_html__( 'Footer Five', 'hestia' ),
)
);
/**
* Number of footer sidebars that need to be registered.
* This option is available only in the PRO version. In Hestia, the value is always 3.
*/
$hestia_nr_footer_widgets = is_customize_preview() ? '4' : get_theme_mod( 'hestia_nr_footer_widgets', '5' );
/**
* If the Number of widgets areas option is selected, add the specific number of footer sidebars in the main sidebars array to be registered.
*/
if ( ! empty( $hestia_nr_footer_widgets ) ) {
$footer_sidebars_array = array_slice( $footer_sidebars_array, 0, $hestia_nr_footer_widgets );
}
if ( ! empty( $footer_sidebars_array ) ) {
$sidebars_array = array_merge( $sidebars_array, $footer_sidebars_array );
}