PluginProbe ʕ •ᴥ•ʔ
My Sticky Bar – Floating Notification Bar & Sticky Header (formerly myStickymenu) / 1.9
My Sticky Bar – Floating Notification Bar & Sticky Header (formerly myStickymenu) v1.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 8 years ago languages 11 years ago mystickymenu.php 8 years ago readme.txt 8 years ago
mystickymenu.php
825 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.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 add_settings_field(
219 'mysticky_disable_at_search',
220 __("Disable at", 'mystickysidebar'),
221 'my-stickymenu-settings',
222 'setting_section_id'
223 );
224
225
226
227 }
228 /**
229 * Sanitize each setting field as needed
230 *
231 * @param array $input Contains all settings fields as array keys
232 */
233 public function sanitize( $input )
234 {
235 $new_input = array();
236 if( isset( $input['mysticky_class_selector'] ) )
237 $new_input['mysticky_class_selector'] = sanitize_text_field( $input['mysticky_class_selector'] );
238
239 if( isset( $input['myfixed_zindex'] ) )
240 $new_input['myfixed_zindex'] = absint( $input['myfixed_zindex'] );
241
242 if( isset( $input['myfixed_bgcolor'] ) )
243 $new_input['myfixed_bgcolor'] = sanitize_text_field( $input['myfixed_bgcolor'] );
244
245 if( isset( $input['myfixed_opacity'] ) )
246 $new_input['myfixed_opacity'] = absint( $input['myfixed_opacity'] );
247
248 if( isset( $input['myfixed_transition_time'] ) )
249 $new_input['myfixed_transition_time'] = sanitize_text_field( $input['myfixed_transition_time'] );
250
251 if( isset( $input['myfixed_disable_small_screen'] ) )
252 $new_input['myfixed_disable_small_screen'] = absint( $input['myfixed_disable_small_screen'] );
253
254 if( isset( $input['mysticky_active_on_height'] ) )
255 $new_input['mysticky_active_on_height'] = absint( $input['mysticky_active_on_height'] );
256
257 if( isset( $input['mysticky_active_on_height_home'] ) )
258 $new_input['mysticky_active_on_height_home'] = absint( $input['mysticky_active_on_height_home'] );
259
260 if( isset( $input['myfixed_fade'] ) )
261 $new_input['myfixed_fade'] = sanitize_text_field( $input['myfixed_fade'] );
262
263 if( isset( $input['myfixed_cssstyle'] ) )
264 $new_input['myfixed_cssstyle'] = sanitize_text_field( $input['myfixed_cssstyle'] );
265
266 if( isset( $input['disable_css'] ) )
267 $new_input['disable_css'] = sanitize_text_field( $input['disable_css'] );
268
269
270
271 if( isset( $input['mysticky_disable_at_front_home'] ) )
272 $new_input['mysticky_disable_at_front_home'] = sanitize_text_field( $input['mysticky_disable_at_front_home'] );
273
274 if( isset( $input['mysticky_disable_at_blog'] ) )
275 $new_input['mysticky_disable_at_blog'] = sanitize_text_field( $input['mysticky_disable_at_blog'] );
276
277 if( isset( $input['mysticky_disable_at_page'] ) )
278 $new_input['mysticky_disable_at_page'] = sanitize_text_field( $input['mysticky_disable_at_page'] );
279
280 if( isset( $input['mysticky_disable_at_tag'] ) )
281 $new_input['mysticky_disable_at_tag'] = sanitize_text_field( $input['mysticky_disable_at_tag'] );
282
283 if( isset( $input['mysticky_disable_at_category'] ) )
284 $new_input['mysticky_disable_at_category'] = sanitize_text_field( $input['mysticky_disable_at_category'] );
285
286 if( isset( $input['mysticky_disable_at_single'] ) )
287 $new_input['mysticky_disable_at_single'] = sanitize_text_field( $input['mysticky_disable_at_single'] );
288
289 if( isset( $input['mysticky_disable_at_archive'] ) )
290 $new_input['mysticky_disable_at_archive'] = sanitize_text_field( $input['mysticky_disable_at_archive'] );
291
292 if( isset( $input['mysticky_enable_at_pages'] ) )
293 $new_input['mysticky_enable_at_pages'] = sanitize_text_field( $input['mysticky_enable_at_pages'] );
294
295 if( isset( $input['mysticky_enable_at_posts'] ) )
296 $new_input['mysticky_enable_at_posts'] = sanitize_text_field( $input['mysticky_enable_at_posts'] );
297
298 if( isset( $input['mysticky_disable_at_search'] ) )
299 $new_input['mysticky_disable_at_search'] = sanitize_text_field( $input['mysticky_disable_at_search'] );
300
301
302
303
304
305 return $new_input;
306 }
307
308 public function mysticky_default_options() {
309
310 global $options;
311 $default = array(
312
313 'mysticky_class_selector' => '.navbar',
314 'myfixed_zindex' => '1000',
315 'myfixed_bgcolor' => '#FAFAFA',
316 'myfixed_opacity' => '90',
317 'myfixed_transition_time' => '0.3',
318 'myfixed_disable_small_screen' => '359',
319 'mysticky_active_on_height' => '320',
320 'mysticky_active_on_height_home' => '320',
321 'myfixed_fade' => false,
322 'myfixed_cssstyle' => '.myfixed { margin:0 auto!important; float:none!important; border:0px!important; background:none!important; max-width:100%!important; }'
323 );
324
325 if ( get_option('mysticky_option_name') == false ) {
326 update_option( 'mysticky_option_name', $default );
327 }
328 }
329
330 public function mysticky_enqueue_color_picker( )
331 {
332 wp_enqueue_style( 'wp-color-picker' );
333 wp_enqueue_script( 'my-script-handle', plugins_url('js/iris-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
334 }
335
336 public function print_section_info()
337 {
338 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');
339 }
340
341 public function mysticky_class_selector_callback()
342 {
343 printf(
344 '<p class="description"><input type="text" size="8" id="mysticky_class_selector" name="mysticky_option_name[mysticky_class_selector]" value="%s" /> ',
345 isset( $this->options['mysticky_class_selector'] ) ? esc_attr( $this->options['mysticky_class_selector']) : ''
346 );
347 echo __("menu or header div class or id.", 'mystickymenu');
348 echo '</p>';
349 }
350
351 public function myfixed_zindex_callback()
352 {
353 printf(
354 '<p class="description"><input type="number" min="0" max="2147483647" step="1" id="myfixed_zindex" name="mysticky_option_name[myfixed_zindex]" value="%s" /></p>',
355 isset( $this->options['myfixed_zindex'] ) ? esc_attr( $this->options['myfixed_zindex']) : ''
356 );
357 }
358
359 public function myfixed_bgcolor_callback()
360 {
361 printf(
362 '<p class="description"><input type="text" id="myfixed_bgcolor" name="mysticky_option_name[myfixed_bgcolor]" class="my-color-field" value="%s" /></p> ' ,
363 isset( $this->options['myfixed_bgcolor'] ) ? esc_attr( $this->options['myfixed_bgcolor']) : ''
364 );
365 }
366
367 public function myfixed_opacity_callback()
368 {
369 printf(
370 '<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" /> ',
371 isset( $this->options['myfixed_opacity'] ) ? esc_attr( $this->options['myfixed_opacity']) : ''
372 );
373 echo __("numbers 1-100.", 'mystickymenu');
374 echo '</p>';
375 }
376
377 public function myfixed_transition_time_callback()
378 {
379 printf(
380 '<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" /> ',
381 isset( $this->options['myfixed_transition_time'] ) ? esc_attr( $this->options['myfixed_transition_time']) : ''
382 );
383 echo __("in seconds.", 'mystickymenu');
384 echo '</p>';
385 }
386
387 public function myfixed_disable_small_screen_callback()
388 {
389 printf(
390 '<p class="description">'
391 );
392 echo __("less than", 'mystickymenu');
393 printf(
394 ' <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" />',
395 isset( $this->options['myfixed_disable_small_screen'] ) ? esc_attr( $this->options['myfixed_disable_small_screen']) : ''
396 );
397 echo __("px width, 0 to disable.", 'mystickymenu');
398 echo '</p>';
399 }
400
401 public function mysticky_active_on_height_callback()
402 {
403 printf(
404 '<p class="description">'
405 );
406 echo __("after", 'mystickymenu');
407 printf(
408 ' <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" />',
409 isset( $this->options['mysticky_active_on_height'] ) ? esc_attr( $this->options['mysticky_active_on_height']) : ''
410 );
411 echo __("px.", 'mystickymenu');
412 echo '</p>';
413 }
414
415 public function mysticky_active_on_height_home_callback()
416 {
417 printf(
418 '<p class="description">'
419 );
420 echo __("after", 'mystickymenu');
421 printf(
422 ' <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" />',
423 isset( $this->options['mysticky_active_on_height_home'] ) ? esc_attr( $this->options['mysticky_active_on_height_home']) : ''
424 );
425 echo __("px.", 'mystickymenu');
426 echo '</p>';
427 }
428
429 public function myfixed_fade_callback()
430 {
431 printf(
432 '<p class="description"><input id="%1$s" name="mysticky_option_name[myfixed_fade]" type="checkbox" %2$s /> ',
433 'myfixed_fade',
434 checked( isset( $this->options['myfixed_fade'] ), true, false )
435 );
436 echo __("Checked is slide, unchecked is fade.", 'mystickymenu');
437 echo '</p>';
438 }
439
440 public function myfixed_cssstyle_callback()
441 {
442 printf(
443 '<p class="description">'
444 );
445 echo __("Add/Edit .myfixed css class to change sticky menu style. Leave it blank for default style.", 'mystickymenu');
446 echo '</p>';
447 printf(
448 '<textarea type="text" rows="4" cols="60" id="myfixed_cssstyle" name="mysticky_option_name[myfixed_cssstyle]">%s</textarea> <br />',
449 isset( $this->options['myfixed_cssstyle'] ) ? esc_attr( $this->options['myfixed_cssstyle']) : ''
450 );
451 echo '<p class="description">';
452 echo __("Default style: ", 'mystickymenu');
453 echo '.myfixed { margin:0 auto!important; float:none!important; border:0px!important; background:none!important; max-width:100%!important; }<br /><br />';
454 echo __("If you want to change sticky hover color first add default style and than: ", 'mystickymenu');
455 echo '.myfixed li a:hover {color:#000; background-color: #ccc;}<br />';
456 echo __("More examples <a href='http://wordpress.transformnews.com/tutorials/mystickymenu-extended-style-functionality-using-myfixed-sticky-class-403'>here</a>.", 'mystickymenu');
457 echo'</p>';
458 }
459
460 public function disable_css_callback()
461 {
462 printf(
463 '<p class="description"><input id="%1$s" name="mysticky_option_name[disable_css]" type="checkbox" %2$s /> ',
464 'disable_css',
465 checked( isset( $this->options['disable_css'] ), true, false )
466 );
467 echo __("Use this option if you plan to include CSS Style manually", 'mystickymenu');
468 echo '</p>';
469 }
470
471
472
473
474
475
476
477
478
479
480
481
482
483 public function mysticky_enable_callback()
484 {
485
486 _e('<span>front page </span>', 'mystickymenu');
487 printf(
488 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_front_home]" type="checkbox" %2$s /> ',
489 'mysticky_disable_at_front_home',
490 checked( isset( $this->options['mysticky_disable_at_front_home'] ), true, false )
491 ) ;
492 _e('<span>blog page </span>', 'mystickymenu');
493 printf(
494 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_blog]" type="checkbox" %2$s /> ',
495 'mysticky_disable_at_blog',
496 checked( isset( $this->options['mysticky_disable_at_blog'] ), true, false )
497 );
498 _e('<span>pages </span>', 'mystickymenu');
499 printf(
500 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_page]" type="checkbox" %2$s /> ',
501 'mysticky_disable_at_page',
502 checked( isset( $this->options['mysticky_disable_at_page'] ), true, false )
503 );
504 _e('<span>tags </span>', 'mystickymenu');
505 printf(
506 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_tag]" type="checkbox" %2$s /> ',
507 'mysticky_disable_at_tag',
508 checked( isset( $this->options['mysticky_disable_at_tag'] ), true, false )
509 );
510 _e('<span>categories </span>', 'mystickymenu');
511 printf(
512 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_category]" type="checkbox" %2$s /> ',
513 'mysticky_disable_at_category',
514 checked( isset( $this->options['mysticky_disable_at_category'] ), true, false )
515 );
516 _e('<span>posts </span>', 'mystickymenu');
517 printf(
518 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_single]" type="checkbox" %2$s /> ',
519 'mysticky_disable_at_single',
520 checked( isset( $this->options['mysticky_disable_at_single'] ), true, false )
521 );
522 _e('<span>archives </span>', 'mystickymenu');
523 printf(
524 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_archive]" type="checkbox" %2$s /> ',
525 'mysticky_disable_at_archive',
526 checked( isset( $this->options['mysticky_disable_at_archive'] ), true, false )
527 );
528
529 _e('<span>search </span>', 'mystickysidebar');
530 printf(
531 '<input id="%1$s" name="mysticky_option_name[mysticky_disable_at_search]" type="checkbox" %2$s /> ',
532 'mysticky_disable_at_search',
533 checked( isset( $this->options['mysticky_disable_at_search'] ), true, false )
534 );
535
536 if (isset ( $this->options['mysticky_disable_at_page'] ) == true ) {
537
538 echo '<p> </p> <hr />';
539 _e('<span class="">Except for this pages: </span>', 'mystickymenu');
540
541 printf(
542 '<input type="text" size="26" id="mysticky_enable_at_pages" name="mysticky_option_name[mysticky_enable_at_pages]" value="%s" /> ',
543 isset( $this->options['mysticky_enable_at_pages'] ) ? esc_attr( $this->options['mysticky_enable_at_pages']) : ''
544 );
545
546 _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');
547
548 }
549
550 if (isset ( $this->options['mysticky_disable_at_single'] ) == true ) {
551
552 echo '<p> </p> <hr />';
553 _e('<span class="">Except for this posts: </span>', 'mystickymenu');
554
555 printf(
556 '<input type="text" size="26" id="mysticky_enable_at_posts" name="mysticky_option_name[mysticky_enable_at_posts]" value="%s" /> ',
557 isset( $this->options['mysticky_enable_at_posts'] ) ? esc_attr( $this->options['mysticky_enable_at_posts']) : ''
558 );
559
560 _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');
561
562 }
563
564 }
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579 }
580
581
582
583 class MyStickyMenuFrontend
584 {
585
586 public function __construct()
587 {
588
589 add_action( 'wp_head', array( $this, 'mysticky_build_stylesheet_content' ) );
590 add_action( 'wp_enqueue_scripts', array( $this, 'mysticky_disable_at' ) );
591
592 }
593
594 public function mysticky_build_stylesheet_content()
595
596 {
597
598 $mysticky_options = get_option( 'mysticky_option_name' );
599
600 if (isset($mysticky_options['disable_css']))
601
602 {
603
604 //do nothing
605
606 } else {
607
608 $mysticky_options['disable_css'] = false;
609
610 };
611
612 if ($mysticky_options ['disable_css'] == false )
613
614 {
615
616
617
618
619
620
621 echo
622 '<style type="text/css">';
623 if ( is_user_logged_in() ) {
624 echo '#wpadminbar { position: absolute !important; top: 0px !important;}';
625 }
626 if ( $mysticky_options['myfixed_cssstyle'] == "" ) {
627 echo '.myfixed{margin:0 auto!important; float:none!important; border:0px!important; background:none!important; max-width:100%!important;}';
628 }
629 echo $mysticky_options ['myfixed_cssstyle'];
630 echo '#mysticky-nav { width:100%!important; position: static;';
631
632 if (isset($mysticky_options['myfixed_fade']))
633 {
634 echo 'top: -100px;';
635 }
636 echo '}';
637
638
639 if ($mysticky_options ['myfixed_opacity'] == 100 ){
640
641 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;}';
642
643 }
644
645 if ($mysticky_options ['myfixed_opacity'] < 100 ){
646
647 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;}';
648
649 }
650
651 if ($mysticky_options ['myfixed_disable_small_screen'] > 0 ){
652
653 echo '@media (max-width: ' . $mysticky_options ['myfixed_disable_small_screen'] . 'px) {.wrapfixed {position: static!important;} }';
654
655 }
656 echo '</style>';
657 }
658 }
659
660 // add_action('wp_head', 'mysticky_build_stylesheet_content');
661
662 public function mystickymenu_script() {
663
664 $mysticky_options = get_option( 'mysticky_option_name' );
665
666 // needed for update 1.7 => 1.8 ... will be removed in the future ()
667 if (isset($mysticky_options['mysticky_active_on_height_home'])){
668 //do nothing
669 } else {
670 $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height'];
671 };
672
673 if ($mysticky_options['mysticky_active_on_height_home'] == 0 ){
674 $mysticky_options['mysticky_active_on_height_home'] = $mysticky_options['mysticky_active_on_height'];
675 };
676
677
678 if ( is_front_page() && is_home() ) {
679
680 $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home'];
681
682 } elseif ( is_front_page()){
683
684 $mysticky_options['mysticky_active_on_height'] = $mysticky_options['mysticky_active_on_height_home'];
685
686 }
687
688 wp_register_script('mystickymenu', plugins_url( 'js/mystickymenu.min.js', __FILE__ ), array('jquery'),'1.8.7', true);
689 wp_enqueue_script( 'mystickymenu' );
690
691 $mysticky_translation_array = array(
692 'mysticky_string' => $mysticky_options['mysticky_class_selector'] ,
693 'mysticky_active_on_height_string' => $mysticky_options['mysticky_active_on_height'],
694 'mysticky_disable_at_width_string' => $mysticky_options['myfixed_disable_small_screen']
695 );
696
697 wp_localize_script( 'mystickymenu', 'mysticky_name', $mysticky_translation_array );
698 }
699
700 //add_action( 'wp_enqueue_scripts', 'mystickymenu_script' );
701
702
703 public function mysticky_disable_at() {
704
705
706 $mysticky_options = get_option( 'mysticky_option_name' );
707
708 $mysticky_disable_at_front_home = isset($mysticky_options['mysticky_disable_at_front_home']);
709 $mysticky_disable_at_blog = isset($mysticky_options['mysticky_disable_at_blog']);
710 $mysticky_disable_at_page = isset($mysticky_options['mysticky_disable_at_page']);
711 $mysticky_disable_at_tag = isset($mysticky_options['mysticky_disable_at_tag']);
712 $mysticky_disable_at_category = isset($mysticky_options['mysticky_disable_at_category']);
713 $mysticky_disable_at_single = isset($mysticky_options['mysticky_disable_at_single']);
714 $mysticky_disable_at_archive = isset($mysticky_options['mysticky_disable_at_archive']);
715 $mysticky_disable_at_search = isset($mysticky_options['mysticky_disable_at_search']);
716 $mysticky_enable_at_pages = isset($mysticky_options['mysticky_enable_at_pages']) ? $mysticky_options['mysticky_enable_at_pages'] : '';
717 $mysticky_enable_at_posts = isset($mysticky_options['mysticky_enable_at_posts']) ? $mysticky_options['mysticky_enable_at_posts'] : '';
718 //$mystickymenu_enable_at_pages_exp = explode( ',', $mystickymenu_enable_at_pages );
719 // Trim input to ignore empty spaces
720 $mysticky_enable_at_pages_exp = array_map('trim', explode(',', $mysticky_enable_at_pages));
721 $mysticky_enable_at_posts_exp = array_map('trim', explode(',', $mysticky_enable_at_posts));
722
723
724
725
726 if ( is_front_page() && is_home() ) {
727 // Default homepage
728 if ( $mysticky_disable_at_front_home == false ) {
729 $this->mystickymenu_script();
730
731 };
732
733
734 } elseif ( is_front_page()){
735 //Static homepage
736 if ( $mysticky_disable_at_front_home == false ) {
737 $this->mystickymenu_script();
738 };
739
740
741 } elseif ( is_home()){
742
743 //Blog page
744 if ( $mysticky_disable_at_blog == false ) {
745 $this->mystickymenu_script();
746 };
747
748
749 } elseif ( is_page() ){
750
751 //Single page
752 if ( $mysticky_disable_at_page == false ) {
753 $this->mystickymenu_script();
754 };
755
756 if ( is_page( $mysticky_enable_at_pages_exp ) ){
757 $this->mystickymenu_script();
758 }
759
760
761 } elseif ( is_tag()){
762
763 //Tag page
764 if ( $mysticky_disable_at_tag == false ) {
765 $this->mystickymenu_script();
766 };
767
768 } elseif ( is_category()){
769
770 //Category page
771 if ( $mysticky_disable_at_category == false ) {
772 $this->mystickymenu_script();
773 };
774
775
776 } elseif ( is_single()){
777
778 //Single post
779 if ( $mysticky_disable_at_single == false ) {
780 $this->mystickymenu_script();
781 };
782
783 if ( is_single( $mysticky_enable_at_posts_exp ) ){
784 $this->mystickymenu_script();
785 }
786
787 } elseif ( is_archive()){
788
789 //Archive
790 if ( $mysticky_disable_at_archive == false ) {
791 $this->mystickymenu_script();
792 };
793
794 } elseif ( is_search()){
795
796 //Archive
797 if ( $mysticky_disable_at_search == false ) {
798 $this->mystickymenu_script();
799 };
800
801 }
802
803
804 }
805
806
807
808
809
810
811
812
813
814 }
815
816 if( is_admin() ) {
817
818 new MyStickyMenuBackend();
819
820 } else {
821
822 new MyStickyMenuFrontend();
823
824 }
825 ?>