| @@ -44,15 +44,19 @@ | ||
| 44 | 44 | function tcm_ui_manager() { |
| 45 | 45 | global $tcm; |
| 46 | 46 | |
| 47 | 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); | |
| 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 | 50 | if ($tcm->Manager->remove($id)) { |
| 51 | 51 | $tcm->Options->pushSuccessMessage('CodeDeleteNotice', $id, $snippet['name']); |
| 52 | 52 | } |
| 53 | - } else if($id!='') { | |
| 53 | + } elseif($id>0) { | |
| 54 | 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 | + } | |
| 55 | 59 | $tcm->Options->pushSuccessMessage('CodeUpdateNotice', $id, $snippet['name']); |
| 56 | 60 | } |
| 57 | 61 | |
| 58 | 62 | $tcm->Options->writeMessages(); |
| @@ -104,11 +108,25 @@ | ||
| 104 | 108 | <?php foreach ($snippets as $snippet) { ?> |
| 105 | 109 | <tr> |
| 106 | 110 | <td><?php echo $snippet['name']?></td> |
| 107 | 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> | |
| 108 | 128 | <?php |
| 109 | - tcm_ui_manager_column($snippet['active']); | |
| 110 | - | |
| 111 | 129 | $hide=!$snippet['active']; |
| 112 | 130 | tcm_ui_manager_column($snippet['includeEverywhereActive'], NULL, $hide); |
| 113 | 131 | ?> |
| 114 | 132 | <td style="text-align:center;"><?php echo $snippet['codesCount']?></td> |