Bläddra i källkod

Add __unstableLocation to all BB&Co Themes (#4101)

* Add __unstableLocation to all BB&Co Themes

As BB & Co. themes ALL become "Universal Capable" this addition allows
the menues to be modifed (should these themes be used in "Classic Mode")

* Registered menu locations for all BB themes
Jason Crist 4 år sedan
förälder
incheckning
c562229404

+ 1 - 1
blockbase/block-template-parts/header.html

@@ -1,6 +1,6 @@
 <!-- wp:group {"align":"full","className":"site-header"} -->
 <div class="wp-block-group alignfull site-header">
 	<!-- wp:site-title /-->
-	<!-- wp:navigation {"isResponsive":true} /-->
+	<!-- wp:navigation {"isResponsive":true,"__unstableLocation":"primary"} --><!-- /wp:navigation -->
 </div>
 <!-- /wp:group -->

+ 11 - 0
blockbase/functions.php

@@ -18,12 +18,23 @@ if ( ! function_exists( 'blockbase_support' ) ) :
 		// Add support for post thumbnails.
 		add_theme_support( 'post-thumbnails' );
 
+		// Experimental support for adding blocks inside nav menus
+		add_theme_support( 'block-nav-menus' );
+
 		// Enqueue editor styles.
 		add_editor_style(
 			array(
 				'/assets/ponyfill.css',
 			)
 		);
+
+		// This theme has one menu location.
+		register_nav_menus(
+			array(
+				'primary' => __( 'Primary Navigation', 'blockbase' ),
+			)
+		);
+
 	}
 	add_action( 'after_setup_theme', 'blockbase_support' );
 endif;

+ 1 - 1
mayland-blocks/block-template-parts/header.html

@@ -1,4 +1,4 @@
 <!-- wp:site-logo /-->
 <!-- wp:site-title /-->
-<!-- wp:navigation {"orientation":"horizontal","textColor":"foreground-light","itemsJustification":"right","fontSize":"small","isResponsive":true} -->
+<!-- wp:navigation {"orientation":"horizontal","textColor":"foreground-light","itemsJustification":"right","fontSize":"small","isResponsive":true,"__unstableLocation":"primary"} -->
 <!-- /wp:navigation -->

+ 8 - 0
mayland-blocks/functions.php

@@ -9,6 +9,14 @@ if ( ! function_exists( 'mayland_blocks_support' ) ) :
 				'theme.css',
 			)
 		);
+
+		// This theme has one menu location.
+		register_nav_menus(
+			array(
+				'primary' => __( 'Primary Navigation', 'mayland-blocks' ),
+			)
+		);
+
 	}
 	add_action( 'after_setup_theme', 'mayland_blocks_support' );
 endif;

+ 0 - 3
quadrat/functions.php

@@ -10,9 +10,6 @@ if ( ! function_exists( 'quadrat_support' ) ) :
 			)
 		);
 
-		// Experimental support for adding blocks inside nav menus
-		add_theme_support( 'block-nav-menus' );
-
 		// Add support for core custom logo.
 		add_theme_support(
 			'custom-logo',

+ 4 - 0
seedlet-blocks/assets/theme.css

@@ -175,6 +175,10 @@
 	line-height: 30px;
 }
 
+.wp-block-navigation__container {
+	justify-content: center;
+}
+
 .wp-block-post-comments .reply a {
 	border-radius: var(--wp--custom--button--border--radius);
 	font-size: var(--wp--preset--font-size--small);

+ 1 - 1
seedlet-blocks/block-template-parts/header.html

@@ -8,7 +8,7 @@
 
 <!-- wp:site-tagline {"textAlign":"center","fontSize":"small"} /-->
 
-<!-- wp:navigation {"itemsJustification":"center","isResponsive":true} -->
+<!-- wp:navigation {"itemsJustification":"center","isResponsive":true,"__unstableLocation":"primary"} -->
 <!-- /wp:navigation -->
 
 <!-- wp:spacer {"height":60} -->

+ 12 - 3
seedlet-blocks/functions.php

@@ -3,22 +3,31 @@
 /**
  * Add Editor Styles
  */
-function seedlet_blocks_editor_styles() {
+function seedlet_blocks_support() {
+
 	// Enqueue editor styles.
 	add_editor_style(
 		array(
 			'/assets/theme.css',
 		)
 	);
+
+	// This theme has one menu location.
+	register_nav_menus(
+		array(
+			'primary' => __( 'Primary Navigation', 'seedlet-blocks' ),
+		)
+	);
+
 }
-add_action( 'after_setup_theme', 'seedlet_blocks_editor_styles' );
+add_action( 'after_setup_theme', 'seedlet_blocks_support' );
 
 /**
  *
  * Enqueue scripts and styles.
  */
 function seedlet_blocks_scripts() {
-	wp_enqueue_style( 'seedlet_blocks-styles', get_stylesheet_directory_uri() . '/assets/theme.css', array('blockbase-ponyfill'), wp_get_theme()->get( 'Version' ) );
+	wp_enqueue_style( 'seedlet_blocks-styles', get_stylesheet_directory_uri() . '/assets/theme.css', array( 'blockbase-ponyfill' ), wp_get_theme()->get( 'Version' ) );
 }
 add_action( 'wp_enqueue_scripts', 'seedlet_blocks_scripts' );
 

+ 6 - 0
seedlet-blocks/sass/blocks/_navigation.scss

@@ -16,4 +16,10 @@
 			}
 		}
 	}
+}
+
+/* NOTE: This can be removed when the rendering of the Navigation block, rendered with a Classic data source (by way of __unstableLocation), 
+is passed all of the block attributes on the block definition in the template. */
+.wp-block-navigation__container {
+	justify-content: center;
 }