Get all registered wp theme customizer sections?

Is there a way to retrieve all the registered customizer sections? I’m building out a custom customizer and don’t want other plugin or themes who register custom sections to appear on this page.

I can remove all the default sections, but I can’t predict which plugins or themes will register sections.

$wp_customize->remove_section( 'title_tagline' );

removes the default title_tagline section.

I can see all of the registered sections by doing print_r( $wp_customize );. I would just loop over that section and build an array to un-register, but I can’t seem to access the array of registered sections due to it being protected.

Is there any other way to retreive registered sections?

2 Answers
2

Have you tried sections method? You can use $wp_customize->sections().

Example:

foreach ($wp_customize->sections() as $section_key => $section_object ) {
  echo $section_key . '<br />';
}

Leave a Comment