Customize: Introduce custom CSS for extending theme styles.

* Custom CSS is associated with a given theme and is displayed in an inline `style` element at the `wp_head` hook after the `wp_print_styles` is called so that it overrides any enqueued stylesheets.
* A `wp_get_custom_css()` function is used for accessing the CSS associated with the current theme (or another theme) and a `wp_get_custom_css` filter for manipulating it.
* CSS is managed in customizer via a new "Additional CSS" section with a single `textarea` control. 
* `WP_Customize_Section::$description_hidden` is introduced for hiding extended descriptions in customizer sections behind a help toggle as done with panels.
* CSS is stored in a `custom_css` post type with the theme (stylesheet) slug as the `post_name`.
* `WP_Customize_Custom_CSS_Setting` is introduced to handle validation of CSS, previewing, and persisting the CSS to the `custom_css` post type.
* The `custom_css` setting is tied to a new `unfiltered_css` capability which maps to `unfiltered_html` by default.
* Escaping the message in the notification template is removed to allow markup (`code` tags) to be rendered.

See https://make.wordpress.org/core/2016/10/11/feature-proposal-better-theme-customizations-via-custom-css-with-live-previews/

Props johnregan3, celloexpressions, folletto, westonruter.
Fixes #35395.


git-svn-id: https://develop.svn.wordpress.org/trunk@38829 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter
2016-10-19 18:14:21 +00:00
parent 949d991913
commit 76226c9b41
12 changed files with 855 additions and 11 deletions
+29
View File
@@ -111,6 +111,35 @@ function create_initial_post_types() {
'query_var' => false,
) );
register_post_type( 'custom_css', array(
'labels' => array(
'name' => __( 'Custom CSS' ),
'singular_name' => __( 'Custom CSS' ),
),
'public' => false,
'hierarchical' => false,
'rewrite' => false,
'query_var' => false,
'delete_with_user' => false,
'can_export' => true,
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'supports' => array( 'title' ),
'capabilities' => array(
'delete_posts' => 'edit_theme_options',
'delete_post' => 'edit_theme_options',
'delete_published_posts' => 'edit_theme_options',
'delete_private_posts' => 'edit_theme_options',
'delete_others_posts' => 'edit_theme_options',
'edit_post' => 'unfiltered_css',
'edit_posts' => 'unfiltered_css',
'edit_others_posts' => 'unfiltered_css',
'edit_published_posts' => 'unfiltered_css',
'read_post' => 'read',
'read_private_posts' => 'read',
'publish_posts' => 'edit_theme_options',
),
) );
register_post_type( 'customize_changeset', array(
'labels' => array(
'name' => _x( 'Changesets', 'post type general name' ),