-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ads.txt file detection does not take mapped domains into account #48
Comments
Looking at this a little bit, I think the technical approach might be something like:
I also wonder if it might be worth making that notice dismissible in case there are other false positive scenarios we haven't thought of yet, we'd still want to fix for those false positives but in the meantime at least people wouldn't keep getting this annoying and inaccurate message. |
@helen, agree. I use this method in my plugins to get the correct ajax url when running on a multisite and having a mapped domain: Bet it work in this case also. |
To reintroduce this filter and account for sites with the dashboard on a different domain to the website, the check will need to happen on the back end. Testing client side causes CORS errors, preventing the JavaScript approach from determining the HTTP response code of I think a server side check will be more robust as the plugin can rely on 301 redirects for sites using domain mapping without having to do function checks to determine if or which plugin is providing the feature. |
I did some experiments with my earlier comment a while back but never committed anything as it was a little complicated. For sites using a domain mapping plugin such as WordPress MU Domain Mapping and wasn't able to come up with a robust solution. Depending on the settings, the As Multisite installs have supported domain mapping for some time, since WordPress 4.5, it's probably pretty safe to only support installs using the native features. To avoid the CORS errors, we'd need to do something like: add_action( 'wp_ajax_adstxts_check_for_existing_file', function() {
$home_url_parsed = wp_parse_url( home_url() );
if ( empty( $home_url_parsed['path'] ) ) {
$check = wp_remote_request( home_url( '/ads.txt' ) )
// Something to determine if it's a file, the WP managed file, etc
// send result
exit;
}
// Something to notify user that it can't be used on sites with the home in a sub_directory.
} ); |
I've merged in #131 to reintroduce a check for a real file for domain mapped sites.
|
Describe the bug
If you use a mapped domain (i.e. your wp-admin is on a different domain from your site, like on WordPress.com), the ads.txt file detection looks for the file on the wp-admin domain, which can return a false positive. See https://wordpress.org/support/topic/existing-ads-txt-file-found/
Steps to Reproduce
I haven't actually done this yet, but my guess is:
Expected behavior
I would not expect to see the notice.
Screenshots
n/a
Environment information
This is as of Ads.txt 1.2.0, seen on WordPress.com with a business plan where you can install plugins and map domains.
Additional context
Reported here: https://wordpress.org/support/topic/existing-ads-txt-file-found/
The text was updated successfully, but these errors were encountered: