From 8dd84d12e6034b6d100af4ebccf1fe749715304e Mon Sep 17 00:00:00 2001 From: Tony Volpe Date: Tue, 17 Sep 2024 10:50:03 -0400 Subject: [PATCH] add campaign tracking plugin --- .../campaign-tracking/CampaignController.php | 350 ++++++++++++++++++ .../plugins/campaign-tracking/admin-cron.php | 24 ++ .../campaign-tracking/campaign-tracking.php | 65 ++++ .../encryption/config-full.php | 26 ++ .../campaign-tracking/encryption/config.php | 26 ++ .../encryption/encrypted-content.php | 7 + .../encryption/message-content-signed.php | 7 + .../encryption/message-content.php | 8 + .../encryption/secured-content.php | 88 +++++ .../plugins/campaign-tracking/functions.php | 161 ++++++++ .../campaign-tracking/lib/CptCampaign.php | 142 +++++++ .../plugins/campaign-tracking/original.php | 40 ++ .../plugins/campaign-tracking/page-types.php | 50 +++ .../res/js/campaign.metabox.js | 36 ++ .../res/js/campaign.metabox.min.js | 1 + .../plugins/campaign-tracking/style.css | 97 +++++ .../plugins/campaign-tracking/sync.php | 47 +++ .../templates/campaign-metabox.php | 18 + .../templates/metabox/input-date.php | 9 + .../templates/metabox/input-text.php | 12 + .../templates/single-campaign.php | 38 ++ 21 files changed, 1252 insertions(+) create mode 100644 wp/wp-content/plugins/campaign-tracking/CampaignController.php create mode 100644 wp/wp-content/plugins/campaign-tracking/admin-cron.php create mode 100644 wp/wp-content/plugins/campaign-tracking/campaign-tracking.php create mode 100755 wp/wp-content/plugins/campaign-tracking/encryption/config-full.php create mode 100755 wp/wp-content/plugins/campaign-tracking/encryption/config.php create mode 100644 wp/wp-content/plugins/campaign-tracking/encryption/encrypted-content.php create mode 100644 wp/wp-content/plugins/campaign-tracking/encryption/message-content-signed.php create mode 100644 wp/wp-content/plugins/campaign-tracking/encryption/message-content.php create mode 100644 wp/wp-content/plugins/campaign-tracking/encryption/secured-content.php create mode 100644 wp/wp-content/plugins/campaign-tracking/functions.php create mode 100644 wp/wp-content/plugins/campaign-tracking/lib/CptCampaign.php create mode 100644 wp/wp-content/plugins/campaign-tracking/original.php create mode 100644 wp/wp-content/plugins/campaign-tracking/page-types.php create mode 100644 wp/wp-content/plugins/campaign-tracking/res/js/campaign.metabox.js create mode 100644 wp/wp-content/plugins/campaign-tracking/res/js/campaign.metabox.min.js create mode 100644 wp/wp-content/plugins/campaign-tracking/style.css create mode 100644 wp/wp-content/plugins/campaign-tracking/sync.php create mode 100644 wp/wp-content/plugins/campaign-tracking/templates/campaign-metabox.php create mode 100644 wp/wp-content/plugins/campaign-tracking/templates/metabox/input-date.php create mode 100644 wp/wp-content/plugins/campaign-tracking/templates/metabox/input-text.php create mode 100644 wp/wp-content/plugins/campaign-tracking/templates/single-campaign.php diff --git a/wp/wp-content/plugins/campaign-tracking/CampaignController.php b/wp/wp-content/plugins/campaign-tracking/CampaignController.php new file mode 100644 index 00000000..2667b3ca --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/CampaignController.php @@ -0,0 +1,350 @@ + CptCampaign::POST_TYPE, + "posts_per_page" => 1, + "meta_key" => CptCampaign::kMETA_CAMPAIGN_ID, + "meta_value" => $utm_campaign + ) + ); + + if (!empty($campaign)) { + $campaign = $campaign[0]; + $campaignID = get_post_meta($campaign->ID, CptCampaign::kMETA_CAMPAIGN_ID, true); + $campaignName = get_post_meta($campaign->ID, CptCampaign::kMETA_CAMPAIGN_NAME, true); + $campaignPhone = get_post_meta($campaign->ID, CptCampaign::kMETA_CAMPAIGN_PHONE, true); + + $this->setCampaignCookies($campaignID, $campaignName, $campaignPhone); + + if (!session_id()) { + session_start(); + } + $_SESSION[self::kCOOKIE_ID] = $campaignID; + $_SESSION[self::kCOOKIE_PHONE] = $campaignPhone; + } + } + } + + // Set session cookies + public function setCampaignCookies($id, $CampaignName, $phone) { + setcookie(self::kCOOKIE_ID, $id, 0, '/'); + setcookie(self::kCOOKIE_CAMPAIGN_NAME, $CampaignName, 0, '/'); + setcookie(self::kCOOKIE_PHONE, $phone, 0, '/'); + } + + // Functions to check and retrieve active campaign phone + public function check_campaign_active_tel($phonenumber) { + if (!empty($_COOKIE[self::kCOOKIE_ID])) { + $campaign = $this->getActiveCampaignPhoneByID($_COOKIE[self::kCOOKIE_ID]); + if (!empty($campaign)) { + return $campaign; + } + } + if (!empty($_SESSION[self::kCOOKIE_ID])) { + $campaign = $this->getActiveCampaignPhoneByID($_SESSION[self::kCOOKIE_ID]); + if (!empty($campaign)) { + return $campaign; + } + } + return $phonenumber; + } + + public function check_campaign_active_ass_phone($phonenumber) { + if (!empty($_COOKIE[self::kCOOKIE_ID])) { + $campaign = $this->getActiveCampaignPhoneByID($_COOKIE[self::kCOOKIE_ID]); + if (!empty($campaign)) { + return $campaign; + } + } + if (!empty($_SESSION[self::kCOOKIE_ID])) { + $campaign = $this->getActiveCampaignPhoneByID($_SESSION[self::kCOOKIE_ID]); + if (!empty($campaign)) { + return $campaign; + } + } + return $phonenumber; + } + + // Retrieve campaign-related information from cookies/sessions + public static function getCampaignID() { + if (!empty($_COOKIE[self::kCOOKIE_ID])) { + return $_COOKIE[self::kCOOKIE_ID]; + } + if (!empty($_SESSION[self::kCOOKIE_ID])) { + return $_SESSION[self::kCOOKIE_ID]; + } + return null; + } + + public static function getCampaignFive9() { + if (!empty($_COOKIE[self::kCOOKIE_ID_FIVE9])) { + return $_COOKIE[self::kCOOKIE_ID_FIVE9]; + } + if (!empty($_SESSION[self::kCOOKIE_ID_FIVE9])) { + return $_SESSION[self::kCOOKIE_ID_FIVE9]; + } + return null; + } + + public static function getCampaignSO() { + if (!empty($_COOKIE[self::KCOOKIE_WEB_TOP_BAR])) { + return $_COOKIE[self::KCOOKIE_WEB_TOP_BAR]; + } + if (!empty($_SESSION[self::KCOOKIE_WEB_TOP_BAR])) { + return $_SESSION[self::KCOOKIE_WEB_TOP_BAR]; + } + return null; + } + + public function get_phone_number() { + $phoneNumber = get_option('cta_tel', true); + return $phoneNumber; + } + + public function getActiveCampaignPhoneByID($campaignID = "-1") { + $campaign = get_posts( + array( + "post_type" => CptCampaign::POST_TYPE, + "posts_per_page" => 1, + "meta_key" => CptCampaign::kMETA_CAMPAIGN_ID, + "meta_value" => $campaignID + ) + ); + + if (!empty($campaign)) { + $campaign = $campaign[0]; + $campaignStart = get_post_meta($campaign->ID, CptCampaign::kMETA_CAMPAIGN_START_DATE, true); + $campaignEnd = get_post_meta($campaign->ID, CptCampaign::kMETA_CAMPAIGN_END_DATE, true); + $campaignStart .= " 00:00:00"; + $campaignEnd .= " 23:59:59"; + $campaignStart = strtotime($campaignStart); + $campaignEnd = strtotime($campaignEnd); + $now = time(); + if ($now >= $campaignStart && $now <= $campaignEnd) { + $campaignPhone = get_post_meta($campaign->ID, CptCampaign::kMETA_CAMPAIGN_PHONE, true); + return $campaignPhone; + } else { + return false; + } + } + return false; + } + + public function setCampaign($id = "", $CampaignName = "", $phone = "", $id_five_9 = "") { + setcookie(self::kCOOKIE_ID, $id, 0, '/'); + setcookie(self::kCOOKIE_CAMPAIGN_NAME, $CampaignName, 0, '/'); + setcookie(self::kCOOKIE_PHONE, $phone, 0, '/'); + setcookie(self::kCOOKIE_ID_FIVE9, $id_five_9, 0, '/'); + + if (!session_id()) { + session_start(); + } + $_SESSION[self::kCOOKIE_ID] = $id; + $_SESSION[self::kCOOKIE_PHONE] = $phone; + $_SESSION[self::kCOOKIE_ID_FIVE9] = $id_five_9; + } + + public function activate() { + $cpt = new CptCampaign(); + $cpt->rewrite_flush(); + } + + public function cronJob($data){ + + if(!empty($data->ResponseBody)){ + + $existings = get_posts( + array( + "post_type"=>CptCampaign::POST_TYPE, + "posts_per_page"=>-1, + "post_status"=>"publish" + ) + ); + + if(!empty($existings)){ + foreach ($existings as $post){ + update_post_meta($post->ID,CptCampaign::kMETA_DELETE,true); + } + } + unset($existings); + + foreach ($data->ResponseBody as $single): + $CampaignID = $single->CampaignID; + $StartDate = $single->StartDate; + $PhoneNumber = $single->PhoneNumber; + $LandingURL = $single->LandingURL; + $FriendlyURL = $single->FriendlyURL; + $EndDate = $single->EndDate; + $CampaignName = $single->CampaignName; + $Five9CallbackCampaign = $single->Five9CallbackCampaign; + $postname = str_replace(get_bloginfo('wpurl'),"",$FriendlyURL); + + $post = get_posts( + array( + "post_type"=>CptCampaign::POST_TYPE, + "posts_per_page"=>-1, + "post_status"=>"publish", + "meta_key"=>CptCampaign::kMETA_CAMPAIGN_ID, + "meta_value"=>$CampaignID + ) + ); + + if(!empty($post)){ + $post = $post[0]; + update_post_meta($post->ID,CptCampaign::kMETA_DELETE,false); + $my_post = array( + 'ID'=> $post->ID, + 'post_title' => wp_strip_all_tags( $CampaignName ), + 'post_content' => "", + 'post_status' => 'publish', + 'post_author' => 1, + 'post_type' => CptCampaign::POST_TYPE, + 'post_name' => $postname, + 'meta_input' => array( + CptCampaign::kMETA_CAMPAIGN_ID => $CampaignID, + CptCampaign::kMETA_CAMPAIGN_START_DATE => $StartDate, + CptCampaign::kMETA_CAMPAIGN_PHONE => $PhoneNumber, + CptCampaign::kMETA_CAMPAIGN_LANDING_URL => $LandingURL, + CptCampaign::kMETA_CAMPAIGN_SHORT_URL => $FriendlyURL, + CptCampaign::kMETA_CAMPAIGN_END_DATE => $EndDate, + CptCampaign::kMETA_CAMPAIGN_NAME => $CampaignName, + CptCampaign::kMETA_FIVE9 => $Five9CallbackCampaign, + ) + ); + + wp_update_post($my_post); + + echo "\nUPDATE CAMPAIGN ".$CampaignName; + }else{ + + $my_post = array( + 'post_title' => wp_strip_all_tags( $CampaignName ), + 'post_content' => "", + 'post_status' => 'publish', + 'post_author' => 1, + 'post_type' => CptCampaign::POST_TYPE, + 'post_name' => $postname, + 'meta_input' => array( + CptCampaign::kMETA_CAMPAIGN_ID => $CampaignID, + CptCampaign::kMETA_CAMPAIGN_START_DATE => $StartDate, + CptCampaign::kMETA_CAMPAIGN_PHONE => $PhoneNumber, + CptCampaign::kMETA_CAMPAIGN_LANDING_URL => $LandingURL, + CptCampaign::kMETA_CAMPAIGN_SHORT_URL => $FriendlyURL, + CptCampaign::kMETA_CAMPAIGN_END_DATE => $EndDate, + CptCampaign::kMETA_CAMPAIGN_NAME => $CampaignName, + CptCampaign::kMETA_FIVE9 => $Five9CallbackCampaign, + ) + ); + + wp_insert_post($my_post); + + echo "\nCreated Campaign: ".$CampaignName; + } + + endforeach; + + $todelete = get_posts( + array( + "post_type"=>CptCampaign::POST_TYPE, + "posts_per_page"=>-1, + "post_status"=>"publish", + "meta_key"=>CptCampaign::kMETA_DELETE, + "meta_value"=>true + ) + ); + + if(!empty($todelete)){ + echo "\n\n*** CAMPAIGN DELETE ***"; + foreach ($todelete as $post){ + echo "\n".$post->post_title; + wp_trash_post($post->ID); + } + } + unset($todelete); + } + } + + // Enqueue admin scripts and styles + public function load_campaign_script($hook){ + if(('post.php' == $hook || 'post-new.php' == $hook) && get_post_type() == CptCampaign::POST_TYPE) { + wp_enqueue_style('jquery-ui'); + wp_enqueue_script('jquery-ui-datepicker'); + wp_enqueue_script("campaign.metabox", kPLUGIN_DIR_URL . 'res/js/campaign.metabox.min.js', false, filemtime(kPLUGIN_DIR_PATH . 'res/js/campaign.metabox.min.js')); + } + } + } +} + +// Initialize the controller +if (class_exists('CampaignController')) { + register_activation_hook(__FILE__, array('CampaignController', 'activate')); + CampaignController::instance(); +} diff --git a/wp/wp-content/plugins/campaign-tracking/admin-cron.php b/wp/wp-content/plugins/campaign-tracking/admin-cron.php new file mode 100644 index 00000000..38ca72c6 --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/admin-cron.php @@ -0,0 +1,24 @@ + +


+ +
+

Sync Campaigns

+

+ +
+ + diff --git a/wp/wp-content/plugins/campaign-tracking/campaign-tracking.php b/wp/wp-content/plugins/campaign-tracking/campaign-tracking.php new file mode 100644 index 00000000..56875f40 --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/campaign-tracking.php @@ -0,0 +1,65 @@ +query_vars['campaign_backend_route'] ) ) + return; + + include_once(plugin_dir_path(__FILE__).'sync.php'); + + die(); +} + +function campaign_cron_init(){ + + campaign_backend_register_rewrites(); + global $wp; + $wp->add_query_var( 'campaign_backend_route' ); +} + +function campaign_backend_register_rewrites(){ + + $pre='campaign_cron'; + $pre=str_replace("/","",$pre); + + add_rewrite_rule( '^' . $pre . '/?$','index.php?campaign_backend_route=/','top' ); + add_rewrite_rule( '^' . $pre . '(.*)?','index.php?campaign_backend_route=$matches[1]','top' ); +} + + add_action( 'template_redirect', 'campaign_cron_loaded', -100 ); + add_action( 'init', 'campaign_cron_init' ); + diff --git a/wp/wp-content/plugins/campaign-tracking/encryption/config-full.php b/wp/wp-content/plugins/campaign-tracking/encryption/config-full.php new file mode 100755 index 00000000..ad215711 --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/encryption/config-full.php @@ -0,0 +1,26 @@ +encrption_key = get_option("encrption_key"); + $this->signature_key = get_option("signature_key");*/ + $this->encrption_key = ENCRYPTION_KEY; + $this->signature_key = SIGNATURE_KEY; + $this->cipher = 'AES-256-CBC'; + + } + + public function encode_content($raw_content) + { + $message_content = new MessageContent(); + $message_content->Body = $raw_content; + $message_content->Timestamp = date('Y-m-d H:i:s', time()); + $message_content->Uid = self::guid(); + + // create signature & pack message + $signed_message = new MessageContentSigned(); + $signed_message->Content = json_encode($message_content); + $signed_message->Signature = $this->generate_signature($signed_message->Content); + + // create initialization vector & encode data + $iv_size = 16; + $iv = openssl_random_pseudo_bytes($iv_size); + $key = base64_decode($this->encrption_key); + $data = json_encode($signed_message); + $padding = 16 - (strlen($data) % 16); + $data .= str_repeat(chr($padding), $padding); + $cipher_text = openssl_encrypt($data, $this->cipher, $key, OPENSSL_RAW_DATA, $iv); + + // store content inside an encrypted container + $encrypted_content = new EncryptedContent(); + $encrypted_content->IV = base64_encode($iv); + $encrypted_content->Data = base64_encode($cipher_text); + + return $encrypted_content; + } + + public function decode_content($encrypted_string) + { + $encrypted_content = json_decode($encrypted_string); + + // decode data + + $key = base64_decode($this->encrption_key); + $iv = base64_decode($encrypted_content->IV); + $message = openssl_decrypt(base64_decode($encrypted_content->Data), $this->cipher, $key, OPENSSL_RAW_DATA, $iv); + $message = json_decode(substr($message, 0)); + $signature = $this->generate_signature($message->Content); + + return json_decode($message->Content)->Body; + } + + private function generate_signature($message_content) + { + $private_key = openssl_get_privatekey($this->signature_key); + + openssl_sign($message_content, $signature, $this->signature_key, 'SHA256'); + + openssl_free_key($private_key); + + return base64_encode($signature); + } + + public static function guid() + { + if (function_exists('com_create_guid') === true) + { + return trim(com_create_guid(), '{}'); + } + + return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)); + } + } +} diff --git a/wp/wp-content/plugins/campaign-tracking/functions.php b/wp/wp-content/plugins/campaign-tracking/functions.php new file mode 100644 index 00000000..18c19307 --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/functions.php @@ -0,0 +1,161 @@ + 'SFDC Environment', 'option_name' => 'select-environment', 'type' => 'select-environment', 'description' => '', 'default' => ''), + //array( 'name' => 'API', 'option_name' => 'id_api_salesforce', 'type' => 'input', 'description' => '', 'default' => ''), + array( 'name' => 'Version', 'option_name' => 'id_version', 'type' => 'input', 'description' => '', 'default' => ''), + array( 'name' => 'API', 'option_name' => 'select-api', 'type' => 'select-api', 'description' => '', 'default' => ''), + array( 'name' => 'Brand ID', 'option_name' => 'id_brand', 'type' => 'select-brand', 'description' => '', 'default' => ''), + array( 'name' => 'Call to Action Tel ', 'option_name' => 'cta_tel', 'type' => 'select-phone', 'description' => 'Telephone', 'default' => '1.800.800.2537') +); + + +add_action( 'wp_enqueue_scripts', 'load_css' ); + +function load_css() { + $plugin_url = plugin_dir_url( __FILE__ ); + wp_enqueue_style( 'style', $plugin_url . 'style.css' ); +} + +add_action('admin_menu', 'campaign_menu_page'); + +function campaign_menu_page() { + $themename = "Campaign Tracking"; + $shortname = "campaign_tracking"; + $menu_slug="edit_posts"; + add_object_page($themename, $themename, $menu_slug, $shortname,'id_main_admin'); +} + +function id_main_admin(){ + $i=0; + global $themename, $shortname,$id_setting; + + $themename = "Campaign Tracking"; + $save=false; + if ( 'save' == $_POST['action'] ) { + $save=true; + foreach($id_setting as $id_single) { + update_option( sanitize_text_field($id_single['option_name']), sanitize_text_field($_POST[$id_single['option_name']]) ); + $i++; + } + } + + if ( $save ) echo '

'.$themename.' Settings save..

'; + ?> +
+ ".$themename." "; + echo $admin_header; + ?> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
" /> + ';}?> +

+ + +

+ +

+
+ + + +
+
+ + +self::kMETA_CAMPAIGN_ID,'type'=>'input-text','title'=>'Campaign ID'), + array('name'=>self::kMETA_CAMPAIGN_NAME,'type'=>'input-text','title'=>'Campaign name'), + array('name'=>self::kMETA_CAMPAIGN_START_DATE,'type'=>'input-date','title'=>'Start date'), + array('name'=>self::kMETA_CAMPAIGN_END_DATE,'type'=>'input-date','title'=>'End date'), + array('name'=>self::kMETA_CAMPAIGN_PHONE,'type'=>'input-text','title'=>'Phone number'), + array('name'=>self::kMETA_CAMPAIGN_SHORT_URL,'type'=>'input-text','title'=>'Friendly URL'), + array('name'=>self::kMETA_CAMPAIGN_LANDING_URL,'type'=>'input-text','title'=>'Landing URL'), + array('name'=>self::kMETA_FIVE9,'type'=>'input-text','title'=>'Five9 Callback Campaign'), + + + ); + + public function __construct(){ + add_action('init', array(&$this, 'init')); + add_action('admin_init', array(&$this, 'admin_init')); + //add_action('admin_print_scripts', array(&$this,'load_custom_wp_admin_script') ); + add_filter('single_template',array(&$this,'single_template')); + } + + public function init(){ + $this->create_post_type(); + add_action('save_post', array(&$this, 'save_post')); + } + + + public function admin_init(){ + + add_action('add_meta_boxes', array(&$this, 'add_meta_boxes')); + } + + public function add_meta_boxes(){ + add_meta_box( + sprintf('campaign_plugin_%s_section', self::POST_TYPE), + 'Info', + array(&$this, 'add_inner_meta_boxes'), + self::POST_TYPE + ); + } + + public function add_inner_meta_boxes($post){ + + include(sprintf("%s/templates/%s-metabox.php",kCampaignPath, self::POST_TYPE)); + } + + public function create_post_type(){ + + $labels = array( + 'name' => __("Campaigns"), + 'singular_name' => __("Campaign"), + 'menu_name' => __("Campaigns"), + 'name_admin_bar' => __("Campaign"), + 'add_new_item' => __( 'Add New Campaign'), + 'new_item' => __( 'New Campaign'), + 'edit_item' => __( 'Edit Campaign' ), + 'view_item' => __( 'View Campaign' ), + 'all_items' => __( 'All Campaigns' ), + 'search_items' => __( 'Search Campaigns'), + 'parent_item_colon' => __( 'Parent Campaigns:' ), + 'not_found' => __( 'No campaigns found.'), + 'not_found_in_trash' => __( 'No campaigns found in Trash.' ) + ); + + register_post_type(self::POST_TYPE, + array( + 'labels' =>$labels, + 'public' => true, + 'has_archive' => false, + 'description' => self::DESCRIPTION, + 'supports' => array( + 'title', 'editor', + ), + 'hierarchical' => false, + 'menu_position'=> 9, + 'query_var' => self::QUERY_VAR, + 'rewrite' => array( 'slug' => '/'.self::POST_TYPE, 'with_front' => false ) +// 'rewrite' => array( 'slug' => self::POST_TYPE ) + ) + ); + } + + public function single_template($single_template){ + global $post; + $found = locate_template('single-'.self::POST_TYPE.'.php'); + if($post->post_type == self::POST_TYPE && $found == ''){ + $single_template = kCampaignPath.'/templates/single-'.self::POST_TYPE.'.php'; + } + + return $single_template; + } + + public function rewrite_flush() { + $this->create_post_type(); + flush_rewrite_rules(); + } + + public function save_post($post_id){ + + if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { + return; + } + + if(isset($_POST['post_type']) && $_POST['post_type'] == self::POST_TYPE && current_user_can('edit_post', $post_id)) + { + foreach($this->_meta as $field) + { + // Update the post's meta field + if (isset($_POST[$field['name']])) + update_post_meta($post_id, $field['name'], $_POST[$field['name']]); + } + } + } + } +} diff --git a/wp/wp-content/plugins/campaign-tracking/original.php b/wp/wp-content/plugins/campaign-tracking/original.php new file mode 100644 index 00000000..3d432127 --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/original.php @@ -0,0 +1,40 @@ +
+
+ +
+
+ +
+
+ +
+ + + post_content; $content=apply_filters('the_content',$content); ?> + + +
+ + +
\ No newline at end of file diff --git a/wp/wp-content/plugins/campaign-tracking/page-types.php b/wp/wp-content/plugins/campaign-tracking/page-types.php new file mode 100644 index 00000000..7acb901f --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/page-types.php @@ -0,0 +1,50 @@ + _x($type[0], 'Post Type ' . $type[0], 'campaign'), + 'singular_name' => _x($type[0], 'Post Type ' . $type[0], 'campaign'), + 'menu_name' => __($type[1], 'campaign'), + 'parent_item_colon' => __('Parent ' . $type[1], 'campaign'), + 'all_items' => __('All ' . $type[1], 'campaign'), + 'view_item' => __('View ' . $type[1], 'campaign'), + 'add_new_item' => __('Add New ' . $type[0], 'campaign'), + 'add_new' => __('Add New', 'campaign'), + 'edit_item' => __('Edit ' . $type[0], 'campaign'), + 'update_item' => __('Update ' . $type[0], 'campaign'), + 'search_items' => __('Search ' . $type[1], 'campaign'), + 'not_found' => __('Not Found', 'campaign'), + 'not_found_in_trash' => __('Not found in Trash', 'campaign'), + ); + + + $args = array( + 'label' => __($type[0], ''), + 'description' => __($type[0], ''), + 'labels' => $labels, + 'supports' => $type[3], + 'taxonomies' => array(), + 'hierarchical' => false, + 'public' => true, + 'show_ui' => true, + 'show_in_menu' => true, + 'show_in_nav_menus' => true, + 'show_in_admin_bar' => true, + 'menu_position' => 5, + 'can_export' => true, + 'has_archive' => $type[2], + 'rewrite' => array('slug' => $slug), + 'exclude_from_search' => false, + 'publicly_queryable' => true, + 'capability_type' => 'page', + ); + + register_post_type($type[0], $args); + } + } + add_action( 'init', 'custom_post_type', 0 ); diff --git a/wp/wp-content/plugins/campaign-tracking/res/js/campaign.metabox.js b/wp/wp-content/plugins/campaign-tracking/res/js/campaign.metabox.js new file mode 100644 index 00000000..8a2c7cb8 --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/res/js/campaign.metabox.js @@ -0,0 +1,36 @@ +function initMetabox(){ + console.log("** initMetabox **"); + + var dateFormat = "yy-mm-dd", + from = $( "#campaign_start_date" ) + .datepicker({ + dateFormat: dateFormat + }) + .on( "change", function() { + to.datepicker( "option", "minDate", getDate( this ) ); + }), + to = $( "#campaign_end_date" ).datepicker({ + dateFormat: dateFormat + }).on( "change", function() { + from.datepicker( "option", "maxDate", getDate( this ) ); + }); + + function getDate( element ) { + var date; + try { + date = $.datepicker.parseDate( dateFormat, element.value ); + } catch( error ) { + date = null; + } + + return date; + } +} + +if($ == undefined){ + window.$ = jQuery.noConflict(); +} + +$(function(){ + initMetabox(); +}); \ No newline at end of file diff --git a/wp/wp-content/plugins/campaign-tracking/res/js/campaign.metabox.min.js b/wp/wp-content/plugins/campaign-tracking/res/js/campaign.metabox.min.js new file mode 100644 index 00000000..f1f1cee1 --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/res/js/campaign.metabox.min.js @@ -0,0 +1 @@ +function initMetabox(){console.log("** initMetabox **");var a="yy-mm-dd",d=$("#campaign_start_date").datepicker({dateFormat:a}).on("change",function(){c.datepicker("option","minDate",b(this))}),c=$("#campaign_end_date").datepicker({dateFormat:a}).on("change",function(){d.datepicker("option","maxDate",b(this))});function b(g){var f;try{f=$.datepicker.parseDate(a,g.value)}catch(e){f=null}return f}}if($==undefined){window.$=jQuery.noConflict()}$(function(){initMetabox()}); \ No newline at end of file diff --git a/wp/wp-content/plugins/campaign-tracking/style.css b/wp/wp-content/plugins/campaign-tracking/style.css new file mode 100644 index 00000000..1362b556 --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/style.css @@ -0,0 +1,97 @@ +.s-button-wrapper { + position: fixed; + bottom: 3em; + right: 3em; + text-align: right; +} + +.s-button { + opacity: .6; + height: 5em; + width: 5em; + font-size: 14px; + border-radius: 50%; + border: 0 none; + color: #fff; + cursor: pointer; + box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26); + -webkit-transform: scale(1); + transform: scale(1); + -webkit-transition: all 200ms ease; + transition: all 200ms ease; +} + +.s-button:hover, +.s-button:focus, +.s-button:active { + box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2); + outline: 0; +} + +.s-button span { + display: block; + font-size: 2em; + -webkit-transform: scale(1); + transform: scale(1); + -webkit-transition: -webkit-transform 100ms ease; + transition: -webkit-transform 100ms ease; + transition: transform 100ms ease; + transition: transform 100ms ease, -webkit-transform 100ms ease; +} + +.s-button:hover span, +.expanded .s-button span, +.expanded .s-button span { + -webkit-transform: scale(1.25); + transform: scale(1.25); +} + +.expanded .s-button { + -webkit-transform: scale(0.7); + transform: scale(0.7); + color: rgba(255, 255, 255, 0.5); + background: #9e9e9e; + +} + +.s-list { + list-style: none; + padding: 0; + margin: 0; + -webkit-transition: all 200ms ease; + transition: all 200ms ease; + -webkit-transform: translate(0, 90px) scale(0.5); + transform: translate(0, 90px) scale(0.5); + -webkit-transform-origin: bottom center; + transform-origin: bottom center; + opacity: 0; +} + +.expanded .s-list { + text-align: left; + font-size: 14px; + -webkit-transform: translate(0px, 20px) scale(1); + transform: translate(0px, 20px) scale(1); + opacity: 1; + box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26); + background-color: #7f5ca3; + padding: 20px !important; + border-radius: 20px; +/* width: 315px; + height: 235px;*/ + overflow: hidden; + opacity: 0.8; +} + +.s-list li { + color: #F5F5F5; +} + +.s-list li:last-child { + margin-bottom: 0; +} + +.s-list li:hover { + color: black; +} + diff --git a/wp/wp-content/plugins/campaign-tracking/sync.php b/wp/wp-content/plugins/campaign-tracking/sync.php new file mode 100644 index 00000000..0117d3dc --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/sync.php @@ -0,0 +1,47 @@ +encode_content(urldecode($url))); +curl_setopt($request_campaign, CURLOPT_HTTPHEADER, array('CA-Authorization: ' . $auth_header)); +$result = curl_exec($request_campaign); +curl_close($request_campaign); +echo $result; +$data = stripslashes($result); + +if(!empty($data)){ + + $data = substr($data,1); + $data = substr($data,0,-1); + $data = (OBJECT)json_decode($crypto->decode_content($data)); + + if(!empty($data) && !empty($data->ResponseBody)){ + + echo "\nCampaign Updates:"; + $campaignController = CampaignController::instance(); + $campaignController->cronJob($data); + + }else{ + echo "\nNo data"; + } + +}else{ + echo "\n** FAILED **\n"; +} + +echo "\n\n***** END CAMPAIGN SYNC *****"; diff --git a/wp/wp-content/plugins/campaign-tracking/templates/campaign-metabox.php b/wp/wp-content/plugins/campaign-tracking/templates/campaign-metabox.php new file mode 100644 index 00000000..9a0a6bbc --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/templates/campaign-metabox.php @@ -0,0 +1,18 @@ + +

Campaign details info

+ +_meta as $meta): + $value=get_post_meta($post->ID, $meta['name'], true); + $field=$meta['name']; + $title=$meta['title']; + if($meta['type']=='input-text') : + include(sprintf("%s/metabox/input-text.php", dirname(__FILE__))) ; + elseif($meta['type']=='input-date') : + include(sprintf("%s/metabox/input-date.php", dirname(__FILE__))) ; + endif ; +endforeach; +?> +
\ No newline at end of file diff --git a/wp/wp-content/plugins/campaign-tracking/templates/metabox/input-date.php b/wp/wp-content/plugins/campaign-tracking/templates/metabox/input-date.php new file mode 100644 index 00000000..2098c8e3 --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/templates/metabox/input-date.php @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/wp/wp-content/plugins/campaign-tracking/templates/metabox/input-text.php b/wp/wp-content/plugins/campaign-tracking/templates/metabox/input-text.php new file mode 100644 index 00000000..5e9d851c --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/templates/metabox/input-text.php @@ -0,0 +1,12 @@ + + + + + + + diff --git a/wp/wp-content/plugins/campaign-tracking/templates/single-campaign.php b/wp/wp-content/plugins/campaign-tracking/templates/single-campaign.php new file mode 100644 index 00000000..506c7701 --- /dev/null +++ b/wp/wp-content/plugins/campaign-tracking/templates/single-campaign.php @@ -0,0 +1,38 @@ +=$campaignStart && $now<=$campaignEnd){ + + //campaign active + $controller = CampaignController::instance(); + $controller->setCampaign($campaignID,$campaignName,$campaignPhone,$campaignFive9CallbackCampaign); + +}else{ + //campaign expired or not yet started +} +function append_query_string($url) { + return add_query_arg($_GET, $url); +} +add_filter('the_permalink', 'append_query_string'); +$permalink = append_query_string($url); +$url = (empty($campaignLink)) ? get_home_url() : $campaignLink; +$myurl = get_option('siteurl'); +