示例#1
0
function xt_get_rate($user = 0)
{
    if (xt_is_fanxian()) {
        $isforce = false;
        if (!(is_object($user) && is_a($user, 'WP_User'))) {
            if ($user > 0) {
                $user = new WP_User($user);
                $isforce = true;
            } else {
                $user = wp_get_current_user();
            }
        } else {
            $isforce = true;
        }
        if ($user->exists()) {
            $rate = xt_get_user_rate($user->ID);
            if ($rate === '') {
                return xt_get_role_rate($user->roles);
            }
            return $rate;
        } else {
            if ($isforce) {
                //如果指定了会员,但不存在,则返回0
                return 0;
            }
            return xt_fanxian_default_rate();
        }
    }
    return 0;
}
示例#2
0
function xt_row_role($key, $role, $count)
{
    global $wp_roles;
    $_title = isset($wp_roles->role_names[$role->name]) ? translate_user_role($wp_roles->role_names[$role->name]) : '未知';
    $_rate = xt_get_role_rate(array($key));
    $_adrate = xt_get_role_adrate(array($key));
    $_sharerate = xt_get_role_sharerate(array($key));
    $_ismulti = xt_is_role_multicashback(array($key));
    $_isSys = in_array($key, xt_roles());
    ?>
    <tr id="role-<?php 
    echo $key;
    ?>
" <?php 
    echo $count % 2 == 0 ? 'class = "alternate"' : '';
    ?>
>
        <td><span><?php 
    echo $_isSys ? '内置' : '自定义';
    ?>
</span></td>
        <td><span><?php 
    echo $key;
    ?>
</span></td>
        <td>
            <span><?php 
    echo $_title;
    ?>
</span>
            <?php 
    if (!$_isSys) {
        ?>
                <br>
                <div class="row-actions">
                        <!--<span class="edit"><a href="">编辑</a> | </span>-->
                    <span class="inline hide-if-no-js"><a href="#" class="editinline">快速编辑</a> | </span>
                    <span class="delete"><a class="delete-role" href="javascript:;" data-value="<?php 
        echo $key;
        ?>
">删除</a></span>
                </div>
                <div class="hidden" id="inline_<?php 
        echo $key;
        ?>
">
                    <div class="title"><?php 
        echo $_title;
        ?>
</div>
                    <div class="rate"><?php 
        echo $_rate;
        ?>
</div>
                    <div class="sharerate"><?php 
        echo $_sharerate;
        ?>
</div>
                    <div class="adrate"><?php 
        echo $_adrate;
        ?>
</div>
                </div>
            <?php 
    }
    ?>
        </td>
        <td><?php 
    echo $_rate;
    ?>
%</td>
        <td><?php 
    echo $_sharerate;
    ?>
%</td>
        <td><?php 
    echo $_adrate;
    ?>
%</td>
    </tr>
    <?php 
}