From 088fff12065ef6278f7a4ac3e2708a54d386a840 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 20 Apr 2016 21:57:25 +0100 Subject: [PATCH] wp table --- lib/php/db/wp.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lib/php/db/wp.php diff --git a/lib/php/db/wp.php b/lib/php/db/wp.php new file mode 100644 index 00000000..608b00d1 --- /dev/null +++ b/lib/php/db/wp.php @@ -0,0 +1,47 @@ +_table = $table; +#debug($table); + #$fields = $this->get_columns(); + #debug($sort); + $this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns()); + return; + } + + protected function column_default( $item, $column_name ) { echo $item[$column_name]; } + + public function get_columns() { + static $cols = array(); + if (empty($cols)) { + foreach ($this->_table->fields() as $f) { + $cols[$f->name] = $f->prettyText($f->name); + } + #$cols = array_map(function($k,$v){return array($v=>$this->_table->prettyText($v));},$fields,$fields); + } + return $cols; + } + + protected function get_sortable_columns() { + $sort = array(); + foreach ($this->get_columns() as $k =>$v) { + #$sort[$k] = array($v => array($k,false)); + $sort[$k] = array($k,false); + } + return $sort; + return $this->get_columns(); + } + + public function prepare_items() { + $sql = $this->_table->rows_sql($opt); + $st = $GLOBALS['wpdb']->prepare($sql); + return $st->execute(); + } + +} +?> -- 2.47.3