PluginProbe ʕ •ᴥ•ʔ
My Sticky Bar – Floating Notification Bar & Sticky Header (formerly myStickymenu) / 2.0.3
My Sticky Bar – Floating Notification Bar & Sticky Header (formerly myStickymenu) v2.0.3
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
1052 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.3
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.3' );
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,#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,#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,#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 'mysticky_active_on_height',
329 __("Make visible on Scroll", 'mystickymenu'),
330 array( $this, 'mysticky_active_on_height_callback' ),
331 'my-stickymenu-settings',
332 'setting_section_id'
333 );
334 add_settings_field(
335 'mysticky_active_on_height_home',
336 __("Make visible on Scroll at homepage", 'mystickymenu'),
337 array( $this, 'mysticky_active_on_height_home_callback' ),
338 'my-stickymenu-settings',
339 'setting_section_id'
340 );
341
342
343 add_settings_field(
344 'myfixed_disable_scroll_down',
345 __("Disable on scroll down", 'mystickymenu'),
346 'my-stickymenu-settings',
347 'setting_section_id'
348 );
349
350 add_settings_field(
351 'myfixed_cssstyle',
352 __("CSS style", 'mystickymenu'),
353 array( $this, 'myfixed_cssstyle_callback' ),
354 'my-stickymenu-settings',
355 'setting_section_id'
356 );
357 add_settings_field(
358 'disable_css',
359 __("Disable CSS style", 'mystickymenu'),
360 array( $this, 'disable_css_callback' ),
361 'my-stickymenu-settings',
362 'setting_section_id'
363 );
364
365
366
367 add_settings_field(
368 'mysticky_disable_at_front_home',
369 __("Disable at", 'mystickysidebar'),
370 array( $this, 'mysticky_enable_callback' ),
371 'my-stickymenu-settings',
372 'setting_section_id'
373 );
374 add_settings_field(
375 'mysticky_disable_at_blog',
376 __("Disable at", 'mystickysidebar'),
377 'my-stickymenu-settings',
378 'setting_section_id'
379 );
380 add_settings_field(
381 'mysticky_disable_at_page',
382 __("Disable at", 'mystickysidebar'),
383 'my-stickymenu-settings',
384 'setting_section_id'
385 );
386 add_settings_field(
387 'mysticky_disable_at_tag',
388 __("Disable at", 'mystickysidebar'),
389 'my-stickymenu-settings',
390 'setting_section_id'
391 );
392 add_settings_field(
393 'mysticky_disable_at_category',
394 __("Disable at", 'mystickysidebar'),
395 'my-stickymenu-settings',
396 'setting_section_id'
397 );
398 add_settings_field(
399 'mysticky_disable_at_single',
400 __("Disable at", 'mystickysidebar'),
401 'my-stickymenu-settings',
402 'setting_section_id'
403 );
404 add_settings_field(
405 'mysticky_disable_at_archive',
406 __("Disable at", 'mystickysidebar'),
407 'my-stickymenu-settings',
408 'setting_section_id'
409 );
410 add_settings_field(
411 'mysticky_enable_at_pages',
412 __(" ", 'mystickysidebar'),
413 'my-stickymenu-settings',
414 'setting_section_id'
415 );
416 add_settings_field(
417 'mysticky_enable_at_posts',
418 __(" ", 'mystickysidebar'),
419 'my-stickymenu-settings',
420 'setting_section_id'
421 );
422 add_settings_field(
423 'mysticky_disable_at_search',
424 __("Disable at", 'mystickysidebar'),
425 'my-stickymenu-settings',
426 'setting_section_id'
427 );
428
429
430
431 }
432 /**
433 * Sanitize each setting field as needed
434 *
435 * @param array $input Contains all settings fields as array keys
436 */
437 public function sanitize( $input )
438 {
439 $new_input = array();
440 if( isset( $input['mysticky_class_selector'] ) )
441 $new_input['mysticky_class_selector'] = sanitize_text_field( $input['mysticky_class_selector'] );
442
443 if( isset( $input['myfixed_zindex'] ) )
444 $new_input['myfixed_zindex'] = absint( $input['myfixed_zindex'] );
445
446 if( isset( $input['myfixed_bgcolor'] ) )
447 $new_input['myfixed_bgcolor'] = sanitize_text_field( $input['myfixed_bgcolor'] );
448
449 if( isset( $input['myfixed_opacity'] ) )
450 $new_input['myfixed_opacity'] = absint( $input['myfixed_opacity'] );
451
452 if( isset( $input['myfixed_transition_time'] ) )
453 $new_input['myfixed_transition_time'] = sanitize_text_field( $input['myfixed_transition_time'] );
454
455 if( isset( $input['myfixed_disable_small_screen'] ) )
456 $new_input['myfixed_disable_small_screen'] = absint( $input['myfixed_disable_small_screen'] );
457
458 if( isset( $input['mysticky_active_on_height'] ) )
459 $new_input['mysticky_active_on_height'] = absint( $input['mysticky_active_on_height'] );
460
461 if( isset( $input['mysticky_active_on_height_home'] ) )
462 $new_input['mysticky_active_on_height_home'] = absint( $input['mysticky_active_on_height_home'] );
463
464 if( isset( $input['myfixed_fade'] ) )
465 $new_input['myfixed_fade'] = sanitize_text_field( $input['myfixed_fade'] );
466
467 if( isset( $input['myfixed_disable_scroll_down'] ) )
468 $new_input['myfixed_disable_scroll_down'] = sanitize_text_field( $input['myfixed_disable_scroll_down'] );
469
470
471 if( isset( $input['myfixed_cssstyle'] ) )
472 $new_input['myfixed_cssstyle'] = sanitize_text_field( $input['myfixed_cssstyle'] );
473
474 if( isset( $input['disable_css'] ) )
475 $new_input['disable_css'] = sanitize_text_field( $input['disable_css'] );
476
477
478
479 if( isset( $input['mysticky_disable_at_front_home'] ) )
480 $new_input['mysticky_disable_at_front_home'] = sanitize_text_field( $input['mysticky_disable_at_front_home'] );
481
482 if( isset( $input['mysticky_disable_at_blog'] ) )
483 $new_input['mysticky_disable_at_blog'] = sanitize_text_field( $input['mysticky_disable_at_blog'] );
484
485 if( isset( $input['mysticky_disable_at_page'] ) )
486 $new_input['mysticky_disable_at_page'] = sanitize_text_field( $input['mysticky_disable_at_page'] );
487
488 if( isset( $input['mysticky_disable_at_tag'] ) )
489 $new_input['mysticky_disable_at_tag'] = sanitize_text_field( $input['mysticky_disable_at_tag'] );
490
491 if( isset( $input['mysticky_disable_at_category'] ) )
492 $new_input['mysticky_disable_at_category'] = sanitize_text_field( $input['mysticky_disable_at_category'] );
493
494 if( isset( $input['mysticky_disable_at_single'] ) )
495 $new_input['mysticky_disable_at_single'] = sanitize_text_field( $input['mysticky_disable_at_single'] );
496
497 if( isset( $input['mysticky_disable_at_archive'] ) )
498 $new_input['mysticky_disable_at_archive'] = sanitize_text_field( $input['mysticky_disable_at_archive'] );
499
500 if( isset( $input['mysticky_enable_at_pages'] ) )
501 $new_input['mysticky_enable_at_pages'] = sanitize_text_field( $input['mysticky_enable_at_pages'] );
502
503 if( isset( $input['mysticky_enable_at_posts'] ) )
504 $new_input['mysticky_enable_at_posts'] = sanitize_text_field( $input['mysticky_enable_at_posts'] );
505
506 if( isset( $input['mysticky_disable_at_search'] ) )
507 $new_input['mysticky_disable_at_search'] = sanitize_text_field( $input['mysticky_disable_at_search'] );
508
509
510
511
512
513 return $new_input;
514 }
515
516 public function mysticky_default_options() {
517
518 global $options;
519 $default = array(
520
521 'mysticky_class_selector' => '.navbar',
522 'myfixed_zindex' => '99990',
523 'myfixed_bgcolor' => '#f7f5e7',
524 'myfixed_opacity' => '90',
525 'myfixed_transition_time' => '0.3',
526 'myfixed_disable_small_screen' => '0',
527 'mysticky_active_on_height' => '0',
528 'mysticky_active_on_height_home' => '0',
529 'myfixed_fade' => 'on',
530 '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%; }'
531 );
532
533 if ( get_option('mysticky_option_name') == false ) {
534 update_option( 'mysticky_option_name', $default );
535 }
536
537
538 if(isset($_POST['reset'])) {
539 update_option( 'mysticky_option_name', $default );
540 }
541
542
543 }
544
545
546
547
548 public function mysticky_enqueue_color_picker( )
549 {
550 wp_enqueue_style( 'wp-color-picker' );
551 wp_enqueue_script( 'my-script-handle', plugins_url('js/iris-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
552
553 }
554
555 public function print_section_info()
556 {
557 echo __(" ", 'mystickymenu');
558 }
559
560 public function mysticky_class_selector_callback()
561 {
562 printf(
563 '<p class="description"><input type="text" size="8" id="mysticky_class_selector" name="mysticky_option_name[mysticky_class_selector]" value="%s" /> ',
564 isset( $this->options['mysticky_class_selector'] ) ? esc_attr( $this->options['mysticky_class_selector']) : ''
565 );
566 echo __("menu or header element class or id.", 'mystickymenu');
567 echo '</p>';
568 }
569
570 public function myfixed_zindex_callback()
571 {
572 printf(
573 '<p class="description"><input type="number" min="0" max="2147483647" step="1" id="myfixed_zindex" name="mysticky_option_name[myfixed_zindex]" value="%s" /></p>',
574 isset( $this->options['myfixed_zindex'] ) ? esc_attr( $this->options['myfixed_zindex']) : ''
575 );
576 }
577
578 public function myfixed_bgcolor_callback()
579 {
580 printf(
581 '<p class="description"><input type="text" id="myfixed_bgcolor" name="mysticky_option_name[myfixed_bgcolor]" class="my-color-field" value="%s" /></p> ' ,
582 isset( $this->options['myfixed_bgcolor'] ) ? esc_attr( $this->options['myfixed_bgcolor']) : ''
583 );
584 }
585
586 public function myfixed_opacity_callback()
587 {
588 printf(
589 '<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" /> ',
590 isset( $this->options['myfixed_opacity'] ) ? esc_attr( $this->options['myfixed_opacity']) : ''
591 );
592 echo __("numbers 1-100.", 'mystickymenu');
593 echo '</p>';
594 }
595
596 public function myfixed_transition_time_callback()
597 {
598 printf(
599 '<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" /> ',
600 isset( $this->options['myfixed_transition_time'] ) ? esc_attr( $this->options['myfixed_transition_time']) : ''
601 );
602 echo __("in seconds.", 'mystickymenu');
603 echo '</p>';
604 }
605
606 public function myfixed_disable_small_screen_callback()
607 {
608 printf(
609 '<p class="description">'
610 );
611 echo __("less than", 'mystickymenu');
612 printf(
613 ' <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" />',
614 isset( $this->options['myfixed_disable_small_screen'] ) ? esc_attr( $this->options['myfixed_disable_small_screen']) : ''
615 );
616 echo __("px width, 0 to disable.", 'mystickymenu');
617 echo '</p>';
618 }
619
620 public function mysticky_active_on_height_callback()
621 {
622 printf(
623 '<p class="description">'
624 );
625 echo __("after", 'mystickymenu');
626 printf(
627 ' <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" />',
628 isset( $this->options['mysticky_active_on_height'] ) ? esc_attr( $this->options['mysticky_active_on_height']) : ''
629 );
630 echo __("px. If set to 0 auto calculate will be used.", 'mystickymenu');
631 echo '</p>';
632 }
633
634 public function mysticky_active_on_height_home_callback()
635 {
636 printf(
637 '<p class="description">'
638 );
639 echo __("after", 'mystickymenu');
640 printf(
641 ' <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" />',
642 isset( $this->options['mysticky_active_on_height_home'] ) ? esc_attr( $this->options['mysticky_active_on_height_home']) : ''
643 );
644 echo __("px. If set to 0 it will use initial Make visible on Scroll value.", 'mystickymenu');
645 echo '</p>';
646 }
647
648 public function myfixed_fade_callback()
649 {
650 printf(
651 '<p class="description"><input id="%1$s" name="mysticky_option_name[myfixed_fade]" type="checkbox" %2$s /> ',
652 'myfixed_fade',
653 checked( isset( $this->options['myfixed_fade'] ), true, false )
654 );
655 echo __("Checked is slide, unchecked is fade.", 'mystickymenu');
656 echo '</p>';
657
658 printf(
659 '<p class="description"><input id="%1$s" name="mysticky_option_name[myfixed_disable_scroll_down]" type="checkbox" %2$s /> ',
660 'myfixed_disable_scroll_down',
661 checked( isset( $this->options['myfixed_disable_scroll_down'] ), true, false )
662 );
663 echo __("Disable sticky menu at scroll down", 'mystickymenu');
664 echo '</p>';
665
666
667
668
669 }
670
671 public function myfixed_cssstyle_callback()
672 {
673 printf(
674 '<p class="description">'
675 );
676 echo __("Add/edit CSS style. Leave it blank for default style.", 'mystickymenu');
677 echo '</p>';
678 printf(
679 '<textarea type="text" rows="4" cols="60" id="myfixed_cssstyle" name="mysticky_option_name[myfixed_cssstyle]">%s</textarea> <br />',
680 isset( $this->options['myfixed_cssstyle'] ) ? esc_attr( $this->options['myfixed_cssstyle']) : ''
681 );
682 echo '<p class="description">';
683
684 echo __("If you want to change sticky hover color: ", 'mystickymenu');
685 echo '.myfixed li a:hover {color:#000; background-color: #ccc;}<br />';
686 echo __("More examples <a href='http://wordpress.transformnews.com/tutorials/mystickymenu-extended-style-functionality-using-myfixed-sticky-class-403'>here</a>.", 'mystickymenu');
687 echo'</p>';
688 }
689
690 public function disable_css_callback()
691 {
692 printf(
693 '<p class="description"><input id="%1$s" name="mysticky_option_name[disable_css]" type="checkbox" %2$s /> ',
694 'disable_css',
695 checked( isset( $this->options['disable_css'] ), true, false )
696 );
697 echo __("Use this option if you plan to include CSS Style manually", 'mystickymenu');
698 echo '</p>';
699 }
700
701
702
703
704
705
706
707
708
709
710
711
712
713 public function mysticky_enable_callback()
714 {
715
716 _e('<span>front page </span>', 'mystickymenu');
717 printf(
718 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_front_home]" type="checkbox" %2$s /> ',
719 'mysticky_disable_at_front_home',
720 checked( isset( $this->options['mysticky_disable_at_front_home'] ), true, false )
721 ) ;
722 _e('<span>blog page </span>', 'mystickymenu');
723 printf(
724 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_blog]" type="checkbox" %2$s /> ',
725 'mysticky_disable_at_blog',
726 checked( isset( $this->options['mysticky_disable_at_blog'] ), true, false )
727 );
728 _e('<span>pages </span>', 'mystickymenu');
729 printf(
730 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_page]" type="checkbox" %2$s /> ',
731 'mysticky_disable_at_page',
732 checked( isset( $this->options['mysticky_disable_at_page'] ), true, false )
733 );
734 _e('<span>tags </span>', 'mystickymenu');
735 printf(
736 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_tag]" type="checkbox" %2$s /> ',
737 'mysticky_disable_at_tag',
738 checked( isset( $this->options['mysticky_disable_at_tag'] ), true, false )
739 );
740 _e('<span>categories </span>', 'mystickymenu');
741 printf(
742 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_category]" type="checkbox" %2$s /> ',
743 'mysticky_disable_at_category',
744 checked( isset( $this->options['mysticky_disable_at_category'] ), true, false )
745 );
746 _e('<span>posts </span>', 'mystickymenu');
747 printf(
748 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_single]" type="checkbox" %2$s /> ',
749 'mysticky_disable_at_single',
750 checked( isset( $this->options['mysticky_disable_at_single'] ), true, false )
751 );
752 _e('<span>archives </span>', 'mystickymenu');
753 printf(
754 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_archive]" type="checkbox" %2$s /> ',
755 'mysticky_disable_at_archive',
756 checked( isset( $this->options['mysticky_disable_at_archive'] ), true, false )
757 );
758
759 _e('<span>search </span>', 'mystickysidebar');
760 printf(
761 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_search]" type="checkbox" %2$s /> ',
762 'mysticky_disable_at_search',
763 checked( isset( $this->options['mysticky_disable_at_search'] ), true, false )
764 );
765
766 if (isset ( $this->options['mysticky_disable_at_page'] ) == true ) {
767
768 echo '<p> </p> <hr />';
769 _e('<span class="">Except for this pages: </span>', 'mystickymenu');
770
771 printf(
772 '<input type="text" size="26" id="mysticky_enable_at_pages" name="mysticky_option_name[mysticky_enable_at_pages]" value="%s" /> ',
773 isset( $this->options['mysticky_enable_at_pages'] ) ? esc_attr( $this->options['mysticky_enable_at_pages']) : ''
774 );
775
776 _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');
777
778 }
779
780 if (isset ( $this->options['mysticky_disable_at_single'] ) == true ) {
781
782 echo '<p> </p> <hr />';
783 _e('<span class="">Except for this posts: </span>', 'mystickymenu');
784
785 printf(
786 '<input type="text" size="26" id="mysticky_enable_at_posts" name="mysticky_option_name[mysticky_enable_at_posts]" value="%s" /> ',
787 isset( $this->options['mysticky_enable_at_posts'] ) ? esc_attr( $this->options['mysticky_enable_at_posts']) : ''
788 );
789
790 _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');
791
792 }
793
794 }
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809 }
810
811
812
813 class MyStickyMenuFrontend
814 {
815
816 public function __construct()
817 {
818
819 add_action( 'wp_head', array( $this, 'mysticky_build_stylesheet_content' ) );
820 add_action( 'wp_enqueue_scripts', array( $this, 'mysticky_disable_at' ) );
821
822 }
823
824 public function mysticky_build_stylesheet_content()
825
826 {
827
828 $mysticky_options = get_option( 'mysticky_option_name' );
829
830 if (isset($mysticky_options['disable_css']))
831
832 {
833
834 //do nothing
835
836 } else {
837
838 $mysticky_options['disable_css'] = false;
839
840 };
841
842 if ($mysticky_options ['disable_css'] == false )
843
844 {
845
846 echo '<style id="mystickymenu" type="text/css">';
847 echo '#mysticky-nav { width:100%; position: static; }';
848 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'] . ';}';
849
850
851 if ($mysticky_options ['myfixed_disable_small_screen'] > 0 ){
852
853 //echo '@media (max-width: '.$mysticky_options['myfixed_disable_small_screen'].'px) {#mysticky-nav.wrapfixed {position: static;} }';
854
855 };
856
857 if ( $mysticky_options['myfixed_cssstyle'] == "" ) {
858 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%; }';
859 }
860
861
862
863 echo $mysticky_options ['myfixed_cssstyle'];
864
865
866
867 echo '</style>';
868 }
869 }
870
871 // add_action('wp_head', 'mysticky_build_stylesheet_content');
872
873 public function mystickymenu_script() {
874
875 $mysticky_options = get_option( 'mysticky_option_name' );
876
877 if ( is_admin_bar_showing() ) {
878 $top = "true";
879 } else {
880 $top = "false";
881 }
882
883
884 // needed for update 1.7 => 1.8 ... will be removed in the future ()
885 if (isset($mysticky_options['mysticky_active_on_height_home'])){
886 //do nothing
887 } else {
888 $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height'];
889 };
890
891
892 if ($mysticky_options['mysticky_active_on_height_home'] == 0 ){
893 $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height'];
894 };
895
896
897 if ( is_front_page() && is_home() ) {
898
899 $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home'];
900
901 } elseif ( is_front_page()){
902
903 $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home'];
904
905 }
906
907 wp_register_script('mystickymenu', plugins_url( 'js/mystickymenu.min.js', __FILE__ ), array('jquery'), MYSTICKY_VERSION, true);
908 wp_enqueue_script( 'mystickymenu' );
909
910 $myfixed_disable_scroll_down = isset($mysticky_options['myfixed_disable_scroll_down']) ? $mysticky_options['myfixed_disable_scroll_down'] : 'false';
911 $mystickyTransition = isset($mysticky_options['myfixed_fade']) ? $mysticky_options['myfixed_fade'] : 'fade';
912
913 $mysticky_translation_array = array(
914 'mystickyClass' => $mysticky_options['mysticky_class_selector'] ,
915 'activationHeight' => $mysticky_options['mysticky_active_on_height'],
916 'disableWidth' => $mysticky_options['myfixed_disable_small_screen'],
917 'adminBar' => $top,
918 'mystickyTransition' => $mystickyTransition,
919 'mysticky_disable_down' => $myfixed_disable_scroll_down,
920
921
922 );
923
924 wp_localize_script( 'mystickymenu', 'option', $mysticky_translation_array );
925 }
926
927 //add_action( 'wp_enqueue_scripts', 'mystickymenu_script' );
928
929
930 public function mysticky_disable_at() {
931
932
933 $mysticky_options = get_option( 'mysticky_option_name' );
934
935 $mysticky_disable_at_front_home = isset($mysticky_options['mysticky_disable_at_front_home']);
936 $mysticky_disable_at_blog = isset($mysticky_options['mysticky_disable_at_blog']);
937 $mysticky_disable_at_page = isset($mysticky_options['mysticky_disable_at_page']);
938 $mysticky_disable_at_tag = isset($mysticky_options['mysticky_disable_at_tag']);
939 $mysticky_disable_at_category = isset($mysticky_options['mysticky_disable_at_category']);
940 $mysticky_disable_at_single = isset($mysticky_options['mysticky_disable_at_single']);
941 $mysticky_disable_at_archive = isset($mysticky_options['mysticky_disable_at_archive']);
942 $mysticky_disable_at_search = isset($mysticky_options['mysticky_disable_at_search']);
943 $mysticky_enable_at_pages = isset($mysticky_options['mysticky_enable_at_pages']) ? $mysticky_options['mysticky_enable_at_pages'] : '';
944 $mysticky_enable_at_posts = isset($mysticky_options['mysticky_enable_at_posts']) ? $mysticky_options['mysticky_enable_at_posts'] : '';
945 //$mystickymenu_enable_at_pages_exp = explode( ',', $mystickymenu_enable_at_pages );
946 // Trim input to ignore empty spaces
947 $mysticky_enable_at_pages_exp = array_map('trim', explode(',', $mysticky_enable_at_pages));
948 $mysticky_enable_at_posts_exp = array_map('trim', explode(',', $mysticky_enable_at_posts));
949
950
951
952
953 if ( is_front_page() && is_home() ) {
954 // Default homepage
955 if ( $mysticky_disable_at_front_home == false ) {
956 $this->mystickymenu_script();
957
958 };
959
960
961 } elseif ( is_front_page()){
962 //Static homepage
963 if ( $mysticky_disable_at_front_home == false ) {
964 $this->mystickymenu_script();
965 };
966
967
968 } elseif ( is_home()){
969
970 //Blog page
971 if ( $mysticky_disable_at_blog == false ) {
972 $this->mystickymenu_script();
973 };
974
975
976 } elseif ( is_page() ){
977
978 //Single page
979 if ( $mysticky_disable_at_page == false ) {
980 $this->mystickymenu_script();
981 };
982
983 if ( is_page( $mysticky_enable_at_pages_exp ) ){
984 $this->mystickymenu_script();
985 }
986
987
988 } elseif ( is_tag()){
989
990 //Tag page
991 if ( $mysticky_disable_at_tag == false ) {
992 $this->mystickymenu_script();
993 };
994
995 } elseif ( is_category()){
996
997 //Category page
998 if ( $mysticky_disable_at_category == false ) {
999 $this->mystickymenu_script();
1000 };
1001
1002
1003 } elseif ( is_single()){
1004
1005 //Single post
1006 if ( $mysticky_disable_at_single == false ) {
1007 $this->mystickymenu_script();
1008 };
1009
1010 if ( is_single( $mysticky_enable_at_posts_exp ) ){
1011 $this->mystickymenu_script();
1012 }
1013
1014 } elseif ( is_archive()){
1015
1016 //Archive
1017 if ( $mysticky_disable_at_archive == false ) {
1018 $this->mystickymenu_script();
1019 };
1020
1021 } elseif ( is_search()){
1022
1023 //Archive
1024 if ( $mysticky_disable_at_search == false ) {
1025 $this->mystickymenu_script();
1026 };
1027
1028 }
1029
1030
1031 }
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041 }
1042
1043 if( is_admin() ) {
1044
1045 new MyStickyMenuBackend();
1046
1047 } else {
1048
1049 new MyStickyMenuFrontend();
1050
1051 }
1052 ?>