wordpress 3.4 theme customizer

16
WordPress Meetup #12 July 22, 2012 WordPress Nepal wpnepal.org facebook.com/groups/wordpressnepal

Upload: chandra-maharzan

Post on 07-Nov-2014

1.149 views

Category:

Education


2 download

DESCRIPTION

Explaining what Theme Customizer is and how to use it in your own themes.

TRANSCRIPT

Page 1: WordPress 3.4 Theme Customizer

WordPress Meetup #12July 22, 2012

WordPress Nepalwpnepal.org

facebook.com/groups/wordpressnepal

Page 2: WordPress 3.4 Theme Customizer

WordPress 3.4Theme Customizer

Chandra Maharzannhuja.com

tweet @maharzan

Page 3: WordPress 3.4 Theme Customizer

Daryl KoopersmithWordPress Core Developer

Page 4: WordPress 3.4 Theme Customizer

Why use it?

• Live Preview - no rush

Page 5: WordPress 3.4 Theme Customizer

Quick Demo

Page 6: WordPress 3.4 Theme Customizer

First things !rst

• add_theme_support( 'custom-header' );

• add_theme_support( 'custom-background' );

• register_nav_menus ( );

Page 7: WordPress 3.4 Theme Customizer

Theme Options

• Theme Mod• set_theme_mod / get_theme_mod

• Individual Settings

• Serialized Settings• set_option / get_option

Page 8: WordPress 3.4 Theme Customizer

Structure

WP_Customize_Section

WP_Customize_Control

WP_Customize_Setting

Page 9: WordPress 3.4 Theme Customizer

Extensions

• WP_Customize_Upload_Control

• WP_Customize_Image_Control

• WP_Customize_Header_Image_Control

Page 10: WordPress 3.4 Theme Customizer

So, How do we do it?

• add_action( 'customize_register', 'my_function' );

• function my_function ( $wp_customize ) {

• $wp_customize->add_section( );

• $wp_customize->add_setting( );

• $wp_customize->add_control( );

Page 11: WordPress 3.4 Theme Customizer

The LIVE FUN!

• 'transport' => 'postMessage'• $wp_customize->add_setting( 'cleanr_options[color]', array(

'default' => '', 'type' => 'option', 'capability' => 'edit_theme_options', 'transport' => 'postMessage') );

Page 12: WordPress 3.4 Theme Customizer

• if ( $wp_customize->is_preview() && ! is_admin() )add_action( 'wp_footer', 'my_custom_preview', 21);

• <?php function my_custom_preview() { ?> <script type="text/javascript"> ( function( $ ){ wp.customize( 'setting_name', function( value ) { value.bind( function( to ) { $( '.posttitle' ).css( 'color', to ? '#' + to : '' ); }); }); } )( jQuery );</script><?php } ?>

Page 13: WordPress 3.4 Theme Customizer

Lets see some code!

Page 14: WordPress 3.4 Theme Customizer

Improvements

• Textarea Type

• CSS Plugin by Daryl Koop

• Clear Color HEX

• Refresh Time

Page 15: WordPress 3.4 Theme Customizer

References

• http://ottopress.com

• http://codex.wordpress.org

• http://graphpaperpress.com

Page 16: WordPress 3.4 Theme Customizer

Thank youQuestions?