PluginProbe ʕ •ᴥ•ʔ
My Sticky Bar – Floating Notification Bar & Sticky Header (formerly myStickymenu) / 2.0.4
My Sticky Bar – Floating Notification Bar & Sticky Header (formerly myStickymenu) v2.0.4
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
js 8 years ago languages 8 years ago index.php 8 years ago mystickymenu.php 8 years ago readme.txt 8 years ago uninstall.php 8 years ago
mystickymenu.php
1083 lines
1 <?php
2 /*
3 Plugin Name: myStickymenu
4 Plugin URI: http://wordpress.transformnews.com/plugins/mystickymenu-simple-sticky-fixed-on-top-menu-implementation-for-twentythirteen-menu-269
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.4
7 Author: m.r.d.a
8 Author URI: http://wordpress.transformnews.com/
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.4' );
16
17 class MyStickyMenuBackend
18 {
19
20 private $options;
21
22 public function __construct()
23 {
24 add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
25 add_action( 'admin_init', array( $this, 'mysticky_load_transl') );
26 add_action( 'admin_init', array( $this, 'page_init' ) );
27 add_action( 'admin_init', array( $this, 'mysticky_default_options' ) );
28
29 add_action( 'admin_enqueue_scripts', array( $this, 'mysticky_enqueue_color_picker' ) );
30 add_action( 'admin_head', array( $this, 'mysticky_admin_script' ) );
31 }
32
33
34
35
36 public function mysticky_admin_script() {
37 echo '<style type="text/css">.mysticky-general,.mysticky-style,.mysticky-advanced,.mysticky-hideform,.mysticky-hideformreset{display:none;}</style>';
38 echo '
39 <script>
40
41 (function( $ ) {
42 "use strict";
43
44 jQuery(document).ready(function($){
45
46 $("#myfixed_zindex,#myfixed_opacity,#myfixed_transition_time,#disable_css").parent().parent().parent().hide();
47 $("#myfixed_bgcolor").parent().parent().parent().hide();
48 $("#myfixed_bgcolor").parent().parent().parent().parent().parent().parent().hide();
49 $("#myfixed_cssstyle,#mysticky_disable_at_front_home").parent().parent().hide();
50 $(".mysticky-hideformreset").hide();
51 $(".mysticky-hideform,.mysticky-general").fadeIn(300);
52
53
54 $(".btn-general").click(function(){
55
56 $(".btn-general").addClass("nav-tab-active");
57 $(".btn-style,.btn-advanced").removeClass("nav-tab-active");
58 $("#mysticky_class_selector,#myfixed_disable_small_screen,#myfixed_disable_large_screen,#mysticky_active_on_height,#mysticky_active_on_height_home,#myfixed_fade").parent().parent().parent().show();
59 $("#myfixed_zindex,#myfixed_opacity,#myfixed_transition_time,#disable_css").parent().parent().parent().hide();
60 $("#myfixed_bgcolor").parent().parent().parent().parent().parent().parent().hide();
61
62 $("#myfixed_cssstyle,#mysticky_disable_at_front_home").parent().parent().hide();
63
64 $(".mysticky-general").fadeIn(300);
65 $(".mysticky-style,.mysticky-advanced,.mysticky-hideformreset") .hide();
66
67
68
69
70 });
71
72 $(".btn-general,.btn-style,.btn-advanced").hover(function() {
73 $(".btn-general,.btn-style,.btn-advanced").css("cursor","pointer");
74 });
75
76
77
78 $(".btn-style").click(function(){
79
80 $(".btn-style").addClass("nav-tab-active");
81 $(".btn-general,.btn-advanced").removeClass("nav-tab-active");
82
83
84 $("#mysticky_class_selector,#myfixed_disable_small_screen,#myfixed_disable_large_screen,#mysticky_active_on_height,#mysticky_active_on_height_home,#myfixed_fade").parent().parent().parent().hide();
85 $("#myfixed_zindex,#myfixed_bgcolor,#myfixed_opacity,#myfixed_transition_time,#disable_css").parent().parent().parent().show();
86 $("#myfixed_cssstyle").parent().parent().show();
87 $("#mysticky_disable_at_front_home").parent().parent().hide();
88 $("#myfixed_bgcolor").parent().parent().parent().parent().parent().parent().show();
89
90
91 $(".mysticky-general").hide();
92 $(".mysticky-hideformreset").hide();
93 $(".mysticky-style") .fadeIn(300);
94 $(".mysticky-advanced").hide();
95
96 });
97
98
99
100
101 $(".btn-advanced").click(function(){
102
103
104 $(".btn-advanced").addClass("nav-tab-active");
105 $(".btn-style,.btn-general").removeClass("nav-tab-active");
106
107 $("#mysticky_class_selector,#myfixed_disable_small_screen,#myfixed_disable_large_screen,#mysticky_active_on_height,#mysticky_active_on_height_home,#myfixed_fade").parent().parent().parent().hide();
108 $("#myfixed_zindex,#myfixed_opacity,#myfixed_transition_time,#disable_css").parent().parent().parent().hide();
109 $("#myfixed_cssstyle").parent().parent().hide();
110 $("#myfixed_bgcolor").parent().parent().parent().parent().parent().parent().hide();
111 $("#mysticky_disable_at_front_home").parent().parent().show();
112 $(".mysticky-hideformreset").fadeIn(300);
113
114 $(".mysticky-general").hide();
115 $(".mysticky-style") .hide();
116 $(".mysticky-advanced").fadeIn(300);
117
118
119
120 });
121
122
123
124 $(".confirm").click(function() {
125 return window.confirm("Reset to default settings?");
126 });
127
128 });
129
130 })(jQuery);
131 </script>';
132
133 }
134
135
136
137
138
139 public function mysticky_load_transl()
140 {
141 load_plugin_textdomain('mystickymenu', FALSE, dirname(plugin_basename(__FILE__)).'/languages/');
142 }
143
144 public function add_plugin_page()
145 {
146 // This page will be under "Settings"
147 add_options_page(
148 'Settings Admin',
149 'myStickymenu',
150 'manage_options',
151 'my-stickymenu-settings',
152 array( $this, 'create_admin_page' )
153 );
154 }
155
156 public function create_admin_page()
157 {
158 // Set class property
159 $this->options = get_option( 'mysticky_option_name');
160 ?>
161 <div class="wrap">
162
163 <h2><?php _e('myStickymenu', 'mystickymenu'); ?></h2>
164 <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>
165
166
167
168 <?php $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'mysticky-general'; ?>
169
170 <h2 class="nav-tab-wrapper">
171 <a class="nav-tab btn-general <?php echo $active_tab == 'mysticky-general' ? 'nav-tab-active' : ''; ?>">General Settings</a>
172 <a class="nav-tab btn-style <?php echo $active_tab == 'mysticky-style' ? 'nav-tab-active' : ''; ?>">Style</a>
173 <a class="nav-tab btn-advanced <?php echo $active_tab == 'mysticky-advanced' ? 'nav-tab-active' : ''; ?>">Advanced</a>
174 </h2>
175
176
177
178
179
180
181
182
183
184 <form class="mysticky-hideform" method="post" action="options.php">
185
186
187
188 <?php
189
190
191 //we check if the page is visited by click on the tabs or on the menu button.
192 //then we get the active tab.
193
194 if(isset($_GET["tab"]))
195 {
196
197 if($_GET["tab"] == "mysticky-general")
198 {
199 echo '<div class="mysticky-general">';
200 settings_fields( 'mysticky_option_group' );
201 do_settings_sections( 'my-stickymenu-settings' );
202 echo '</div>';
203
204 }
205 else if($_GET["tab"] == "mysticky-style")
206 {
207 echo '<div class="mysticky-style">';
208 settings_fields( 'mysticky_option_group' );
209 do_settings_sections( 'my-stickymenu-settings' );
210 echo '</div>';
211 }
212
213 else if($_GET["tab"] == "mysticky-advanced")
214 {
215 echo '<div class="mysticky-advanced">';
216 settings_fields( 'mysticky_option_group' );
217 do_settings_sections( 'my-stickymenu-settings' );
218 echo '</div>';
219 }
220
221
222 }
223
224 else {
225
226 // echo '<div class="mysticky-general">';
227 settings_fields( 'mysticky_option_group' );
228 do_settings_sections( 'my-stickymenu-settings' );
229 // echo '</div>';
230
231
232 }
233
234
235 submit_button();
236 ?>
237
238
239 </form>
240
241 <form class="mysticky-hideformreset" method="post" action="">
242 <input name="reset" class="button button-secondary confirm" type="submit" value="Reset to default settings" >
243 <input type="hidden" name="action" value="reset" />
244 </form>
245
246
247 </div>
248 <?php
249 }
250
251 public function page_init()
252 {
253 global $id, $title, $callback, $page;
254 register_setting(
255 'mysticky_option_group',
256 'mysticky_option_name',
257 array( $this, 'sanitize' )
258 );
259
260
261
262
263 add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() );
264
265 add_settings_section(
266 'setting_section_id',
267 __(" ", 'mystickymenu'),
268 array( $this, 'print_section_info' ),
269 'my-stickymenu-settings'
270
271 );
272
273
274
275
276
277 add_settings_field(
278 'mysticky_class_selector',
279 __("Sticky Class", 'mystickymenu'),
280 array( $this, 'mysticky_class_selector_callback' ),
281 'my-stickymenu-settings',
282 'setting_section_id'
283 );
284
285 add_settings_field(
286 'myfixed_fade',
287 __("Fade or slide effect", 'mystickymenu'),
288 array( $this, 'myfixed_fade_callback' ),
289 'my-stickymenu-settings',
290 'setting_section_id'
291 );
292 add_settings_field(
293 'myfixed_zindex',
294 __("Sticky z-index", 'mystickymenu'),
295 array( $this, 'myfixed_zindex_callback' ),
296 'my-stickymenu-settings',
297 'setting_section_id'
298 );
299 add_settings_field(
300 'myfixed_bgcolor',
301 __("Sticky Background Color", 'mystickymenu'),
302 array( $this, 'myfixed_bgcolor_callback' ),
303 'my-stickymenu-settings',
304 'setting_section_id'
305 );
306 add_settings_field(
307 'myfixed_opacity',
308 __("Sticky Opacity", 'mystickymenu'),
309 array( $this, 'myfixed_opacity_callback' ),
310 'my-stickymenu-settings',
311 'setting_section_id'
312 );
313 add_settings_field(
314 'myfixed_transition_time',
315 __("Sticky Transition Time", 'mystickymenu'),
316 array( $this, 'myfixed_transition_time_callback' ),
317 'my-stickymenu-settings',
318 'setting_section_id'
319 );
320 add_settings_field(
321 'myfixed_disable_small_screen',
322 __("Disable at Small Screen Sizes", 'mystickymenu'),
323 array( $this, 'myfixed_disable_small_screen_callback' ),
324 'my-stickymenu-settings',
325 'setting_section_id'
326 );
327 add_settings_field(
328 'myfixed_disable_large_screen',
329 __("Disable at Large Screen Sizes", 'mystickymenu'),
330 array( $this, 'myfixed_disable_large_screen_callback' ),
331 'my-stickymenu-settings',
332 'setting_section_id'
333 );
334 add_settings_field(
335 'mysticky_active_on_height',
336 __("Make visible on Scroll", 'mystickymenu'),
337 array( $this, 'mysticky_active_on_height_callback' ),
338 'my-stickymenu-settings',
339 'setting_section_id'
340 );
341 add_settings_field(
342 'mysticky_active_on_height_home',
343 __("Make visible on Scroll at homepage", 'mystickymenu'),
344 array( $this, 'mysticky_active_on_height_home_callback' ),
345 'my-stickymenu-settings',
346 'setting_section_id'
347 );
348
349
350 add_settings_field(
351 'myfixed_disable_scroll_down',
352 __("Disable on scroll down", 'mystickymenu'),
353 'my-stickymenu-settings',
354 'setting_section_id'
355 );
356
357 add_settings_field(
358 'myfixed_cssstyle',
359 __("CSS style", 'mystickymenu'),
360 array( $this, 'myfixed_cssstyle_callback' ),
361 'my-stickymenu-settings',
362 'setting_section_id'
363 );
364 add_settings_field(
365 'disable_css',
366 __("Disable CSS style", 'mystickymenu'),
367 array( $this, 'disable_css_callback' ),
368 'my-stickymenu-settings',
369 'setting_section_id'
370 );
371
372
373
374 add_settings_field(
375 'mysticky_disable_at_front_home',
376 __("Disable at", 'mystickysidebar'),
377 array( $this, 'mysticky_enable_callback' ),
378 'my-stickymenu-settings',
379 'setting_section_id'
380 );
381 add_settings_field(
382 'mysticky_disable_at_blog',
383 __("Disable at", 'mystickysidebar'),
384 'my-stickymenu-settings',
385 'setting_section_id'
386 );
387 add_settings_field(
388 'mysticky_disable_at_page',
389 __("Disable at", 'mystickysidebar'),
390 'my-stickymenu-settings',
391 'setting_section_id'
392 );
393 add_settings_field(
394 'mysticky_disable_at_tag',
395 __("Disable at", 'mystickysidebar'),
396 'my-stickymenu-settings',
397 'setting_section_id'
398 );
399 add_settings_field(
400 'mysticky_disable_at_category',
401 __("Disable at", 'mystickysidebar'),
402 'my-stickymenu-settings',
403 'setting_section_id'
404 );
405 add_settings_field(
406 'mysticky_disable_at_single',
407 __("Disable at", 'mystickysidebar'),
408 'my-stickymenu-settings',
409 'setting_section_id'
410 );
411 add_settings_field(
412 'mysticky_disable_at_archive',
413 __("Disable at", 'mystickysidebar'),
414 'my-stickymenu-settings',
415 'setting_section_id'
416 );
417 add_settings_field(
418 'mysticky_enable_at_pages',
419 __(" ", 'mystickysidebar'),
420 'my-stickymenu-settings',
421 'setting_section_id'
422 );
423 add_settings_field(
424 'mysticky_enable_at_posts',
425 __(" ", 'mystickysidebar'),
426 'my-stickymenu-settings',
427 'setting_section_id'
428 );
429 add_settings_field(
430 'mysticky_disable_at_search',
431 __("Disable at", 'mystickysidebar'),
432 'my-stickymenu-settings',
433 'setting_section_id'
434 );
435
436
437
438 }
439 /**
440 * Sanitize each setting field as needed
441 *
442 * @param array $input Contains all settings fields as array keys
443 */
444 public function sanitize( $input )
445 {
446 $new_input = array();
447 if( isset( $input['mysticky_class_selector'] ) )
448 $new_input['mysticky_class_selector'] = sanitize_text_field( $input['mysticky_class_selector'] );
449
450 if( isset( $input['myfixed_zindex'] ) )
451 $new_input['myfixed_zindex'] = absint( $input['myfixed_zindex'] );
452
453 if( isset( $input['myfixed_bgcolor'] ) )
454 $new_input['myfixed_bgcolor'] = sanitize_text_field( $input['myfixed_bgcolor'] );
455
456 if( isset( $input['myfixed_opacity'] ) )
457 $new_input['myfixed_opacity'] = absint( $input['myfixed_opacity'] );
458
459 if( isset( $input['myfixed_transition_time'] ) )
460 $new_input['myfixed_transition_time'] = sanitize_text_field( $input['myfixed_transition_time'] );
461
462 if( isset( $input['myfixed_disable_small_screen'] ) )
463 $new_input['myfixed_disable_small_screen'] = absint( $input['myfixed_disable_small_screen'] );
464
465 if( isset( $input['myfixed_disable_large_screen'] ) )
466 $new_input['myfixed_disable_large_screen'] = absint( $input['myfixed_disable_large_screen'] );
467
468 if( isset( $input['mysticky_active_on_height'] ) )
469 $new_input['mysticky_active_on_height'] = absint( $input['mysticky_active_on_height'] );
470
471 if( isset( $input['mysticky_active_on_height_home'] ) )
472 $new_input['mysticky_active_on_height_home'] = absint( $input['mysticky_active_on_height_home'] );
473
474 if( isset( $input['myfixed_fade'] ) )
475 $new_input['myfixed_fade'] = sanitize_text_field( $input['myfixed_fade'] );
476
477 if( isset( $input['myfixed_disable_scroll_down'] ) )
478 $new_input['myfixed_disable_scroll_down'] = sanitize_text_field( $input['myfixed_disable_scroll_down'] );
479
480
481 if( isset( $input['myfixed_cssstyle'] ) )
482 $new_input['myfixed_cssstyle'] = sanitize_text_field( $input['myfixed_cssstyle'] );
483
484 if( isset( $input['disable_css'] ) )
485 $new_input['disable_css'] = sanitize_text_field( $input['disable_css'] );
486
487
488
489 if( isset( $input['mysticky_disable_at_front_home'] ) )
490 $new_input['mysticky_disable_at_front_home'] = sanitize_text_field( $input['mysticky_disable_at_front_home'] );
491
492 if( isset( $input['mysticky_disable_at_blog'] ) )
493 $new_input['mysticky_disable_at_blog'] = sanitize_text_field( $input['mysticky_disable_at_blog'] );
494
495 if( isset( $input['mysticky_disable_at_page'] ) )
496 $new_input['mysticky_disable_at_page'] = sanitize_text_field( $input['mysticky_disable_at_page'] );
497
498 if( isset( $input['mysticky_disable_at_tag'] ) )
499 $new_input['mysticky_disable_at_tag'] = sanitize_text_field( $input['mysticky_disable_at_tag'] );
500
501 if( isset( $input['mysticky_disable_at_category'] ) )
502 $new_input['mysticky_disable_at_category'] = sanitize_text_field( $input['mysticky_disable_at_category'] );
503
504 if( isset( $input['mysticky_disable_at_single'] ) )
505 $new_input['mysticky_disable_at_single'] = sanitize_text_field( $input['mysticky_disable_at_single'] );
506
507 if( isset( $input['mysticky_disable_at_archive'] ) )
508 $new_input['mysticky_disable_at_archive'] = sanitize_text_field( $input['mysticky_disable_at_archive'] );
509
510 if( isset( $input['mysticky_enable_at_pages'] ) )
511 $new_input['mysticky_enable_at_pages'] = sanitize_text_field( $input['mysticky_enable_at_pages'] );
512
513 if( isset( $input['mysticky_enable_at_posts'] ) )
514 $new_input['mysticky_enable_at_posts'] = sanitize_text_field( $input['mysticky_enable_at_posts'] );
515
516 if( isset( $input['mysticky_disable_at_search'] ) )
517 $new_input['mysticky_disable_at_search'] = sanitize_text_field( $input['mysticky_disable_at_search'] );
518
519
520
521
522
523 return $new_input;
524 }
525
526 public function mysticky_default_options() {
527
528 global $options;
529 $default = array(
530
531 'mysticky_class_selector' => '.navbar',
532 'myfixed_zindex' => '99990',
533 'myfixed_bgcolor' => '#f7f5e7',
534 'myfixed_opacity' => '90',
535 'myfixed_transition_time' => '0.3',
536 'myfixed_disable_small_screen' => '0',
537 'myfixed_disable_large_screen' => '0',
538 'mysticky_active_on_height' => '0',
539 'mysticky_active_on_height_home' => '0',
540 'myfixed_fade' => 'on',
541 'myfixed_cssstyle' => '#mysticky-nav.wrapfixed { } #mysticky-nav.wrapfixed.up { } #mysticky-nav.wrapfixed.down { } #mysticky-nav .myfixed { margin:0 auto; float:none; border:0px; background:none; max-width:100%; }'
542 );
543
544 if ( get_option('mysticky_option_name') == false ) {
545 update_option( 'mysticky_option_name', $default );
546 }
547
548
549 if(isset($_POST['reset'])) {
550 update_option( 'mysticky_option_name', $default );
551 }
552
553
554 }
555
556
557
558
559 public function mysticky_enqueue_color_picker( )
560 {
561 wp_enqueue_style( 'wp-color-picker' );
562 wp_enqueue_script( 'my-script-handle', plugins_url('js/iris-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
563
564 }
565
566 public function print_section_info()
567 {
568 echo __(" ", 'mystickymenu');
569 }
570
571 public function mysticky_class_selector_callback()
572 {
573 printf(
574 '<p class="description"><input type="text" size="8" id="mysticky_class_selector" name="mysticky_option_name[mysticky_class_selector]" value="%s" /> ',
575 isset( $this->options['mysticky_class_selector'] ) ? esc_attr( $this->options['mysticky_class_selector']) : ''
576 );
577 echo __("menu or header element class or id.", 'mystickymenu');
578 echo '</p>';
579 }
580
581 public function myfixed_zindex_callback()
582 {
583 printf(
584 '<p class="description"><input type="number" min="0" max="2147483647" step="1" id="myfixed_zindex" name="mysticky_option_name[myfixed_zindex]" value="%s" /></p>',
585 isset( $this->options['myfixed_zindex'] ) ? esc_attr( $this->options['myfixed_zindex']) : ''
586 );
587 }
588
589 public function myfixed_bgcolor_callback()
590 {
591 printf(
592 '<p class="description"><input type="text" id="myfixed_bgcolor" name="mysticky_option_name[myfixed_bgcolor]" class="my-color-field" value="%s" /></p> ' ,
593 isset( $this->options['myfixed_bgcolor'] ) ? esc_attr( $this->options['myfixed_bgcolor']) : ''
594 );
595 }
596
597 public function myfixed_opacity_callback()
598 {
599 printf(
600 '<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" /> ',
601 isset( $this->options['myfixed_opacity'] ) ? esc_attr( $this->options['myfixed_opacity']) : ''
602 );
603 echo __("numbers 1-100.", 'mystickymenu');
604 echo '</p>';
605 }
606
607 public function myfixed_transition_time_callback()
608 {
609 printf(
610 '<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" /> ',
611 isset( $this->options['myfixed_transition_time'] ) ? esc_attr( $this->options['myfixed_transition_time']) : ''
612 );
613 echo __("in seconds.", 'mystickymenu');
614 echo '</p>';
615 }
616
617 public function myfixed_disable_small_screen_callback()
618 {
619 printf(
620 '<p class="description">'
621 );
622 echo __("less than", 'mystickymenu');
623 printf(
624 ' <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" />',
625 isset( $this->options['myfixed_disable_small_screen'] ) ? esc_attr( $this->options['myfixed_disable_small_screen']) : ''
626 );
627 echo __("px width, 0 to disable.", 'mystickymenu');
628 echo '</p>';
629 }
630
631
632
633 public function myfixed_disable_large_screen_callback()
634 {
635 printf(
636 '<p class="description">'
637 );
638 echo __("more than", 'mystickymenu');
639 printf(
640 ' <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" />',
641 isset( $this->options['myfixed_disable_large_screen'] ) ? esc_attr( $this->options['myfixed_disable_large_screen']) : ''
642 );
643 echo __("px width, 0 to disable.", 'mystickymenu');
644 echo '</p>';
645 }
646
647
648
649 public function mysticky_active_on_height_callback()
650 {
651 printf(
652 '<p class="description">'
653 );
654 echo __("after", 'mystickymenu');
655 printf(
656 ' <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" />',
657 isset( $this->options['mysticky_active_on_height'] ) ? esc_attr( $this->options['mysticky_active_on_height']) : ''
658 );
659 echo __("px. If set to 0 auto calculate will be used.", 'mystickymenu');
660 echo '</p>';
661 }
662
663 public function mysticky_active_on_height_home_callback()
664 {
665 printf(
666 '<p class="description">'
667 );
668 echo __("after", 'mystickymenu');
669 printf(
670 ' <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" />',
671 isset( $this->options['mysticky_active_on_height_home'] ) ? esc_attr( $this->options['mysticky_active_on_height_home']) : ''
672 );
673 echo __("px. If set to 0 it will use initial Make visible on Scroll value.", 'mystickymenu');
674 echo '</p>';
675 }
676
677 public function myfixed_fade_callback()
678 {
679 printf(
680 '<p class="description"><input id="%1$s" name="mysticky_option_name[myfixed_fade]" type="checkbox" %2$s /> ',
681 'myfixed_fade',
682 checked( isset( $this->options['myfixed_fade'] ), true, false )
683 );
684 echo __("Checked is slide, unchecked is fade.", 'mystickymenu');
685 echo '</p>';
686
687 printf(
688 '<p class="description"><input id="%1$s" name="mysticky_option_name[myfixed_disable_scroll_down]" type="checkbox" %2$s /> ',
689 'myfixed_disable_scroll_down',
690 checked( isset( $this->options['myfixed_disable_scroll_down'] ), true, false )
691 );
692 echo __("Disable sticky menu at scroll down", 'mystickymenu');
693 echo '</p>';
694
695
696
697
698 }
699
700 public function myfixed_cssstyle_callback()
701 {
702 printf(
703 '<p class="description">'
704 );
705 echo __("Add/edit CSS style. Leave it blank for default style.", 'mystickymenu');
706 echo '</p>';
707 printf(
708 '<textarea type="text" rows="4" cols="60" id="myfixed_cssstyle" name="mysticky_option_name[myfixed_cssstyle]">%s</textarea> <br />',
709 isset( $this->options['myfixed_cssstyle'] ) ? esc_attr( $this->options['myfixed_cssstyle']) : ''
710 );
711 echo '<p class="description">';
712
713 echo __("If you want to change sticky hover color: ", 'mystickymenu');
714 echo '.myfixed li a:hover {color:#000; background-color: #ccc;}<br />';
715 echo __("More examples <a href='http://wordpress.transformnews.com/tutorials/mystickymenu-extended-style-functionality-using-myfixed-sticky-class-403'>here</a>.", 'mystickymenu');
716 echo'</p>';
717 }
718
719 public function disable_css_callback()
720 {
721 printf(
722 '<p class="description"><input id="%1$s" name="mysticky_option_name[disable_css]" type="checkbox" %2$s /> ',
723 'disable_css',
724 checked( isset( $this->options['disable_css'] ), true, false )
725 );
726 echo __("Use this option if you plan to include CSS Style manually", 'mystickymenu');
727 echo '</p>';
728 }
729
730
731
732
733
734
735
736
737
738
739
740
741
742 public function mysticky_enable_callback()
743 {
744
745 _e('<span>front page </span>', 'mystickymenu');
746 printf(
747 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_front_home]" type="checkbox" %2$s /> ',
748 'mysticky_disable_at_front_home',
749 checked( isset( $this->options['mysticky_disable_at_front_home'] ), true, false )
750 ) ;
751 _e('<span>blog page </span>', 'mystickymenu');
752 printf(
753 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_blog]" type="checkbox" %2$s /> ',
754 'mysticky_disable_at_blog',
755 checked( isset( $this->options['mysticky_disable_at_blog'] ), true, false )
756 );
757 _e('<span>pages </span>', 'mystickymenu');
758 printf(
759 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_page]" type="checkbox" %2$s /> ',
760 'mysticky_disable_at_page',
761 checked( isset( $this->options['mysticky_disable_at_page'] ), true, false )
762 );
763 _e('<span>tags </span>', 'mystickymenu');
764 printf(
765 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_tag]" type="checkbox" %2$s /> ',
766 'mysticky_disable_at_tag',
767 checked( isset( $this->options['mysticky_disable_at_tag'] ), true, false )
768 );
769 _e('<span>categories </span>', 'mystickymenu');
770 printf(
771 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_category]" type="checkbox" %2$s /> ',
772 'mysticky_disable_at_category',
773 checked( isset( $this->options['mysticky_disable_at_category'] ), true, false )
774 );
775 _e('<span>posts </span>', 'mystickymenu');
776 printf(
777 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_single]" type="checkbox" %2$s /> ',
778 'mysticky_disable_at_single',
779 checked( isset( $this->options['mysticky_disable_at_single'] ), true, false )
780 );
781 _e('<span>archives </span>', 'mystickymenu');
782 printf(
783 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_archive]" type="checkbox" %2$s /> ',
784 'mysticky_disable_at_archive',
785 checked( isset( $this->options['mysticky_disable_at_archive'] ), true, false )
786 );
787
788 _e('<span>search </span>', 'mystickysidebar');
789 printf(
790 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_search]" type="checkbox" %2$s /> ',
791 'mysticky_disable_at_search',
792 checked( isset( $this->options['mysticky_disable_at_search'] ), true, false )
793 );
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 sidebar 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 sidebar 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.wrapfixed { } #mysticky-nav.wrapfixed.up { } #mysticky-nav.wrapfixed.down { } #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_enable_at_pages = isset($mysticky_options['mysticky_enable_at_pages']) ? $mysticky_options['mysticky_enable_at_pages'] : '';
975 $mysticky_enable_at_posts = isset($mysticky_options['mysticky_enable_at_posts']) ? $mysticky_options['mysticky_enable_at_posts'] : '';
976 //$mystickymenu_enable_at_pages_exp = explode( ',', $mystickymenu_enable_at_pages );
977 // Trim input to ignore empty spaces
978 $mysticky_enable_at_pages_exp = array_map('trim', explode(',', $mysticky_enable_at_pages));
979 $mysticky_enable_at_posts_exp = array_map('trim', explode(',', $mysticky_enable_at_posts));
980
981
982
983
984 if ( is_front_page() && is_home() ) {
985 // Default homepage
986 if ( $mysticky_disable_at_front_home == false ) {
987 $this->mystickymenu_script();
988
989 };
990
991
992 } elseif ( is_front_page()){
993 //Static homepage
994 if ( $mysticky_disable_at_front_home == false ) {
995 $this->mystickymenu_script();
996 };
997
998
999 } elseif ( is_home()){
1000
1001 //Blog page
1002 if ( $mysticky_disable_at_blog == false ) {
1003 $this->mystickymenu_script();
1004 };
1005
1006
1007 } elseif ( is_page() ){
1008
1009 //Single page
1010 if ( $mysticky_disable_at_page == false ) {
1011 $this->mystickymenu_script();
1012 };
1013
1014 if ( is_page( $mysticky_enable_at_pages_exp ) ){
1015 $this->mystickymenu_script();
1016 }
1017
1018
1019 } elseif ( is_tag()){
1020
1021 //Tag page
1022 if ( $mysticky_disable_at_tag == false ) {
1023 $this->mystickymenu_script();
1024 };
1025
1026 } elseif ( is_category()){
1027
1028 //Category page
1029 if ( $mysticky_disable_at_category == false ) {
1030 $this->mystickymenu_script();
1031 };
1032
1033
1034 } elseif ( is_single()){
1035
1036 //Single post
1037 if ( $mysticky_disable_at_single == false ) {
1038 $this->mystickymenu_script();
1039 };
1040
1041 if ( is_single( $mysticky_enable_at_posts_exp ) ){
1042 $this->mystickymenu_script();
1043 }
1044
1045 } elseif ( is_archive()){
1046
1047 //Archive
1048 if ( $mysticky_disable_at_archive == false ) {
1049 $this->mystickymenu_script();
1050 };
1051
1052 } elseif ( is_search()){
1053
1054 //Archive
1055 if ( $mysticky_disable_at_search == false ) {
1056 $this->mystickymenu_script();
1057 };
1058
1059 }
1060
1061
1062 }
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072 }
1073
1074 if( is_admin() ) {
1075
1076 new MyStickyMenuBackend();
1077
1078 } else {
1079
1080 new MyStickyMenuFrontend();
1081
1082 }
1083 ?>