Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverts the custom CSS to an experiment while we resolve the handling of unfiltered html capabilities #46663

Merged
merged 2 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ function gutenberg_enable_experiments() {
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-block-inspector-tabs', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableBlockInspectorTabs = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-global-styles-custom-css', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableGlobalStylesCustomCSS = true', 'before' );
}
}

add_action( 'admin_init', 'gutenberg_enable_experiments' );
16 changes: 16 additions & 0 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ function gutenberg_initialize_experiments_settings() {
)
);

add_settings_field(
'gutenberg-global-styles-custom-css',
__( 'Global styles custom css ', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => sprintf(
/* translators: %s: WordPress documentation for roles and capabilities. */
__( 'Test the Global Styles custom CSS field in the site editor. This requires a user to have <a href="%s">unfiltered html capabilities</a>.', 'gutenberg' ),
'https://wordpress.org/support/article/roles-and-capabilities/#unfiltered_html'
),
'id' => 'gutenberg-global-styles-custom-css',
)
);

register_setting(
'gutenberg-experiments',
'gutenberg-experiments'
Expand Down
61 changes: 34 additions & 27 deletions packages/edit-site/src/components/global-styles/screen-root.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ function ScreenRoot() {
};
}, [] );

const __experimentalGlobalStylesCustomCSS =
window?.__experimentalEnableGlobalStylesCustomCSS;
return (
<Card size="small">
<CardBody>
Expand Down Expand Up @@ -100,33 +102,38 @@ function ScreenRoot() {
</ItemGroup>
</CardBody>

<CardDivider />

<CardBody>
<Spacer
as="p"
paddingTop={ 2 }
paddingX="13px"
marginBottom={ 4 }
>
{ __(
'Add your own CSS to customize the appearance and layout of your site.'
) }
</Spacer>
<ItemGroup>
<NavigationButtonAsItem
path="/css"
aria-label={ __( 'Additional CSS' ) }
>
<HStack justify="space-between">
<FlexItem>{ __( 'Custom' ) }</FlexItem>
<IconWithCurrentColor
icon={ isRTL() ? chevronLeft : chevronRight }
/>
</HStack>
</NavigationButtonAsItem>
</ItemGroup>
</CardBody>
{ __experimentalGlobalStylesCustomCSS && (
<>
<CardDivider />
<CardBody>
<Spacer
as="p"
paddingTop={ 2 }
paddingX="13px"
marginBottom={ 4 }
>
{ __(
'Add your own CSS to customize the appearance and layout of your site.'
) }
</Spacer>
<ItemGroup>
<NavigationButtonAsItem
path="/css"
aria-label={ __( 'Additional CSS' ) }
>
<HStack justify="space-between">
<FlexItem>{ __( 'Custom' ) }</FlexItem>
<IconWithCurrentColor
icon={
isRTL() ? chevronLeft : chevronRight
}
/>
</HStack>
</NavigationButtonAsItem>
</ItemGroup>
</CardBody>
</>
) }
</Card>
);
}
Expand Down