PHP code example of helgatheviking / kia-customizer-radio-image-control

1. Go to this page and download the library: Download helgatheviking/kia-customizer-radio-image-control library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

helgatheviking / kia-customizer-radio-image-control example snippets



/**
 * Add range slider to Customizer.
 *
 * @param  obj     $wp_customize
 */
function kia_customizer( $wp_customize ) {
    // Include the class
     );

    $wp_customize->add_setting(
        'my_setting',
        array(
            'default'              => 'tabular',
            'type'                 => 'option',
            'capability'           => 'edit_themes',
            'sanitize_callback'    => array( 'KIA_Customizer_Radio_Image_Control', 'sanitize' ),
            'sanitize_js_callback' => array( 'KIA_Customizer_Radio_Image_Control', 'sanitize' ),
        )
    );

	$wp_customize->add_control(
		new KIA_Customizer_Radio_Image_Control(
			$wp_customize,
			'my_setting',
			array(
				'label'       => __( 'Layout', 'your-textdomain' ),
				'section'  => 'my_section',
				'settings' => 'my_setting',
				'choices'     => array(
					'tabular' 	=> array(
						'label' => esc_html__( 'List', 'your-textdomain' ),
						'image' => 'assets/images/th-list.svg', // URL to image.
					),
					'grid'		=> array(
						'label' => esc_html__( 'Grid', 'your-textdomain' ),
						'image' => 'assets/images/th-grid.svg', // URL to image.
					),
				),
			),
		)
	);

}
add_action( 'customize_register', 'kia_customizer' );