Skip to content

Instantly share code, notes, and snippets.

@albarin
Last active August 5, 2022 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albarin/ed365a35083b1861d7deeacba268cf29 to your computer and use it in GitHub Desktop.
Save albarin/ed365a35083b1861d7deeacba268cf29 to your computer and use it in GitHub Desktop.
<?php
add_action( 'customize_register', 'test_customize_register' );
function test_customize_register($wp_customize) {
$wp_customize->add_section(
'test_section',
array(
'title' => __( 'Test section', 'woocommerce' ),
'priority' => 10,
'panel' => 'woocommerce',
)
);
$wp_customize->add_setting(
'test_setting',
array(
'default' => 'no',
'type' => 'option',
'capability' => 'manage_woocommerce',
'sanitize_callback' => 'wc_bool_to_string',
'sanitize_js_callback' => 'wc_string_to_bool',
)
);
$wp_customize->add_control(
'test_setting',
array(
'label' => __( 'Enable it!', 'woocommerce' ),
'section' => 'test_section',
'settings' => 'test_setting',
'type' => 'checkbox',
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment