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