Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Wonder Blocks Headers and Footers #350

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
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
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 @@ -34,7 +34,7 @@
storedPreviewSettings:
select( nfdOnboardingStore ).getStepPreviewData(),
};
}, [] );

Check warning on line 37 in src/OnboardingSPA/components/Drawer/DrawerPanel/DesignHeaderMenu.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useSelect has a missing dependency: 'location.pathname'. Either include it or remove the dependency array

const { setCurrentOnboardingData, updateThemeStatus, setHeaderMenuData } =
useDispatch( nfdOnboardingStore );
Expand All @@ -48,6 +48,7 @@
}

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

if (
Expand All @@ -57,6 +58,14 @@
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 All @@ -76,7 +85,7 @@
if ( themeStatus === THEME_STATUS_ACTIVE ) {
getPatternsData();
}
}, [ themeStatus ] );

Check warning on line 88 in src/OnboardingSPA/components/Drawer/DrawerPanel/DesignHeaderMenu.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'getPatternsData'. Either include it or remove the dependency array

const handleClick = async ( idx ) => {
if ( document.getElementsByClassName( 'nfd-onboard-content' ) ) {
Expand Down
Loading