mikedoubintchik / wordpress-post-modal

This WordPress plugin allows you to open any page in a modal window. This is a starter plugin that you would customize for your project.
GNU General Public License v2.0
43 stars 23 forks source link

Modal does not find subpages #15

Open plazareff opened 4 years ago

plazareff commented 4 years ago

When the "modal-link" link is of type '/parent-page/subpage", the plugin does not find the page (404) as it calls the get_page_by_pathWP function but only passes the permalink (subpage) where it should pass the whole path (parentpage/subpage)

plazareff commented 4 years ago

As a temporary workaround, I modified the file wp-post-modal-public.js:

line 229, replaced basename(postLink) by $this[0].pathname

mikedoubintchik commented 4 years ago

What do you think the best way to determine if something is a subpage? Another attribute on the a tag?

There's no way to do it automatically that I can think of.

plazareff commented 4 years ago

I'm not especially at ease with Wordpress development, so I can't tell if there's another WP function that would be more useful than get_page_by_path.

On the JS side, I think I would analyze the href attribute to see if it's a full or relative url, compare the domain name with the current page and act accordingly. My basic opinion being that basename() should be avoided.

I'll look deeper into it when I get some time, closer to the release of the site I'm currently on as I don't like the idea to leave the client with a "hacked" plugin for upgrade's sake anyway...

Thank You for your message ;-)