From adc8f48f5e4adcebe9e12b5b515d47dc21a3bd72 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Tue, 6 Feb 2024 14:18:16 -0500 Subject: [PATCH 1/9] Update homepage header --- .../wporg-developer-2023/patterns/front-page-header.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/wp-content/themes/wporg-developer-2023/patterns/front-page-header.php b/source/wp-content/themes/wporg-developer-2023/patterns/front-page-header.php index bac2eff2e..765b3db57 100644 --- a/source/wp-content/themes/wporg-developer-2023/patterns/front-page-header.php +++ b/source/wp-content/themes/wporg-developer-2023/patterns/front-page-header.php @@ -9,9 +9,7 @@ - - - + From f88e0b927358bc2c62d19bef3f1452dcc7cb7152 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Tue, 6 Feb 2024 17:39:30 -0500 Subject: [PATCH 2/9] New block: Add a page title block which can be used for single, archive, and search page titles. --- .../themes/wporg-developer-2023/functions.php | 1 + .../src/page-title/block.json | 28 +++++++++++ .../src/page-title/index.js | 17 +++++++ .../src/page-title/index.php | 50 +++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 source/wp-content/themes/wporg-developer-2023/src/page-title/block.json create mode 100644 source/wp-content/themes/wporg-developer-2023/src/page-title/index.js create mode 100644 source/wp-content/themes/wporg-developer-2023/src/page-title/index.php diff --git a/source/wp-content/themes/wporg-developer-2023/functions.php b/source/wp-content/themes/wporg-developer-2023/functions.php index 1a61ae532..044ae948b 100644 --- a/source/wp-content/themes/wporg-developer-2023/functions.php +++ b/source/wp-content/themes/wporg-developer-2023/functions.php @@ -177,6 +177,7 @@ require_once __DIR__ . '/src/command-github/block.php'; require_once __DIR__ . '/src/command-title/block.php'; require_once __DIR__ . '/src/command-subcommand/block.php'; +require_once __DIR__ . '/src/page-title/index.php'; require_once __DIR__ . '/src/reference-new-updated/block.php'; require_once __DIR__ . '/src/resource-select/index.php'; require_once __DIR__ . '/src/search-filters/index.php'; diff --git a/source/wp-content/themes/wporg-developer-2023/src/page-title/block.json b/source/wp-content/themes/wporg-developer-2023/src/page-title/block.json new file mode 100644 index 000000000..ffa7f300b --- /dev/null +++ b/source/wp-content/themes/wporg-developer-2023/src/page-title/block.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 2, + "name": "wporg/page-title", + "version": "0.1.0", + "title": "Page Title", + "category": "widgets", + "description": "Page Title", + "attributes": { + "level": { + "type": "integer", + "default": 1 + } + }, + "supports": { + "html": false, + "spacing": { + "margin": true, + "padding": true + }, + "typography": { + "fontSize": true, + "lineHeight": true + } + }, + "textdomain": "wporg", + "editorScript": "file:./index.js" +} diff --git a/source/wp-content/themes/wporg-developer-2023/src/page-title/index.js b/source/wp-content/themes/wporg-developer-2023/src/page-title/index.js new file mode 100644 index 000000000..abba51c28 --- /dev/null +++ b/source/wp-content/themes/wporg-developer-2023/src/page-title/index.js @@ -0,0 +1,17 @@ +/** + * WordPress dependencies + */ +import { registerBlockType } from '@wordpress/blocks'; + +/** + * Internal dependencies + */ +import Edit from '../shared/dynamic-edit'; +import metadata from './block.json'; + +registerBlockType( metadata.name, { + /** + * @see ./edit.js + */ + edit: Edit, +} ); diff --git a/source/wp-content/themes/wporg-developer-2023/src/page-title/index.php b/source/wp-content/themes/wporg-developer-2023/src/page-title/index.php new file mode 100644 index 000000000..24541a676 --- /dev/null +++ b/source/wp-content/themes/wporg-developer-2023/src/page-title/index.php @@ -0,0 +1,50 @@ + __NAMESPACE__ . '\render', + ) + ); +} + +/** + * Render the block content. + * + * @return string Returns the block markup. + */ +function render( $attributes, $content, $block ) { + $tag_name = 'h1'; + if ( isset( $attributes['level'] ) ) { + $tag_name = 0 === $attributes['level'] ? 'p' : 'h' . (int) $attributes['level']; + } + + $title = get_the_title(); + + if ( is_search() ) { + $title = __( 'Search results', 'wporg' ); + } elseif ( is_archive() ) { + $title = get_the_archive_title(); + } elseif ( in_array( get_post_type(), array( 'wp-parser-function', 'wp-parser-method' ) ) ) { + $title .= '()'; + } + + $wrapper_attributes = get_block_wrapper_attributes(); + return sprintf( + '<%1$s %2$s>%3$s', + $tag_name, + $wrapper_attributes, + $title, + ); +} From 88116ffc48aa4062a7bb6120a88468384e61cced Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Tue, 6 Feb 2024 16:51:26 -0500 Subject: [PATCH 3/9] Add the "Level 2 B" header variation as "header-alt" --- .../wporg-developer-2023/parts/header-alt.html | 15 +++++++++++++++ .../themes/wporg-developer-2023/parts/header.html | 11 +---------- .../wporg-developer-2023/templates/archive.html | 2 +- .../templates/page-dashicons.html | 2 +- .../wporg-developer-2023/templates/search.html | 2 +- .../templates/single-handbook.html | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 source/wp-content/themes/wporg-developer-2023/parts/header-alt.html diff --git a/source/wp-content/themes/wporg-developer-2023/parts/header-alt.html b/source/wp-content/themes/wporg-developer-2023/parts/header-alt.html new file mode 100644 index 000000000..668cd7c3d --- /dev/null +++ b/source/wp-content/themes/wporg-developer-2023/parts/header-alt.html @@ -0,0 +1,15 @@ + + + + + +
+ + + +
+ + + + + diff --git a/source/wp-content/themes/wporg-developer-2023/parts/header.html b/source/wp-content/themes/wporg-developer-2023/parts/header.html index 6542d790a..67667df02 100644 --- a/source/wp-content/themes/wporg-developer-2023/parts/header.html +++ b/source/wp-content/themes/wporg-developer-2023/parts/header.html @@ -5,14 +5,5 @@ - - - - -
- - - -
- + diff --git a/source/wp-content/themes/wporg-developer-2023/templates/archive.html b/source/wp-content/themes/wporg-developer-2023/templates/archive.html index 5fb5ec1b6..c6c68661a 100644 --- a/source/wp-content/themes/wporg-developer-2023/templates/archive.html +++ b/source/wp-content/themes/wporg-developer-2023/templates/archive.html @@ -1,4 +1,4 @@ - + diff --git a/source/wp-content/themes/wporg-developer-2023/templates/page-dashicons.html b/source/wp-content/themes/wporg-developer-2023/templates/page-dashicons.html index b6377a0e2..b10c28755 100644 --- a/source/wp-content/themes/wporg-developer-2023/templates/page-dashicons.html +++ b/source/wp-content/themes/wporg-developer-2023/templates/page-dashicons.html @@ -1,4 +1,4 @@ - +
diff --git a/source/wp-content/themes/wporg-developer-2023/templates/search.html b/source/wp-content/themes/wporg-developer-2023/templates/search.html index 9ece06540..06dd6d730 100644 --- a/source/wp-content/themes/wporg-developer-2023/templates/search.html +++ b/source/wp-content/themes/wporg-developer-2023/templates/search.html @@ -1,4 +1,4 @@ - +
diff --git a/source/wp-content/themes/wporg-developer-2023/templates/single-handbook.html b/source/wp-content/themes/wporg-developer-2023/templates/single-handbook.html index e285f8075..468ad81bd 100644 --- a/source/wp-content/themes/wporg-developer-2023/templates/single-handbook.html +++ b/source/wp-content/themes/wporg-developer-2023/templates/single-handbook.html @@ -1,4 +1,4 @@ - + From 2393269b62b230a94b0f6208ef1c736af4ec61f1 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Tue, 6 Feb 2024 16:08:35 -0500 Subject: [PATCH 4/9] Block Hooks: Update template part depending on the current page. --- .../wporg-developer-2023/inc/block-hooks.php | 30 +++++++++++++++++++ .../parts/header-third.html | 28 +++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 source/wp-content/themes/wporg-developer-2023/parts/header-third.html diff --git a/source/wp-content/themes/wporg-developer-2023/inc/block-hooks.php b/source/wp-content/themes/wporg-developer-2023/inc/block-hooks.php index 2be763f16..8622d82f9 100644 --- a/source/wp-content/themes/wporg-developer-2023/inc/block-hooks.php +++ b/source/wp-content/themes/wporg-developer-2023/inc/block-hooks.php @@ -8,6 +8,7 @@ use function DevHub\is_parsed_post_type; add_filter( 'render_block', __NAMESPACE__ . '\filter_handbook_meta_link_block', 10, 2 ); +add_filter( 'render_block_data', __NAMESPACE__ . '\modify_header_template_part' ); /** * Filters the search block and conditionally inserts search filters. @@ -77,3 +78,32 @@ function filter_handbook_meta_link_block( $block_content, $block ) { return $block_content; } + +/** + * Update header template based on current query. + * + * @param array $parsed_block The block being rendered. + * + * @return array The updated block. + */ +function modify_header_template_part( $parsed_block ) { + if ( + 'core/template-part' === $parsed_block['blockName'] && + ! empty( $parsed_block['attrs']['slug'] ) && + str_starts_with( $parsed_block['attrs']['slug'], 'header' ) + ) { + $template_slug = 'header-third'; + if ( + function_exists( 'wporg_is_handbook' ) && + wporg_is_handbook() && + ! wporg_is_handbook_landing_page() + ) { + $parsed_block['attrs']['slug'] = $template_slug; + } elseif ( 'command' === get_post_type() && is_single() ) { + $parsed_block['attrs']['slug'] = $template_slug; + } elseif ( is_parsed_post_type() && ! is_search() ) { + $parsed_block['attrs']['slug'] = $template_slug; + } + } + return $parsed_block; +} diff --git a/source/wp-content/themes/wporg-developer-2023/parts/header-third.html b/source/wp-content/themes/wporg-developer-2023/parts/header-third.html new file mode 100644 index 000000000..55b891393 --- /dev/null +++ b/source/wp-content/themes/wporg-developer-2023/parts/header-third.html @@ -0,0 +1,28 @@ + + + + + + + +
+ + + +
+ + + + + + + +
+ + + +
+ From 0fb9698faed703bd352209993eb50431b27450a5 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Thu, 8 Feb 2024 12:11:41 -0500 Subject: [PATCH 5/9] Unhide breadcrumbs on small screens --- .../themes/wporg-developer-2023/src/style/style.scss | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/wp-content/themes/wporg-developer-2023/src/style/style.scss b/source/wp-content/themes/wporg-developer-2023/src/style/style.scss index a44882a57..fb84b6662 100644 --- a/source/wp-content/themes/wporg-developer-2023/src/style/style.scss +++ b/source/wp-content/themes/wporg-developer-2023/src/style/style.scss @@ -7,10 +7,6 @@ // If the breadcrumbs are present, the space after them needs to be reduced. // The next content is typically the search field. margin-bottom: calc(var(--wp--preset--spacing--10) * -1); - - @media (max-width: 767px) { - display: none !important; - } } pre { From 116121c84e6e2375344c48ab08b6879ee722a327 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Fri, 16 Feb 2024 18:00:01 -0500 Subject: [PATCH 6/9] Fade in page title on scroll --- .../themes/wporg-developer-2023/parts/header-alt.html | 2 +- .../themes/wporg-developer-2023/parts/header-third.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/wp-content/themes/wporg-developer-2023/parts/header-alt.html b/source/wp-content/themes/wporg-developer-2023/parts/header-alt.html index 668cd7c3d..7c718930a 100644 --- a/source/wp-content/themes/wporg-developer-2023/parts/header-alt.html +++ b/source/wp-content/themes/wporg-developer-2023/parts/header-alt.html @@ -6,7 +6,7 @@
- +
diff --git a/source/wp-content/themes/wporg-developer-2023/parts/header-third.html b/source/wp-content/themes/wporg-developer-2023/parts/header-third.html index 55b891393..8cd3a9a85 100644 --- a/source/wp-content/themes/wporg-developer-2023/parts/header-third.html +++ b/source/wp-content/themes/wporg-developer-2023/parts/header-third.html @@ -11,7 +11,7 @@
- +
From eab620d8348342f9b1a1cddfa3761745fb3a1509 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Fri, 16 Feb 2024 18:14:16 -0500 Subject: [PATCH 7/9] Fix spacing of Table of Contents sidebar --- source/wp-content/themes/wporg-developer-2023/theme.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/wp-content/themes/wporg-developer-2023/theme.json b/source/wp-content/themes/wporg-developer-2023/theme.json index 098fb5caf..849eb4199 100644 --- a/source/wp-content/themes/wporg-developer-2023/theme.json +++ b/source/wp-content/themes/wporg-developer-2023/theme.json @@ -158,7 +158,7 @@ "wporg-sidebar-container": { "spacing": { "margin": { - "top": "150px" + "top": "100px" } } }, From f35ac4a9fed665f0458d7a4bb29c87cde15c92de Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Fri, 16 Feb 2024 18:17:13 -0500 Subject: [PATCH 8/9] Update space over search box to match other pages --- .../themes/wporg-developer-2023/patterns/search-content.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/wp-content/themes/wporg-developer-2023/patterns/search-content.php b/source/wp-content/themes/wporg-developer-2023/patterns/search-content.php index c015dba7d..63d5f3536 100644 --- a/source/wp-content/themes/wporg-developer-2023/patterns/search-content.php +++ b/source/wp-content/themes/wporg-developer-2023/patterns/search-content.php @@ -13,8 +13,8 @@
- -