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

Navigation: add new patterns #35063

Closed
wants to merge 1 commit into from
Closed
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
39 changes: 39 additions & 0 deletions lib/block-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ function register_gutenberg_patterns() {
register_block_pattern_category( 'query', array( 'label' => __( 'Query', 'gutenberg' ) ) );
}

if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( 'navigation' ) ) {
register_block_pattern_category( 'navigation', array( 'label' => __( 'Navigation', 'gutenberg' ) ) );
}

$patterns = array(
'query-standard-posts' => array(
'title' => _x( 'Standard', 'Block pattern title', 'gutenberg' ),
Expand Down Expand Up @@ -157,6 +161,41 @@ function register_gutenberg_patterns() {
<!-- wp:social-link {"url":"#","service":"mail"} /--></ul>
<!-- /wp:social-links -->',
),
'navigation-page-links' => array(
'title' => _x( 'All pages menu', 'Block pattern title', 'gutenberg' ),
'categories' => array( 'navigation' ),
'blockTypes' => array( 'core/navigation' ),
'content' => '<!-- wp:navigation --><!-- wp:page-list {"isNavigationChild":true,"showSubmenuIcon":true,"openSubmenusOnClick":false} /--><!-- /wp:navigation -->',
),
'navigation-page-links-responsive' => array(
'title' => _x( 'All pages menu (responsive)', 'Block pattern title', 'gutenberg' ),
'viewportWidth' => 500,
'categories' => array( 'navigation' ),
'blockTypes' => array( 'core/navigation' ),
'content' => '<!-- wp:navigation {"isResponsive":true} --><!-- wp:page-list {"isNavigationChild":true,"showSubmenuIcon":true,"openSubmenusOnClick":false} /--><!-- /wp:navigation -->',
),
'navigation-vertical' => array(
'title' => _x( 'Vertical navigation menu', 'Block pattern title', 'gutenberg' ),
'categories' => array( 'navigation' ),
'blockTypes' => array( 'core/navigation' ),
'content' => '<!-- wp:navigation {"orientation":"vertical","style":{"typography":{"fontFamily":"var:preset|font-family|system-fonts"}},"fontSize":"extra-large"} -->
<!-- wp:home-link {"label":"Home"} /-->
<!-- wp:navigation-link {"label":"About","type":"page","kind":"post-type","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Contact","type":"page","kind":"post-type","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Portfolio","type":"page","kind":"post-type","isTopLevelLink":true} /-->
<!-- /wp:navigation -->',
),
'navigation-horizontal' => array(
'title' => _x( 'Horizontal navigation menu', 'Block pattern title', 'gutenberg' ),
'categories' => array( 'navigation' ),
'blockTypes' => array( 'core/navigation' ),
'content' => '<!-- wp:navigation {"style":{"typography":{"fontFamily":"var:preset|font-family|system-fonts"}},"fontSize":"extra-large"} -->
<!-- wp:home-link {"label":"Home"} /-->
<!-- wp:navigation-link {"label":"About","type":"page","kind":"post-type","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Contact","type":"page","kind":"post-type","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Portfolio","type":"page","kind":"post-type","isTopLevelLink":true} /-->
<!-- /wp:navigation -->',
),
);

foreach ( $patterns as $name => $pattern ) {
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@ export default function NavigationLinkEdit( {
/* translators: label for missing values in navigation link block */
missingText = __( 'Add link' );
}
if ( label ) {
missingText = label;
}

return (
<Fragment>
Expand Down