PluginProbe ʕ •ᴥ•ʔ
My Sticky Bar – Floating Notification Bar & Sticky Header (formerly myStickymenu) / 2.0.1
My Sticky Bar – Floating Notification Bar & Sticky Header (formerly myStickymenu) v2.0.1
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
1056 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.1
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.1' );
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
47 $("#myfixed_zindex,#myfixed_opacity,#myfixed_transition_time,#disable_css").parent().parent().parent().hide();
48 $("#myfixed_bgcolor").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().hide();
61 $("#myfixed_cssstyle,#mysticky_disable_at_front_home").parent().parent().hide();
62
63 $(".mysticky-general").fadeIn(300);
64 $(".mysticky-style,.mysticky-advanced,.mysticky-hideformreset") .hide();
65
66
67
68
69 });
70
71 $(".btn-general,.btn-style,.btn-advanced").hover(function() {
72 $(".btn-general,.btn-style,.btn-advanced").css("cursor","pointer");
73 });
74
75
76
77 $(".btn-style").click(function(){
78
79 $(".btn-style").addClass("nav-tab-active");
80 $(".btn-general,.btn-advanced").removeClass("nav-tab-active");
81
82
83 $("#mysticky_class_selector,#myfixed_disable_small_screen,#mysticky_active_on_height,#mysticky_active_on_height_home,#myfixed_fade").parent().parent().parent().hide();
84
85 $("#myfixed_zindex,#myfixed_bgcolor,#myfixed_opacity,#myfixed_transition_time,#disable_css").parent().parent().parent().show();
86
87 $("#myfixed_cssstyle").parent().parent().show();
88
89 $("#mysticky_disable_at_front_home").parent().parent().hide();
90
91 $("#myfixed_bgcolor").parent().parent().parent().parent().parent().show();
92
93 $(".mysticky-general").hide();
94 $(".mysticky-hideformreset").hide();
95 $(".mysticky-style") .fadeIn(300);
96 $(".mysticky-advanced").hide();
97
98 });
99
100
101
102
103 $(".btn-advanced").click(function(){
104
105
106 $(".btn-advanced").addClass("nav-tab-active");
107 $(".btn-style,.btn-general").removeClass("nav-tab-active");
108
109 $("#mysticky_class_selector,#myfixed_disable_small_screen,#mysticky_active_on_height,#mysticky_active_on_height_home,#myfixed_fade").parent().parent().parent().hide();
110 $("#myfixed_zindex,#myfixed_opacity,#myfixed_transition_time,#disable_css").parent().parent().parent().hide();
111 $("#myfixed_cssstyle").parent().parent().hide();
112
113 $("#myfixed_bgcolor").parent().parent().parent().parent().parent().hide();
114
115 $("#mysticky_disable_at_front_home").parent().parent().show();
116 $(".mysticky-hideformreset").fadeIn(300);
117
118 $(".mysticky-general").hide();
119 $(".mysticky-style") .hide();
120 $(".mysticky-advanced").fadeIn(300);
121
122
123
124 });
125
126
127
128 $(".confirm").click(function() {
129 return window.confirm("Reset to default settings?");
130 });
131
132 });
133
134 })(jQuery);
135 </script>';
136
137 }
138
139
140
141
142
143 public function mysticky_load_transl()
144 {
145 load_plugin_textdomain('mystickymenu', FALSE, dirname(plugin_basename(__FILE__)).'/languages/');
146 }
147
148 public function add_plugin_page()
149 {
150 // This page will be under "Settings"
151 add_options_page(
152 'Settings Admin',
153 'myStickymenu',
154 'manage_options',
155 'my-stickymenu-settings',
156 array( $this, 'create_admin_page' )
157 );
158 }
159
160 public function create_admin_page()
161 {
162 // Set class property
163 $this->options = get_option( 'mysticky_option_name');
164 ?>
165 <div class="wrap">
166
167 <h2><?php _e('myStickymenu', 'mystickymenu'); ?></h2>
168 <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>
169
170
171
172 <?php $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'mysticky-general'; ?>
173
174 <h2 class="nav-tab-wrapper">
175 <a class="nav-tab btn-general <?php echo $active_tab == 'mysticky-general' ? 'nav-tab-active' : ''; ?>">General Settings</a>
176 <a class="nav-tab btn-style <?php echo $active_tab == 'mysticky-style' ? 'nav-tab-active' : ''; ?>">Style</a>
177 <a class="nav-tab btn-advanced <?php echo $active_tab == 'mysticky-advanced' ? 'nav-tab-active' : ''; ?>">Advanced</a>
178 </h2>
179
180
181
182
183
184
185
186
187
188 <form class="mysticky-hideform" method="post" action="options.php">
189
190
191
192 <?php
193
194
195 //we check if the page is visited by click on the tabs or on the menu button.
196 //then we get the active tab.
197
198 if(isset($_GET["tab"]))
199 {
200
201 if($_GET["tab"] == "mysticky-general")
202 {
203 echo '<div class="mysticky-general">';
204 settings_fields( 'mysticky_option_group' );
205 do_settings_sections( 'my-stickymenu-settings' );
206 echo '</div>';
207
208 }
209 else if($_GET["tab"] == "mysticky-style")
210 {
211 echo '<div class="mysticky-style">';
212 settings_fields( 'mysticky_option_group' );
213 do_settings_sections( 'my-stickymenu-settings' );
214 echo '</div>';
215 }
216
217 else if($_GET["tab"] == "mysticky-advanced")
218 {
219 echo '<div class="mysticky-advanced">';
220 settings_fields( 'mysticky_option_group' );
221 do_settings_sections( 'my-stickymenu-settings' );
222 echo '</div>';
223 }
224
225
226 }
227
228 else {
229
230 // echo '<div class="mysticky-general">';
231 settings_fields( 'mysticky_option_group' );
232 do_settings_sections( 'my-stickymenu-settings' );
233 // echo '</div>';
234
235
236 }
237
238
239 submit_button();
240 ?>
241
242
243 </form>
244
245 <form class="mysticky-hideformreset" method="post" action="">
246 <input name="reset" class="button button-secondary confirm" type="submit" value="Reset to default settings" >
247 <input type="hidden" name="action" value="reset" />
248 </form>
249
250
251 </div>
252 <?php
253 }
254
255 public function page_init()
256 {
257 global $id, $title, $callback, $page;
258 register_setting(
259 'mysticky_option_group',
260 'mysticky_option_name',
261 array( $this, 'sanitize' )
262 );
263
264
265
266
267 add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() );
268
269 add_settings_section(
270 'setting_section_id',
271 __(" ", 'mystickymenu'),
272 array( $this, 'print_section_info' ),
273 'my-stickymenu-settings'
274
275 );
276
277
278
279
280
281 add_settings_field(
282 'mysticky_class_selector',
283 __("Sticky Class", 'mystickymenu'),
284 array( $this, 'mysticky_class_selector_callback' ),
285 'my-stickymenu-settings',
286 'setting_section_id'
287 );
288
289 add_settings_field(
290 'myfixed_fade',
291 __("Fade or slide effect", 'mystickymenu'),
292 array( $this, 'myfixed_fade_callback' ),
293 'my-stickymenu-settings',
294 'setting_section_id'
295 );
296 add_settings_field(
297 'myfixed_zindex',
298 __("Sticky z-index", 'mystickymenu'),
299 array( $this, 'myfixed_zindex_callback' ),
300 'my-stickymenu-settings',
301 'setting_section_id'
302 );
303 add_settings_field(
304 'myfixed_bgcolor',
305 __("Sticky Background Color", 'mystickymenu'),
306 array( $this, 'myfixed_bgcolor_callback' ),
307 'my-stickymenu-settings',
308 'setting_section_id'
309 );
310 add_settings_field(
311 'myfixed_opacity',
312 __("Sticky Opacity", 'mystickymenu'),
313 array( $this, 'myfixed_opacity_callback' ),
314 'my-stickymenu-settings',
315 'setting_section_id'
316 );
317 add_settings_field(
318 'myfixed_transition_time',
319 __("Sticky Transition Time", 'mystickymenu'),
320 array( $this, 'myfixed_transition_time_callback' ),
321 'my-stickymenu-settings',
322 'setting_section_id'
323 );
324 add_settings_field(
325 'myfixed_disable_small_screen',
326 __("Disable at Small Screen Sizes", 'mystickymenu'),
327 array( $this, 'myfixed_disable_small_screen_callback' ),
328 'my-stickymenu-settings',
329 'setting_section_id'
330 );
331 add_settings_field(
332 'mysticky_active_on_height',
333 __("Make visible on Scroll", 'mystickymenu'),
334 array( $this, 'mysticky_active_on_height_callback' ),
335 'my-stickymenu-settings',
336 'setting_section_id'
337 );
338 add_settings_field(
339 'mysticky_active_on_height_home',
340 __("Make visible on Scroll at homepage", 'mystickymenu'),
341 array( $this, 'mysticky_active_on_height_home_callback' ),
342 'my-stickymenu-settings',
343 'setting_section_id'
344 );
345
346
347 add_settings_field(
348 'myfixed_disable_scroll_down',
349 __("Disable on scroll down", 'mystickymenu'),
350 'my-stickymenu-settings',
351 'setting_section_id'
352 );
353
354 add_settings_field(
355 'myfixed_cssstyle',
356 __("CSS style", 'mystickymenu'),
357 array( $this, 'myfixed_cssstyle_callback' ),
358 'my-stickymenu-settings',
359 'setting_section_id'
360 );
361 add_settings_field(
362 'disable_css',
363 __("Disable CSS style", 'mystickymenu'),
364 array( $this, 'disable_css_callback' ),
365 'my-stickymenu-settings',
366 'setting_section_id'
367 );
368
369
370
371 add_settings_field(
372 'mysticky_disable_at_front_home',
373 __("Disable at", 'mystickysidebar'),
374 array( $this, 'mysticky_enable_callback' ),
375 'my-stickymenu-settings',
376 'setting_section_id'
377 );
378 add_settings_field(
379 'mysticky_disable_at_blog',
380 __("Disable at", 'mystickysidebar'),
381 'my-stickymenu-settings',
382 'setting_section_id'
383 );
384 add_settings_field(
385 'mysticky_disable_at_page',
386 __("Disable at", 'mystickysidebar'),
387 'my-stickymenu-settings',
388 'setting_section_id'
389 );
390 add_settings_field(
391 'mysticky_disable_at_tag',
392 __("Disable at", 'mystickysidebar'),
393 'my-stickymenu-settings',
394 'setting_section_id'
395 );
396 add_settings_field(
397 'mysticky_disable_at_category',
398 __("Disable at", 'mystickysidebar'),
399 'my-stickymenu-settings',
400 'setting_section_id'
401 );
402 add_settings_field(
403 'mysticky_disable_at_single',
404 __("Disable at", 'mystickysidebar'),
405 'my-stickymenu-settings',
406 'setting_section_id'
407 );
408 add_settings_field(
409 'mysticky_disable_at_archive',
410 __("Disable at", 'mystickysidebar'),
411 'my-stickymenu-settings',
412 'setting_section_id'
413 );
414 add_settings_field(
415 'mysticky_enable_at_pages',
416 __(" ", 'mystickysidebar'),
417 'my-stickymenu-settings',
418 'setting_section_id'
419 );
420 add_settings_field(
421 'mysticky_enable_at_posts',
422 __(" ", 'mystickysidebar'),
423 'my-stickymenu-settings',
424 'setting_section_id'
425 );
426 add_settings_field(
427 'mysticky_disable_at_search',
428 __("Disable at", 'mystickysidebar'),
429 'my-stickymenu-settings',
430 'setting_section_id'
431 );
432
433
434
435 }
436 /**
437 * Sanitize each setting field as needed
438 *
439 * @param array $input Contains all settings fields as array keys
440 */
441 public function sanitize( $input )
442 {
443 $new_input = array();
444 if( isset( $input['mysticky_class_selector'] ) )
445 $new_input['mysticky_class_selector'] = sanitize_text_field( $input['mysticky_class_selector'] );
446
447 if( isset( $input['myfixed_zindex'] ) )
448 $new_input['myfixed_zindex'] = absint( $input['myfixed_zindex'] );
449
450 if( isset( $input['myfixed_bgcolor'] ) )
451 $new_input['myfixed_bgcolor'] = sanitize_text_field( $input['myfixed_bgcolor'] );
452
453 if( isset( $input['myfixed_opacity'] ) )
454 $new_input['myfixed_opacity'] = absint( $input['myfixed_opacity'] );
455
456 if( isset( $input['myfixed_transition_time'] ) )
457 $new_input['myfixed_transition_time'] = sanitize_text_field( $input['myfixed_transition_time'] );
458
459 if( isset( $input['myfixed_disable_small_screen'] ) )
460 $new_input['myfixed_disable_small_screen'] = absint( $input['myfixed_disable_small_screen'] );
461
462 if( isset( $input['mysticky_active_on_height'] ) )
463 $new_input['mysticky_active_on_height'] = absint( $input['mysticky_active_on_height'] );
464
465 if( isset( $input['mysticky_active_on_height_home'] ) )
466 $new_input['mysticky_active_on_height_home'] = absint( $input['mysticky_active_on_height_home'] );
467
468 if( isset( $input['myfixed_fade'] ) )
469 $new_input['myfixed_fade'] = sanitize_text_field( $input['myfixed_fade'] );
470
471 if( isset( $input['myfixed_disable_scroll_down'] ) )
472 $new_input['myfixed_disable_scroll_down'] = sanitize_text_field( $input['myfixed_disable_scroll_down'] );
473
474
475 if( isset( $input['myfixed_cssstyle'] ) )
476 $new_input['myfixed_cssstyle'] = sanitize_text_field( $input['myfixed_cssstyle'] );
477
478 if( isset( $input['disable_css'] ) )
479 $new_input['disable_css'] = sanitize_text_field( $input['disable_css'] );
480
481
482
483 if( isset( $input['mysticky_disable_at_front_home'] ) )
484 $new_input['mysticky_disable_at_front_home'] = sanitize_text_field( $input['mysticky_disable_at_front_home'] );
485
486 if( isset( $input['mysticky_disable_at_blog'] ) )
487 $new_input['mysticky_disable_at_blog'] = sanitize_text_field( $input['mysticky_disable_at_blog'] );
488
489 if( isset( $input['mysticky_disable_at_page'] ) )
490 $new_input['mysticky_disable_at_page'] = sanitize_text_field( $input['mysticky_disable_at_page'] );
491
492 if( isset( $input['mysticky_disable_at_tag'] ) )
493 $new_input['mysticky_disable_at_tag'] = sanitize_text_field( $input['mysticky_disable_at_tag'] );
494
495 if( isset( $input['mysticky_disable_at_category'] ) )
496 $new_input['mysticky_disable_at_category'] = sanitize_text_field( $input['mysticky_disable_at_category'] );
497
498 if( isset( $input['mysticky_disable_at_single'] ) )
499 $new_input['mysticky_disable_at_single'] = sanitize_text_field( $input['mysticky_disable_at_single'] );
500
501 if( isset( $input['mysticky_disable_at_archive'] ) )
502 $new_input['mysticky_disable_at_archive'] = sanitize_text_field( $input['mysticky_disable_at_archive'] );
503
504 if( isset( $input['mysticky_enable_at_pages'] ) )
505 $new_input['mysticky_enable_at_pages'] = sanitize_text_field( $input['mysticky_enable_at_pages'] );
506
507 if( isset( $input['mysticky_enable_at_posts'] ) )
508 $new_input['mysticky_enable_at_posts'] = sanitize_text_field( $input['mysticky_enable_at_posts'] );
509
510 if( isset( $input['mysticky_disable_at_search'] ) )
511 $new_input['mysticky_disable_at_search'] = sanitize_text_field( $input['mysticky_disable_at_search'] );
512
513
514
515
516
517 return $new_input;
518 }
519
520 public function mysticky_default_options() {
521
522 global $options;
523 $default = array(
524
525 'mysticky_class_selector' => '.navbar',
526 'myfixed_zindex' => '99990',
527 'myfixed_bgcolor' => '#f7f5e7',
528 'myfixed_opacity' => '90',
529 'myfixed_transition_time' => '0.3',
530 'myfixed_disable_small_screen' => '0',
531 'mysticky_active_on_height' => '0',
532 'mysticky_active_on_height_home' => '0',
533 'myfixed_fade' => 'on',
534 '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%; }'
535 );
536
537 if ( get_option('mysticky_option_name') == false ) {
538 update_option( 'mysticky_option_name', $default );
539 }
540
541
542 if(isset($_POST['reset'])) {
543 update_option( 'mysticky_option_name', $default );
544 }
545
546
547 }
548
549
550
551
552 public function mysticky_enqueue_color_picker( )
553 {
554 wp_enqueue_style( 'wp-color-picker' );
555 wp_enqueue_script( 'my-script-handle', plugins_url('js/iris-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
556
557 }
558
559 public function print_section_info()
560 {
561 echo __(" ", 'mystickymenu');
562 }
563
564 public function mysticky_class_selector_callback()
565 {
566 printf(
567 '<p class="description"><input type="text" size="8" id="mysticky_class_selector" name="mysticky_option_name[mysticky_class_selector]" value="%s" /> ',
568 isset( $this->options['mysticky_class_selector'] ) ? esc_attr( $this->options['mysticky_class_selector']) : ''
569 );
570 echo __("menu or header element class or id.", 'mystickymenu');
571 echo '</p>';
572 }
573
574 public function myfixed_zindex_callback()
575 {
576 printf(
577 '<p class="description"><input type="number" min="0" max="2147483647" step="1" id="myfixed_zindex" name="mysticky_option_name[myfixed_zindex]" value="%s" /></p>',
578 isset( $this->options['myfixed_zindex'] ) ? esc_attr( $this->options['myfixed_zindex']) : ''
579 );
580 }
581
582 public function myfixed_bgcolor_callback()
583 {
584 printf(
585 '<p class="description"><input type="text" id="myfixed_bgcolor" name="mysticky_option_name[myfixed_bgcolor]" class="my-color-field" value="%s" /></p> ' ,
586 isset( $this->options['myfixed_bgcolor'] ) ? esc_attr( $this->options['myfixed_bgcolor']) : ''
587 );
588 }
589
590 public function myfixed_opacity_callback()
591 {
592 printf(
593 '<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" /> ',
594 isset( $this->options['myfixed_opacity'] ) ? esc_attr( $this->options['myfixed_opacity']) : ''
595 );
596 echo __("numbers 1-100.", 'mystickymenu');
597 echo '</p>';
598 }
599
600 public function myfixed_transition_time_callback()
601 {
602 printf(
603 '<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" /> ',
604 isset( $this->options['myfixed_transition_time'] ) ? esc_attr( $this->options['myfixed_transition_time']) : ''
605 );
606 echo __("in seconds.", 'mystickymenu');
607 echo '</p>';
608 }
609
610 public function myfixed_disable_small_screen_callback()
611 {
612 printf(
613 '<p class="description">'
614 );
615 echo __("less than", 'mystickymenu');
616 printf(
617 ' <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" />',
618 isset( $this->options['myfixed_disable_small_screen'] ) ? esc_attr( $this->options['myfixed_disable_small_screen']) : ''
619 );
620 echo __("px width, 0 to disable.", 'mystickymenu');
621 echo '</p>';
622 }
623
624 public function mysticky_active_on_height_callback()
625 {
626 printf(
627 '<p class="description">'
628 );
629 echo __("after", 'mystickymenu');
630 printf(
631 ' <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" />',
632 isset( $this->options['mysticky_active_on_height'] ) ? esc_attr( $this->options['mysticky_active_on_height']) : ''
633 );
634 echo __("px. If set to 0 auto calculate will be used.", 'mystickymenu');
635 echo '</p>';
636 }
637
638 public function mysticky_active_on_height_home_callback()
639 {
640 printf(
641 '<p class="description">'
642 );
643 echo __("after", 'mystickymenu');
644 printf(
645 ' <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" />',
646 isset( $this->options['mysticky_active_on_height_home'] ) ? esc_attr( $this->options['mysticky_active_on_height_home']) : ''
647 );
648 echo __("px. If set to 0 it will use initial Make visible on Scroll value.", 'mystickymenu');
649 echo '</p>';
650 }
651
652 public function myfixed_fade_callback()
653 {
654 printf(
655 '<p class="description"><input id="%1$s" name="mysticky_option_name[myfixed_fade]" type="checkbox" %2$s /> ',
656 'myfixed_fade',
657 checked( isset( $this->options['myfixed_fade'] ), true, false )
658 );
659 echo __("Checked is slide, unchecked is fade.", 'mystickymenu');
660 echo '</p>';
661
662 printf(
663 '<p class="description"><input id="%1$s" name="mysticky_option_name[myfixed_disable_scroll_down]" type="checkbox" %2$s /> ',
664 'myfixed_disable_scroll_down',
665 checked( isset( $this->options['myfixed_disable_scroll_down'] ), true, false )
666 );
667 echo __("Disable sticky menu at scroll down", 'mystickymenu');
668 echo '</p>';
669
670
671
672
673 }
674
675 public function myfixed_cssstyle_callback()
676 {
677 printf(
678 '<p class="description">'
679 );
680 echo __("Add/edit CSS style. Leave it blank for default style.", 'mystickymenu');
681 echo '</p>';
682 printf(
683 '<textarea type="text" rows="4" cols="60" id="myfixed_cssstyle" name="mysticky_option_name[myfixed_cssstyle]">%s</textarea> <br />',
684 isset( $this->options['myfixed_cssstyle'] ) ? esc_attr( $this->options['myfixed_cssstyle']) : ''
685 );
686 echo '<p class="description">';
687
688 echo __("If you want to change sticky hover color: ", 'mystickymenu');
689 echo '.myfixed li a:hover {color:#000; background-color: #ccc;}<br />';
690 echo __("More examples <a href='http://wordpress.transformnews.com/tutorials/mystickymenu-extended-style-functionality-using-myfixed-sticky-class-403'>here</a>.", 'mystickymenu');
691 echo'</p>';
692 }
693
694 public function disable_css_callback()
695 {
696 printf(
697 '<p class="description"><input id="%1$s" name="mysticky_option_name[disable_css]" type="checkbox" %2$s /> ',
698 'disable_css',
699 checked( isset( $this->options['disable_css'] ), true, false )
700 );
701 echo __("Use this option if you plan to include CSS Style manually", 'mystickymenu');
702 echo '</p>';
703 }
704
705
706
707
708
709
710
711
712
713
714
715
716
717 public function mysticky_enable_callback()
718 {
719
720 _e('<span>front page </span>', 'mystickymenu');
721 printf(
722 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_front_home]" type="checkbox" %2$s /> ',
723 'mysticky_disable_at_front_home',
724 checked( isset( $this->options['mysticky_disable_at_front_home'] ), true, false )
725 ) ;
726 _e('<span>blog page </span>', 'mystickymenu');
727 printf(
728 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_blog]" type="checkbox" %2$s /> ',
729 'mysticky_disable_at_blog',
730 checked( isset( $this->options['mysticky_disable_at_blog'] ), true, false )
731 );
732 _e('<span>pages </span>', 'mystickymenu');
733 printf(
734 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_page]" type="checkbox" %2$s /> ',
735 'mysticky_disable_at_page',
736 checked( isset( $this->options['mysticky_disable_at_page'] ), true, false )
737 );
738 _e('<span>tags </span>', 'mystickymenu');
739 printf(
740 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_tag]" type="checkbox" %2$s /> ',
741 'mysticky_disable_at_tag',
742 checked( isset( $this->options['mysticky_disable_at_tag'] ), true, false )
743 );
744 _e('<span>categories </span>', 'mystickymenu');
745 printf(
746 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_category]" type="checkbox" %2$s /> ',
747 'mysticky_disable_at_category',
748 checked( isset( $this->options['mysticky_disable_at_category'] ), true, false )
749 );
750 _e('<span>posts </span>', 'mystickymenu');
751 printf(
752 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_single]" type="checkbox" %2$s /> ',
753 'mysticky_disable_at_single',
754 checked( isset( $this->options['mysticky_disable_at_single'] ), true, false )
755 );
756 _e('<span>archives </span>', 'mystickymenu');
757 printf(
758 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_archive]" type="checkbox" %2$s /> ',
759 'mysticky_disable_at_archive',
760 checked( isset( $this->options['mysticky_disable_at_archive'] ), true, false )
761 );
762
763 _e('<span>search </span>', 'mystickysidebar');
764 printf(
765 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_search]" type="checkbox" %2$s /> ',
766 'mysticky_disable_at_search',
767 checked( isset( $this->options['mysticky_disable_at_search'] ), true, false )
768 );
769
770 if (isset ( $this->options['mysticky_disable_at_page'] ) == true ) {
771
772 echo '<p> </p> <hr />';
773 _e('<span class="">Except for this pages: </span>', 'mystickymenu');
774
775 printf(
776 '<input type="text" size="26" id="mysticky_enable_at_pages" name="mysticky_option_name[mysticky_enable_at_pages]" value="%s" /> ',
777 isset( $this->options['mysticky_enable_at_pages'] ) ? esc_attr( $this->options['mysticky_enable_at_pages']) : ''
778 );
779
780 _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');
781
782 }
783
784 if (isset ( $this->options['mysticky_disable_at_single'] ) == true ) {
785
786 echo '<p> </p> <hr />';
787 _e('<span class="">Except for this posts: </span>', 'mystickymenu');
788
789 printf(
790 '<input type="text" size="26" id="mysticky_enable_at_posts" name="mysticky_option_name[mysticky_enable_at_posts]" value="%s" /> ',
791 isset( $this->options['mysticky_enable_at_posts'] ) ? esc_attr( $this->options['mysticky_enable_at_posts']) : ''
792 );
793
794 _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');
795
796 }
797
798 }
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813 }
814
815
816
817 class MyStickyMenuFrontend
818 {
819
820 public function __construct()
821 {
822
823 add_action( 'wp_head', array( $this, 'mysticky_build_stylesheet_content' ) );
824 add_action( 'wp_enqueue_scripts', array( $this, 'mysticky_disable_at' ) );
825
826 }
827
828 public function mysticky_build_stylesheet_content()
829
830 {
831
832 $mysticky_options = get_option( 'mysticky_option_name' );
833
834 if (isset($mysticky_options['disable_css']))
835
836 {
837
838 //do nothing
839
840 } else {
841
842 $mysticky_options['disable_css'] = false;
843
844 };
845
846 if ($mysticky_options ['disable_css'] == false )
847
848 {
849
850 echo '<style id="mystickymenu" type="text/css">';
851 echo '#mysticky-nav { width:100%; position: static; }';
852 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'] . ';}';
853
854
855 if ($mysticky_options ['myfixed_disable_small_screen'] > 0 ){
856
857 //echo '@media (max-width: '.$mysticky_options['myfixed_disable_small_screen'].'px) {#mysticky-nav.wrapfixed {position: static;} }';
858
859 };
860
861 if ( $mysticky_options['myfixed_cssstyle'] == "" ) {
862 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%; }';
863 }
864
865
866
867 echo $mysticky_options ['myfixed_cssstyle'];
868
869
870
871 echo '</style>';
872 }
873 }
874
875 // add_action('wp_head', 'mysticky_build_stylesheet_content');
876
877 public function mystickymenu_script() {
878
879 $mysticky_options = get_option( 'mysticky_option_name' );
880
881 if ( is_admin_bar_showing() ) {
882 $top = "true";
883 } else {
884 $top = "false";
885 }
886
887
888 // needed for update 1.7 => 1.8 ... will be removed in the future ()
889 if (isset($mysticky_options['mysticky_active_on_height_home'])){
890 //do nothing
891 } else {
892 $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height'];
893 };
894
895
896 if ($mysticky_options['mysticky_active_on_height_home'] == 0 ){
897 $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height'];
898 };
899
900
901 if ( is_front_page() && is_home() ) {
902
903 $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home'];
904
905 } elseif ( is_front_page()){
906
907 $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home'];
908
909 }
910
911 wp_register_script('mystickymenu', plugins_url( 'js/mystickymenu.min.js', __FILE__ ), array('jquery'), MYSTICKY_VERSION, true);
912 wp_enqueue_script( 'mystickymenu' );
913
914 $myfixed_disable_scroll_down = isset($mysticky_options['myfixed_disable_scroll_down']) ? $mysticky_options['myfixed_disable_scroll_down'] : 'false';
915 $mystickyTransition = isset($mysticky_options['myfixed_fade']) ? $mysticky_options['myfixed_fade'] : 'fade';
916
917 $mysticky_translation_array = array(
918 'mystickyClass' => $mysticky_options['mysticky_class_selector'] ,
919 'activationHeight' => $mysticky_options['mysticky_active_on_height'],
920 'disableWidth' => $mysticky_options['myfixed_disable_small_screen'],
921 'adminBar' => $top,
922 'mystickyTransition' => $mystickyTransition,
923 'mysticky_disable_down' => $myfixed_disable_scroll_down,
924
925
926 );
927
928 wp_localize_script( 'mystickymenu', 'option', $mysticky_translation_array );
929 }
930
931 //add_action( 'wp_enqueue_scripts', 'mystickymenu_script' );
932
933
934 public function mysticky_disable_at() {
935
936
937 $mysticky_options = get_option( 'mysticky_option_name' );
938
939 $mysticky_disable_at_front_home = isset($mysticky_options['mysticky_disable_at_front_home']);
940 $mysticky_disable_at_blog = isset($mysticky_options['mysticky_disable_at_blog']);
941 $mysticky_disable_at_page = isset($mysticky_options['mysticky_disable_at_page']);
942 $mysticky_disable_at_tag = isset($mysticky_options['mysticky_disable_at_tag']);
943 $mysticky_disable_at_category = isset($mysticky_options['mysticky_disable_at_category']);
944 $mysticky_disable_at_single = isset($mysticky_options['mysticky_disable_at_single']);
945 $mysticky_disable_at_archive = isset($mysticky_options['mysticky_disable_at_archive']);
946 $mysticky_disable_at_search = isset($mysticky_options['mysticky_disable_at_search']);
947 $mysticky_enable_at_pages = isset($mysticky_options['mysticky_enable_at_pages']) ? $mysticky_options['mysticky_enable_at_pages'] : '';
948 $mysticky_enable_at_posts = isset($mysticky_options['mysticky_enable_at_posts']) ? $mysticky_options['mysticky_enable_at_posts'] : '';
949 //$mystickymenu_enable_at_pages_exp = explode( ',', $mystickymenu_enable_at_pages );
950 // Trim input to ignore empty spaces
951 $mysticky_enable_at_pages_exp = array_map('trim', explode(',', $mysticky_enable_at_pages));
952 $mysticky_enable_at_posts_exp = array_map('trim', explode(',', $mysticky_enable_at_posts));
953
954
955
956
957 if ( is_front_page() && is_home() ) {
958 // Default homepage
959 if ( $mysticky_disable_at_front_home == false ) {
960 $this->mystickymenu_script();
961
962 };
963
964
965 } elseif ( is_front_page()){
966 //Static homepage
967 if ( $mysticky_disable_at_front_home == false ) {
968 $this->mystickymenu_script();
969 };
970
971
972 } elseif ( is_home()){
973
974 //Blog page
975 if ( $mysticky_disable_at_blog == false ) {
976 $this->mystickymenu_script();
977 };
978
979
980 } elseif ( is_page() ){
981
982 //Single page
983 if ( $mysticky_disable_at_page == false ) {
984 $this->mystickymenu_script();
985 };
986
987 if ( is_page( $mysticky_enable_at_pages_exp ) ){
988 $this->mystickymenu_script();
989 }
990
991
992 } elseif ( is_tag()){
993
994 //Tag page
995 if ( $mysticky_disable_at_tag == false ) {
996 $this->mystickymenu_script();
997 };
998
999 } elseif ( is_category()){
1000
1001 //Category page
1002 if ( $mysticky_disable_at_category == false ) {
1003 $this->mystickymenu_script();
1004 };
1005
1006
1007 } elseif ( is_single()){
1008
1009 //Single post
1010 if ( $mysticky_disable_at_single == false ) {
1011 $this->mystickymenu_script();
1012 };
1013
1014 if ( is_single( $mysticky_enable_at_posts_exp ) ){
1015 $this->mystickymenu_script();
1016 }
1017
1018 } elseif ( is_archive()){
1019
1020 //Archive
1021 if ( $mysticky_disable_at_archive == false ) {
1022 $this->mystickymenu_script();
1023 };
1024
1025 } elseif ( is_search()){
1026
1027 //Archive
1028 if ( $mysticky_disable_at_search == false ) {
1029 $this->mystickymenu_script();
1030 };
1031
1032 }
1033
1034
1035 }
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045 }
1046
1047 if( is_admin() ) {
1048
1049 new MyStickyMenuBackend();
1050
1051 } else {
1052
1053 new MyStickyMenuFrontend();
1054
1055 }
1056 ?>