-
Notifications
You must be signed in to change notification settings - Fork 26
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
Data Liberation: Add interior pages #375
base: trunk
Are you sure you want to change the base?
Changes from all commits
6b42dd5
d19edac
d58f6b1
69d1544
0cecaa7
38fce81
33152fa
069f0c0
7d3f419
d487096
e64dd41
bce74bf
705f7b2
bd190bc
95d5d8a
13b9cb9
8653ef6
92b2453
635e45d
835dd86
9dfecca
c33ccbf
6238975
cc9fb3c
731242d
ff2f7c8
6353c07
ded91a8
462548b
fd0cc8f
8a16b35
431eeaf
96fa7f1
064d05e
54bdf05
5e21c8c
7716d17
b5efb17
3d237f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
/** | ||
* Actions and filters. | ||
*/ | ||
add_filter( 'document_title_parts', __NAMESPACE__ . '\document_title' ); | ||
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets' ); | ||
add_action( 'init', __NAMESPACE__ . '\register_shortcodes' ); | ||
add_filter( 'wp_img_tag_add_loading_attr', __NAMESPACE__ . '\override_lazy_loading', 10, 2 ); | ||
|
@@ -27,6 +28,12 @@ | |
add_filter( 'render_block_data', __NAMESPACE__ . '\update_header_template_part_class' ); | ||
add_filter( 'wporg_block_navigation_menus', __NAMESPACE__ . '\add_site_navigation_menus' ); | ||
|
||
// Remove table of contents. | ||
add_filter( 'wporg_handbook_toc_should_add_toc', '__return_false' ); | ||
|
||
// Remove the edit link from handbook titles. | ||
add_filter( 'wporg_markdown_should_filter_title', '__return_false' ); | ||
|
||
/** | ||
* Enqueue scripts and styles. | ||
*/ | ||
|
@@ -138,6 +145,25 @@ function override_lazy_loading( $value, $image ) { | |
* Use the page heirarchy to display breadcrumbs. | ||
*/ | ||
function update_site_breadcrumbs( $breadcrumbs ) { | ||
|
||
// Handle breadcrumbs for the data liberation section. | ||
if ( is_singular( 'and-handbook' ) ) { | ||
return array( | ||
array( | ||
'url' => home_url( '/data-liberation' ), | ||
'title' => __( 'Home', 'wporg' ), | ||
), | ||
array( | ||
'url' => home_url( '/data-liberation/and' ), | ||
'title' => __( 'Guides', 'wporg' ), | ||
), | ||
array( | ||
'url' => false, | ||
'title' => get_the_title(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also see this, looks like it comes from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is everyone okay with removing that function from the wporg-markdown plugin? Context: #375 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's not going to be used anywhere, I also think we can remove it. |
||
), | ||
); | ||
} | ||
|
||
$parent = get_post_parent(); | ||
if ( ! $parent ) { | ||
return $breadcrumbs; | ||
|
@@ -263,6 +289,16 @@ function add_site_navigation_menus( $menus ) { | |
* @param WP_Block $instance The block instance. | ||
*/ | ||
function use_parent_page_title( $block_content, $block, $instance ) { | ||
|
||
// Handle the site title for data liberation. | ||
if ( is_post_type_archive( 'and-handbook' ) || is_singular( 'and-handbook' ) ) { | ||
return str_replace( | ||
array( home_url(), get_bloginfo( 'name' ) ), | ||
array( home_url( '/data-liberation' ), __( 'Data Liberation', 'wporg' ) ), | ||
$block_content | ||
); | ||
} | ||
|
||
if ( is_home() || is_single() || is_archive() ) { | ||
return str_replace( | ||
array( home_url(), get_bloginfo( 'name' ) ), | ||
|
@@ -323,3 +359,26 @@ function update_header_template_part_class( $block ) { | |
} | ||
return $block; | ||
} | ||
|
||
/** | ||
* Append an optimized site name. | ||
* | ||
* @param array $parts { | ||
* The document title parts. | ||
* | ||
* @type string $title Title of the viewed page. | ||
* @type string $page Optional. Page number if paginated. | ||
* @type string $tagline Optional. Site description when on home page. | ||
* @type string $site Optional. Site title when not on home page. | ||
* } | ||
* @return array Filtered title parts. | ||
*/ | ||
function document_title( $parts ) { | ||
|
||
if ( is_singular( 'and-handbook' ) ) { | ||
// translators: %s: Name of the guide. | ||
$parts['title'] = sprintf( __( '%s - Data Liberation', 'wporg' ), $parts['title'] ); | ||
} | ||
|
||
return $parts; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
// phpcs:disable WordPress.Files.FileName -- Allow underscore for pattern partial. | ||
/** | ||
* Title: Section Nav (Data Liberation Single) | ||
* Slug: wporg-main-2022/nav-data-liberation-single | ||
* Inserter: no | ||
*/ | ||
|
||
?> | ||
<!-- wp:pattern {"slug":"wporg-main-2022/nav-data-liberation"} /--> | ||
|
||
<!-- wp:group {"className":"wporg-breadcrumbs","align":"full","style":{"spacing":{"padding":{"top":"18px","bottom":"18px","left":"var:preset|spacing|edge-space","right":"var:preset|spacing|edge-space"}}},"backgroundColor":"white","layout":{"type":"flex","flexWrap":"wrap","justifyContent":"space-between"}} --> | ||
<div class="wporg-breadcrumbs wp-block-group alignfull has-white-background-color has-background" style="padding-top:18px;padding-right:var(--wp--preset--spacing--edge-space);padding-bottom:18px;padding-left:var(--wp--preset--spacing--edge-space)"> | ||
<!-- wp:wporg/site-breadcrumbs {"fontSize":"small"} /--> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
// phpcs:disable WordPress.Files.FileName -- Allow underscore for pattern partial. | ||
/** | ||
* Title: Section Nav (Data Liberation) | ||
* Slug: wporg-main-2022/nav-data-liberation | ||
* Inserter: no | ||
*/ | ||
|
||
?> | ||
|
||
<!-- wp:wporg/local-navigation-bar {"backgroundColor":"charcoal-2","style":{"position":{"type":"sticky"},"elements":{"link":{"color":{"text":"var:preset|color|white"},":hover":{"color":{"text":"var:preset|color|white"}}}}},"textColor":"white","fontSize":"small"} --> | ||
<!-- wp:site-title {"level":0,"fontSize":"small"} /--> | ||
<!-- wp:navigation {"menuSlug":"documentation","icon":"menu","overlayBackgroundColor":"charcoal-2","overlayTextColor":"white","layout":{"type":"flex","orientation":"horizontal"},"fontSize":"small"} /--> | ||
<!-- /wp:wporg/local-navigation-bar --> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Title: Data Liberation Guides List | ||
* Slug: wporg-main-2022/data-liberation-guide-single | ||
* Inserter: no | ||
*/ | ||
|
||
?> | ||
<!-- wp:group {"align":"wide","layout":{"type":"constrained","justifyContent":"left"}} --> | ||
<div class="wp-block-group alignwide"><!-- wp:group {"tagName":"article"} --> | ||
<article class="wp-block-group"><!-- wp:post-title {"level":1,"style":{"spacing":{"margin":{"top":"var:preset|spacing|60","bottom":"var:preset|spacing|40"}}}} /--> | ||
|
||
<!-- wp:wporg/sidebar-container {"style":{"spacing":{"margin":{"bottom":"40px"}}}} --> | ||
<!-- wp:wporg/table-of-contents /--> | ||
<!-- /wp:wporg/sidebar-container --> | ||
|
||
<!-- wp:post-content {"layout":{"inherit":true}} /--></article> | ||
<!-- /wp:group --></div> | ||
<!-- /wp:group --> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* Title: Data Liberation Guides List | ||
* Slug: wporg-main-2022/data-liberation-guides | ||
* Inserter: no | ||
*/ | ||
|
||
?> | ||
|
||
<!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"right":"var:preset|spacing|edge-space","left":"var:preset|spacing|edge-space"}}},"layout":{"type":"constrained"}} --> | ||
<div class="wp-block-group alignwide" style="padding-right:var(--wp--preset--spacing--edge-space);padding-left:var(--wp--preset--spacing--edge-space)"><!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"top":"var:preset|spacing|60","bottom":"var:preset|spacing|80"}}},"layout":{"type":"default"}} --> | ||
<div class="wp-block-group alignwide" style="padding-top:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--80)"><!-- wp:heading {"style":{"spacing":{"margin":{"bottom":"var:preset|spacing|30","top":"0"}}}} --> | ||
<h2 class="wp-block-heading" style="margin-top:0;margin-bottom:var(--wp--preset--spacing--30)">Guides</h2> | ||
<!-- /wp:heading --> | ||
|
||
<!-- wp:group {"layout":{"type":"default"}} --> | ||
<div class="wp-block-group"><!-- wp:query {"queryId":2,"query":{"perPage":10,"pages":0,"offset":0,"postType":"and-handbook","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false},"layout":{"type":"default"}} --> | ||
<div class="wp-block-query"><!-- wp:group {"style":{"border":{"bottom":{"color":"var:preset|color|light-grey-1","width":"1px"}},"spacing":{"margin":{"bottom":"var:preset|spacing|30"}}},"layout":{"type":"default"}} --> | ||
<div class="wp-block-group" style="border-bottom-color:var(--wp--preset--color--light-grey-1);border-bottom-width:1px;margin-bottom:var(--wp--preset--spacing--30)"><!-- wp:post-template {"style":{"spacing":{"blockGap":"0"}},"className":"is-style-border-list"} --> | ||
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|20","left":"var:preset|spacing|20","right":"var:preset|spacing|20"},"margin":{"top":"0","bottom":"0"}},"border":{"top":{"color":"var:preset|color|light-grey-1","width":"1px"},"right":{"color":"var:preset|color|light-grey-1","width":"1px"},"bottom":{},"left":{"color":"var:preset|color|light-grey-1","width":"1px"}}},"layout":{"type":"default"}} --> | ||
<div class="wp-block-group" style="border-top-color:var(--wp--preset--color--light-grey-1);border-top-width:1px;border-right-color:var(--wp--preset--color--light-grey-1);border-right-width:1px;border-left-color:var(--wp--preset--color--light-grey-1);border-left-width:1px;margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><!-- wp:post-title {"level":3,"isLink":true,"style":{"spacing":{"margin":{"top":"0","bottom":"0"}},"typography":{"fontStyle":"normal","fontWeight":"700"},"elements":{"link":{"color":{"text":"var:preset|color|blueberry-1"}}}},"textColor":"blueberry-1","fontSize":"normal","fontFamily":"inter"} /--> | ||
|
||
<!-- wp:post-excerpt {"style":{"spacing":{"margin":{"top":"0","bottom":"0"}}}} /--></div> | ||
<!-- /wp:group --> | ||
<!-- /wp:post-template --></div> | ||
<!-- /wp:group --> | ||
|
||
<!-- wp:query-pagination --> | ||
<!-- wp:query-pagination-previous /--> | ||
|
||
<!-- wp:query-pagination-numbers /--> | ||
|
||
<!-- wp:query-pagination-next /--> | ||
<!-- /wp:query-pagination --></div> | ||
<!-- /wp:query --></div> | ||
<!-- /wp:group --></div> | ||
<!-- /wp:group --></div> | ||
<!-- /wp:group --> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- wp:wporg/global-header {"style":{"border":{"bottom":{"color":"var:preset|color|white-opacity-15","style":"solid","width":"1px"}}}} /--> | ||
|
||
<!-- wp:pattern {"slug":"wporg-main-2022/nav-data-liberation"} /--> | ||
|
||
<!-- wp:group {"tagName":"main","style":{"spacing":{"blockGap":"0px"}},"className":"entry-content","layout":{"inherit":true,"type":"constrained"}} --> | ||
<main class="wp-block-group entry-content"> | ||
<!-- wp:pattern {"slug":"wporg-main-2022/data-liberation-guides"} /--> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there plans to support translating the data lib pages? If not, we probably don't need to use the pattern process here, since these pages wouldn't be rolled out to rosetta sites. (IIRC we don't have a process for translating handbooks yet, which is why i assume no) Not a strong suggestion, but it would be one less abstraction, to put the pattern content (query loop, etc) here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I default to yes. We should support it but understand that rosetta experiences vary right now and these pages may never be viewed in other locales... but still feel it should be localized. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, if we assume that it will be available eventually then 👍🏻 — my aim was to not make more work for the translators. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good thought and something I haven't considered when developing. Thanks. |
||
</main> | ||
<!-- /wp:group --> | ||
|
||
<!-- wp:wporg/global-footer /--> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!-- wp:wporg/global-header {"style":{"border":{"bottom":{"color":"var:preset|color|white-opacity-15","style":"solid","width":"1px"}}}} /--> | ||
|
||
<!-- wp:pattern {"slug":"wporg-main-2022/nav-data-liberation-single"} /--> | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra line. |
||
<!-- wp:group {"tagName":"main","style":{"spacing":{"padding":{"left":"var:preset|spacing|edge-space","right":"var:preset|spacing|edge-space","bottom":"var:preset|spacing|70"}}},"className":"alignfull","layout":{"type":"constrained"}} --> | ||
<main class="wp-block-group alignfull" style="padding-right:var(--wp--preset--spacing--edge-space);padding-bottom:var(--wp--preset--spacing--70);padding-left:var(--wp--preset--spacing--edge-space)"> | ||
<!-- wp:pattern {"slug":"wporg-main-2022/data-liberation-guide-single"} /--> | ||
</main> | ||
<!-- /wp:group --> | ||
StevenDufresne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<!-- wp:wporg/global-footer /--> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why this filter seems to not exist anymore… I would have thought this would prevent the issue @renintw and I are seeing here. I can't find the filter in the wporg-markdown plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, dang. That was a filter I implemented in my local environment in the markdown plugin. Essentially returning early here.
I discussed this with @dd32 and since we don't use the title anywhere anymore, we agreed we could remove the function altogether and I forgot to update.