Open benlk opened 5 years ago
This may be related to #91 and #90.
Next steps:
jquery.dfp.js
attempting to get the height from an array key or object property that doesn't match the key/property that is actually in the thing.[ ] Does window.dfw
have a value at the time the ads are loaded? May need to put that localization into the header instead of the footer. https://secure.helpscout.net/conversation/765188412/3113/?folderId=1219602
[ ] is window.dfw
correctly defined? From [this Helpscout ticket](https://secure.helpscout.net/conversation/765188412/3113/?folderId=1219602:
But after updating the plugin, the site stopped showing ads and there were below errors in the console:
-> GET https://securepubads.g.doubleclick.net/gampad/ads?gdfp_req=1& .... with 400 error. -> Access to XMLHttpRequest at 'https://securepubads.g.doubleclick.net/gampad/ads?gdfp_req=1&pvsid=417413281066130& ........' from origin 'https://example.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
After digging up in the code, I found below DOM code in the footer of the website:
plugin ver 0.3 code:
jQuery('.dfw-unit:not(.dfw-lazy-load)').dfp( window.dfw );
which is different than the earlier version of the plugin which is as below:
plugin ver 0.2.1 code:
jQuery('.dfw-unit:not(.dfw-lazy-load)').dfp({ dfpID: '<?php echo $this->networkCode(); ?>', collapseEmptyDivs: false, setTargeting: <?php echo json_encode($this->targeting()); ?>, sizeMapping: <?php echo json_encode($mappings); ?> });
The older plugin was using these php values instead of the JS var dfw.
So, I commented out the below line in "/plugins/doubleclick-for-wp/inc/class-doubleclick.php" :
jQuery('.dfw-unit:not(.dfw-lazy-load)').dfp( window.dfw );
and added this code:
jQuery('.dfw-unit:not(.dfw-lazy-load)').dfp({ dfpID: '<?php echo $this->network_code(); ?>', collapseEmptyDivs: false, setTargeting: <?php echo json_encode($this->targeting()); ?>, sizeMapping: <?php echo json_encode($mappings); ?> });
which fixed the issue and I can see the ads on my site now and the category targeting also seem to be working.
window.dfw.dfpID
drawing from dfpID
and not something else?Aha.
window.dfw
uses targeting
and mappings
; the added code uses setTargeting
and sizeMapping
.
That might reduce the amount of code needed on https://github.com/INN/doubleclick-for-wp/blob/bf4fcb5423ff359af955948ba253a8e2211185a3/js/jquery.dfw.js#L35-L39
From https://secure.helpscout.net/conversation/739589544/2981/?folderId=1219602
WP 5.0.2
PHP 7.2.2
Plugins:
It's a long list
- Advanced Cron Manager - Advanced Custom Fields PRO - Akismet Anti-Spam - Alexa Certify - All In One SEO Pack - AMP - Beautiful taxonomy filter - Better WordPress Recent Comments - BP Profile Search - BuddyPress - BuddyPress Friends Only Activity Stream - Buddypress Messages Spam Blocker - BuddyPress Xprofile Custom Fields Type - Classic Editor - Cloudflare - Co-Authors - Comments Like Dislike - Cookie Consent - DoubleClick for WordPress - Edit Flow - Email Address Encoder - Enhanced Text Widget - Export Users to CSV - Featured Images in RSS w/ Size and Position - Gravity Forms - Gravity Forms Polls Add-On - Gravity Forms Quiz Add-On - iframe - Jetpack by WordPress.com - Lazy Load for Comments - MemberPress Business Edition - MemberPress - MailChimp - MetaSlider - oEmbed in Comments - PHP Compatibility Checker - Popup Maker - Post-Plugin Library - Public Post Preview - Recent Posts Widget Extended - Redis Object Cache - Regenerate Thumbnails - Register IPs - Revision Control - Simple 301 Redirects - Simple Image Widget - Simple Lightbox - Stop New User + Change Password Emails Select - Stop Spammers - Theme Check - Upcoming Events - Widget Select - VaultPress Widget CSS Classes - Wordfence Security - Wordpress Video Plugin - WP Crontrol - WP Missed Schedule - WP Resized Image Quality - WP ULike - WP-Ban - WP-Cron Status Checker - Yet Another Related Posts Plugin > some of those are plugins I wrote myself, if they look unfamiliarCustom theme
Plugin version 0.3
The contents of the
?googfc
error:Other details: