Skip to content

Instantly share code, notes, and snippets.

@ibllex
Forked from slushman/customizer-links.php
Created February 16, 2022 07:03
Show Gist options
  • Save ibllex/ca87fab28fbc913593665095a2846ab6 to your computer and use it in GitHub Desktop.
Save ibllex/ca87fab28fbc913593665095a2846ab6 to your computer and use it in GitHub Desktop.

Revisions

  1. @slushman slushman revised this gist Jun 3, 2016. No changes.
  2. @slushman slushman revised this gist Jun 3, 2016. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions customizer-links.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    /**
    * How to link into the WordPress Customizer
    */

    Simple Link:
    <a href="<?php echo esc_url( admin_url( 'customize.php' ) ); ?>">Link to Customizer</a>

  3. @slushman slushman renamed this gist Jun 3, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @slushman slushman created this gist Jun 3, 2016.
    47 changes: 47 additions & 0 deletions customizer-links.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    Simple Link:
    <a href="<?php echo esc_url( admin_url( 'customize.php' ) ); ?>">Link to Customizer</a>


    Link to Panel:
    $query['autofocus[panel]'] = 'nav_menus';
    $panel_link = add_query_arg( $query, admin_url( 'customize.php' ) );
    ?><a href="<?php echo esc_url( $panel_link ); ?>">Link to Panel</a>


    Link to section:
    $query['autofocus[section]'] = 'title_tagline';
    $section_link = add_query_arg( $query, admin_url( 'customize.php' ) );
    ?><a href="<?php echo esc_url( $section_link ); ?>">Link to Section</a>


    Link to control (field)
    $query['autofocus[control]'] = 'blogname';
    $control_link = add_query_arg( $query, admin_url( 'customize.php' ) );
    ?><a href="<?php echo esc_url( $control_link ); ?>">Link to Control</a>


    Return somewhere else after the Customizer:
    $query['return'] = admin_url();
    $link_with_return = add_query_arg( $query, admin_url( 'customize.php' ) );


    Link to control, the return to another page:
    $query['autofocus[control]'] = 'blogname';
    $query['return'] = admin_url( 'post-new.php' );
    $link = add_query_arg( $query, admin_url( 'customize.php' ) );
    ?><a href="<?php echo esc_url( $link ); ?>">Set title, then write post</a>


    Set Preview page:
    $query['url'] = site_url( '/news' );
    $link = add_query_arg( $query, admin_url( 'customize.php' ) );
    ?><a href="<?php echo esc_url( $link ); ?>">News Page in Preview</a>



    All together:
    $query['autofocus[section]'] = 'menu_locations';
    $query['return'] = admin_url( 'post-new.php?post_type=page' );
    $query['url'] = site_url( '/about-us' );
    $link = add_query_arg( $query, admin_url( 'customize.php' ) );
    ?><a href="<?php echo esc_url( $link ); ?>">Craziness!</a>