From b20cda2d4b252353360327a2051dd6b05158f41d Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 9 Nov 2016 01:11:49 +0000 Subject: [PATCH] Customize: Rename `unfiltered_css` meta capability to `edit_css`; add `revisions` support to `custom_css` post type. Props lukecavanagh, georgestephanis, westonruter. See #38672, #35395. git-svn-id: https://develop.svn.wordpress.org/trunk@39175 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/capabilities.php | 2 +- src/wp-includes/class-wp-customize-manager.php | 2 +- .../class-wp-customize-custom-css-setting.php | 2 +- src/wp-includes/post.php | 10 +++++----- tests/phpunit/tests/customize/custom-css-setting.php | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/capabilities.php b/src/wp-includes/capabilities.php index fe87bc8d70..35b0b5f762 100644 --- a/src/wp-includes/capabilities.php +++ b/src/wp-includes/capabilities.php @@ -320,7 +320,7 @@ function map_meta_cap( $cap, $user_id ) { else $caps[] = 'do_not_allow'; break; - case 'unfiltered_css' : + case 'edit_css' : case 'unfiltered_html' : // Disallow unfiltered_html for all users, even admins and super admins. if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 13856ceb0c..96acb450ec 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -3598,7 +3598,7 @@ final class WP_Customize_Manager { ) ); $custom_css_setting = new WP_Customize_Custom_CSS_Setting( $this, sprintf( 'custom_css[%s]', get_stylesheet() ), array( - 'capability' => 'unfiltered_css', + 'capability' => 'edit_css', 'default' => sprintf( "/*\n%s\n*/", __( "You can add your own CSS here.\n\nClick the help icon above to learn more." ) ), ) ); $this->add_setting( $custom_css_setting ); diff --git a/src/wp-includes/customize/class-wp-customize-custom-css-setting.php b/src/wp-includes/customize/class-wp-customize-custom-css-setting.php index 17e01fc6a5..034e081484 100644 --- a/src/wp-includes/customize/class-wp-customize-custom-css-setting.php +++ b/src/wp-includes/customize/class-wp-customize-custom-css-setting.php @@ -46,7 +46,7 @@ final class WP_Customize_Custom_CSS_Setting extends WP_Customize_Setting { * * @var string */ - public $capability = 'unfiltered_css'; + public $capability = 'edit_css'; /** * Stylesheet diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 89ddaaa711..e1276cdcb7 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -133,17 +133,17 @@ function create_initial_post_types() { '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' ), + 'supports' => array( 'title', 'revisions' ), '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', + 'edit_post' => 'edit_css', + 'edit_posts' => 'edit_css', + 'edit_others_posts' => 'edit_css', + 'edit_published_posts' => 'edit_css', 'read_post' => 'read', 'read_private_posts' => 'read', 'publish_posts' => 'edit_theme_options', diff --git a/tests/phpunit/tests/customize/custom-css-setting.php b/tests/phpunit/tests/customize/custom-css-setting.php index 138f3a0f09..fea097644d 100644 --- a/tests/phpunit/tests/customize/custom-css-setting.php +++ b/tests/phpunit/tests/customize/custom-css-setting.php @@ -79,7 +79,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { $this->assertTrue( post_type_exists( 'custom_css' ) ); $this->assertEquals( 'custom_css', $this->setting->type ); $this->assertEquals( 'twentysixteen', $this->setting->stylesheet ); - $this->assertEquals( 'unfiltered_css', $this->setting->capability ); + $this->assertEquals( 'edit_css', $this->setting->capability ); $exception = null; try {