تابع ووکامرسی wc_set_term_order ترتیب بندی و sort ترم تاکسونومی

تابع ووکامرسی wc_set_term_order – ترتیب بندی و sort ترم تاکسونومی
Syntax – سینتکس
(int) wc_set_term_order( (int) $term_id, (int) $index, (string) $taxonomy, (bool) $recursive = false );
Parameters – پارامتر ها (4)
- 1- $term_id (int)
- 2- $index (int)
- 3- $taxonomy (string)
- 4- $recursive (bool)
Usage – نحوه استفاده
if ( !function_exists( 'wc_set_term_order' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-term-functions.php';
}
// The term id.
$term_id = -1;
// The index.
$index = -1;
// The taxonomy.
$taxonomy = '';
// (default: false)
$recursive = false;
// NOTICE! Understand what this does before running.
$result = wc_set_term_order($term_id, $index, $taxonomy, $recursive);
Defined – محل تعریف
/includes/wc-term-functions.php
function wc_set_term_order( $term_id, $index, $taxonomy, $recursive = false ) {
$term_id = (int) $term_id;
$index = (int) $index;
// Meta name
if ( taxonomy_is_product_attribute( $taxonomy ) )
$meta_name = 'order_' . esc_attr( $taxonomy );
else
$meta_name = 'order';
update_woocommerce_term_meta( $term_id, $meta_name, $index );
if ( ! $recursive ) return $index;
$children = get_terms( $taxonomy, "parent=$term_id&menu_order=ASC&hide_empty=0" );
foreach ( $children as $term ) {
$index++;
$index = wc_set_term_order( $term->term_id, $index, $taxonomy, true );
}
clean_term_cache( $term_id, $taxonomy );
return $index;
}
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر