/**
  * Generate HTML for a single row on the users.php admin panel.
  */
 function single_row($row_data, $style = '')
 {
     global $wpdb;
     if (!isset($_REQUEST['order'])) {
         $_REQUEST['order'] = 'desc';
     }
     if (!isset($_REQUEST['orderby'])) {
         $_REQUEST['orderby'] = 'wgreported_on';
     }
     $url = admin_url('admin.php?page=wangguard_queue&order=' . $_REQUEST['order'] . '&orderby=' . $_REQUEST['orderby']);
     $row_data->reported_by->filter = 'display';
     $authors_div = "";
     if (is_a($row_data, 'WP_User')) {
         //USER
         $row_data->filter = 'display';
         $email = $row_data->user_email;
         $checkbox = '';
         // Set up the hover actions for this user
         $actions = array();
         $actions['unreport'] = "<a href='javascript:void(0)' rel='" . $row_data->ID . "' class='wangguard-queue-remove-user'>" . __('Remove from Queue', 'wangguard') . "</a>";
         if (defined('BP_VERSION')) {
             $user_editobj_link = esc_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), "user-edit.php?user_id=" . $row_data->ID));
             $editobj_link = esc_url(bp_core_get_user_domain($row_data->ID));
             // Set up the hover actions for this user
             add_thickbox();
             $actions['edituser'] = "******" . __('Edit user', 'wangguard') . "</a>";
             $actions['bpprofile'] = "<a href='{$editobj_link}?TB_iframe=true&width=900&height=550' class='thickbox'>" . __('BP Profile', 'wangguard') . "</a>";
             $report = "<strong><a target=\"_blank\" href=\"{$editobj_link}\">{$row_data->user_login}</a></strong><br />";
         } else {
             $editobj_link = esc_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), "user-edit.php?user_id=" . $row_data->ID));
             $report = "<strong><a target=\"_blank\" href=\"{$editobj_link}\">{$row_data->user_login}</a></strong><br />";
         }
         $report .= $this->row_actions($actions);
         // Set up the checkbox ( because the user is editable, otherwise its empty )
         $checkbox = "<input type='checkbox' name='users[]' id='user_{$row_data->ID}' value='{$row_data->ID}' />";
         $avatar = get_avatar($row_data->ID, 32);
         $userid = $row_data->ID;
         $statushtml = wangguard_user_custom_columns("", "wangguardstatus", $userid);
         $rowID = "user-" . $userid;
     } else {
         //BLOG
         $checkbox = '';
         $editobj_link = network_admin_url("site-info.php?id={$row_data->ID}");
         $email = $row_data->blog_email;
         $authors_links = array();
         $blog_prefix = $wpdb->get_blog_prefix($row_data->ID);
         $authors = $wpdb->get_results("SELECT u.user_login, um.user_id, um.meta_value AS caps FROM {$wpdb->users} u, {$wpdb->usermeta} um WHERE u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities'");
         foreach ((array) $authors as $author) {
             $caps = maybe_unserialize($author->caps);
             if (!isset($caps['administrator'])) {
                 continue;
             }
             $editauthor_link = esc_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), "user-edit.php?user_id=" . $author->user_id));
             $authors_links[] = "<a target=\"_blank\" href=\"{$editauthor_link}\">{$author->user_login}</a>";
         }
         if (count($authors_links)) {
             $authors_div = "<div class=\"row-actions\">" . __("Authors: ", "wangguard") . implode(" | ", $authors_links) . "</div>";
         }
         $actions = array();
         $report = "<strong><a target=\"_blank\" href=\"{$editobj_link}\">{$row_data->user_login}</a></strong><br />";
         $actions['unreport'] = "<a href='javascript:void(0)' rel='" . $row_data->ID . "' class='wangguard-queue-remove-blog'>" . __('Remove from Queue', 'wangguard') . "</a>";
         $report .= $this->row_actions($actions);
         // Set up the checkbox ( because the user is editable, otherwise its empty )
         $checkbox = "<input type='checkbox' name='blogs[]' id='blog_{$row_data->ID}' value='{$row_data->ID}' />";
         $avatar = '';
         $statushtml .= "<div class=\"row-actions\">";
         $statushtml .= '<a href="javascript:void(0)" rel="' . $row_data->ID . '" class="wangguard-splogger-blog">' . esc_html(__('Report authors as Sploggers', 'wangguard')) . '</a>';
         $statushtml .= '<br/><a href="' . $row_data->site_url . '" target="_blank">' . esc_html(__('Open blog', 'wangguard')) . '</a>';
         $statushtml .= "</div>";
         $rowID = "blog-" . $row_data->ID;
     }
     $r = "<tr id='{$rowID}'{$style}>";
     list($columns, $hidden) = $this->get_column_info();
     foreach ($columns as $column_name => $column_display_name) {
         $class = "class=\"{$column_name} column-{$column_name}\"";
         $style = '';
         $attributes = "{$class}{$style}";
         switch ($column_name) {
             case 'cb':
                 $r .= "<th scope='row' class='check-column'>{$checkbox}</th>";
                 break;
             case 'username':
                 $r .= "<td {$attributes}>{$avatar} {$report}</td>";
                 break;
             case 'wgtype':
                 $r .= "<td {$attributes}>{$row_data->wgtype} {$authors_div}</td>";
                 break;
             case 'name':
                 $r .= "<td {$attributes}>{$row_data->first_name} {$row_data->last_name}</td>";
                 break;
             case 'email':
                 $r .= "<td {$attributes}><a href='mailto:{$email}' title='" . esc_attr(sprintf(__('E-mail: %s'), $email)) . "'>{$email}</a></td>";
                 break;
             case 'wgreported_by':
                 $edit_reported_link = esc_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), "user-edit.php?user_id=" . $row_data->reported_by->ID));
                 $r .= "<td {$attributes}><a href='{$edit_reported_link}'>{$row_data->reported_by->user_login}</a></td>";
                 break;
             case 'wgreported_on':
                 $r .= "<td {$attributes}>" . date(get_option('date_format'), strtotime($row_data->reported_on)) . " " . date(get_option('time_format'), strtotime($row_data->reported_on)) . "</td>";
                 break;
             case 'wgstatus':
                 $r .= "<td {$attributes}>" . $statushtml . "</td>";
                 break;
         }
     }
     $r .= '</tr>';
     return $r;
 }
 /**
  * Generate HTML for a single row on the users.php admin panel.
  */
 function single_row($row_data, $style = '', $numposts)
 {
     global $wpdb, $wp_roles;
     $url = admin_url('admin.php?page=wangguard_users&order=' . (isset($_REQUEST['order']) ? $_REQUEST['order'] : '') . '&orderby=' . (isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : ''));
     //USER
     $row_data->filter = 'display';
     $email = $row_data->user_email;
     $checkbox = '';
     $actions = false;
     if (defined('BP_VERSION')) {
         add_thickbox();
         $user_editobj_link = esc_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), "user-edit.php?user_id=" . $row_data->ID));
         $editobj_link = esc_url(bp_core_get_user_domain($row_data->ID));
         // Set up the hover actions for this user
         $actions['edituser'] = "******" . __('Edit user', 'wangguard') . "</a>";
         $actions['bpprofile'] = "<a href='{$editobj_link}?TB_iframe=true&width=900&height=550' class='thickbox'>" . __('BP Profile', 'wangguard') . "</a>";
         $report = "<strong><a target=\"_blank\" href=\"{$editobj_link}\">{$row_data->user_login}</a></strong><br />";
     } else {
         $editobj_link = esc_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), "user-edit.php?user_id=" . $row_data->ID));
         $report = "<strong><a target=\"_blank\" href=\"{$editobj_link}\">{$row_data->user_login}</a></strong><br />";
     }
     // Set up the checkbox ( because the user is editable, otherwise its empty )
     $checkbox = "<input type='checkbox' name='users[]' id='user_{$row_data->ID}' value='{$row_data->ID}' />";
     $avatar = get_avatar($row_data->ID, 32);
     $role = reset($row_data->roles);
     if (!empty($role)) {
         $role = $wp_roles->role_names[$role];
     }
     $userid = $row_data->ID;
     $statushtml = wangguard_user_custom_columns("", "wangguardstatus", $userid);
     $rowID = "user-" . $userid;
     $trstyle = "class='{$style} " . (@$row_data->spam || @$row_data->user_status ? "site-spammed" : '') . "'";
     $r = "<tr id='{$rowID}'{$trstyle}>";
     list($columns, $hidden) = $this->get_column_info();
     foreach ($columns as $column_name => $column_display_name) {
         $class = "class=\"{$column_name} column-{$column_name}\" {$style}";
         $attributes = $class;
         switch ($column_name) {
             case 'cb':
                 $r .= "<th scope='row' class='check-column'>{$checkbox}</th>";
                 break;
             case 'info':
                 add_thickbox();
                 if (!is_multisite()) {
                     $url = esc_url(admin_url(add_query_arg(array('page' => 'wangguard_users_info'), 'admin.php')));
                 } else {
                     $url = esc_url(network_admin_url(add_query_arg(array('page' => 'wangguard_users_info'), 'admin.php')));
                 }
                 $arrayUrl = array('userID' => $row_data->ID, 'userIP' => $row_data->user_ip, '?TB_iframe' => 'true', 'width' => '900', 'height' => '550');
                 $final_user_info_url = esc_url(add_query_arg($arrayUrl, $url));
                 $r .= "<td  width='25'><a class='thickbox' title='" . __('Info about', 'wangguard') . "  {$row_data->first_name} {$row_data->last_name}' href='" . $final_user_info_url . "'><img class='alignnone size-full wp-image-2055' alt='Info about {$row_data->first_name} {$row_data->last_name}' src='" . plugins_url('img/info-wgg.png', __FILE__) . "' width='15' height='15' /> " . __('User Info', 'wangguard') . "</a>";
                 break;
             case 'username':
                 $r .= "<td {$attributes}>{$avatar} {$report} <span style='font-size:11px'>{$role}" . ($actions ? $this->row_actions($actions) : "") . "</span></td>";
                 break;
             case 'name':
                 $r .= "<td {$attributes}>{$row_data->first_name} {$row_data->last_name}</td>";
                 break;
             case 'email':
                 $r .= "<td {$attributes}><a href='mailto:{$email}' title='" . esc_attr(sprintf(__('E-mail: %s'), $email)) . "'>{$email}</a></td>";
                 break;
             case 'user_registered':
                 $r .= "<td {$attributes}><span style='font-size:11px'>" . date(get_option('date_format'), strtotime($row_data->user_registered)) . " " . date(get_option('time_format'), strtotime($row_data->user_registered)) . "</span></td>";
                 break;
             case 'from_ip':
                 $r .= "<td {$attributes}>";
                 $r .= "<div class='wangguard-user-ip' data='{$row_data->user_ip}'><span class='wangguard-user-ip-bb'>";
                 $r .= $row_data->user_ip;
                 $r .= '</span>';
                 if ($row_data->user_ip_is_proxy) {
                     $r .= " <span class='wangguard_proxy'>" . __('proxy', 'wangguard') . "</span>";
                 }
                 $r .= "</div>";
                 if (!empty($row_data->user_reported_proxy_ip)) {
                     $r .= "<div class='wangguard-user-ip' data='{$row_data->user_reported_proxy_ip}'><span class='wangguard-user-ip-bb'>";
                     $r .= $row_data->user_reported_proxy_ip;
                     $r .= '</span>';
                     $r .= " <span class='wangguard_proxy'>" . __('reported proxy', 'wangguard') . "</span>";
                     $r .= "</div>";
                 }
                 $r .= "</td>";
                 break;
             case 'posts':
                 $attributes = 'class="posts column-posts num"' . $style;
                 $r .= "<td {$attributes}>";
                 if ($numposts > 0) {
                     $r .= "<a target='_blank' href='edit.php?author={$row_data->ID}' title='" . esc_attr__('View posts by this author') . "' class='edit'>";
                     $r .= $numposts;
                     $r .= '</a>';
                 } else {
                     $r .= 0;
                 }
                 $r .= "</td>";
                 break;
             case 'blogs':
                 add_thickbox();
                 $r .= "<td {$attributes}>";
                 if (function_exists("get_blogs_of_user")) {
                     $blogs = @get_blogs_of_user($row_data->ID, true);
                     if (is_array($blogs)) {
                         foreach ((array) $blogs as $key => $details) {
                             $r .= '- <a href="' . $details->siteurl . '?TB_iframe=true&width=900&height=550" class="thickbox" title="' . htmlentities($details->siteurl, 0, 'UTF-8') . '">' . $details->blogname . '</a><br/>';
                         }
                     }
                 }
                 $r .= "</td>";
                 break;
             case 'groups':
                 add_thickbox();
                 $r .= "<td {$attributes}>";
                 if (defined('BP_VERSION') && class_exists('BP_Groups_member')) {
                     global $bp;
                     $bpgrpupsslug = $bp->groups->root_slug;
                     $groups = BP_Groups_Member::get_is_admin_of($row_data->ID);
                     foreach ($groups as $group) {
                         if (is_array($group)) {
                             foreach ($group as $detail) {
                                 $groupdomain = $bp->root_domain;
                                 $bpgroupsslug = $bp->groups->root_slug;
                                 $groupslug = $detail->slug;
                                 $groupname = $detail->name;
                                 $r .= '- <a href="' . $groupdomain . '/' . $bpgroupsslug . '/' . $groupslug . '/?TB_iframe=true&width=900&height=550" class="thickbox" title="' . htmlentities($groupdomain . '/' . $bpgrpupsslug . '/' . $groupslug, 0, 'UTF-8') . '">' . $groupname . '</a><br/>';
                             }
                         } else {
                             continue;
                         }
                     }
                 }
                 $r .= "</td>";
                 break;
             case 'wgstatus':
                 $r .= "<td {$attributes}>" . $statushtml . "</td>";
                 break;
         }
     }
     $r .= '</tr>';
     return $r;
 }
 /**
  * Generate HTML for a single row on the users.php admin panel.
  */
 function single_row($row_data, $style = '', $numposts)
 {
     global $wpdb, $wp_roles;
     $url = admin_url('admin.php?page=wangguard_users&order=' . (isset($_REQUEST['order']) ? $_REQUEST['order'] : '') . '&orderby=' . (isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : ''));
     //USER
     $row_data->filter = 'display';
     $email = $row_data->user_email;
     $checkbox = '';
     $actions = false;
     if (defined('BP_VERSION')) {
         $user_editobj_link = esc_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), "user-edit.php?user_id=" . $row_data->ID));
         $editobj_link = esc_url(bp_core_get_user_domain($row_data->ID));
         // Set up the hover actions for this user
         $actions['edituser'] = "******" . __('Edit user', 'wangguard') . "</a>";
         $actions['bpprofile'] = "<a href='{$editobj_link}' target='_blank'>" . __('BP Profile', 'wangguard') . "</a>";
         $report = "<strong><a target=\"_blank\" href=\"{$editobj_link}\">{$row_data->user_login}</a></strong><br />";
     } else {
         $editobj_link = esc_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), "user-edit.php?user_id=" . $row_data->ID));
         $report = "<strong><a target=\"_blank\" href=\"{$editobj_link}\">{$row_data->user_login}</a></strong><br />";
     }
     // Set up the checkbox ( because the user is editable, otherwise its empty )
     $checkbox = "<input type='checkbox' name='users[]' id='user_{$row_data->ID}' value='{$row_data->ID}' />";
     $avatar = get_avatar($row_data->ID, 32);
     $role = reset($row_data->roles);
     if (!empty($role)) {
         $role = $wp_roles->role_names[$role];
     }
     $userid = $row_data->ID;
     $statushtml = wangguard_user_custom_columns("", "wangguardstatus", $userid);
     $rowID = "user-" . $userid;
     $trstyle = "class='{$style} " . (@$row_data->spam || @$row_data->user_status ? "site-spammed" : '') . "'";
     $r = "<tr id='{$rowID}'{$trstyle}>";
     list($columns, $hidden) = $this->get_column_info();
     foreach ($columns as $column_name => $column_display_name) {
         $class = "class=\"{$column_name} column-{$column_name}\" {$style}";
         $attributes = $class;
         switch ($column_name) {
             case 'cb':
                 $r .= "<th scope='row' class='check-column'>{$checkbox}</th>";
                 break;
             case 'username':
                 $r .= "<td {$attributes}>{$avatar} {$report} <span style='font-size:11px'>{$role}" . ($actions ? $this->row_actions($actions) : "") . "</span></td>";
                 break;
             case 'name':
                 $r .= "<td {$attributes}>{$row_data->first_name} {$row_data->last_name}</td>";
                 break;
             case 'email':
                 $r .= "<td {$attributes}><a href='mailto:{$email}' title='" . esc_attr(sprintf(__('E-mail: %s'), $email)) . "'>{$email}</a></td>";
                 break;
             case 'user_registered':
                 $r .= "<td {$attributes}><span style='font-size:11px'>" . date(get_option('date_format'), strtotime($row_data->user_registered)) . " " . date(get_option('time_format'), strtotime($row_data->user_registered)) . "</span></td>";
                 break;
             case 'from_ip':
                 $r .= "<td {$attributes}>";
                 $r .= "<div class='wangguard-user-ip' data='{$row_data->user_ip}'><span class='wangguard-user-ip-bb'>";
                 $r .= $row_data->user_ip;
                 $r .= '</span>';
                 if ($row_data->user_ip_is_proxy) {
                     $r .= " <span class='wangguard_proxy'>" . __('proxy', 'wangguard') . "</span>";
                 }
                 $r .= "</div>";
                 if (!empty($row_data->user_reported_proxy_ip)) {
                     $r .= "<div class='wangguard-user-ip' data='{$row_data->user_reported_proxy_ip}'><span class='wangguard-user-ip-bb'>";
                     $r .= $row_data->user_reported_proxy_ip;
                     $r .= '</span>';
                     $r .= " <span class='wangguard_proxy'>" . __('reported proxy', 'wangguard') . "</span>";
                     $r .= "</div>";
                 }
                 $r .= "</td>";
                 break;
             case 'posts':
                 $attributes = 'class="posts column-posts num"' . $style;
                 $r .= "<td {$attributes}>";
                 if ($numposts > 0) {
                     $r .= "<a target='_blank' href='edit.php?author={$row_data->ID}' title='" . esc_attr__('View posts by this author') . "' class='edit'>";
                     $r .= $numposts;
                     $r .= '</a>';
                 } else {
                     $r .= 0;
                 }
                 $r .= "</td>";
                 break;
             case 'blogs':
                 $r .= "<td {$attributes}>";
                 if (function_exists("get_blogs_of_user")) {
                     $blogs = @get_blogs_of_user($row_data->ID, true);
                     if (is_array($blogs)) {
                         foreach ((array) $blogs as $key => $details) {
                             $r .= '- <a href="' . $details->siteurl . '" title="' . htmlentities($details->siteurl, 0, 'UTF-8') . '" target="_new">' . $details->blogname . '</a><br/>';
                         }
                     }
                 }
                 $r .= "</td>";
                 break;
             case 'wgstatus':
                 $r .= "<td {$attributes}>" . $statushtml . "</td>";
                 break;
         }
     }
     $r .= '</tr>';
     return $r;
 }
Ejemplo n.º 4
0
function wangguard_wpmu_custom_columns($column_name, $userid)
{
    wangguard_user_custom_columns('', $column_name, $userid, true);
}