public function column_default($item, $column_name) { //example: $item->getMetaValue('CurrentUserID') if (!$this->_plugin->settings->GetDatetimeFormat()) { $datetimeFormat = 'h:i:s.$$$&\\n\\b\\s\\p;A'; } else { $datetimeFormat = 'H:i:s.$$$'; } switch ($column_name) { case 'read': return '<span class="log-read log-read-' . ($item->is_read ? 'old' : 'new') . '" title="' . __('Click to toggle.', 'wp-security-audit-log') . '"></span>'; case 'type': return str_pad($item->alert_id, 4, '0', STR_PAD_LEFT); case 'code': $code = $this->_plugin->alerts->GetAlert($item->alert_id); $code = $code ? $code->code : 0; $const = (object) array('name' => 'E_UNKNOWN', 'value' => 0, 'description' => __('Unknown error code.', 'wp-security-audit-log')); $const = $this->_plugin->constants->GetConstantBy('value', $code, $const); return '<span class="log-type log-type-' . $const->value . '" title="' . esc_html($const->name . ': ' . $const->description) . '"></span>'; case 'crtd': return $item->created_on ? str_replace('$$$', substr(number_format(fmod($item->created_on + $this->_gmt_offset_sec, 1), 3), 2), date('Y-m-d<\\b\\r>' . $datetimeFormat, $item->created_on + $this->_gmt_offset_sec)) : '<i>unknown</i>'; case 'user': $username = $item->GetUsername(); if ($username && ($user = get_user_by('login', $username))) { $image = get_avatar($user->ID, 32); $uhtml = '<a href="' . admin_url('user-edit.php?user_id=' . $user->ID) . '" target="_blank">' . esc_html($user->display_name) . '</a>'; $roles = $item->GetUserRoles(); if (is_array($roles) && count($roles)) { $roles = __(esc_html(ucwords(implode(', ', $roles)))); } else { if (is_string($roles) && $roles != '') { $roles = __(esc_html(ucwords(str_replace(array("\"", "[", "]"), " ", $roles)))); } else { $roles = '<i>' . __('Unknown', 'wp-security-audit-log') . '</i>'; } } } else { $image = '<img src="' . $this->_plugin->GetBaseUrl() . '/img/wordpress-logo-32.png" class="avatar avatar-32 photo" width="32" height="32" alt=""/>'; $uhtml = '<i>' . __('System', 'wp-security-audit-log') . '</i>'; $roles = ''; } return $image . $uhtml . '<br/>' . $roles; case 'scip': $scip = $item->GetSourceIP(); if (is_string($scip)) { $scip = str_replace(array("\"", "[", "]"), "", $scip); } $oips = array(); //$item->GetOtherIPs(); // if there's no IP... if (is_null($scip) || $scip == '') { return '<i>unknown</i>'; } // if there's only one IP... $link = "http://whatismyipaddress.com/ip/" . $scip . "?utm_source=plugin&utm_medium=referral&utm_campaign=WPSAL"; if (count($oips) < 2) { return "<a target='_blank' href='{$link}'>" . esc_html($scip) . '</a>'; } // if there are many IPs... $html = "<a target='_blank' href='http://whatismyipaddress.com/ip/{$scip}'>" . esc_html($scip) . '</a>' . ' <a href="javascript:;" onclick="jQuery(this).hide().next().show();">(more…)</a><div style="display: none;">'; foreach ($oips as $ip) { if ($scip != $ip) { $html .= '<div>' . $ip . '</div>'; } } $html .= '</div>'; return $html; case 'site': $info = get_blog_details($item->site_id, true); return !$info ? 'Unknown Site ' . $item->site_id : '<a href="' . esc_attr($info->siteurl) . '">' . esc_html($info->blogname) . '</a>'; case 'mesg': return '<div id="Event' . $item->id . '">' . $item->GetMessage(array($this, 'meta_formatter')) . '</div>'; case 'data': $url = admin_url('admin-ajax.php') . '?action=AjaxInspector&occurrence=' . $item->id; return '<a class="more-info thickbox" title="' . __('Alert Data Inspector', 'wp-security-audit-log') . '"' . ' href="' . $url . '&TB_iframe=true&width=600&height=550">…</a>'; default: return isset($item->{$column_name}) ? esc_html($item->{$column_name}) : 'Column "' . esc_html($column_name) . '" not found'; } }