X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/849f15aeed7a5e39314057bdc0064d8edd60dd7d..d3947bc013df7edd54b46deed8230d2eeafc5ecb:/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 f5da18e3..d5441f63 100644 --- a/wp-includes/class-wp-customize-panel.php +++ b/wp-includes/class-wp-customize-panel.php @@ -1,13 +1,21 @@ instance_number = self::$instance_count; $this->sections = array(); // Users cannot customize the $sections array. - - return $this; } /** @@ -166,7 +174,7 @@ class WP_Customize_Panel { * * @return bool Whether the panel is active to the current preview. */ - public final function active() { + final public function active() { $panel = $this; $active = call_user_func( $this->active_callback, $this ); @@ -206,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; @@ -221,7 +230,7 @@ class WP_Customize_Panel { * * @return bool False if theme doesn't support the panel or the user doesn't have the capability. */ - public final function check_capabilities() { + final public function check_capabilities() { if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) { return false; } @@ -240,12 +249,10 @@ class WP_Customize_Panel { * * @return string Content for the panel. */ - public final function get_content() { + 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() ); } /** @@ -253,7 +260,7 @@ class WP_Customize_Panel { * * @since 4.0.0 */ - public final function maybe_render() { + final public function maybe_render() { if ( ! $this->check_capabilities() ) { return; } @@ -281,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 {@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 {@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 }}}
    - + <# } #>