incsectionshestia-big-title-section - choi game ban ca

/imgposts/yup74ui3.jpg

Mặc định, mã nguồn cho phần Banner tĩnh nằm trong tệp tin ./inc/sections/hestia-big-title-section.php. Phần này được mô tả là "Phần Tiêu đề lớn cho trang chủ."

Big Title section for the homepage.

Trong phiên bản PRO trả phí, mã nguồn cho tính năng Slider nhiều ảnh nằm trong tệp tin ./inc/sections/hestia-slider-section.php.

Thay thế hàm hestia_slider() vào vị trí của hàm hestia_big_title():

 1if ( ! empty( $hestia_big_title_background ) || ! empty( $hestia_big_title_title ) || ! empty( $hestia_big_title_text ) || ! empty( $hestia_big_title_button_text ) || ! empty( $hestia_big_title_button_link ) ) {
 2    hestia_big_title();
 3} else {
 4    if ( ! empty( $hestia_slider_content ) ) {
 5        hestia_slider();
 6    } else {
 7        hestia_big_title();
 8    }
 9}
10endif;
11
12add_action( 'hestia_header', 'hestia_slider_compatibility' );

Chúng ta có thể điều chỉnh phần ban đầu để nhập hai hình nền thay vì một. Sử dụng JSON encode để lưu trữ dữ liệu.

Cấu hình cho phần Big Title Section được lưu trữ như sau:

1$hestia_big_title_background = get_theme_mod( 'hestia_big_title_background' );

Còn đối với phần Slider Section, thông tin sẽ được lưu trữ bằng cách sử dụng:

 1$hestia_slider_content = get_theme_mod( 'hestia_slider_content', json_encode( $slider_default ) );
 2$hestia_slider_content = json_decode( $hestia_slider_content );
 3
 4if ( ! empty( $hestia_slider_content ) ) {
 5    foreach ( $hestia_slider_content as $slider_item ) :
 6        $title  = ! empty( $slider_item->title ) ? apply_filters( 'hestia_translate_single_string', $slider_item->title, 'Slider section' ) : '';
 7        $subtitle = ! empty( $slider_item->subtitle ) ? apply_filters( 'hestia_translate_single_string', $slider_item->subtitle, 'Slider section' ) : '';
 8        $button  = ! empty( $slider_item->text ) ? apply_filters( 'hestia_translate_single_string', $slider_item->text, 'Slider section' ) : '';
 9        $link   = ! empty( $slider_item->link ) ? apply_filters( 'hestia_translate_single_string', $slider_item->link, 'Slider section' ) : '';
10        $button2 = ! empty( $slider_item->text2 ) ? apply_filters( 'hestia_translate_single_string', $slider_item->text2, 'Slider section' ) : '';
11        $link2  = ! empty( $slider_item->link2 ) ? apply_filters( 'hestia_translate_single_string', $slider_item->link2, 'Slider section' ) : '';
12        $image  = ! empty( $slider_item->image_url ) && ! has_header_video() ? apply_filters( 'hestia_translate_single_string', $slider_item->image_url, 'Slider section' ) : '';
13        $color  = ! empty( $slider_item->color ) ? apply_filters( 'hestia_translate_single_string', $slider_item->color, 'Slider section' ) : '';
14        $color2  = ! empty( $slider_item->color2 ) ? apply_filters( 'hestia_translate_single_string', $slider_item->color2, 'Slider section' ) : '';
15    endforeach;
16}

Hàm hestia_get_slider_default() định nghĩa giá trị mặc định của các slide:

 1function hestia_get_slider_default() {
 2    return array(
 3        array(
 4            'image_url' => get_template_directory_uri() . '/assets/img/slider1.jpg',
 5            'title'   => esc_html__( 'Lorem Ipsum', 'hestia' ),
 6            'subtitle' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'hestia' ),
 7            'text'   => esc_html__( 'Button', 'hestia' ),
 8            'link'   => '#',
 9            'id'    => 'customizer_repeater_56d7ea7f40a56',
10            'color'   => '#e91e63',
11        ),
12        array(
13            'image_url' => get_template_directory_uri() . '/assets/img/slider2.jpg',
14            'title'   => esc_html__( 'Lorem Ipsum', 'hestia' ),
15            'subtitle' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'hestia' ),
16            'text'   => esc_html__( 'Button', 'hestia' ),
17            'link'   => '#',
18            'id'    => 'customizer_repeater_56d7ea7f40a57',
19            'color'   => '#e91e63',
20        ),
21        array(
22            'image_url' => get_template_directory_uri() . '/assets/img/slider3.jpg',
23            'title'   => esc_html__( 'Lorem Ipsum', 'hestia' ),
24            'subtitle' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'hestia' ),
25            'text'   => esc_html__( 'Button', 'hestia' ),
26            'link'   => '#',
27            'id'    => 'customizer_repeater_56d7ea7f40a58',
28            'color'   => '#e91e63',
29        ),
30    );
31}
1$ wp theme mod get hestia_big_title_background --format=json; echo '';
2[{"key":0,"value":false},{"key":"hestia_big_title_background","value":"http:\/\/en.xxx.com\/wp-content\/uploads\/2018\/06\/866294069.jpg"}]
3
4$ wp theme mod get hestia_slider_content --format=json; echo '';
5[{"key":0,"value":false},{"key":"hestia_slider_content","value":""}]

Thêm các công cụ chọn ảnh banner vào giao diện quản trị admin và lưu trữ chúng vào cơ sở dữ liệu. Khi đọc dữ liệu slider, thay thế dữ liệu mẫu mặc định bằng dữ liệu từ cơ sở dữ liệu, sử dụng hàm get_theme_mod để lấy cấu hình đã lưu.

Hàm này dùng để lấy một thiết lập tùy chỉnh cho chủ đề hiện tại. Cùng với hàm set_theme_mod(), nó cung cấp cho nhà phát triển chủ đề một giải pháp đơn giản hơn so với API Cài đặt khi cần xử lý các cài đặt cơ bản liên quan đến chủ đề.