Changeset 1610908
- Timestamp:
- 03/08/2017 10:16:15 PM (9 years ago)
- Location:
- marketing-optimizer/trunk
- Files:
-
- 7 edited
-
admin/main-settings-page.php (modified) (2 diffs)
-
constants.php (modified) (1 diff)
-
includes/api/class.mo_api.php (modified) (2 diffs)
-
includes/class.mo_post_type.php (modified) (3 diffs)
-
includes/class.mo_settings.php (modified) (1 diff)
-
marketing-optimizer.php (modified) (6 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
marketing-optimizer/trunk/admin/main-settings-page.php
r1607320 r1610908 27 27 $mo_settings_obj->set_mo_marketing_optimizer ( $_POST ['mo_marketing_optimizer'] ); 28 28 } 29 if (isset ( $_POST ['mo_username'] )){29 if(isset($_POST['mo_username']) && isset($_POST['mo_password'])){ 30 30 $mo_settings_obj->set_mo_username ( $_POST ['mo_username'] ); 31 }32 if (isset ( $_POST ['mo_password'] )) {33 31 $mo_settings_obj->set_mo_password ( $_POST ['mo_password'] ); 34 }35 if(isset($_POST['mo_username']) && isset($_POST['mo_password'])){36 32 require_once (WP_PLUGIN_DIR . '/marketing-optimizer/includes/'.'class.mo_autoloader.php'); 37 33 $mo_api_auth_obj = new mo_api_auth($mo_settings_obj->get_mo_username(), $mo_settings_obj->get_mo_password()); … … 41 37 42 38 if ( $decodec_auth_result['success'] == 'true' && is_array($decodec_auth_result['data']) ) { 43 sleep(5);44 39 $mo_api_accounts_obj = new mo_api_accounts('my'); 45 40 $mo_api_accounts_obj->execute($decodec_auth_result['data']['id_token']); -
marketing-optimizer/trunk/constants.php
r1607324 r1610908 1 1 <?php 2 define('API_URL','https://ap p.marketingoptimizer.com/api/v1/');3 define('REMOTE_FORM_POST_URL','https://ap p.marketingoptimizer.com/remote/form_post.php');4 define('APJS_PHP_URL','//ap p.marketingoptimizer.com/remote/ap_js.php?f=');5 define('APJS_URL',' //app.marketingoptimizer.com/remote/ap.js');2 define('API_URL','https://api.marketingoptimizer.com/api/v1/'); 3 define('REMOTE_FORM_POST_URL','https://api.marketingoptimizer.com/remote/form_post.php'); 4 define('APJS_PHP_URL','//api.marketingoptimizer.com/remote/ap_js.php?f='); 5 define('APJS_URL','api.marketingoptimizer.com/remote/ap.js'); -
marketing-optimizer/trunk/includes/api/class.mo_api.php
r1607320 r1610908 105 105 public function execute($token = NULL) 106 106 { 107 if(isset($_COOKIE['mo_api_live'])) 108 $token = $_COOKIE['mo_api_live']; 107 if(isset($_COOKIE[$this->get_cookie_name()])) { 108 $token = $_COOKIE[$this->get_cookie_name()]; 109 } 109 110 110 111 $ch = curl_init(); 111 112 curl_setopt($ch, CURLOPT_URL, $this->get_uri()); 112 if( strpos($this->get_uri(),'login') === false ) 113 curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer ". $token));114 else113 if( strpos($this->get_uri(),'login') === false ) { 114 curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer ". $token)); 115 } else { 115 116 curl_setopt($ch, CURLOPT_HEADER, 0); 116 117 } 117 118 switch ($this->get_request_type()) { 118 119 case 'POST': … … 127 128 } 128 129 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 129 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);130 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);131 curl_setopt($ch, CURLOPT_AUTOREFERER, 1);132 curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);130 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); 131 //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 132 //curl_setopt($ch, CURLOPT_AUTOREFERER, 1); 133 //curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 133 134 134 if ($this->get_is_new_session()) {135 /* if ($this->get_is_new_session()) { 135 136 curl_setopt($ch, CURLOPT_COOKIESESSION, true); 136 137 } else if(isset($_COOKIE[$this->get_cookie_name()])){ 137 138 curl_setopt($ch, CURLOPT_COOKIE, $this->get_cookie_name() .'=' . $_COOKIE[$this->get_cookie_name()]); 138 } 139 } */ 139 140 $response = curl_exec($ch); 140 141 $error = curl_error($ch); 142 141 143 curl_close($ch); 142 144 if ($error) { -
marketing-optimizer/trunk/includes/class.mo_post_type.php
r1607320 r1610908 955 955 $mo_settings_obj = new mo_settings (); 956 956 if($mo_settings_obj->get_mo_marketing_optimizer() == true){ 957 958 echo "<script type='text/javascript'> \n"; 959 echo "console.log('Mo Plugin is ON');"; 960 echo "console.log('MO Account Id: ".$mo_settings_obj->get_mo_account_id ()."');"; 961 echo "console.log('MO Post Type: ".$this->get_mo_pt_post_type()."');"; 962 echo "</script> \n"; 963 957 964 if ($mo_settings_obj->get_mo_account_id ()) { 958 if (is_object ( $post ) && $post->post_type === $this->get_mo_pt_post_type()) { 965 966 if (is_object ( $post ) && $post->post_type === $this->get_mo_pt_post_type()) { 967 959 968 $mo_obj = $this->get_obj_by_type($post->ID); 960 969 if ($mo_settings_obj->get_mo_lp_cache_compatible () == 'false' || isset ( $_GET ['mo_page_variation_id'] ) || isset ( $_GET ['t'] ) || count ( $mo_obj->get_variation_ids_arr () ) > 0) { … … 1002 1011 1003 1012 1004 // if (! $mo_obj->mo_bot_detected () || $this->mo_page_track_admin_user ()) { 1005 // echo $website_tracking_js; 1006 if (! $mo_obj->mo_bot_detected () || $this->mo_page_track_admin_user ()) { 1013 if (! $mo_obj->mo_bot_detected () || $this->mo_track_admin_user ()) { 1007 1014 echo $website_tracking_js; 1008 1015 } … … 1010 1017 } 1011 1018 } 1019 } else { 1020 1021 1022 echo "<script type='text/javascript'> \n"; 1023 echo "console.log('Mo Plugin is OFF');"; 1024 echo "</script> \n"; 1012 1025 } 1013 1026 } -
marketing-optimizer/trunk/includes/class.mo_settings.php
r1607320 r1610908 153 153 154 154 public function get_mo_account_id(){ 155 return $this->mo_account_id;155 return (int) $this->mo_account_id; 156 156 } 157 157 158 158 public function set_mo_account_id($value){ 159 $this->mo_account_id = $value;159 $this->mo_account_id = (int) $value; 160 160 } 161 161 -
marketing-optimizer/trunk/marketing-optimizer.php
r1607331 r1610908 3 3 * Plugin Name: Marketing Optimizer for Wordpress Plugin 4 4 * URI: http://www.marketingoptimizer.com/?apcid=8381 5 * Version: 2017030 3.15 * Version: 20170308 6 6 * Description: Create Landing Pages for Wordpress 7 7 * Author: Marketing Optimizer, customercare@marketingoptimizer.com … … 23 23 CONST MO_DIRECTORY = 'marketing-optimizer'; 24 24 25 public static $plugin_version = '2017030 3.1';25 public static $plugin_version = '20170308'; 26 26 27 27 public static $plugin_name = 'marketing-optimizer'; … … 140 140 141 141 $this->get_login_cookie_api(); 142 $this->set_account_id();143 142 144 143 add_action('after_setup_theme', array( … … 254 253 255 254 $mo_settings_obj = new mo_settings(); 256 $mo_account_user_ id= $mo_settings_obj->get_mo_username();255 $mo_account_user_name = $mo_settings_obj->get_mo_username(); 257 256 $mo_account_password = $mo_settings_obj->get_mo_password(); 258 259 if ( $mo_settings_obj->mo_marketing_optimizer == 'true' ) { 260 if (! isset($_COOKIE["mo_api_live"]) && $mo_account_user_id && $mo_account_password) { 261 $mo_api = new mo_api_auth($mo_account_user_id, $mo_account_password); 262 $mo_api->set_cookie_name('mo_api_live') 263 ->set_is_new_session(true) 264 ->execute(); 265 266 $decodec_result = json_decode($mo_api->get_response(), true); 267 257 258 if ( $mo_settings_obj->get_mo_marketing_optimizer() == 'true' || $mo_settings_obj->get_mo_marketing_optimizer() == true) { 259 260 if ($mo_account_user_name && $mo_account_password) { 261 $mo_api = new mo_api_auth($mo_account_user_name, $mo_account_password); 262 $mo_api->execute(); 263 $decodec_result = json_decode($mo_api->get_response(), true); 264 //var_dump($mo_api->get_response()); 268 265 if ( $decodec_result['success'] == 'true' && is_array($decodec_result['data']) ) { 269 setcookie("mo_api_live", $decodec_result['data']['id_token']); 270 271 if (! $mo_settings_obj->get_mo_account_id()) { 272 sleep(5); 266 $token = $decodec_result['data']['id_token']; 267 setcookie($mo_api->get_cookie_name(), $token); 268 if (! $mo_settings_obj->get_mo_account_id()) { 273 269 $mo_api_accounts_obj = new mo_api_accounts('my'); 274 $mo_api_accounts_obj->execute($ decodec_result['data']['id_token']);270 $mo_api_accounts_obj->execute($token); 275 271 $response = $mo_api_accounts_obj->get_response(); 276 272 $decodec_result = json_decode($response, true); 277 $this->set_account_id($decodec_result['data']['id']); 273 $account_id = $decodec_result['data']['id']; 274 $this->set_account_id($account_id); 278 275 } 276 } else { 277 unset($_COOKIE[$mo_api->get_cookie_name()]); 279 278 } 280 279 } … … 305 304 { 306 305 update_option($this->plugin_settings, $this->options_list); 307 $this->mo_migrate_to_new_plugin();308 306 } 309 307 // End Load Plugin Options … … 724 722 } 725 723 726 public function mo_migrate_to_new_plugin()727 {728 global $wpdb;729 if (! get_option('mo_migration', 0)) {730 $old_var_page_ids_arr = $wpdb->get_results('SELECT * FROM wp_posts WHERE post_type = "variation-page"');731 foreach ($old_var_page_ids_arr as $post_obj) {732 $parent_page = get_post_meta($post_obj->ID, 'mo_variation_parent', true);733 if ($parent_page) {734 $this->mo_update_parent_page($parent_page);735 $mo_page_obj = mo_pages::instance($parent_page);736 $mo_page_var_ids_arr = $mo_page_obj->get_variation_ids_arr();737 if (empty($mo_page_var_ids_arr)) {738 $mo_page_var_ids_arr[0] = 0;739 }740 $next_var_id = end($mo_page_var_ids_arr) + 1;741 $mo_page_var_ids_arr[$next_var_id] = $next_var_id;742 $mo_page_obj->set_variation_ids_arr($mo_page_var_ids_arr);743 $mo_page_obj->set_variations_arr($mo_page_var_ids_arr);744 $mo_page_obj->set_variation_property($next_var_id, 'title', $post_obj->post_title);745 $mo_page_obj->set_variation_property($next_var_id, 'description', get_post_meta($post_obj->ID, 'mo_variation_name', true));746 $mo_page_obj->set_variation_property($next_var_id, 'content', $post_obj->post_content);747 $mo_page_obj->set_variation_property($next_var_id, 'variation_id', get_post_meta($post_obj->ID, 'mo_variation_id', true));748 $status = get_post_meta($post_obj->ID, 'mo_variation_active', true) == 'true' ? 1 : 0;749 $mo_page_obj->set_variation_property($next_var_id, 'status', $status);750 $mo_page_obj->set_variation_property($next_var_id, 'template', get_post_meta($post_obj->ID, '_post_template', true));751 $mo_page_obj->set_variation_property($next_var_id, 'impressions', get_post_meta($post_obj->ID, 'mo_page_views_count', true));752 $mo_page_obj->set_variation_property($next_var_id, 'visitors', get_post_meta($post_obj->ID, 'mo_unique_page_views_count', true));753 $mo_page_obj->set_variation_property($next_var_id, 'conversions', get_post_meta($post_obj->ID, 'mo_conversion_count', true));754 $mo_page_obj->save();755 wp_delete_post($post_obj->ID, true);756 }757 }758 update_option('mo_migration', 1);759 }760 }761 762 724 public function mo_update_parent_page($post_id) 763 725 { -
marketing-optimizer/trunk/readme.txt
r1607327 r1610908 106 106 107 107 == Changelog == 108 = Version 20170308 = 109 * #bugFix fixed issue with new API update. 108 110 = Version 20170303 = 109 111 * #enhancement updated to the new API.
Note: See TracChangeset
for help on using the changeset viewer.