Skip to content

Commit

Permalink
Merge pull request #110 from newfold-labs/PRESS0-1871-diy-header-menu…
Browse files Browse the repository at this point in the history
…-fix

added header and footer mapping in fallback
  • Loading branch information
arunshenoy99 authored Sep 10, 2024
2 parents fe195d1 + bc5a99b commit 8f09f94
Showing 1 changed file with 18 additions and 12 deletions.
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

0 comments on commit 8f09f94

Please sign in to comment.