You need the unfiltered_html
capability to write JavaScript in post content. This is granted by default to administrators and editors.
The better way would be to write a small plugin that provides you a shortcode:
<?php
/**
* Plugin Name: WPSE 234978 – Provide shortcode for Sharpspring embed
* Plugin URL: http://wordpress.stackexchange.com/q/234978/31323
* License: MIT
* Version: 1.0.0
* Author: David Naber
*/
namespace WPSE234978;
add_action(
'wp_loaded',
function () {
/**
* Register the shortcode '[sharpspring_embed]'
*/
add_shortcode( 'sharpsrpring_embed', __NAMESPACE__ . '\sharpspring_embed_shortcode' );
}
);
/**
* Translates the shortcode to the sharpspring embed code
*
* @return string
*/
function sharpspring_embed_shortcode() {
$embed = <<<HTML
<script type="text/javascript">
var ss_form = {'account': '**********', 'formID':'****************'};
ss_form.width="100%";
ss_form.height="1000";
ss_form.domain = '***********';
// ss_form.hidden = {'Company': 'Anon'}; // Modify this for sending hidden variables, or overriding values
</script>
<script type="text/javascript" src="https://********.marketingautomation.services/client/form.js?ver=1.1.1"></script>
HTML;
return $embed;
}
Create a new directory inside wp-content/plugins
and name it to something like $YOURSITE-sharpspring-embed
. Create a PHP file inside (name it like $YOURSITE-sharpspring-embed
) that directory and paste the code above into that file. Remember to replace your credentials and app IDs.
Then activate the plugin and use the shortcode [sharpspring_embed]
in your post content.
Note: that plugin requires at least PHP version 5.3 (today 5.6 is the current stable version).