From ba9ee74028c3aec9c64d7fcd49388de17c12a1a6 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 14 Aug 2014 04:40:17 +0000 Subject: [PATCH] Separate WP_Customize_Panel from WP_Customize_Section. props celloexpressions. fixes #29197. Built from https://develop.svn.wordpress.org/trunk@29487 git-svn-id: http://core.svn.wordpress.org/trunk@29265 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-manager.php | 1 + wp-includes/class-wp-customize-panel.php | 201 +++++++++++++++++++++ wp-includes/class-wp-customize-section.php | 79 -------- 3 files changed, 202 insertions(+), 79 deletions(-) create mode 100644 wp-includes/class-wp-customize-panel.php diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index 1e23944038..6a04ea7a12 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -66,6 +66,7 @@ final class WP_Customize_Manager { */ public function __construct() { require( ABSPATH . WPINC . '/class-wp-customize-setting.php' ); + require( ABSPATH . WPINC . '/class-wp-customize-panel.php' ); require( ABSPATH . WPINC . '/class-wp-customize-section.php' ); require( ABSPATH . WPINC . '/class-wp-customize-control.php' ); require( ABSPATH . WPINC . '/class-wp-customize-widgets.php' ); diff --git a/wp-includes/class-wp-customize-panel.php b/wp-includes/class-wp-customize-panel.php new file mode 100644 index 0000000000..379129e4cc --- /dev/null +++ b/wp-includes/class-wp-customize-panel.php @@ -0,0 +1,201 @@ +$key = $args[ $key ]; + } + } + + $this->manager = $manager; + $this->id = $id; + + $this->sections = array(); // Users cannot customize the $sections array. + + return $this; + } + + /** + * Checks required user capabilities and whether the theme has the + * feature support required by the panel. + * + * @since 4.0.0 + * + * @return bool False if theme doesn't support the panel or the user doesn't have the capability. + */ + public final function check_capabilities() { + if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) { + return false; + } + + if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) { + return false; + } + + return true; + } + + /** + * Check capabilities and render the panel. + * + * @since 4.0.0 + */ + public final function maybe_render() { + if ( ! $this->check_capabilities() ) { + return; + } + + /** + * Fires before rendering a Customizer panel. + * + * @since 4.0.0 + * + * @param WP_Customize_Panel $this WP_Customize_Panel instance. + */ + do_action( 'customize_render_panel', $this ); + + /** + * Fires before rendering a specific Customizer panel. + * + * The dynamic portion of the hook name, $this->id, refers to the ID + * of the specific Customizer panel to be rendered. + * + * @since 4.0.0 + */ + do_action( "customize_render_panel_{$this->id}" ); + + $this->render(); + } + + /** + * Render the panel, and the sections that have been added to it. + * + * @since 4.0.0 + * @access protected + */ + protected function render() { + ?> +
  • +

    + title ); ?> + +

    + + +
  • + sections = array(); // Users cannot customize the $sections array. - - return $this; - } - - /** - * Render the panel, and the sections that have been added to it. - * - * @since 4.0.0 - * @access protected - */ - protected function render() { - ?> -
  • -

    - title ); ?> - -

    - - -
  • -