Skip to content

Instantly share code, notes, and snippets.

@azizultex
Created July 26, 2016 11:31
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 azizultex/c65b9d8d5007dd67444d388d24a8397f to your computer and use it in GitHub Desktop.
Save azizultex/c65b9d8d5007dd67444d388d24a8397f to your computer and use it in GitHub Desktop.
Kirki demo settings
function superminimal_demo_panels_sections( $wp_customize ) {
/**
* Add Panel
*/
$wp_customize->add_panel( 'sitepoint_demo_panel', array(
'priority' => 10,
'title' => __( 'SitePoint Demo Panel', 'superminimal' ),
'description' => __( 'Kirki integration for SitePoint demo', 'superminimal' ),
) );
/**
* Add a Section for Site Text Colors
*/
$wp_customize->add_section( 'superminimal_text_colors', array(
'title' => __( 'Site Text Colors', 'superminimal' ),
'priority' => 10,
'panel' => 'sitepoint_demo_panel',
'description' => __( 'Section description.', 'superminimal' ),
) );
/**
* Add a Section for Site Layout
*/
$wp_customize->add_section( 'superminimal_site_layout', array(
'title' => __( 'Site Layout', 'superminimal' ),
'priority' => 10,
'panel' => 'sitepoint_demo_panel',
'description' => __( 'Section description.', 'superminimal' ),
) );
/**
* Add a Section for Footer Text
*/
$wp_customize->add_section( 'superminimal_footer_text', array(
'title' => __( 'Footer Text', 'superminimal' ),
'priority' => 10,
'panel' => 'sitepoint_demo_panel',
'description' => __( 'Section description.', 'superminimal' ),
) );
// $wp_customize->add_setting( 'setting_id', array(
// 'type' => 'theme_mod', // or 'option'
// 'capability' => 'edit_theme_options',
// 'theme_supports' => '', // Rarely needed.
// 'default' => '',
// 'transport' => 'refresh', // or postMessage
// 'sanitize_callback' => '',
// 'sanitize_js_callback' => '', // Basically to_json.
// ) );
// $wp_customize->add_control( 'setting_id', array(
// 'type' => 'date',
// 'priority' => 10, // Within the section.
// 'section' => 'superminimal_footer_text', // Required, core or custom.
// 'label' => __( 'Date' ),
// 'description' => __( 'This is a date control with a red border.' ),
// 'input_attrs' => array(
// 'class' => 'my-custom-class-for-js',
// 'style' => 'border: 1px solid #900',
// 'placeholder' => __( 'mm/dd/yyyy' ),
// )
// ) );
// $wp_customize->add_setting( 'setting_id_1', array(
// 'type' => 'theme_mod', // or 'option'
// 'capability' => 'edit_theme_options',
// 'theme_supports' => '', // Rarely needed.
// 'default' => '',
// 'transport' => 'refresh', // or postMessage
// 'sanitize_callback' => '',
// 'sanitize_js_callback' => '', // Basically to_json.
// ) );
// $wp_customize->add_control( 'setting_id_1', array(
// 'type' => 'range',
// 'section' => 'superminimal_footer_text',
// 'label' => __( 'Range' ),
// 'description' => __( 'This is the range control description.' ),
// 'input_attrs' => array(
// 'min' => 0,
// 'max' => 10,
// 'step' => 2,
// ),
// ) );
}
add_action( 'customize_register', 'superminimal_demo_panels_sections' );
function superminimal_demo_fields( $fields ) {
$fields[] = array(
'type' => 'textarea',
'setting' => 'superminimalsdf_footer_text',
'label' => __( 'Footer Text', 'superminimal' ),
'description' => __( 'Add some text to the footer', 'superminimal' ),
'section' => 'superminimal_footer_text',
'default' => 'Superminimal Theme – Kirki Toolkit Demo for SitePoint',
'priority' => 20,
);
$fields[] = array(
'type' => 'dashicons',
'settings' => 'my_setting_dashicons',
'label' => __( 'Dashicons Control', 'my_textdomain' ),
'section' => 'superminimal_footer_text',
'default' => 'menu',
'priority' => 10,
);
$fields[] = array(
'type' => 'multicolor',
'settings' => 'my_setting_multicolor',
'label' => esc_attr__( 'Label', 'my_textdomain' ),
'section' => 'superminimal_text_colors',
'priority' => 10,
'choices' => array(
'link' => esc_attr__( 'Color', 'my_textdomain' ),
'hover' => esc_attr__( 'Hover', 'my_textdomain' ),
'active' => esc_attr__( 'Active', 'my_textdomain' ),
),
'default' => array(
'link' => '#0088cc',
'hover' => '#00aaff',
'active' => '#00ffff',
),
);
$fields[] = array(
'type' => 'image',
'settings' => 'image_demo',
'label' => __( 'This is the label', 'my_textdomain' ),
'description' => __( 'This is the control description', 'my_textdomain' ),
'help' => __( 'This is some extra help text.', 'my_textdomain' ),
'section' => 'superminimal_site_layout',
'default' => '',
'priority' => 10,
);
$fields[] = array(
'type' => 'repeater',
'label' => esc_attr__( 'Repeater Control', 'my_textdomain' ),
'section' => 'superminimal_site_layout',
'priority' => 10,
'settings' => 'my_setting',
'default' => array(
array(
'link_text' => esc_attr__( 'Kirki Site', 'my_textdomain' ),
'link_url' => 'https://kirki.org',
),
array(
'link_text' => esc_attr__( 'Kirki Repository', 'my_textdomain' ),
'link_url' => 'https://github.com/aristath/kirki',
),
),
'fields' => array(
'link_text' => array(
'type' => 'text',
'label' => esc_attr__( 'Link Text', 'my_textdomain' ),
'description' => esc_attr__( 'This will be the label for your link', 'my_textdomain' ),
'default' => '',
),
'link_url' => array(
'type' => 'text',
'label' => esc_attr__( 'Link URL', 'my_textdomain' ),
'description' => esc_attr__( 'This will be the link URL', 'my_textdomain' ),
'default' => '',
),
)
);
$fields[] = array(
'type' => 'switch',
'settings' => 'my_setting',
'label' => __( 'This is the label', 'my_textdomain' ),
'section' => 'superminimal_text_colors',
'default' => '1',
'priority' => 10,
'choices' => array(
'on' => esc_attr__( 'Enable', 'my_textdomain' ),
'off' => esc_attr__( 'Disable', 'my_textdomain' ),
),
);
return $fields;
}
add_filter( 'kirki/fields', 'superminimal_demo_fields' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment