Widgets to activate this plugin. Author: ActiveCampaign Version: 2.1 Author URI: http://www.activecampaign.com/ */ # Changelog ## version 1: - initial release ## version 1.1: Verified this works with latest versions of WordPress and ActiveCampaign; Updated installation instructions ## version 2.0: Re-configured to work with ActiveCampaign version 5.4. Also improved some areas. ## version 2.1: Changed internal API requests to use only API URL and Key instead of Username and Password. Also provided option to remove style blocks, and converting block preg_match_all("||iUs", $form_html, $matches); if ( isset($matches[0]) and count($matches[0]) > 0 ) { $form_html = str_replace($matches[0], "", $form_html); } } // replace /i", "", $form_html); echo $form_html; } } else { // If it's set to fetch the form each time (using the API) if ($options_site["api_url"] && $options_site["api_key"] && $options_form["form_id"]) { $api_url = $options_site["api_url"] . "admin/api.php?api_key=" . $options_site["api_key"] . "&api_action=form_view&api_output=serialize&id=" . $options_form["form_id"]; $api_result = ac_subscribe_curl_get($api_url); // for some reason the very first character of the string is "s" instead of "<". Example: sstyle> $api_result = preg_replace("/^s?/i", "<", $api_result); if ( (int)$options_form["remove_css"] ) { // remove |iUs", $api_result, $matches); if ( isset($matches[0]) and count($matches[0]) > 0 ) { $api_result = str_replace($matches[0], "", $api_result); } } // replace /i", "", $api_result); echo $api_result; } } } //echo print_r($options_site); //echo print_r($options_form); echo $after_title; echo $after_widget; } function widget_ac_subscribe_admin() { $options_site = ac_subscribe_options_site_get(); $options_form = ac_subscribe_options_form_get(); if ( !function_exists(curl_init) ) { ac_subscribe_curl_fail(); } else { if ($_SERVER["REQUEST_METHOD"] == "POST") { // The second part of the form, where we ask which form they want to use. // Have to run this section of code first, since we exit right away once this is run. // Hidden form element which is set to true when that part of the form is submitted if ($_POST["ac_subscribe_form_submit"] == true) { // SECOND submit $api_url = $options_site["api_url"] . "admin/api.php?api_key=" . $options_site["api_key"] . "&api_action=form_view&api_output=serialize&id=" . $_POST["ac_subscribe_form_id"]; $api_result = ac_subscribe_curl_get($api_url); //print_r($api_result);exit(); if (is_array($api_result) && isset($api_result["result_code"]) && !(int)$api_result["result_code"]) { echo "
Connection failed. Here is the message returned:
" . $api_result["result_message"] . "
API URL:
" . $api_url . "
" . $api_result["result_message"] . "
Please make sure that your login information is correct, and that you have at least one integration form set up already.
"; // Show login form again ac_subscribe_admin_login(); exit(); } // Start second page of the form echo "Please select the form to display:
"; // Loop through each array item in the result // Remember, the result contains other items like "result_code" foreach ($api_result as $k => $v) { // Only look at array items that are not result_code, result_message, or result_output (included at the end of the result array) if ( $k === 0 || intval($k) ) { echo ""; echo ""; echo "
"; } } } else { ac_subscribe_admin_login(); } ?>Your ActiveCampaign API URL: " style="width: 99%;" />
Your ActiveCampaign API Key: " style="width: 99%;" />