Advertisement
Guest User

filz51 - functions.php

a guest
Dec 14th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.23 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. /**
  5. * Optimize WooCommerce Scripts
  6. * Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
  7. */
  8. add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
  9.  
  10. function child_manage_woocommerce_styles() {
  11. //remove generator meta tag
  12. remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
  13.  
  14. //first check that woo exists to prevent fatal errors
  15. if ( function_exists( 'is_woocommerce' ) ) {
  16. //dequeue scripts and styles
  17. if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
  18. wp_dequeue_style( 'woocommerce_frontend_styles' );
  19. wp_dequeue_style( 'woocommerce_fancybox_styles' );
  20. wp_dequeue_style( 'woocommerce_chosen_styles' );
  21. wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
  22. wp_dequeue_script( 'wc_price_slider' );
  23. wp_dequeue_script( 'wc-single-product' );
  24. wp_dequeue_script( 'wc-add-to-cart' );
  25. wp_dequeue_script( 'wc-cart-fragments' );
  26. wp_dequeue_script( 'wc-checkout' );
  27. wp_dequeue_script( 'wc-add-to-cart-variation' );
  28. wp_dequeue_script( 'wc-single-product' );
  29. wp_dequeue_script( 'wc-cart' );
  30. wp_dequeue_script( 'wc-chosen' );
  31. wp_dequeue_script( 'woocommerce' );
  32. wp_dequeue_script( 'prettyPhoto' );
  33. wp_dequeue_script( 'prettyPhoto-init' );
  34. wp_dequeue_script( 'jquery-blockui' );
  35. wp_dequeue_script( 'jquery-placeholder' );
  36. wp_dequeue_script( 'fancybox' );
  37. wp_dequeue_script( 'jqueryui' );
  38. }
  39. }
  40.  
  41. }
  42.  
  43. add_filter('do_not_defer','scripts_to_not_defer');
  44. function scripts_to_not_defer(){
  45. return array('jquery', 'cycle');
  46. }
  47.  
  48.  
  49.  
  50. /* Verhindert das Laden von emoji.js. Von hier: https://wordpress.org/support/topic/emoji-and-smiley-js-and-css-added-to-head
  51. */
  52. remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
  53. remove_action( 'wp_print_styles', 'print_emoji_styles' );
  54.  
  55.  
  56.  
  57. /**
  58. * Diese Funktionen zwingt die Funktion wp_mail (über php Mailer) SMTP zu verwenden.
  59. * von hier: http://www.flippercode.com/send-html-emails-using-wp-mail-wordpress/ (noch nicht eingepflaumt)
  60. * von hier: http://www.butlerblog.com/2011/07/08/changing-the-wp_mail-from-address-in-wordpress-without-a-plugin/
  61. * von hier: http://www.butlerblog.com/2013/12/12/easy-smtp-email-settings-for-wordpress/
  62. **/
  63.  
  64. add_filter( 'wp_mail_from', 'my_mail_from' );
  65. function my_mail_from( $email )
  66. {
  67. return "[email protected]";
  68. }
  69.  
  70. add_filter( 'wp_mail_from_name', 'my_mail_from_name' );
  71. function my_mail_from_name( $name )
  72. {
  73. return "Gleitschirm-Flugschule Magiclift";
  74. }
  75.  
  76.  
  77. /**
  78. * Erzeugt im WooCommerce-Shop ein "Preis auf Anfrage" bei leerem Preisfeld
  79. **/
  80. add_filter('woocommerce_empty_price_html', 'custom_call_for_price');
  81.  
  82. function custom_call_for_price() {
  83. return 'Preis auf Anfrage';
  84. }
  85.  
  86.  
  87. global $avia_config;
  88.  
  89. /**
  90. * Verhindert Probleme zwischen Events Manager und Enfold
  91. * http://www.kriesi.at/support/topic/events-manager/**/
  92.  
  93. $avia_config['g_maps_widget_active'] = 1;
  94.  
  95. $avia_map_prefix = isset($_SERVER['HTTPS'] ) ? "https" : "http";
  96. wp_register_script( 'avia-google-maps-api', $avia_map_prefix.'://maps.google.com/maps/api/js?key=AIzaSyClKhnVf5PihM7M5aCuqeZu4sV3Mx5YuhQ');
  97. wp_enqueue_script( 'avia-google-maps-api' );
  98.  
  99.  
  100. /**
  101. * Dieser Code ermöglicht es, den Ubuntu-Font fürs Frontend auszuwählen
  102. **/
  103. add_filter( 'avf_google_heading_font', 'avia_add_heading_font');
  104. function avia_add_heading_font($fonts)
  105. {
  106. $fonts['Ubuntu'] = 'Ubuntu';
  107. return $fonts;
  108. }
  109.  
  110. add_filter( 'avf_google_content_font', 'avia_add_content_font');
  111. function avia_add_content_font($fonts)
  112. {
  113. $fonts['Ubuntu'] = 'Ubuntu';
  114. return $fonts;
  115. }
  116. add_theme_support('avia_conditionals_for_mega_menu');
  117. add_theme_support('avia_template_builder_custom_css');
  118.  
  119. /**
  120. * Dieser Code ermöglicht eine Fancybox -
  121. * Für Mail-Form auf Produkteseiten
  122. * von hier: http://www.kriesi.at/support/topic/contact-form-in-pop-up-prettyphoto-issue/#post-304173
  123. **/
  124. function popup_inline() { ?>
  125. <script type="text/javascript">
  126. jQuery(window).load(function(){
  127. jQuery('.open-popup-link').magnificPopup({
  128. type:'inline',
  129. midClick: true // Allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source in href.
  130. });
  131. });
  132. </script>
  133. <?php }
  134.  
  135. add_action('wp_head', 'popup_inline');
  136.  
  137. /**
  138. * Dieser Code macht Social Icons auf Produktseiten sichtbar
  139. * von hier: http://www.kriesi.at/support/topic/social-buttons-on-woocommerce-product-pages/
  140. **/
  141. add_action('woocommerce_after_single_product_summary', 'avia_add_social_toolbar', 10, 2);
  142. function avia_add_social_toolbar($id = "", $context = "")
  143. {
  144. avia_social_share_links();
  145. }
  146.  
  147. /**
  148. * Dieser Code ermöglicht eine Anpassung im Webshop für Enfold -
  149. * von hier: http://www.kriesi.at/documentation/enfold/custom-woocommerce-shop-overview/
  150. **/
  151. add_theme_support( 'avia_custom_shop_page' );
  152.  
  153.  
  154. /**
  155. * Dieser Code ermöglicht Links in Images mit Hotspots -
  156. * von hier: http://www.kriesi.at/documentation/enfold/custom-woocommerce-shop-overview/
  157. **/
  158.  
  159. add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
  160. function avia_include_shortcode_template($paths)
  161. {
  162. $template_url = get_stylesheet_directory();
  163. array_unshift($paths, $template_url.'/shortcodes/');
  164. return $paths;
  165. }
  166.  
  167.  
  168.  
  169. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement