| @@ -1,118 +1,236 @@ | ||
| 1 | 1 | <?php |
| 2 | -function tcm_ui_editor() { | |
| 3 | - global $tcm; | |
| 2 | +function tcmp_notice_pro_features() { | |
| 3 | + global $tcmp; | |
| 4 | + ?> | |
| 5 | + <br/> | |
| 6 | + <div class="message updated below-h2 iwp"> | |
| 7 | + <div style="height:10px;"></div> | |
| 8 | + <?php | |
| 9 | + $i=1; | |
| 10 | + while($tcmp->Lang->H('Notice.ProHeader'.$i)) { | |
| 11 | + $tcmp->Lang->P('Notice.ProHeader'.$i); | |
| 12 | + echo '<br/>'; | |
| 13 | + ++$i; | |
| 14 | + } | |
| 15 | + $i=1; | |
| 16 | + ?> | |
| 17 | + <br/> | |
| 18 | + <?php | |
| 4 | 19 | |
| 5 | - $tcm->Form->prefix = 'Editor'; | |
| 6 | - $id = intval($tcm->Utils->qs('id', 0)); | |
| 7 | - $action = $tcm->Utils->qs('action'); | |
| 8 | - $snippet = $tcm->Manager->get($id, TRUE); | |
| 9 | - //var_dump($snippet); | |
| 20 | + /*$options = array('public' => TRUE, '_builtin' => FALSE); | |
| 21 | + $q=get_post_types($options, 'names'); | |
| 22 | + if(is_array($q) && count($q)>0) { | |
| 23 | + sort($q); | |
| 24 | + $q=implode(', ', $q); | |
| 25 | + $q='(<b>'.$q.'</b>)'; | |
| 26 | + } else { | |
| 27 | + $q=''; | |
| 28 | + }*/ | |
| 29 | + $q=''; | |
| 30 | + while($tcmp->Lang->H('Notice.ProFeature'.$i)) { ?> | |
| 31 | + <div style="clear:both; margin-top: 2px;"></div> | |
| 32 | + <div style="float:left; vertical-align:middle; height:24px; margin-right:5px; margin-top:-5px;"> | |
| 33 | + <img src="<?php echo TCMP_PLUGIN_IMAGES_URI?>tick.png" /> | |
| 34 | + </div> | |
| 35 | + <div style="float:left; vertical-align:middle; height:24px;"> | |
| 36 | + <?php $tcmp->Lang->P('Notice.ProFeature'.$i, $q)?> | |
| 37 | + </div> | |
| 38 | + <?php ++$i; | |
| 39 | + } | |
| 40 | + ?> | |
| 41 | + <div style="clear:both;"></div> | |
| 42 | + <div style="height:10px;"></div> | |
| 43 | + <div style="float:right;"> | |
| 44 | + <?php | |
| 45 | + $url=TCMP_PAGE_PREMIUM.'?utm_source=free-users&utm_medium=wp-cta&utm_campaign=wp-plugin'; | |
| 46 | + ?> | |
| 47 | + <a href="<?php echo $url?>" target="_blank"> | |
| 48 | + <b><?php $tcmp->Lang->P('Notice.ProCTA')?></b> | |
| 49 | + </a> | |
| 50 | + </div> | |
| 51 | + <div style="height:10px; clear:both;"></div> | |
| 52 | + </div> | |
| 53 | + <br/> | |
| 54 | +<?php } | |
| 55 | +function tcmp_ui_editor_check($snippet) { | |
| 56 | + global $tcmp; | |
| 10 | 57 | |
| 11 | - if (wp_verify_nonce($tcm->Utils->qs('tcm_nonce'), 'tcm_nonce')) { | |
| 12 | - //var_dump($_POST); | |
| 13 | - //var_dump($_GET); | |
| 14 | - foreach ($snippet as $k => $v) { | |
| 15 | - $snippet[$k] = $tcm->Utils->qs($k); | |
| 16 | - if (is_string($snippet[$k])) { | |
| 17 | - $snippet[$k] = stripslashes($snippet[$k]); | |
| 58 | + $snippet['trackMode']=intval($snippet['trackMode']); | |
| 59 | + $snippet['trackPage']=intval($snippet['trackPage']); | |
| 60 | + | |
| 61 | + $snippet['includeEverywhereActive']=0; | |
| 62 | + if($snippet['trackPage']==TCMP_TRACK_PAGE_ALL) { | |
| 63 | + $snippet['includeEverywhereActive']=1; | |
| 64 | + } | |
| 65 | + $snippet=$tcmp->Manager->sanitize($snippet['id'], $snippet); | |
| 66 | + | |
| 67 | + if ($snippet['name'] == '') { | |
| 68 | + $tcmp->Options->pushErrorMessage('Please enter a unique name'); | |
| 69 | + } else { | |
| 70 | + $exist=$tcmp->Manager->exists($snippet['name']); | |
| 71 | + if ($exist && $exist['id'] != $snippet['id']) { | |
| 72 | + //nonostante il tutto il nome deve essee univoco | |
| 73 | + $tcmp->Options->pushErrorMessage('You have entered a name that already exists. IDs are NOT case-sensitive'); | |
| 74 | + } | |
| 75 | + } | |
| 76 | + if ($snippet['code'] == '') { | |
| 77 | + $tcmp->Options->pushErrorMessage('Paste your HTML Tracking Code into the textarea'); | |
| 78 | + } | |
| 79 | + | |
| 80 | + if($snippet['trackMode']==TCMP_TRACK_MODE_CODE) { | |
| 81 | + | |
| 82 | + $types=$tcmp->Utils->query(TCMP_QUERY_POST_TYPES); | |
| 83 | + if($snippet['trackPage']==TCMP_TRACK_PAGE_SPECIFIC) { | |
| 84 | + foreach ($types as $v) { | |
| 85 | + $includeActiveKey='includePostsOfType_'.$v['id'].'_Active'; | |
| 86 | + $includeArrayKey='includePostsOfType_'.$v['id']; | |
| 87 | + $exceptActiveKey='exceptPostsOfType_'.$v['id'].'_Active'; | |
| 88 | + $exceptArrayKey='exceptPostsOfType_'.$v['id']; | |
| 89 | + | |
| 90 | + if ($snippet[$includeActiveKey] == 1 && $snippet[$exceptActiveKey] == 1) { | |
| 91 | + if (in_array(-1, $snippet[$includeArrayKey]) && in_array(-1, $snippet[$exceptArrayKey])) { | |
| 92 | + $tcmp->Options->pushErrorMessage('Error.IncludeExcludeAll', $v['name']); | |
| 93 | + } | |
| 94 | + } | |
| 95 | + if ($snippet[$includeActiveKey] == 1 && count($snippet[$includeArrayKey]) == 0) { | |
| 96 | + $tcmp->Options->pushErrorMessage('Error.IncludeSelectAtLeastOne', $v['name']); | |
| 97 | + } | |
| 18 | 98 | } |
| 19 | - } | |
| 20 | 99 | |
| 21 | - if ($snippet['name'] == '') { | |
| 22 | - $tcm->Options->pushErrorMessage('Please enter a unique name'); | |
| 100 | + //second loop to respect the display order | |
| 101 | + foreach ($types as $v) { | |
| 102 | + $includeActiveKey='includePostsOfType_'.$v['id'].'_Active'; | |
| 103 | + $includeArrayKey='includePostsOfType_'.$v['id']; | |
| 104 | + $exceptActiveKey='exceptPostsOfType_'.$v['id'].'_Active'; | |
| 105 | + $exceptArrayKey='exceptPostsOfType_'.$v['id']; | |
| 106 | + | |
| 107 | + if ($snippet[$includeActiveKey] == 1 && in_array(-1, $snippet[$includeArrayKey])) { | |
| 108 | + if ($snippet[$exceptActiveKey] == 1 && count($snippet[$exceptArrayKey]) == 0) { | |
| 109 | + $tcmp->Options->pushErrorMessage('Error.ExcludeSelectAtLeastOne', $v['name']); | |
| 110 | + } | |
| 111 | + } | |
| 112 | + } | |
| 23 | 113 | } else { |
| 24 | - $exist=$tcm->Manager->exists($snippet['name']); | |
| 25 | - if ($exist && $exist['id'] != $snippet['id']) { | |
| 26 | - //nonostante il tutto il nome deve essee univoco | |
| 27 | - $tcm->Options->pushErrorMessage('You have entered a name that already exists. IDs are NOT case-sensitive'); | |
| 114 | + foreach($types as $v) { | |
| 115 | + $exceptActiveKey='exceptPostsOfType_'.$v['id'].'_Active'; | |
| 116 | + $exceptArrayKey='exceptPostsOfType_'.$v['id']; | |
| 117 | + | |
| 118 | + if(isset($snippet[$exceptActiveKey]) | |
| 119 | + && $snippet[$exceptActiveKey]==1 | |
| 120 | + && count($snippet[$exceptArrayKey])==0) { | |
| 121 | + $tcmp->Options->pushErrorMessage('Error.ExcludeSelectAtLeastOne', $v['name']); | |
| 122 | + } | |
| 28 | 123 | } |
| 29 | 124 | } |
| 30 | - if ($snippet['code'] == '') { | |
| 31 | - $tcm->Options->pushErrorMessage('Paste your HTML Tracking Code into the textarea'); | |
| 125 | + } | |
| 126 | +} | |
| 127 | +function tcmp_ui_editor() { | |
| 128 | + global $tcmp; | |
| 129 | + | |
| 130 | + $tcmp->Form->prefix='Editor'; | |
| 131 | + $id=TCMP_ISQS('id', 0); | |
| 132 | + if($id==0 && $tcmp->Manager->isLimitReached(FALSE)) { | |
| 133 | + $tcmp->Utils->redirect(TCMP_TAB_MANAGER_URI); | |
| 134 | + } | |
| 135 | + | |
| 136 | + $snippet=$tcmp->Manager->get($id, TRUE); | |
| 137 | + if (wp_verify_nonce(TCMP_QS('tcmp_nonce'), 'tcmp_nonce')) { | |
| 138 | + foreach ($snippet as $k=>$v) { | |
| 139 | + $snippet[$k]=TCMP_QS($k); | |
| 140 | + if (is_string($snippet[$k])) { | |
| 141 | + $snippet[$k]=stripslashes($snippet[$k]); | |
| 142 | + } | |
| 32 | 143 | } |
| 33 | 144 | |
| 34 | - if (!$tcm->Options->hasErrorMessages()) { | |
| 35 | - $snippet = $tcm->Manager->put($snippet['id'], $snippet); | |
| 36 | - if ($id <= 0) { | |
| 37 | - $tcm->Options->pushSuccessMessage('Editor.Add', $snippet['id'], $snippet['name']); | |
| 38 | - $snippet = $tcm->Manager->get('', TRUE); | |
| 145 | + tcmp_ui_editor_check($snippet); | |
| 146 | + if (!$tcmp->Options->hasErrorMessages()) { | |
| 147 | + $snippet=$tcmp->Manager->put($snippet['id'], $snippet); | |
| 148 | + /*if ($id <= 0) { | |
| 149 | + $tcmp->Options->pushSuccessMessage('Editor.Add', $snippet['id'], $snippet['name']); | |
| 150 | + $snippet=$tcmp->Manager->get('', TRUE); | |
| 39 | 151 | } else { |
| 40 | - $tcm->Utils->redirect(TCM_PAGE_MANAGER.'&id='.$id); | |
| 152 | + $tcmp->Utils->redirect(TCMP_PAGE_MANAGER.'&id='.$id); | |
| 41 | 153 | exit(); |
| 42 | - } | |
| 43 | - } | |
| 154 | + }*/ | |
| 155 | + $id=$snippet['id']; | |
| 156 | + $tcmp->Utils->redirect(TCMP_PAGE_MANAGER.'&id='.$id); } | |
| 44 | 157 | } |
| 45 | - $tcm->Options->writeMessages(); | |
| 46 | - | |
| 47 | - if($tcm->Manager->rc()<=0 && $id<=0) { | |
| 48 | - $tcm->Utils->redirect(TCM_PAGE_MANAGER); | |
| 49 | - exit(); | |
| 50 | - } | |
| 51 | - tcm_ui_free_notice(); | |
| 52 | - | |
| 158 | + $tcmp->Options->writeMessages() | |
| 53 | 159 | ?> |
| 54 | 160 | <script> |
| 55 | 161 | jQuery(function(){ |
| 56 | - var tcmPostTypes=[]; | |
| 57 | - | |
| 58 | - <?php | |
| 59 | - $types=$tcm->Utils->query(TCM_QUERY_POST_TYPES); | |
| 60 | - foreach($types as $v) { ?> | |
| 61 | - tcmPostTypes.push('<?php echo $v['name']?>'); | |
| 62 | - <?php } ?> | |
| 63 | - | |
| 64 | 162 | //enable/disable some part of except creating coherence |
| 65 | 163 | function tcmCheckVisible() { |
| 66 | - var showExceptCategories=true; | |
| 67 | - var showExceptTags=true; | |
| 68 | - var showExceptPostTypes={}; | |
| 69 | - jQuery.each(tcmPostTypes, function (i,v) { | |
| 70 | - showExceptPostTypes[v]=true; | |
| 71 | - }); | |
| 164 | + var $mode=jQuery('[name=trackMode]:checked'); | |
| 165 | + var showTrackCode=false; | |
| 166 | + var showTrackConversion=false; | |
| 167 | + if($mode.length>0) { | |
| 168 | + if(parseInt($mode.val())!=<?php echo TCMP_TRACK_MODE_CODE ?>) { | |
| 169 | + showTrackConversion=true; | |
| 170 | + jQuery('#position-box').hide(); | |
| 72 | 171 | |
| 73 | - var $all=jQuery('#includeEverywhereActive'); | |
| 74 | - if(!$all.is(':checked')) { | |
| 75 | - showExceptCategories=false; | |
| 76 | - showExceptTags=false; | |
| 172 | + tcmShowHide('.box-track-conversion', false); | |
| 173 | + tcmShowHide('#box-track-conversion-'+$mode.val(), true); | |
| 174 | + } else { | |
| 175 | + showTrackCode=true; | |
| 176 | + jQuery('#position-box').show(); | |
| 177 | + } | |
| 178 | + } | |
| 179 | + tcmShowHide('#box-track-conversion', showTrackConversion); | |
| 180 | + tcmShowHide('#box-track-code', showTrackCode); | |
| 77 | 181 | |
| 78 | - jQuery.each(tcmPostTypes, function (i,v) { | |
| 79 | - isCheck=jQuery('#includePostsOfType_'+v+'_Active').is(':checked'); | |
| 80 | - selection=jQuery('#includePostsOfType_'+v).select2("val"); | |
| 81 | - found=false; | |
| 82 | - for(i=0; i<selection.length; i++) { | |
| 83 | - if(parseInt(selection[i])==-1){ | |
| 84 | - found=true; | |
| 182 | + var $all=jQuery('[name=trackPage]:checked'); | |
| 183 | + if($all.length>0 && parseInt($all.val())==<?php echo TCMP_TRACK_PAGE_SPECIFIC ?>) { | |
| 184 | + showExcept=false; | |
| 185 | + jQuery('[type=checkbox]').each(function() { | |
| 186 | + var $check=jQuery(this); | |
| 187 | + var id=TCMP.attr($check, 'id', ''); | |
| 188 | + if(TCMP.startsWith(id, 'include')) { | |
| 189 | + var $select=id.replace('_Active', ''); | |
| 190 | + $select=TCMP.jQuery($select); | |
| 191 | + | |
| 192 | + isCheck=$check.is(':checked'); | |
| 193 | + selection=$select.select2('val'); | |
| 194 | + found=false; | |
| 195 | + for(i=0; i<selection.length; i++) { | |
| 196 | + if(parseInt(selection[i])==-1){ | |
| 197 | + found=true; | |
| 198 | + } | |
| 85 | 199 | } |
| 86 | - } | |
| 87 | 200 | |
| 88 | - showExceptPostTypes[v]=false; | |
| 89 | - if(isCheck && found) { | |
| 90 | - showExceptPostTypes[v]=true; | |
| 91 | - if(v!='page') { | |
| 92 | - showExceptCategories=true; | |
| 93 | - showExceptTags=true; | |
| 201 | + var $except=id.replace('_Active', ''); | |
| 202 | + $except=$except.replace('Active', '')+'Box'; | |
| 203 | + $except=$except.substr('include'.length); | |
| 204 | + $except='except'+$except; | |
| 205 | + $except=jQuery('[id='+$except+']'); | |
| 206 | + | |
| 207 | + if(found) { | |
| 208 | + showExcept=true; | |
| 209 | + if($except.length>0) { | |
| 210 | + $except.show(); | |
| 211 | + } | |
| 212 | + } else { | |
| 213 | + if($except.length>0) { | |
| 214 | + $except.hide(); | |
| 215 | + } | |
| 94 | 216 | } |
| 95 | 217 | } |
| 96 | 218 | }); |
| 97 | 219 | } |
| 98 | 220 | |
| 99 | - //hide/show except post type if all the website is selected | |
| 100 | - //or [All] is selected in a specific post type select | |
| 101 | - var showExcept=false; | |
| 102 | - jQuery.each(showExceptPostTypes, function (k,v) { | |
| 103 | - if(v) { | |
| 104 | - //at least one post type to show except | |
| 221 | + showInclude=false; | |
| 222 | + if($all.length==0) { | |
| 223 | + showExcept=false; | |
| 224 | + } else { | |
| 225 | + if(parseInt($all.val())==<?php echo TCMP_TRACK_PAGE_ALL ?>) { | |
| 105 | 226 | showExcept=true; |
| 227 | + } else { | |
| 228 | + showInclude=true; | |
| 106 | 229 | } |
| 107 | - tcmShowHide('#exceptPostsOfType_'+k+'Box', v); | |
| 108 | - }); | |
| 109 | - | |
| 110 | - tcmShowHide('#exceptCategoriesBox', showExceptCategories); | |
| 111 | - tcmShowHide('#exceptTagsBox', showExceptTags); | |
| 112 | - | |
| 113 | - showExcept=(showExcept || showExceptTags || showExceptCategories); | |
| 114 | - tcmShowHide('#tcm-except-div', showExcept); | |
| 230 | + } | |
| 231 | + tcmShowHide('#tcmp-except-div', showExcept); | |
| 232 | + tcmShowHide('#tcmp-include-div', showInclude); | |
| 115 | 233 | } |
| 116 | 234 | function tcmShowHide(selector, show) { |
| 117 | 235 | $selector=jQuery(selector); |
| 118 | 236 | if(show) { |
| @@ -127,18 +245,18 @@ | ||
| 127 | 245 | , theme: "classic" |
| 128 | 246 | }).on('change', function() { |
| 129 | 247 | tcmCheckVisible(); |
| 130 | 248 | });*/ |
| 131 | - jQuery(".tcmLineTags").select2({ | |
| 249 | + jQuery('.tcmLineTags,.tcmp-dropdown').select2({ | |
| 132 | 250 | placeholder: "Type here..." |
| 133 | 251 | , theme: "classic" |
| 134 | 252 | , width: '550px' |
| 135 | 253 | }); |
| 136 | 254 | |
| 137 | - jQuery('.tcm-hideShow').click(function() { | |
| 255 | + jQuery('.tcmp-hideShow').click(function() { | |
| 138 | 256 | tcmCheckVisible(); |
| 139 | 257 | }); |
| 140 | - jQuery('.tcm-hideShow, input[type=checkbox]').change(function() { | |
| 258 | + jQuery('.tcmp-hideShow, input[type=checkbox], input[type=radio]').change(function() { | |
| 141 | 259 | tcmCheckVisible(); |
| 142 | 260 | }); |
| 143 | 261 | jQuery('.tcmLineTags').on('change', function() { |
| 144 | 262 | tcmCheckVisible(); |
| @@ -147,97 +265,150 @@ | ||
| 147 | 265 | }); |
| 148 | 266 | </script> |
| 149 | 267 | <?php |
| 150 | 268 | |
| 151 | - $tcm->Form->formStarts(); | |
| 152 | - $tcm->Form->hidden('id', $snippet); | |
| 153 | - $tcm->Form->checkbox('active', $snippet); | |
| 154 | - $tcm->Form->text('name', $snippet); | |
| 155 | - $tcm->Form->textarea('code', $snippet); | |
| 156 | - $values = array(TCM_POSITION_HEAD, TCM_POSITION_BODY, TCM_POSITION_FOOTER); | |
| 157 | - $tcm->Form->select('position', $snippet, $values, FALSE); | |
| 269 | + $tcmp->Form->formStarts(); | |
| 270 | + $tcmp->Form->hidden('id', $snippet); | |
| 271 | + $tcmp->Form->hidden('order', $snippet); | |
| 158 | 272 | |
| 159 | - $tcm->Form->p('When do you want to add this code?'); | |
| 160 | - $args=array('class'=>'tcm-hideShow tcm-checkbox' | |
| 161 | - , 'tcm-hideIfTrue'=>'true' | |
| 162 | - , 'tcm-hideShow'=>'tcm-include-div'); | |
| 163 | - $tcm->Form->checkbox('includeEverywhereActive', $snippet, 1, $args); | |
| 273 | + $tcmp->Form->checkbox('active', $snippet); | |
| 274 | + $tcmp->Form->text('name', $snippet); | |
| 275 | + $tcmp->Form->editor('code', $snippet); | |
| 164 | 276 | |
| 165 | - $args=array('id'=>'tcm-include-div', 'name'=>'tcm-include-div', 'style'=>'margin-top:10px;'); | |
| 166 | - $tcm->Form->divStarts($args); | |
| 167 | - tcm_formOptions('include', $snippet); | |
| 168 | - $tcm->Form->divEnds(); | |
| 277 | + $values=array(TCMP_POSITION_HEAD, TCMP_POSITION_BODY, TCMP_POSITION_FOOTER); | |
| 278 | + $tcmp->Form->dropdown('position', $snippet, $values, FALSE); | |
| 279 | + $values=array(TCMP_DEVICE_TYPE_ALL, TCMP_DEVICE_TYPE_DESKTOP, TCMP_DEVICE_TYPE_MOBILE, TCMP_DEVICE_TYPE_TABLET); | |
| 280 | + $tcmp->Form->dropdown('deviceType', $snippet, $values, TRUE); | |
| 169 | 281 | |
| 170 | - $args=array('id'=>'tcm-except-div', 'name'=>'tcm-except-div'); | |
| 171 | - $tcm->Form->divStarts($args); | |
| 172 | - $tcm->Form->p('Except when?'); | |
| 173 | - tcm_formOptions('except', $snippet); | |
| 174 | - $tcm->Form->divEnds(); | |
| 282 | + $args=array('id'=>'box-track-mode'); | |
| 283 | + $tcmp->Form->divStarts($args); | |
| 284 | + { | |
| 285 | + $tcmp->Form->p('Where do you want to add this code?'); | |
| 286 | + $tcmp->Form->radio('trackMode', $snippet['trackMode'], TCMP_TRACK_MODE_CODE); | |
| 287 | + $plugins=$tcmp->Ecommerce->getActivePlugins(); | |
| 288 | + if(count($plugins)==0) { | |
| 289 | + $plugins=array('Ecommerce'=>array( | |
| 290 | + 'name'=>'Ecommerce' | |
| 291 | + , 'id'=>TCMP_PLUGINS_NO_PLUGINS | |
| 292 | + , 'version'=>'') | |
| 293 | + ); | |
| 294 | + } | |
| 295 | + $tcmp->Form->tagNew=TRUE; | |
| 296 | + foreach($plugins as $k=>$v) { | |
| 297 | + $ecommerce=$v['name']; | |
| 298 | + if(isset($v['version']) && $v['version']!='') { | |
| 299 | + $ecommerce.=' (v.'.$v['version'].')'; | |
| 300 | + } | |
| 301 | + $args=array('label'=>$tcmp->Lang->L('Editor.trackMode_1', $ecommerce)); | |
| 302 | + $tcmp->Form->radio('trackMode', $snippet['trackMode'], $v['id'], $args); | |
| 303 | + } | |
| 304 | + $tcmp->Form->tagNew=FALSE; | |
| 175 | 305 | |
| 176 | - $tcm->Form->nonce('tcm_nonce', 'tcm_nonce'); | |
| 177 | - tcm_notice_pro_features(); | |
| 178 | - $tcm->Form->submit('Save'); | |
| 179 | - if($id>0) { | |
| 180 | - $tcm->Form->delete($id); | |
| 181 | 306 | } |
| 182 | - $tcm->Form->formEnds(); | |
| 183 | -} | |
| 307 | + $tcmp->Form->divEnds(); | |
| 184 | 308 | |
| 185 | -function tcm_notice_pro_features() { | |
| 186 | - global $tcm; | |
| 309 | + $args=array('id'=>'box-track-conversion'); | |
| 310 | + $tcmp->Form->divStarts($args); | |
| 311 | + { | |
| 312 | + $tcmp->Form->p('ConversionProductQuestion'); | |
| 313 | + ?> | |
| 314 | + <p style="font-style: italic;"><?php $tcmp->Lang->P('Editor.PositionBlocked') ?></p> | |
| 315 | + <?php | |
| 316 | + foreach($plugins as $k=>$v) { | |
| 317 | + $args=array('id'=>'box-track-conversion-'.$v['id'], 'class'=>'box-track-conversion'); | |
| 318 | + $tcmp->Form->divStarts($args); | |
| 319 | + { | |
| 320 | + if($v['id']==TCMP_PLUGINS_NO_PLUGINS) { | |
| 321 | + $plugins=$tcmp->Ecommerce->getPlugins(FALSE); | |
| 322 | + $ecommerce=''; | |
| 323 | + foreach($plugins as $k=>$v) { | |
| 324 | + if($ecommerce!='') { | |
| 325 | + $ecommerce.=', '; | |
| 326 | + } | |
| 327 | + $ecommerce.=$k; | |
| 328 | + } | |
| 329 | + $tcmp->Options->pushErrorMessage('Editor.NoEcommerceFound', $ecommerce); | |
| 330 | + $tcmp->Options->writeMessages(); | |
| 331 | + } else { | |
| 332 | + $postType=$tcmp->Ecommerce->getCustomPostType($v['id']); | |
| 333 | + $keyActive='CTC_'.$v['id'].'_Active'; | |
| 334 | + $label=$tcmp->Lang->L('Editor.EcommerceCheck', $v['name'], $v['version']); | |
| 187 | 335 | |
| 188 | - ?> | |
| 189 | - <br/> | |
| 190 | - <div class="message updated below-h2"> | |
| 191 | - <div style="height:10px;"></div> | |
| 192 | - <?php | |
| 193 | - $i=1; | |
| 194 | - while($tcm->Lang->H('Notice.ProHeader'.$i)) { | |
| 195 | - $tcm->Lang->P('Notice.ProHeader'.$i); | |
| 196 | - echo '<br/>'; | |
| 197 | - ++$i; | |
| 336 | + if($postType!='') { | |
| 337 | + $args=array('post_type'=>$postType, 'all'=>TRUE); | |
| 338 | + $values=$tcmp->Utils->query(TCMP_QUERY_POSTS_OF_TYPE, $args); | |
| 339 | + $keyArray='CTC_'.$v['id'].'_ProductsIds'; | |
| 340 | + if(count($snippet[$keyArray])==0) { | |
| 341 | + //when enabled default selected -1 | |
| 342 | + $snippet[$keyArray]=array(-1); | |
| 343 | + } | |
| 344 | + | |
| 345 | + $args=array('label'=>$label, 'class'=>'tcmp-select tcmLineTags'); | |
| 346 | + $tcmp->Form->labels=FALSE; | |
| 347 | + $tcmp->Form->dropdown($keyArray, $snippet[$keyArray], $values, TRUE, $args); | |
| 348 | + $tcmp->Form->labels=TRUE; | |
| 349 | + } else { | |
| 350 | + $args=array('label'=>$label); | |
| 351 | + $tcmp->Form->checkbox($keyActive, $snippet[$keyActive], 1, $args); | |
| 352 | + } | |
| 353 | + } | |
| 354 | + } | |
| 355 | + $tcmp->Form->divEnds(); | |
| 356 | + | |
| 357 | + $tcmp->Form->br(); | |
| 358 | + $tcmp->Form->i('ConversionDynamicFields'); | |
| 359 | + $tcmp->Form->br(); | |
| 360 | + $tcmp->Form->br(); | |
| 198 | 361 | } |
| 199 | - $i=1; | |
| 200 | - ?> | |
| 201 | - <br/> | |
| 202 | - <?php | |
| 362 | + } | |
| 363 | + $tcmp->Form->divEnds(); | |
| 203 | 364 | |
| 204 | - $options = array('public' => TRUE, '_builtin' => FALSE); | |
| 205 | - $q = get_post_types($options, 'names'); | |
| 206 | - $q = array_merge($q, array('post', 'page')); | |
| 207 | - sort($q); | |
| 208 | - $q=implode(', ', $q); | |
| 365 | + $args=array('id'=>'box-track-code'); | |
| 366 | + $tcmp->Form->divStarts($args); | |
| 367 | + { | |
| 368 | + $tcmp->Form->p('In which page do you want to insert this code?'); | |
| 369 | + $tcmp->Form->radio('trackPage', $snippet['trackPage'], TCMP_TRACK_PAGE_ALL); | |
| 370 | + $tcmp->Form->radio('trackPage', $snippet['trackPage'], TCMP_TRACK_PAGE_SPECIFIC); | |
| 209 | 371 | |
| 210 | - while($tcm->Lang->H('Notice.ProFeature'.$i)) { ?> | |
| 211 | - <div style="clear:both; margin-top: 2px;"></div> | |
| 212 | - <div style="float:left; vertical-align:middle; height:24px; margin-right:5px;"> | |
| 213 | - <img src="<?php echo TCM_PLUGIN_IMAGES?>tick.png" /> | |
| 214 | - </div> | |
| 215 | - <div style="float:left; vertical-align:middle; height:24px;"> | |
| 216 | - <?php $tcm->Lang->P('Notice.ProFeature'.$i, $q)?> | |
| 217 | - </div> | |
| 218 | - <?php ++$i; | |
| 372 | + //, 'style'=>'margin-top:10px;' | |
| 373 | + $args=array('id'=>'tcmp-include-div'); | |
| 374 | + $tcmp->Form->divStarts($args); | |
| 375 | + { | |
| 376 | + $tcmp->Form->p('Include tracking code in which pages?'); | |
| 377 | + tcmp_formOptions('include', $snippet); | |
| 219 | 378 | } |
| 220 | - ?> | |
| 221 | - <div style="clear:both;"></div> | |
| 222 | - <div style="height:10px;"></div> | |
| 223 | - </div> | |
| 224 | - <br/> | |
| 225 | -<?php } | |
| 379 | + $tcmp->Form->divEnds(); | |
| 226 | 380 | |
| 227 | -function tcm_formOptions($prefix, $snippet) { | |
| 228 | - global $tcm; | |
| 381 | + $args=array('id'=>'tcmp-except-div'); | |
| 382 | + $tcmp->Form->divStarts($args); | |
| 383 | + { | |
| 384 | + $tcmp->Form->p('Do you want to exclude some specific pages?'); | |
| 385 | + tcmp_formOptions('except', $snippet); | |
| 386 | + } | |
| 387 | + $tcmp->Form->divEnds(); | |
| 388 | + } | |
| 389 | + $tcmp->Form->divEnds(); | |
| 229 | 390 | |
| 230 | - $types=$tcm->Utils->query(TCM_QUERY_POST_TYPES); | |
| 391 | + $tcmp->Form->nonce('tcmp_nonce', 'tcmp_nonce'); | |
| 392 | + tcmp_notice_pro_features(); | |
| 393 | + $tcmp->Form->submit('Save'); | |
| 394 | + $tcmp->Form->formEnds(); | |
| 395 | +} | |
| 396 | + | |
| 397 | +function tcmp_formOptions($prefix, $snippet) { | |
| 398 | + global $tcmp; | |
| 399 | + | |
| 400 | + $types=$tcmp->Utils->query(TCMP_QUERY_POST_TYPES); | |
| 231 | 401 | foreach($types as $v) { |
| 232 | - $args = array('post_type' => $v['name'], 'all' => TRUE); | |
| 233 | - $values = $tcm->Utils->query(TCM_QUERY_POSTS_OF_TYPE, $args); | |
| 402 | + $args=array('post_type'=>$v['id'], 'all'=>TRUE); | |
| 403 | + $values=$tcmp->Utils->query(TCMP_QUERY_POSTS_OF_TYPE, $args); | |
| 404 | + //$tcmp->Form->premium=!in_array($v['name'], array('post', 'page')); | |
| 234 | 405 | |
| 235 | - $keyActive=$prefix.'PostsOfType_'.$v['name'].'_Active'; | |
| 236 | - $keyArray=$prefix.'PostsOfType_'.$v['name']; | |
| 237 | - if($snippet[$keyActive]==0 && count($snippet[$keyArray])==0) { | |
| 406 | + $keyActive=$prefix.'PostsOfType_'.$v['id'].'_Active'; | |
| 407 | + $keyArray=$prefix.'PostsOfType_'.$v['id']; | |
| 408 | + if($snippet[$keyActive]==0 && count($snippet[$keyArray])==0 && $prefix!='except') { | |
| 238 | 409 | //when enabled default selected -1 |
| 239 | 410 | $snippet[$keyArray]=array(-1); |
| 240 | 411 | } |
| 241 | - $tcm->Form->checkSelect($keyActive, $keyArray, $snippet, $values); | |
| 412 | + $tcmp->Form->checkSelect($keyActive, $keyArray, $snippet, $values); | |
| 242 | 413 | } |
| 243 | 414 | } |