Skip Navigation

[Resolved] Adding tag in Custom Content Template/View

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by Waqar 3 years, 8 months ago.

Assisted by: Waqar.

Author
Posts
#2021293

Hello,

I am trying to:

Add the following into a view I have created. A content template that is for a property listing component
<h3>Schedule a Tour</h3>
<script type="text/javascript" src="hidden link"></script>

The contact form system we use has a few other options, but the script tag is the ideal one to use. However, it seems Types does not allow scripts in our views?

As a sample, I have a view created. And it saves perfectly. Then the second I copy/paste the above into my view and hit save, it says, "Content template not saved" which leads me to believe scripts are not allowed.

Is there a workaround for this? I saw reference to work arounds on the forums for people who were putting <script> tags into their custom content from the content entry page (example from the WordPress post body field) but that's not exactly what I'm doing, so I'm wondering if there is an option somewhere I just have to enable to allow this. I would imagine people add custom JavaScript to their views all the time but maybe not?

Anyway I was just hoping for some clarification! I have recreated this entire view thinking there was something wrong with my browser/cache cookies and then finally realized what is happening!

EDIT: I should also add, I am the administrator on the site and have enabled saving Unfiltered HTML from the plugin options. Also, I am using Views with the Classic Editor as well.

Link to a page where the issue can be seen:
n/a

I expected to see:
A form embedded from our form provider

Instead, I got:
"Content template not saved" error

#2021681

Hi,

Thank you for contacting us and I'd be happy to assist.

I've performed some tests on my website with the exact same code that you've shared, but I couldn't reproduce this issue. The code not only saved without any error but also loaded as expected on the front-end.

Do you see any other error or warning, in the browser's console or in the server's error log, if you enable WordPress debugging?
( ref: https://codex.wordpress.org/Debugging_in_WordPress )

Based on the previous reports about a similar error, some third-party plugin or security configuration on the website's server could be falsely treating that script code as unsafe and blocking it.

Please test this with all non-toolset plugins disabled and if the issue persists, consult your hosting's support team, to ask about any recent changes to their security policies and configurations.

I hope this helps and please let me know how it goes.

regards,
Waqar

#2022091

Hi Waqar,

I've tried some further debugging but have been unsuccessful. Perhaps you can guide me as to what else to check. I used the Health Check and troubleshooting plugin to remove all plugins except Types and Views and even changed my theme to the default 2021. I still get the error when trying to save my View.

In the chrome developer console, I see the only error being a 403 forbidden error on hidden link while loading the view editor. I don't know if that means anything?

We manage our hosting in-house and they did not make any other security changes to the server, however, while we have used Types and Views in the past, I don't know if I've ever tried to enable a contact form on the site from within a view. I will also contact them and see if they have any other ideas in the meantime.

Thank you and please let me know if you have any other suggestions.

#2025785

Thanks for writing back.

The "admin-ajax.php" file is the standard gateway that WordPress, themes, and plugins use to securely process the AJAX requests. The 403 forbidden error confirms that something on the server is blocking it.

As it is a very generic error, it can be caused by a number of factors. You'll find some useful troubleshooting tips from these links:
hidden link
hidden link
hidden link

It would also be interesting to test the clone of the website on a different server, to confirm if this is specific to a particular host or setup.

#2026575

Through a lot of back and forth with our web host, I finally figured out the issue, And it was a DUMB one.

We are working on the new site in a test folder. And the live site is another WordPress installation. The live site had Wordfence firewall installed on it. And the Wordfence firewall was protecting the site in the subfolder and stopping us from sending Javascript in the backend (I guess it thought it was XSS attack of some kind).

Thank you for all your help. Once I deactivated Wordfence I was able to submit the javascript. So I was able to reenabled Wordfence and whitelist my IP in the global options to be allowed to save properly.

#2026585

Weird, I typed up my response, then the page refreshed. But my response did not post.

Trying again! This issue has been resolved, after much back and forth with our host, and it was due to the Wordfence installation on the main site. We are working within a subfolder and the main site Wordfence was being active inside the subfolder, stopping the Javascript being added into the template. (I suppose it was thinking it was an XSS attack). Once I deactivated Wordfence on the main site, I was able to submit the form.

So the solution was to whitelist my IP in Wordfence on the main site.

#2027185

Thanks for the update and glad that this is sorted out now.

The fix you shared, will surely help other users, facing a similar challenge.

You're welcome to mark this ticket as resolved and start a new one, for each new question or concern.