Skip to content

Commit f2a771e

Browse files
committed
Merge branch 'fix/cover-repeated-background-localize' of https://github.com/Omcodes23/create-block-theme into fix/cover-repeated-background-localize
om vataliya
2 parents a4c8b6c + 6ee8f91 commit f2a771e

6 files changed

Lines changed: 50 additions & 41 deletions

File tree

create-block-theme.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Plugin Name: Create Block Theme
66
* Plugin URI: https://wordpress.org/plugins/create-block-theme
77
* Description: Generates a block theme
8-
* Version: 2.7.0
8+
* Version: 2.8.0
99
* Author: WordPress.org
1010
* Author URI: https://wordpress.org/
1111
* License: GNU General Public License v2 or later

includes/create-theme/theme-patterns.php

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public static function pattern_from_wp_block( $pattern_post ) {
2929
$pattern->slug = wp_get_theme()->get( 'TextDomain' ) . '/' . $pattern->name;
3030
$pattern_category_list = get_the_terms( $pattern->id, 'wp_pattern_category' );
3131
$pattern->categories = ! empty( $pattern_category_list ) ? join( ', ', wp_list_pluck( $pattern_category_list, 'name' ) ) : '';
32-
$pattern->sync_status = get_post_meta( $pattern->id, 'wp_pattern_sync_status', true );
3332
$pattern->content = <<<PHP
3433
<?php
3534
/**
@@ -71,7 +70,7 @@ public static function create_pattern_link( $attributes ) {
7170
return '<!-- wp:pattern ' . $attributes_json . ' /-->';
7271
}
7372

74-
public static function replace_local_pattern_references( $pattern ) {
73+
public static function replace_local_pattern_references( $pattern, $options = null ) {
7574
// Find any references to pattern in templates
7675
$templates_to_update = array();
7776
$args = array(
@@ -89,7 +88,7 @@ public static function replace_local_pattern_references( $pattern ) {
8988
$templates_to_update = array_unique( $templates_to_update );
9089

9190
// Only update templates that reference the pattern
92-
CBT_Theme_Templates::add_templates_to_local( 'all', null, null, null, $templates_to_update );
91+
CBT_Theme_Templates::add_templates_to_local( 'all', null, null, $options, $templates_to_update );
9392

9493
// List all template and pattern files in the theme
9594
$base_dir = get_stylesheet_directory();
@@ -160,41 +159,38 @@ public static function add_patterns_to_theme( $options = null ) {
160159
$pattern = self::prepare_pattern_for_export( $pattern, $options );
161160
$pattern_exists = false;
162161

163-
// Check pattern is synced before adding to theme.
164-
if ( 'unsynced' !== $pattern->sync_status ) {
165-
// Check pattern name doesn't already exist before creating the file.
166-
$existing_patterns = glob( $patterns_dir . DIRECTORY_SEPARATOR . '*.php' );
167-
foreach ( $existing_patterns as $existing_pattern ) {
168-
if ( strpos( $existing_pattern, $pattern->name . '.php' ) !== false ) {
169-
$pattern_exists = true;
170-
}
171-
}
172-
173-
if ( $pattern_exists ) {
174-
return new WP_Error(
175-
'pattern_already_exists',
176-
sprintf(
177-
/* Translators: Pattern name. */
178-
__(
179-
'A pattern with this name already exists: "%s".',
180-
'create-block-theme'
181-
),
182-
$pattern->name
183-
)
184-
);
162+
// Check pattern name doesn't already exist before creating the file.
163+
$existing_patterns = glob( $patterns_dir . DIRECTORY_SEPARATOR . '*.php' );
164+
foreach ( $existing_patterns as $existing_pattern ) {
165+
if ( strpos( $existing_pattern, $pattern->name . '.php' ) !== false ) {
166+
$pattern_exists = true;
185167
}
168+
}
186169

187-
// Create the pattern file.
188-
file_put_contents(
189-
$patterns_dir . DIRECTORY_SEPARATOR . $pattern->name . '.php',
190-
$pattern->content
170+
if ( $pattern_exists ) {
171+
return new WP_Error(
172+
'pattern_already_exists',
173+
sprintf(
174+
/* Translators: Pattern name. */
175+
__(
176+
'A pattern with this name already exists: "%s".',
177+
'create-block-theme'
178+
),
179+
$pattern->name
180+
)
191181
);
182+
}
192183

193-
self::replace_local_pattern_references( $pattern );
184+
// Create the pattern file.
185+
file_put_contents(
186+
$patterns_dir . DIRECTORY_SEPARATOR . $pattern->name . '.php',
187+
$pattern->content
188+
);
194189

195-
// Remove it from the database to ensure that these patterns are loaded from the theme.
196-
wp_delete_post( $pattern->id, true );
197-
}
190+
self::replace_local_pattern_references( $pattern, $options );
191+
192+
// Remove it from the database to ensure that these patterns are loaded from the theme.
193+
wp_delete_post( $pattern->id, true );
198194
}
199195
}
200196
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-block-theme",
3-
"version": "2.7.0",
3+
"version": "2.8.0",
44
"private": true,
55
"description": "Create a block-based theme",
66
"author": "The WordPress Contributors",

readme.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contributors: wordpressdotorg, mikachan, onemaggie, pbking, scruffian, mmaattiiaass, jffng, madhudollu, egregor, vcanales, jeffikus, cwhitmore
33
Tags: themes, theme, block-theme
44
Requires at least: 6.7
5-
Tested up to: 6.8
6-
Stable tag: 2.7.0
5+
Tested up to: 6.9
6+
Stable tag: 2.8.0
77
Requires PHP: 7.4
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -125,6 +125,19 @@ If you are having problems, please try the following:
125125

126126
== Changelog ==
127127

128+
= 2.8.0 =
129+
* Update "Tested up to" version to 6.9 (#793)
130+
* Save all patterns (#790)
131+
* I18n: Makes it possible to translate text strings in HTML comments (#788)
132+
* Move and version attributes to the start of the theme.json file as this helps editing in IDEs (#787)
133+
* Localize Details block summary text (#778)
134+
* PHPCS: enalbe VariableAnalysis.CodeAnalysis.VariableAnalysis rule (#782)
135+
* Clean up package.json and update libraries (#781)
136+
* Bump minimum required WordPress version to 6.7 (#775)
137+
* Added filters for changing paths (#771)
138+
* Add option to remove taxonomy query from query block attributes (#734) (#743)
139+
* Wp-env: remove mappings field (#774)
140+
128141
= 2.7.0 =
129142
* Update "Tested up to" version to 6.8 (#768)
130143
* Update wp-env configuration to use 'development mode' and to store themes in an accessible place for development (#764)

src/editor-sidebar/save-panel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ export const SaveThemePanel = () => {
158158
/>
159159
<CheckboxControl
160160
__nextHasNoMarginBottom
161-
label={ __( 'Save Synced Patterns', 'create-block-theme' ) }
161+
label={ __( 'Save Patterns', 'create-block-theme' ) }
162162
help={ __(
163-
'Any synced patterns created in the Editor will be moved to the theme. Note that this will delete all synced patterns from the Editor and any references in templates will be made relative to the theme.',
163+
'All patterns created in the Editor will be moved to the theme. Note that this will delete all patterns from the Editor and any references in templates will be made relative to the theme.',
164164
'create-block-theme'
165165
) }
166166
checked={ preference.savePatterns }

0 commit comments

Comments
 (0)