Skip to content

Commit

Permalink
Save only templates that have been changed (#572)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Norris <1645628+mikachan@users.noreply.github.com>
  • Loading branch information
pbking and mikachan authored Apr 22, 2024
1 parent a07987a commit 09154a8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
10 changes: 7 additions & 3 deletions includes/class-create-block-theme-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,14 @@ function rest_save_theme( $request ) {
}

if ( isset( $options['saveTemplates'] ) && true === $options['saveTemplates'] ) {
if ( is_child_theme() ) {
Theme_Templates::add_templates_to_local( 'current', null, null, $options );
if ( true === $options['processOnlySavedTemplates'] ) {
Theme_Templates::add_templates_to_local( 'user', null, null, $options );
} else {
Theme_Templates::add_templates_to_local( 'all', null, null, $options );
if ( is_child_theme() ) {
Theme_Templates::add_templates_to_local( 'current', null, null, $options );
} else {
Theme_Templates::add_templates_to_local( 'all', null, null, $options );
}
}
Theme_Templates::clear_user_templates_customizations();
}
Expand Down
17 changes: 17 additions & 0 deletions src/editor-sidebar/save-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const SaveThemePanel = () => {
const [ saveOptions, setSaveOptions ] = useState( {
saveStyle: true,
saveTemplates: true,
processOnlySavedTemplates: true,
saveFonts: true,
removeNavRefs: false,
localizeText: false,
Expand Down Expand Up @@ -96,6 +97,22 @@ export const SaveThemePanel = () => {
} );
} }
/>
<CheckboxControl
label="Process Only Modified Templates"
help="Process only templates you have modified in the Editor. Any templates you have not modified will be left as is."
disabled={ ! saveOptions.saveTemplates }
checked={
saveOptions.saveTemplates &&
saveOptions.processOnlySavedTemplates
}
onChange={ () => {
setSaveOptions( {
...saveOptions,
processOnlySavedTemplates:
! saveOptions.processOnlySavedTemplates,
} );
} }
/>
<CheckboxControl
label="Localize Text"
help="Any text in a template will be copied to a pattern and localized."
Expand Down

0 comments on commit 09154a8

Please sign in to comment.