Advertisement
johnbacon

WooCommerce Wrapping Hook/Function

Apr 15th, 2012
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.12 KB | None | 0 0
  1. <?php
  2.  
  3. // Stop images from becoming wrapped in <p> tags
  4. function filter_ptags_on_images($content){
  5. return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
  6. }
  7. add_filter('the_content', 'filter_ptags_on_images');
  8.  
  9. // Remove WooCommerce if not necessary on page
  10. function remove_unnecessary_woocommerce() {
  11.     if ( !is_woocommerce() ) wp_deregister_script( 'comment-reply' );
  12. }
  13.  
  14.  
  15. // Adjust markup on all WooCommerce pages
  16. remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
  17. remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
  18.  
  19. add_action('woocommerce_before_main_content', 'sanglorians_before_content', 10);
  20. add_action('woocommerce_after_main_content', 'sanglorians_after_content', 10);
  21.  
  22. // Remove mfunc breaking sidebar crap - this is only needed if you're cacheing the sidebar
  23.     function woocommerce_prevent_sidebar_cache( $sidebar ) {
  24.         echo '';
  25.     }
  26.  
  27. // Fix the layout etc
  28. function sanglorians_before_content() {
  29.     ?>
  30.     <!-- #content Starts -->
  31.     <div id="content" class="clearfix">
  32.         <!-- Header -->
  33.         <header class="header">
  34.             <?php get_template_part( 'navigation' ); ?>
  35.         </header>
  36.         <div class="title"><div class="container clearfix"><h2 class="full">Shop</h2></div></div>
  37.         <div class="container clearfix">
  38.         <div class="two_thirds">
  39.   <?php
  40. }
  41. function sanglorians_after_content() {
  42.     ?></div>
  43.     <?php
  44. }
  45.  
  46.     // Override image sizes for frontpage slider */
  47.     add_image_size( 'slideshow_full', 1024, 768, true );
  48.     add_image_size( 'slideshow_custom_thumb', 130, 130, true );
  49.  
  50.     // Removed Google Maps from Subspace functions.php file
  51.     // Currently broken
  52.     function deregister_scripts() {
  53.         wp_deregister_script( 'google-maps' );
  54.         wp_deregister_script( 'jquery-masonry' );
  55.         if ( !is_singular() ) wp_deregister_script( 'comment-reply' );
  56.     }
  57.     add_action('init', 'deregister_scripts');
  58.  
  59.     // Add optimized async Google Analytics to footer
  60.     // mathiasbynens.be/notes/async-analytics-snippet
  61.     function add_google_analytics() {
  62.         echo '<script>var _gaq = [["_setAccount", "UA-15504121-11"], ["_trackPageview"]]; (function(d, t) {var g = d.createElement(t),s = d.getElementsByTagName(t)[0]; g.src = "//www.google-analytics.com/ga.js"; s.parentNode.insertBefore(g, s);}(document, "script")); </script>';
  63.     }
  64.     add_action('wp_footer', 'add_google_analytics');
  65.  
  66.         // Disable WooCommerce styles
  67.         //define('WOOCOMMERCE_USE_CSS', false);
  68.  
  69.         // Disable the theme / plugin text editor in Admin
  70.         define('DISALLOW_FILE_EDIT', true);
  71.  
  72.         // Remove WordPress head junk
  73.         remove_action('wp_head', 'wp_generator');
  74.         remove_action('wp_head', 'rsd_link');
  75.         remove_action('wp_head', 'wlwmanifest_link');
  76.  
  77.         // Temporarily add BugHerd back in
  78.         function add_bugherd() {
  79.             echo "<script type='text/javascript'>(function (d, t) {var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];bh.type = 'text/javascript'; bh.src = '//www.bugherd.com/sidebarv2.js?apikey=1e6094ab-cb08-4f6b-bed7-5bae4301e8a8';s.parentNode.insertBefore(bh, s);})(document, 'script');</script>";
  80.         }
  81.         add_action('wp_footer', 'add_bugherd');
  82.  
  83. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement