Advertisement
cipher87

PMPro Enfold Menu

Feb 6th, 2018
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.99 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * Add your own functions here. You can also copy some of the theme functions into this file.
  5. * Wordpress will use those functions instead of the original functions then.
  6. */
  7.  
  8. function wc_remove_checkout_field( $fields ) {
  9.     unset( $fields['billing']['billing_company'] );
  10.     unset($fields['billing']['billing_address_1']);
  11.     unset($fields['billing']['billing_address_2']);
  12.     unset($fields['billing']['billing_state']);
  13.     unset($fields['billing']['billing_city']);
  14.     unset($fields['billing']['billing_postcode']);
  15.     unset($fields['billing']['billing_phone']);
  16.     unset($fields['order']['order_comments']);
  17.  
  18.     return $fields;
  19. }
  20. add_filter( 'woocommerce_checkout_fields' , 'wc_remove_checkout_field' );
  21.  
  22. // Content Views Pro - Change the "No posts found." message
  23. add_filter( 'pt_cv_content_no_post_found_text', 'cvp_theme_no_post_found_text', 100, 1 );
  24. function cvp_theme_no_post_found_text( $args ) {
  25.     $args = '';
  26.    
  27.     return $args;
  28. }
  29.  
  30.  
  31. function hide_discount_code_field_for_free_levels($show)
  32. {
  33.   global $pmpro_level;
  34.  
  35.   if(function_exists('pmpro_isLevelFree') && pmpro_isLevelFree($pmpro_level))
  36.     $show = false;
  37.  
  38.   return $show;
  39. }
  40. add_filter('pmpro_show_discount_code', 'hide_discount_code_field_for_free_levels');
  41.  
  42.  
  43. function hide_discount_code_field_for_specific_levels($show)
  44. {
  45.   global $pmpro_level;
  46.  
  47.   if( in_array( $pmpro_level->id, array(1,2,3,5,15,17,18,19,20) ) )
  48.   {
  49.       $show = false;
  50.   }
  51.   return $show;
  52. }
  53. add_filter('pmpro_show_discount_code', 'hide_discount_code_field_for_specific_levels');
  54.  
  55.  
  56. /*
  57.     Global to store levels with non-default currencies
  58.     Keys are level ids. Values are an asrray with the currency abbreviation and symbol as the first and second entries.
  59. */
  60.  
  61. global $level_currencies;
  62. $level_currencies = array(
  63.         18 => array("EUR", "&euro;"),
  64.         19 => array("EUR", "&euro;"),
  65.         20 => array("EUR", "&euro;")
  66.     );
  67.  
  68. //main function to check for a currency level and update currencies
  69. function update_currency_per_level($level_id)
  70. {
  71.     global $pmpro_currency, $pmpro_currency_symbol, $level_currencies;
  72.  
  73.     foreach($level_currencies as $level_currency_id => $level_currency)
  74.     {
  75.         if($level_id == $level_currency_id)
  76.         {
  77.             $pmpro_currency = $level_currency[0];
  78.             $pmpro_currency_symbol = $level_currency[1];
  79.         }
  80.     }
  81. }
  82.  
  83. //change currency on checkout page
  84. function my_pmpro_checkout_level($level)
  85. {
  86.     update_currency_per_level($level->id);
  87.  
  88.     return $level;
  89. }
  90. add_filter("pmpro_checkout_level", "my_pmpro_checkout_level");
  91.  
  92. //change currency when sent as a request param
  93. function my_init_currency_check()
  94. {
  95.     if(!empty($_REQUEST['level']))
  96.         return update_currency_per_level(intval($_REQUEST['level']));
  97. }
  98. add_action("init", "my_init_currency_check");
  99.  
  100. //params in the admin
  101. function my_admin_init_currency_check()
  102. {
  103.     if(!empty($_REQUEST['edit']) && !empty($_REQUEST['page']) && $_REQUEST['page'] == 'pmpro-membershiplevels')
  104.         return update_currency_per_level(intval($_REQUEST['edit']));
  105. }
  106. add_action("admin_init", "my_admin_init_currency_check");
  107.  
  108. add_filter( 'wp_nav_menu_items', 'avia_append_search_nav', 9997, 2 );
  109. add_filter( 'avf_fallback_menu_items', 'avia_append_search_nav', 9997, 2 );
  110. function avia_append_search_nav ( $items, $args )
  111. {  
  112.     if(avia_get_option('header_searchicon','header_searchicon') != "header_searchicon") return $items;
  113.     if(avia_get_option('header_position',  'header_top') != "header_top") return $items;
  114.  
  115.         if ((is_object($args) && !strstr($args->theme_location, 'avia2') && !strstr($args->theme_location, 'avia3')) || (is_string($args) && $args = "fallback_menu"))
  116.       {
  117.             global $avia_config;
  118.             ob_start();
  119.             get_search_form();
  120.             $form =  htmlspecialchars(ob_get_clean()) ;
  121.  
  122.             $items .= '<li id="menu-item-search" class="noMobile menu-item menu-item-search-dropdown menu-item-avia-special">
  123.                     <a href="?s=" data-avia-search-tooltip="'.$form.'" '.av_icon_string('search').'><span class="avia_hidden_link_text">'.__('Search','avia_framework').'</span></a>
  124.                          </li>';
  125.         }
  126.    
  127.         return $items;
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement