33class CBT_Theme_Patterns {
44 public static function pattern_from_template ( $ template , $ new_slug = null ) {
55 $ theme_slug = $ new_slug ? $ new_slug : wp_get_theme ()->get ( 'TextDomain ' );
6- $ pattern_slug = $ theme_slug . '/ ' . $ template ->slug ;
6+ $ template_slug = str_replace ( '*/ ' , '*/ ' , $ template ->slug );
7+ $ pattern_slug = $ theme_slug . '/ ' . $ template_slug ;
78 $ pattern_content = <<<PHP
89 <?php
910 /**
10- * Title: {$ template -> slug }
11+ * Title: {$ template_slug }
1112 * Slug: {$ pattern_slug }
1213 * Inserter: no
1314 */
@@ -29,12 +30,14 @@ public static function pattern_from_wp_block( $pattern_post ) {
2930 $ pattern ->slug = wp_get_theme ()->get ( 'TextDomain ' ) . '/ ' . $ pattern ->name ;
3031 $ pattern_category_list = get_the_terms ( $ pattern ->id , 'wp_pattern_category ' );
3132 $ pattern ->categories = ! empty ( $ pattern_category_list ) ? join ( ', ' , wp_list_pluck ( $ pattern_category_list , 'name ' ) ) : '' ;
33+ $ pattern_title = str_replace ( '*/ ' , '*/ ' , $ pattern ->title );
34+ $ pattern_categories = str_replace ( '*/ ' , '*/ ' , $ pattern ->categories );
3235 $ pattern ->content = <<<PHP
3336 <?php
3437 /**
35- * Title: {$ pattern -> title }
38+ * Title: {$ pattern_title }
3639 * Slug: {$ pattern ->slug }
37- * Categories: {$ pattern -> categories }
40+ * Categories: {$ pattern_categories }
3841 */
3942 ?>
4043 {$ pattern_post ->post_content }
0 commit comments