PluginProbe ʕ •ᴥ•ʔ
My Sticky Bar – Floating Notification Bar & Sticky Header (formerly myStickymenu) / 2.0.6
My Sticky Bar – Floating Notification Bar & Sticky Header (formerly myStickymenu) v2.0.6
2.9.1 2.9.0 2.8.9 2.8.8 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 2.0 2.0.1 2.0.3 2.0.4 2.0.5 2.0.6 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7
mystickymenu / mystickymenu.php
mystickymenu Last commit date
css 7 years ago js 7 years ago languages 8 years ago index.php 8 years ago mystickymenu.php 7 years ago readme.txt 7 years ago uninstall.php 8 years ago
mystickymenu.php
1091 lines
1 <?php
2 /*
3 Plugin Name: myStickymenu
4 Plugin URI: https://premio.io/
5 Description: Simple sticky (fixed on top) menu implementation for navigation menu. After install go to Settings / myStickymenu and change Sticky Class to .your_navbar_class or #your_navbar_id.
6 Version: 2.0.6
7 Author: Premio
8 Author URI: https://premio.io/
9 Text Domain: mystickymenu
10 Domain Path: /languages
11 License: GPLv2 or later
12 */
13
14 defined('ABSPATH') or die("Cannot access pages directly.");
15 define( 'MYSTICKY_VERSION', '2.0.6' );
16
17 class MyStickyMenuBackend
18 {
19
20 private $options;
21
22
23
24 public function __construct()
25 {
26
27
28 add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
29 add_action( 'admin_init', array( $this, 'mysticky_load_transl') );
30 add_action( 'admin_init', array( $this, 'page_init' ) );
31 add_action( 'admin_init', array( $this, 'mysticky_default_options' ) );
32
33 //add_action( 'admin_enqueue_scripts', array( $this, 'mysticky_enqueue_color_picker' ) );
34 //add_action( 'admin_head', array( $this, 'mysticky_admin_script' ) );
35 add_action( 'admin_enqueue_scripts', array( $this, 'mysticky_admin_script' ) );
36
37 add_filter( 'plugin_action_links_mystickymenu/mystickymenu.php', array( $this, 'mystickymenu_settings_link' ) );
38
39
40 }
41
42 public function mystickymenu_settings_link($links){
43 $settings_link = '<a href="options-general.php?page=my-stickymenu-settings">Settings</a>';
44 array_unshift($links, $settings_link);
45 return $links;
46 }
47
48
49
50
51
52 public function mysticky_admin_script($hook) {
53 if ($hook != 'settings_page_my-stickymenu-settings') {
54 return;
55 }
56
57 wp_register_script('mystickymenuAdminScript', plugins_url('/js/mystickymenu-admin.js', __FILE__), array( 'jquery' ), MYSTICKY_VERSION);
58 wp_enqueue_script('mystickymenuAdminScript');
59
60 wp_register_style('mystickymenuAdminStyle', plugins_url('/css/mystickymenu-admin.css', __FILE__) );
61 wp_enqueue_style('mystickymenuAdminStyle');
62
63 wp_enqueue_style( 'wp-color-picker' );
64 wp_enqueue_script( 'my-script-handle', plugins_url('js/iris-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
65 }
66
67 /*
68 public function mysticky_enqueue_color_picker( )
69 {
70 wp_enqueue_style( 'wp-color-picker' );
71 wp_enqueue_script( 'my-script-handle', plugins_url('js/iris-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
72
73 }
74
75 */
76
77
78
79 public function mysticky_load_transl(){
80 load_plugin_textdomain('mystickymenu', FALSE, dirname(plugin_basename(__FILE__)).'/languages/');
81 }
82
83 public function add_plugin_page(){
84 // This page will be under "Settings"
85 add_options_page(
86 'Settings Admin',
87 'myStickymenu',
88 'manage_options',
89 'my-stickymenu-settings',
90 array( $this, 'create_admin_page' )
91 );
92 }
93
94 public function create_admin_page(){
95 // Set class property
96 $this->options = get_option( 'mysticky_option_name');
97 ?>
98 <div id="mystickymenu" class="wrap">
99
100 <h2><?php _e('myStickymenu', 'mystickymenu'); ?></h2>
101 <p><?php _e("Add sticky menu / header to any theme. <br />Simply change 'Sticky Class' to HTML element class desired to be sticky (div id can be used as well).", 'mystickymenu'); ?></p>
102
103 <div class="main-content">
104
105
106
107 <?php $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'mysticky-general'; ?>
108
109 <h2 class="nav-tab-wrapper">
110 <a class="nav-tab btn-general <?php echo $active_tab == 'mysticky-general' ? 'nav-tab-active' : ''; ?>">General Settings</a>
111 <a class="nav-tab btn-style <?php echo $active_tab == 'mysticky-style' ? 'nav-tab-active' : ''; ?>">Style</a>
112 <a class="nav-tab btn-advanced <?php echo $active_tab == 'mysticky-advanced' ? 'nav-tab-active' : ''; ?>">Advanced</a>
113 </h2>
114
115
116
117
118
119
120
121
122
123 <form class="mysticky-hideform" method="post" action="options.php">
124
125
126
127 <?php
128
129
130 //we check if the page is visited by click on the tabs or on the menu button.
131 //then we get the active tab.
132
133 if(isset($_GET["tab"]))
134 {
135
136 if($_GET["tab"] == "mysticky-general")
137 {
138 echo '<div class="mysticky-general">';
139 settings_fields( 'mysticky_option_group' );
140 do_settings_sections( 'my-stickymenu-settings' );
141 echo '</div>';
142
143 }
144 else if($_GET["tab"] == "mysticky-style")
145 {
146 echo '<div class="mysticky-style">';
147 settings_fields( 'mysticky_option_group' );
148 do_settings_sections( 'my-stickymenu-settings' );
149 echo '</div>';
150 }
151
152 else if($_GET["tab"] == "mysticky-advanced")
153 {
154 echo '<div class="mysticky-advanced">';
155 settings_fields( 'mysticky_option_group' );
156 do_settings_sections( 'my-stickymenu-settings' );
157 echo '</div>';
158 }
159
160
161 }
162
163 else {
164
165 // echo '<div class="mysticky-general">';
166 settings_fields( 'mysticky_option_group' );
167 do_settings_sections( 'my-stickymenu-settings' );
168 // echo '</div>';
169
170
171 }
172
173
174 submit_button();
175 ?>
176
177
178 </form>
179
180 <form class="mysticky-hideformreset" method="post" action="">
181 <input name="reset" class="button button-secondary confirm" type="submit" value="Reset to default settings" >
182 <input type="hidden" name="action" value="reset" />
183 </form>
184
185
186 </div>
187
188
189 <div class="main-sidebar">
190
191 <h3><?php _e('Plugin info','mystickymenu'); ?></h3>
192
193 <div class="inner">
194 <ul>
195 <li><strong><?php _e('Author:','mystickymenu'); ?></strong> <a href="https://premio.io/" target="_blank">Premio</a></li>
196 <li><strong><?php _e('Version:','mystickymenu'); ?></strong> <?php echo MYSTICKY_VERSION; ?></li>
197 <li><strong><?php _e('Documentation:','mystickymenu'); ?></strong> <a href="http://wordpress.transformnews.com/plugins/mystickymenu-simple-sticky-fixed-on-top-menu-implementation-for-twentythirteen-menu-269" target="_blank">About Plugin</a> <a href="http://wordpress.transformnews.com/tutorials/mystickymenu-theme-support-682" target="_blank">Theme Support</a></li>
198 <li><strong><?php _e('Support Forum','mystickymenu'); ?></strong>: <a href="https://wordpress.org/support/plugin/mystickymenu" target="_blank">WordPress.org</a></li>
199 <!--<li><strong><?php _e('Donate:','mystickymenu'); ?></strong> <a href="" target="_blank">Soon</a></li>-->
200
201 </ul>
202 </div>
203
204 <p><a href="https://wordpress.org/support/plugin/mystickymenu/reviews/" target="_blank"><strong><?php _e('Add your own review','mystickymenu'); ?></strong></a></p>
205
206 </div>
207 </div>
208 <?php
209 }
210
211 public function page_init()
212 {
213 global $id, $title, $callback, $page;
214 register_setting(
215 'mysticky_option_group',
216 'mysticky_option_name',
217 array( $this, 'sanitize' )
218 );
219
220
221
222
223 add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() );
224
225 add_settings_section(
226 'setting_section_id',
227 __(" ", 'mystickymenu'),
228 array( $this, 'print_section_info' ),
229 'my-stickymenu-settings'
230
231 );
232
233
234
235
236
237 add_settings_field(
238 'mysticky_class_selector',
239 __("Sticky Class", 'mystickymenu'),
240 array( $this, 'mysticky_class_selector_callback' ),
241 'my-stickymenu-settings',
242 'setting_section_id'
243 );
244
245 add_settings_field(
246 'myfixed_fade',
247 __("Fade or slide effect", 'mystickymenu'),
248 array( $this, 'myfixed_fade_callback' ),
249 'my-stickymenu-settings',
250 'setting_section_id'
251 );
252 add_settings_field(
253 'myfixed_zindex',
254 __("Sticky z-index", 'mystickymenu'),
255 array( $this, 'myfixed_zindex_callback' ),
256 'my-stickymenu-settings',
257 'setting_section_id'
258 );
259 add_settings_field(
260 'myfixed_bgcolor',
261 __("Sticky Background Color", 'mystickymenu'),
262 array( $this, 'myfixed_bgcolor_callback' ),
263 'my-stickymenu-settings',
264 'setting_section_id'
265 );
266 add_settings_field(
267 'myfixed_opacity',
268 __("Sticky Opacity", 'mystickymenu'),
269 array( $this, 'myfixed_opacity_callback' ),
270 'my-stickymenu-settings',
271 'setting_section_id'
272 );
273 add_settings_field(
274 'myfixed_transition_time',
275 __("Sticky Transition Time", 'mystickymenu'),
276 array( $this, 'myfixed_transition_time_callback' ),
277 'my-stickymenu-settings',
278 'setting_section_id'
279 );
280 add_settings_field(
281 'myfixed_disable_small_screen',
282 __("Disable at Small Screen Sizes", 'mystickymenu'),
283 array( $this, 'myfixed_disable_small_screen_callback' ),
284 'my-stickymenu-settings',
285 'setting_section_id'
286 );
287 add_settings_field(
288 'myfixed_disable_large_screen',
289 __("Disable at Large Screen Sizes", 'mystickymenu'),
290 array( $this, 'myfixed_disable_large_screen_callback' ),
291 'my-stickymenu-settings',
292 'setting_section_id'
293 );
294 add_settings_field(
295 'mysticky_active_on_height',
296 __("Make visible on Scroll", 'mystickymenu'),
297 array( $this, 'mysticky_active_on_height_callback' ),
298 'my-stickymenu-settings',
299 'setting_section_id'
300 );
301 add_settings_field(
302 'mysticky_active_on_height_home',
303 __("Make visible on Scroll at homepage", 'mystickymenu'),
304 array( $this, 'mysticky_active_on_height_home_callback' ),
305 'my-stickymenu-settings',
306 'setting_section_id'
307 );
308
309
310 add_settings_field(
311 'myfixed_disable_scroll_down',
312 __("Disable on scroll down", 'mystickymenu'),
313 'my-stickymenu-settings',
314 'setting_section_id'
315 );
316
317 add_settings_field(
318 'myfixed_cssstyle',
319 __("CSS style", 'mystickymenu'),
320 array( $this, 'myfixed_cssstyle_callback' ),
321 'my-stickymenu-settings',
322 'setting_section_id'
323 );
324 add_settings_field(
325 'disable_css',
326 __("Disable CSS style", 'mystickymenu'),
327 array( $this, 'disable_css_callback' ),
328 'my-stickymenu-settings',
329 'setting_section_id'
330 );
331
332
333
334 add_settings_field(
335 'mysticky_disable_at_front_home',
336 __("Disable at", 'mystickymenu'),
337 array( $this, 'mysticky_enable_callback' ),
338 'my-stickymenu-settings',
339 'setting_section_id'
340 );
341 add_settings_field(
342 'mysticky_disable_at_blog',
343 __("Disable at", 'mystickymenu'),
344 'my-stickymenu-settings',
345 'setting_section_id'
346 );
347 add_settings_field(
348 'mysticky_disable_at_page',
349 __("Disable at", 'mystickymenu'),
350 'my-stickymenu-settings',
351 'setting_section_id'
352 );
353 add_settings_field(
354 'mysticky_disable_at_tag',
355 __("Disable at", 'mystickymenu'),
356 'my-stickymenu-settings',
357 'setting_section_id'
358 );
359 add_settings_field(
360 'mysticky_disable_at_category',
361 __("Disable at", 'mystickymenu'),
362 'my-stickymenu-settings',
363 'setting_section_id'
364 );
365 add_settings_field(
366 'mysticky_disable_at_single',
367 __("Disable at", 'mystickymenu'),
368 'my-stickymenu-settings',
369 'setting_section_id'
370 );
371 add_settings_field(
372 'mysticky_disable_at_archive',
373 __("Disable at", 'mystickymenu'),
374 'my-stickymenu-settings',
375 'setting_section_id'
376 );
377 add_settings_field(
378 'mysticky_enable_at_pages',
379 __(" ", 'mystickymenu'),
380 'my-stickymenu-settings',
381 'setting_section_id'
382 );
383 add_settings_field(
384 'mysticky_enable_at_posts',
385 __(" ", 'mystickymenu'),
386 'my-stickymenu-settings',
387 'setting_section_id'
388 );
389 add_settings_field(
390 'mysticky_disable_at_search',
391 __("Disable at", 'mystickymenu'),
392 'my-stickymenu-settings',
393 'setting_section_id'
394 );
395 add_settings_field(
396 'mysticky_disable_at_404',
397 __("Disable at", 'mystickymenu'),
398 'my-stickymenu-settings',
399 'setting_section_id'
400 );
401
402
403
404 }
405 /**
406 * Sanitize each setting field as needed
407 *
408 * @param array $input Contains all settings fields as array keys
409 */
410 public function sanitize( $input )
411 {
412 $new_input = array();
413 if( isset( $input['mysticky_class_selector'] ) )
414 $new_input['mysticky_class_selector'] = sanitize_text_field( $input['mysticky_class_selector'] );
415
416 if( isset( $input['myfixed_zindex'] ) )
417 $new_input['myfixed_zindex'] = absint( $input['myfixed_zindex'] );
418
419 if( isset( $input['myfixed_bgcolor'] ) )
420 $new_input['myfixed_bgcolor'] = sanitize_text_field( $input['myfixed_bgcolor'] );
421
422 if( isset( $input['myfixed_opacity'] ) )
423 $new_input['myfixed_opacity'] = absint( $input['myfixed_opacity'] );
424
425 if( isset( $input['myfixed_transition_time'] ) )
426 $new_input['myfixed_transition_time'] = sanitize_text_field( $input['myfixed_transition_time'] );
427
428 if( isset( $input['myfixed_disable_small_screen'] ) )
429 $new_input['myfixed_disable_small_screen'] = absint( $input['myfixed_disable_small_screen'] );
430
431 if( isset( $input['myfixed_disable_large_screen'] ) )
432 $new_input['myfixed_disable_large_screen'] = absint( $input['myfixed_disable_large_screen'] );
433
434 if( isset( $input['mysticky_active_on_height'] ) )
435 $new_input['mysticky_active_on_height'] = absint( $input['mysticky_active_on_height'] );
436
437 if( isset( $input['mysticky_active_on_height_home'] ) )
438 $new_input['mysticky_active_on_height_home'] = absint( $input['mysticky_active_on_height_home'] );
439
440 if( isset( $input['myfixed_fade'] ) )
441 $new_input['myfixed_fade'] = sanitize_text_field( $input['myfixed_fade'] );
442
443 if( isset( $input['myfixed_disable_scroll_down'] ) )
444 $new_input['myfixed_disable_scroll_down'] = sanitize_text_field( $input['myfixed_disable_scroll_down'] );
445
446
447 if( isset( $input['myfixed_cssstyle'] ) )
448 $new_input['myfixed_cssstyle'] = sanitize_text_field( $input['myfixed_cssstyle'] );
449
450 if( isset( $input['disable_css'] ) )
451 $new_input['disable_css'] = sanitize_text_field( $input['disable_css'] );
452
453
454
455 if( isset( $input['mysticky_disable_at_front_home'] ) )
456 $new_input['mysticky_disable_at_front_home'] = sanitize_text_field( $input['mysticky_disable_at_front_home'] );
457
458 if( isset( $input['mysticky_disable_at_blog'] ) )
459 $new_input['mysticky_disable_at_blog'] = sanitize_text_field( $input['mysticky_disable_at_blog'] );
460
461 if( isset( $input['mysticky_disable_at_page'] ) )
462 $new_input['mysticky_disable_at_page'] = sanitize_text_field( $input['mysticky_disable_at_page'] );
463
464 if( isset( $input['mysticky_disable_at_tag'] ) )
465 $new_input['mysticky_disable_at_tag'] = sanitize_text_field( $input['mysticky_disable_at_tag'] );
466
467 if( isset( $input['mysticky_disable_at_category'] ) )
468 $new_input['mysticky_disable_at_category'] = sanitize_text_field( $input['mysticky_disable_at_category'] );
469
470 if( isset( $input['mysticky_disable_at_single'] ) )
471 $new_input['mysticky_disable_at_single'] = sanitize_text_field( $input['mysticky_disable_at_single'] );
472
473 if( isset( $input['mysticky_disable_at_archive'] ) )
474 $new_input['mysticky_disable_at_archive'] = sanitize_text_field( $input['mysticky_disable_at_archive'] );
475
476 if( isset( $input['mysticky_enable_at_pages'] ) )
477 $new_input['mysticky_enable_at_pages'] = sanitize_text_field( $input['mysticky_enable_at_pages'] );
478
479 if( isset( $input['mysticky_enable_at_posts'] ) )
480 $new_input['mysticky_enable_at_posts'] = sanitize_text_field( $input['mysticky_enable_at_posts'] );
481
482 if( isset( $input['mysticky_disable_at_search'] ) )
483 $new_input['mysticky_disable_at_search'] = sanitize_text_field( $input['mysticky_disable_at_search'] );
484
485 if( isset( $input['mysticky_disable_at_404'] ) )
486 $new_input['mysticky_disable_at_404'] = sanitize_text_field( $input['mysticky_disable_at_404'] );
487
488
489
490
491 return $new_input;
492 }
493
494 public function mysticky_default_options() {
495
496 global $options;
497 $default = array(
498
499 'mysticky_class_selector' => '.navbar',
500 'myfixed_zindex' => '99990',
501 'myfixed_bgcolor' => '#f7f5e7',
502 'myfixed_opacity' => '90',
503 'myfixed_transition_time' => '0.3',
504 'myfixed_disable_small_screen' => '0',
505 'myfixed_disable_large_screen' => '0',
506 'mysticky_active_on_height' => '0',
507 'mysticky_active_on_height_home' => '0',
508 'myfixed_fade' => 'on',
509 'myfixed_cssstyle' => '#mysticky-nav .myfixed { margin:0 auto; float:none; border:0px; background:none; max-width:100%; }'
510 );
511
512 if ( get_option('mysticky_option_name') == false ) {
513 update_option( 'mysticky_option_name', $default );
514 }
515
516
517 if(isset($_POST['reset'])) {
518 update_option( 'mysticky_option_name', $default );
519 }
520
521
522 }
523
524
525
526
527
528
529 public function print_section_info()
530 {
531 echo __(" ", 'mystickymenu');
532 }
533
534 public function mysticky_class_selector_callback()
535 {
536 printf(
537 '<p class="description"><input type="text" size="18" id="mysticky_class_selector" class="mystickyinput" name="mysticky_option_name[mysticky_class_selector]" value="%s" /> ',
538 isset( $this->options['mysticky_class_selector'] ) ? esc_attr( $this->options['mysticky_class_selector']) : ''
539 );
540 echo __("menu or header element class or id.", 'mystickymenu');
541 echo '</p>';
542 }
543
544 public function myfixed_zindex_callback()
545 {
546 printf(
547 '<p class="description"><input type="number" min="0" max="2147483647" step="1" id="myfixed_zindex" name="mysticky_option_name[myfixed_zindex]" value="%s" /></p>',
548 isset( $this->options['myfixed_zindex'] ) ? esc_attr( $this->options['myfixed_zindex']) : ''
549 );
550 }
551
552 public function myfixed_bgcolor_callback()
553 {
554 printf(
555 '<p class="description"><input type="text" id="myfixed_bgcolor" name="mysticky_option_name[myfixed_bgcolor]" class="my-color-field" value="%s" /></p> ' ,
556 isset( $this->options['myfixed_bgcolor'] ) ? esc_attr( $this->options['myfixed_bgcolor']) : ''
557 );
558 }
559
560 public function myfixed_opacity_callback()
561 {
562 printf(
563 '<p class="description"><input type="number" class="small-text" min="0" step="1" max="100" id="myfixed_opacity" name="mysticky_option_name[myfixed_opacity]" value="%s" /> ',
564 isset( $this->options['myfixed_opacity'] ) ? esc_attr( $this->options['myfixed_opacity']) : ''
565 );
566 echo __("numbers 1-100.", 'mystickymenu');
567 echo '</p>';
568 }
569
570 public function myfixed_transition_time_callback()
571 {
572 printf(
573 '<p class="description"><input type="number" class="small-text" min="0" step="0.1" id="myfixed_transition_time" name="mysticky_option_name[myfixed_transition_time]" value="%s" /> ',
574 isset( $this->options['myfixed_transition_time'] ) ? esc_attr( $this->options['myfixed_transition_time']) : ''
575 );
576 echo __("in seconds.", 'mystickymenu');
577 echo '</p>';
578 }
579
580 public function myfixed_disable_small_screen_callback()
581 {
582 printf(
583 '<p class="description">'
584 );
585 echo __("less than", 'mystickymenu');
586 printf(
587 ' <input type="number" class="small-text" min="0" step="1" id="myfixed_disable_small_screen" name="mysticky_option_name[myfixed_disable_small_screen]" value="%s" />',
588 isset( $this->options['myfixed_disable_small_screen'] ) ? esc_attr( $this->options['myfixed_disable_small_screen']) : ''
589 );
590 echo __("px width, 0 to disable.", 'mystickymenu');
591 echo '</p>';
592 }
593
594
595
596 public function myfixed_disable_large_screen_callback()
597 {
598 printf(
599 '<p class="description">'
600 );
601 echo __("more than", 'mystickymenu');
602 printf(
603 ' <input type="number" class="small-text" min="0" step="1" id="myfixed_disable_large_screen" name="mysticky_option_name[myfixed_disable_large_screen]" value="%s" />',
604 isset( $this->options['myfixed_disable_large_screen'] ) ? esc_attr( $this->options['myfixed_disable_large_screen']) : ''
605 );
606 echo __("px width, 0 to disable.", 'mystickymenu');
607 echo '</p>';
608 }
609
610
611
612 public function mysticky_active_on_height_callback()
613 {
614 printf(
615 '<p class="description">'
616 );
617 echo __("after", 'mystickymenu');
618 printf(
619 ' <input type="number" class="small-text" min="0" step="1" id="mysticky_active_on_height" name="mysticky_option_name[mysticky_active_on_height]" value="%s" />',
620 isset( $this->options['mysticky_active_on_height'] ) ? esc_attr( $this->options['mysticky_active_on_height']) : ''
621 );
622 echo __("px. If set to 0 auto calculate will be used.", 'mystickymenu');
623 echo '</p>';
624 }
625
626 public function mysticky_active_on_height_home_callback()
627 {
628 printf(
629 '<p class="description">'
630 );
631 echo __("after", 'mystickymenu');
632 printf(
633 ' <input type="number" class="small-text" min="0" step="1" id="mysticky_active_on_height_home" name="mysticky_option_name[mysticky_active_on_height_home]" value="%s" />',
634 isset( $this->options['mysticky_active_on_height_home'] ) ? esc_attr( $this->options['mysticky_active_on_height_home']) : ''
635 );
636 echo __("px. If set to 0 it will use initial Make visible on Scroll value.", 'mystickymenu');
637 echo '</p>';
638 }
639
640 public function myfixed_fade_callback()
641 {
642 printf(
643 '<p class="description"><input id="%1$s" name="mysticky_option_name[myfixed_fade]" type="checkbox" %2$s /> ',
644 'myfixed_fade',
645 checked( isset( $this->options['myfixed_fade'] ), true, false )
646 );
647 echo __("Checked is slide, unchecked is fade.", 'mystickymenu');
648 echo '</p>';
649
650 printf(
651 '<p class="description"><input id="%1$s" name="mysticky_option_name[myfixed_disable_scroll_down]" type="checkbox" %2$s /> ',
652 'myfixed_disable_scroll_down',
653 checked( isset( $this->options['myfixed_disable_scroll_down'] ), true, false )
654 );
655 echo __("Disable sticky menu at scroll down", 'mystickymenu');
656 echo '</p>';
657
658
659
660
661 }
662
663 public function myfixed_cssstyle_callback()
664 {
665 printf(
666 '<p class="description">'
667 );
668 echo __("Add/edit CSS style. Leave it blank for default style.", 'mystickymenu');
669 echo '</p>';
670 printf(
671 '<textarea type="text" rows="4" cols="60" id="myfixed_cssstyle" name="mysticky_option_name[myfixed_cssstyle]">%s</textarea> <br />',
672 isset( $this->options['myfixed_cssstyle'] ) ? esc_attr( $this->options['myfixed_cssstyle']) : ''
673 );
674
675 echo '<p>';
676 echo __("CSS ID's and Classes to use:", 'mystickymenu');
677 echo'</p>';
678
679 echo '<pre>#mysticky-wrap { }<br>';
680 echo '#mysticky-nav.wrapfixed { }<br>';
681 echo '#mysticky-nav.wrapfixed.up { }<br>';
682 echo '#mysticky-nav.wrapfixed.down { }<br>';
683 echo '#mysticky-nav ';
684 printf (
685 isset( $this->options['mysticky_class_selector'] ) ? esc_attr( $this->options['mysticky_class_selector']) : ''
686 );
687 echo ' { }<br>#mysticky-nav ';
688 printf (
689 isset( $this->options['mysticky_class_selector'] ) ? esc_attr( $this->options['mysticky_class_selector']) : ''
690 );
691 echo '.myfixed { }</pre>';
692 echo '<p class="description">';
693 echo __("Find examples <a href='http://wordpress.transformnews.com/tutorials/mystickymenu-extended-style-functionality-using-myfixed-sticky-class-403'>here</a>.", 'mystickymenu');
694 echo'</p>';
695 }
696
697 public function disable_css_callback()
698 {
699 printf(
700 '<p class="description"><input id="%1$s" name="mysticky_option_name[disable_css]" type="checkbox" %2$s /> ',
701 'disable_css',
702 checked( isset( $this->options['disable_css'] ), true, false )
703 );
704 echo __("Use this option if you plan to include CSS Style manually", 'mystickymenu');
705 echo '</p>';
706 }
707
708
709
710
711
712
713
714
715
716
717
718
719
720 public function mysticky_enable_callback()
721 {
722
723
724 printf(
725 '<div><input id="%1$s" name="mysticky_option_name[mysticky_disable_at_front_home]" type="checkbox" %2$s /> ',
726 'mysticky_disable_at_front_home',
727 checked( isset( $this->options['mysticky_disable_at_front_home'] ), true, false )
728 ) ;
729 _e('<span>front page </span>', 'mystickymenu');
730 printf('</div>');
731 printf(
732 '<div><input id="%1$s" name="mysticky_option_name[mysticky_disable_at_blog]" type="checkbox" %2$s /> ',
733 'mysticky_disable_at_blog',
734 checked( isset( $this->options['mysticky_disable_at_blog'] ), true, false )
735 );
736 _e('<span>blog page </span>', 'mystickymenu');
737 printf('</div>');
738
739 printf(
740 '<div><input id="%1$s" name="mysticky_option_name[mysticky_disable_at_page]" type="checkbox" %2$s /> ',
741 'mysticky_disable_at_page',
742 checked( isset( $this->options['mysticky_disable_at_page'] ), true, false )
743 );
744 _e('<span>pages </span>', 'mystickymenu');
745 printf('</div>');
746
747 printf(
748 '<div><input id="%1$s" name="mysticky_option_name[mysticky_disable_at_tag]" type="checkbox" %2$s /> ',
749 'mysticky_disable_at_tag',
750 checked( isset( $this->options['mysticky_disable_at_tag'] ), true, false )
751 );
752 _e('<span>tags </span>', 'mystickymenu');
753 printf('</div>');
754
755 printf(
756 '<div><input id="%1$s" name="mysticky_option_name[mysticky_disable_at_category]" type="checkbox" %2$s /> ',
757 'mysticky_disable_at_category',
758 checked( isset( $this->options['mysticky_disable_at_category'] ), true, false )
759 );
760 _e('<span>categories </span>', 'mystickymenu');
761 printf('</div>');
762
763 printf(
764 '<div><input id="%1$s" name="mysticky_option_name[mysticky_disable_at_single]" type="checkbox" %2$s /> ',
765 'mysticky_disable_at_single',
766 checked( isset( $this->options['mysticky_disable_at_single'] ), true, false )
767 );
768 _e('<span>posts </span>', 'mystickymenu');
769 printf('</div>');
770
771 printf(
772 '<div><input id="%1$s" name="mysticky_option_name[mysticky_disable_at_archive]" type="checkbox" %2$s /> ',
773 'mysticky_disable_at_archive',
774 checked( isset( $this->options['mysticky_disable_at_archive'] ), true, false )
775 );
776 _e('<span>archives </span>', 'mystickymenu');
777 printf('</div>');
778
779 printf(
780 '<div><input id="%1$s" name="mysticky_option_name[mysticky_disable_at_search]" type="checkbox" %2$s /> ',
781 'mysticky_disable_at_search',
782 checked( isset( $this->options['mysticky_disable_at_search'] ), true, false )
783 );
784 _e('<span>search </span>', 'mystickymenu');
785 printf('</div>');
786
787 printf(
788 '<div><input id="%1$s" name="mysticky_option_name[mysticky_disable_at_404]" type="checkbox" %2$s /> ',
789 'mysticky_disable_at_404',
790 checked( isset( $this->options['mysticky_disable_at_404'] ), true, false )
791 );
792 _e('<span>404 </span>', 'mystickymenu');
793 printf('</div>');
794
795 if (isset ( $this->options['mysticky_disable_at_page'] ) == true ) {
796
797 echo '<p> </p> <hr />';
798 _e('<span class="">Except for this pages: </span>', 'mystickymenu');
799
800 printf(
801 '<input type="text" size="26" id="mysticky_enable_at_pages" name="mysticky_option_name[mysticky_enable_at_pages]" value="%s" /> ',
802 isset( $this->options['mysticky_enable_at_pages'] ) ? esc_attr( $this->options['mysticky_enable_at_pages']) : ''
803 );
804
805 _e('<span class="description">Comma separated list of pages to enable. It should be page name, id or slug. Example: about-us, 1134, Contact Us. Leave blank if you realy want to disable sticky menu for all pages.</span>', 'mystickymenu');
806
807 }
808
809 if (isset ( $this->options['mysticky_disable_at_single'] ) == true ) {
810
811 echo '<p> </p> <hr />';
812 _e('<span class="">Except for this posts: </span>', 'mystickymenu');
813
814 printf(
815 '<input type="text" size="26" id="mysticky_enable_at_posts" name="mysticky_option_name[mysticky_enable_at_posts]" value="%s" /> ',
816 isset( $this->options['mysticky_enable_at_posts'] ) ? esc_attr( $this->options['mysticky_enable_at_posts']) : ''
817 );
818
819 _e('<span class="description">Comma separated list of posts to enable. It should be post name, id or slug. Example: about-us, 1134, Contact Us. Leave blank if you realy want to disable sticky menu for all posts.</span>', 'mystickymenu');
820
821 }
822
823 }
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838 }
839
840
841
842 class MyStickyMenuFrontend
843 {
844
845 public function __construct()
846 {
847
848 add_action( 'wp_head', array( $this, 'mysticky_build_stylesheet_content' ) );
849 add_action( 'wp_enqueue_scripts', array( $this, 'mysticky_disable_at' ) );
850
851 }
852
853 public function mysticky_build_stylesheet_content()
854
855 {
856
857 $mysticky_options = get_option( 'mysticky_option_name' );
858
859 if (isset($mysticky_options['disable_css']))
860
861 {
862
863 //do nothing
864
865 } else {
866
867 $mysticky_options['disable_css'] = false;
868
869 };
870
871 if ($mysticky_options ['disable_css'] == false )
872
873 {
874
875 echo '<style id="mystickymenu" type="text/css">';
876 echo '#mysticky-nav { width:100%; position: static; }';
877 echo '#mysticky-nav.wrapfixed { position:fixed; left: 0px; margin-top:0px; z-index: '. $mysticky_options ['myfixed_zindex'] .'; -webkit-transition: ' . $mysticky_options ['myfixed_transition_time'] . 's; -moz-transition: ' . $mysticky_options ['myfixed_transition_time'] . 's; -o-transition: ' . $mysticky_options ['myfixed_transition_time'] . 's; transition: ' . $mysticky_options ['myfixed_transition_time'] . 's; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=' . $mysticky_options ['myfixed_opacity'] . ')"; filter: alpha(opacity=' . $mysticky_options ['myfixed_opacity'] . '); opacity:' . $mysticky_options ['myfixed_opacity'] / 100 . '; background-color: ' . $mysticky_options ['myfixed_bgcolor'] . ';}';
878
879
880 if ($mysticky_options ['myfixed_disable_small_screen'] > 0 ){
881
882 //echo '@media (max-width: '.$mysticky_options['myfixed_disable_small_screen'].'px) {#mysticky-nav.wrapfixed {position: static;} }';
883
884 };
885
886 if ( $mysticky_options['myfixed_cssstyle'] == "" ) {
887 echo '#mysticky-nav .myfixed { margin:0 auto; float:none; border:0px; background:none; max-width:100%; }';
888 }
889
890
891
892 echo $mysticky_options ['myfixed_cssstyle'];
893
894
895
896 echo '</style>';
897 }
898 }
899
900 // add_action('wp_head', 'mysticky_build_stylesheet_content');
901
902 public function mystickymenu_script() {
903
904 $mysticky_options = get_option( 'mysticky_option_name' );
905
906 if ( is_admin_bar_showing() ) {
907 $top = "true";
908 } else {
909 $top = "false";
910 }
911
912
913 // needed for update 1.7 => 1.8 ... will be removed in the future ()
914 if (isset($mysticky_options['mysticky_active_on_height_home'])){
915 //do nothing
916 } else {
917 $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height'];
918 };
919
920
921 if ($mysticky_options['mysticky_active_on_height_home'] == 0 ){
922 $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height'];
923 };
924
925
926 if ( is_front_page() && is_home() ) {
927
928 $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home'];
929
930 } elseif ( is_front_page()){
931
932 $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home'];
933
934 }
935
936 wp_register_script('mystickymenu', plugins_url( 'js/mystickymenu.min.js', __FILE__ ), array('jquery'), MYSTICKY_VERSION, true);
937 wp_enqueue_script( 'mystickymenu' );
938
939 $myfixed_disable_scroll_down = isset($mysticky_options['myfixed_disable_scroll_down']) ? $mysticky_options['myfixed_disable_scroll_down'] : 'false';
940 $mystickyTransition = isset($mysticky_options['myfixed_fade']) ? $mysticky_options['myfixed_fade'] : 'fade';
941 $mystickyDisableLarge = isset($mysticky_options['myfixed_disable_large_screen']) ? $mysticky_options['myfixed_disable_large_screen'] : '0';
942
943 $mysticky_translation_array = array(
944 'mystickyClass' => $mysticky_options['mysticky_class_selector'] ,
945 'activationHeight' => $mysticky_options['mysticky_active_on_height'],
946 'disableWidth' => $mysticky_options['myfixed_disable_small_screen'],
947 'disableLargeWidth' => $mystickyDisableLarge,
948 'adminBar' => $top,
949 'mystickyTransition' => $mystickyTransition,
950 'mysticky_disable_down' => $myfixed_disable_scroll_down,
951
952
953 );
954
955 wp_localize_script( 'mystickymenu', 'option', $mysticky_translation_array );
956 }
957
958 //add_action( 'wp_enqueue_scripts', 'mystickymenu_script' );
959
960
961 public function mysticky_disable_at() {
962
963
964 $mysticky_options = get_option( 'mysticky_option_name' );
965
966 $mysticky_disable_at_front_home = isset($mysticky_options['mysticky_disable_at_front_home']);
967 $mysticky_disable_at_blog = isset($mysticky_options['mysticky_disable_at_blog']);
968 $mysticky_disable_at_page = isset($mysticky_options['mysticky_disable_at_page']);
969 $mysticky_disable_at_tag = isset($mysticky_options['mysticky_disable_at_tag']);
970 $mysticky_disable_at_category = isset($mysticky_options['mysticky_disable_at_category']);
971 $mysticky_disable_at_single = isset($mysticky_options['mysticky_disable_at_single']);
972 $mysticky_disable_at_archive = isset($mysticky_options['mysticky_disable_at_archive']);
973 $mysticky_disable_at_search = isset($mysticky_options['mysticky_disable_at_search']);
974 $mysticky_disable_at_404 = isset($mysticky_options['mysticky_disable_at_404']);
975 $mysticky_enable_at_pages = isset($mysticky_options['mysticky_enable_at_pages']) ? $mysticky_options['mysticky_enable_at_pages'] : '';
976 $mysticky_enable_at_posts = isset($mysticky_options['mysticky_enable_at_posts']) ? $mysticky_options['mysticky_enable_at_posts'] : '';
977 //$mystickymenu_enable_at_pages_exp = explode( ',', $mystickymenu_enable_at_pages );
978 // Trim input to ignore empty spaces
979 $mysticky_enable_at_pages_exp = array_map('trim', explode(',', $mysticky_enable_at_pages));
980 $mysticky_enable_at_posts_exp = array_map('trim', explode(',', $mysticky_enable_at_posts));
981
982
983
984
985 if ( is_front_page() && is_home() ) {
986 // Default homepage
987 if ( $mysticky_disable_at_front_home == false ) {
988 $this->mystickymenu_script();
989
990 };
991
992
993 } elseif ( is_front_page()){
994 //Static homepage
995 if ( $mysticky_disable_at_front_home == false ) {
996 $this->mystickymenu_script();
997 };
998
999
1000 } elseif ( is_home()){
1001
1002 //Blog page
1003 if ( $mysticky_disable_at_blog == false ) {
1004 $this->mystickymenu_script();
1005 };
1006
1007
1008 } elseif ( is_page() ){
1009
1010 //Single page
1011 if ( $mysticky_disable_at_page == false ) {
1012 $this->mystickymenu_script();
1013 };
1014
1015 if ( is_page( $mysticky_enable_at_pages_exp ) ){
1016 $this->mystickymenu_script();
1017 }
1018
1019
1020 } elseif ( is_tag()){
1021
1022 //Tag page
1023 if ( $mysticky_disable_at_tag == false ) {
1024 $this->mystickymenu_script();
1025 };
1026
1027 } elseif ( is_category()){
1028
1029 //Category page
1030 if ( $mysticky_disable_at_category == false ) {
1031 $this->mystickymenu_script();
1032 };
1033
1034
1035 } elseif ( is_single()){
1036
1037 //Single post
1038 if ( $mysticky_disable_at_single == false ) {
1039 $this->mystickymenu_script();
1040 };
1041
1042 if ( is_single( $mysticky_enable_at_posts_exp ) ){
1043 $this->mystickymenu_script();
1044 }
1045
1046 } elseif ( is_archive()){
1047
1048 //Archive
1049 if ( $mysticky_disable_at_archive == false ) {
1050 $this->mystickymenu_script();
1051 };
1052
1053 } elseif ( is_search()){
1054
1055 //Search
1056 if ( $mysticky_disable_at_search == false ) {
1057 $this->mystickymenu_script();
1058 };
1059
1060 } elseif ( is_404()){
1061
1062 //404
1063 if ( $mysticky_disable_at_404 == false ) {
1064 $this->mystickymenu_script();
1065 };
1066
1067 }
1068
1069
1070 }
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080 }
1081
1082 if( is_admin() ) {
1083
1084 new MyStickyMenuBackend();
1085
1086 } else {
1087
1088 new MyStickyMenuFrontend();
1089
1090 }
1091 ?>