تابع ووکامرسی wc_reorder_terms ثبت ترم و تاکسونومی اختصاصی
تابع ووکامرسی wc_reorder_terms – ثبت ترم و تاکسونومی اختصاصی
Syntax – سینتکس
(int) wc_reorder_terms( (int) $the_term, (int) $next_id, (string) $taxonomy, (int) $index = 0, (null) $terms = null );
Parameters – پارامتر ها (5)
- 1- $the_term (int)
- 2- $next_id (int)
- 3- $taxonomy (string)
- 4- $index (int)
- 5- $terms (null)
Usage – نحوه استفاده
if ( !function_exists( 'wc_reorder_terms' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-term-functions.php'; } // The term. $the_term = -1; // the id of the next sibling element in save hierarchy level $next_id = -1; // The taxonomy. $taxonomy = ''; // (default: 0) $index = -1; // (default: null) $terms = null; // NOTICE! Understand what this does before running. $result = wc_reorder_terms($the_term, $next_id, $taxonomy, $index, $terms);
Defined – محل تعریف
/includes/wc-term-functions.php
function wc_reorder_terms( $the_term, $next_id, $taxonomy, $index = 0, $terms = null ) { if ( ! $terms ) $terms = get_terms( $taxonomy, 'menu_order=ASC&hide_empty=0&parent=0' ); if ( empty( $terms ) ) return $index; $id = $the_term->term_id; $term_in_level = false; // flag: is our term to order in this level of terms foreach ( $terms as $term ) { if ( $term->term_id == $id ) { // our term to order, we skip $term_in_level = true; continue; // our term to order, we skip } // the nextid of our term to order, lets move our term here if ( null !== $next_id && $term->term_id == $next_id ) { $index++; $index = wc_set_term_order( $id, $index, $taxonomy, true ); } // set order $index++; $index = wc_set_term_order( $term->term_id, $index, $taxonomy ); // if that term has children we walk through them $children = get_terms( $taxonomy, "parent={$term->term_id}&menu_order=ASC&hide_empty=0" ); if ( ! empty( $children ) ) { $index = wc_reorder_terms( $the_term, $next_id, $taxonomy, $index, $children ); } } // no nextid meaning our term is in last position if ( $term_in_level && null === $next_id ) { $index = wc_set_term_order( $id, $index + 1, $taxonomy, true ); } return $index; }
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر