Skip to content

Commit

Permalink
Merge pull request #350 from newfold-labs/enhance/wonder-blocks-heade…
Browse files Browse the repository at this point in the history
…r-footers

Add Wonder Blocks Headers and Footers
  • Loading branch information
arunshenoy99 authored Nov 1, 2023
2 parents 531384a + 95bc7ad commit 385f93e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"mustache/mustache": "^2.14",
"wp-cli/wp-config-transformer": "^1.3",
"newfold-labs/wp-module-onboarding-data": "^0.0.5",
"newfold-labs/wp-module-patterns": "^0.1.6"
"newfold-labs/wp-module-patterns": "^0.1.8"
},
"require-dev": {
"wp-phpunit/wp-phpunit": "^6.2",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion includes/RestApi/Themes/ThemeGeneratorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use NewfoldLabs\WP\Module\Onboarding\Mustache\Mustache;
use NewfoldLabs\WP\Module\Onboarding\Data\Themes;
use NewfoldLabs\WP\Module\Onboarding\Data\Options;
use NewfoldLabs\WP\Module\Onboarding\Data\Patterns;

/**
* Class ThemeGeneratorController
Expand Down Expand Up @@ -130,6 +131,13 @@ public function generate_child_theme() {
}
}

if ( $flow_data['partFooter'] ) {
$part_patterns['footer'] = $this->generate_theme_part_pattern( $flow_data['partFooter'] );
if ( \is_wp_error( $part_patterns['footer'] ) ) {
return $part_patterns['footer'];
}
}

$child_theme_stylesheet_comment = $this->generate_child_theme_stylesheet_comment( $parent_theme_slug, $child_theme_slug );

// Write the child theme to the filesystem under themes.
Expand Down Expand Up @@ -295,7 +303,7 @@ private function generate_child_theme_stylesheet_comment( $parent_theme_slug, $c
* @return string|\WP_Error the pattern for the part.
*/
private function generate_theme_part_pattern( $pattern_slug ) {
$pattern = \WP_Block_Patterns_Registry::get_instance()->get_registered( $pattern_slug );
$pattern = Patterns::get_pattern_from_slug( $pattern_slug );
if ( ! $pattern ) {
return new \WP_Error(
'nfd_onboarding_pattern_not_registered',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const DesignHeaderMenu = () => {
}

const headerMenuPatterns = headerMenuPreviewResponse?.body.pageHeaders;
const footerPattern = headerMenuPreviewResponse?.body.pageFooter;
const pageContent = headerMenuPreviewResponse?.body.pageBody;

if (
Expand All @@ -57,6 +58,14 @@ const DesignHeaderMenu = () => {
currentData.data.partHeader = headerMenuPatterns[ 0 ].slug;
setCurrentOnboardingData( currentData );
}

if (
! currentData.data?.partFooter ||
currentData.data?.partFooter === ''
) {
currentData.data.partFooter = footerPattern.slug;
setCurrentOnboardingData( currentData );
}
setSelectedPattern( currentData.data.partHeader );
setHeaderMenuPreviewData( headerMenuPreviewResponse.body );
setPatterns( headerMenuPatterns );
Expand Down

0 comments on commit 385f93e

Please sign in to comment.