아래 PHP 코드는 Google Merchant Center에서 Woocommerce 카테고리를 제외합니다. 코드를 더 짧게 만들려면 in_array
을 어떻게 조합 하시겠습니까? 하나의 값이 true를 반환하기에 충분한 경우PHP에서 다중 배열 결합
// Exclude categories from my Google Product Feed
function lw_gpf_exclude_product($excluded, $product_id, $feed_format) {
// Return TRUE to exclude a product, FALSE to include it, $excluded to use the default behaviour.
$cats = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));
if (in_array(60, $cats)) {
return TRUE;
}
if (in_array(63, $cats)) {
return TRUE;
}
if (in_array(88, $cats)) {
return TRUE;
}
if (in_array(89, $cats)) {
return TRUE;
}
return $excluded;
}
add_filter('woocommerce_gpf_exclude_product', 'lw_gpf_exclude_product', 11, 3);
[http://php.net/manual/en/function.array-intersect.php](http://php. net/manual/ko/function.array-intersect.php) – cske