ActiveDEMAND tracking script to your website. As well this plugin gives you the ability to use shortcodes to embed ActiveDEMAND webforms into your widgets, pages, posts, and sidebars. * Version: 0.0.8 * Author: JumpDEMAND Inc. * Author URI: https://www.ActiveDEMAND.com * License:GPL-2.0+ * License URI:http://www.gnu.org/licenses/gpl-2.0.txt */ /**================================================= * Admin Menu * ===================================================*/ include 'partials/helper-functions.php'; 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'] //$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 . "", 4000); //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); //save the new document $form_str = $dom->saveHTML(); } } } return $form_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"]; ?>

Settings

Your ActiveDEMAND Account


You will require an ActiveDEMAND account to use this plugin. With an ActiveDEMAND account you will be able to:

To sign up for your ActiveDEMAND account, click here

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:

ActiveDEMAND Options

ActiveDEMAND API Key
Style Forms in WordPress />

Using ActiveDEMAND Web Forms

The ActiveDEMAND plugin adds a tracking script to your WordPress pages. As well this plugin offers the ability to use form shortcodes on your pages, posts, and sidebars that will render an ActiveDEMAND Web Form. This allows you to maintain your form styling and configuration within ActiveDEMAND and keep your WordPress site in sync with your ActiveDEMAND account.

Available Web Form Short Codes

children() as $child) { echo ""; echo ""; } ?>
Form Name Shortcode
"; echo $child->name; echo "[activedemand_form id='"; echo $child->id; echo "']

In your visual editor, look for the 'Insert ActiveDEMAND Shortcut' button:
.

No Web Forms Configured

To use the ActiveDEMAND web form shortcodes, you will first have to add some webforms to your account in ActiveDEMAND. Once you do have webforms configured, the available shortcodes will be displayed here.

Need help with the ActiveDEMAND plugin?"; $text .= "

Check out the documentation and support forums for help with this plugin.

"; $text .= "Documentation
Support forums
ActiveDEMAND Support portal"; } return $text; } function get_base_url() { return plugins_url(null, __FILE__); } function activedemand_register_tinymce_javascript($plugin_array) { $plugin_array['activedemand'] = plugins_url('/js/tinymce-plugin.js', __FILE__); return $plugin_array; } function activedemand_buttons() { add_filter("mce_external_plugins", "activedemand_add_buttons"); add_filter('mce_buttons', 'activedemand_register_buttons'); } function activedemand_add_buttons($plugin_array) { $plugin_array['activedemand'] = get_base_url() . '/includes/activedemand-plugin.js'; return $plugin_array; } function activedemand_register_buttons($buttons) { array_push($buttons, 'insert_form_shortcode'); return $buttons; } function add_editor() { global $pagenow; // Add html for shortcodes popup if ('post.php' == $pagenow || 'post-new.php' == $pagenow) { include 'partials/tinymce-editor.php'; } } //defer our script loading add_filter('clean_url', function ($url) { if (FALSE === strpos($url, 'jquery.tracker.compiled.js.gz')) { // not our file return $url; } // Must be a ', not "! return "$url' defer='defer"; }, 11, 1); add_filter('contextual_help', 'activedemand_plugin_help', 10, 3); add_action('wp_enqueue_scripts', 'activedemand_enqueue_scripts'); add_action('admin_enqueue_scripts', 'activedemand_admin_enqueue_scripts'); add_shortcode('activedemand_form', 'activedemand_process_form_shortcode'); add_action('admin_menu', 'activedemand_menu'); add_filter('plugin_action_links', 'activedemand_plugin_action_links', 10, 2); //widgets // add new buttons add_action('init', 'activedemand_buttons'); add_action('in_admin_footer', 'add_editor'); ?>