Changeset 786070
- Timestamp:
- 10/10/2013 07:47:04 PM (12 years ago)
- Location:
- triplelift-native-advertising/trunk/triplelift
- Files:
-
- 1 added
- 6 edited
-
html/general_settings.php (added)
-
library/admin_register.php (modified) (1 diff)
-
library/api.php (modified) (2 diffs)
-
library/injection.php (modified) (11 diffs)
-
library/router.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
triplelift.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
triplelift-native-advertising/trunk/triplelift/library/admin_register.php
r761046 r786070 62 62 } 63 63 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 } 65 77 } -
triplelift-native-advertising/trunk/triplelift/library/api.php
r761046 r786070 37 37 $ch = curl_init(); 38 38 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 } 40 42 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 41 43 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); … … 47 49 $ch = curl_init(); 48 50 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 } 50 54 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 51 55 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); -
triplelift-native-advertising/trunk/triplelift/library/injection.php
r781404 r786070 5 5 public $options_field = TRIPLELIFT_NP_OPTIONS_OBJECT_FIELD, $options_object, $tags; 6 6 public $post_count = 0, $eligible_tags; 7 8 public $debug = false; 9 public $debug_output = array(); 7 10 8 11 public $wp_fields = array( … … 32 35 } 33 36 } 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 } 34 52 $this->find_eligible_tags(); 35 53 add_action ( 'init' , array('triplelift_np_injection', 'inject_init' ) ); 54 36 55 } 37 56 … … 39 58 $this->eligible_tags = array(); 40 59 $path = parse_url(get_bloginfo( 'url' ), PHP_URL_PATH); 41 60 42 61 foreach ($this->tags as $curr_tag) { 43 62 $ineligible = false; 44 63 $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 45 73 if ((($curr_tag['admin_preview'] && is_admin()) || !$curr_tag['admin_preview']) && $curr_tag['active']) { 74 if ($this->debug) {$curr_tag_debug['branch_1'] = true;} 46 75 if (!$ineligible && !$to_add) { 76 77 if ($this->debug) {$curr_tag_debug['branch_2'] = true;} 47 78 if (is_array($curr_tag['exclude_path']) && count($curr_tag['exclude_path'])) { 79 80 if ($this->debug) {$curr_tag_debug['branch_3'] = true;} 48 81 foreach ($curr_tag['exclude_path'] as $curr_path) { 49 82 if (strlen($curr_path) && strpos($path,$curr_path) !== false) { 83 84 if ($this->debug) {$curr_tag_debug['branch_4'] = true;} 50 85 $ineligible = true; 51 86 break; … … 54 89 } 55 90 if (is_array($curr_tag['include_path']) && count($curr_tag['include_path'])) { 91 92 if ($this->debug) {$curr_tag_debug['branch_5'] = true;} 56 93 foreach ($curr_tag['include_path'] as $curr_path) { 57 94 if (strlen($curr_path) && strpos($path,$curr_path) !== false) { 95 96 if ($this->debug) {$curr_tag_debug['branch_6'] = true;} 58 97 $path_match = true; 59 98 break; … … 61 100 } 62 101 } 63 64 102 } 65 103 104 if ($this->debug) {$curr_tag_debug['post_ineligible'] = $ineligible;} 66 105 if (!$ineligible) $this->eligible_tags[] = array( 67 106 'script' => $curr_tag['script'], … … 74 113 ); 75 114 } 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 } 77 119 } 78 120 } 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 } 79 126 80 127 function inject_native_ad($content, $hook_type) { … … 82 129 global $triplelift_np_injection_register; 83 130 $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 } 84 152 foreach ($injection->eligible_tags as $curr_tag) { 85 153 $include_match = false; 86 154 $ineligible = false; 155 if ($injection->debug) { 156 $curr_eligible_tag = array(); 157 $curr_eligible_tag['tag'] = $curr_tag; 158 } 87 159 if ($curr_tag['hook'] == $hook_type) { 160 161 if ($injection->debug) {$curr_eligible_tag['branch_1'] = true;} 88 162 foreach ($injection->wp_fields as $curr_field) { 163 if ($injection->debug) {$curr_eligible_tag[$curr_field] = $curr_field();} 89 164 if ($curr_tag['wp_page_type_exclude'][$curr_field] && $curr_field()) { 165 166 if ($injection->debug) {$curr_eligible_tag['branch_2'] = true;} 90 167 $ineligible = true; 91 168 break; 92 169 } 93 170 if ($curr_tag['wp_page_type_include'][$curr_field] && $curr_field()) { 171 172 if ($injection->debug) {$curr_eligible_tag['branch_3'] = true;} 94 173 $include_match = true; 95 174 break; … … 98 177 99 178 if (!$ineligible && ($include_match || $curr_tag['path_match'])) { 179 180 if ($injection->debug) {$curr_eligible_tag['branch_4'] = true;} 100 181 // we got a match 101 182 // are we doing offset stuff 102 183 if (isset($curr_tag['offset']) && $curr_tag['offset'] != 'n/a') { 184 185 if ($injection->debug) {$curr_eligible_tag['branch_5'] = true;} 103 186 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;} 105 192 $injection->post_count++; 106 193 return $content.html_entity_decode(stripslashes($curr_tag['script'])); 107 194 } 108 195 } 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;} 110 201 $injection->post_count++; 111 202 return $content.html_entity_decode(stripslashes($curr_tag['script'])); … … 114 205 } 115 206 } 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;} 117 212 $injection->post_count++; 118 213 return $content.html_entity_decode(stripslashes($curr_tag['script'])); … … 120 215 } 121 216 122 123 217 $injection->post_count++; 124 218 break; … … 126 220 127 221 } 222 if ($injection->debug) { 223 array_push($curr_post_debug['eligible_tag_debug_log'], $curr_eligible_tag); 224 } 128 225 } 226 array_push($injection->debug_output['post_debug_log'], $curr_post_debug); 129 227 return $content; 130 228 } -
triplelift-native-advertising/trunk/triplelift/library/router.php
r781404 r786070 7 7 public $options_object, $active, $initialized, $tags, $theme, $blog_host; 8 8 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 ); 10 14 public $active_page = 'manage_tags'; 11 15 … … 153 157 break; 154 158 155 case 'manage_tags':159 case 'manage_tags': 156 160 $page_action = 'include'; 157 161 $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'; 158 177 break; 159 178 -
triplelift-native-advertising/trunk/triplelift/readme.txt
r781404 r786070 4 4 Requires at least: 3.2. 5 5 Tested up to: 3.6.1 6 Stable tag: 1. 36 Stable tag: 1.4.1 7 7 License: MIT 8 8 … … 68 68 == Changelog == 69 69 70 = 1.4 = 71 * Debug Mode 72 * New page signup 73 70 74 = 1.3 = 71 75 * Polish UI -
triplelift-native-advertising/trunk/triplelift/triplelift.php
r781404 r786070 3 3 Plugin Name: TripleLift Native Advertising 4 4 Plugin URI: http://www.triplelift.com/ 5 Version: 1. 35 Version: 1.4.1 6 6 Author: Triple Lift, Inc. 7 7 Description: TripleLift enables integrated native advertising that fits beautifully without the layout of your site … … 49 49 } 50 50 51 register_activation_hook( __FILE__, array( 'Triplelift_np_admin_register', 'install_plugin' ) );
Note: See TracChangeset
for help on using the changeset viewer.