Plugin Directory

Changeset 1610908


Ignore:
Timestamp:
03/08/2017 10:16:15 PM (9 years ago)
Author:
activeim
Message:

#bugfix moving old version to tag

Location:
marketing-optimizer/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • marketing-optimizer/trunk/admin/main-settings-page.php

    r1607320 r1610908  
    2727                    $mo_settings_obj->set_mo_marketing_optimizer ( $_POST ['mo_marketing_optimizer'] );
    2828            }
    29             if (isset ( $_POST ['mo_username'] )) {
     29            if(isset($_POST['mo_username']) && isset($_POST['mo_password'])){
    3030                    $mo_settings_obj->set_mo_username ( $_POST ['mo_username'] );
    31             }
    32             if (isset ( $_POST ['mo_password'] )) {
    3331                    $mo_settings_obj->set_mo_password ( $_POST ['mo_password'] );
    34             }
    35             if(isset($_POST['mo_username']) && isset($_POST['mo_password'])){
    3632                require_once (WP_PLUGIN_DIR . '/marketing-optimizer/includes/'.'class.mo_autoloader.php');
    3733                $mo_api_auth_obj = new mo_api_auth($mo_settings_obj->get_mo_username(), $mo_settings_obj->get_mo_password());
     
    4137               
    4238                if ( $decodec_auth_result['success'] == 'true' && is_array($decodec_auth_result['data']) ) {
    43                     sleep(5);
    4439                    $mo_api_accounts_obj = new mo_api_accounts('my');
    4540                    $mo_api_accounts_obj->execute($decodec_auth_result['data']['id_token']);
  • marketing-optimizer/trunk/constants.php

    r1607324 r1610908  
    11<?php
    2     define('API_URL','https://app.marketingoptimizer.com/api/v1/');
    3     define('REMOTE_FORM_POST_URL','https://app.marketingoptimizer.com/remote/form_post.php');
    4     define('APJS_PHP_URL','//app.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  
    105105    public function execute($token = NULL)
    106106    {
    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        }
    109110       
    110111        $ch = curl_init();
    111112        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         else
     113        if( strpos($this->get_uri(),'login') === false ) {
     114            curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer ". $token));
     115        } else {
    115116            curl_setopt($ch, CURLOPT_HEADER, 0);
    116        
     117        }
    117118        switch ($this->get_request_type()) {
    118119            case 'POST':
     
    127128        }
    128129        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);
    133134       
    134         if ($this->get_is_new_session()) {
     135/*         if ($this->get_is_new_session()) {
    135136            curl_setopt($ch, CURLOPT_COOKIESESSION, true);
    136137        } else if(isset($_COOKIE[$this->get_cookie_name()])){
    137138            curl_setopt($ch, CURLOPT_COOKIE, $this->get_cookie_name() .'=' . $_COOKIE[$this->get_cookie_name()]);
    138         }
     139        } */
    139140        $response = curl_exec($ch);
    140141        $error = curl_error($ch);
     142       
    141143        curl_close($ch);
    142144        if ($error) {
  • marketing-optimizer/trunk/includes/class.mo_post_type.php

    r1607320 r1610908  
    955955        $mo_settings_obj = new mo_settings ();
    956956        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                       
    957964            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                       
    959968                    $mo_obj = $this->get_obj_by_type($post->ID);
    960969                                        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) {
     
    10021011                                               
    10031012                                               
    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 ()) {
    10071014                            echo $website_tracking_js;
    10081015                        }
     
    10101017                }
    10111018            }
     1019        } else {
     1020           
     1021           
     1022                        echo "<script type='text/javascript'> \n";
     1023                        echo "console.log('Mo Plugin is OFF');";
     1024                        echo "</script> \n";
    10121025        }
    10131026    }
  • marketing-optimizer/trunk/includes/class.mo_settings.php

    r1607320 r1610908  
    153153
    154154    public function get_mo_account_id(){
    155         return $this->mo_account_id;
     155        return (int) $this->mo_account_id;
    156156    }
    157157
    158158    public function set_mo_account_id($value){
    159         $this->mo_account_id = $value;
     159        $this->mo_account_id = (int) $value;
    160160    }
    161161   
  • marketing-optimizer/trunk/marketing-optimizer.php

    r1607331 r1610908  
    33 * Plugin Name: Marketing Optimizer for Wordpress Plugin
    44 * URI: http://www.marketingoptimizer.com/?apcid=8381
    5  * Version: 20170303.1
     5 * Version: 20170308
    66 * Description: Create Landing Pages for Wordpress
    77 * Author: Marketing Optimizer, customercare@marketingoptimizer.com
     
    2323    CONST MO_DIRECTORY = 'marketing-optimizer';
    2424
    25     public static $plugin_version = '20170303.1';
     25    public static $plugin_version = '20170308';
    2626
    2727    public static $plugin_name = 'marketing-optimizer';
     
    140140       
    141141        $this->get_login_cookie_api();
    142         $this->set_account_id();
    143142       
    144143        add_action('after_setup_theme', array(
     
    254253       
    255254        $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();
    257256        $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());
    268265                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()) {                     
    273269                        $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);
    275271                        $response = $mo_api_accounts_obj->get_response();
    276272                        $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);                     
    278275                    }
     276                } else {
     277                    unset($_COOKIE[$mo_api->get_cookie_name()]);
    279278                }
    280279            }
     
    305304    {
    306305        update_option($this->plugin_settings, $this->options_list);
    307         $this->mo_migrate_to_new_plugin();
    308306    }
    309307    // End Load Plugin Options
     
    724722    }
    725723
    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 
    762724    public function mo_update_parent_page($post_id)
    763725    {
  • marketing-optimizer/trunk/readme.txt

    r1607327 r1610908  
    106106
    107107== Changelog ==
     108= Version 20170308 =
     109* #bugFix fixed issue with new API update.
    108110= Version 20170303 =
    109111* #enhancement updated to the new API.
Note: See TracChangeset for help on using the changeset viewer.