PHP code example of nsrosenqvist / cmb2-switch

1. Go to this page and download the library: Download nsrosenqvist/cmb2-switch 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/ */

    

nsrosenqvist / cmb2-switch example snippets


$analytics = new_cmb2_box(array(
    'id'            => 'analytics',
    'title'         => __('Analytics', 'theme'),
));

$analytics_state = $analytics->add_field(array(
    'name' => __( 'Enable Analytics?', 'theme'),
    'id'   => 'analytics_state',
    'type'    => 'switch',
    'default' => cmb2_set_switch_default(true),
));