php 可用性检查和WPML之间的兼容性(不重复)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 可用性检查和WPML之间的兼容性(不重复)相关的知识,希望对你有一定的参考价值。
add_action( 'ebac_order_processed', 'ebac_wpml_compatibility', 10, 3 );
function ebac_wpml_compatibility( $item, $keep_stock_id, $booked ) {
global $sitepress;
$trid = $sitepress->get_element_trid( $keep_stock_id, 'post_product' );
if ( is_numeric( $trid ) ) {
$translations = $sitepress->get_element_translations( $trid, 'post_product' );
if ( is_array( $translations ) ) {
foreach ( $translations as $translation ) {
if ( ! isset( $translation->element_id ) || $translation->element_id == $keep_stock_id ) {
continue;
}
// Update original post meta
update_post_meta( $translation->element_id, '_booking_days', $booked );
}
}
}
}
add_filter( 'ebac_booked_products', 'ebac_booked_products_wpml', 10, 1 );
function ebac_booked_products_wpml( $products ) {
global $sitepress;
if ( ! empty( $products ) ) foreach ( $products as $product ) {
$id = $product['product_id'];
$trid = $sitepress->get_element_trid( $id, 'post_product' );
if ( is_numeric( $trid ) ) {
$translations = $sitepress->get_element_translations( $trid, 'post_product' );
if ( is_array( $translations ) ) {
foreach ( $translations as $translation ) {
if ( ! isset( $translation->element_id ) || $translation->element_id == $id ) {
continue;
}
$products[] = array(
'product_id' => $translation->element_id,
'start' => $product['start'],
'end' => $product['end'],
'qty' => $product['qty']
);
}
}
}
}
return $products;
}
add_filter( 'ebac_delete_stock_ids', 'ebac_wpml_delete_stock_ids', 10, 2 );
function ebac_wpml_delete_stock_ids( $ids, $id ) {
global $sitepress;
$trid = $sitepress->get_element_trid( $id, 'post_product' );
if ( is_numeric( $trid ) ) {
$translations = $sitepress->get_element_translations( $trid, 'post_product' );
if ( is_array( $translations ) ) {
foreach ( $translations as $translation ) {
if ( ! isset( $translation->element_id ) || $translation->element_id == $id ) {
continue;
}
$ids[] = $translation->element_id;
}
}
}
return $ids;
}
以上是关于php 可用性检查和WPML之间的兼容性(不重复)的主要内容,如果未能解决你的问题,请参考以下文章