示例#1
0
function ubermenu_sticky_custom_styles($styles)
{
    if (ubermenu_op('sticky_disable_css', 'general') == 'on') {
        return $styles;
    }
    if (UM_STICKY()->sticky_apply()) {
        $css = '';
        $css .= "\n/** UberMenu Sticky CSS **/\n";
        $css .= ".ubermenu.ubermenu-sticky, .ubermenu-responsive-toggle.ubermenu-sticky{ z-index:1000; }";
        $css .= ".ubermenu-sticky.ubermenu-sticky-full-width{ left:0; width:100%; max-width:100%; }\n";
        $css .= ".ubermenu-sticky-full-width.ubermenu-sticky .ubermenu-nav{ padding-left:1px; }\n";
        $breakpoint = ubermenu_op('responsive_breakpoint', 'general');
        if ($breakpoint === '') {
            $breakpoint = 959;
        }
        if (is_numeric($breakpoint)) {
            $breakpoint .= 'px';
        }
        //Responsive Sticky Styles
        $css .= "@media screen and (max-width: {$breakpoint}){ \n" . "  .ubermenu-responsive-toggle.ubermenu-sticky{ height:43px; left:0; width:100% !important; } \n" . "  .ubermenu.ubermenu-responsive.ubermenu-sticky{ margin-top:43px; left:0; width:100% !important; } \n";
        //"  .ubermenu-sticky-wrapper{ max-height:0; min-height:0 !important; } \n".
        $css .= "  /* Mobile Sticky */\n";
        $css .= "  .ubermenu.ubermenu-is-mobile.ubermenu-sticky { min-height:400px; max-height:600px; overflow-y:auto !important; -webkit-overflow-scrolling:touch; }\n";
        $css .= "  .ubermenu.ubermenu-is-mobile.ubermenu-sticky > .ubermenu-nav{ height:100%; }\n";
        $css .= "  .ubermenu.ubermenu-is-mobile.ubermenu-sticky .ubermenu-active > .ubermenu-submenu-drop{ max-height:none; }\n";
        $css .= "}\n";
        //End media query
        //Special Sticky Classes
        $css .= "/* Special Classes */ ";
        $css .= ".ubermenu .ubermenu-item.um-sticky-only{ display:none !important; } ";
        $css .= ".ubermenu.ubermenu-sticky .ubermenu-item-level-0.um-sticky-only{ display:inline-block !important; } ";
        $css .= ".ubermenu.ubermenu-sticky .ubermenu-submenu .ubermenu-item.um-sticky-only{ display:block !important; } ";
        $css .= ".ubermenu .ubermenu-item-level-0.um-unsticky-only{ display:inline-block !important; } ";
        $css .= ".ubermenu .ubermenu-submenu .ubermenu-item.um-unsticky-only{ display:block !important; } ";
        $css .= ".ubermenu.ubermenu-sticky .ubermenu-item.um-unsticky-only{ display:none !important; }\n";
        /*
        		// The actual sticky CSS
        		$css.= "{$stickyMegaMenu}{ margin: 0 !important; z-index:1000; position:fixed !important; top: {$offset}px; bottom: auto !important; -webkit-transition:none; -moz-transition:none; transition:none; }\n";
        		
        		if( !$alwaysSticky ){
        			//Special Sticky Classes
        			$css.= "#megaMenu ul.megaMenu li.um-sticky-only{ display: none !important; }";
        			$css.= "#megaMenu-sticky-wrapper #megaMenu.ubermenu-sticky li.um-sticky-only{ display: block !important; }";
        			$css.= "#megaMenu ul.megaMenu li.um-unsticky-only{ display: block !important; }";
        			$css.= "#megaMenu-sticky-wrapper #megaMenu.ubermenu-sticky li.um-unsticky-only{ display: none !important; }";
        
        		}
        
        		if( $settings->op( 'ubersticky-mobile' ) ){
        			$css.= "\n/* Mobile Sticky */
        /*\n";
        			$stickyWrapper = '#megaMenu-sticky-wrapper.uber-sticky-mobile '; //trailing space is important
        			if( $alwaysSticky ) $stickyWrapper = ''; //Apply if we're not using
        			$css.= "{$stickyWrapper}#megaMenu ul.megaMenu.megaMenuToggleOpen{ overflow-y:scroll !important; -webkit-overflow-scrolling: touch; }";	//  overflow-scrolling: touch;
        		}
        
        		//At smaller sizes, make align left, full width!
        		if( $settings->op( 'ubersticky-expand-menu-bar' ) ){
        			$css.= "\n/* Expand Menu Bar */
        /*\n";
        		$css.= "{$stickyMegaMenu}{ left: 0; right:auto; width: 100%; border-radius: 0; }\n";
        		
        		if( is_numeric( $settings->op( 'ubersticky-center-inner' ) ) ){
        			$css.= "/* Center Inner Menu */
        /*\n";
        				$css.= "#megaMenu.ubermenu-sticky ul.megaMenu{ padding-left:2px; margin: 0 auto; float:none; max-width: {$settings->op( 'ubersticky-center-inner' )}px; }\n"; //leave selectors as is, use core UM settings instead
        				$css.= "#megaMenu.megaMenuHorizontal ul.megaMenu > li:first-child > a{ box-shadow:none; }\n";
        			}
        		}
        
        
        		//If UberMenu was supposed to be centered
        		if( $settings->op( 'center-menubar' ) ){
        			$css.= "/* Center Menubar */
        /*\n";
        			$css.= "#megaMenu-sticky-wrapper{ margin:0 auto; max-width: 100%; width: {$settings->op( 'wpmega-container-w' )}px; }\n";
        		}
        
        		if( ( $bkg_color = $settings->op( 'ubersticky-background-color' ) ) != '' ){
        			$css.= "/* Menu Bar Background */
        /*\n";
        			$css.= "#megaMenu-sticky-wrapper #megaMenu.ubermenu-sticky{ background: #$bkg_color; }\n";
        		}
        		*/
        if (ubermenu_op('sticky_toolbar_footer', 'general') == 'on') {
            $css .= "/* Move Admin Bar to bottom */\n@media screen and (min-width:783px){\n  * html body { margin-top: 0 !important; }\n  body.admin-bar { margin-top: -28px; padding-bottom: 28px; }\n  body.wp-admin #footer { padding-bottom: 28px; }\n  #wpadminbar { top: auto !important; bottom: 0; }\n  #wpadminbar .quicklinks .ab-sub-wrapper { bottom: 28px; }\n  #wpadminbar .quicklinks .ab-sub-wrapper ul .ab-sub-wrapper { bottom: -7px; } }\n";
        } else {
            $breakpoint = ubermenu_op('responsive_breakpoint', 'general');
            if (is_numeric($breakpoint)) {
                $breakpoint .= 'px';
            }
            $css .= "@media screen and (min-width:783px){ .admin-bar .ubermenu.ubermenu-sticky, .admin-bar .ubermenu-responsive-toggle.ubermenu-sticky{ margin-top:32px; } }\n";
            $css .= "@media screen and (min-width:783px) and (max-width:{$breakpoint}){ .admin-bar .ubermenu.ubermenu-sticky{ margin-top:78px; } }\n";
            $css .= "@media screen and (min-width:600px) and (max-width:782px){ .admin-bar .ubermenu.ubermenu-sticky, .admin-bar .ubermenu-responsive-toggle.ubermenu-sticky{ margin-top:46px; } .admin-bar .ubermenu.ubermenu-sticky{ margin-top:89px; } }\n";
        }
        $styles[70] = $css;
        //uberp( $styles );
    }
    return $styles;
}
                    }
                    $apply = apply_filters('ubermenu_sticky_apply', $apply, $config_id);
                    self::$sticky_apply[$config_id] = $apply;
                }
                return self::$sticky_apply[$config_id];
            }
            return self::$sticky_apply;
        }
    }
}
// End if class_exists check
function UM_STICKY()
{
    return UberMenu_Sticky::instance();
}
UM_STICKY();
//Let the user know they need to install UberMenu if they haven't already
add_action('plugins_loaded', 'ubermenu_sticky_ubercheck', 20);
function ubermenu_sticky_ubercheck()
{
    if (!function_exists('ubermenu')) {
        add_action('admin_notices', 'ubermenu_sticky_admin_notice');
    }
}
function ubermenu_sticky_admin_notice()
{
    ?>
<div class="error">
        <p><?php 
    _e('<strong>UberMenu Sticky</strong> is an Extension and requires the UberMenu plugin to function.  Please install and activate <a href="http://wpmegamenu.com">UberMenu</a> to use this extension.', 'ubermenu');
    ?>