PluginProbe ʕ •ᴥ•ʔ
Tracking Code Manager / 1.4
Tracking Code Manager v1.4
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
about.php 11 years ago editor.php 11 years ago feedback.php 11 years ago manager.php 11 years ago metabox.php 11 years ago settings.php 11 years ago
manager.php
133 lines
1 <?php
2 //column renderer
3 function tcm_ui_manager_column($active, $values=NULL, $hide=FALSE) {
4 global $tcm;
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">'.$tcm->Lang->L('Yes').'</span>';
13 } else {
14 $text='<span style="font-weight:bold; color:red">'.$tcm->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 tcm_ui_free_notice() {
34 global $tcm;
35
36 if($tcm->Manager->rc()<=0) {
37 $tcm->Options->pushErrorMessage('FreeLicenseReached');
38 } elseif($tcm->Manager->count()>0) {
39 $tcm->Options->pushSuccessMessage('PluginLimit.Line1', 6, $tcm->Manager->rc());
40 $tcm->Options->pushSuccessMessage('PluginLimit.Line2', TCM_PAGE_PREMIUM);
41 }
42 $tcm->Options->writeMessages();
43 }
44 function tcm_ui_manager() {
45 global $tcm;
46
47 $id=intval($tcm->Utils->qs('id', 0));
48 if ($tcm->Utils->qs('action')=='delete' && $id>0 && wp_verify_nonce($tcm->Utils->qs('tcm_nonce'), 'tcm_delete')) {
49 $snippet=$tcm->Manager->get($id);
50 if ($tcm->Manager->remove($id)) {
51 $tcm->Options->pushSuccessMessage('CodeDeleteNotice', $id, $snippet['name']);
52 }
53 } else if($id!='') {
54 $snippet=$tcm->Manager->get($id);
55 $tcm->Options->pushSuccessMessage('CodeUpdateNotice', $id, $snippet['name']);
56 }
57
58 $tcm->Options->writeMessages();
59 tcm_ui_free_notice();
60
61 //controllo che faccio per essere retrocompatibile con la prima versione
62 //dove non avevo un id e salvavo tutto con il con il nome quindi una stringa
63 $snippets=$tcm->Manager->keys();
64 foreach($snippets as $v) {
65 $snippet=$tcm->Manager->get($v, FALSE, TRUE);
66 if(!$snippet) {
67 $tcm->Manager->remove($v);
68 } elseif(!is_numeric($v)) {
69 $tcm->Manager->remove($v);
70 $tcm->Manager->put('', $snippet);
71 }
72 }
73 $snippets=$tcm->Manager->values();
74 if (count($snippets)>0) { ?>
75 <div style="float:left;">
76 <form method="get" action="" style="margin:5px;" class="alignright">
77 <input type="hidden" name="page" value="<?php echo TCM_PLUGIN_NAME?>" />
78 <input type="hidden" name="tab" value="<?php echo TCM_TAB_EDITOR?>" />
79 <input type="submit" class="button-primary" value="<?php $tcm->Lang->P('Button.Add')?>" />
80 </form>
81 <form method="get" style="margin:5px;" class="alignright" action="<?php echo TCM_PAGE_PREMIUM?>">
82 <input type="submit" class="button" value="<?php $tcm->Lang->P('Button.BuyPRO')?>" />
83 </form>
84 </div>
85 <div style="clear:both;"></div>
86
87 <style>
88 .widefat th {
89 font-weight: bold!important;
90 }
91 </style>
92 <table class="widefat fixed" style="width:850px;">
93 <thead>
94 <tr>
95 <th><?php $tcm->Lang->P('Name')?></th>
96 <th><?php $tcm->Lang->P('Position')?></th>
97 <th style="text-align:center;"><?php $tcm->Lang->P('Active?')?></th>
98 <th style="text-align:center;"><?php $tcm->Lang->P('Each pages?')?></th>
99 <th style="text-align:center;"><?php $tcm->Lang->P('Count')?></th>
100 <th style="text-align:center;"><?php $tcm->Lang->P('Actions')?></th>
101 </tr>
102 </thead>
103 <tbody>
104 <?php foreach ($snippets as $snippet) { ?>
105 <tr>
106 <td><?php echo $snippet['name']?></td>
107 <td><?php $tcm->Lang->P('Editor.position.'.$snippet['position'])?></td>
108 <?php
109 tcm_ui_manager_column($snippet['active']);
110
111 $hide=!$snippet['active'];
112 tcm_ui_manager_column($snippet['includeEverywhereActive'], NULL, $hide);
113 ?>
114 <td style="text-align:center;"><?php echo $snippet['codesCount']?></td>
115 <td style="text-align:center;">
116 <a href="<?php echo TCM_TAB_EDITOR_URI?>&id=<?php echo $snippet['id'] ?>">
117 <?php echo $tcm->Lang->L('Edit')?>
118 </a>
119 &nbsp;|&nbsp;
120 <span class="trash">
121 <a onclick="return confirm('<?php echo $tcm->Lang->L('Are you sure you want to delete this code?')?>');" href="<?php echo TCM_TAB_MANAGER_URI?>&tcm_nonce=<?php echo esc_attr(wp_create_nonce('tcm_delete')); ?>&action=delete&id=<?php echo $snippet['id'] ?>">
122 <?php echo $tcm->Lang->L('Delete')?>
123 </a>
124 </span>
125 </td>
126 </tr>
127 <?php } ?>
128 </tbody>
129 </table>
130 <?php } else { ?>
131 <h2><?php $tcm->Lang->P('EmptyTrackingList', TCM_TAB_EDITOR_URI)?></h2>
132 <?php } ?>
133 <?php }