x3p0-dev / x3p0-breadcrumbs

Breadcrumbs block for WordPress.
GNU General Public License v3.0
36 stars 2 forks source link

What is the breadcrumb Posts which links to /WP_Router/ #8

Open MaxdAyala opened 2 months ago

MaxdAyala commented 2 months ago

Hello Justin,

I've been trying out this plugin and it seems to mostly work fine with the WP 2024 theme and a few plugins.

One oddity I have is with a plugin that generates pages with classic views I guess. It produces a breadcrumb like this:

Home > Posts > Submit an Event

The link for the Posts breadcrumb goes to /WP_Router/

If I follow this link it goes to a page titled Archives: Posts. Below the title is a heading "WP Router Placeholder Page" that is a link to /WP_Router/wp-router-placeholder-page/. If I click this link I am taken to the home page.

Have you seen this before, and why does it happen? Is there anything I can do to get a better breadcrumb link in this case?

I'm using version 1.0.1 of the plugin. WP 2024 (child) theme, WP 6.5.5.

Thanks

justintadlock commented 2 months ago

What's the plugin? I'm happy to test it.

MaxdAyala commented 1 month ago

So, I retested with a fresh install as follows:

WP 6.6.1

Install and activate these plugins: The Events Calendar v 6.6.0.2 The Events Calendar Community Events v 5.0.0.1 X3P0 v 1.0.1

Set the permalink structure to be "Post name".

Edit the header template and add a new row containing the X3P0 Breadcrumb block.

Edit the fallback header template to show the breadcrumbs. file: wp-includes/theme-compat/header.php

</head>
<body <?php body_class(); ?>>
<div id="page">

<div id="header" role="banner">
    <div id="headerimg">
        <h1><a href="<?php echo home_url(); ?>/"><?php bloginfo( 'name' ); ?></a></h1>
        <div class="description"><?php bloginfo( 'description' ); ?></div>
    </div>
        <header class="wp-block-template-part">
<?php
            block_header_area();
?>
        </header>
</div>
<hr />

Navigate to the add event page (or select it from the Event admin menu): /events/community/add/

Then look at the breadcrumb link which has "Posts" linking to /WP_Router/

Note that the Community Events plugin is a paid plugin, so you won't be able to install it directly. If you don't have access to it I can check the licence to see if I can send it to you for testing purposes.

Thanks.

justintadlock commented 1 month ago

From the terms: https://theeventscalendar.com/terms/

All plug-ins and add-ons provided as part of the Services, unless otherwise stated, are licensed under the GNU General Public License (http://www.gnu.org/licenses/gpl.html) version 2.0 or later.

The plugin is under the GPL (as all WordPress plugins, free or paid, should be), so you can freely share it. Feel free to directly upload a ZIP of it here in the ticket.

MaxdAyala commented 1 month ago

Okay, zip file attached. the-events-calendar-community-events.zip

justintadlock commented 1 month ago

Basically, what seems to be happening is that the community plugin is telling WordPress that it's a single post when visiting this custom "add event" page. That's why the "Posts" parent breadcrumb is appearing.

I haven't figured out how it's generating the incorrect WP_Router URL yet, but I suspect it's related to the plugin using the WP-Router repository, which is made by a third party and hasn't been updated in over five years (the community plugin relies heavily on this).

The Breadcrumbs block relies on the standard WordPress query vars, which tells it things like whether this is a single post, etc. And when a plugin does something very non-standard, it has no way to deal with that out of the box. Mind you, this is in large part because WordPress doesn't have a proper routing system in place and plugins end up doing their own thing.

I'm not 100% sure what the best option is yet.

Ideally, the community plugin would simply extend the breadcrumbs with its own custom thing, but this would be best done whenever I build the Environment class I have planned: https://github.com/x3p0-dev/x3p0-breadcrumbs/issues/3

The other option would be for Breadcrumbs to add a custom conditional check specifically for the community plugin. But I'm not too keen on this idea because it is a slippery slope to start adding specific checks for specific plugins and puts the burden on me to keep up with code that is not my own (not just for this one plugin but for others in the future).

MaxdAyala commented 1 month ago

It doesn't look like there is any easy solution.

The parent plugin, The Events Calendar, seems to work ok, so maybe they will get round to rewriting the Community Events plugin at some point and it might start working.

It looks like they might use a fork of WP_Router with a few minor updates.

The breadcrumbs not working is not too important for me because it is more of an adminy type page that doesn't have many users. If I switch it off on these pages it's not going to matter too much, it's more of a nice to have feature to be consistent with other pages, but users will be okay if I disable the breadcrumbs for these pages.

Thanks for looking into it.