public function column_default($log, $col) { global $wpdb; // вывод if (0) { } elseif ($col == 'ip') { return '<a title="' . __('Поиск по IP', 'dem') . '" href="' . esc_url(add_query_arg(array('ip' => $log->ip, 'poll' => null))) . '">' . long2ip($log->ip) . '</a>'; } elseif ($col == 'qid') { if (!($poll = $this->cache('polls', $log->qid))) { $poll = $this->cache('polls', $log->qid, DemPoll::get_poll($log->qid)); } $url = Dem::$i->admin_page_url(); return esc_html($poll->question) . ' <div class="row-actions"> <span class="edit"><a href="' . add_query_arg(array('edit_poll' => $poll->id), $url) . '">' . __('Редактировать', 'dem') . '</a> | </span> <span class="edit"><a href="' . esc_url(add_query_arg(array('ip' => null, 'poll' => $log->qid))) . '">' . __('Логи опроса', 'dem') . '</a></span> </div> '; } elseif ($col == 'userid') { if (!($user = $this->cache('users', $log->userid))) { $user = $this->cache('users', $log->userid, $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE ID = " . (int) $log->userid)); } return esc_html(@$user->user_nicename); } elseif ($col == 'aids') { $out = array(); foreach (explode(',', $log->aids) as $aid) { if (!($answ = $this->cache('answs', $aid))) { $answ = $this->cache('answs', $aid, $wpdb->get_row("SELECT * FROM {$wpdb->democracy_a} WHERE aid = " . (int) $aid)); } $out[] = '- ' . esc_html($answ->answer); } return implode('<br>', $out); } else { return isset($log->{$col}) ? $log->{$col} : print_r($log, true); } }
public function column_default($log, $col) { global $wpdb; // вывод if (0) { } elseif ($col == 'ip') { return '<a href="' . esc_url(add_query_arg(array('ip' => $log->ip, 'poll' => null))) . '">' . long2ip($log->ip) . '</a>'; } elseif ($col == 'qid') { if (!($poll = $this->cache('polls', $log->qid))) { $poll = $this->cache('polls', $log->qid, DemPoll::get_poll($log->qid)); } return '<a href="' . esc_url(add_query_arg(array('ip' => null, 'poll' => $log->qid))) . '">' . esc_html($poll->question) . '</a>'; } elseif ($col == 'userid') { if (!($user = $this->cache('users', $log->userid))) { $user = $this->cache('users', $log->userid, $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE ID = " . (int) $log->userid)); } return esc_html(@$user->user_nicename); } elseif ($col == 'aids') { $out = array(); foreach (explode(',', $log->aids) as $aid) { if (!($answ = $this->cache('answs', $aid))) { $answ = $this->cache('answs', $aid, $wpdb->get_row("SELECT * FROM {$wpdb->democracy_a} WHERE aid = " . (int) $aid)); } $out[] = '- ' . esc_html($answ->answer); } return implode('<br>', $out); } else { return isset($log->{$col}) ? $log->{$col} : print_r($log, true); } }