- This topic has 14 replies, 2 voices, and was last updated 4 years, 7 months ago by
David.
-
AuthorPosts
-
February 1, 2021 at 4:00 am #1641388
Dimitrios
Hello there.
I recently installed Quantcast to my site for user consent.
I want to have a persistent link in the footer because it is required by law but for some reason, the code won’t work.
HERE IS THE CUSTOM CODE: https://help.quantcast.com/hc/en-us/articles/360047084654-Allowing-Users-to-Change-Consents-Privacy-Settings-Button-TCF-v2-
Here is what I put on the footer: <a class=”change-consent”
onclick=”window.__tcfapi(‘displayConsentUi’, 2, function() {} );”>change consent
When I hit save and test it, it doesn’t work. I am using this in another site without the GeneratePress theme and it works.What I noticed is that after I have saved that, if I go again in the footer to see the code it is just
< style=”cursor:pointer” class=”change-consent”>Update Privacy Settings > (I skipped the a tag because it makes it a link)I don’t know why but after saving it skips some code.
Any ideas on how to fix it? It is supposed to pop up a window when UPDATE PRIVACY SETTINGS is clicked so that the user can change their settings.
-Thanks
February 1, 2021 at 4:44 am #1641449David
StaffCustomer SupportHi there,
can you to try adding the code to a Footer Bar Widget not the Copyright information field.
February 1, 2021 at 4:50 am #1641455Dimitrios
Yes, it works as a Footer Bar Widget… Why isn’t it working in the main footer? Can we please find a way so that it works in the main footer?
You can check it on my website. I have put both persistent links but only the one in the footer bar is working.
February 1, 2021 at 5:23 am #1641490Dimitrios
Isn’t that kind of code allowed there? And how can we fix this?
February 1, 2021 at 6:02 am #1641515David
StaffCustomer SupportThe copyright field provides support for standard HTML. WP by default sanitizes HTML and strips any code it sees as a potential security risk. HTML Widgets have greater flexibility and allow admin users to include unfilteredHTMLl.
If you must add it to the Copyright info, then first you will need to create a Shortcode to output your link:
https://docs.generatepress.com/article/creating-a-shortcode/
Then add the shortcode to the copyright field.
February 1, 2021 at 6:40 am #1641555Dimitrios
Thanks a lot!!! I appreciate it!
February 1, 2021 at 6:54 am #1641664David
StaffCustomer SupportYou’re welcome
February 1, 2021 at 7:30 am #1641722Dimitrios
Could you tell me how to implement the code inside the shortcode though?
add_shortcode( ‘my_shortcode’, function() {
ob_start();
// Start your PHP belowecho ‘short code example’;
// End your PHP above
return ob_get_clean();
} );I WANT TO ADD THIS CODE INSIDE BUT IT SHOWS ERROR:
<a style=”cursor:pointer” class=”change-consent”
onclick=”window.__tcfapi(‘displayConsentUi’, 2, function() {} );”>Update Privacy SettingsFebruary 1, 2021 at 7:57 am #1641746David
StaffCustomer SupportFirst off change the
my_shortcode
label here:add_shortcode( 'my_shortcode', function() {
to whatever you require eg.
consent_link
The echo statement is then what controls your output – i copied the HTML from your site to make sure it matches the working link:
echo '<a style="cursor:pointer" class="change-consent" onclick="window.__tcfapi(\'displayConsentUi\', 2, function() {} );">Update Privacy Settings</a>';
February 1, 2021 at 8:01 am #1641755Dimitrios
it shows the following errors https://ibb.co/D92qpdy
Any ideas?
February 1, 2021 at 8:03 am #1641757David
StaffCustomer SupportEditing the above code
February 1, 2021 at 8:10 am #1641764Dimitrios
I did use the shortcode…. but it still doesn’t work… Maybe take a look?
The code is okay without errors
add_shortcode( ‘consent_link’, function() {
ob_start();
// Start your PHP belowecho ‘Update Privacy Settings‘;
// End your PHP above
return ob_get_clean();
} );February 1, 2021 at 10:35 am #1641938David
StaffCustomer SupportGrrr stoopid quotes lol
Try the updated (again) code aboveFebruary 1, 2021 at 11:05 am #1641974Dimitrios
Haha! It works now!
Thanks!
February 1, 2021 at 12:35 pm #1642041David
StaffCustomer SupportAwesome 🙂 Glad to be of help.
-
AuthorPosts
- You must be logged in to reply to this topic.