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

Tweak: Theme settings page [ED-11811] #331

Merged
merged 5 commits into from
Oct 19, 2023
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
14 changes: 14 additions & 0 deletions assets/dev/js/admin/hello-admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@
background: #ffffff;
}

.components-notice {
margin: 0;
margin-block-end: 20px;

.dashicon {
padding-inline-end: 10px;
color: #f0b849;
}

button {
display: none;
}
}

.code-example {
display: inline-block;
margin-block-end: 1.5rem;
Expand Down
28 changes: 17 additions & 11 deletions assets/dev/js/admin/pages/panels/scripts-styles.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,58 @@
import { __ } from '@wordpress/i18n';
import { SETTINGS } from '../settings.js';
import { PanelBody, ToggleControl } from '@wordpress/components';
import { PanelBody, ToggleControl, Notice, Dashicon } from '@wordpress/components';

export const PanelScriptsStyles = ( { settingsData, updateSettings } ) => {
return (
<PanelBody title={ __( 'Scripts & Styles', 'hello-elementor' ) } >

<Notice status="warning" isDismissible="false">
<Dashicon icon="flag" />
{ __( 'Be cautious, disabling some of the following options may break your website.', 'hello-elementor' ) }
</Notice>

<ToggleControl
label={ __( 'Unregister Emoji scripts & styles', 'hello-elementor' ) }
help={ __( 'Scripts and styles required to display Emojis.', 'hello-elementor' ) }
help={ __( 'Disable emoji-related scripts and styles.', 'hello-elementor' ) }
checked={ !! settingsData[ SETTINGS.EMOJI ] || false }
onChange={ ( value ) => updateSettings( SETTINGS.EMOJI, value ) }
/>

<ToggleControl
label={ __( 'Unregister oEmbed script', 'hello-elementor' ) }
help={ __( 'oEmbed-specific JavaScript that loads embeded elements from external recources.', 'hello-elementor' ) }
checked={ !! settingsData[ SETTINGS.OEMBED_SCRIPT ] || false }
onChange={ ( value ) => updateSettings( SETTINGS.OEMBED_SCRIPT, value ) }
label={ __( 'Unregister wp-embed script', 'hello-elementor' ) }
help={ __( 'Disable the script which is responsible for embedding external resources.', 'hello-elementor' ) }
checked={ !! settingsData[ SETTINGS.WP_EMBED_SCRIPT ] || false }
onChange={ ( value ) => updateSettings( SETTINGS.WP_EMBED_SCRIPT, value ) }
/>
<code className="code-example"> &lt;script type=&quot;text/javascript&quot; src=&quot;https://{ window.location.hostname }/wp-includes/js/wp-embeds.min.js&quot; /&gt; </code>
<code className="code-example"> &lt;script type=&quot;text/javascript&quot; src=&quot;https://{ window.location.hostname }/wp-includes/js/wp-embed.min.js&quot; /&gt; </code>

<ToggleControl
label={ __( 'Unregister classic-theme styles', 'hello-elementor' ) }
help={ __( "Styles associated with the classic themes that don't use Gutenberg.", 'hello-elementor' ) }
help={ __( "Disable the styles associated with classic themes that don't use Gutenberg.", 'hello-elementor' ) }
checked={ !! settingsData[ SETTINGS.CLASSIC_THEME_STYLES ] || false }
onChange={ ( value ) => updateSettings( SETTINGS.CLASSIC_THEME_STYLES, value ) }
/>
<code className="code-example"> &lt;link rel=&quot;stylesheet&quot; href=&quot;https://{ window.location.hostname }/wp-includes/css/classic-themes.min.css&quot; /&gt; </code>

<ToggleControl
label={ __( 'Unregister Gutenberg styles', 'hello-elementor' ) }
help={ __( 'Gutenberg styles for a cleaner look and enhanced website performance.', 'hello-elementor' ) }
help={ __( 'Disable all Gutenberg-related CSS, both static and inline styles.', 'hello-elementor' ) }
checked={ !! settingsData[ SETTINGS.GUTENBERG ] || false }
onChange={ ( value ) => updateSettings( SETTINGS.GUTENBERG, value ) }
/>
<code className="code-example"> &lt;link rel=&quot;stylesheet&quot; href=&quot;http://dev.local/wp-includes/css/dist/block-library/style.css&quot; /&gt; </code>

<ToggleControl
label={ __( 'Unregister Hello style.css', 'hello-elementor' ) }
help={ __( "Hello theme's style.css file which contains CSS reset rules.", 'hello-elementor' ) }
help={ __( "Disable Hello theme's style.css file which contains CSS reset rules for unified cross-browser view.", 'hello-elementor' ) }
checked={ !! settingsData[ SETTINGS.HELLO_STYLE ] || false }
onChange={ ( value ) => updateSettings( SETTINGS.HELLO_STYLE, value ) }
/>
<code className="code-example"> &lt;link rel=&quot;stylesheet&quot; href=&quot;http://{ window.location.hostname }/wp-content/themes/hello-theme/style.min.css&quot; /&gt; </code>

<ToggleControl
label={ __( 'Unregister Hello theme.css', 'hello-elementor' ) }
help={ __( "Hello theme's theme.css file which contains CSS rules that style WordPress elements.", 'hello-elementor' ) }
help={ __( "Disable Hello theme's theme.css file which contains CSS rules that style WordPress elements.", 'hello-elementor' ) }
checked={ !! settingsData[ SETTINGS.HELLO_THEME ] || false }
onChange={ ( value ) => updateSettings( SETTINGS.HELLO_THEME, value ) }
/>
Expand Down
2 changes: 1 addition & 1 deletion assets/dev/js/admin/pages/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const SETTINGS = {
POST_COMMENTS_RSS: '_post_comments_rss',
/* Scripts & Styles */
EMOJI: '_emoji',
OEMBED_SCRIPT: '_oembed_script',
WP_EMBED_SCRIPT: '_wp_embed_script',
CLASSIC_THEME_STYLES: '_classic_theme_styles',
GUTENBERG: '_gutenberg',
HELLO_STYLE: '_hello_style',
Expand Down
4 changes: 2 additions & 2 deletions includes/settings-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function hello_elementor_tweak_settings() {
'POST_COMMENTS_RSS' => '_post_comments_rss',
/* Scripts & Styles */
'EMOJI' => '_emoji',
'OEMBED_SCRIPT' => '_oembed_script',
'WP_EMBED_SCRIPT' => '_wp_embed_script',
'CLASSIC_THEME_STYLES' => '_classic_theme_styles',
'GUTENBERG' => '_gutenberg',
'HELLO_STYLE' => '_hello_style',
Expand Down Expand Up @@ -207,7 +207,7 @@ function hello_elementor_render_tweaks( $settings_group, $settings ) {
remove_action( 'wp_print_styles', 'wp_enqueue_emoji_styles' ); // WP 6.4 and above
} );

hello_elementor_do_tweak( $settings_group . $settings['OEMBED_SCRIPT'], function() {
hello_elementor_do_tweak( $settings_group . $settings['WP_EMBED_SCRIPT'], function() {
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
add_action( 'wp_enqueue_scripts', function() {
wp_deregister_script( 'wp-embed' );
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Source: https://stocksnap.io/photo/4B83RD7BV9
* New: Option to remove site comments RSS feed.
* New: Option to remove post comments RSS feed.
* New: Option to unregister Emoji scripts & styles.
* New: Option to unregister oEmbed script.
* New: Option to unregister wp-embed script.
* New: Option to unregister classic-theme styles.
* New: Option to unregister Gutenberg styles.
* New: Option to unregister Hello style.css.
Expand Down