PluginProbe
Tracking Code Manager / 2.0.15
Tracking Code Manager v2.0.15
2.8.0 2.7.0 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 All 29 releases
← All changes | includes/admin/manager.php +116 -151 1.52.0.15 View file →
@@ -1,151 +1,116 @@
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->is('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 - } elseif($id>0) {
54 - $snippet=$tcm->Manager->get($id);
55 - if($tcm->Utils->is('action', 'toggle') && $id>0 && wp_verify_nonce($tcm->Utils->qs('tcm_nonce'), 'tcm_toggle')) {
56 - $snippet['active']=($snippet['active']==0 ? 1 : 0);
57 - $tcm->Manager->put($snippet['id'], $snippet);
58 - }
59 - $tcm->Options->pushSuccessMessage('CodeUpdateNotice', $id, $snippet['name']);
60 - }
61 -
62 - $tcm->Options->writeMessages();
63 - tcm_ui_free_notice();
64 -
65 - //controllo che faccio per essere retrocompatibile con la prima versione
66 - //dove non avevo un id e salvavo tutto con il con il nome quindi una stringa
67 - $snippets=$tcm->Manager->keys();
68 - foreach($snippets as $v) {
69 - $snippet=$tcm->Manager->get($v, FALSE, TRUE);
70 - if(!$snippet) {
71 - $tcm->Manager->remove($v);
72 - } elseif(!is_numeric($v)) {
73 - $tcm->Manager->remove($v);
74 - $tcm->Manager->put('', $snippet);
75 - }
76 - }
77 - $snippets=$tcm->Manager->values();
78 - if (count($snippets)>0) { ?>
79 - <div style="float:left;">
80 - <form method="get" action="" style="margin:5px;" class="alignright">
81 - <input type="hidden" name="page" value="<?php echo TCM_PLUGIN_NAME?>" />
82 - <input type="hidden" name="tab" value="<?php echo TCM_TAB_EDITOR?>" />
83 - <input type="submit" class="button-primary" value="<?php $tcm->Lang->P('Button.Add')?>" />
84 - </form>
85 - <form method="get" style="margin:5px;" class="alignright" action="<?php echo TCM_PAGE_PREMIUM?>">
86 - <input type="submit" class="button" value="<?php $tcm->Lang->P('Button.BuyPRO')?>" />
87 - </form>
88 - </div>
89 - <div style="clear:both;"></div>
90 -
91 - <style>
92 - .widefat th {
93 - font-weight: bold!important;
94 - }
95 - </style>
96 - <table class="widefat fixed" style="width:850px;">
97 - <thead>
98 - <tr>
99 - <th><?php $tcm->Lang->P('Name')?></th>
100 - <th><?php $tcm->Lang->P('Position')?></th>
101 - <th style="text-align:center;"><?php $tcm->Lang->P('Active?')?></th>
102 - <th style="text-align:center;"><?php $tcm->Lang->P('Each pages?')?></th>
103 - <th style="text-align:center;"><?php $tcm->Lang->P('Count')?></th>
104 - <th style="text-align:center;"><?php $tcm->Lang->P('Actions')?></th>
105 - </tr>
106 - </thead>
107 - <tbody>
108 - <?php foreach ($snippets as $snippet) { ?>
109 - <tr>
110 - <td><?php echo $snippet['name']?></td>
111 - <td><?php $tcm->Lang->P('Editor.position.'.$snippet['position'])?></td>
112 - <td style="text-align:center;">
113 - <?php
114 - $color='red';
115 - $text='No';
116 - $question='QuestionActiveOn';
117 - if($snippet['active']==1) {
118 - $color='green';
119 - $text='Yes';
120 - $question='QuestionActiveOff';
121 - }
122 - $text='<span style="font-weight:bold; color:'.$color.'">'.$tcm->Lang->L($text).'</span>';
123 - ?>
124 - <a onclick="return confirm('<?php echo $tcm->Lang->L($question)?>');" href="<?php echo TCM_TAB_MANAGER_URI?>&tcm_nonce=<?php echo esc_attr(wp_create_nonce('tcm_toggle')); ?>&action=toggle&id=<?php echo $snippet['id'] ?>">
125 - <?php echo $text?>
126 - </a>
127 - </td>
128 - <?php
129 - $hide=!$snippet['active'];
130 - tcm_ui_manager_column($snippet['includeEverywhereActive'], NULL, $hide);
131 - ?>
132 - <td style="text-align:center;"><?php echo $snippet['codesCount']?></td>
133 - <td style="text-align:center;">
134 - <a href="<?php echo TCM_TAB_EDITOR_URI?>&id=<?php echo $snippet['id'] ?>">
135 - <?php echo $tcm->Lang->L('Edit')?>
136 - </a>
137 - &nbsp;|&nbsp;
138 - <span class="trash">
139 - <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'] ?>">
140 - <?php echo $tcm->Lang->L('Delete')?>
141 - </a>
142 - </span>
143 - </td>
144 - </tr>
145 - <?php } ?>
146 - </tbody>
147 - </table>
148 - <?php } else { ?>
149 - <h2><?php $tcm->Lang->P('EmptyTrackingList', TCM_TAB_EDITOR_URI)?></h2>
150 - <?php } ?>
151 -<?php }
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 + } elseif ( '' != $id && 0 != $id ) {
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'] = ( 0 === $snippet['active'] ? 1 : 0 );
16 + $tcmp->manager->put( $snippet['id'], $snippet );
17 + }
18 + $tcmp->options->pushSuccessMessage( 'CodeUpdateNotice', $id, $snippet['name'] );
19 + }
20 +
21 + $tcmp->manager->is_limit_reached( 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 + <table class="widefat fixed" style="width:100%" id="tblSortable">
48 + <thead>
49 + <tr>
50 + <th style="width:30px;">#N</th>
51 + <th style="width:50px; text-align:center;"><?php $tcmp->lang->P( 'Active?' ); ?></th>
52 + <th><?php $tcmp->lang->P( 'Name' ); ?></th>
53 + <th><?php $tcmp->lang->P( 'Where?' ); ?></th>
54 + <th style="text-align:center;"><?php $tcmp->lang->P( 'Shortcode' ); ?></th>
55 + <th style="text-align:center;"><?php $tcmp->lang->P( 'Actions' ); ?></th>
56 + </tr>
57 + </thead>
58 + <tbody class="table-body">
59 + <?php
60 + $i = 1;
61 + foreach ( $snippets as $snippet ) {
62 + global $tcmp_allowed_html_tags;
63 + $bClass = ( ( $i % 2 ) === 1 ? 'odd' : 'even' );
64 + ?>
65 + <tr class="<?php echo esc_attr( $bClass ); ?>" id="row_<?php echo esc_attr( $snippet['id'] ); ?>">
66 + <td>#<?php echo esc_html( $i++ ); ?></td>
67 + <td style="text-align:center;">
68 + <?php
69 + $color = 'red';
70 + $text = 'No';
71 + $question = 'QuestionActiveOn';
72 + if ( 1 == $snippet['active'] ) {
73 + $color = 'green';
74 + $text = 'Yes';
75 + $question = 'QuestionActiveOff';
76 + }
77 + $text = '<span style="font-weight:bold; color:' . $color . '">' . $tcmp->lang->L( $text ) . '</span>';
78 + ?>
79 + <a onclick="return confirm('<?php echo esc_attr( $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 esc_attr( $snippet['id'] ); ?>">
80 + <?php echo wp_kses( $text, $tcmp_allowed_html_tags ); ?>
81 + </a>
82 + </td>
83 + <td><?php echo esc_html( $snippet['name'] ); ?></td>
84 + <td>
85 + <?php
86 + if ( $tcmp->manager->is_mode_script( $snippet ) ) {
87 + if ( $tcmp->manager->is_page_everywhere( $snippet ) ) {
88 + $text = 'Everywhere';
89 + } else {
90 + $text = 'Specific Pages';
91 + }
92 + } else {
93 + $text = 'Conversion';
94 + }
95 + esc_html( $tcmp->lang->P( $text ) );
96 + ?>
97 + </td>
98 + <td style="text-align:center;">
99 + <input type="text" style="width:110px; text-align:center;" value='[tcm id="<?php echo esc_html( $snippet['id'] ); ?>"]' readonly="readonly" class="tcmp-select-onfocus" />
100 + </td>
101 + <td style="text-align:center;">
102 + <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 esc_attr( $snippet['id'] ); ?>';"/>
103 + <input type="button" class="button button-secondary" value="<?php $tcmp->lang->P( 'Delete?' ); ?>" onclick="TCMP_btnDeleteClick(<?php echo esc_attr( $snippet['id'] ); ?>)"/>
104 + </td>
105 + </tr>
106 + <?php } ?>
107 + </tbody>
108 + </table>
109 + <?php
110 + tcmp_notice_pro_features();
111 + } else {
112 + ?>
113 + <h2><?php $tcmp->lang->P( 'EmptyTrackingList', TCMP_TAB_EDITOR_URI ); ?></h2>
114 + <?php
115 + }
116 +}