$timeout ); $result = wp_remote_get($url . "?" . $fields_string,$args2); if( is_wp_error( $result ) ) { return ""; }elseif( is_array( $result) ) { $result = $result['body']; if (strlen($result)==1) { $result=""; } return $result; } return ""; } function activedemand_postHTML($url, $args, $timeout) { $fields_string = activedemand_field_string($args); $args2= array( 'timeout' => $timeout, ); $result = wp_remote_post($url,$args2); return $result; } /** * Adds ActiveDEMAND popups if API Key isset and activedemand_server_showpopups is true * * @param string $content * @return string $content with popup prefix */ function activedemand_field_string($args) { $options = get_option(PREFIX.'_options_field'); $fields_string = ""; if (is_array($options) && array_key_exists(PREFIX.'_appkey', $options)) { $activedemand_appkey = $options[PREFIX."_appkey"]; } else { $activedemand_appkey = ""; } if ("" != $activedemand_appkey) { $cookievalue = activedemand_get_cookie_value(); $url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; if (isset($_SERVER['HTTP_REFERER'])) { $referrer = $_SERVER['HTTP_REFERER']; } else { $referrer = ""; } if ($cookievalue != "") { $fields = array( 'api-key' => $activedemand_appkey, PREFIX.'_session_guid' => activedemand_get_cookie_value(), 'url' => $url, 'ip_address' => activedemand_get_ip_address(), 'referer' => $referrer ); } else { $fields = array( 'api-key' => $activedemand_appkey, 'url' => $url, 'ip_address' => activedemand_get_ip_address(), 'referer' => $referrer ); } if (is_array($args)) { $fields = array_merge($fields, $args); } $fields_string = http_build_query($fields); } return $fields_string; } add_action('init', __NAMESPACE__.'\activedemand_get_cookie_value'); function activedemand_get_cookie_value() { if (is_admin()) return ""; static $cookieValue = ""; if(!empty($cookieValue)) return $cookieValue; //not editing an options page etc. if (!empty($_COOKIE['activedemand_session_guid'])) { $cookieValue = $_COOKIE['activedemand_session_guid']; } else { $urlParms = $_SERVER['HTTP_HOST']; if (NULL != $urlParms) { $cookieValue = activedemand_get_GUID(); $basedomain = activedemand_get_basedomain(); setcookie('activedemand_session_guid', $cookieValue, time() + (60 * 60 * 24 * 365 * 10), "/", $basedomain); } } return $cookieValue; } function activedemand_get_basedomain() { $result = ""; $urlParms = $_SERVER['HTTP_HOST']; if (NULL != $urlParms) { $result = str_replace('www.', "", $urlParms); } return $result; } // create a session if one doesn't exist function activedemand_get_GUID() { if (function_exists('com_create_guid')) { return com_create_guid(); } else { mt_srand((double)microtime() * 10000);//optional for php 4.2.0 and up. $charid = strtoupper(md5(uniqid(rand(), true))); $hyphen = chr(45);// "-" $uuid = substr($charid, 0, 8) . $hyphen . substr($charid, 8, 4) . $hyphen . substr($charid, 12, 4) . $hyphen . substr($charid, 16, 4) . $hyphen . substr($charid, 20, 12); return $uuid; } } // get the ip address function activedemand_get_ip_address() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } return $ip; } //--------------- Admin Menu ------------------------------------------------------------------------- function activedemand_menu() { global $activedemand_plugin_hook; $activedemand_plugin_hook = add_options_page(PLUGIN_VENDOR.' options', PLUGIN_VENDOR, 'manage_options', PREFIX.'_options', __NAMESPACE__.'\activedemand_plugin_options'); add_action('admin_init', __NAMESPACE__.'\register_activedemand_settings'); } function register_activedemand_settings() { register_setting(PREFIX.'_options', PREFIX.'_options_field'); register_setting(PREFIX.'_options', PREFIX.'_server_showpopups'); register_setting(PREFIX.'_options', PREFIX.'_show_tinymce'); } 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_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() { $woo_commerce_installed = false; $options = is_array(get_option(PREFIX.'_options_field'))? get_option(PREFIX.'_options_field') : array(); $form_xml = ""; if (!array_key_exists(PREFIX.'_appkey', $options)) { $options[PREFIX.'_appkey'] = ""; } $activedemand_appkey = $options[PREFIX.'_appkey']; if (!array_key_exists(PREFIX.'_ignore_form_style', $options)) { $options[PREFIX.'_ignore_form_style'] = 0; } if (!array_key_exists(PREFIX.'_ignore_block_style', $options)) { $options[PREFIX.'_ignore_block_style'] = 0; } if (array_key_exists(PREFIX.'_woo_commerce_order_form_id', $options)) { $activedemand_woo_commerce_order_form_id = $options[PREFIX."_woo_commerce_order_form_id"]; } else { $activedemand_woo_commerce_order_form_id = 0; } if (class_exists('woocommerce')) { $woo_commerce_installed = true; } if (array_key_exists(PREFIX.'_woo_commerce_use_status', $options)) { $activedemand_woo_commerce_use_status = $options[PREFIX."_woo_commerce_use_status"]; if (!array_key_exists("pending", $activedemand_woo_commerce_use_status)) { $activedemand_woo_commerce_use_status["pending"] = FALSE; } if (!array_key_exists("processing", $activedemand_woo_commerce_use_status)) { $activedemand_woo_commerce_use_status["processing"] = FALSE; } if (!array_key_exists("on-hold", $activedemand_woo_commerce_use_status)) { $activedemand_woo_commerce_use_status["on-hold"] = FALSE; } if (!array_key_exists("completed", $activedemand_woo_commerce_use_status)) { $activedemand_woo_commerce_use_status["completed"] = FALSE; } if (!array_key_exists("refunded", $activedemand_woo_commerce_use_status)) { $activedemand_woo_commerce_use_status["refunded"] = FALSE; } if (!array_key_exists("cancelled", $activedemand_woo_commerce_use_status)) { $activedemand_woo_commerce_use_status["cancelled"] = FALSE; } if (!array_key_exists("failed", $activedemand_woo_commerce_use_status)) { $activedemand_woo_commerce_use_status["failed"] = FALSE; } } else { $activedemand_woo_commerce_use_status = array( "pending" => FALSE, "processing" => FALSE, "on-hold" => FALSE, "completed" => TRUE, "refunded" => FALSE, "cancelled" => FALSE, "failed" => FALSE ); $options[PREFIX."_woo_commerce_use_status"] = $activedemand_woo_commerce_use_status; } update_option(PREFIX.'_options_field', $options); ?>
You will need to enter your application key in order to enable the form shortcodes. Your can find your API key in your account settings:
The 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 Web Form/Dynamic Content block. This allows you to maintain your dynamic content, form styling, and configuration within .
In your visual editor, look for the 'Insert Shortcode' button:
.
Available Web Form Shortcodes
No Web Forms ConfiguredTo use the web form shortcodes, you will first have to add some Web Forms to your account in . Once you do have Web Forms configured, the available shortcodes will be displayed here. |
Available Dynamic Content Block Shortcodes
No Dynamic Blocks ConfiguredTo use the Dynamic Content Block shortcodes, you will first have to add some Dynamic Content Blocks to your account in . Once you do have Dynamic Blocks configured, the available shortcodes will be displayed here. |