Skip to content

Commit ea38d18

Browse files
committed
chore: rename design library reference with pattern library
1 parent 0ef6e48 commit ea38d18

File tree

16 files changed

+170
-170
lines changed

16 files changed

+170
-170
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Built for enterprise teams, OneDesign unifies your design, editorial, and develo
7676
- API key
7777

7878
### Accessing the Pattern Library
79-
1. On your Governing Site, access the Design Library from the sidebar menu
79+
1. On your Governing Site, access the Pattern Library from the sidebar menu
8080
2. This opens a full-page interface showing all available patterns
8181
3. Patterns are organized by categories with vertical tabs for your registered sites
8282

@@ -113,7 +113,7 @@ For development guidelines, please refer to our [Development Guide](./docs/DEVEL
113113
### How are patterns transferred between sites?
114114
Patterns are transferred securely via WordPress REST API, ensuring that all pattern data, including blocks and settings, are properly synchronized.
115115
### Can I customize which patterns are available to specific sites?
116-
Yes, you can control which patterns are applied to each brand site by managing the selections in the Design Library.
116+
Yes, you can control which patterns are applied to each brand site by managing the selections in the Pattern Library.
117117
### Are there any limits to how many patterns I can sync?
118118
There are no hard limits on the number of patterns you can sync, but performance may vary depending on your server resources and the complexity of the patterns.
119119
### Can I also remove patterns from specific sites?

assets/src/admin/patterns/pattern-event.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { __ } from '@wordpress/i18n';
55

66
/**
7-
* This File contains the code to add the Design Library Button.
7+
* This File contains the code to add the Pattern Library Button.
88
*/
99

1010
window.addEventListener( 'DOMContentLoaded', function() {
@@ -16,13 +16,13 @@ window.addEventListener( 'DOMContentLoaded', function() {
1616
this.libraryCache.gutenberg = document.getElementById( 'editor' );
1717
this.libraryCache.gutenbergEditorHeader = document.querySelector( '.edit-post-layout' );
1818
this.libraryCache.switchModeTemplate = document.getElementById(
19-
'design-library-gutenberg-button',
19+
'pattern-library-gutenberg-button',
2020
).innerHTML;
2121
this.libraryCache.switchMode = this.createElementFromHTML(
2222
this.libraryCache.switchModeTemplate,
2323
);
2424
this.libraryCache.switchModeButton = this.libraryCache.switchMode.querySelector(
25-
'#design-library-main-button',
25+
'#pattern-library-main-button',
2626
);
2727
this.addCustomEventOnButtonClick();
2828

@@ -38,7 +38,7 @@ window.addEventListener( 'DOMContentLoaded', function() {
3838
return div.firstChild;
3939
},
4040
buildButton() {
41-
if ( ! this.libraryCache.gutenberg.querySelector( '#design-library-button' ) ) {
41+
if ( ! this.libraryCache.gutenberg.querySelector( '#pattern-library-button' ) ) {
4242
this.libraryCache?.gutenberg
4343
?.querySelector( '.edit-post-header-toolbar' )
4444
?.appendChild( this.libraryCache.switchMode );
@@ -51,7 +51,7 @@ window.addEventListener( 'DOMContentLoaded', function() {
5151
this.libraryCache.switchModeButton.addEventListener( 'click', () => {
5252
window.console.log( 'Firing Custom Event' );
5353
const designLibraryModalOpenEvent = new CustomEvent( 'designLibraryModalOpen', {
54-
detail: { message: __( 'Open the Design Library Modal!', 'onedesign' ) },
54+
detail: { message: __( 'Open the Pattern Library Modal!', 'onedesign' ) },
5555
} );
5656

5757
document.dispatchEvent( designLibraryModalOpenEvent );

assets/src/admin/templates/components/TemplateModal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const TemplateModal = () => {
8383
} catch ( error ) {
8484
setSitesHealthCheckResult( ( prevResults ) => ( {
8585
...prevResults,
86-
[ siteInfo[ siteId ]?.id ]: { success: false, message: 'Failed to reach the site.' },
86+
[ siteInfo[ siteId ]?.id ]: { success: false, message: __( 'Failed to reach the site.', 'onedesign' ) },
8787
} ) );
8888
}
8989
}

assets/src/admin/templates/template-event.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { __ } from '@wordpress/i18n';
55

66
/**
7-
* This File contains the code to add the Design Library Button.
7+
* This File contains the code to add the Pattern Library Button.
88
*/
99

1010
window.addEventListener( 'DOMContentLoaded', function() {
@@ -51,7 +51,7 @@ window.addEventListener( 'DOMContentLoaded', function() {
5151
this.libraryCache.switchModeButton.addEventListener( 'click', () => {
5252
window.console.log( 'Template event fired...' );
5353
const TemplateLibraryOpenEvent = new CustomEvent( 'TemplateLibraryOpen', {
54-
detail: { message: __( 'Open the Design Library Modal!', 'onedesign' ) },
54+
detail: { message: __( 'Open the Pattern Library Modal!', 'onedesign' ) },
5555
} );
5656

5757
document.dispatchEvent( TemplateLibraryOpenEvent );

assets/src/css/editor.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@
232232
}
233233
}
234234

235-
.post-type-design-library {
235+
.post-type-pattern-library {
236236

237237
.editor-document-tools__left {
238238
display: none;

docs/DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Code contributions, bug reports, and feature requests are welcome! The following
9494
│ │ │ └── class-secret-key.php
9595
│ │ ├── post-type
9696
│ │ │ ├── class-base.php
97-
│ │ │ ├── class-design-library.php
97+
│ │ │ ├── class-pattern-library.php
9898
│ │ │ ├── class-meta.php
9999
│ │ │ └── class-template.php
100100
│ │ └── rest

inc/classes/class-assets.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace OneDesign;
99

1010
use OneDesign\Plugin_Configs\Constants;
11-
use OneDesign\Post_Types\{ Design_Library, Template };
11+
use OneDesign\Post_Types\{ Pattern, Template };
1212
use OneDesign\Traits\Singleton;
1313

1414
/**
@@ -128,7 +128,7 @@ public function enqueue_scripts(): void {
128128

129129
$current_screen = get_current_screen();
130130

131-
if ( Design_Library::SLUG === $current_screen->id ) {
131+
if ( Pattern::SLUG === $current_screen->id ) {
132132

133133
$this->register_script(
134134
'onedesign-patterns-library-script',

inc/classes/class-cpt-restriction.php

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace OneDesign;
99

1010
use OneDesign\Traits\Singleton;
11-
use OneDesign\Post_Types\{ Design_Library, Template };
11+
use OneDesign\Post_Types\{ Pattern, Template };
1212

1313
/**
1414
* Class CPT_Restriction
@@ -40,10 +40,10 @@ protected function __construct() {
4040
public function setup_hooks(): void {
4141
add_filter( 'register_post_type_args', array( $this, 'restrict_cpt' ), 5, 2 );
4242
add_action( 'init', array( $this, 'unregister_cpt' ), 20 );
43-
add_action( 'current_screen', array( $this, 'limit_design_library_posts' ) );
43+
add_action( 'current_screen', array( $this, 'limit_pattern_library_posts' ) );
4444
add_action( 'current_screen', array( $this, 'limit_template_posts' ) );
45-
add_filter( 'register_post_type_args', array( $this, 'modify_design_library_labels' ), 10, 2 );
46-
add_action( 'admin_menu', array( $this, 'modify_design_library_admin_menu' ), 999 );
45+
add_filter( 'register_post_type_args', array( $this, 'modify_pattern_library_labels' ), 10, 2 );
46+
add_action( 'admin_menu', array( $this, 'modify_pattern_library_admin_menu' ), 999 );
4747
add_filter( 'default_content', array( $this, 'add_default_content_to_editor' ), 10, 2 );
4848
add_filter( 'default_title', array( $this, 'add_default_title_to_editor' ), 10, 2 );
4949
}
@@ -56,8 +56,8 @@ public function setup_hooks(): void {
5656
* @return string Modified title.
5757
*/
5858
public function add_default_title_to_editor( string $title ): string {
59-
if ( Design_Library::SLUG === get_current_screen()->post_type ) {
60-
return esc_html__( 'Design Library', 'onedesign' );
59+
if ( Pattern::SLUG === get_current_screen()->post_type ) {
60+
return esc_html__( 'Pattern Library', 'onedesign' );
6161
}
6262
return $title;
6363
}
@@ -71,7 +71,7 @@ public function add_default_title_to_editor( string $title ): string {
7171
* @return array Modified arguments.
7272
*/
7373
public function restrict_cpt( array $args, string $post_type ): array {
74-
if ( ! in_array( $post_type, array( Design_Library::SLUG, Template::SLUG ), true ) ) {
74+
if ( ! in_array( $post_type, array( Pattern::SLUG, Template::SLUG ), true ) ) {
7575
return $args;
7676
}
7777

@@ -87,7 +87,7 @@ public function restrict_cpt( array $args, string $post_type ): array {
8787
return $args;
8888
}
8989

90-
if ( in_array( $post_type, array( Design_Library::SLUG, Template::SLUG ), true ) ) {
90+
if ( in_array( $post_type, array( Pattern::SLUG, Template::SLUG ), true ) ) {
9191
$args['public'] = false;
9292
$args['show_ui'] = false;
9393
$args['show_in_menu'] = false;
@@ -120,32 +120,32 @@ public function unregister_cpt(): void {
120120
return;
121121
}
122122

123-
unregister_post_type( Design_Library::SLUG );
123+
unregister_post_type( Pattern::SLUG );
124124
unregister_post_type( Template::SLUG );
125125
}
126126

127127
/**
128-
* Callback function to limit design library posts.
128+
* Callback function to limit pattern library posts.
129129
*
130130
* @return void
131131
*/
132-
public function limit_design_library_posts(): void {
133-
// Check if we're trying to create a new design library post.
132+
public function limit_pattern_library_posts(): void {
133+
// Check if we're trying to create a new pattern library post.
134134
$screen = get_current_screen();
135-
if ( ! $screen || Design_Library::SLUG !== $screen->post_type || 'add' !== $screen->action ) {
135+
if ( ! $screen || Pattern::SLUG !== $screen->post_type || 'add' !== $screen->action ) {
136136
return;
137137
}
138138

139-
// Count existing design library posts.
140-
$existing_posts = wp_count_posts( Design_Library::SLUG );
139+
// Count existing pattern library posts.
140+
$existing_posts = wp_count_posts( Pattern::SLUG );
141141
$post_count = $existing_posts->publish + $existing_posts->draft + $existing_posts->pending + $existing_posts->private;
142142

143143
// If a post already exists, redirect to edit screen.
144144
if ( $post_count > 0 ) {
145145
// Get the existing post.
146146
$existing_post = get_posts(
147147
array(
148-
'post_type' => Design_Library::SLUG,
148+
'post_type' => Pattern::SLUG,
149149
'post_status' => array( 'publish', 'draft', 'pending', 'private' ),
150150
'numberposts' => 1,
151151
'suppress_filters' => false,
@@ -171,7 +171,7 @@ public function limit_template_posts(): void {
171171
return;
172172
}
173173

174-
// Count existing design library posts.
174+
// Count existing pattern library posts.
175175
$existing_posts = wp_count_posts( Template::SLUG );
176176

177177
// check if $existing_posts is not null to avoid errors.
@@ -202,16 +202,16 @@ public function limit_template_posts(): void {
202202
}
203203

204204
/**
205-
* Callback function to modify design library labels.
205+
* Callback function to modify pattern library labels.
206206
*
207207
* @param array $args Array of arguments for registering a post type.
208208
* @param string $post_type Post type key.
209209
*
210210
* @return array Modified arguments.
211211
*/
212-
public function modify_design_library_labels( array $args, string $post_type ): array {
212+
public function modify_pattern_library_labels( array $args, string $post_type ): array {
213213
// Only modify if it's our post type.
214-
if ( Design_Library::SLUG !== $post_type ) {
214+
if ( Pattern::SLUG !== $post_type ) {
215215
return $args;
216216
}
217217

@@ -220,34 +220,34 @@ public function modify_design_library_labels( array $args, string $post_type ):
220220
$post_count = $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- We need to get the latest count.
221221
$wpdb->prepare(
222222
"SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s AND post_status IN ('publish', 'draft', 'pending', 'private')",
223-
Design_Library::SLUG
223+
Pattern::SLUG
224224
)
225225
);
226226

227227
if ( $post_count > 0 ) {
228-
// Change "Add New" text to "Edit Design Library".
228+
// Change "Add New" text to "Edit Pattern Library".
229229
if ( isset( $args['labels'] ) ) {
230-
$args['labels']['add_new'] = esc_html__( 'Edit Design Library', 'onedesign' );
231-
$args['labels']['add_new_item'] = esc_html__( 'Edit Design Library', 'onedesign' );
230+
$args['labels']['add_new'] = esc_html__( 'Edit Pattern Library', 'onedesign' );
231+
$args['labels']['add_new_item'] = esc_html__( 'Edit Pattern Library', 'onedesign' );
232232
}
233233
}
234234

235235
return $args;
236236
}
237237

238238
/**
239-
* Callback function to modify a design library admin menu.
239+
* Callback function to modify a pattern library admin menu.
240240
*/
241-
public function modify_design_library_admin_menu(): void {
241+
public function modify_pattern_library_admin_menu(): void {
242242
global $submenu;
243243

244244
// Make sure the submenu exists and contains our post type.
245-
if ( ! isset( $submenu[ 'edit.php?post_type=' . Design_Library::SLUG ] ) ) {
245+
if ( ! isset( $submenu[ 'edit.php?post_type=' . Pattern::SLUG ] ) ) {
246246
return;
247247
}
248248

249-
// Count existing design library posts.
250-
$existing_posts = wp_count_posts( Design_Library::SLUG );
249+
// Count existing pattern library posts.
250+
$existing_posts = wp_count_posts( Pattern::SLUG );
251251

252252
// check if $existing_posts is not null to avoid errors.
253253
if ( ! $existing_posts ) {
@@ -258,12 +258,12 @@ public function modify_design_library_admin_menu(): void {
258258

259259
if ( $post_count > 0 ) {
260260
// Find the "Add New" menu item.
261-
foreach ( $submenu[ 'edit.php?post_type=' . Design_Library::SLUG ] as $key => $item ) {
262-
if ( 'post-new.php?post_type=' . Design_Library::SLUG === $item[2] ) {
261+
foreach ( $submenu[ 'edit.php?post_type=' . Pattern::SLUG ] as $key => $item ) {
262+
if ( 'post-new.php?post_type=' . Pattern::SLUG === $item[2] ) {
263263
// Get the existing post.
264264
$existing_post = get_posts(
265265
array(
266-
'post_type' => Design_Library::SLUG,
266+
'post_type' => Pattern::SLUG,
267267
'post_status' => array( 'publish', 'draft', 'pending', 'private' ),
268268
'numberposts' => 1,
269269
'suppress_filters' => false,
@@ -272,8 +272,8 @@ public function modify_design_library_admin_menu(): void {
272272

273273
if ( ! empty( $existing_post ) ) {
274274
// Change the "Add New" link to edit the existing post.
275-
$submenu['edit.php?post_type=design-library'][ $key ][2] = 'post.php?post=' . $existing_post[0]->ID . '&action=edit'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- We need to modify for design library post type.
276-
$submenu['edit.php?post_type=design-library'][ $key ][0] = esc_html__( 'Edit Design Library', 'onedesign' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- We need to modify for design library post type.
275+
$submenu['edit.php?post_type=onedesign-pattern'][ $key ][2] = 'post.php?post=' . $existing_post[0]->ID . '&action=edit'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- We need to modify for pattern library post type.
276+
$submenu['edit.php?post_type=onedesign-pattern'][ $key ][0] = esc_html__( 'Edit Pattern Library', 'onedesign' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- We need to modify for pattern library post type.
277277
}
278278
break;
279279
}
@@ -290,7 +290,7 @@ public function modify_design_library_admin_menu(): void {
290290
* @return string Modified content.
291291
*/
292292
public function add_default_content_to_editor( string $content, object $post ): string {
293-
if ( Design_Library::SLUG === $post->post_type && empty( $content ) ) {
293+
if ( Pattern::SLUG === $post->post_type && empty( $content ) ) {
294294
$content = '<!-- wp:heading {"level":2} -->
295295
<h2>Click on the "Patterns Selection" to push patterns to brand site.</h2>
296296
<!-- /wp:heading -->';

inc/classes/class-hooks.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use OneDesign\Plugin_Configs\Constants;
1111
use OneDesign\Traits\Singleton;
12-
use OneDesign\Post_Types\{ Design_Library, Template };
12+
use OneDesign\Post_Types\{ Pattern, Template };
1313

1414
/**
1515
* Class Hooks
@@ -36,7 +36,7 @@ protected function __construct() {
3636
* @return void
3737
*/
3838
public function setup_hooks(): void {
39-
add_action( 'admin_footer', array( $this, 'print_design_library_button_in_editor_js_template' ) );
39+
add_action( 'admin_footer', array( $this, 'print_pattern_library_button_in_editor_js_template' ) );
4040
add_action( 'admin_footer', array( $this, 'add_templates_button_to_editor' ) );
4141
add_action( 'wp_ajax_register_block_patterns', array( $this, 'ajax_register_block_patterns' ) );
4242
add_action( 'wp_ajax_nopriv_register_block_patterns', array( $this, 'ajax_register_block_patterns' ) );
@@ -147,8 +147,8 @@ public function add_body_class_for_missing_sites( $classes ): string {
147147
$classes .= ' onedesign-missing-brand-sites ';
148148

149149
// remove submenu pages.
150-
remove_submenu_page( 'onedesign', 'design-library' );
151-
remove_submenu_page( 'onedesign', 'onedesign-templates' );
150+
remove_submenu_page( 'onedesign', 'onedesign-pattern-library' );
151+
remove_submenu_page( 'onedesign', 'onedesign-template-library' );
152152

153153
return $classes;
154154
}
@@ -306,7 +306,7 @@ public function create_template(): void {
306306
* @return array|bool
307307
*/
308308
public function allowed_block_types( bool|array $allowed_block_types, \WP_Block_Editor_Context $editor_context ): array|bool {
309-
// Allow all block types in the Design Library post type.
309+
// Allow all block types in the Pattern Library post type.
310310
if ( isset( $editor_context->post->post_type ) && ( Template::SLUG === $editor_context->post->post_type ) ) {
311311
return array();
312312
}
@@ -323,20 +323,20 @@ public function remove_core_block_patterns(): void {
323323
}
324324

325325
/**
326-
* Prints the Design Library Button Template.
326+
* Prints the Pattern Library Button Template.
327327
*
328328
* @return void
329329
*/
330-
public function print_design_library_button_in_editor_js_template(): void {
330+
public function print_pattern_library_button_in_editor_js_template(): void {
331331
$current_screen = get_current_screen();
332-
if ( ! $current_screen || Design_Library::SLUG !== $current_screen->post_type ) {
332+
if ( ! $current_screen || Pattern::SLUG !== $current_screen->post_type ) {
333333
return;
334334
}
335335
?>
336-
<script id="design-library-gutenberg-button" type="text/html">
337-
<div id="design-library-button">
338-
<button id="design-library-main-button" type="button" class="button button-primary button-large">
339-
<span class="design-library-main-button-active">
336+
<script id="pattern-library-gutenberg-button" type="text/html">
337+
<div id="pattern-library-button">
338+
<button id="pattern-library-main-button" type="button" class="button button-primary button-large">
339+
<span class="pattern-library-main-button-active">
340340
<?php esc_html_e( 'Patterns Selection', 'onedesign' ); ?>
341341
</button>
342342
</div>

0 commit comments

Comments
 (0)