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