Skip to content

[FEATURE] Custom Faceted Directory - #376

Open
GeoffDusome wants to merge 30 commits into
mainfrom
feature/MOOSE-350/faceted-directory-custom
Open

[FEATURE] Custom Faceted Directory#376
GeoffDusome wants to merge 30 commits into
mainfrom
feature/MOOSE-350/faceted-directory-custom

Conversation

@GeoffDusome

@GeoffDusome GeoffDusome commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What does this do/fix?

This pull request introduces several new block controllers for faceted directory functionality, updates the block registration, and improves context handling for block rendering. The most important changes are outlined below.


Faceted Directory Feature Implementation:

  • Added three new block controllers: Directory_Grid_Controller, Faceted_Directory_Controller, and Filter_Bar_Controller in the Components/Blocks namespace, providing the core logic for faceted directories, directory grid display, and filter bar controls. These controllers handle pagination, post type filtering, facet rendering, and block context management. [1] [2] [3]

Block Registration and Core Integration:

  • Registered new blocks (tribe/directory-grid, tribe/faceted-directory, tribe/filter-bar) in the Blocks_Definer so they are available in the editor and frontend.
  • Registered new definers and subscribers for facets in the main Core class, ensuring the new faceted directory features are loaded and hooked into the plugin lifecycle. [1] [2]

Block Controller Improvements:

  • Enhanced the Abstract_Block_Controller to support richer block context handling, including a fallback mechanism for editor preview context and a flag to control this behavior. This ensures consistent context data for both frontend and editor previews. [1] [2]

Media Handling Enhancement:

  • Updated the get_media method in the Post_Data trait to return a placeholder image when no media is available, improving the user experience for posts without featured images.

Changelog Update:

  • Documented the WordPress Core update, plugin, Composer, and NPM dependency updates, and ESLint config changes in the changelog.

QA

Links to relevant issues

Screenshots/video:

Demo Environment:

Pull request checklist

  • I've added a changelog entry for these changes.
  • I've linked to a relevant Jira issue.
  • I've captured a screenshot or screencast of the changes and linked it above.

@MlKilderkin MlKilderkin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we split this into smaller PRs next time? Currently it is very hard to review

Comment thread wp-content/plugins/core/src/Components/Blocks/Directory_Grid_Controller.php Outdated
$this->request = is_array( $request ) ? $request : [];
$this->paged = max( 1, absint( $this->request[ Facet_Registry::PAGE_PARAM ] ?? get_query_var( 'paged' ) ?: 1 ) );

$built = tribe_project()->container()->get( Directory_Query::class )->build(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curios why we do in such way and don't actually do DI in constructor? public function __construct( Directory_Query $dir_query, array $args = [] )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assume it's just a style choice. I don't think there's a correct way to do this right?

Comment thread wp-content/plugins/core/src/Facets/Directory_Query.php
: 'top';

$post_types = $this->attributes['postTypes'] ?? [ 'post' ];
$this->post_types = Facet_Registry::filter_public_post_types(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use DI in controller instead of static method call? Same applies to other places

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or make this as trait

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand the harm in the way this is set up, if you feel strongly please feel free to make a pass at the PR.

Comment thread wp-content/plugins/core/src/Facets/Facet_Index.php
* One row per post + facet + term, so a multi-facet filter resolves in a single
* grouped query instead of one taxonomy join per facet.
*/
class Facet_Index {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have kind of benchmark for this how long does it takes to rebuild the index? For example: Kinsta hosting likely fail you if your job will be run more than 30 seconds. Pantheon as well. We might need to do that in batches

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no benchmarks currently and have no real way to run any. This is a good call. I think it makes sense to look into this in a follow-up or maybe on a project that would be on a hosting platform that would require it.

*
* @return array<string, bool>
*/
private static function add_ancestors( array $keep, array $terms ): array {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally curios why we(AI) keep trying to use static methods? Almost all architecture is built on usage of DI and only s1 ported legacy uses static

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the idea is that the static methods have no dependency on the class itself so there's no need to use DI. I don't think static methods need to leave our codebase entirely, but maybe we need to change the location of them to a Helpers class or something instead?

Comment thread wp-content/plugins/core/src/Facets/Facets_Subscriber.php Outdated
Comment thread wp-content/themes/core/blocks/tribe/filter-bar/js/results.js
GeoffDusome and others added 7 commits August 26, 2026 09:40
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…rite newer ones

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…args

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@GeoffDusome

Copy link
Copy Markdown
Contributor Author

@dpellenwood - I'd like to give BE a chance to actually go through this work and adjust to what they think makes the most sense. Because this was written mostly by AI, it's entirely possible things can be adjusted, reordered, split out into different files, or rewritten differently (and better).

Myk had some good points in his review, but I don't know that all of it needs to be addressed right away. Typically if we had to do something like this on a project a BE developer would have the BE created prior to me touching the FE, so we're working a bit backwards here.

Personally, I would feel more comfortable with this if BE has a chance to actually go hands on with it to make it our own int he way we'd do it. If we could get Myk (or anyone else) some time to work on this that would be great. Because this feature is so large and important, I think it's important that we do our due diligence and do this the right way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants