X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/af50974463450c98503e763a7836a50e260461a9..53f4633144ed68c8b8fb5861f992b5489894a940:/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..3857d507 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 +175,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 +215,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 +231,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 +250,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 +261,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 +289,194 @@ 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 ) . '' ); + echo sprintf( __( 'You are customizing %s' ), '{{ data.title }}' ); ?> +
    - description ) ) : ?> -
    - description; ?> + <# if ( data.description ) { #> +
    + {{{ data.description }}}
    - + <# } #>
  • render_screen_options(); + } + + /** + * Returns the advanced options for the nav menus page. + * + * Link title attribute added as it's a relatively advanced concept for new users. + * + * @since 4.3.0 + * @access public + * + * @return array The advanced menu properties. + */ + public function wp_nav_menu_manage_columns() { + return array( + '_title' => __( 'Show advanced menu properties' ), + 'cb' => '', + 'link-target' => __( 'Link Target' ), + 'attr-title' => __( 'Title Attribute' ), + 'css-classes' => __( 'CSS Classes' ), + 'xfn' => __( 'Link Relationship (XFN)' ), + 'description' => __( 'Description' ), + ); + } + + /** + * An Underscore (JS) template for this panel's content (but not its container). + * + * Class variables for this panel class are available in the `data` JS object; + * export custom variables by overriding WP_Customize_Panel::json(). + * + * @since 4.3.0 + * @access protected + * + * @see WP_Customize_Panel::print_template() + */ + protected function content_template() { + ?> +
  • + +
    + + {{ data.title }}' ); + ?> + + + +
    + <# if ( data.description ) { #> +
    {{{ data.description }}}
    + <# } #> + render_screen_options(); ?> +
  • +