• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP translate_level_to_role函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中translate_level_to_role函数的典型用法代码示例。如果您正苦于以下问题:PHP translate_level_to_role函数的具体用法?PHP translate_level_to_role怎么用?PHP translate_level_to_role使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了translate_level_to_role函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: upgrade_160

/**
 * Execute changes made in WordPress 2.0.
 *
 * @since 2.0.0
 */
function upgrade_160()
{
    global $wpdb, $wp_current_db_version;
    populate_roles_160();
    $users = $wpdb->get_results("SELECT * FROM {$wpdb->users}");
    foreach ($users as $user) {
        if (!empty($user->user_firstname)) {
            update_user_meta($user->ID, 'first_name', $wpdb->escape($user->user_firstname));
        }
        if (!empty($user->user_lastname)) {
            update_user_meta($user->ID, 'last_name', $wpdb->escape($user->user_lastname));
        }
        if (!empty($user->user_nickname)) {
            update_user_meta($user->ID, 'nickname', $wpdb->escape($user->user_nickname));
        }
        if (!empty($user->user_level)) {
            update_user_meta($user->ID, $wpdb->prefix . 'user_level', $user->user_level);
        }
        if (!empty($user->user_icq)) {
            update_user_meta($user->ID, 'icq', $wpdb->escape($user->user_icq));
        }
        if (!empty($user->user_aim)) {
            update_user_meta($user->ID, 'aim', $wpdb->escape($user->user_aim));
        }
        if (!empty($user->user_msn)) {
            update_user_meta($user->ID, 'msn', $wpdb->escape($user->user_msn));
        }
        if (!empty($user->user_yim)) {
            update_user_meta($user->ID, 'yim', $wpdb->escape($user->user_icq));
        }
        if (!empty($user->user_description)) {
            update_user_meta($user->ID, 'description', $wpdb->escape($user->user_description));
        }
        if (isset($user->user_idmode)) {
            $idmode = $user->user_idmode;
            if ($idmode == 'nickname') {
                $id = $user->user_nickname;
            }
            if ($idmode == 'login') {
                $id = $user->user_login;
            }
            if ($idmode == 'firstname') {
                $id = $user->user_firstname;
            }
            if ($idmode == 'lastname') {
                $id = $user->user_lastname;
            }
            if ($idmode == 'namefl') {
                $id = $user->user_firstname . ' ' . $user->user_lastname;
            }
            if ($idmode == 'namelf') {
                $id = $user->user_lastname . ' ' . $user->user_firstname;
            }
            if (!$idmode) {
                $id = $user->user_nickname;
            }
            $wpdb->update($wpdb->users, array('display_name' => $id), array('ID' => $user->ID));
        }
        // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
        $caps = get_user_meta($user->ID, $wpdb->prefix . 'capabilities');
        if (empty($caps) || defined('RESET_CAPS')) {
            $level = get_user_meta($user->ID, $wpdb->prefix . 'user_level', true);
            $role = translate_level_to_role($level);
            update_user_meta($user->ID, $wpdb->prefix . 'capabilities', array($role => true));
        }
    }
    $old_user_fields = array('user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level');
    $wpdb->hide_errors();
    foreach ($old_user_fields as $old) {
        $wpdb->query("ALTER TABLE {$wpdb->users} DROP {$old}");
    }
    $wpdb->show_errors();
    // populate comment_count field of posts table
    $comments = $wpdb->get_results("SELECT comment_post_ID, COUNT(*) as c FROM {$wpdb->comments} WHERE comment_approved = '1' GROUP BY comment_post_ID");
    if (is_array($comments)) {
        foreach ($comments as $comment) {
            $wpdb->update($wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID));
        }
    }
    // Some alpha versions used a post status of object instead of attachment and put
    // the mime type in post_type instead of post_mime_type.
    if ($wp_current_db_version > 2541 && $wp_current_db_version <= 3091) {
        $objects = $wpdb->get_results("SELECT ID, post_type FROM {$wpdb->posts} WHERE post_status = 'object'");
        foreach ($objects as $object) {
            $wpdb->update($wpdb->posts, array('post_status' => 'attachment', 'post_mime_type' => $object->post_type, 'post_type' => ''), array('ID' => $object->ID));
            $meta = get_post_meta($object->ID, 'imagedata', true);
            if (!empty($meta['file'])) {
                update_attached_file($object->ID, $meta['file']);
            }
        }
    }
}
开发者ID:beaucollins,项目名称:wp,代码行数:97,代码来源:upgrade.php


示例2: upgrade_160

function upgrade_160()
{
    global $wpdb, $table_prefix, $wp_current_db_version;
    populate_roles_160();
    $users = $wpdb->get_results("SELECT * FROM {$wpdb->users}");
    foreach ($users as $user) {
        if (!empty($user->user_firstname)) {
            update_usermeta($user->ID, 'first_name', $wpdb->escape($user->user_firstname));
        }
        if (!empty($user->user_lastname)) {
            update_usermeta($user->ID, 'last_name', $wpdb->escape($user->user_lastname));
        }
        if (!empty($user->user_nickname)) {
            update_usermeta($user->ID, 'nickname', $wpdb->escape($user->user_nickname));
        }
        if (!empty($user->user_level)) {
            update_usermeta($user->ID, $table_prefix . 'user_level', $user->user_level);
        }
        if (!empty($user->user_icq)) {
            update_usermeta($user->ID, 'icq', $wpdb->escape($user->user_icq));
        }
        if (!empty($user->user_aim)) {
            update_usermeta($user->ID, 'aim', $wpdb->escape($user->user_aim));
        }
        if (!empty($user->user_msn)) {
            update_usermeta($user->ID, 'msn', $wpdb->escape($user->user_msn));
        }
        if (!empty($user->user_yim)) {
            update_usermeta($user->ID, 'yim', $wpdb->escape($user->user_icq));
        }
        if (!empty($user->user_description)) {
            update_usermeta($user->ID, 'description', $wpdb->escape($user->user_description));
        }
        if (isset($user->user_idmode)) {
            $idmode = $user->user_idmode;
            if ($idmode == 'nickname') {
                $id = $user->user_nickname;
            }
            if ($idmode == 'login') {
                $id = $user->user_login;
            }
            if ($idmode == 'firstname') {
                $id = $user->user_firstname;
            }
            if ($idmode == 'lastname') {
                $id = $user->user_lastname;
            }
            if ($idmode == 'namefl') {
                $id = $user->user_firstname . ' ' . $user->user_lastname;
            }
            if ($idmode == 'namelf') {
                $id = $user->user_lastname . ' ' . $user->user_firstname;
            }
            if (!$idmode) {
                $id = $user->user_nickname;
            }
            $id = $wpdb->escape($id);
            $wpdb->query("UPDATE {$wpdb->users} SET display_name = '{$id}' WHERE ID = '{$user->ID}'");
        }
        // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
        $caps = get_usermeta($user->ID, $table_prefix . 'capabilities');
        if (empty($caps) || defined('RESET_CAPS')) {
            $level = get_usermeta($user->ID, $table_prefix . 'user_level');
            $role = translate_level_to_role($level);
            update_usermeta($user->ID, $table_prefix . 'capabilities', array($role => true));
        }
    }
    $old_user_fields = array('user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level');
    $wpdb->hide_errors();
    foreach ($old_user_fields as $old) {
        $wpdb->query("ALTER TABLE {$wpdb->users} DROP {$old}");
    }
    $wpdb->show_errors();
    if (0 == $wpdb->get_var("SELECT SUM(category_count) FROM {$wpdb->categories}")) {
        // Create counts
        $categories = $wpdb->get_col("SELECT cat_ID FROM {$wpdb->categories}");
        foreach ($categories as $cat_id) {
            $count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->post2cat}, {$wpdb->posts} WHERE {$wpdb->posts}.ID={$wpdb->post2cat}.post_id AND post_status='publish' AND category_id = '{$cat_id}'");
            $wpdb->query("UPDATE {$wpdb->categories} SET category_count = '{$count}' WHERE cat_ID = '{$cat_id}'");
        }
    }
    // populate comment_count field of posts table
    $comments = $wpdb->get_results("SELECT comment_post_ID, COUNT(*) as c FROM {$wpdb->comments} WHERE comment_approved = '1' GROUP BY comment_post_ID");
    if (is_array($comments)) {
        foreach ($comments as $comment) {
            $wpdb->query("UPDATE {$wpdb->posts} SET comment_count = {$comment->c} WHERE ID = '{$comment->comment_post_ID}'");
        }
    }
    // Some alpha versions used a post status of object instead of attachment and put
    // the mime type in post_type instead of post_mime_type.
    if ($wp_current_db_version > 2541 && $wp_current_db_version <= 3091) {
        $objects = $wpdb->get_results("SELECT ID, post_type FROM {$wpdb->posts} WHERE post_status = 'object'");
        foreach ($objects as $object) {
            $wpdb->query("UPDATE {$wpdb->posts} SET post_status = 'attachment',\n\t\t\tpost_mime_type = '{$object->post_type}',\n\t\t\tpost_type = ''\n\t\t\tWHERE ID = {$object->ID}");
            $meta = get_post_meta($object->ID, 'imagedata', true);
            if (!empty($meta['file'])) {
                add_post_meta($object->ID, '_wp_attached_file', $meta['file']);
            }
        }
    }
//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:upgrade-functions.php


示例3: upgrade_160_helper

/**
 * Execute changes made in WordPress 2.0.
 *
 * @since 2.0.0
 */
function upgrade_160_helper($users)
{
    global $wpdb;
    populate_roles_160();
    foreach ($users as $user_details) {
        $user = $wpdb->get_results("SELECT * FROM {$wpdb->users} WHERE ID = '" . $user_details['user_id'] . "'");
        if (!empty($user->user_firstname)) {
            update_usermeta($user->ID, 'first_name', $wpdb->escape($user->user_firstname));
        }
        if (!empty($user->user_lastname)) {
            update_usermeta($user->ID, 'last_name', $wpdb->escape($user->user_lastname));
        }
        if (!empty($user->user_nickname)) {
            update_usermeta($user->ID, 'nickname', $wpdb->escape($user->user_nickname));
        }
        if (!empty($user->user_level)) {
            update_usermeta($user->ID, $wpdb->prefix . 'user_level', $user->user_level);
        }
        if (!empty($user->user_icq)) {
            update_usermeta($user->ID, 'icq', $wpdb->escape($user->user_icq));
        }
        if (!empty($user->user_aim)) {
            update_usermeta($user->ID, 'aim', $wpdb->escape($user->user_aim));
        }
        if (!empty($user->user_msn)) {
            update_usermeta($user->ID, 'msn', $wpdb->escape($user->user_msn));
        }
        if (!empty($user->user_yim)) {
            update_usermeta($user->ID, 'yim', $wpdb->escape($user->user_icq));
        }
        if (!empty($user->user_description)) {
            update_usermeta($user->ID, 'description', $wpdb->escape($user->user_description));
        }
        if (isset($user->user_idmode)) {
            $idmode = $user->user_idmode;
            if ($idmode == 'nickname') {
                $id = $user->user_nickname;
            }
            if ($idmode == 'login') {
                $id = $user->user_login;
            }
            if ($idmode == 'firstname') {
                $id = $user->user_firstname;
            }
            if ($idmode == 'lastname') {
                $id = $user->user_lastname;
            }
            if ($idmode == 'namefl') {
                $id = $user->user_firstname . ' ' . $user->user_lastname;
            }
            if ($idmode == 'namelf') {
                $id = $user->user_lastname . ' ' . $user->user_firstname;
            }
            if (!$idmode) {
                $id = $user->user_nickname;
            }
            $wpdb->update($wpdb->users, array('display_name' => $id), array('ID' => $user->ID));
        }
        // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
        $caps = get_usermeta($user->ID, $wpdb->prefix . 'capabilities');
        if (empty($caps) || defined('RESET_CAPS')) {
            $level = get_usermeta($user->ID, $wpdb->prefix . 'user_level');
            $role = translate_level_to_role($level);
            update_usermeta($user->ID, $wpdb->prefix . 'capabilities', array($role => true));
        }
    }
}
开发者ID:ericandrewlewis,项目名称:wordpress-mu,代码行数:72,代码来源:upgrade.php


示例4: DoSimpleLogin

 function DoSimpleLogin($args = '')
 {
     global $user_ID, $current_user, $login_errors, $user_level;
     get_currentuserinfo();
     extract($args);
     if ($user_ID != '') {
         require_once ABSPATH . '/wp-admin/includes/upgrade.php';
         $user_role = translate_level_to_role($user_level);
         $dashboard_link = $this->GetOption('dashboard_link');
         $profile_link = $this->GetOption('profile_link');
         echo $before_widget . $before_title . __('Welcome', 'simpelogin') . ', ' . $current_user->display_name . $after_title . "\n";
         if ($this->GetOption('show_gravatar') == true) {
             echo '<div class="simplelogin-avatar">' . get_avatar($user_ID, $size = $this->GetOption('gravatar_size')) . '</div>' . "\n";
         }
         do_action('simplelogin_avatar', $current_user);
         echo '<ul class="simplelogin-links">' . "\n";
         if ($dashboard_link[$user_role] == true) {
             $dashboard_url = $this->GetOption('dashboard_url');
             $dashboard_url = !empty($dashboard_url) ? $dashboard_url : admin_url();
             echo '<li><a href="' . $dashboard_url . '">' . __('Dashboard', 'simpelogin') . '</a></li>' . "\n";
         }
         if ($profile_link[$user_role] == true) {
             $profile_url = $this->GetOption('profile_url');
             $profile_url = !empty($profile_url) ? $profile_url : admin_url('profile.php');
             echo '<li><a href="' . $profile_url . '">' . __('Profile', 'simpelogin') . '</a></li>' . "\n";
         }
         do_action('simplelogin_custom_links', $user_role);
         echo '<li><a href="' . wp_nonce_url(simplelogin_url(array('action' => 'logout', 'redirect_to' => simplelogin_url())), 'log-out') . '">' . __('Logout', 'simpelogin') . '</a></li>' . "\n";
         echo '</ul>' . "\n";
     } else {
         require WP_PLUGIN_DIR . '/simplelogin/includes/wp-login-forms.php';
     }
     echo $after_widget;
 }
开发者ID:slaFFik,项目名称:l10n-ru,代码行数:34,代码来源:simplelogin.php



注:本文中的translate_level_to_role函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP translate_nooped_plural函数代码示例发布时间:2022-05-23
下一篇:
PHP translate_inline函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap