Skip to content

Instantly share code, notes, and snippets.

View Jespertastesen's full-sized avatar

Jesper Tastesen Jespertastesen

View GitHub Profile
function themedemo_customize($wp_customize)
{
$wp_customize->add_section( 'themedemo_demo_settings', array(
'title' => 'Indstillinger',
'priority' => 35,
) );
$wp_customize->add_setting( 'headline-1', array(
'default' => 'default_value',
@Jespertastesen
Jespertastesen / WP Customizer - Text
Created May 27, 2017 16:13 — forked from ajskelton/WP Customizer - Text
Add a Text field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_text_setting_id', array(
'capability' => 'edit_theme_options',
'default' => 'Lorem Ipsum',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( 'themeslug_text_setting_id', array(
'type' => 'text',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Text' ),
@Jespertastesen
Jespertastesen / WP Customizer - Textarea
Created May 27, 2017 16:13 — forked from ajskelton/WP Customizer - Textarea
Add a Textarea field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_textarea_setting_id', array(
'capability' => 'edit_theme_options',
'default' => 'Lorem Ipsum Dolor Sit amet',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( 'themeslug_textarea_setting_id', array(
'type' => 'textarea',
'section' => 'custom_section', // // Add a default or your own section
'label' => __( 'Custom Text Area' ),
@Jespertastesen
Jespertastesen / WP Customizer - Date
Created May 27, 2017 16:13 — forked from ajskelton/WP Customizer - Date
Add a Date field to the WordPress Customizer. Includes sanitize function for displaying date as '2016-10-25'.
$wp_customize->add_setting( 'date_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_date',
) );
$wp_customize->add_control( 'date_setting_id', array(
'type' => 'date',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Date' ),
'description' => __( 'This is a custom date control.' ),
@Jespertastesen
Jespertastesen / WP Customizer - URL
Created May 27, 2017 16:13 — forked from ajskelton/WP Customizer - URL
Add a URL field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_url_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_url',
) );
$wp_customize->add_control( 'themeslug_url_setting_id', array(
'type' => 'url',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom URL' ),
'description' => __( 'This is a custom url input.' ),
@Jespertastesen
Jespertastesen / WP Customizer - Email
Created May 27, 2017 16:13 — forked from ajskelton/WP Customizer - Email
Add a Email field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_email_setting_id', array(
'capability' => 'edit_theme_options',
'default' => '',
'sanitize_callback' => 'themeslug_sanitize_email',
) );
$wp_customize->add_control( 'themeslug_email_setting_id', array(
'type' => 'email',
'section' => 'custom_section', // Required, core or custom.
'label' => __( 'Custom Email' ),
@Jespertastesen
Jespertastesen / WP Customizer - Checkbox
Created May 27, 2017 16:13 — forked from ajskelton/WP Customizer - Checkbox
Add a Checkbox field to the WordPress Customizer.
$wp_customize->add_setting( 'themecheck_checkbox_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_checkbox',
) );
$wp_customize->add_control( 'themeslug_checkbox_setting_id', array(
'type' => 'checkbox',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Checkbox' ),
'description' => __( 'This is a custom checkbox input.' ),
@Jespertastesen
Jespertastesen / WP Customizer - Radio Buttons
Created May 27, 2017 16:12 — forked from ajskelton/WP Customizer - Radio Buttons
Add a Radio field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_radio_setting_id', array(
'capability' => 'edit_theme_options',
'default' => 'blue',
'sanitize_callback' => 'themeslug_customizer_sanitize_radio',
) );
$wp_customize->add_control( 'themeslug_radio_setting_id', array(
'type' => 'radio',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Radio Selection' ),
@Jespertastesen
Jespertastesen / WP Customizer - Select
Created May 27, 2017 16:12 — forked from ajskelton/WP Customizer - Select
Add a Select field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_select_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_select',
'default' => 'value1',
) );
$wp_customize->add_control( 'themeslug_select_setting_id', array(
'type' => 'select',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Select Option' ),