PluginProbe ʕ •ᴥ•ʔ
Tracking Code Manager / 2.0.7
Tracking Code Manager v2.0.7
trunk 1.11.8 1.11.9 1.12.0 1.12.1 1.12.2 1.12.3 1.4 1.5 2.0.0 2.0.1 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0
tracking-code-manager / includes / admin / manager.php
tracking-code-manager / includes / admin Last commit date
AdminOptions.php 4 years ago editor.php 4 years ago manager.php 4 years ago metabox.php 4 years ago settings.php 4 years ago whatsnew.php 4 years ago
manager.php
172 lines
1 <?php
2
3 function tcmp_ui_manager() {
4 global $tcmp;
5
6 $id=TCMP_ISQS('id', 0);
7 if (TCMP_SQS('action')=='delete' && $id>0 && wp_verify_nonce(TCMP_QS('tcmp_nonce'), 'tcmp_delete')) {
8 $snippet=$tcmp->Manager->get($id);
9 if ($tcmp->Manager->remove($id)) {
10 $tcmp->Options->pushSuccessMessage('CodeDeleteNotice', $id, $snippet['name']);
11 }
12 } else if ($id != '' && $id != 0) {
13 $snippet = $tcmp->Manager->get($id);
14 if ($tcmp->Utils->is('action', 'toggle') && $id>0 && wp_verify_nonce(TCMP_QS('tcmp_nonce'), 'tcmp_toggle')) {
15 $snippet['active']=($snippet['active']==0 ? 1 : 0);
16 $tcmp->Manager->put($snippet['id'], $snippet);
17 }
18 $tcmp->Options->pushSuccessMessage('CodeUpdateNotice', $id, $snippet['name']);
19 }
20
21 $tcmp->Manager->isLimitReached(TRUE);
22 $tcmp->Options->writeMessages();
23
24 //controllo che faccio per essere retrocompatibile con la prima versione
25 //dove non avevo un id e salvavo tutto con il con il nome quindi una stringa
26 $snippets=$tcmp->Manager->keys();
27 foreach($snippets as $v) {
28 $snippet=$tcmp->Manager->get($v, FALSE, TRUE);
29 if(!$snippet) {
30 $tcmp->Manager->remove($v);
31 } elseif(!is_numeric($v)) {
32 $tcmp->Manager->remove($v);
33 $tcmp->Manager->put('', $snippet);
34 }
35 }
36 $snippets=$tcmp->Manager->values();
37 if (count($snippets)>0) { ?>
38 <div style="float:left;">
39 <form method="get" action="" style="margin:5px; float:left;">
40 <input type="hidden" name="page" value="<?php echo TCMP_PLUGIN_SLUG?>" />
41 <input type="hidden" name="tab" value="<?php echo TCMP_TAB_EDITOR?>" />
42 <input type="submit" class="button-primary" value="<?php $tcmp->Lang->P('Button.Add')?>" />
43 </form>
44 </div>
45 <div style="clear:both;"></div>
46
47 <style>
48 .widefat th {
49 font-weight: bold!important;
50 }
51 table input {
52 font-size: 13px;
53 }
54 .widefat thead td, .widefat thead th {
55 border-bottom: 0px!important;
56 }
57 </style>
58 <table class="widefat fixed" style="width:100%" id="tblSortable">
59 <thead>
60 <tr>
61 <th style="width:30px;">#N</th>
62 <th style="width:50px; text-align:center;"><?php $tcmp->Lang->P('Active?')?></th>
63 <th><?php $tcmp->Lang->P('Name')?></th>
64 <th><?php $tcmp->Lang->P('Where?')?></th>
65 <th style="text-align:center;"><?php $tcmp->Lang->P('Shortcode')?></th>
66 <th style="text-align:center;"><?php $tcmp->Lang->P('Actions')?></th>
67 </tr>
68 </thead>
69 <tbody class="table-body">
70 <?php
71 $i=1;
72 foreach ($snippets as $snippet) {
73 $bClass=(($i%2)==1 ? 'odd' : 'even');
74 ?>
75 <tr class="<?php echo $bClass?>" id="row_<?php echo $snippet['id']?>">
76 <td>#<?php echo $i++ ?></td>
77 <td style="text-align:center;">
78 <?php
79 $color='red';
80 $text='No';
81 $question='QuestionActiveOn';
82 if($snippet['active']==1) {
83 $color='green';
84 $text='Yes';
85 $question='QuestionActiveOff';
86 }
87 $text='<span style="font-weight:bold; color:'.$color.'">'.$tcmp->Lang->L($text).'</span>';
88 ?>
89 <a onclick="return confirm('<?php echo $tcmp->Lang->L($question)?>');" href="<?php echo TCMP_TAB_MANAGER_URI?>&tcmp_nonce=<?php echo esc_attr(wp_create_nonce('tcmp_toggle')); ?>&action=toggle&id=<?php echo $snippet['id'] ?>">
90 <?php echo $text?>
91 </a>
92 </td>
93 <td><?php echo $snippet['name']?></td>
94 <td>
95 <?php
96 if($tcmp->Manager->isModeScript($snippet)) {
97 if($tcmp->Manager->isPageEverywhere($snippet)) {
98 $text='Everywhere';
99 } else {
100 $text='Specific Pages';
101 }
102 } else {
103 $text='Conversion';
104 }
105 $tcmp->Lang->P($text);
106 ?>
107 </td>
108 <td style="text-align:center;">
109 <input type="text" style="width:110px; text-align:center;" value='[tcm id="<?php echo esc_html($snippet['id']); ?>"]' readonly="readonly" class="tcmp-select-onfocus" />
110 </td>
111 <td style="text-align:center;">
112 <input type="button" class="button button-secondary" value="<?php $tcmp->Lang->P('Edit')?>" onclick="location.href='<?php echo TCMP_TAB_EDITOR_URI?>&id=<?php echo $snippet['id'] ?>';"/>
113 <input type="button" class="button button-secondary" value="<?php $tcmp->Lang->P('Delete?')?>" onclick="TCMP_btnDeleteClick(<?php echo $snippet['id'] ?>)"/>
114 </td>
115 </tr>
116 <?php } ?>
117 </tbody>
118 </table>
119 <script>
120 function TCMP_btnDeleteClick(id) {
121 var success=confirm('<?php echo $tcmp->Lang->L('Question.DeleteQuestion')?>');
122 if(success) {
123 var href='<?php echo TCMP_TAB_MANAGER_URI?>&tcmp_nonce=<?php echo esc_attr(wp_create_nonce('tcmp_delete')); ?>&action=delete&id=';
124 location.href=href+id;
125 }
126 }
127 </script>
128 <?php
129 tcmp_notice_pro_features();
130 if(count($snippets)>1) {
131 tcmp_manager_sortable_scripts();
132 }
133 } else { ?>
134 <h2><?php $tcmp->Lang->P('EmptyTrackingList', TCMP_TAB_EDITOR_URI)?></h2>
135 <?php }
136 }
137 function tcmp_manager_sortable_scripts() {
138 ?>
139 <style>
140 .ui-state-highlight {
141 border: 1px dotted red!important;
142 background-color: #F4E449!important;
143 }
144 #tblSortable tbody tr:hover {
145 cursor: move!important;
146 }
147 #tblSortable tbody tr a:hover {
148 cursor: hand!important;
149 }
150 </style>
151 <script>
152 jQuery(function() {
153 var $sortable=jQuery("#tblSortable .table-body");
154 $sortable.sortable({
155 tolerance:'intersect'
156 , cursor:'move'
157 , items:'tr'
158 , placeholder:'ui-state-highlight'
159 , nested: 'tbody'
160 , update: function(event, ui) {
161 var orders=$sortable.sortable('serialize');
162 var data={action: 'TCMP_changeOrder', order: orders};
163 jQuery.post(ajaxurl, data, function(result) {
164 console.log(result);
165 });
166 }
167 });
168 $sortable.disableSelection();
169 });
170 </script>
171 <?php
172 }