<?php

/**
 * Goblog Free Example Customize.
 *
 * @package Goblog Free
 * @subpackage Goblog Free
 * @since 1.0
 */

// Customize Example
function goblog_free_customize_test($wp_customize)
{

    // Section
    $wp_customize->add_section(
        'example',
        array(
            'title'           => __('Example', 'goblog-free'),
            'priority'        => 360,
            'active_callback' => 'goblog_free_callback_example',
        )
    );

    // Callback
    function goblog_free_callback_example()
    {
        return true;
    }

    // =================== Example For Switch ===================
    // Setting
    $wp_customize->add_setting(
        'example_switch_example',
        array(
            'default'           => 1,
            'transport'         => 'postMessage',
            'sanitize_callback' => 'goblog_free_switch_sanitization'
        )
    );

    // Control
    $wp_customize->add_control(new Goblog_Free_Customize_Toggle_Switch(
        $wp_customize,
        'example_switch_example',
        array(
            'label'   => __('Toggle switch', 'goblog-free'),
            'section' => 'example'
        )
    ));

    // =================== Example For Range ===================
    // Setting
    $wp_customize->add_setting(
        'example_range',
        array(
            'default'           => 5,
            'transport'         => 'postMessage',
            'sanitize_callback' => 'goblog_free_range_sanitization',
        )
    );

    // Control
    $wp_customize->add_control(new Goblog_Free_Customize_Range(
        $wp_customize,
        'example_range',
        array(
            'label'   => __('Font size: ( 5 )', 'goblog-free'),
            'min'     => 0,
            'max'     => 1250,
            'step'    => 1,
            'section' => 'example',
        )
    ));

    // =================== Example For Radio Text ===================
    // Setting
    $wp_customize->add_setting(
        'example_radio_text',
        array(
            'default'           => 'right',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'absint'
        )
    );

    // Control
    $wp_customize->add_control(new Goblog_Free_Customize_Radio_Text(
        $wp_customize,
        'example_radio_text',
        array(
            'label'        => __('Posisi', 'goblog-free'),
            'description'  => __('Sample custom control description', 'goblog-free'),
            'section'      => 'example',
            'choices'      => array(
                'left'     => __('Left', 'goblog-free'),
                'centered' => __('Center', 'goblog-free'),
                'right'    => __('Right', 'goblog-free')
            )
        )
    ));

    // =================== Example For Radio Image ===================
    // Setting
    $wp_customize->add_setting(
        'example_radio_image',
        array(
            'default'           => 'layout5',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'goblog_free_text_image_sanitization'
        )
    );

    // Control
    $wp_customize->add_control(new Goblog_Free_Customize_Radio_Image(
        $wp_customize,
        'example_radio_image',
        array(
            'label'       => __('Image Example 123', 'goblog-free'),
            'description' => __('Sample custom control description', 'goblog-free'),
            'section'     => 'example',
            'choices'     => array(
                'layout1' => array(
                    'image'   => trailingslashit(get_template_directory_uri()) . 'inc/customize/assets/images/example/post1.png',
                    'name'    => __('post1', 'goblog-free')
                ),
                'layout2' => array(
                    'image'   => trailingslashit(get_template_directory_uri()) . 'inc/customize/assets/images/example/post2.png',
                    'name'    => __('post2', 'goblog-free')
                ),
                'layout3' => array(
                    'image'    => trailingslashit(get_template_directory_uri()) . 'inc/customize/assets/images/example/post3.png',
                    'name'     => __('post3', 'goblog-free')
                ),
                'layout4' => array(
                    'image'   => trailingslashit(get_template_directory_uri()) . 'inc/customize/assets/images/example/post1.png',
                    'name'    => __('post1', 'goblog-free')
                ),
                'layout5' => array(
                    'image'   => trailingslashit(get_template_directory_uri()) . 'inc/customize/assets/images/example/post2.png',
                    'name'    => __('post2', 'goblog-free')
                ),
                'layout6' => array(
                    'image'    => trailingslashit(get_template_directory_uri()) . 'inc/customize/assets/images/example/post3.png',
                    'name'     => __('post3', 'goblog-free')
                )
            )
        )
    ));

    // =================== Example For Input Text ===================
    // Setting
    $wp_customize->add_setting(
        'untuk_url',
        array(
            'default'           => 'https://goblog-free.com',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'esc_url_raw'
        )
    );

    // Control
    $wp_customize->add_control(
        'untuk_url',
        array(
            'label'   => __('Masukan Link: ', 'goblog-free'),
            'section' => 'example',
            'type'    => 'text',
            'input_attrs'     => array(
                'class'       => 'type-input-text',
                'style'       => 'border: 1px solid #f5f5f5',
                'placeholder' => __('Masukan Link Valid', 'goblog-free'),
            ),
        )
    );

    // =================== Example For Input Area ===================
    // Setting
    $wp_customize->add_setting(
        'untuk_deskripsi',
        array(
            'default'           => 'Lorem ipsum dolor sit amet.',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'wp_filter_nohtml_kses'
        )
    );

    // Control
    $wp_customize->add_control(
        'untuk_deskripsi',
        array(
            'label'   => __('Deskripsi: ', 'goblog-free'),
            'section' => 'example',
            'type'    => 'textarea',
            'input_attrs'     => array(
                'class'       => 'type-input-area',
                'style'       => 'border: 1px solid #f5f5f5',
                'placeholder' => __('Masukan Deskripsi Singkat', 'goblog-free'),
            ),
        )
    );

    // =================== Example For Checkbox ===================
    // Setting
    $wp_customize->add_setting(
        'untuk_checkbox',
        array(
            'default'           => 1,
            'transport'         => 'postMessage',
            'sanitize_callback' => 'absint',
        )
    );

    // Control
    $wp_customize->add_control(
        'untuk_checkbox',
        array(
            'label'   => __('Display check: ', 'goblog-free'),
            'section' => 'example',
            'type'    => 'checkbox',
            'input_attrs'     => array(
                'class'       => 'type-input-checkbox',
                'style'       => 'border: 1px solid #f5f5f5',
            ),
        )
    );

    // =================== Example For Background Color ===================
    // Setting
    $wp_customize->add_setting(
        'untuk_color',
        array(
            'default'           => '#fff',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'sanitize_hex_color',
        )
    );

    // Control
    $wp_customize->add_control(new WP_Customize_Color_Control(
        $wp_customize,
        'untuk_color',
        array(
            'label'    => __('Background Color', 'goblog-free'),
            'section'  => 'example',
            'settings' => 'untuk_color',
        )
    ));
}
add_action('customize_register', 'goblog_free_customize_test');
