Advertisement
Guest User

config.php

a guest
May 5th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 55.26 KB | None | 0 0
  1. <?php
  2.  
  3. function avia_woocommerce_enabled()
  4. {
  5.     // if( !function_exists( 'wc_get_template_part' ) && class_exists( 'woocommerce' )) return "deprecated";
  6.     if ( class_exists( 'woocommerce' ) ){ return true; }
  7.     return false;
  8. }
  9.  
  10. global $avia_config;
  11.  
  12. //product thumbnails
  13. $avia_config['imgSize']['shop_thumbnail']   = array('width'=>120, 'height'=>120);
  14. $avia_config['imgSize']['shop_catalog']     = array('width'=>450, 'height'=>450);
  15. $avia_config['imgSize']['shop_single']      = array('width'=>450, 'height'=>999, 'crop' => false);
  16.  
  17. avia_backend_add_thumbnail_size($avia_config);
  18.  
  19. include('admin-options.php');
  20. include('admin-import.php');
  21. include( 'woocommerce-mod-css-dynamic.php');
  22.  
  23. add_theme_support( 'woocommerce' );
  24.  
  25.  
  26. function av_add_deprecated_notice()
  27. {
  28.     echo '<div class="notice notice-error">';
  29.     echo    '<p>' .  __('Attention! Please update WooCommerce to the latest version to properly display your products', 'avia_framework') . '</p>';
  30.     echo '</div>';
  31. }
  32.  
  33.  
  34.  
  35. //check if the plugin is enabled, otherwise stop the script
  36. if(avia_woocommerce_enabled() !== true) {
  37.  
  38.     if(avia_woocommerce_enabled() == "deprecated")
  39.     {
  40.         add_action('admin_notices', 'av_add_deprecated_notice');
  41.     }
  42.  
  43.     return false;
  44. }
  45.  
  46.  
  47. function avia_woocommerce_version_check( $version  )
  48. {
  49.     global $woocommerce;
  50.     if( version_compare( $woocommerce->version, $version, ">=" ) ) {
  51.         return true;
  52.     }
  53.  
  54.     return false;
  55. }
  56.  
  57.  
  58.  
  59. //register my own styles, remove wootheme stylesheet
  60. if(!is_admin()){
  61.     add_action('init', 'avia_woocommerce_register_assets');
  62. }
  63.  
  64.  
  65.  
  66. function avia_woocommerce_register_assets()
  67. {
  68.     wp_enqueue_style( 'avia-woocommerce-css', AVIA_BASE_URL.'config-woocommerce/woocommerce-mod.css');
  69.     if( version_compare( WC()->version, '2.7.0', '<' ) )
  70.     {
  71.         wp_enqueue_script( 'avia-woocommerce-js', AVIA_BASE_URL.'config-woocommerce/woocommerce-mod-v26.js', array('jquery'), 1, true);
  72.     }
  73.     else
  74.     {
  75.         wp_enqueue_script( 'avia-woocommerce-js', AVIA_BASE_URL.'config-woocommerce/woocommerce-mod.js', array('jquery'), 1, true);
  76.     }
  77.  
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84. global $woocommerce;
  85.  
  86. if(version_compare($woocommerce->version, "2.1", "<"))
  87. {
  88.     define('WOOCOMMERCE_USE_CSS', false);
  89. }
  90. else
  91. {
  92.     add_filter( 'woocommerce_enqueue_styles', 'avia_woocommerce_enqueue_styles' );
  93.     function avia_woocommerce_enqueue_styles($styles)
  94.     {
  95.         $styles = array();
  96.         return $styles;
  97.     }
  98. }
  99.  
  100.  
  101. if ( class_exists( 'WC_Bookings' ) )
  102. {
  103.     require_once( 'config-woocommerce-bookings/config.php' ); //compatibility with woocommerce plugin
  104. }
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113. ######################################################################
  114. # config
  115. ######################################################################
  116.  
  117. //add avia_framework config defaults
  118.  
  119. $avia_config['shop_overview_column']  = get_option('avia_woocommerce_column_count');  // columns for the overview page
  120. $avia_config['shop_overview_products']= get_option('avia_woocommerce_product_count'); // products for the overview page
  121.  
  122. $avia_config['shop_single_column']       = 4;           // columns for related products and upsells
  123. $avia_config['shop_single_column_items'] = 4;   // number of items for related products and upsells
  124. $avia_config['shop_overview_excerpt'] = false;      // display excerpt
  125.  
  126. if(!$avia_config['shop_overview_column']) $avia_config['shop_overview_column'] = 3;
  127.  
  128.  
  129. ######################################################################
  130. # Create the correct template html structure
  131. ######################################################################
  132.  
  133. //remove woo defaults
  134. remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10);
  135. remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
  136. remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
  137. remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
  138. remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
  139. remove_action( 'woocommerce_pagination', 'woocommerce_catalog_ordering', 20 );
  140. remove_action( 'woocommerce_pagination', 'woocommerce_pagination', 10 );
  141. remove_action( 'woocommerce_before_single_product', array($woocommerce, 'show_messages'), 10);
  142.  
  143.  
  144.  
  145. //add theme actions && filter
  146. add_action( 'woocommerce_after_shop_loop_item_title', 'avia_woocommerce_overview_excerpt', 10);
  147. add_filter( 'loop_shop_columns', 'avia_woocommerce_loop_columns');
  148. add_filter( 'loop_shop_per_page', 'avia_woocommerce_product_count' );
  149.  
  150. //single page adds
  151. add_action( 'avia_add_to_cart', 'woocommerce_template_single_add_to_cart', 30, 2 );
  152.  
  153.  
  154.  
  155. /*update woocommerce v2*/
  156.  
  157. remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); /*remove result count above products*/
  158. remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); /*remove woocommerce ordering dropdown*/
  159. remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 ); //remove rating
  160. remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 ); //remove woo pagination
  161.  
  162.  
  163. ######################################################################
  164. # FUNCTIONS
  165. ######################################################################
  166.  
  167. #
  168. # set the shop page id, otherwise avia_get_the_ID() can return a wrong id on the shop page
  169. #
  170. add_filter('avf_avia_get_the_ID','avia_set_shop_page_id', 10, 1);
  171. function avia_set_shop_page_id($id)
  172. {
  173.     if(is_shop()) $id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' );
  174.     return $id;
  175. }
  176.  
  177. #
  178. # removes the default post image from shop overview pages and replaces it with this image
  179. #
  180. add_action( 'woocommerce_before_shop_loop_item_title', 'avia_woocommerce_thumbnail', 10);
  181. remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
  182.  
  183.  
  184.  
  185.  
  186. function avia_woocommerce_thumbnail($asdf)
  187. {
  188.     global $product, $avia_config;
  189.  
  190.     if(function_exists('wc_get_rating_html'))
  191.     {
  192.         $rating = wc_get_rating_html(  $product->get_average_rating() );
  193.     }
  194.     else
  195.     {
  196.         $rating = $product->get_rating_html(); //get rating
  197.     }
  198.  
  199.     $id = get_the_ID();
  200.     $size = 'shop_catalog';
  201.  
  202.     echo "<div class='thumbnail_container'>";
  203.         echo avia_woocommerce_gallery_first_thumbnail( $id , $size);
  204.         echo get_the_post_thumbnail( $id , $size );
  205.         if(!empty($rating)) echo "<span class='rating_container'>".$rating."</span>";
  206.         if($product->get_type() == 'simple') echo "<span class='cart-loading'></span>";
  207.     echo "</div>";
  208. }
  209.  
  210.  
  211. function avia_woocommerce_gallery_first_thumbnail($id, $size, $id_only = false)
  212. {
  213.     $active_hover = get_post_meta( $id, '_product_hover', true );
  214.  
  215.     if(!empty($active_hover))
  216.     {
  217.         $product_gallery = get_post_meta( $id, '_product_image_gallery', true );
  218.  
  219.         if(!empty($product_gallery))
  220.         {
  221.             $gallery    = explode(',',$product_gallery);
  222.             $image_id   = $gallery[0];
  223.  
  224.             //return id only
  225.             if(!empty($id_only)) return $image_id;
  226.  
  227.             $image      = wp_get_attachment_image( $image_id, $size, false, array( 'class' => "attachment-$size avia-product-hover" ));
  228.  
  229.             //return image
  230.             if(!empty($image)) return $image;
  231.         }
  232.     }
  233. }
  234.  
  235.  
  236.  
  237.  
  238. #
  239. # add ajax cart / options buttons to the product
  240. #
  241.  
  242. add_action( 'woocommerce_after_shop_loop_item', 'avia_add_cart_button', 16);
  243. function avia_add_cart_button()
  244. {
  245.     global $product, $avia_config;
  246.  
  247.     if ($product->get_type() == 'bundle' ){
  248.         $product = new WC_Product_Bundle($product->get_id());
  249.     }
  250.  
  251.     $extraClass  = "";
  252.  
  253.     ob_start();
  254.     woocommerce_template_loop_add_to_cart();
  255.     $output = ob_get_clean();
  256.  
  257.     if(!empty($output))
  258.     {
  259.         $pos = strpos($output, ">");
  260.  
  261.         if ($pos !== false) {
  262.             $output = substr_replace($output,"><span ".av_icon_string('cart')."></span> ", $pos , strlen(1));
  263.         }
  264.     }
  265.  
  266.  
  267.     if($product->get_type() == 'variable' && empty($output))
  268.     {
  269.         $output = '<a class="add_to_cart_button button product_type_variable" href="'.get_permalink($product->get_id()).'"><span '.av_icon_string("details").'></span> '.__("Select options","avia_framework").'</a>';
  270.     }
  271.  
  272.     if(in_array($product->get_type(), array('subscription', 'simple', 'bundle')))
  273.     {
  274.         $output .= '<a class="button show_details_button" href="'.get_permalink($product->get_id()).'"><span '.av_icon_string("details").'></span>  '.__("Show Details","avia_framework").'</a>';
  275.     }
  276.     else
  277.     {
  278.         $extraClass  = "single_button";
  279.     }
  280.  
  281.     if(empty($extraClass)) $output .= " <span class='button-mini-delimiter'></span>";
  282.  
  283.  
  284.     if($output && !post_password_required() && '' == avia_get_option('product_layout',''))
  285.     {
  286.         echo "<div class='avia_cart_buttons $extraClass'>$output</div>";
  287.     }
  288. }
  289.  
  290.  
  291.  
  292.  
  293.  
  294. #
  295. # wrap products on overview pages into an extra div for improved styling options. adds "product_on_sale" class if prodct is on sale
  296. #
  297.  
  298. add_action( 'woocommerce_before_shop_loop_item', 'avia_shop_overview_extra_div', 5);
  299. function avia_shop_overview_extra_div()
  300. {
  301.     global $product;
  302.     $product_class = $product->is_on_sale() ? "product_on_sale" : "";
  303.     $product_class.= " av-product-class-".avia_get_option('product_layout');
  304.  
  305.     echo "<div class='inner_product main_color wrapped_style noLightbox $product_class'>";
  306. }
  307.  
  308. add_action( 'woocommerce_after_shop_loop_item',  'avia_close_div', 1000);
  309. function avia_close_div()
  310. {
  311.     echo "</div>";
  312. }
  313.  
  314.  
  315. #
  316. # wrap product titles and sale number on overview pages into an extra div for improved styling options
  317. #
  318.  
  319. add_action( 'woocommerce_before_shop_loop_item_title', 'avia_shop_overview_extra_header_div', 20);
  320. function avia_shop_overview_extra_header_div()
  321. {
  322.     echo "<div class='inner_product_header'><div class='avia-arrow'></div>";
  323.     echo    "<div class='inner_product_header_table'>";
  324.     echo        "<div class='inner_product_header_cell'>";
  325. }
  326.  
  327. add_action( 'woocommerce_after_shop_loop_item_title',  'avia_close_div', 1000);
  328. add_action( 'woocommerce_after_shop_loop_item_title',  'avia_close_div', 1001);
  329. add_action( 'woocommerce_after_shop_loop_item_title',  'avia_close_div', 1002);
  330.  
  331.  
  332. #
  333. # remove on sale badge from usual location and add it to the bottom of the product
  334. #
  335. remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10);
  336. add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10);
  337.  
  338.  
  339. #
  340. # create the shop navigation with account links, as well as cart and checkout, called as fallback function by the wp_nav_menu function in header.php
  341. #
  342. function avia_shop_nav($args)
  343. {
  344.     $output = "";
  345.     $url = avia_collect_shop_urls();
  346.  
  347.     $output .= "<ul>";
  348.  
  349.     if( is_user_logged_in() )
  350.     {
  351.         $current = $sub1 = $sub2 = $sub3 = "";
  352.         if(is_account_page()) $current = "current-menu-item";
  353.         if(is_page(get_option('woocommerce_change_password_page_id'))) $sub1 = "current-menu-item";
  354.         if(is_page(get_option('woocommerce_edit_address_page_id'))) $sub2 = "current-menu-item";
  355.         if(is_page(get_option('woocommerce_view_order_page_id'))) $sub3 = "current-menu-item";
  356.  
  357.  
  358.         $output .= "<li class='$current account_overview_link'><a href='".$url['account_overview']."'>".__('My Account', 'avia_framework')."</a>";
  359.             $output .= "<ul>";
  360.             $output .= "<li class='$sub1 account_change_pw_link'><a href='".$url['account_change_pw']."'>".__('Change Password', 'avia_framework')."</a></li>";
  361.             $output .= "<li class='$sub2 account_edit_adress_link'><a href='".$url['account_edit_adress']."'>".__('Edit Address', 'avia_framework')."</a></li>";
  362.             $output .= "<li class='$sub3 account_view_order_link'><a href='".$url['account_view_order']."'>".__('View Order', 'avia_framework')."</a></li>";
  363.             $output .= "</ul>";
  364.         $output .= "</li>";
  365.         $output .= "<li class='account_logout_link'><a href='".$url['logout']."'>".__('Log Out', 'avia_framework')."</a></li>";
  366.     }
  367.     else
  368.     {
  369.         $sub1 = $sub2 = "";
  370.         if(is_page(get_option('woocommerce_myaccount_page_id')))
  371.         {
  372.             if(isset($_GET['account_visible']) && $_GET['account_visible'] == 'register') $sub1 = "current-menu-item";
  373.             if(isset($_GET['account_visible']) && $_GET['account_visible'] == 'login') $sub2 = "current-menu-item";
  374.         }
  375.  
  376.         $url_param = strpos($url['account_overview'], '?') === false ? "?" : "&";
  377.  
  378.         if (get_option('woocommerce_enable_myaccount_registration') =='yes')
  379.         {
  380.             $output .= "<li class='register_link $sub1'><a href='".$url['account_overview'].$url_param."account_visible=register'>".__('Register', 'avia_framework')."</a></li>";
  381.         }
  382.  
  383.         $output .= "<li class='login_link $sub2'><a href='".$url['account_overview'].$url_param."account_visible=login'>".__('Log In', 'avia_framework')."</a></li>";
  384.     }
  385.  
  386.     $output .= "</ul>";
  387.  
  388.     if($args['echo'] == true)
  389.     {
  390.         echo $output;
  391.     }
  392.     else
  393.     {
  394.         return $output;
  395.     }
  396. }
  397.  
  398.  
  399. #
  400. # helper function that collects all the necessary urls for the shop navigation
  401. #
  402.  
  403. function avia_collect_shop_urls()
  404. {
  405.     global $woocommerce;
  406.  
  407.     $url['cart']                = $woocommerce->cart->get_cart_url();
  408.     $url['checkout']            = $woocommerce->cart->get_checkout_url();
  409.     $url['account_overview']    = get_permalink(get_option('woocommerce_myaccount_page_id'));
  410.     $url['account_edit_adress'] = get_permalink(get_option('woocommerce_edit_address_page_id'));
  411.     $url['account_view_order']  = get_permalink(get_option('woocommerce_view_order_page_id'));
  412.     $url['account_change_pw']   = get_permalink(get_option('woocommerce_change_password_page_id'));
  413.     $url['logout']              = wp_logout_url(home_url('/'));
  414.  
  415.     return $url;
  416. }
  417.  
  418.  
  419.  
  420.  
  421. #
  422. # check which page is displayed and if the automatic sidebar menu for subpages should be prevented
  423. #
  424. add_filter( 'avf_sidebar_menu_filter', 'avia_woocommerce_sidebar_filter');
  425.  
  426. function avia_woocommerce_sidebar_filter($menu)
  427. {
  428.     $id = avia_get_the_ID();
  429.     if(is_cart() || is_checkout() || get_option('woocommerce_thanks_page_id') == $id){$menu = "";}
  430.     return $menu;
  431. }
  432.  
  433.  
  434. #
  435. # check if a single product is displayed and always set the sidebar styling to that of a right sidebar
  436. #
  437. add_filter( 'avf_sidebar_position', 'avia_woocommerce_sidebar_pos');
  438.  
  439. function avia_woocommerce_sidebar_pos($sidebar)
  440. {
  441.     if(is_product())
  442.     {
  443.         $sidebar = "sidebar_right";
  444.     }
  445.  
  446.     return $sidebar;
  447. }
  448.  
  449.  
  450.  
  451. function avia_add_to_cart($post, $product )
  452. {
  453.     echo "<div class='avia_cart avia_cart_".$product->get_type()."'>";
  454.     do_action( 'avia_add_to_cart', $post, $product );
  455.     echo "</div>";
  456. }
  457.  
  458.  
  459.  
  460. #
  461. # replace thumbnail image size with full size image on single pages
  462. #
  463. /*
  464.  
  465. add_filter( 'single_product_small_thumbnail_size', 'avia_woocommerce_thumb_size');
  466.  
  467. function avia_woocommerce_thumb_size()
  468. {
  469.     return 'shop_single';
  470. }
  471. */
  472.  
  473.  
  474.  
  475.  
  476. #
  477. # if we are viewing a woocommerce page modify the breadcrumb nav
  478. #
  479.  
  480. if(!function_exists('avia_woocommerce_breadcrumb'))
  481. {
  482.     add_filter('avia_breadcrumbs_trail','avia_woocommerce_breadcrumb');
  483.  
  484.     function avia_woocommerce_breadcrumb($trail)
  485.     {
  486.         global $avia_config;
  487.  
  488.         if(is_woocommerce())
  489.         {
  490.  
  491.             $home       = $trail[0];
  492.             $last       = array_pop($trail);
  493.             $shop_id    = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' );
  494.             $taxonomy   = "product_cat";
  495.  
  496.             // on the shop frontpage simply display the shop name, rather than shop name + "All Products"
  497.             if(is_shop())
  498.             {
  499.                 if(!empty($shop_id) && $shop_id  != -1)  $trail = array_merge( $trail, avia_breadcrumbs_get_parents( $shop_id ) );
  500.                 $last = "";
  501.  
  502.                 if(is_search())
  503.                 {
  504.                     $last = __('Search results for:','avia_framework').' '.esc_attr($_GET['s']);
  505.                 }
  506.             }
  507.  
  508.             // on the product page single page modify the breadcrumb to read [home] [if available:parent shop pages] [shop] [if available:parent categories] [category] [title]
  509.             if(is_product())
  510.             {
  511.                 //fetch all product categories and search for the ones with parents. if none are avalaible use the first category found
  512.                 $product_category = $parent_cat = array();
  513.                 $temp_cats = get_the_terms(get_the_ID(), $taxonomy);
  514.  
  515.                 if(!empty($temp_cats))
  516.                 {
  517.                     foreach($temp_cats as $key => $cat)
  518.                     {
  519.                         if($cat->parent != 0 && !in_array($cat->term_taxonomy_id, $parent_cat))
  520.                         {
  521.                             $product_category[] = $cat;
  522.                             $parent_cat[] = $cat->parent;
  523.                         }
  524.                     }
  525.  
  526.                     //if no categories with parents use the first one
  527.                     if(empty($product_category)) $product_category[] = reset($temp_cats);
  528.  
  529.                 }
  530.                 //unset the trail and build our own
  531.                 unset($trail);
  532.  
  533.                 $trail[0] = $home;
  534.                 if(!empty($shop_id) && $shop_id  != -1)    $trail = array_merge( $trail, avia_breadcrumbs_get_parents( $shop_id ) );
  535.                 if(!empty($parent_cat)) $trail = array_merge( $trail, avia_breadcrumbs_get_term_parents( $parent_cat[0] , $taxonomy ) );
  536.                 if(!empty($product_category)) $trail[] = '<a href="' . get_term_link( $product_category[0]->slug, $taxonomy ) . '" title="' . esc_attr( $product_category[0]->name ) . '">' . $product_category[0]->name . '</a>';
  537.  
  538.             }
  539.  
  540.  
  541.             // add the [shop] trail to category/tag pages: [home] [if available:parent shop pages] [shop] [if available:parent categories] [category/tag]
  542.             if(is_product_category() || is_product_tag())
  543.             {
  544.                 if(!empty($shop_id) && $shop_id  != -1)
  545.                 {
  546.                     $shop_trail = avia_breadcrumbs_get_parents( $shop_id ) ;
  547.                     array_splice($trail, 1, 0, $shop_trail);
  548.                 }
  549.             }
  550.  
  551.             if(is_product_tag())
  552.             {
  553.                 $last = __("Tag",'avia_framework').": ".$last;
  554.             }
  555.  
  556.  
  557.             if(!empty($last)) $trail[] = $last;
  558.         }
  559.  
  560.         return $trail;
  561.     }
  562.  
  563. }
  564.  
  565.  
  566.  
  567. #
  568. # creates the avia framework container arround the shop pages
  569. #
  570. add_action( 'woocommerce_before_main_content', 'avia_woocommerce_before_main_content', 10);
  571.  
  572.  
  573. function avia_woocommerce_before_main_content()
  574. {
  575.     global $avia_config;
  576.  
  577.     if(!isset($avia_config['shop_overview_column'])) $avia_config['shop_overview_column'] = "auto";
  578.  
  579.     $id = get_option('woocommerce_shop_page_id');
  580.     $layout = get_post_meta($id, 'layout', true);
  581.  
  582.     if(!empty($layout))
  583.     {
  584.             $avia_config['layout']['current'] = $avia_config['layout'][$layout];
  585.             $avia_config['layout']['current']['main'] = $layout;
  586.     }
  587.  
  588.         $avia_config['layout'] = apply_filters('avia_layout_filter', $avia_config['layout'], $id);
  589.  
  590.     $title_args = array();
  591.  
  592.     if(is_woocommerce())
  593.     {
  594.         $t_link = "";
  595.  
  596.         if(is_shop()) $title  = get_option('woocommerce_shop_page_title');
  597.  
  598.         $shop_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' );
  599.         if($shop_id && $shop_id != -1)
  600.         {
  601.             if(empty($title)) $title = get_the_title($shop_id);
  602.             $t_link = get_permalink($shop_id);
  603.         }
  604.  
  605.         if(empty($title)) $title  = __("Shop",'avia_framework');
  606.  
  607.         if(is_product_category() || is_product_tag())
  608.         {
  609.             global $wp_query;
  610.             $tax = $wp_query->get_queried_object();
  611.             $title = $tax->name;
  612.             $t_link = '';
  613.         }
  614.  
  615.         $title_args = array('title' => $title, 'link' => $t_link);
  616.     }
  617.  
  618.     if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title($title_args);
  619.  
  620.  
  621.     if(is_singular()) {
  622.  
  623.         $result = 'sidebar_right';
  624.         $avia_config['layout']['current'] = $avia_config['layout'][$result];
  625.         $avia_config['layout']['current']['main'] = $result;
  626.  
  627.     }
  628.     $sidebar_setting = avia_layout_class( 'main' , false );
  629.     echo "<div class='container_wrap container_wrap_first main_color {$sidebar_setting} template-shop shop_columns_".$avia_config['shop_overview_column']."'>";
  630.  
  631.         echo "<div class='container'>";
  632.  
  633.         if(!is_singular()) { $avia_config['overview'] = true; }
  634. }
  635.  
  636. #
  637. # closes the avia framework container arround the shop pages
  638. #
  639.  
  640. add_action( 'woocommerce_after_main_content', 'avia_woocommerce_after_main_content', 10);
  641. function avia_woocommerce_after_main_content()
  642. {
  643.  
  644.     global $avia_config;
  645.     $avia_config['currently_viewing'] = "shop";
  646.  
  647.             //reset all previous queries
  648.             wp_reset_query();
  649.  
  650.             //get the sidebar
  651.             if(!is_singular())
  652.             get_sidebar();
  653.  
  654.     //  echo "</div>"; // end container - gets already closed at the top of footer.php
  655.  
  656.         echo "</div>"; // end tempate-shop content
  657.         echo "</div>"; // close default .container_wrap element
  658. }
  659.  
  660.  
  661. add_action( 'avf_custom_sidebar', 'avia_woocommerce_custom_sidebar', 10);
  662. function avia_woocommerce_custom_sidebar($sidebar)
  663. {
  664.     if(is_shop())
  665.     {
  666.         $the_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' );
  667.         $sidebar = get_post_meta($the_id, 'sidebar', true);
  668.     }
  669.  
  670.     return $sidebar;
  671. }
  672.  
  673.  
  674.  
  675.  
  676. #
  677. # wrap an empty product search into extra div
  678. #
  679. add_action( 'woocommerce_before_main_content', 'avia_woocommerce_404_search', 9111);
  680. function avia_woocommerce_404_search()
  681. {
  682.     global $wp_query;
  683.  
  684.     if( (is_search() || is_archive()) && empty($wp_query->found_posts) )
  685.     {
  686.         echo "<div class='template-page template-search template-search-none content ".avia_layout_class( 'content', false )." units'>";
  687.         echo "<div class='entry entry-content-wrapper' id='search-fail'>";
  688.     }
  689. }
  690.  
  691. add_action( 'woocommerce_after_main_content', 'avia_woocommerce_404_search_close', 1);
  692. function avia_woocommerce_404_search_close()
  693. {
  694.     global $wp_query;
  695.  
  696.     if( (is_search() || is_shop() || is_archive()) && empty($wp_query->found_posts) )
  697.     {
  698.         get_template_part('includes/error404');
  699.         echo "</div>";
  700.         echo "</div>"; // close default .container_wrap element
  701.     }
  702. }
  703.  
  704.  
  705.  
  706.  
  707. #
  708. # modifies the class of a page so we can display single login and single register
  709. #
  710. add_filter( 'avia_layout_class_filter_main', 'avia_register_login_class');
  711.  
  712. function avia_register_login_class($layout)
  713. {
  714.     if(isset($_GET['account_visible']))
  715.     {
  716.         if($_GET['account_visible'] == 'register') $layout .= " template-register";
  717.         if($_GET['account_visible'] == 'login') $layout .= " template-login";
  718.     }
  719.  
  720.     return $layout;
  721. }
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729. #
  730. # creates the avia framework content container arround the shop loop
  731. #
  732. add_action( 'woocommerce_before_shop_loop', 'avia_woocommerce_before_shop_loop', 1);
  733.  
  734. function avia_woocommerce_before_shop_loop()
  735. {
  736.  
  737.     global $avia_config;
  738.     if(isset($avia_config['dynamic_template'])) return;
  739.     $markup = avia_markup_helper(array('context' => 'content','echo'=>false,'post_type'=>'products'));
  740.     echo "<main class='template-shop content ".avia_layout_class( 'content' , false)." units' $markup><div class='entry-content-wrapper'>";
  741. }
  742.  
  743. #
  744. # closes the avia framework content container arround the shop loop
  745. #
  746. add_action( 'woocommerce_after_shop_loop', 'avia_woocommerce_after_shop_loop', 10);
  747.  
  748. function avia_woocommerce_after_shop_loop()
  749. {
  750.             global $avia_config;
  751.             if(isset($avia_config['dynamic_template'])) return;
  752.             if(isset($avia_config['overview'] )) echo avia_pagination('', 'nav');
  753.             echo "</div></main>"; //end content
  754. }
  755.  
  756.  
  757.  
  758. #
  759. # echo the excerpt
  760. #
  761. function avia_woocommerce_overview_excerpt()
  762. {
  763.     global $avia_config;
  764.  
  765.     if(!empty($avia_config['shop_overview_excerpt']))
  766.     {
  767.         echo "<div class='product_excerpt'>";
  768.         the_excerpt();
  769.         echo "</div>";
  770.     }
  771. }
  772.  
  773.  
  774.  
  775. #
  776. # creates the preview images based on page/category image
  777. #
  778. remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
  779. remove_action( 'woocommerce_product_archive_description', 'woocommerce_product_archive_description', 10 );
  780.  
  781. add_action( 'woocommerce_before_shop_loop', 'avia_woocommerce_overview_banner_image', 10);
  782. add_action( 'woocommerce_before_shop_loop', 'woocommerce_taxonomy_archive_description', 11 );
  783. //add_action( 'woocommerce_before_shop_loop', 'woocommerce_product_archive_description', 12 ); //causes warning
  784.  
  785.  
  786. function avia_woocommerce_overview_banner_image()
  787. {
  788.     global $avia_config;
  789.     if(avia_is_dynamic_template() || is_paged() || is_search() ) return false;
  790.  
  791.     $image_size = "entry_with_sidebar";
  792.     $layout = avia_layout_class( 'main' , false );
  793.     if($layout == 'fullsize') $image_size = 'entry_without_sidebar';
  794.  
  795.     if(is_shop())
  796.     {
  797.         $shop_id = function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' );
  798.         if($shop_id != -1)
  799.         {
  800.             $image = get_the_post_thumbnail($shop_id, $image_size);
  801.             if($image) echo "<div class='page-thumb'>{$image}</div>";
  802.         }
  803.     }
  804.  
  805.  
  806.  
  807.     if(is_product_category())
  808.     {
  809.         global $wp_query;
  810.         $image  = "";
  811.         if(isset($wp_query->query_vars['taxonomy']))
  812.         {
  813.             $term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']);
  814.  
  815.             if(!empty($term->term_id))
  816.             {
  817.                 $attachment_id  = get_woocommerce_term_meta($term->term_id, 'thumbnail_id');
  818.                 $style          = get_woocommerce_term_meta($term->term_id, 'av_cat_styling');
  819.  
  820.                 if(!empty($attachment_id) && empty($style))
  821.                 {
  822.                     $image = wp_get_attachment_image( $attachment_id, $image_size, false, array('class'=>'category_thumb'));
  823.                     if($image) echo "<div class='page-thumb'>{$image}</div>";
  824.                 }
  825.  
  826.             }
  827.         }
  828.     }
  829.  
  830. }
  831.  
  832.  
  833.  
  834. add_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner', 11 );
  835.  
  836.  
  837. function avia_woocommerce_big_cat_banner()
  838. {
  839.     if(is_product_category())
  840.     {
  841.         global $wp_query, $avia_config;
  842.  
  843.         if(isset($wp_query->query_vars['taxonomy']))
  844.         {
  845.             $term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']);
  846.             if(!empty($term->term_id))
  847.             {
  848.                 $description    = term_description() ;
  849.                 $style          = get_woocommerce_term_meta($term->term_id, 'av_cat_styling');
  850.                 $attachment_id  = get_woocommerce_term_meta($term->term_id, 'thumbnail_id');
  851.  
  852.                 $overlay    = get_woocommerce_term_meta($term->term_id, 'av-banner-overlay');
  853.                 $font       = get_woocommerce_term_meta($term->term_id, 'av-banner-font');
  854.                 $opacity    = get_woocommerce_term_meta($term->term_id, 'av-banner-overlay-opacity');
  855.  
  856.                 if(!empty($style))
  857.                 {
  858.                     remove_action( 'woocommerce_before_shop_loop', 'woocommerce_taxonomy_archive_description', 11 );
  859.                     echo avia_woocommerce_parallax_banner($attachment_id, $overlay, $opacity, $description, $font);
  860.                     $avia_config['woo-banner'] = true;
  861.                 }
  862.             }
  863.         }
  864.     }
  865. }
  866.  
  867.  
  868.  
  869. add_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 );
  870.  
  871. function avia_woocommerce_shop_banner()
  872. {
  873.     global $avia_config;
  874.  
  875.     if(is_shop() || (is_product_category() && avia_get_option('shop_banner_global') == "shop_banner_global") && !isset($avia_config['woo-banner']))
  876.     {
  877.         $options = avia_get_option();
  878.  
  879.         if( isset( $options['shop_banner'] )  && ( $options['shop_banner'] == 'av-active-shop-banner' ) )
  880.         {
  881.             $bg         = $options['shop_banner_image'];
  882.             $overlay    = $options['shop_banner_overlay_color'];
  883.             $opacity    = $options['shop_banner_overlay_opacity'];
  884.             $description= wpautop($options['shop_banner_message']);
  885.             $font       = $options['shop_banner_message_color'];
  886.  
  887.             echo avia_woocommerce_parallax_banner($bg, $overlay, $opacity, $description, $font);
  888.         }
  889.     }
  890. }
  891.  
  892.  
  893. function avia_woocommerce_parallax_banner($bg, $overlay, $opacity, $description, $font)
  894. {
  895.  
  896.     if(is_numeric($bg))
  897.     {
  898.         $bg = wp_get_attachment_image_src($bg, 'extra_large');
  899.         if(is_array($bg) && $bg[0] != "") $bg = $bg[0];
  900.     }
  901.  
  902.     if($font) $font = "style='color:{$font};'";
  903.     if($bg) $bg = "background-image: url(".$bg.");";
  904.  
  905.  
  906.  
  907.  
  908.     $output = "";
  909.  
  910.     $output .='<div id="av_product_description" class="avia-section main_color avia-section-large avia-no-border-styling avia-full-stretch av-parallax-section av-section-color-overlay-active avia-bg-style-parallax container_wrap fullsize" data-section-bg-repeat="stretch" '.$font.'>';
  911.     $output .='<div class="av-parallax avia-full-stretch" data-avia-parallax-ratio="0.3">';
  912.     $output .='<div class="av-parallax-inner av-parallax-woo" style="'.$bg.' main_color background-attachment: scroll; background-position: 50% 50%; background-repeat: no-repeat;">';
  913.     $output .='</div>';
  914.     $output .='</div>';
  915.  
  916.  
  917.     $output .='<div class="av-section-color-overlay-wrap">';
  918.     if(!empty($overlay))
  919.     {
  920.         $output .='<div class="av-section-color-overlay" style="opacity: '.$opacity.'; background-color: '.$overlay.'; "></div>';
  921.     }
  922.  
  923.     $output .='<div class="container">';
  924.     $output .='<main class="template-page content av-content-full alpha units">';
  925.     if($description) $output .= "<h1>".$description."</h1>";
  926.     $output .='</main></div></div></div>';
  927.  
  928.     return $output;
  929. }
  930.  
  931.  
  932. #
  933. # creates the title + description for overview pages
  934. #
  935. function avia_woocommerce_advanced_title()
  936. {
  937.  
  938.     global $wp_query;
  939.     $titleClass     = "";
  940.     $image          = "";
  941.  
  942.  
  943.     if(!empty($attachment_id))
  944.     {
  945.         $titleClass .= "title_container_image ";
  946.         $image      = wp_get_attachment_image( $attachment_id, 'thumbnail', false, array('class'=>'category_thumb'));
  947.     }
  948.  
  949.     echo "<div class='extralight-border title_container shop_title_container $titleClass'>";
  950.     //echo avia_breadcrumbs();
  951.     woocommerce_catalog_ordering();
  952.     echo $image;
  953. }
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963. #
  964. # modify shop overview column count
  965. #
  966. function avia_woocommerce_loop_columns()
  967. {
  968.     global $avia_config;
  969.     return $avia_config['shop_overview_column'];
  970. }
  971.  
  972.  
  973. #
  974. # modify shop overview product count
  975. #
  976.  
  977. function avia_woocommerce_product_count()
  978. {
  979.     global $avia_config;
  980.     return $avia_config['shop_overview_products'];
  981. }
  982.  
  983.  
  984. #
  985. # filter cross sells on the cart page. display 4 on fullwidth pages and 3 on carts with sidebar
  986. #
  987.  
  988. add_filter('woocommerce_cross_sells_total', 'avia_woocommerce_cross_sale_count');
  989. add_filter('woocommerce_cross_sells_columns', 'avia_woocommerce_cross_sale_count');
  990.  
  991. function avia_woocommerce_cross_sale_count($count)
  992. {
  993.     return 4;
  994. }
  995.  
  996. #
  997. # move cross sells below the shipping
  998. #
  999.  
  1000. remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
  1001. add_action( 'woocommerce_after_cart', 'woocommerce_cross_sell_display' , 10);
  1002.  
  1003.  
  1004.  
  1005.  
  1006. #
  1007. # display tabs and related items within the summary wrapper
  1008. #
  1009. remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
  1010. add_action(    'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 1 );
  1011.  
  1012.  
  1013.  
  1014. #
  1015. # display upsells and related products within dedicated div with different column and number of products
  1016. #
  1017. remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products',20);
  1018. remove_action( 'woocommerce_after_single_product', 'woocommerce_output_related_products',10);
  1019. add_action( 'woocommerce_after_single_product_summary', 'avia_woocommerce_output_related_products', 20);
  1020.  
  1021. function avia_woocommerce_output_related_products($items = false, $columns = false)
  1022. {
  1023.     global $avia_config;
  1024.     $output = "";
  1025.  
  1026.     if(!$items)     $items   = $avia_config['shop_single_column_items'];
  1027.     if(!$columns)   $columns = $avia_config['shop_single_column'];
  1028.  
  1029.     ob_start();
  1030.     woocommerce_related_products(array('posts_per_page'=>$items, 'columns'=>$columns)); // X products, X columns
  1031.     $content = ob_get_clean();
  1032.     if($content)
  1033.     {
  1034.         $output .= "<div class='product_column product_column_".$columns."'>";
  1035.         //$output .= "<h3>".(__('Related Products', 'avia_framework'))."</h3>";
  1036.         $output .= $content;
  1037.         $output .= "</div>";
  1038.     }
  1039.  
  1040.     $avia_config['woo_related'] = $output;
  1041.     return $output;
  1042.  
  1043. }
  1044.  
  1045. remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
  1046. remove_action( 'woocommerce_after_single_product', 'woocommerce_upsell_display',10);
  1047. add_action( 'woocommerce_after_single_product_summary', 'avia_woocommerce_output_upsells', 21); // needs to be called after the "related product" function to inherit columns and product count
  1048.  
  1049. function avia_woocommerce_output_upsells($items = false, $columns = false)
  1050. {
  1051.     global $avia_config;
  1052.  
  1053.     $output = "";
  1054.  
  1055.     if(!$items)     $items   = $avia_config['shop_single_column_items'];
  1056.     if(!$columns)   $columns = $avia_config['shop_single_column'];
  1057.  
  1058.     ob_start();
  1059.     woocommerce_upsell_display($items,$columns); // 4 products, 4 columns
  1060.     $content = ob_get_clean();
  1061.     if($content)
  1062.     {
  1063.         $output .= "<div class='product_column product_column_".$columns."'>";
  1064.         //$output .= "<h3>".(__('You may also like', 'avia_framework'))."</h3>";
  1065.         $output .= $content;
  1066.         $output .= "</div>";
  1067.     }
  1068.  
  1069.     $avia_config['woo_upsells'] = $output;
  1070.     return $output;
  1071.  
  1072. }
  1073.  
  1074. add_action( 'woocommerce_after_single_product_summary', 'avia_woocommerce_display_output_upsells', 30); //display the related products and upsells
  1075.  
  1076. function avia_woocommerce_display_output_upsells()
  1077. {
  1078.     global $avia_config;
  1079.  
  1080.     $products = $avia_config['woo_upsells'].$avia_config['woo_related'];
  1081.  
  1082.     if(!empty($products))
  1083.     {
  1084.  
  1085.         $output  = "</div></div></div>";
  1086.         $output .= '<div id="av_section_1" class="avia-section alternate_color avia-section-small  container_wrap fullsize"><div class="container"><div class="template-page content  twelve alpha units">';
  1087.         $output .= $products;
  1088.  
  1089.         echo $output;
  1090.     }
  1091. }
  1092.  
  1093.  
  1094.  
  1095. #
  1096. # wrap single product image in an extra div
  1097. #
  1098. add_action( 'woocommerce_before_single_product_summary', 'avia_add_image_div', 2);
  1099. add_action( 'woocommerce_before_single_product_summary',  'avia_close_image_div', 20);
  1100. if(!function_exists('avia_add_image_div'))
  1101. {
  1102.     function avia_add_image_div()
  1103.     {
  1104.         if(avia_woocommerce_version_check('3.0.0') && current_theme_supports('avia-new-product-gallery-feature')) $nolightbox = 'noLightbox';
  1105.         echo "<div class='".$nolightbox." single-product-main-image alpha'>";
  1106.     }
  1107. }
  1108.  
  1109.  
  1110.  
  1111. if(!function_exists('avia_close_image_div'))
  1112. {
  1113.     function avia_close_image_div()
  1114.     {
  1115.         global $avia_config;
  1116.         if(is_product()) {
  1117.         $avia_config['currently_viewing'] = "shop_single";
  1118.         get_sidebar();
  1119.         }
  1120.         echo "</div>";
  1121.     }
  1122. }
  1123.  
  1124.  
  1125.  
  1126. #
  1127. # wrap single product summary in an extra div
  1128. #
  1129. add_action( 'woocommerce_before_single_product_summary', 'avia_add_summary_div', 25);
  1130. add_action( 'woocommerce_after_single_product_summary',  'avia_close_div', 3);
  1131.  
  1132. if(!function_exists('avia_add_summary_div'))
  1133. {
  1134.     function avia_add_summary_div()
  1135.     {
  1136.         echo "<div class='single-product-summary'>";
  1137.     }
  1138. }
  1139.  
  1140. //remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
  1141.  
  1142. if(avia_woocommerce_version_check('3.0.0')) // in woocommerce 3.0.0
  1143. {
  1144.     add_action('woocommerce_product_thumbnails', 'avia_product_gallery_thumbnail_opener', 19);
  1145.     add_action('woocommerce_product_thumbnails',  'avia_close_div', 21);
  1146. }
  1147.  
  1148. if(!function_exists('avia_product_gallery_thumbnail_opener'))
  1149. {
  1150.     function avia_product_gallery_thumbnail_opener()
  1151.     {
  1152.         echo "<div class='thumbnails'>";
  1153.     }
  1154. }
  1155.  
  1156.  
  1157.  
  1158.  
  1159. #
  1160. # displays a front end interface for modifying the shoplist query parameters like sorting order, product count etc
  1161. #
  1162. if(!function_exists('avia_woocommerce_frontend_search_params'))
  1163. {
  1164.     add_action( 'woocommerce_before_shop_loop', 'avia_woocommerce_frontend_search_params', 20);
  1165.  
  1166.     function avia_woocommerce_frontend_search_params()
  1167.     {
  1168.         global $avia_config;
  1169.  
  1170.         if(!empty($avia_config['woocommerce']['disable_sorting_options'])) return false;
  1171.  
  1172.         $product_order['default']   = __("Default Order",'avia_framework');
  1173.         $product_order['title']     = __("Name",'avia_framework');
  1174.         $product_order['price']     = __("Price",'avia_framework');
  1175.         $product_order['date']      = __("Date",'avia_framework');
  1176.         $product_order['popularity'] = __("Popularity",'avia_framework');
  1177.  
  1178.         $product_sort['asc']        = __("Click to order products ascending",  'avia_framework');
  1179.         $product_sort['desc']       = __("Click to order products descending",  'avia_framework');
  1180.  
  1181.         $per_page_string            = __("Products per page",'avia_framework');
  1182.  
  1183.  
  1184.         $per_page                   = get_option('avia_woocommerce_product_count');
  1185.         if(!$per_page) $per_page    = get_option('posts_per_page');
  1186.         if(!empty($avia_config['woocommerce']['default_posts_per_page'])) $per_page = $avia_config['woocommerce']['default_posts_per_page'];
  1187.  
  1188.  
  1189.         parse_str($_SERVER['QUERY_STRING'], $params);
  1190.  
  1191.         $po_key = !empty($avia_config['woocommerce']['product_order']) ? $avia_config['woocommerce']['product_order'] : 'default';
  1192.         $ps_key = !empty($avia_config['woocommerce']['product_sort'])  ? $avia_config['woocommerce']['product_sort'] : 'asc';
  1193.         $pc_key = !empty($avia_config['woocommerce']['product_count']) ? $avia_config['woocommerce']['product_count'] : $per_page;
  1194.  
  1195.         $ps_key = strtolower($ps_key);
  1196.  
  1197.         $nofollow = 'rel="nofollow"';
  1198.  
  1199.         //generate markup
  1200.         $output  = "";
  1201.         $output .= "<div class='product-sorting'>";
  1202.         $output .= "    <ul class='sort-param sort-param-order'>";
  1203.         $output .= "        <li><span class='currently-selected'>".__("Sort by",'avia_framework')." <strong>".$product_order[$po_key]."</strong></span>";
  1204.         $output .= "        <ul>";
  1205.         $output .= "        <li".avia_woo_active_class($po_key, 'default')."><a href='".avia_woo_build_query_string($params, 'product_order', 'default')."' {$nofollow}>    <span class='avia-bullet'></span>".$product_order['default']."</a></li>";
  1206.         $output .= "        <li".avia_woo_active_class($po_key, 'title')."><a href='".avia_woo_build_query_string($params, 'product_order', 'title')."' {$nofollow}>    <span class='avia-bullet'></span>".$product_order['title']."</a></li>";
  1207.         $output .= "        <li".avia_woo_active_class($po_key, 'price')."><a href='".avia_woo_build_query_string($params, 'product_order', 'price')."' {$nofollow}>    <span class='avia-bullet'></span>".$product_order['price']."</a></li>";
  1208.         $output .= "        <li".avia_woo_active_class($po_key, 'date')."><a href='".avia_woo_build_query_string($params, 'product_order', 'date')."' {$nofollow}>  <span class='avia-bullet'></span>".$product_order['date']."</a></li>";
  1209.         $output .= "        <li".avia_woo_active_class($po_key, 'popularity')."><a href='".avia_woo_build_query_string($params, 'product_order', 'popularity')."' {$nofollow}>  <span class='avia-bullet'></span>".$product_order['popularity']."</a></li>";
  1210.         $output .= "        </ul>";
  1211.         $output .= "        </li>";
  1212.         $output .= "    </ul>";
  1213.  
  1214.         $output .= "    <ul class='sort-param sort-param-sort'>";
  1215.         $output .= "        <li>";
  1216.         if($ps_key == 'desc')   $output .= "            <a title='".$product_sort['asc']."' class='sort-param-asc'  href='".avia_woo_build_query_string($params, 'product_sort', 'asc')."' {$nofollow}>".$product_sort['desc']."</a>";
  1217.         if($ps_key == 'asc')    $output .= "            <a title='".$product_sort['desc']."' class='sort-param-desc' href='".avia_woo_build_query_string($params, 'product_sort', 'desc')."' {$nofollow}>".$product_sort['asc']."</a>";
  1218.         $output .= "        </li>";
  1219.         $output .= "    </ul>";
  1220.  
  1221.         $output .= "    <ul class='sort-param sort-param-count'>";
  1222.         $output .= "        <li><span class='currently-selected'>".__("Display",'avia_framework')." <strong>".$pc_key." ".$per_page_string."</strong></span>";
  1223.         $output .= "        <ul>";
  1224.         $output .= "        <li".avia_woo_active_class($pc_key, $per_page).">  <a href='".avia_woo_build_query_string($params, 'product_count', $per_page)."' {$nofollow}>      <span class='avia-bullet'></span>".$per_page." ".$per_page_string."</a></li>";
  1225.         $output .= "        <li".avia_woo_active_class($pc_key, $per_page*2)."><a href='".avia_woo_build_query_string($params, 'product_count', $per_page * 2)."' {$nofollow}>  <span class='avia-bullet'></span>".($per_page * 2)." ".$per_page_string."</a></li>";
  1226.         $output .= "        <li".avia_woo_active_class($pc_key, $per_page*3)."><a href='".avia_woo_build_query_string($params, 'product_count', $per_page * 3)."' {$nofollow}>  <span class='avia-bullet'></span>".($per_page * 3)." ".$per_page_string."</a></li>";
  1227.         $output .= "        </ul>";
  1228.         $output .= "        </li>";
  1229.         $output .= "    </ul>";
  1230.  
  1231.  
  1232.  
  1233.         $output .= "</div>";
  1234.         echo $output;
  1235.     }
  1236. }
  1237.  
  1238. //helper function to create the active list class
  1239. if(!function_exists('avia_woo_active_class'))
  1240. {
  1241.     function avia_woo_active_class($key1, $key2)
  1242.     {
  1243.         if($key1 == $key2) return " class='current-param'";
  1244.     }
  1245. }
  1246.  
  1247.  
  1248. //helper function to build the query strings for the catalog ordering menu
  1249. if(!function_exists('avia_woo_build_query_string'))
  1250. {
  1251.     function avia_woo_build_query_string($params = array(), $overwrite_key, $overwrite_value)
  1252.     {
  1253.         $params[$overwrite_key] = $overwrite_value;
  1254.         $paged = (array_key_exists('product_count', $params)) ? 'paged=1&' : '';
  1255.         return "?" . $paged . http_build_query($params);
  1256.     }
  1257. }
  1258.  
  1259. //function that actually overwrites the query parameters
  1260. if(!function_exists('avia_woocommerce_overwrite_catalog_ordering'))
  1261. {
  1262.     add_action( 'woocommerce_get_catalog_ordering_args', 'avia_woocommerce_overwrite_catalog_ordering', 20);
  1263.  
  1264.     function avia_woocommerce_overwrite_catalog_ordering($args)
  1265.     {
  1266.         global $avia_config;
  1267.  
  1268.         if(!empty($avia_config['woocommerce']['disable_sorting_options'])) return $args;
  1269.  
  1270.         //check the folllowing get parameters and session vars. if they are set overwrite the defaults
  1271.         $check = array('product_order', 'product_count', 'product_sort');
  1272.         if(empty($avia_config['woocommerce'])) $avia_config['woocommerce'] = array();
  1273.  
  1274.         foreach($check as $key)
  1275.         {
  1276.             if(isset($_GET[$key]) ) $_SESSION['avia_woocommerce'][$key] = esc_attr($_GET[$key]);
  1277.             if(isset($_SESSION['avia_woocommerce'][$key]) ) $avia_config['woocommerce'][$key] = $_SESSION['avia_woocommerce'][$key];
  1278.         }
  1279.  
  1280.  
  1281.         // is user wants to use new product order remove the old sorting parameter
  1282.         if(isset($_GET['product_order']) && !isset($_GET['product_sort']) && isset($_SESSION['avia_woocommerce']['product_sort']))
  1283.         {
  1284.             unset($_SESSION['avia_woocommerce']['product_sort'], $avia_config['woocommerce']['product_sort']);
  1285.         }
  1286.  
  1287.         extract($avia_config['woocommerce']);
  1288.  
  1289.         // set the product order
  1290.         if(!empty($product_order))
  1291.         {
  1292.             switch ( $product_order ) {
  1293.                 case 'date'  : $orderby = 'date'; $order = 'desc'; $meta_key = '';  break;
  1294.                 case 'price' : $orderby = 'meta_value_num'; $order = 'asc'; $meta_key = '_price'; break;
  1295.                 case 'popularity' : $orderby = 'meta_value_num'; $order = 'desc'; $meta_key = 'total_sales'; break;
  1296.                 case 'title' : $orderby = 'title'; $order = 'asc'; $meta_key = ''; break;
  1297.                 case 'default':
  1298.                 default : $orderby = 'menu_order title'; $order = 'asc'; $meta_key = ''; break;
  1299.             }
  1300.         }
  1301.  
  1302.  
  1303.  
  1304.         // set the product count
  1305.         if(!empty($product_count) && is_numeric($product_count))
  1306.         {
  1307.             $avia_config['shop_overview_products_overwritten'] = true;
  1308.             $avia_config['shop_overview_products'] = (int) $product_count;
  1309.         }
  1310.  
  1311.         //set the product sorting
  1312.         if(!empty($product_sort))
  1313.         {
  1314.             switch ( $product_sort ) {
  1315.                 case 'desc' : $order = 'desc'; break;
  1316.                 case 'asc' : $order = 'asc'; break;
  1317.                 default : $order = 'asc'; break;
  1318.             }
  1319.         }
  1320.  
  1321.  
  1322.         if(isset($orderby)) $args['orderby'] = $orderby;
  1323.         if(isset($order))   $args['order'] = $order;
  1324.         if (!empty($meta_key))
  1325.         {
  1326.             $args['meta_key'] = $meta_key;
  1327.         }
  1328.  
  1329.  
  1330.         $avia_config['woocommerce']['product_sort'] = $args['order'];
  1331.  
  1332.         return $args;
  1333.     }
  1334.  
  1335.  
  1336. }
  1337.  
  1338. //remove produt information on password protected products
  1339. if(!function_exists('avia_woocommerce_remove_hooks'))
  1340. {
  1341.     add_action('woocommerce_before_single_product', 'avia_woocommerce_remove_hooks');
  1342.  
  1343.     function avia_woocommerce_remove_hooks()
  1344.     {
  1345.         /*remove content from password protected products*/
  1346.         if(post_password_required())
  1347.         {
  1348.             add_action( 'woocommerce_after_single_product_summary', 'avia_woocommerce_echo_password', 1 );
  1349.             remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 1 );
  1350.             remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
  1351.             remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
  1352.             remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
  1353.             remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
  1354.             remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
  1355.             remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
  1356.             remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
  1357.             remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
  1358.             remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
  1359.             remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
  1360.             remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
  1361.             remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
  1362.             remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
  1363.             remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
  1364.             remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
  1365.             remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
  1366.             remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
  1367.             remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
  1368.             remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
  1369.             remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
  1370.         }
  1371.     }
  1372. }
  1373.  
  1374. if(!function_exists('avia_woocommerce_echo_password'))
  1375. {
  1376.     add_action('ava_woocomemrce_password_protection_remove_hooks', 'avia_woocommerce_remove_hooks');
  1377.  
  1378.     function avia_woocommerce_echo_password()
  1379.     {
  1380.         /*remove content from password protected products*/
  1381.         if(post_password_required())
  1382.         {
  1383.             echo get_the_password_form();
  1384.         }
  1385.     }
  1386. }
  1387.  
  1388. add_action('after_setup_theme', 'avia_new_product_gallery_support', 50);
  1389. function avia_new_product_gallery_support() {
  1390.     if(avia_woocommerce_version_check('3.0.0') && current_theme_supports('avia-new-product-gallery-feature')) {
  1391.         remove_action('woocommerce_product_thumbnails', 'avia_product_gallery_thumbnail_opener', 19);
  1392.         remove_action('woocommerce_product_thumbnails', 'avia_close_div', 21);
  1393.     } else {
  1394.         add_filter('woocommerce_single_product_image_html','avia_woocommerce_post_thumbnail_description', 10, 2);
  1395.         add_filter('woocommerce_single_product_image_thumbnail_html','avia_woocommerce_gallery_thumbnail_description', 10, 4);
  1396.     }
  1397. }
  1398.  
  1399. if(!function_exists('avia_woocommerce_post_thumbnail_description'))
  1400. {
  1401.     function avia_woocommerce_post_thumbnail_description($img, $post_id)
  1402.     {
  1403.         global $post, $woocommerce, $product;
  1404.         if(has_post_thumbnail())
  1405.         {
  1406.             $image_title = esc_attr(get_post_field('post_content', get_post_thumbnail_id()));
  1407.             $image_link  = wp_get_attachment_url( get_post_thumbnail_id() );
  1408.             $image  = get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ), array(
  1409.                 'title' => $image_title
  1410.                 ) );
  1411.             $attachment_count = count( $product->get_gallery_attachment_ids() );
  1412.  
  1413.             if ( $attachment_count > 0 ) {
  1414.                 $gallery = '[product-gallery]';
  1415.             } else {
  1416.                 $gallery = '';
  1417.             }
  1418.  
  1419.             return sprintf( '<a href="%s" itemprop="image" class="woocommerce-main-image zoom" title="%s"  rel="prettyPhoto' . $gallery . '">%s</a>', $image_link, $image_title, $image);
  1420.         }
  1421.  
  1422.         return $img;
  1423.     }
  1424. }
  1425.  
  1426. if(!function_exists('avia_woocommerce_gallery_thumbnail_description'))
  1427. {
  1428.     function avia_woocommerce_gallery_thumbnail_description($img, $attachment_id, $post_id = "", $image_class = "" )
  1429.     {
  1430.             $image_link = wp_get_attachment_url( $attachment_id );
  1431.  
  1432.             if(!$image_link) return $img;
  1433.  
  1434.             $image = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ) );
  1435.             $image_title = esc_attr(get_post_field('post_content', $attachment_id));
  1436.             $img = sprintf( '<a href="%s" class="%s" title="%s"  rel="prettyPhoto[product-gallery]">%s</a>', $image_link, $image_class, $image_title, $image );
  1437.  
  1438.         return $img;
  1439.     }
  1440. }
  1441.  
  1442.  
  1443. if(!function_exists('avia_title_args_woopage'))
  1444. {
  1445.     add_filter('avf_title_args','avia_title_args_woopage', 10, 4);
  1446.     function avia_title_args_woopage($args)
  1447.     {
  1448.         if(is_single() && is_product())
  1449.         {
  1450.             $args['heading'] = "strong";
  1451.         }
  1452.  
  1453.         return $args;
  1454.     }
  1455. }
  1456.  
  1457.  
  1458. /*
  1459. Function that is able to overwrite the default "shop" page used by woocommerce so the template builder can be used
  1460. Will only be executed if the user has switched the "shop" page to advanced layout builder. Default products are no longer displayed
  1461. and the user needs to add a product grid element
  1462.  
  1463. Can be activated by adding
  1464.  
  1465. add_theme_support( 'avia_custom_shop_page' );
  1466.  
  1467. to your functions.php file
  1468. */
  1469. if(!function_exists('avia_woocommerce_default_page'))
  1470. {
  1471.     add_filter( 'pre_get_posts', 'avia_woocommerce_default_page' );
  1472.  
  1473.     function avia_woocommerce_default_page($query)
  1474.     {
  1475.         if(current_theme_supports('avia_custom_shop_page'))
  1476.         {
  1477.             if(!$query->is_admin && $query->is_main_query() && !$query->is_tax && $query->is_archive && $query->is_post_type_archive)
  1478.             {
  1479.                 $vars = $query->query_vars;
  1480.  
  1481.                 if(isset($vars['post_type']) && 'product' == $vars['post_type'] )
  1482.                 {
  1483.                     $shop_page_id   = wc_get_page_id( 'shop' );
  1484.                     $builder_active = AviaHelper::builder_status($shop_page_id);
  1485.  
  1486.                     if($builder_active == "active")
  1487.                     {
  1488.                         $query->set( 'post_type', 'page' );
  1489.                         $query->set( 'p', $shop_page_id  );
  1490.                         $query->set( 'meta_query', array() );
  1491.  
  1492.                         $query->is_singular = true;
  1493.                         $query->is_page     = true;
  1494.                         $query->is_archive  = false;
  1495.                         $query->is_post_type_archive  = false;
  1496.                         $query->query = array('p'=>$shop_page_id, 'post_type' => 'page');
  1497.                     }
  1498.                 }
  1499.             }
  1500.         }
  1501.  
  1502.     return $query;
  1503.  
  1504.     }
  1505. }
  1506.  
  1507.  
  1508.  
  1509. if(!function_exists('avia_woocommerce_disable_editor'))
  1510. {
  1511.     add_filter( 'avf_builder_button_params', 'avia_woocommerce_disable_editor' );
  1512.  
  1513.  
  1514.     function avia_woocommerce_disable_editor($params)
  1515.     {
  1516.         if(!current_theme_supports('avia_custom_shop_page'))
  1517.         {
  1518.             global $post_ID;
  1519.             $shop_page_id = wc_get_page_id( 'shop' );
  1520.  
  1521.             if($post_ID == $shop_page_id)
  1522.             {
  1523.                 $disabled = __('(disabled)', 'avia_framework');
  1524.  
  1525.                 $params['visual_label']     = $params['visual_label']  . " ".$disabled;
  1526.                 $params['default_label']    = $params['default_label'] . " ".$disabled;
  1527.                 $params['button_class']     = "av-builer-button-disabled";
  1528.                 $params['disabled']         = true;
  1529.                 $params['note']             = __('This page is set as the default WooCommerce Shop Overview and therefore does not support the Enfold advanced layout editor', 'avia_framework')." <br/><a href='http://www.kriesi.at/documentation/enfold/custom-woocommerce-shop-overview/' target='_blank'>(".__('Learn more').")</a>";
  1530.  
  1531.             }
  1532.         }
  1533.  
  1534.  
  1535.         if(avia_backend_get_post_type() == "product")
  1536.         {
  1537.             $params['noteclass'] = "av-notice av-only-active";
  1538.             $params['note'] = __('Please note that the Advanced Layout Builder for products will not work with all WooCommerce Extensions', 'avia_framework');
  1539.         }
  1540.  
  1541.  
  1542.  
  1543.  
  1544.         return $params;
  1545.     }
  1546.  
  1547. }
  1548.  
  1549. if(!function_exists('avia_woocommerce_disable_editor_option'))
  1550. {
  1551.     add_filter( 'avf_builder_active', 'avia_woocommerce_disable_editor_option' , 10 , 2);
  1552.  
  1553.     function avia_woocommerce_disable_editor_option($params, $post_id)
  1554.     {
  1555.         if(!current_theme_supports('avia_custom_shop_page'))
  1556.         {
  1557.             if($post_id == wc_get_page_id( 'shop' ))
  1558.             {
  1559.                 $params = false;
  1560.             }
  1561.         }
  1562.  
  1563.         return $params;
  1564.     }
  1565.  
  1566. }
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573. #
  1574. # place the cart button according to the header layout (top/sidebar)
  1575. #
  1576.  
  1577. if(!function_exists('avia_woocommerce_cart_placement'))
  1578. {
  1579.     add_action( 'init', 'avia_woocommerce_cart_placement', 10);
  1580.  
  1581.     function avia_woocommerce_cart_placement()
  1582.     {
  1583.         $position   = avia_get_option('header_position',  'header_top') == "header_top" ? "ava_main_header" : "ava_inside_main_menu";
  1584.         if(avia_get_option('cart_icon') == "always_display_menu")
  1585.         {
  1586.             $position = "ava_inside_main_menu";
  1587.             if( strpos( avia_get_option('header_layout'), 'bottom_nav_header') !== false && avia_get_option('header_position') == 'header_top')
  1588.             {
  1589.                 $position = "ava_before_bottom_main_menu";
  1590.             }
  1591.         }
  1592.  
  1593.         add_action( $position, 'avia_woocommerce_cart_dropdown', 10);
  1594.     }
  1595. }
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602. #
  1603. # permanent display of cart button
  1604. #
  1605.  
  1606.  
  1607.  
  1608. if(!function_exists('avia_woocommerce_cart_pos'))
  1609. {
  1610.     add_filter( 'avf_header_classes', 'avia_woocommerce_cart_pos' , 10 , 3);
  1611.  
  1612.     function avia_woocommerce_cart_pos($class, $necessary, $prefix)
  1613.     {
  1614.         if($prefix == 'html_') // only for the html tag
  1615.         {
  1616.             global $woocommerce;
  1617.             $cart = $woocommerce->cart->get_cart();
  1618.             $cart_pos = avia_get_option('cart_icon');
  1619.  
  1620.             if($cart_pos == "always_display" || (!empty($cart) && !avia_active_caching()))
  1621.             {
  1622.                 $class[] = "visible_cart";
  1623.             }
  1624.  
  1625.             if($cart_pos == "always_display_menu")
  1626.             {
  1627.                 $class[] = "cart_at_menu";
  1628.             }
  1629.         }
  1630.  
  1631.         return $class;
  1632.     }
  1633.  
  1634. }
  1635.  
  1636.  
  1637.  
  1638. function avia_woocommerce_cart_dropdown()
  1639. {
  1640.     global $woocommerce, $avia_config;
  1641.     $cart_subtotal = $woocommerce->cart->get_cart_subtotal();
  1642.     $link = $woocommerce->cart->get_cart_url();
  1643.     $id = "";
  1644.     $added = wc_get_notices('success');
  1645.     $trigger = !empty($added) ? "av-display-cart-on-load" : "";
  1646.  
  1647.     if(avia_get_option('cart_icon') == "always_display_menu")
  1648.     {
  1649.         $id = 'id="menu-item-shop"';
  1650.     }
  1651.  
  1652.     $output = "";
  1653.     $output .= "<ul {$id} class = 'cart_dropdown {$trigger}' data-success='".__('was added to the cart', 'avia_framework')."'><li class='cart_dropdown_first'>";
  1654.     $output .= "<a class='cart_dropdown_link' href='".$link."'><span ".av_icon_string('cart')."></span><span class='av-cart-counter'>0</span><span class='avia_hidden_link_text'>".__('Shopping Cart','avia_framework')."</span></a><!--<span class='cart_subtotal'>".$cart_subtotal."</span>-->";
  1655.     $output .= "<div class='dropdown_widget dropdown_widget_cart'><div class='avia-arrow'></div>";
  1656.     $output .= '<div class="widget_shopping_cart_content"></div>';
  1657.     $output .= "</div>";
  1658.     $output .= "</li></ul>";
  1659.  
  1660.  
  1661.     echo $output;
  1662.  
  1663. }
  1664.  
  1665. /*
  1666.     after importing demo pages make sure that if we got multiple shop/my account/etc pages (happens if the user used default woocommerce setup)
  1667.     to remove the duplicates and set the theme options properly
  1668. */
  1669.  
  1670. add_action('avia_after_import_hook', 'avia_woocommerce_set_pages');
  1671. // add_action('ava_after_main_container', 'avia_woocommerce_set_pages');
  1672.  
  1673. function avia_woocommerce_set_pages()
  1674. {
  1675.     global $wpdb;
  1676.  
  1677.     $pages = array(
  1678.             'shop' => array(
  1679.                 'title'   => 'Shop',
  1680.                 'slug'    => 'shop',
  1681.             ),
  1682.             'cart' => array(
  1683.                 'title'   => 'Cart',
  1684.                 'slug'    => 'cart',
  1685.             ),
  1686.             'checkout' => array(
  1687.                 'title'   => 'Checkout',
  1688.                 'slug'    => 'checkout',
  1689.             ),
  1690.             'myaccount' => array(
  1691.                 'title'   => 'My Account',
  1692.                 'slug'    => 'my-account',
  1693.             )
  1694.         );
  1695.  
  1696.     /*query string to get multiple posts with the same name*/
  1697.     $pagequery = "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type='page'";
  1698.  
  1699.  
  1700.     foreach ($pages as $page)
  1701.     {
  1702.         $entries = $wpdb->get_results( $wpdb->prepare( $pagequery , $page['title'] ));
  1703.  
  1704.         if(!empty($entries))
  1705.         {
  1706.             $keep   = 0;
  1707.             $delete = array();
  1708.  
  1709.             //we got one post of that name. the user did not yet activate woocommerce setup or no page with that name was imported
  1710.             if(count($entries) === 1)
  1711.             {
  1712.                 $keep = $entries[0]->ID;
  1713.             }
  1714.             else //we got 2 or more entries. keep the one with the highest id as woocommerce setting and delete the other ones
  1715.             {
  1716.                 foreach($entries as $entry)
  1717.                 {
  1718.                     if($entry->ID > $keep)
  1719.                     {
  1720.                         if($keep) $delete[] = $keep;
  1721.                         $keep = $entry->ID;
  1722.                     }
  1723.                     else
  1724.                     {
  1725.                         $delete[] = $entry->ID;
  1726.                     }
  1727.                 }
  1728.             }
  1729.  
  1730.             //delete the not required posts
  1731.             foreach($delete as $delete_id)
  1732.             {
  1733.                 wp_delete_post( $delete_id, true );
  1734.             }
  1735.  
  1736.             if($keep > 0)
  1737.             {
  1738.                 //store the value of the $keep as the default woo setting
  1739.                 $setting = str_replace("-", "", $page['slug']);
  1740.                 update_option('woocommerce_' . $setting . '_page_id' , $keep);
  1741.  
  1742.                 //modify the page slug and remove any numbers if necessary
  1743.                 $update_post = array(
  1744.                       'ID'          => $keep,
  1745.                       'post_name'   => $page['slug']
  1746.                   );
  1747.  
  1748.                 wp_update_post( $update_post );
  1749.             }
  1750.         }
  1751.     }
  1752. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement