Skip to content

Instantly share code, notes, and snippets.

@ControlledChaos
Forked from ajskelton/WP Customizer - URL
Created January 19, 2020 06:32
Show Gist options
  • Save ControlledChaos/e91b091899788ecae82e316393548f45 to your computer and use it in GitHub Desktop.
Save ControlledChaos/e91b091899788ecae82e316393548f45 to your computer and use it in GitHub Desktop.

Revisions

  1. @ajskelton ajskelton renamed this gist Oct 25, 2016. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions WP Customizer - Url → WP Customizer - URL
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,3 @@
    /*
    * Custom URL Field
    */

    $wp_customize->add_setting( 'themeslug_url_setting_id', array(
    'capability' => 'edit_theme_options',
    'sanitize_callback' => 'themeslug_sanitize_url',
  2. @ajskelton ajskelton created this gist Oct 25, 2016.
    22 changes: 22 additions & 0 deletions WP Customizer - Url
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    /*
    * Custom URL Field
    */

    $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.' ),
    'input_attrs' => array(
    'placeholder' => __( 'http://www.google.com' ),
    ),
    ) );

    function themeslug_sanitize_url( $url ) {
    return esc_url_raw( $url );
    }