Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

jonradio on "Checking URL is part of current WordPress site"

$
0
0

How do I determine (from within my plugin) whether a URL entered in a Settings field is part of the current WordPress site? i.e. - it points to a valid "page" (post/page/category page/image attachment page/Admin panel, etc.)

On one of my plugins' Setting pages, I allow Admins to copy and paste a URL from their Internet browser into a Settings field, because it is the simplest way for them to specify a page, post, category page, or any other WordPress-displayed "element" that they want my plugin to control.

get_page_by_path() and url_to_postid() are too "narrow" as they only cover Posts and Pages. Because most people use Permalinks, WP_Rewrite looks interesting, but I haven't figured out how to feed it my URL and get a response telling me if it exists (not 404 page) and whether it is a WordPress-displayed "page" (not someone else's .html or .jpg file).


Viewing all articles
Browse latest Browse all 8245

Trending Articles