PluginProbe ʕ •ᴥ•ʔ
Tracking Code Manager / 2.0.2
Tracking Code Manager v2.0.2
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 / classes / ui / Tabs.php
tracking-code-manager / includes / classes / ui Last commit date
Check.php 5 years ago Form.php 5 years ago Tabs.php 5 years ago
Tabs.php
295 lines
1 <?php
2 class TCMP_Tabs {
3 private $tabs = array();
4
5 function __construct() {
6 }
7 public function init() {
8 global $tcmp;
9 if($tcmp->Utils->isAdminUser()) {
10 add_action('admin_menu', array(&$this, 'attachMenu'));
11 add_filter('plugin_action_links', array(&$this, 'pluginActions'), 10, 2);
12 if($tcmp->Utils->isPluginPage()) {
13 add_action('admin_enqueue_scripts', array(&$this, 'enqueueScripts'));
14 }
15 }
16 }
17
18 function attachMenu() {
19 add_submenu_page('options-general.php'
20 , TCMP_PLUGIN_NAME, TCMP_PLUGIN_NAME
21 , 'manage_options', TCMP_PLUGIN_SLUG, array(&$this, 'showTabPage'));
22 }
23 function pluginActions($links, $file) {
24 global $tcmp;
25 if($file==TCMP_PLUGIN_SLUG.'/index.php'){
26 $settings=array();
27 $settings[]="<a href='".TCMP_TAB_MANAGER_URI."'>".$tcmp->Lang->L('Settings').'</a>';
28 $settings[]="<a href='".TCMP_PAGE_PREMIUM."'>".$tcmp->Lang->L('PREMIUM').'</a>';
29 $links=array_merge($settings, $links);
30 }
31 return $links;
32 }
33 function enqueueScripts() {
34 wp_enqueue_script('jquery');
35 wp_enqueue_script('jQuery');
36 wp_enqueue_script('jquery-ui-sortable');
37
38 $this->wpEnqueueStyle('assets/css/style.css');
39 $this->wpEnqueueStyle('assets/deps/select2-3.5.2/select2.css');
40 $this->wpEnqueueScript('assets/deps/select2-3.5.2/select2.min.js');
41 $this->wpEnqueueScript('assets/deps/starrr/starrr.js');
42
43 $this->wpEnqueueScript('assets/js/library.js');
44 $this->wpEnqueueScript('assets/js/plugin.js');
45 }
46 function wpEnqueueStyle($uri, $name='') {
47 if($name=='') {
48 $name=explode('/', $uri);
49 $name=$name[count($name)-1];
50 $dot=strrpos($name, '.');
51 if($dot!==FALSE) {
52 $name=substr($name, 0, $dot);
53 }
54 $name=TCMP_PLUGIN_PREFIX.'_'.$name;
55 }
56
57 $v='?v='.TCMP_PLUGIN_VERSION;
58 wp_enqueue_style($name, TCMP_PLUGIN_URI.$uri.$v);
59 }
60 function wpEnqueueScript($uri, $name='', $version=FALSE) {
61 if($name=='') {
62 $name=explode('/', $uri);
63 $name=$name[count($name)-1];
64 $dot=strrpos($name, '.');
65 if($dot!==FALSE) {
66 $name=substr($name, 0, $dot);
67 }
68 $name=TCMP_PLUGIN_PREFIX.'_'.$name;
69 }
70
71 $v='?v='.TCMP_PLUGIN_VERSION;
72 $deps=array();
73 wp_enqueue_script($name, TCMP_PLUGIN_URI.$uri.$v, $deps, $version, FALSE);
74 }
75
76 function showTabPage() {
77 global $tcmp;
78
79 $v=$tcmp->Options->getShowWhatsNewSeenVersion();
80 if($v!=TCMP_WHATSNEW_VERSION) {
81 $tcmp->Options->setShowWhatsNew(TRUE);
82 }
83
84 $hwb=TCMP_ISQS('hwb', '');
85 if($hwb!='') {
86 $tcmp->Options->setShowWhatsNew(FALSE);
87 }
88
89 $id=TCMP_ISQS('id', 0);
90 $defaultTab=TCMP_TAB_MANAGER;
91 $tab=TCMP_SQS('tab', $defaultTab);
92
93 if($tcmp->Options->isShowWhatsNew()) {
94 $tab=TCMP_TAB_WHATS_NEW;
95 $defaultTab=$tab;
96 $this->tabs[TCMP_TAB_WHATS_NEW]=$tcmp->Lang->L('What\'s New');
97 //$this->tabs[TCMP_TAB_MANAGER]=$tcmp->Lang->L('Start using the plugin!');
98 } else {
99 if($id>0 || !$tcmp->Manager->isLimitReached(FALSE)) {
100 $this->tabs[TCMP_TAB_EDITOR]=$tcmp->Lang->L($id>0 && $tab==TCMP_TAB_EDITOR ? 'Edit Script' : 'Add New Script');
101 } elseif($tab==TCMP_TAB_EDITOR) {
102 $tab = TCMP_TAB_MANAGER;
103 }
104
105 $this->tabs[TCMP_TAB_MANAGER]=$tcmp->Lang->L('Manager');
106 $this->tabs[TCMP_TAB_SETTINGS]=$tcmp->Lang->L('Settings');
107 $this->tabs[TCMP_TAB_DOCS]=$tcmp->Lang->L('Docs & FAQ');
108 }
109
110 ?>
111
112 <div class="wrap" style="margin: 5px;">
113 <?php
114 $this->showTabs($defaultTab);
115 $header='';
116 switch ($tab) {
117 case TCMP_TAB_EDITOR:
118 $header=($id>0 ? 'Edit' : 'Add');
119 break;
120 case TCMP_TAB_WHATS_NEW:
121 $header='';
122 break;
123 case TCMP_TAB_MANAGER:
124 $header='Manager';
125 break;
126 case TCMP_TAB_SETTINGS:
127 $header='Settings';
128 break;
129 }
130
131 if($tcmp->Lang->H($header.'Title')) { ?>
132 <h2><?php $tcmp->Lang->P($header . 'Title', TCMP_PLUGIN_VERSION) ?></h2>
133 <?php if ($tcmp->Lang->H($header . 'Subtitle')) { ?>
134 <div><?php $tcmp->Lang->P($header . 'Subtitle') ?></div>
135 <?php } ?>
136 <br/>
137 <?php }
138
139 tcmp_ui_first_time();
140 ?>
141 <div style="float:left; margin:5px;">
142 <?php
143 $styles=array();
144 $styles[]='float:left';
145 $styles[]='margin-right:20px';
146 if($tab!=TCMP_TAB_WHATS_NEW) {
147 $styles[]='max-width:750px';
148 }
149 $styles=implode('; ', $styles);
150 ?>
151 <div id="tcmp-page" style="<?php echo $styles?>">
152 <?php switch ($tab) {
153 case TCMP_TAB_WHATS_NEW:
154 tcmp_ui_whats_new();
155 break;
156 case TCMP_TAB_EDITOR:
157 tcmp_ui_editor();
158 break;
159 case TCMP_TAB_MANAGER:
160 tcmp_ui_manager();
161 break;
162 case TCMP_TAB_SETTINGS:
163 tcmp_ui_track();
164 tcmp_ui_settings();
165 break;
166 } ?>
167 </div>
168 <?php if($tab!=TCMP_TAB_WHATS_NEW) { ?>
169 <div id="tcmp-sidebar" style="float:left; max-width: 250px;">
170 <?php
171 $count=$this->getPluginsCount();
172 $plugins=array();
173 while(count($plugins)<2) {
174 $id=rand(1, $count);
175 if(!isset($plugins[$id])) {
176 $plugins[$id]=$id;
177 }
178 }
179
180 $this->drawContactUsWidget();
181 foreach($plugins as $id) {
182 $this->drawPluginWidget($id);
183 }
184 ?>
185 </div>
186 <?php } ?>
187 </div>
188 </div>
189 <div style="clear:both"></div>
190 <?php }
191 function getPluginsCount() {
192 global $tcmp;
193 $index=1;
194 while($tcmp->Lang->H('Plugin'.$index.'.Name')) {
195 $index++;
196 }
197 return $index-1;
198 }
199 function drawPluginWidget($id) {
200 global $tcmp;
201 ?>
202 <div class="tcmp-plugin-widget">
203 <b><?php $tcmp->Lang->P('Plugin'.$id.'.Name') ?></b>
204 <br>
205 <i><?php $tcmp->Lang->P('Plugin'.$id.'.Subtitle') ?></i>
206 <br>
207 <ul style="list-style: circle;">
208 <?php
209 $index=1;
210 while($tcmp->Lang->H('Plugin'.$id.'.Feature'.$index)) { ?>
211 <li><?php $tcmp->Lang->P('Plugin'.$id.'.Feature'.$index) ?></li>
212 <?php $index++;
213 } ?>
214 </ul>
215 <a style="float:right;" class="button-primary" href="<?php $tcmp->Lang->P('Plugin'.$id.'.Permalink') ?>" target="_blank">
216 <?php $tcmp->Lang->P('PluginCTA')?>
217 </a>
218 <div style="clear:both"></div>
219 </div>
220 <br>
221 <?php }
222 function drawContactUsWidget() {
223 global $tcmp;
224 ?>
225 <b><?php $tcmp->Lang->P('Sidebar.Title') ?></b>
226 <ul style="list-style: circle;">
227 <?php
228 $index=1;
229 while($tcmp->Lang->H('Sidebar'.$index.'.Name')) { ?>
230 <li>
231 <a href="<?php $tcmp->Lang->P('Sidebar'.$index.'.Url')?>" target="_blank">
232 <?php $tcmp->Lang->P('Sidebar'.$index.'.Name')?>
233 </a>
234 </li>
235 <?php $index++;
236 } ?>
237 </ul>
238 <?php }
239 function showTabs($defaultTab) {
240 global $tcmp;
241 $tab=$tcmp->Check->of('tab', $defaultTab);
242 if($tab==TCMP_TAB_DOCS) {
243 $tcmp->Utils->redirect(TCMP_TAB_DOCS_URI);
244 }
245 if($tcmp->Options->isShowWhatsNew()) {
246 $tab=TCMP_TAB_WHATS_NEW;
247 }
248
249 ?>
250 <h2 class="nav-tab-wrapper" style="float:left; width:97%;">
251 <?php
252 foreach ($this->tabs as $k=>$v) {
253 $active = ($tab==$k ? 'nav-tab-active' : '');
254 $style='';
255 $target='_self';
256 if($tcmp->Options->isShowWhatsNew() && $k==TCMP_TAB_MANAGER) {
257 $active='';
258 $style='background-color:#F2E49B';
259 }
260 if($k==TCMP_TAB_DOCS) {
261 $target='_blank';
262 $style='background-color:#F2E49B';
263 }
264 ?>
265 <a style="float:left; margin-left:10px; <?php echo $style?>" class="nav-tab <?php echo $active?>" target="<?php echo $target ?>" href="?page=<?php echo TCMP_PLUGIN_SLUG?>&tab=<?php echo $k?>"><?php echo $v?></a>
266 <?php
267 }
268 ?>
269 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css">
270 <style>
271 .starrr {display:inline-block}
272 .starrr i{font-size:16px;padding:0 1px;cursor:pointer;color:#2ea2cc;}
273 </style>
274 <div style="float:right; display:none;" id="rate-box">
275 <span style="font-weight:700; font-size:13px; color:#555;"><?php $tcmp->Lang->P('Rate us')?></span>
276 <div id="tcmp-rate" class="starrr" data-connected-input="tcmp-rate-rank"></div>
277 <input type="hidden" id="tcmp-rate-rank" name="tcmp-rate-rank" value="5" />
278 <?php $tcmp->Utils->twitter('intellywp') ?>
279 </div>
280 <script>
281 jQuery(function() {
282 jQuery(".starrr").starrr();
283 jQuery('#tcmp-rate').on('starrr:change', function(e, value){
284 var url='https://wordpress.org/support/view/plugin-reviews/tracking-code-manager?rate=5#postform';
285 window.open(url);
286 });
287 jQuery('#rate-box').show();
288 });
289 </script>
290 </h2>
291 <div style="clear:both;"></div>
292 <?php }
293 }
294
295