PluginProbe ʕ •ᴥ•ʔ
Tracking Code Manager / 2.0.14
Tracking Code Manager v2.0.14
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 3 years ago Form.php 3 years ago Tabs.php 3 years ago
Tabs.php
325 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, 'attach_menu' ) );
11 add_filter( 'plugin_action_links', array( &$this, 'plugin_actions' ), 10, 2 );
12 if ( $tcmp->utils->isPluginPage() ) {
13 add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
14 }
15 }
16 }
17
18 function attach_menu() {
19 add_submenu_page(
20 'options-general.php',
21 TCMP_PLUGIN_NAME,
22 TCMP_PLUGIN_NAME,
23 'manage_options',
24 TCMP_PLUGIN_SLUG,
25 array( &$this, 'showTabPage' )
26 );
27 }
28 function plugin_actions( $links, $file ) {
29 global $tcmp;
30 if ( TCMP_PLUGIN_SLUG . '/index.php' == $file ) {
31 $settings = array();
32 $settings[] = "<a href='" . TCMP_TAB_MANAGER_URI . "'>" . $tcmp->lang->L( 'Settings' ) . '</a>';
33 $settings[] = "<a href='" . TCMP_PAGE_PREMIUM . "'>" . $tcmp->lang->L( 'PREMIUM' ) . '</a>';
34 $links = array_merge( $settings, $links );
35 }
36 return $links;
37 }
38 function enqueue_scripts() {
39 wp_enqueue_script( 'jquery' );
40 wp_enqueue_script( 'jQuery' );
41 wp_enqueue_script( 'jquery-ui-sortable' );
42
43 $this->wpEnqueueStyle( 'assets/css/style.css' );
44 $this->wpEnqueueStyle( 'assets/css/manager.css' );
45 $this->wpEnqueueStyle( 'assets/deps/select2-4.0.13/select2.css' );
46 $this->wpEnqueueScript( 'assets/deps/select2-4.0.13/select2.full.js' );
47 $this->wpEnqueueScript( 'assets/deps/starrr/starrr.js' );
48
49 $this->wpEnqueueScript( 'assets/js/library.js' );
50 $this->wpEnqueueScript( 'assets/js/plugin.js' );
51
52 $this->wpEnqueueScript( 'assets/js/editor.js' );
53 $this->wpEnqueueScript( 'assets/js/manager.js' );
54 $this->wpEnqueueScript( 'assets/js/delete-confirm.js' );
55 $this->wpEnqueueScript( 'assets/js/ace/ace.js' );
56
57 $this->wpEnqueueStyle( 'assets/css/font-awesome.min.css' );
58
59 global $tcmp;
60 wp_add_inline_script( 'TCMP__delete-confirm', 'const delete_data = ' . json_encode( array(
61 'confirm' => $tcmp->lang->L( 'Question.DeleteQuestion' ),
62 'href' => TCMP_TAB_MANAGER_URI,
63 'nonce' => wp_create_nonce( 'tcmp_delete' ),
64 ) ), 'before' );
65 }
66 function wpEnqueueStyle( $uri, $name = '' ) {
67 if ( '' == $name ) {
68 $name = explode( '/', $uri );
69 $name = $name[ count( $name ) - 1 ];
70 $dot = strrpos( $name, '.' );
71 if ( false != $dot ) {
72 $name = substr( $name, 0, $dot );
73 }
74 $name = TCMP_PLUGIN_PREFIX . '_' . $name;
75 }
76
77 $v = '?v=' . TCMP_PLUGIN_VERSION;
78 wp_enqueue_style( $name, TCMP_PLUGIN_URI . $uri . $v );
79 }
80 function wpEnqueueScript( $uri, $name = '', $version = false ) {
81 if ( '' == $name ) {
82 $name = explode( '/', $uri );
83 $name = $name[ count( $name ) - 1 ];
84 $dot = strrpos( $name, '.' );
85 if ( false != $dot ) {
86 $name = substr( $name, 0, $dot );
87 }
88 $name = TCMP_PLUGIN_PREFIX . '_' . $name;
89 }
90
91 $v = '?v=' . TCMP_PLUGIN_VERSION;
92 $deps = array();
93 wp_enqueue_script( $name, TCMP_PLUGIN_URI . $uri . $v, $deps, $version, false );
94 }
95
96 function showTabPage() {
97 global $tcmp;
98
99 $v = $tcmp->options->getShowWhatsNewSeenVersion();
100 if ( TCMP_WHATSNEW_VERSION != $v ) {
101 $tcmp->options->setShowWhatsNew( true );
102 }
103
104 $hwb = tcmp_isqs( 'hwb', '' );
105 if ( '' != $hwb ) {
106 $tcmp->options->setShowWhatsNew( false );
107 }
108
109 $id = tcmp_isqs( 'id', 0 );
110 $default_tab = TCMP_TAB_MANAGER;
111 $tab = tcmp_sqs( 'tab', $default_tab );
112
113 if ( $tcmp->options->isShowWhatsNew() ) {
114 $tab = TCMP_TAB_WHATS_NEW;
115 $default_tab = $tab;
116 $this->tabs[ TCMP_TAB_WHATS_NEW ] = $tcmp->lang->L( 'What\'s New' );
117 //$this->tabs[TCMP_TAB_MANAGER]=$tcmp->lang->L('Start using the plugin!');
118 } else {
119 if ( $id > 0 || ! $tcmp->manager->is_limit_reached( false ) ) {
120 $this->tabs[ TCMP_TAB_EDITOR ] = $tcmp->lang->L( $id > 0 && TCMP_TAB_EDITOR == $tab ? 'Edit Script' : 'Add New Script' );
121 } elseif ( TCMP_TAB_EDITOR == $tab ) {
122 $tab = TCMP_TAB_MANAGER;
123 }
124
125 $this->tabs[ TCMP_TAB_MANAGER ] = $tcmp->lang->L( 'Manager' );
126 $this->tabs[ TCMP_TAB_ADMIN_OPTIONS ] = $tcmp->lang->L( 'Admin Options' );
127 $this->tabs[ TCMP_TAB_SETTINGS ] = $tcmp->lang->L( 'Settings' );
128 $this->tabs[ TCMP_TAB_DOCS ] = $tcmp->lang->L( 'Docs & FAQ' );
129 }
130
131 ?>
132
133 <div class="wrap" style="margin: 5px;">
134 <?php
135 $this->showTabs( $default_tab );
136 $header = '';
137 switch ( $tab ) {
138 case TCMP_TAB_EDITOR:
139 $header = ( $id > 0 ? 'Edit' : 'Add' );
140 break;
141 case TCMP_TAB_WHATS_NEW:
142 $header = '';
143 break;
144 case TCMP_TAB_MANAGER:
145 $header = 'Manager';
146 break;
147 case TCMP_TAB_ADMIN_OPTIONS:
148 $header = 'Admin Options';
149 break;
150 case TCMP_TAB_SETTINGS:
151 $header = 'Settings';
152 break;
153 }
154
155 if ( $tcmp->lang->H( $header . 'Title' ) ) {
156 ?>
157 <h2><?php $tcmp->lang->P( $header . 'Title', TCMP_PLUGIN_VERSION ); ?></h2>
158 <?php if ( $tcmp->lang->H( $header . 'Subtitle' ) ) { ?>
159 <div><?php $tcmp->lang->P( $header . 'Subtitle' ); ?></div>
160 <?php } ?>
161 <br/>
162 <?php
163 }
164
165 tcmp_ui_first_time();
166 ?>
167 <div style="float:left; margin:5px;">
168 <?php
169 $styles = array();
170 $styles[] = 'float:left';
171 $styles[] = 'margin-right:20px';
172 if ( TCMP_TAB_WHATS_NEW != $tab ) {
173 $styles[] = 'max-width:750px';
174 }
175 $styles = implode( '; ', $styles );
176 ?>
177 <div id="tcmp-page" style="<?php echo esc_attr( $styles ); ?>">
178 <?php
179 switch ( $tab ) {
180 case TCMP_TAB_WHATS_NEW:
181 tcmp_ui_whats_new();
182 break;
183 case TCMP_TAB_EDITOR:
184 tcmp_ui_editor();
185 break;
186 case TCMP_TAB_MANAGER:
187 tcmp_ui_manager();
188 break;
189 case TCMP_TAB_ADMIN_OPTIONS:
190 tcmp_ui_admin_options();
191 break;
192 case TCMP_TAB_SETTINGS:
193 tcmp_ui_track();
194 tcmp_ui_settings();
195 break;
196 }
197 ?>
198 </div>
199 <?php if ( TCMP_TAB_WHATS_NEW != $tab ) { ?>
200 <div id="tcmp-sidebar" style="float:left; max-width: 250px;">
201 <?php
202 $count = $this->getPluginsCount();
203 $plugins = array();
204 while ( count( $plugins ) < 2 ) {
205 $id = rand( 1, $count );
206 if ( ! isset( $plugins[ $id ] ) ) {
207 $plugins[ $id ] = $id;
208 }
209 }
210
211 $this->drawContactUsWidget();
212 foreach ( $plugins as $id ) {
213 $this->drawPluginWidget( $id );
214 }
215 ?>
216 </div>
217 <?php } ?>
218 </div>
219 </div>
220 <div style="clear:both"></div>
221 <?php
222 }
223 function getPluginsCount() {
224 global $tcmp;
225 $index = 1;
226 while ( $tcmp->lang->H( 'Plugin' . $index . '.Name' ) ) {
227 $index++;
228 }
229 return $index - 1;
230 }
231 function drawPluginWidget( $id ) {
232 global $tcmp;
233 ?>
234 <div class="tcmp-plugin-widget">
235 <b><?php $tcmp->lang->P( 'Plugin' . $id . '.Name' ); ?></b>
236 <br>
237 <i><?php $tcmp->lang->P( 'Plugin' . $id . '.Subtitle' ); ?></i>
238 <br>
239 <ul style="list-style: circle;">
240 <?php
241 $index = 1;
242 while ( $tcmp->lang->H( 'Plugin' . $id . '.Feature' . $index ) ) {
243 ?>
244 <li><?php $tcmp->lang->P( 'Plugin' . $id . '.Feature' . $index ); ?></li>
245 <?php
246 $index++;
247 }
248 ?>
249 </ul>
250 <a style="float:right;" class="button-primary" href="<?php $tcmp->lang->P( 'Plugin' . $id . '.Permalink' ); ?>" target="_blank">
251 <?php $tcmp->lang->P( 'PluginCTA' ); ?>
252 </a>
253 <div style="clear:both"></div>
254 </div>
255 <br>
256 <?php
257 }
258 function drawContactUsWidget() {
259 global $tcmp;
260 ?>
261 <b><?php $tcmp->lang->P( 'Sidebar.Title' ); ?></b>
262 <ul style="list-style: circle;">
263 <?php
264 $index = 1;
265 while ( $tcmp->lang->H( 'Sidebar' . $index . '.Name' ) ) {
266 ?>
267 <li>
268 <a href="<?php $tcmp->lang->P( 'Sidebar' . $index . '.Url' ); ?>" target="_blank">
269 <?php $tcmp->lang->P( 'Sidebar' . $index . '.Name' ); ?>
270 </a>
271 </li>
272 <?php
273 $index++;
274 }
275 ?>
276 </ul>
277 <?php
278 }
279 function showTabs( $default_tab ) {
280 global $tcmp;
281 $tab = $tcmp->check->of( 'tab', $default_tab );
282 if ( $tcmp->options->isShowWhatsNew() ) {
283 $tab = TCMP_TAB_WHATS_NEW;
284 }
285
286 ?>
287 <h2 class="nav-tab-wrapper" style="float:left; width:97%;">
288 <?php
289
290 foreach ( $this->tabs as $k => $v ) {
291 $active = ( $tab == $k ? 'nav-tab-active' : '' );
292 $style = '';
293 $target = '_self';
294 if ( $tcmp->options->isShowWhatsNew() && TCMP_TAB_MANAGER == $k ) {
295 $active = '';
296 $style = 'background-color:#F2E49B';
297 }
298 if ( TCMP_TAB_DOCS == $k ) {
299 $target = '_blank';
300 $style = 'background-color:#F2E49B';
301 ?>
302 <a href="<?php echo esc_url(TCMP_TAB_DOCS_URI) ?>" class="nav-tab <?php echo esc_attr( $active ); ?>" style="float:left; margin-left:10px;background-color:#F2E49B;" target="_blank">
303 <?php echo esc_attr( $v ); ?>
304 </a>
305 <?php
306 } else {
307 ?>
308 <a style="float:left; margin-left:10px; <?php echo esc_attr( $style ); ?>" class="nav-tab <?php echo esc_attr( $active ); ?>" target="<?php echo esc_attr( $target ); ?>" href="?page=<?php echo TCMP_PLUGIN_SLUG; ?>&tab=<?php echo esc_attr( $k ); ?>"><?php echo esc_attr( $v ); ?></a>
309 <?php
310 }
311 }
312 ?>
313 <div style="float:right; display:none;" id="rate-box">
314 <span style="font-weight:700; font-size:13px; color:#555;"><?php $tcmp->lang->P( 'Rate us' ); ?></span>
315 <div id="tcmp-rate" class="starrr" data-connected-input="tcmp-rate-rank"></div>
316 <input type="hidden" id="tcmp-rate-rank" name="tcmp-rate-rank" value="5" />
317 <?php $tcmp->utils->twitter( 'data443risk' ); ?>
318 </div>
319 </h2>
320 <div style="clear:both;"></div>
321 <?php
322 }
323 }
324
325