تابع ووکامرسی wc_get_object_terms دریافت ویژگی های taxonomy آبجکت
تابع ووکامرسی wc_get_object_terms – دریافت ویژگی های taxonomy آبجکت با کمک wp_list_pluck
Syntax – سینتکس
(array) wc_get_object_terms( (int) $object_id, (string) $taxonomy, (constant) $field = null, (null) $index_key = null );
Parameters – پارامتر ها (4)
- 1- $object_id (int)
- 2- $taxonomy (string)
- 3- $field (constant)
- 4- $index_key (null)
Usage – نحوه استفاده
if ( !function_exists( 'wc_get_object_terms' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-term-functions.php'; } // The object id. $object_id = -1; // Taxonomy slug. $taxonomy = ''; // Field name. $field = null; // Index key name. $index_key = null; // NOTICE! Understand what this does before running. $result = wc_get_object_terms($object_id, $taxonomy, $field, $index_key);
Defined – محل تعریف
/includes/wc-term-functions.php
function wc_get_object_terms( $object_id, $taxonomy, $field = null, $index_key = null ) { // Test if terms exists. get_the_terms() return false when it finds no terms. $terms = get_the_terms( $object_id, $taxonomy ); if ( $terms && ! is_wp_error( $terms ) ) { if ( ! is_null( $field ) ) { $terms = wp_list_pluck( $terms, $field, $index_key ); } } else { $terms = array(); } return $terms; }
versions – نسخه ها
از نسخه : 3.0.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر