X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/7f1521bf193b382565eb753043c161f4cb3fcda7..8d3bb1a5dcfdea9857d3c88c3751f09593e34dc8:/wp-includes/class-wp-customize-panel.php diff --git a/wp-includes/class-wp-customize-panel.php b/wp-includes/class-wp-customize-panel.php index ee9f846b..46e604a9 100644 --- a/wp-includes/class-wp-customize-panel.php +++ b/wp-includes/class-wp-customize-panel.php @@ -24,6 +24,8 @@ class WP_Customize_Panel { * Used when sorting two instances whose priorities are equal. * * @since 4.1.0 + * + * @static * @access protected * @var int */ @@ -128,9 +130,9 @@ class WP_Customize_Panel { * @see WP_Customize_Section::active() * * @var callable Callback is called with one argument, the instance of - * {@see WP_Customize_Section}, and returns bool to indicate - * whether the section is active (such as it relates to the URL - * currently being previewed). + * WP_Customize_Section, and returns bool to indicate whether + * the section is active (such as it relates to the URL currently + * being previewed). */ public $active_callback = ''; @@ -177,12 +179,12 @@ class WP_Customize_Panel { $active = call_user_func( $this->active_callback, $this ); /** - * Filter response of WP_Customize_Panel::active(). + * Filters response of WP_Customize_Panel::active(). * * @since 4.1.0 * - * @param bool $active Whether the Customizer panel is active. - * @param WP_Customize_Panel $panel {@see WP_Customize_Panel} instance. + * @param bool $active Whether the Customizer panel is active. + * @param WP_Customize_Panel $panel WP_Customize_Panel instance. */ $active = apply_filters( 'customize_panel_active', $active, $panel ); @@ -190,7 +192,7 @@ class WP_Customize_Panel { } /** - * Default callback used when invoking {@see WP_Customize_Panel::active()}. + * Default callback used when invoking WP_Customize_Panel::active(). * * Subclasses can override this with their specific logic, or they may * provide an 'active_callback' argument to the constructor. @@ -212,7 +214,8 @@ class WP_Customize_Panel { * @return array The array to be exported to the client as JSON. */ public function json() { - $array = wp_array_slice_assoc( (array) $this, array( 'title', 'description', 'priority', 'type' ) ); + $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'type' ) ); + $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); $array['content'] = $this->get_content(); $array['active'] = $this->active(); $array['instanceNumber'] = $this->instance_number; @@ -249,9 +252,7 @@ class WP_Customize_Panel { final public function get_content() { ob_start(); $this->maybe_render(); - $template = trim( ob_get_contents() ); - ob_end_clean(); - return $template; + return trim( ob_get_clean() ); } /** @@ -287,47 +288,102 @@ class WP_Customize_Panel { } /** - * Render the panel container, and then its contents. + * Render the panel container, and then its contents (via `this->render_content()`) in a subclass. + * + * Panel containers are now rendered in JS by default, see WP_Customize_Panel::print_template(). * * @since 4.0.0 * @access protected */ - protected function render() { - $classes = 'accordion-section control-section control-panel control-panel-' . $this->type; + protected function render() {} + + /** + * Render the panel UI in a subclass. + * + * Panel contents are now rendered in JS by default, see WP_Customize_Panel::print_template(). + * + * @since 4.1.0 + * @access protected + */ + protected function render_content() {} + + /** + * Render the panel's JS templates. + * + * This function is only run for panel types that have been registered with + * WP_Customize_Manager::register_panel_type(). + * + * @since 4.3.0 + * + * @see WP_Customize_Manager::register_panel_type() + */ + public function print_template() { + ?> + + + -
  • +
  • - title ); ?> + {{ data.title }}

    - +
  • -
  • -
    +
  • + +
    ' . esc_html( $this->title ) . '' ); + /* translators: %s: the site/panel title in the Customizer */ + echo sprintf( __( 'You are customizing %s' ), '{{ data.title }}' ); ?> + <# if ( data.description ) { #> + + <# } #>
    - description ) ) : ?> -
    - description; ?> + <# if ( data.description ) { #> +
    + {{{ data.description }}}
    - + <# } #>