Skip to content

Commit

Permalink
Remove breadcrumbs and update layout
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwoodnz committed Sep 5, 2023
1 parent 9c30b27 commit 90a8891
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 93 deletions.
78 changes: 0 additions & 78 deletions source/wp-content/themes/wporg-documentation-2022/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* Actions and filters.
*/
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets' );
add_filter( 'wporg_block_site_breadcrumbs', __NAMESPACE__ . '\set_site_breadcrumbs' );
add_action( 'pre_get_posts', __NAMESPACE__ . '\pre_get_posts' );
add_filter( 'comment_form_defaults', __NAMESPACE__ . '\comment_form_defaults' );
add_filter( 'comment_form_field_comment', __NAMESPACE__ . '\hide_field_after_submission' );
Expand Down Expand Up @@ -41,83 +40,6 @@ function enqueue_assets() {
);
}

/**
* Update the breadcrumbs format for this site.
*
* @param array $breadcrumbs An array of breadcrumb links.
* @return array Updated breadcrumbs.
*/
function set_site_breadcrumbs( $breadcrumbs ) {
if ( is_front_page() ) {
return array();
}

// Set the first item's title. By default this is the site title, but the
// site title for `w.org/support` is "WordPress Forums", which is not
// correct for the breadcrumbs.
$breadcrumbs[0]['title'] = __( 'Home', 'wporg-docs' );

if ( is_category() ) {
// Format: home / topic page / category
$category = get_queried_object();
$breadcrumbs = array( $breadcrumbs[0] );
if ( $category->category_parent ) {
$parent = get_term( $category->category_parent );
$breadcrumbs[] = array(
'url' => get_topic_permalink( $parent ),
'title' => $parent->name,
);
}
$breadcrumbs[] = array(
'url' => '',
'title' => $category->name,
);
} elseif ( is_singular( 'helphub_article' ) ) {
// Format: home / topic page / category / article title
$breadcrumbs = array( $breadcrumbs[0] );
$categories = get_the_category();
if ( $categories ) {
$cats_without_parents = wp_list_filter( $categories, [ 'parent' => 0 ] );
$cats_with_parents = wp_list_filter( $categories, [ 'parent' => 0 ], 'NOT' );
if ( $cats_without_parents ) {
$category = reset( $cats_without_parents );
$breadcrumbs[] = array(
'url' => get_topic_permalink( $category ),
'title' => $category->name,
);
}
if ( $cats_with_parents ) {
$category = reset( $cats_with_parents );
$breadcrumbs[] = array(
'url' => get_term_link( $category->term_id, $category->taxonomy ),
'title' => $category->name,
);
}
}
$breadcrumbs[] = array(
'url' => '',
'title' => get_the_title(),
);
}

return $breadcrumbs;
}

/**
* Get the topic landing page permalink for a given parent category.
*/
function get_topic_permalink( $category ) {
if ( empty( $category->slug ) ) {
return '';
}

if ( 'wordpress-overview' === $category->slug ) {
return site_url( '/overview/' );
}

return site_url( '/' . $category->slug . '/' );
}

/**
* Filter the default query.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- wp:wporg/global-header /-->

<!-- wp:group {"align":"full","style":{"elements":{"link":{"color":{"text":"var:preset|color|white"}}}},"backgroundColor":"charcoal-2","textColor":"white","className":"is-sticky","layout":{"type":"constrained"}} -->
<div class="wp-block-group alignfull is-sticky has-white-color has-charcoal-2-background-color has-text-color has-background has-link-color">

<!-- wp:group {"align":"full","style":{"border":{"top":{"color":"var:preset|color|opacities-white-10","width":"1px"}},"spacing":{"padding":{"top":"18px","bottom":"18px","left":"var:preset|spacing|edge-space","right":"var:preset|spacing|edge-space"}}},"layout":{"type":"flex","flexWrap":"wrap","justifyContent":"right"}} -->
<div class="wp-block-group alignfull" style="border-top-color:var(--wp--preset--color--opacities-white-10);border-top-width:1px;padding-top:18px;padding-right:var(--wp--preset--spacing--edge-space);padding-bottom:18px;padding-left:var(--wp--preset--spacing--edge-space)">

<!-- wp:template-part {"slug":"header-navigation"} /-->

</div>
<!-- /wp:group -->

</div>
<!-- /wp:group -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- wp:navigation {"textColor":"white","className":"is-style-dropdown-on-mobile","style":{"spacing":{"blockGap":"24px"}},"fontSize":"small"} -->

<!-- wp:navigation-link {"label":"WordPress Overview","url":"https://wordpress.org/documentation/overview/","kind":"custom","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Technical Guides","type":"custom","url":"https://wordpress.org/documentation/technical-guides/","kind":"custom","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Support Guides","type":"custom","url":"https://wordpress.org/documentation/support-guides/","kind":"custom","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Customization","type":"custom","url":"https://wordpress.org/documentation/customization/","kind":"custom","isTopLevelLink":true} /-->

<!-- /wp:navigation -->
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,18 @@

?>

<!-- wp:group {"align":"full","style":{"spacing":{"blockGap":"0"}},"backgroundColor":"charcoal-2","className":"is-sticky","layout":{"type":"constrained"}} -->
<div class="wp-block-group alignfull is-sticky has-charcoal-2-background-color has-background">

<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"18px","bottom":"18px","left":"var:preset|spacing|edge-space","right":"var:preset|spacing|edge-space"}},"elements":{"link":{"color":{"text":"var:preset|color|white"}}},"border":{"top":{"color":"var:preset|color|opacities-white-10","width":"1px"},"right":{},"bottom":{},"left":{}}},"backgroundColor":"charcoal-2","textColor":"white","layout":{"type":"flex","flexWrap":"wrap","justifyContent":"space-between"}} -->
<div class="wp-block-group alignfull has-white-color has-charcoal-2-background-color has-text-color has-background has-link-color" style="border-top-color:var(--wp--preset--color--opacities-white-10);border-top-width:1px;padding-top:18px;padding-right:var(--wp--preset--spacing--edge-space);padding-bottom:18px;padding-left:var(--wp--preset--spacing--edge-space)">
<!-- wp:group {"align":"full","style":{"spacing":{"blockGap":"0"},"elements":{"link":{"color":{"text":"var:preset|color|white"}}}},"backgroundColor":"charcoal-2","textColor":"white","className":"is-sticky","layout":{"type":"constrained"}} -->
<div class="wp-block-group alignfull is-sticky has-white-color has-charcoal-2-background-color has-text-color has-background has-link-color">

<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"18px","bottom":"18px","left":"var:preset|spacing|edge-space","right":"var:preset|spacing|edge-space"}},"border":{"top":{"color":"var:preset|color|opacities-white-10","width":"1px"}}},"className":"has-background","layout":{"type":"flex","flexWrap":"wrap","justifyContent":"space-between"}} -->
<div class="wp-block-group alignfull has-background" style="border-top-color:var(--wp--preset--color--opacities-white-10);border-top-width:1px;padding-top:18px;padding-right:var(--wp--preset--spacing--edge-space);padding-bottom:18px;padding-left:var(--wp--preset--spacing--edge-space)">

<!-- wp:paragraph {"fontSize":"small"} -->
<p class="has-small-font-size"><?php esc_html_e( 'Documentation', 'wporg-docs' ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:navigation {"textColor":"white","backgroundColor":"charcoal-2","className":"is-style-dropdown-on-mobile","style":{"spacing":{"blockGap":"24px"}},"fontSize":"small"} -->

<!-- wp:navigation-link {"label":"WordPress Overview","url":"https://wordpress.org/documentation/overview/","kind":"custom","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Technical Guides","type":"custom","url":"https://wordpress.org/documentation/technical-guides/","kind":"custom","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Support Guides","type":"custom","url":"https://wordpress.org/documentation/support-guides/","kind":"custom","isTopLevelLink":true} /-->
<!-- wp:navigation-link {"label":"Customization","type":"custom","url":"https://wordpress.org/documentation/customization/","kind":"custom","isTopLevelLink":true} /-->

<!-- /wp:navigation -->

<!-- wp:template-part {"slug":"header-navigation"} /-->

</div>
<!-- /wp:group -->

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- wp:template-part {"slug":"header","className":"has-display-contents"} /-->
<!-- wp:template-part {"slug":"header-home","className":"has-display-contents"} /-->

<!-- wp:group {"tagName":"main"} -->
<main class="wp-block-group">
Expand Down

0 comments on commit 90a8891

Please sign in to comment.