Skip to content
Merged
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
11 changes: 7 additions & 4 deletions includes/create-theme/theme-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
class CBT_Theme_Patterns {
public static function pattern_from_template( $template, $new_slug = null ) {
$theme_slug = $new_slug ? $new_slug : wp_get_theme()->get( 'TextDomain' );
$pattern_slug = $theme_slug . '/' . $template->slug;
$template_slug = str_replace( '*/', '*/', $template->slug );
$pattern_slug = $theme_slug . '/' . $template_slug;
$pattern_content = <<<PHP
<?php
/**
* Title: {$template->slug}
* Title: {$template_slug}
* Slug: {$pattern_slug}
* Inserter: no
*/
Expand All @@ -29,12 +30,14 @@ public static function pattern_from_wp_block( $pattern_post ) {
$pattern->slug = wp_get_theme()->get( 'TextDomain' ) . '/' . $pattern->name;
$pattern_category_list = get_the_terms( $pattern->id, 'wp_pattern_category' );
$pattern->categories = ! empty( $pattern_category_list ) ? join( ', ', wp_list_pluck( $pattern_category_list, 'name' ) ) : '';
$pattern_title = str_replace( '*/', '*&#47;', $pattern->title );
$pattern_categories = str_replace( '*/', '*&#47;', $pattern->categories );
$pattern->content = <<<PHP
<?php
/**
* Title: {$pattern->title}
* Title: {$pattern_title}
* Slug: {$pattern->slug}
* Categories: {$pattern->categories}
* Categories: {$pattern_categories}
*/
?>
{$pattern_post->post_content}
Expand Down
Loading