本文整理汇总了PHP中wc_reorder_terms函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_reorder_terms函数的具体用法?PHP wc_reorder_terms怎么用?PHP wc_reorder_terms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_reorder_terms函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wc_reorder_terms
/**
* Move a term before the a given element of its hierarchy level.
*
* @param int $the_term
* @param int $next_id the id of the next sibling element in save hierarchy level
* @param string $taxonomy
* @param int $index (default: 0)
* @param mixed $terms (default: null)
* @return int
*/
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;
}
开发者ID:Korkey128k,项目名称:woocommerce,代码行数:48,代码来源:wc-term-functions.php
示例2: term_ordering
/**
* Ajax request handling for categories ordering
*/
public function term_ordering()
{
global $wpdb;
$id = (int) $_POST['id'];
$next_id = isset($_POST['nextid']) && (int) $_POST['nextid'] ? (int) $_POST['nextid'] : null;
$taxonomy = isset($_POST['thetaxonomy']) ? esc_attr($_POST['thetaxonomy']) : null;
$term = get_term_by('id', $id, $taxonomy);
if (!$id || !$term || !$taxonomy) {
die(0);
}
wc_reorder_terms($term, $next_id, $taxonomy);
$children = get_terms($taxonomy, "child_of={$id}&menu_order=ASC&hide_empty=0");
if ($term && sizeof($children)) {
echo 'children';
die;
}
}
开发者ID:chhavinav,项目名称:fr.ilovejuice,代码行数:20,代码来源:class-wc-ajax.php
示例3: term_ordering
/**
* Ajax request handling for categories ordering
*/
public static function term_ordering()
{
// check permissions again and make sure we have what we need
if (!current_user_can('edit_products') || empty($_POST['id'])) {
die(-1);
}
$id = (int) $_POST['id'];
$next_id = isset($_POST['nextid']) && (int) $_POST['nextid'] ? (int) $_POST['nextid'] : null;
$taxonomy = isset($_POST['thetaxonomy']) ? esc_attr($_POST['thetaxonomy']) : null;
$term = get_term_by('id', $id, $taxonomy);
if (!$id || !$term || !$taxonomy) {
die(0);
}
wc_reorder_terms($term, $next_id, $taxonomy);
$children = get_terms($taxonomy, "child_of={$id}&menu_order=ASC&hide_empty=0");
if ($term && sizeof($children)) {
echo 'children';
die;
}
}
开发者ID:JodiWarren,项目名称:woocommerce,代码行数:23,代码来源:class-wc-ajax.php
示例4: woocommerce_order_terms
/**
* @deprecated
*/
function woocommerce_order_terms($the_term, $next_id, $taxonomy, $index = 0, $terms = null)
{
return wc_reorder_terms($the_term, $next_id, $taxonomy, $index, $terms);
}
开发者ID:nayemDevs,项目名称:woocommerce,代码行数:7,代码来源:wc-deprecated-functions.php
注:本文中的wc_reorder_terms函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论