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