ActiveDEMAND tracking script to your website. As well this plugin gives you the ability to add custom popups and use shortcodes to embed ActiveDEMAND webforms and dynamic content blocks into your widgets, pages, posts, and sidebars. * Version: 0.1.8 * Author: JumpDEMAND Inc. * Author URI: https://www.activedemand.com/small-business-marketing-software/ * License:GPL-2.0+ * License URI:http://www.gnu.org/licenses/gpl-2.0.txt */ /**================================================= * Admin Menu * ===================================================*/ function activedemand_getHTML($url, $timeout) { $result = ""; if (in_array('curl', get_loaded_extensions())) { $ch = curl_init($url); // initialize curl with given url curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); // set useragent curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // max. seconds to execute curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);//force IP4 $result = curl_exec($ch); if (curl_exec($ch) === false) { echo 'ActiveDEMAND Web Form error: ' . curl_error($ch); } curl_close($ch); } else { $result = file_get_contents($url); } return $result; } function activedemand_menu() { global $activedemand_plugin_hook; $activedemand_plugin_hook = add_options_page('ActiveDEMAND options', 'ActiveDEMAND', 'manage_options', 'activedemand_options', 'activedemand_plugin_options'); add_action('admin_init', 'register_activedemand_settings'); } function register_activedemand_settings() { register_setting('activedemand_options', 'activedemand_options_field'); } function activedemand_enqueue_scripts() { wp_enqueue_script('ActiveDEMAND-Track', 'https://activedemand-static.s3.amazonaws.com/public/javascript/jquery.tracker.compiled.js.gz'); } function activedemand_admin_enqueue_scripts() { global $pagenow; if ('post.php' == $pagenow || 'post-new.php' == $pagenow) { wp_enqueue_script('jquery-ui-dialog'); wp_enqueue_style('wp-jquery-ui-dialog'); } } function activedemand_process_form_shortcode($atts, $content = null) { //[activedemand_form id='123'] $cookieValue = $_COOKIE['activedemand_session_guid']; //$id exists after this call. extract(shortcode_atts(array('id' => ''), $atts)); $options = get_option('activedemand_options_field'); $activedemand_appkey = $options["activedemand_appkey"]; $activedemand_ignore_form_style = $options["activedemand_ignore_form_style"]; $form_str = ""; if (is_numeric($id)) { $form_str = activedemand_getHTML("https://api.activedemand.com/v1/forms/" . $id . "?api-key=" . $activedemand_appkey . "&activedemand_session_guid=" . $cookieValue . "", 10); //The following example will delete the table element of an HTML content. if ($activedemand_ignore_form_style) { //strip out the style tag $dom = new DOMDocument(); //avoid the whitespace after removing the node $dom->preserveWhiteSpace = false; //parse html dom elements $dom->loadHTML($form_str); //get the Style from dom if ($style = $dom->getElementsByTagName('style')->item(0)) { //remove the node by telling the parent node to remove the child $style->parentNode->removeChild($style); //remove the class reference from the form element $form = $dom->getElementsByTagName('form')->item(0); $form->setAttribute('class', ''); //save the new document $form_str = $dom->saveHTML(); } } } if ($form_str != "") { //replace \n to ensure WP auto format does not mess with our CSS $form_str = str_replace("\n", "", $form_str); } return $form_str; } function activedemand_process_block_shortcode($atts, $content = null) { //[activedemand_block id='123'] //first get our cookie $cookieValue = $_COOKIE['activedemand_session_guid']; //$id exists after this call. extract(shortcode_atts(array('id' => ''), $atts)); $options = get_option('activedemand_options_field'); $activedemand_appkey = $options["activedemand_appkey"]; $block_str = ""; if (is_numeric($id)) { $block_str = activedemand_getHTML("https://api.activedemand.com/v1/smart_blocks/" . $id . "?api-key=" . $activedemand_appkey . "&activedemand_session_guid=" . $cookieValue . "", 10); //The following example will delete the table element of an HTML content. } if ($block_str != "") { //replace \n to ensure WP auto format does not mess with our CSS $block_str = str_replace("\n", "", $block_str); } return $block_str; } function activedemand_plugin_action_links($links, $file) { static $this_plugin; if (!$this_plugin) { $this_plugin = plugin_basename(__FILE__); } if ($file == $this_plugin) { $settings_link = 'Settings'; array_unshift($links, $settings_link); } return $links; } function activedemand_plugin_options() { $options = get_option('activedemand_options_field'); $activedemand_appkey = $options["activedemand_appkey"]; if (!array_key_exists('activedemand_ignore_form_style', $options)) { $options['activedemand_ignore_form_style'] = 0; } if (!array_key_exists('activedemand_defer_script', $options)) { $options['activedemand_defer_script'] = 0; } ?>
You will need to enter your application key in order to enable the form shortcodes. Your can find your ActiveDEMAND API key in your account settings:
The ActiveDEMAND plugin adds a tracking script to your WordPress pages. This plugin offers the ability to use web form and content block shortcodes on your pages, posts, and sidebars that will render an ActiveDEMAND Web Form/Dynamic Content block. This allows you to maintain your dynamic content, form styling, and configuration within ActiveDEMAND.
In your visual editor, look for the 'Insert ActiveDEMAND Shortcode' button:
.
Available Web Form Shortcodes
No Web Forms ConfiguredTo use the ActiveDEMAND web form shortcodes, you will first have to add some Web Forms to your account in ActiveDEMAND. Once you do have Web Forms configured, the available shortcodes will be displayed here. |
Available Dynamic Content "Smart" Block Shortcodes
No Dynamic Content Blocks ConfiguredTo use the ActiveDEMAND Dynamic Content Block shortcodes, you will first have to add some Dynamic Content Blocks to your account in ActiveDEMAND. Once you do have Dynamic Blocks configured, the available shortcodes will be displayed here. |
Check out the documentation and support forums for help with this plugin.
"; $text .= "Documentation