際際滷

際際滷Share a Scribd company logo
CUSTOMIZING THE
WORDPRESS CUSTOMIZER
Jason Yingling | @jason_yingling | jasonyingling.me
Sliding container of
sections.
Panels
Groups of options.
Controls are added to
sections.
Sections
Where a customizer control stores its data.
Ex. The selected hex value of a color picker.
Settings
An HTML form element
displayed in a
customizer section
allowing a setting to be
updated.
Control
Define customize_register action
Adding a Panel
Adding a Section
Adding a Setting
Sanitizing Data
sanitize_text_field()
sanitize_hex_color()
sanitize_hex_color_nohash()
Plenty more:
https://codex.wordpress.org/Data_Validation
Transport: refresh vs
postMessage
refresh - causes the page to ajax reload when control
is updated
postMessage - Allows for live updating through JavaScript
when control is updated
Adding a Control
Types of ControlsWP_Customize_Control()
Creates a control that allows users to enter plain text. This is also the parent class for the classes that follow.
WP_Customize_Color_Control()
Creates a control that allows users to select a color from a color wheel.
WP_Customize_Upload_Control()
Creates a control that allows users to upload media.
WP_Customize_Image_Control()
Creates a control that allows users to select or upload an image.
WP_Customize_Background_Image_Control()
Creates a control that allows users to select a new background image.
WP_Customize_Header_Image_Control()
Creates a control that allows users to select a new header image.
Outputting CSS with wp_head
Live Updating Settings
Changing Settings
Moving Controls to Different
Sections
Removing Sections
19
- https://codex.wordpress.org/Theme_Cus
tomization_API
- Team Treehouse
- @jason_yingling
- jason.yingling@red8interactive.com
Questions &
Resources
Customizing the WordPress Customizer

More Related Content

Customizing the WordPress Customizer

Editor's Notes

  • #8: Priority controls the placement of the panel among other panels theme_colors is the slug and will be used to add sections to this panel Title sets the title of the panel Description sets the description
  • #9: panel lets you add section to an existing panel
  • #10: Slug will be used when we add a control Default allows setting the default setting option sanitize callback allows you to sanitize data entered by a control. required if you want to submit to .org. Good idea regardless. transport can be postMessage or refresh. Default is refresh and causes the page to reload when the option is changed. postMessage allows for updating with JS.
  • #14: WP Customize Control can be used to make any types of form inputs. Selects, text fields, checkboxes, ranges, etc.
  • #15: Could also use the custom_header function as done in _s You can also use get_theme_mod in theme files
  • #19: Dont remove core features if you plan to submit the theme to WordPress.org