Changeset 1382226
- Timestamp:
- 03/30/2016 07:43:24 PM (10 years ago)
- Location:
- adobe-dtm/trunk
- Files:
-
- 3 edited
-
adobe-dtm.php (modified) (7 diffs)
-
dtm.php (modified) (17 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
adobe-dtm/trunk/adobe-dtm.php
r1381562 r1382226 2 2 /* 3 3 Plugin Name: Adobe DTM for Wordpress 4 Version: 1. 24 Version: 1.3 5 5 Plugin URI: http://www.searchdiscovery.com/adobe-dtm-for-wordpress/ 6 6 Description: The first Adobe Dynamic Tag Management (DTM) plugin for WordPress. … … 9 9 */ 10 10 11 define('SDIDTM_VERSION', '1. 2');11 define('SDIDTM_VERSION', '1.3'); 12 12 define('SDIDTM_PATH', plugin_dir_path(__FILE__)); 13 13 … … 27 27 if($isAssoc == true){ 28 28 foreach($options as $opt){ 29 $value = $dtmSaved[$opt['name']];29 $value = isset($dtmSaved[$opt['name']]) ? $dtmSaved[$opt['name']] : ''; 30 30 if(!$value){ 31 31 $value = $opt['default']; … … 35 35 } 36 36 $newOptions[$opt['name']] = $opt; 37 $newOptions[$opt['name']]['value'] = $value; 37 $newOptions[$opt['name']]['value'] = $value; 38 38 } 39 39 } … … 41 41 if($type == 'config'){ 42 42 foreach($options as $opt){ 43 if( $dtmSaved && $dtmSaved[$opt['name']]){43 if(isset($dtmSaved) && isset($dtmSaved[$opt['name']])){ 44 44 $opt['value'] = $dtmSaved[$opt['name']]; 45 45 } … … 58 58 $chk = $opt; 59 59 $ipt = $opt; 60 if( $dtmSaved && $dtmSaved['include-'.$opt['name']]){60 if(isset($dtmSaved) && isset($dtmSaved['include-'.$opt['name']])){ 61 61 $chk['value'] = $dtmSaved['include-'.$opt['name']]; 62 62 } … … 86 86 else if($type == 'disable'){ 87 87 foreach($options as $opt){ 88 if(isset($dtmSaved) && $dtmSaved['disable-'.$opt['name']]){88 if(isset($dtmSaved) && isset($dtmSaved['disable-'.$opt['name']])){ 89 89 $opt['value'] = $dtmSaved['disable-'.$opt['name']]; 90 90 } -
adobe-dtm/trunk/dtm.php
r1067347 r1382226 1 1 <?php 2 global $dtm ;2 global $dtm, $v; 3 3 4 4 function SDIDTM_checked( $args ){ … … 31 31 } 32 32 if($d['code'] == 'guest' && count($current_user->roles) == 0){ 33 if(SDIDTM_checked($v)){ 34 $isDisabled = true; 35 } 33 if(isset($v)){ 34 if(SDIDTM_checked($v)){ 35 $isDisabled = true; 36 } 37 } 36 38 } 37 39 } … … 98 100 $s = $dtmSaved; 99 101 100 $postType = SDIDTM_include($s['include-posttype']);101 $postLbl = SDIDTM_value($data['posttype']);102 $subPostType = SDIDTM_include($s['include-postsubtype']);103 $subPostLbl = SDIDTM_value($data['postsubtype']);102 $postType = isset($s['include-posttype']) ? SDIDTM_include($s['include-posttype']) : ''; 103 $postLbl = isset($data['posttype']) ? SDIDTM_value($data['posttype']) : ''; 104 $subPostType = isset($s['include-postsubtype']) ? SDIDTM_include($s['include-postsubtype']) : ''; 105 $subPostLbl = isset($data['postsubtype']) ? SDIDTM_value($data['postsubtype']) : ''; 104 106 105 107 if(SDIDTM_disable()){ … … 108 110 109 111 $date = array(); 110 111 if (SDIDTM_include($s['include-loggedin'])) { 112 if (is_user_logged_in()) { 113 $dataLayer[SDIDTM_value($data['loggedin'])] = "logged-in"; 114 } else { 115 $dataLayer[SDIDTM_value($data['loggedin'])] = "logged-out"; 116 } 117 } 118 119 if (SDIDTM_include($s['include-userrole'])) { 120 get_currentuserinfo(); 121 $dataLayer[SDIDTM_value($data['userrole'])] = ($current_user->roles[0] == NULL ? "guest" : $current_user->roles[0]); 122 } 123 124 if (SDIDTM_include($s['include-posttitle'])) { 125 $dataLayer[SDIDTM_value($data['posttitle'])] = strip_tags(wp_title("|", false, "right")); 112 113 if(isset($s['include-loggedin'])){ 114 if (SDIDTM_include($s['include-loggedin'])) { 115 if (is_user_logged_in()) { 116 $dataLayer[SDIDTM_value($data['loggedin'])] = "logged-in"; 117 } else { 118 $dataLayer[SDIDTM_value($data['loggedin'])] = "logged-out"; 119 } 120 } 121 } 122 123 if(isset($s['include-userrole'])){ 124 if (SDIDTM_include($s['include-userrole'])) { 125 get_currentuserinfo(); 126 $dataLayer[SDIDTM_value($data['userrole'])] = ($current_user->roles[0] == NULL ? "guest" : $current_user->roles[0]); 127 } 128 } 129 130 if(isset($s['include-posttitle'])){ 131 if (SDIDTM_include($s['include-posttitle'])) { 132 $dataLayer[SDIDTM_value($data['posttitle'])] = strip_tags(wp_title("|", false, "right")); 133 } 126 134 } 127 135 … … 131 139 } 132 140 133 if(SDIDTM_include($s['include-custom'])){ 134 $meta = get_post_custom(); 135 $newmeta = array(); 136 foreach($meta as $mn=>$mv){ 137 if(strpos($mn, "_edit_")===false && strpos($mn, "_wp_")===false){ 138 $newmeta[$mn] = $mv; 139 } 140 } 141 $dataLayer[SDIDTM_value($data['custom'])] = $newmeta; 141 if(isset($s['include-custom'])){ 142 if(SDIDTM_include($s['include-custom'])){ 143 $meta = get_post_custom(); 144 $newmeta = array(); 145 foreach($meta as $mn=>$mv){ 146 if(strpos($mn, "_edit_")===false && strpos($mn, "_wp_")===false){ 147 $newmeta[$mn] = $mv; 148 } 149 } 150 $dataLayer[SDIDTM_value($data['custom'])] = $newmeta; 151 } 142 152 } 143 153 … … 149 159 } 150 160 151 if(SDIDTM_include($s['include-comments'])){ 152 if(comments_open()){ 153 $dataLayer[SDIDTM_value($data['comments'])] = get_comments_number(); 154 } 155 } 156 157 if (SDIDTM_include($s['include-categories'])) { 158 $_post_cats = get_the_category(); 159 if ($_post_cats) { 160 $dataLayer[SDIDTM_value($data['categories'])] = array(); 161 foreach ($_post_cats as $_one_cat) { 162 $dataLayer[SDIDTM_value($data['categories'])][] = $_one_cat->slug; 163 } 164 } 165 } 166 167 if (SDIDTM_include($s['include-tags'])) { 168 $_post_tags = get_the_tags(); 169 if ($_post_tags) { 170 $dataLayer[SDIDTM_value($data['tags'])] = array(); 171 foreach ($_post_tags as $tag) { 172 $dataLayer[SDIDTM_value($data['tags'])][] = $tag->slug; 173 } 174 } 175 } 176 177 if (SDIDTM_include($s['include-author'])) { 178 $postuser = get_userdata($GLOBALS["post"]->post_author); 179 if (false !== $postuser) { 180 $dataLayer[SDIDTM_value($data['author'])] = $postuser->display_name; 181 } 182 } 183 161 if(isset($s['include-comments'])){ 162 if(SDIDTM_include($s['include-comments'])){ 163 if(comments_open()){ 164 $dataLayer[SDIDTM_value($data['comments'])] = get_comments_number(); 165 } 166 } 167 } 168 169 if(isset($s['include-categories'])){ 170 if (SDIDTM_include($s['include-categories'])) { 171 $_post_cats = get_the_category(); 172 if ($_post_cats) { 173 $dataLayer[SDIDTM_value($data['categories'])] = array(); 174 foreach ($_post_cats as $_one_cat) { 175 $dataLayer[SDIDTM_value($data['categories'])][] = $_one_cat->slug; 176 } 177 } 178 } 179 } 180 181 if(isset($s['include-tags'])){ 182 if (SDIDTM_include($s['include-tags'])) { 183 $_post_tags = get_the_tags(); 184 if ($_post_tags) { 185 $dataLayer[SDIDTM_value($data['tags'])] = array(); 186 foreach ($_post_tags as $tag) { 187 $dataLayer[SDIDTM_value($data['tags'])][] = $tag->slug; 188 } 189 } 190 } 191 } 192 193 if(isset($s['include-author'])){ 194 if (SDIDTM_include($s['include-author'])) { 195 $postuser = get_userdata($GLOBALS["post"]->post_author); 196 if (false !== $postuser) { 197 $dataLayer[SDIDTM_value($data['author'])] = $postuser->display_name; 198 } 199 } 200 } 201 184 202 $date["date"] = get_the_date(); 185 203 $date["year"] = get_the_date("Y"); … … 187 205 $date["day"] = get_the_date("d"); 188 206 } 189 207 190 208 if (is_archive() || is_post_type_archive()) { 191 209 if ($postType) { 192 210 $dataLayer[$postLbl] = get_post_type(); 193 211 194 212 if (is_category()) { 195 213 $dataLayer[$subPostLbl] = "category-" . get_post_type(); … … 202 220 } else if (is_year()) { 203 221 $dataLayer[$subPostLbl] = "year-" . get_post_type(); 204 222 205 223 $date["year"] = get_the_date("Y"); 206 224 } else if (is_month()) { … … 210 228 } else if (is_day()) { 211 229 $dataLayer[$subPostLbl] = "day-" . get_post_type(); 212 230 213 231 $date["date"] = get_the_date(); 214 232 $date["year"] = get_the_date("Y"); … … 219 237 } else if (is_date()) { 220 238 $dataLayer[$subPostLbl] = "date-" . get_post_type(); 221 239 222 240 $date["date"] = get_the_date(); 223 241 $date["year"] = get_the_date("Y"); … … 226 244 } 227 245 } 228 246 229 247 if ((is_tax() || is_category()) && $SDIDTM_options[SDIDTM_include($s['include-categories'])]) { 230 248 $_post_cats = get_the_category(); … … 234 252 } 235 253 } 236 254 237 255 if (SDIDTM_include($s['include-author']) && (is_author())) { 238 256 $dataLayer[SDIDTM_value($data['author'])] = get_the_author(); 239 257 } 240 258 } 241 259 242 260 if (is_search()) { 243 261 if(SDIDTM_include($s['include-searchterm'])){ … … 251 269 } 252 270 } 253 271 254 272 if (is_front_page() && $postType) { 255 273 $dataLayer[$postLbl] = "homepage"; 256 274 } 257 275 258 276 if (!is_front_page() && is_home() && $postType) { 259 277 $dataLayer[$postLbl] = "blog-home"; 260 278 } 261 262 if (SDIDTM_include($s['include-postcount'])) { 263 $dataLayer[SDIDTM_value($data['postcount'])] = (int)$wp_query->post_count; 264 // $dataLayer["postCountTotal"] = (int)$wp_query->found_posts; 265 } 266 267 if (SDIDTM_include($s['include-postdate']) && count($date)>0) { 268 $dataLayer[SDIDTM_value($data['postdate'])] = $date; 269 } 270 279 280 if(isset($s['include-postcount'])){ 281 if (SDIDTM_include($s['include-postcount'])) { 282 $dataLayer[SDIDTM_value($data['postcount'])] = (int)$wp_query->post_count; 283 // $dataLayer["postCountTotal"] = (int)$wp_query->found_posts; 284 } 285 } 286 287 if(isset($s['include-postdate'])){ 288 if (SDIDTM_include($s['include-postdate']) && count($date)>0) { 289 $dataLayer[SDIDTM_value($data['postdate'])] = $date; 290 } 291 } 292 271 293 return $dataLayer; 272 294 } … … 275 297 global $dtm; 276 298 $config = SDIDTM_get_options('config', true); 277 299 278 300 $dataLayer = array(); 279 301 $dataLayer = (array)apply_filters("sdidtm_build_datalayer", $dataLayer); 280 302 281 303 $_dtm_header_content = ''; 282 304 283 305 if ($config['dtm-code']['value'] != "" && !SDIDTM_disable()) { 284 306 $_dtm_header_content.= ' … … 292 314 } 293 315 } 294 295 echo $_dtm_header_content ;316 317 echo $_dtm_header_content."\n<meta name=\"adobe-dtm-wordpress\" content=\"true\">"; 296 318 } 297 319 … … 300 322 global $dtm; 301 323 $config = SDIDTM_get_options('config', true); 302 324 303 325 $_dtm_tag = ''; 304 326 305 327 if ($config['dtm-code']['value'] != "" && !SDIDTM_checked($config['include-dtm-exists']) && !SDIDTM_disable()) { 306 328 $_dtm_tag.= ' … … 311 333 </script>'; 312 334 } 313 335 314 336 echo $_dtm_tag; 315 337 } -
adobe-dtm/trunk/readme.txt
r1072944 r1382226 49 49 == Changelog == 50 50 51 = 1.3 = 52 Updated code for servers with very strict PHP settings to prevent errors. Also added a meta tag with name "adobe-dtm-wordpress" to easily identify if the plugin is installed successfully. 53 51 54 = 1.1 = 52 55 Code enhancements.
Note: See TracChangeset
for help on using the changeset viewer.