From 83d81f32b07b996dd4ae6e40b2707d4dd8323641 Mon Sep 17 00:00:00 2001 From: Brandon Date: Sat, 29 Jul 2023 03:12:40 -0500 Subject: [PATCH] fix(crumb): Fix blog items getting invalid URL (Fixes #3) (#13) * enhance(crumb): Add the blog page `id` to the blog item * chore(docs): Bump minimum required version to 7.4 --- README.md | 2 +- src/Crumb.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 09d72ba..5ab4f42 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A simple breadcrumb package for Sage 10. ## Requirements - [Sage](https://github.com/roots/sage) >= 10.0 -- [PHP](https://secure.php.net/manual/en/install.php) >= 7.3 +- [PHP](https://secure.php.net/manual/en/install.php) >= 7.4 - [Composer](https://getcomposer.org/download/) ## Installation diff --git a/src/Crumb.php b/src/Crumb.php index 9349722..c47bdfd 100644 --- a/src/Crumb.php +++ b/src/Crumb.php @@ -38,14 +38,15 @@ public function __construct(array $config) protected function add($key, $value = null, $id = null, $blog = false) { if ( - ($value === true && empty($blog) || $blog === true) && + $blog === true && get_option('show_on_front') === 'page' && ! empty($blog = get_option('page_for_posts')) && ! empty($this->config['blog']) ) { $this->add( $this->config['blog'], - get_permalink($blog) + get_permalink($blog), + $blog ); } @@ -131,6 +132,8 @@ public function build() if (is_month()) { return $this->add( get_the_date('F Y'), + null, + null, true ); } @@ -138,12 +141,16 @@ public function build() if (is_year()) { return $this->add( get_the_date('Y'), + null, + null, true ); } return $this->add( get_the_date(), + null, + null, true ); }