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