Hi abooster –
Thanks for the post.
I’m not able to reproduce your issue. As a regular user (Subscriber level), neither private pages nor drafts appear in the Link autocomplete dialog. In fact, in my tests, private pages don’t even appear for the site administrator. The AJAX callback that powers the dialog specifically excludes non-public items: https://core.trac.ww.wp.xz.cn/browser/tags/4.5.2/src/wp-includes/class-wp-editor.php?marks=1325#L1307
My guess is that you are using a third-party plugin to make certain pages “private/secret … after a successful payment has been verified”. If this is the case, then that plugin ought to be responsible for ensuring that the pages cannot be accessed in other parts of the interface. The ‘wp_link_query_args’ filter can be used to add exclusions. (BuddyPress Docs itself has global protection that prevents off-limits Docs from appearing in *any* listing, including the link dialog.)
Removing the internal link dialog doesn’t seem like a good solution, as it’s a useful piece of functionality that plays an important role in many people’s workflow. You are, of course, welcome to remove it on your own site. (Use if ( bp_docs_is_doc_edit() ) { ... } to limit the disabling to the Docs editing interface.
It’s worth noting that this behavior has nothing to do with BuddyPress. The link dialog is default WordPress functionality, and BuddyPress Docs uses WP’s editor. Blame either WordPress or Docs, if you must, but BuddyPress is innocent 🙂
Well, it seems you misunderstood something here…
I never said that those pages are set to private.
They are and must be set to *public* because even ordinary website visitors must be able to see the content on those pages BUT ONLY WHEN I SHOW IT TO THEM.
So, those pages need to stay hidden the same way they are hidden from search engines (i.e. search engines are prohibited from indexing/crawling those pages) but in terms of the internal WP settings those pages need to stay “public”.
Do you understand now what I mean?
The internal WordPress setting for those pages cannot be set to private.
In settings the pages must remain “public”.
But just because I set a particular page’s settings to “public” doesn’t mean I want any random user to browse those “public” but HIDDEN pages.
There are many different scenarios where such situation can occur and I have at least 2-3 such scenarios in my case here.
Just because a page exists and it’s internally set to “public” doesn’t mean I would want users to randomly browse those pages. They MUST remain hidden and the users must not be able to access those pages through the link insert dialog. But that’s exactly what happens when a subscriber level user tries to insert a link.
And yes, as I said in the previous post, I understand that this behavior of the insert link dialog is NOT your plugin’s fault.
And while I perfectly understand that this behavior is a core WordPress functionality it is indeed a fault of the BuddyPress developers because it is gross negligence on their part that they haven’t blocked BuddyPress from using that functionality!
That functionality is very helpful in WordPress. But BuddyPress and bbPress MUST be prevented/excluded from using that functionality!
Removing the internal link dialog for non-admin BuddyPress and bbPress users is *absolutely necessary* for security and privacy reasons!
Absolutely necessary!
Because doing otherwise borders on gross negligence in regards to security and privacy.
So, I’m still hoping that you implement at least an option to remove that perilous “insert link” dialog. Because it could take many months or years until the coders of the BuddyPress core realize that they are committing gross negligence here by knowingly leaving this security/privacy hole wide open.
(if I could code, I would have done it a long time ago)
You can change what is shown in WordPress’s link dialog using something like this (which excludes BP Docs from being included in the list):
add_filter( 'wp_link_query_args', 'my_filter_wp_link_query_args' );
function my_filter_wp_link_query_args( $query ) {
$query['post_type'] = array_diff( $query['post_type'], array('bp_doc') );
return $query;
}
Great! And where do I put this in?
Your theme’s functions.php file would be fine.
Hmm… I just tried that but it has no effect whatsoever.
The page suggestions still appear in the “insert link” dialog as if nothing happened.
Suggestions?
That exact snippet works as expected for me. Make sure you’ve added it as provided in the functions.php (before any closing php tags–they look like ?>) of your active theme.