Advertisement
upekshapriya

Patch for WordPress CSS Drop-down Menu

Mar 9th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2.  
  3. function wp_list_pages_filter($output) {
  4. //$output = preg_replace('#class="noiframe">([\w\s]+)</a>[\s]*<ul class=\'children\'>#', 'class="noiframe drop">$1<ul class=\'children\'>', $output);
  5. $output = preg_replace("#</a>\s+<ul class='children'>#", "<!--[if gte IE 7]><!--></a><!--<![endif]-->\n<!--[if lte IE 6]><table><tr><td><![endif]-->\n<ul class='children'>", $output);
  6. $output = str_replace("</ul>", "</ul>\n<!--[if lte IE 6]></td></tr></table></a><![endif]-->", $output);
  7. return $output;
  8. }
  9. add_filter('wp_list_pages', 'wp_list_pages_filter');
  10.  
  11.  
  12. //  see http://stackoverflow.com/questions/7933681/jquery-addclass-to-a-child-element
  13. function jquery_add_drops() {
  14.    ?>
  15.     <script language="JavaScript" type="text/javascript">  
  16.          jQuery(document).ready(function(){
  17.          jQuery("li:has(ul.children) > a").addClass('drop');
  18. });
  19.     </script>
  20.     <?php
  21. }
  22.  
  23. if (!(is_admin())) {
  24. wp_enqueue_script('jquery');
  25. add_action('wp_head', 'jquery_add_drops');
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement