Creating dropdown-pages control with Customize JS API

All base controls from the core can be created with the Customize JS API, except the dropdown pages control, that renders as a select list with all pages of the site. This means, we usually need to create that control via the PHP API at the moment.

As a reaction to a question, Weston Ruter wrote a plugin that lets us create the dropdown pages control via the JS API (some details on that can be found in his answer to the question). The important part is the print_control_templates() method that creates a control template for the JS API to use when it should create a dropdown-pages control. This template is included in the customizer with the following call in the init() method:

add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_control_templates' ) );

One post a week: How I made the #projekt52 in 2017

Like in 2016 I took part in the #projekt52, which was started by Torsten Landsiedel – little difference to 2016 is that I made it this year and didn't have to give up after only a few weeks. The reason for that was a small change of my attitude.

(Almost) no topic is too small for a post

The main reason for finishing the project this year was that I made the decision to stop thinking of topics as too small or unimportant for articles (I got that idea from a tweet, but unfortunately cannot say who wrote it anymore). Maybe it saves some time for another person or is helpful for yourself if you have the problem again after a while. So if I need to search for a longer time for a problem’s solution during a project, I create a draft for that.

With that, I often can finish a draft for my weekly posts instead of the need of searching a topic first. I hope to keep that output interval and write a post per week besides my weekly recap in 2018 too 🙂

Creating panels, sections, and controls with the Customize JS API

Until now I mostly used the PHP API of the customizer. Since Weston Ruter’s post about the improvements of the Customize JS API in WordPress 4.9, I wanted to change that and learn more about the Customize JS API. This post shows you how to create panels, sections, and controls with that API. Continue reading Creating panels, sections, and controls with the Customize JS API