Plugin Directory

Changeset 786070


Ignore:
Timestamp:
10/10/2013 07:47:04 PM (12 years ago)
Author:
eric@…
Message:

update trunk

Location:
triplelift-native-advertising/trunk/triplelift
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • triplelift-native-advertising/trunk/triplelift/library/admin_register.php

    r761046 r786070  
    6262    }
    6363
    64 
     64    function install_plugin() {
     65        $plugin_data = get_plugin_data( dirname(__FILE__).'/../triplelift.php' );
     66        $theme = wp_get_theme();
     67        $api = new Triplelift_np_admin_api();
     68        $out = $api->do_post("/native_advertising/wp/new_install", array(
     69            'theme_name'    => $theme->Name,
     70            'host'          => get_bloginfo('url'),
     71            'admin_email'   => get_bloginfo('admin_email'),
     72            'wp_version'    => get_bloginfo('version'),
     73            'plugin_version' => $plugin_data['Version'],   
     74        ));
     75           
     76    }   
    6577}
  • triplelift-native-advertising/trunk/triplelift/library/api.php

    r761046 r786070  
    3737        $ch = curl_init();
    3838        curl_setopt($ch, CURLOPT_URL, TRIPLELIFT_NP_API_URL.$path);
    39         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Auth-token: '.$this->_token));
     39        if (isset($this->_token)) {
     40            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Auth-token: '.$this->_token));
     41        }
    4042        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    4143        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
     
    4749        $ch = curl_init();
    4850        curl_setopt($ch, CURLOPT_URL, TRIPLELIFT_NP_API_URL.$path);
    49         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Auth-token: '.$this->_token));
     51        if (isset($this->_token)) {
     52            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Auth-token: '.$this->_token));
     53        }
    5054        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    5155        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  • triplelift-native-advertising/trunk/triplelift/library/injection.php

    r781404 r786070  
    55    public $options_field = TRIPLELIFT_NP_OPTIONS_OBJECT_FIELD, $options_object, $tags;
    66    public $post_count = 0, $eligible_tags;
     7
     8    public $debug = false;
     9    public $debug_output = array();
    710
    811    public $wp_fields =  array(
     
    3235            }
    3336        }
     37        if (isset($this->options_object['debug_mode']) && $this->options_object['debug_mode'] && isset($_GET['tripleliftDebug']) && $_GET['tripleliftDebug'] ) {
     38            $this->debug = true;
     39            $this->debug_output['options_object'] = $this->options_object;
     40            $this->debug_output['time_started'] = date("Y-m-d H:i:s");
     41            $this->debug_output['theme'] = get_current_theme();
     42            $this->debug_output['blog_title'] = get_bloginfo('name');
     43            $this->debug_output['url'] = get_bloginfo('url');
     44            $this->debug_output['charset'] = get_bloginfo('charset');
     45            $this->debug_output['wpversion'] = get_bloginfo('version');
     46            $this->debug_output['all_tags'] = $this->tags;
     47            $this->debug_output['tag_debug_log'] = array();
     48            $this->debug_output['post_debug_log'] = array();
     49            $this->debug_output['path'] = parse_url(get_bloginfo( 'url' ), PHP_URL_PATH);
     50            add_action( 'wp_footer' , array('triplelift_np_injection', 'debug_output' ) );
     51        }
    3452        $this->find_eligible_tags();
    3553        add_action ( 'init' , array('triplelift_np_injection', 'inject_init' ) );
     54
    3655    }   
    3756
     
    3958        $this->eligible_tags = array();
    4059        $path = parse_url(get_bloginfo( 'url' ), PHP_URL_PATH);
    41 
     60       
    4261        foreach ($this->tags as $curr_tag) {
    4362            $ineligible = false;
    4463            $path_match = false;
     64            if ($this->debug) {
     65                $curr_tag_debug = array();
     66                $curr_tag_debug['admin_preview'] = $curr_tag['admin_preview'];
     67                $curr_tag_debug['is_admin'] = is_admin();
     68                $curr_tag_debug['active'] = $curr_tag['active'];
     69                $curr_tag_debug['tag'] = $curr_tag;
     70               
     71            }
     72       
    4573            if ((($curr_tag['admin_preview'] && is_admin()) || !$curr_tag['admin_preview']) && $curr_tag['active'])  {
     74                if ($this->debug) {$curr_tag_debug['branch_1'] = true;}
    4675                if (!$ineligible && !$to_add) {
     76                   
     77                    if ($this->debug) {$curr_tag_debug['branch_2'] = true;}
    4778                    if (is_array($curr_tag['exclude_path']) && count($curr_tag['exclude_path'])) {
     79                       
     80                        if ($this->debug) {$curr_tag_debug['branch_3'] = true;}
    4881                        foreach ($curr_tag['exclude_path'] as $curr_path) {
    4982                            if (strlen($curr_path) && strpos($path,$curr_path) !== false) {
     83                                   
     84                                if ($this->debug) {$curr_tag_debug['branch_4'] = true;}
    5085                                $ineligible = true;
    5186                                break;
     
    5489                    }
    5590                    if (is_array($curr_tag['include_path']) && count($curr_tag['include_path'])) {
     91                           
     92                        if ($this->debug) {$curr_tag_debug['branch_5'] = true;}
    5693                        foreach ($curr_tag['include_path'] as $curr_path) {
    5794                            if (strlen($curr_path) && strpos($path,$curr_path) !== false) {
     95                                   
     96                                if ($this->debug) {$curr_tag_debug['branch_6'] = true;}
    5897                                $path_match = true;
    5998                                break;
     
    61100                        }
    62101                    }
    63 
    64102                }
    65 
     103   
     104                if ($this->debug) {$curr_tag_debug['post_ineligible'] = $ineligible;}
    66105                if (!$ineligible) $this->eligible_tags[] = array(
    67106                    'script' => $curr_tag['script'],
     
    74113                );
    75114            }
    76            
     115            if ($this->debug) {
     116                array_push($this->debug_output['tag_debug_log'], $curr_tag_debug);
     117                $this->debug_output['eligible_tags'] = $this->eligible_tags;
     118            }
    77119        }
    78120    }
     121
     122    function debug_output() {
     123        global $triplelift_np_injection_register;
     124        print '<script>console.log('. json_encode($triplelift_np_injection_register->debug_output).')</script>';
     125    }
    79126
    80127    function inject_native_ad($content, $hook_type) {
     
    82129        global $triplelift_np_injection_register;
    83130        $injection =& $triplelift_np_injection_register;
     131        if ($injection->debug) {
     132            $curr_post_debug = array();
     133            $curr_post_debug['content'] = $content;
     134            $curr_post_debug['hook_type'] = $hook_type;
     135            $curr_post_debug['page_post_type'] = array(
     136                'is_home' => is_home(),
     137                'is_front_page' => is_front_page(),
     138                'is_404' => is_404(),
     139                'is_archive' => is_archive(),
     140                'is_author' => is_author(),
     141                'is_category' => is_category(),
     142                'is_comments_popup' => is_comments_popup(),
     143                'is_search' => is_search(),
     144                'is_singular' => is_singular(),
     145                'is_tag' => is_tag(),
     146                'is_time' => is_time(),
     147                'is_year' => is_year()
     148            );
     149            $curr_post_debug['eligible_tag_debug_log'] = array();
     150            $curr_eligible_tag = array();
     151        }
    84152        foreach ($injection->eligible_tags as $curr_tag) {
    85153            $include_match = false;
    86154            $ineligible = false;
     155            if ($injection->debug) {
     156                $curr_eligible_tag = array();
     157                $curr_eligible_tag['tag'] = $curr_tag; 
     158            }
    87159            if ($curr_tag['hook'] == $hook_type) {
     160               
     161                if ($injection->debug) {$curr_eligible_tag['branch_1'] = true;}
    88162                foreach ($injection->wp_fields as $curr_field) {
     163                    if ($injection->debug) {$curr_eligible_tag[$curr_field] = $curr_field();}
    89164                    if ($curr_tag['wp_page_type_exclude'][$curr_field] && $curr_field()) {
     165                       
     166                        if ($injection->debug) {$curr_eligible_tag['branch_2'] = true;}
    90167                        $ineligible = true;
    91168                        break;
    92169                    }
    93170                    if ($curr_tag['wp_page_type_include'][$curr_field] && $curr_field()) {
     171                       
     172                        if ($injection->debug) {$curr_eligible_tag['branch_3'] = true;}
    94173                        $include_match = true;
    95174                        break;
     
    98177
    99178                if (!$ineligible && ($include_match || $curr_tag['path_match'])) {
     179                   
     180                    if ($injection->debug) {$curr_eligible_tag['branch_4'] = true;}
    100181                    // we got a match
    101182                    // are we doing offset stuff
    102183                    if (isset($curr_tag['offset']) && $curr_tag['offset'] != 'n/a') {
     184                       
     185                        if ($injection->debug) {$curr_eligible_tag['branch_5'] = true;}
    103186                        if ($injection->post_count <= $curr_tag['offset']) {
    104                             if ($injection->post_count == $curr_tag['offset']) {
     187                           
     188                            if ($injection->debug) {$curr_eligible_tag['branch_6'] = true;}
     189                            if ($injection->post_count == $curr_tag['offset']) {
     190                               
     191                                if ($injection->debug) {$curr_eligible_tag['branch_7'] = true;}
    105192                                $injection->post_count++;
    106193                                return $content.html_entity_decode(stripslashes($curr_tag['script']));
    107194                            }   
    108195                        } else {
    109                             if ( ($injection->post_count - $curr_tag['offset']) % $curr_tag['interval'] == 0 && $injection->post_count > 0) {
     196                           
     197                            if ($injection->debug) {$curr_eligible_tag['branch_8'] = true;}
     198                            if ( ($injection->post_count - $curr_tag['offset']) % $curr_tag['interval'] == 0 && $injection->post_count > 0) {
     199                               
     200                                if ($injection->debug) {$curr_eligible_tag['branch_9'] = true;}
    110201                                $injection->post_count++;
    111202                                return $content.html_entity_decode(stripslashes($curr_tag['script']));
     
    114205                        }
    115206                    } else {
    116                         if ($injection->post_count % $curr_tag['interval'] == 0 && $injection->post_count > 0) {
     207                       
     208                        if ($injection->debug) {$curr_eligible_tag['branch_10'] = true;}
     209                        if ($injection->post_count % $curr_tag['interval'] == 0 && $injection->post_count > 0) {
     210                           
     211                            if ($injection->debug) {$curr_eligible_tag['branch_11'] = true;}
    117212                            $injection->post_count++;
    118213                            return $content.html_entity_decode(stripslashes($curr_tag['script']));
     
    120215                    }
    121216                   
    122 
    123217                    $injection->post_count++;
    124218                    break;
     
    126220
    127221            }
     222            if ($injection->debug) {
     223                array_push($curr_post_debug['eligible_tag_debug_log'], $curr_eligible_tag);
     224            }
    128225        }
     226        array_push($injection->debug_output['post_debug_log'], $curr_post_debug);
    129227        return $content;
    130228    }
  • triplelift-native-advertising/trunk/triplelift/library/router.php

    r781404 r786070  
    77    public $options_object, $active, $initialized, $tags, $theme, $blog_host;
    88
    9     public $tabs = array( 'manage_tags' => 'Manage Tags', 'new_tag' => 'Create New Tag');
     9    public $tabs = array(
     10        'manage_tags' => 'Manage Tags',
     11        'new_tag' => 'Create New Tag',
     12        'settings' => 'General Settings'
     13    );
    1014    public $active_page = 'manage_tags';
    1115
     
    153157                    break;
    154158
    155                case 'manage_tags':
     159                case 'manage_tags':
    156160                    $page_action = 'include';
    157161                    $page_include = 'html/manage_tags.php';
     162                    break;
     163
     164                case 'settings':
     165                    $this->active_page = 'settings';
     166                    $page_action = 'include';
     167                    $page_include = 'html/general_settings.php';
     168                    break;
     169
     170                case 'modify_general_settings':
     171                    $this->options_object['debug_mode'] = isset($_POST['triplelift_np_admin_global_debug']) ? $_POST['triplelift_np_admin_global_debug'] : false;
     172                    update_option( $this->options_field, $this->options_object );
     173                    $this->debug_mode = $this->options_object['debug_mode'];
     174                    $this->active_page = 'settings';
     175                    $page_action = 'include';
     176                    $page_include = 'html/general_settings.php';
    158177                    break;
    159178
  • triplelift-native-advertising/trunk/triplelift/readme.txt

    r781404 r786070  
    44Requires at least: 3.2.
    55Tested up to: 3.6.1
    6 Stable tag: 1.3
     6Stable tag: 1.4.1
    77License: MIT
    88
     
    6868== Changelog ==
    6969
     70= 1.4 =
     71* Debug Mode
     72* New page signup
     73
    7074= 1.3 =
    7175* Polish UI
  • triplelift-native-advertising/trunk/triplelift/triplelift.php

    r781404 r786070  
    33Plugin Name: TripleLift Native Advertising
    44Plugin URI: http://www.triplelift.com/
    5 Version: 1.3
     5Version: 1.4.1
    66Author: Triple Lift, Inc.
    77Description: TripleLift enables integrated native advertising that fits beautifully without the layout of your site
     
    4949}
    5050
     51register_activation_hook( __FILE__, array( 'Triplelift_np_admin_register', 'install_plugin' ) );
Note: See TracChangeset for help on using the changeset viewer.