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

added header and footer mapping in fallback #110

Merged
merged 2 commits into from
Sep 10, 2024
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
30 changes: 18 additions & 12 deletions includes/Patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ public static function get_fallbacks() {
'about-4' => 'yith-wonder/company-page',
'contact-4' => 'yith-wonder/contact-us',
'testimonials-template-2' => 'yith-wonder/testimonials-page',
'header-1' => 'yith-wonder/site-header-left-logo-navigation-inline',
'header-3' => 'yith-wonder/site-header-centered',
'header-8' => 'yith-wonder/site-header-left-logo-navigation-below',
'header-10' => 'yith-wonder/site-header-splitted-menu',
'footer-15' => 'yith-wonder/site-footer',
),
);
}
Expand Down Expand Up @@ -230,19 +235,19 @@ public static function get_theme_patterns_meta() {
/**
* Sanitize the content by cleaning wp_grammar.
*
* @param string $content Data to clean
* @param string $content Data to clean.
*
* @return string
*/
private static function cleanup_wp_grammar( $content ) {

// Remove template-part if that exists
// Remove template-part if that exists.
$content = preg_replace( '/^<!-- wp:template-part .* \/-->$/m', '', $content );

// Create an array with the values you want to replace
// Create an array with the values you want to replace.
$searches = array( "\n", "\t" );

// Replace the line breaks and tabs with a empty string
// Replace the line breaks and tabs with a empty string.
$content = str_replace( $searches, '', $content );

return $content;
Expand Down Expand Up @@ -307,7 +312,7 @@ public static function get_pattern_from_block_patterns_registry( $pattern_slug )
/**
* Retrieve pattern from slug.
*
* @param string $pattern_slug Pattern Slug Data
* @param string $pattern_slug Pattern Slug Data.
*
* @return array|boolean
*/
Expand Down Expand Up @@ -335,7 +340,7 @@ public static function get_pattern_from_slug( $pattern_slug ) {
* @return string|boolean
*/
private static function get_selected_header_from_flow_data() {
// fetch the selected header menu slug from DB
// fetch the selected header menu slug from DB.
$flow_data = \get_option( Options::get_option_name( 'flow' ), false );
if ( ! $flow_data ) {
return false;
Expand Down Expand Up @@ -364,7 +369,7 @@ private static function get_selected_header_from_flow_data() {
/**
* Replace the header menu slug in the patterns array
*
* @param array $pattern_content pattern grammar that is to be modified
* @param array $pattern_content pattern grammar that is to be modified.
*
* @return array
*/
Expand All @@ -387,8 +392,8 @@ private static function replace_split_menu_items( $pattern_content ) {
/**
* Retrieve Theme Step Patterns from chosen Theme in Previous Step
*
* @param string $step Step from which Theme Step Pattern is required
* @param boolean $squash Flag set to retrieve the block pattern
* @param string $step Step from which Theme Step Pattern is required.
* @param boolean $squash Flag set to retrieve the block pattern.
*
* @return array|string
*/
Expand All @@ -414,7 +419,8 @@ public static function get_theme_step_patterns_from_step( $step, $squash = false
if ( 'wonder-blocks' === $header_menu_data['type'] ) {
$pattern_slug_data['wonder_blocks'] = $slug;
} else {
$pattern_slug = $slug;
// to update the chosen header from the fallback in the homelayouts page(wp-setup/step/design/homepage-menu).
$pattern_slug_data['wonder_blocks'] = array_search( $active_theme . '/' . $slug, self::get_fallbacks()['wonder-blocks'], true );
}
}
$pattern_slugs[ $pattern_slug ] = $pattern_slug_data;
Expand Down Expand Up @@ -459,7 +465,7 @@ public static function get_theme_step_patterns_from_step( $step, $squash = false
/**
* Retrieve Homepage Menu Step Patterns
*
* @param array $patterns Step Patterns Data
* @param array $patterns Step Patterns Data.
* @return array
*/
private static function filter_yith_wonder_homepage_patterns( $patterns ) {
Expand Down Expand Up @@ -491,7 +497,7 @@ private static function filter_yith_wonder_homepage_patterns( $patterns ) {
/**
* Retrieve Header Menu Step Patterns
*
* @param array $patterns Step Patterns Data
* @param array $patterns Step Patterns Data.
* @return array
*/
private static function filter_yith_wonder_headermenu_patterns( $patterns ) {
Expand Down
Loading